Skip to content

fix: update the default model, quote workflow inputs, cut at words - #17

Merged
abrichr merged 6 commits into
mainfrom
fix/ledger-wave2-2026-10-14
Oct 14, 2026
Merged

abrichr merged 6 commits into
mainfrom
fix/ledger-wave2-2026-10-14

Conversation

@abrichr

@abrichr abrichr commented Oct 14, 2026

Copy link
Copy Markdown
Member

This branch fixes three problems in drafting and posting.

  • The default drafting model was a deprecated Claude snapshot. Current models think by default, which broke how herald read the reply.
  • The weekly-digest workflow let a crafted dispatch input run shell commands in the step that holds the posting secrets.
  • herald publish cut drafts in the middle of words and links, and counted X posts in Python characters instead of X's weighted count.

Fixes

Problem Change Regression test Ref
The default model was claude-sonnet-4-20250514, a deprecated snapshot written in five places. The workflow had no way to change it. config.DEFAULT_MODEL = "claude-sonnet-5-5" is the only default. A blank HERALD_DEFAULT_MODEL falls back to it, compose() reads the setting, and the workflow passes vars.HERALD_DEFAULT_MODEL. tests/test_config.py, tests/test_no_retired_models.py, test_compose_without_model_uses_the_setting, test_publish_step_lets_a_repository_variable_set_the_model B263
Current models think by default. compose() read content[0].text, which raises AttributeError on a thinking block. Text blocks are read by type. max_tokens goes from 2000 to 16000, because thinking counts toward it. A reply with no text raises ComposeError, which the CLI prints as one line. test_compose_reads_text_after_a_thinking_block, test_compose_without_text_raises, test_reply_without_text_prints_one_line B263
A reply cut off by max_tokens or a refusal went to the plain-text fallback, so half-written JSON became the draft for every platform. compose() raises ComposeError for those two stop reasons. test_compose_rejects_an_unfinished_reply (2 cases) B263
The workflow put inputs.days, inputs.content_type and step outputs straight into run: scripts. A dispatch with days set to 7"; echo ...; echo " ran the command. Inputs and outputs reach the shell through env: and are quoted. The params step accepts only digest, release or spotlight and a whole number of days, and stops otherwise. test_run_scripts_contain_no_expressions, test_params_step_rejects_days_that_are_not_a_number (6 cases), test_params_step_rejects_an_unknown_content_type, test_publish_step_passes_dry_run_to_herald B268
X, LinkedIn and Discord drafts were cut at a fixed number of Python characters, inside words and links and with no ellipsis. On X, 240 CJK characters (420 by X's count) went out unchanged, and a long link that X counts as 23 was cut. A new shorten() in platforms/base.py cuts after the last whole word that fits and adds …. The X publisher measures with x_weighted_length. TestShorten (3), the word-boundary, CJK and long-link tests in tests/test_platforms.py, test_non_json_fallback_does_not_cut_mid_word B250
x_weighted_length counted a link followed by … as one link of 23. X ends the link before the ellipsis and counts the ellipsis as 2, so a shortened post that ended in a link could go out at 281. … now ends a link, like other trailing punctuation. The count can only go up, so herald post still refuses everything it refused before. test_ellipsis_after_a_link_is_not_part_of_it, test_publish_counts_an_ellipsis_after_a_link B250
When gh failed, the collectors returned an empty list without a word, so a failed run looked like a quiet week. They print the reason on stderr. test_collect_releases_failure_says_why, test_collect_prs_without_gh_says_so B250
Every Discord embed was titled "Weekly Digest", including release and spotlight runs. The params step sets the title from the content type. test_params_step_titles_a_spotlight, test_publish_step_titles_the_embed_from_the_content_type B250

Not fixed here

  • Running herald publish again after a partial failure posts again to the platforms that already succeeded. This needs a decision: should publish keep an append-only ledger like herald post and skip a platform that already got the same draft?
  • consilium keeps its Claude seat on claude-sonnet-4-6. consilium reads content[0].text and can pass temperature, so a model that thinks by default would break it. That's a follow-up for openadapt-consilium. The gpt-4o seat wasn't checked.
  • The drafting call has no server-side refusal fallback. The locked anthropic SDK (0.84.0) doesn't support the fallbacks parameter. A refusal now stops the run with a one-line message.
  • The preview and the [DRY RUN] Would post line show each draft before the publisher shortens it.
  • No live API call was made. The model id comes from Anthropic's model list.
  • The log of the failed 2026-07-13 digest run has expired (HTTP 410), so the reported 404 for the old model id couldn't be checked again. Anthropic's model list marks that id deprecated.

How it was tested

  • On origin/main (ab68343) with this branch's test files copied in: 40 failed, 190 passed. Each failure is the defect, not a missing name. For example, the thinking-block tests raise AttributeError, the injection tests print INJECTED-42 because the shell ran the input, and the CJK test sends 420 weighted characters.
  • On this branch: 230 passed on Python 3.12 and on Python 3.10 (uv sync --extra dev --no-sources, as CI does).
  • The three checker commits add tests that failed on 33a3a76 before the fixes (4 failed).
  • ruff check . and actionlint (which runs shellcheck on each run: script) report nothing. uv build builds the sdist and the wheel.
Tests that fail on origin/main
tests/test_cli.py::TestModelCallErrors::test_reply_without_text_prints_one_line
tests/test_collector.py::TestGitHubReleases::test_collect_releases_failure_says_why
tests/test_collector.py::TestGitHubReleases::test_collect_prs_without_gh_says_so
tests/test_composer.py::TestCompose::test_non_json_fallback_does_not_cut_mid_word
tests/test_composer.py::TestCompose::test_compose_without_model_uses_the_setting
tests/test_composer.py::TestCompose::test_compose_reads_text_after_a_thinking_block
tests/test_composer.py::TestCompose::test_compose_without_text_raises
tests/test_composer.py::TestCompose::test_compose_rejects_an_unfinished_reply[max_tokens]
tests/test_composer.py::TestCompose::test_compose_rejects_an_unfinished_reply[refusal]
tests/test_config.py::test_empty_env_keeps_default_model
tests/test_config.py::test_config_names_the_default_once
tests/test_no_retired_models.py::test_no_retired_model_ids[.env.example]
tests/test_no_retired_models.py::test_no_retired_model_ids[README.md]
tests/test_no_retired_models.py::test_no_retired_model_ids[herald/composer.py]
tests/test_no_retired_models.py::test_no_retired_model_ids[herald/config.py]
tests/test_platforms.py::TestDiscordPublisher::test_publish_cuts_long_content_at_a_word_boundary
tests/test_platforms.py::TestTwitterPublisher::test_publish_truncates_to_280
tests/test_platforms.py::TestTwitterPublisher::test_publish_cuts_at_a_word_boundary
tests/test_platforms.py::TestTwitterPublisher::test_publish_counts_cjk_as_x_does
tests/test_platforms.py::TestTwitterPublisher::test_publish_keeps_a_long_link_that_x_counts_as_23
tests/test_platforms.py::TestTwitterPublisher::test_publish_counts_an_ellipsis_after_a_link
tests/test_platforms.py::TestLinkedInPublisher::test_publish_cuts_long_content_at_a_word_boundary
tests/test_platforms.py::TestShorten::test_text_that_fits_is_unchanged
tests/test_platforms.py::TestShorten::test_drops_a_trailing_comma_before_the_ellipsis
tests/test_platforms.py::TestShorten::test_one_long_word_is_cut_inside_the_word
tests/test_verbatim.py::TestWeightedLength::test_ellipsis_after_a_link_is_not_part_of_it
tests/test_workflows.py::test_publish_step_passes_dry_run_to_herald
tests/test_workflows.py::test_publish_step_lets_a_repository_variable_set_the_model
tests/test_workflows.py::test_run_scripts_contain_no_expressions[release-announce.yml]
tests/test_workflows.py::test_params_step_rejects_days_that_are_not_a_number (6 cases)
tests/test_workflows.py::test_params_step_rejects_an_unknown_content_type
tests/test_workflows.py::test_params_step_passes_valid_dispatch_inputs
tests/test_workflows.py::test_params_step_uses_digest_defaults_on_schedule
tests/test_workflows.py::test_params_step_titles_a_spotlight
tests/test_workflows.py::test_publish_step_titles_the_embed_from_the_content_type

The three TestShorten tests fail on an import because shorten() is new. The publisher tests above them cover the same behavior and fail on the output.

Before merging

  • The weekly-digest workflow is enabled. Its next scheduled run, Monday 2026-10-19 at 15:00 UTC, posts live. Until this merges, that run uses the code on main. After merging, dispatch it once with dry_run set to true and check that it finishes without a model error. If you can't do that before Monday, disable the workflow until you can.
  • Optional: set the repository variable HERALD_DEFAULT_MODEL to choose a different drafting model.

🤖 Generated with Claude Code

abrichr and others added 6 commits October 14, 2026 09:57
The default drafting model was the dated snapshot claude-sonnet-4-20250514,
written in config.py, twice more in composer.py, in .env.example and in the
README. The API now returns 404 for it, and the scheduled weekly digest
failed on 2026-07-13 with that error. The workflow had no way to change the
model without a code change.

Changes:
- config.py names the default once, DEFAULT_MODEL = "claude-sonnet-5-5".
  An empty HERALD_DEFAULT_MODEL falls back to it, so an unset workflow
  variable can't blank the model.
- compose() uses the default_model setting when no model is passed,
  instead of repeating the literal.
- compose() reads text blocks by type. Current models think by default,
  so a reply can start with a thinking block, and content[0].text raised
  AttributeError. max_tokens goes from 2000 to 16000 because thinking
  counts toward it. A reply with no text raises ComposeError, which the
  CLI prints as one line.
- The consilium council keeps a separate Claude seat, claude-sonnet-4-6,
  because consilium reads the first reply block as text. The README says
  so.
- The weekly-digest workflow passes vars.HERALD_DEFAULT_MODEL to herald.
- .env.example no longer pins a model; the README names the new default.
- tests/test_no_retired_models.py fails if shipped code, docs or
  workflows name a retired model id.

Ledger: B263

Signed-off-by: abrichr <richard.abrich@mldsai.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The "Determine content type" step wrote ${{ inputs.content_type }} and
${{ inputs.days }} straight into its run script, and the publish step
did the same with the step outputs. GitHub substitutes those
expressions before the shell starts, so a dispatch with days set to
7"; echo INJECTED; echo " ran the injected command. Anyone who can
dispatch the workflow could run commands in the publish step, which
holds the posting secrets.

Changes:
- Both steps read inputs and outputs from env: and quote them.
- The params step accepts only digest, release or spotlight and a whole
  number of days, and stops with an error otherwise, so a newline can't
  add a second output either.
- The dry-run flag also comes from env.
- tests/test_workflows.py fails if any run: script in any workflow
  contains an expression. It also runs the params step in bash, after
  substituting expressions the way the runner does, with injection
  attempts and with valid inputs.

Ledger: B268

Signed-off-by: abrichr <richard.abrich@mldsai.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Main already fixed the README install line, the release collector's
JSON parsing and the dry-run input. Three defects were left.

- X, LinkedIn and Discord drafts were cut at a fixed number of Python
  characters, inside a word or a link and with no ellipsis. For X the
  count was also wrong: a long link that X counts as 23 was cut, and 240
  CJK characters (420 by X's count) were sent as they were. A new
  shorten() helper in platforms/base.py cuts after the last whole word
  that fits and adds an ellipsis. The X publisher measures with
  x_weighted_length, the counter herald post already uses. The composer's
  plain-text fallback no longer cuts the X draft at 280 first, and cuts
  the summary at a word.
- When gh failed (not installed, timed out, signed out, or not JSON),
  the collectors returned an empty list without a word, so a failed run
  looked like a quiet week. They now print the reason on stderr.
- The weekly-digest workflow titled every Discord embed "Weekly Digest",
  including release and spotlight runs. The params step now sets the
  title from the content type.

The README describes the new shortening. A test checks that every
README install command uses the GitHub URL, since the package isn't on
PyPI.

Not changed: re-running publish after a partial failure still posts
again to the platforms that succeeded. That needs a decision on
whether publish should keep a ledger like herald post.

Ledger: B250

Signed-off-by: abrichr <richard.abrich@mldsai.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
compose() fell through to its plain-text fallback whenever the reply
wasn't valid JSON. A reply cut off by max_tokens or a refusal is usually
half-written JSON, so the fallback made that fragment the draft for
Discord, X and LinkedIn, and `herald publish` would post it. Current
models think by default and thinking counts toward max_tokens, so a cut-off
reply is more likely than before.

compose() now raises ComposeError when the stop reason is max_tokens or
refusal, and the CLI prints it as one line. The composer tests now check
the exception by name, so on code without ComposeError they fail on the
behavior (an AttributeError, or no error) rather than on an import.

Ledger: B263

Signed-off-by: abrichr <richard.abrich@mldsai.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
x_weighted_length counted a link followed directly by U+2026 as one link
of 23. X ends the link before the ellipsis and counts the ellipsis as 2.
`herald publish` adds an ellipsis when it shortens an X draft, so a draft
whose last whole word was a link could be sent at 281 by X's count, and X
would refuse it.

The ellipsis now ends a link, like the other trailing punctuation. The
count only goes up, so `herald post` refuses at least everything it
refused before.

Ledger: B250

Signed-off-by: abrichr <richard.abrich@mldsai.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- test_config reads the default from the settings field, so on the old
  code the blank-variable test fails because the model is blank.
- The CLI test runs the real compose() with a reply that holds only a
  thinking block, which used to raise AttributeError.
- The workflow injection payloads print INJECTED-42 only when the shell
  evaluates them, and the tests check that marker first, in the output
  file too.
- The dry-run test checks that the publish script passes DRY_RUN_FLAG.
- The model-id guard calls the Sonnet 4 snapshot deprecated, as
  Anthropic's model list does, and adds two ids past their retirement
  date. The config comment no longer claims a 404 that the expired run
  log can't confirm.

Ledger: B263, B268

Signed-off-by: abrichr <richard.abrich@mldsai.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@abrichr
abrichr merged commit 50392aa into main Oct 14, 2026
3 checks passed
@abrichr
abrichr deleted the fix/ledger-wave2-2026-10-14 branch October 14, 2026 16:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant