Repository navigation
feat: add herald post to post approved text to X verbatim - #14
Merged
Merged
Conversation
Adds a publish path that posts an approved file exactly as written: no model call, no truncation, no rewriting. - X weighted length check (twitter-text v3 weights, every link counts 23); overlength text is refused, never cut. - --expect-sha256 binds the post to the approved text hash. - Three results with exit codes: published (0), not_sent (3), uncertain (4). 4xx and connect failures are not_sent; 5xx, read timeouts, resets, duplicate-content refusals and 2xx-without-id are uncertain. - Append-only JSON Lines ledger keyed by content hash. A write-ahead "uncertain" record precedes every request, so a killed job is reconciled. - After an uncertain attempt the next run reads the account's own recent posts first; a match is recorded as published, an absence needs --retry. - --precheck-timeline skips posting when the text is already on the timeline (covers a lost ledger). - tweepy requests get a timeout; dry run never opens the account. - LinkedIn stays manual copy-paste per its API terms (exit not_sent). The existing LLM collect/compose/publish commands are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review fixes for the verbatim `herald post` path. - Length: a bare domain (no http/https) now counts as 23 or its own length, whichever is longer. A long dotted word that X leaves as plain text used to count as 23, so the check could pass text X would refuse. An overlength refusal caused by such a word says to add https://. - Dry run after an uncertain attempt now reports `uncertain` (exit 4) instead of `not_sent`, because an earlier request may have posted. A dry run after a reconciled check says a live run needs --retry. - A --retry run reads the account's recent posts again before sending, so a slow earlier post that appears after the first check is not posted twice. If that read fails, nothing is sent. - Reconciliation accepts any matching recent post, including one older than the attempt. This ends the loop where X refused duplicate text, the check filtered the older post out, and --retry hit the same refusal. - Messages in uncertain states say "This run sent nothing; the earlier attempt may still have posted" instead of "Nothing was sent". - Ledger write failures during a timeline check return a result instead of a traceback; a failed reconciliation record stays `uncertain`. - HERALD_POST_LEDGER now works from .env (it was only read from the process environment), matching .env.example. - --expect-sha256 ignores case and surrounding whitespace. The README and the mismatch message explain that the hash covers the text without trailing newlines and how to print it with --dry-run --json. - README: result table covers found-on-account and reconciled cases, the 2-minute wait, the retry re-read, and ledger durability. --retry help no longer says the check "proved" anything. Each fix has a regression test that fails on the previous commit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review fixes for `herald post`. - HERALD_DRY_RUN=true now keeps `herald post` preview-only, as it already did for `herald publish`. Before, a live post went out with the setting on. - An unreadable ledger reports `uncertain` (exit 4), not `not_sent`. A full disk can cut the "published" record short right after X accepted the post, so a broken ledger can't rule out an earlier post. - If the X account can't be opened (for example, missing credentials) after an earlier `uncertain` attempt, the result stays `uncertain`. - The message after a successful post with a failed ledger write no longer promises what the next run will do; it asks for a ledger check. - Docs no longer claim the length count is never shorter than X's: an explicit link always counts as 23, and if X counts more and refuses, the result is `not_sent`. The test for long explicit links uses a real TLD. - README: one run per ledger at a time, HERALD_DRY_RUN, the extra `uncertain` cases, and a link to LinkedIn's API terms (section 3.1). Each behavior fix has a regression test that fails on the previous commit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
herald postposts an approved text file to X exactly as written, with no model call. It never shortens or rewrites the text; if the text is too long, it refuses and says by how much. Each run ends in one of three results with its own exit code, so a publishing job knows whether the post exists. Existing commands are unchanged.What changes
Checks before anything is sent
--expect-sha256ties the post to the approved text, so an edit after approval stops it. The hash covers the text without trailing newlines;--dry-run --jsonprints it ascontent_sha256.https://counts as 23 or its full length, whichever is longer. Overlength text is refused, never cut.Results and exit codes
publishednot_sentuncertainattempt found no match.uncertainHerald also reports
uncertain, without sending, when it can't read the ledger or can't open the account after an earlieruncertainattempt, because an earlier post can't be ruled out.No blind retry
uncertainledger record before each request, so a crash or cancelled job leaves a record the next run checks.uncertainresult, the next run reads the account's 20 most recent posts first. A match is recorded as published, and nothing is sent.uncertain. After that, posting again requires--retry, which reads the recent posts once more and sends nothing if the read fails.Other behavior
--precheck-timelineskips the post if the text is among the 20 most recent posts (covers a lost ledger).--dry-runorHERALD_DRY_RUN=trueruns only the local checks and never opens the X account.--ledgerorHERALD_POST_LEDGER(environment or.env) sets the ledger path, which a live post requires.--platform linkedinexits withnot_sentand asks you to paste the text yourself, because LinkedIn's API Terms of Use (section 3.1) don't allow automated posting.Known limits
herald postat a time per ledger. A GitHub Actions concurrency group is enough.How it was tested
pytest -q: 131 passed, including 56 intests/test_verbatim.py, which fake the X account and make no network calls.ruff check .: all checks passed.uv build: the sdist and wheel build.--platform linkedin, and a missing ledger each returnnot_sent(exit 3). A corrupt ledger returnsuncertain(exit 4).HERALD_DRY_RUN=truewith credentials set never opens the account.Before merging
Merging doesn't post anything. Items 1 to 4 are needed before the first live post.
HERALD_TWITTER_*settings (OAuth 1.0a user tokens for the company account) where the publishing job runs.HERALD_REFat the merge commit.herald publish's LinkedIn posting (/v2/ugcPosts, which may conflict with the same terms) and its 280-character cut for X. This PR leaves both as they are.🤖 Generated with Claude Code