Repository navigation
simplify: one tested review-anchor resolver, skill depth into references - #971
Conversation
Two GitHub behaviours make a review's `.commit_id` unreadable on its own — a thread reply gets wrapped in a synthetic zero-body review anchored at the then-current head, and a force-push re-points earlier reviews at the new head. Every caller that reads an anchor has to discount both, and five did: three sites in the review skill, two in weekly. All five were untested shell, each carrying its own paragraph of rationale, and they had already drifted — weekly documents that its filter ordering deliberately differs from review's. They collapse into bot-review-state.sh, which resolves the whole question once and emits it as JSON: the newest substantive review and whether a rewrite postdates it, whether anything genuinely anchors the current head, the orphan body a partially-failed review POST left behind, and the fresh and stale approvals. Each call site now reads one field. 19 tests cover the semantics, including the ordering subtlety weekly had split two ways: newest-then-test, so a superseded pre-rewrite approval isn't dismissed while the live one stands. running-in-ci was 677 lines against the 500-line cap the authoring skill sets, and its remedy for that is splitting into references/, which cost nothing until read. Grounded-analysis depth, the other-repos rules, and the bar for proposing a skill PR move there; SKILL.md keeps the rule and a pointer. The one real contraction is "rewriting is authoring", now a sentence rather than a section with a worked example. Every bundled skill is now under the cap.
tend-agent
left a comment
There was a problem hiding this comment.
One finding, in the head resolution the new script now owns for all five call sites.
gh pr view --json commits is not paginated — api/query_builder.go issues commits(first: 100), and the connection comes back oldest-first. On a PR with more than 100 commits .commits[-1].oid is commit #100, not the head, so head_sha names a mid-branch commit and every head-keyed field derived from it goes quiet rather than wrong-loud: at_head finds nothing (the step 5 pre-post guard stops firing, so a fold-in re-run can post a second review on a commit it already reviewed), and orphan_id finds nothing (a 422 recovery POSTs a duplicate instead of editing the orphan body). weekly's redundant-approval guard fails the same way — its own HEAD_SHA never matches fresh_approval_sha, so approvals accumulate on one commit. gh pr view --json headRefOid answers directly and can't truncate.
The pattern is in three skill sites too, all inside these hunks, so I've suggested each; test_the_head_is_the_last_commit_not_the_first and the COMMITS_JSON fixture move with the script change (adding headRefOid alongside commits in the fixture keeps the fake gh serving both). Happy to push the lot as a commit if you'd rather not click through four.
Nothing else — the resolver's semantics match what each of the five call sites was doing, including the ordering split weekly had documented as deliberate, and the references/ move preserves every section from the old running-in-ci.
What I checked
- Ran the script live against #971 and #970 — output shape and the
fresh_approval_shaon #970's approval both correct. uv run pytestingenerator/: 510 passed atff781fa.ruff check/ruff format --checkclean at the pinnedv0.14.11;shellcheckclean on the new script.- Trailing comma in the jq object construction parses on jq 1.6 as well as the runner's 1.7, so no floor is raised there.
- Field-by-field against the five replaced snippets:
fresh_approval_shafilter-then-last,stale_approval_idlast-then-test,at_headcomposing the substantive + rewrite + anchor filters in the same order as the old pre-post guard,orphan_idadding the body-length test.DISMISSEDdropping out of both approval fields is what keepsweeklyfrom re-dismissing, andff781fapins it. - Section-by-section diff of
running-in-ci's headings against the three newreferences/files: every subsection lands, and the two skills that named Filing Issues in Other Repos were both retargeted to Other Repos.
`gh pr view --json commits` issues `commits(first: 100)` unpaginated and oldest-first, so past 100 commits `.commits[-1]` is commit #100 rather than the head. Every head-keyed field then matches nothing and goes quiet rather than wrong-loud: the pre-post guard stops firing, so a fold-in re-run posts a second review on a commit it already reviewed; the 422 recovery finds no orphan and duplicates instead of editing; and in review's moved-head check the truncation inverts the guard, so a push that did move the head reads as "HEAD hasn't moved" and the review posts against the stale commit. weekly's redundant-approval guard fails the same way, collecting an approval per run on one commit. Four sites: the resolver plus three in the skills. `headRefOid` is the head by definition and can't truncate. The fixture now serves a deliberately wrong-last `commits` list alongside `headRefOid`, so going back to the old read fails nine tests rather than passing on a short PR.
Release 0.1.16: the version bump, the lockfile sync, and the `CHANGELOG.md` section that `pypi-release.yaml` publishes verbatim as the release notes. 11 commits since 0.1.15. On the shipped surface: a cost gate on self-initiated fixes (#960), tested CI-poll scripts and an anchor-based run window (#965), one review-anchor resolver plus the head-resolution fix past 100 commits (#971), the mention engagement gate as a tested script (#970), `review-reviewers` paused to manual dispatch (#966), the stale re-anchored approval on rebased dependency PRs (#890), and a line-anchored evidence-log selector (#963). After merge: tag `0.1.16` to publish, then regenerate tend's own workflows with `uvx tend@latest init` and restamp `review-reviewers.yaml`, whose action pin `init` never rewrites. > _This was written by Claude Code on behalf of max-sixty_
Automated nightly regeneration of tend's workflow files. **tend version:** 0.1.15 → 0.1.17 **Notable changes** - 👀 reactions now mark a session in flight: the bot reacts when an issue or PR is opened, and the reaction comes off when the session ends (max-sixty/tend#974, max-sixty/tend#979). - Mention gating was reworked — coarser pre-check gates, tested poll scripts, and an anchor-based run window replace the hand-rolled matching (max-sixty/tend#965, max-sixty/tend#971). - Self-initiated fixes are now gated on cost as well as evidence, so the bot doesn't open a PR whose value doesn't justify the session (max-sixty/tend#960). - `tend check` reads the bot's own bypass verdict on repos where the actor list is withheld, instead of reporting a false FAIL (max-sixty/tend#976). - Weekly no longer trusts a re-anchored approval on a rebased dependency PR (max-sixty/tend#890), and review-reviewers is paused as a scheduled sweep, kept as a manual spot-check (max-sixty/tend#966). Compare: max-sixty/tend@0.1.15...0.1.17 Co-authored-by: worktrunk-bot <[email protected]>
`running-in-ci` is loaded by every tend session and `review` by every review, and both carried text that a minority of sessions reach. In a sample of 39 leaf sessions, 3 pushed, 1 opened a PR, 4 replied inline, none dismissed an approval or read another run's log; of 16 reviews, 5 posted, 4 approved, 1 re-targeted after a mid-review push, none ran in draft mode or hit a 422. Every session paid for the text anyway — about half of leaf's spend is the fixed per-turn payload, and these two files are the largest part of it. ## Move action-specific guidance into `references/` `running-in-ci/SKILL.md` keeps the rules every session needs (overlay loading, reading context, restrictions, ending the turn, weighing a fix, conversation conduct, reader-facing prose) and gains a References list naming each `references/` file and the action that triggers reading it. The moved sections — PR creation, pushing, CI monitoring, posting mechanics and the pre-post re-fetch, dismissing a standing approval, directives on others' work, other runs' session logs — are verbatim in the new files. The `author-association.md` symlink moves into `references/` with the section that uses it. 52 KB → 20 KB. `review/SKILL.md` keeps steps 0–5, the verdict rules, and the APPROVE and preflight recipes; draft mode, re-targeting after a mid-review push, the pre-approve settled-rollup check with the post-approve CI outcomes, and the inline-suggestion payload with 422 recovery move to `references/`, listed under the workflow heading with the step that reads each. 41 KB → 26 KB. Skills that cited a moved section by heading now cite the reference file, and every cross-skill citation carries the plugin prefix (`/tend-ci-runner:running-in-ci`). Pointers within the review skill name the step (**Submit**, **Pre-flight checks**) rather than its number. The Codex `AGENTS.md` tail tells Codex to read a named reference in full before the action, and CLAUDE.md's authoring rules record the placement rule. ## Decide the review pre-flight in the script `review_preflight.py start` emitted `last_review_sha`, `force_full_review`, `force_pushed_since`, `author` and `bot_login`, and the skill spent five paragraphs combining them into two decisions. Every input was already in the snapshot, so the combination is the script's to make: `start` now emits `already_reviewed` and `self_authored`, and the step says what to do with each. The pre-flight step becomes a three-bullet list keyed on `already_reviewed`, `is_draft` and `incremental_path`. `already_reviewed` reads `at_head` — the rewrite-aware field the same snapshot has carried since the anchor resolver landed in #971. The raw `last_review_sha == head_sha` comparison the prose used reports a rewritten head as reviewed, because a force push re-points an earlier review's `.commit_id` at the new head; that is what the deleted force-push paragraph existed to work around. `incremental_path` is likewise non-null only when an incremental applies, so the `force_full_review` guard on the trivial-skip rule was already enforced by the script. Also dropped, as prose restating something already written down: the second copy of what `$TMPDIR/reviewed-head` holds, the settled-rollup criteria that live in `references/approving.md`, and the preflight's command-mode internals. Left alone deliberately: having `start` skip outright when nothing new was said. The exception — an unanswered question directed at the bot — is not a crisp boundary, and getting it wrong means a maintainer question goes unanswered, while the payoff is one saved session boot. `head_sha` also stays in the snapshot: it is the session log's only record of which commit a run that finishes without posting was about. `generator/tests/test_review_preflight.py` gains three cases — a review standing on the head, a force push that must not read as reviewed, and `ready_for_review` overriding both. `generator/tests/test_repo_pins.py` gains `test_skill_reference_citations_resolve`: with the rules behind rarer actions now reachable only through a `references/` citation, a citation pointing nowhere would leave a session acting without the rule while nothing fails, so every cited name must exist in some skill's `references/`. The merge from main takes #1212's deletion of the skill-text assertions this change would otherwise have reworded. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01PoS7vwmM9mqPmS2UGBLJiw > _This was written by Claude Code on behalf of max-sixty_ --------- Co-authored-by: Claude Fable 5.1 <[email protected]>
Two rounds of cutting, both aimed at the same shape: logic that mattered enough to be right, living in prose that nothing checked.
One resolver for "which review anchors this head"
A review's
.commit_idcan't be read on its own. Replying to a review thread makes GitHub wrap the reply in a synthetic zero-body review anchored at the then-current head, so the newest record routinely points at a commit nothing reviewed. And a force-push doesn't just move the head — it re-points earlier reviews'.commit_idat the new one, so a review of code that no longer exists reports the current head.Every caller that reads an anchor has to discount both, and five did: three sites in
review(step 1's anchor resolution, step 5's pre-post guard, step 6's orphan probe) and two inweekly(the redundant-approval guard and the stale-approval dismissal). All five were untested shell, each carrying its own paragraph of rationale — and they had already drifted, to the point thatweeklydocuments its filter ordering as deliberately different fromreview's.plugins/tend-ci-runner/scripts/bot-review-state.shanswers the question once and emits it as JSON — the newest substantive review and whether a rewrite postdates it, whether anything genuinely anchors the current head, the orphan body a partially-failed review POST left behind, and the fresh and stale approvals. Each call site now reads one field.The consequences of getting any of this wrong are outward, which is what earns the mechanism its place: a reply container counted as a review discards a real one after the work is done; a missing rewrite filter leaves a rebased PR carrying an approval it never earned, or makes the recovery
PUToverwrite a published review with this run's findings.A head-resolution bug the extraction surfaced
Centralizing the anchor logic made a pre-existing bug visible, so it's fixed here too.
gh pr view --json commitsissuescommits(first: 100)— unpaginated, oldest-first — so past 100 commits.commits[-1]is commit #100 rather than the head. Every head-keyed field then matches nothing and goes quiet rather than wrong-loud: the pre-post guard stops firing, so a fold-in re-run posts a second review on a commit it already reviewed; the 422 recovery finds no orphan and duplicates instead of editing it;review's moved-head check inverts, so a push that did move the head reads as "HEAD hasn't moved" and the review posts against a stale commit; andweekly's redundant-approval guard never matches, collecting an approval per weekly run on one commit.Four sites now read
headRefOid, which is the head by definition and can't truncate. The test fixture serves a deliberately wrong-lastcommitslist alongside it, so reverting fails nine tests rather than passing on a short PR.Skill depth into
references/running-in-ciwas 677 lines against the 500-line capauthoring-skillssets, and that skill's own remedy is splitting intoreferences/, which costs nothing until read. Grounded-analysis depth, the other-repos rules, and the bar for proposing a skill PR move there; SKILL.md keeps each rule and a pointer. Every bundled skill is now under the cap.running-in-cireviewweeklyTesting
20 tests in
generator/tests/test_bot_review_state.pyrun the script against a fakegh: reply containers vs. real reviews, rewrite timing on both sides of a review, fresh vs. stale approvals, a dismissed one that must not be re-dismissed, orphan bodies, and the repo being named on every call. Five mutations confirm they bite — counting reply containers as substantive, counting a DISMISSED review as an approval, dropping the rewrite filter fromat_heador fromorphan_id, and the ordering flip below each fail 1–2 tests.The ordering subtlety is the one
weeklyhad split two ways, and the single implementation settles it: take the newest approval, then test whether it predates the rewrite. Filtering first names a pre-rewrite approval that a later one already superseded — dismissing a review that no longer decides anything while the one that does stands untouched.What this trades away
The brief was to accept modest reductions in feature precision. Only one materialized: "rewriting is authoring" is now a sentence inside
grounded-analysis.mdrather than a section with a worked example. Everything else here is behaviour-preserving — the duplication turned out to be a better trade than cutting precision.Reading the anchor state is now up to three script calls in a review run rather than the same work inlined three times, each fetching one endpoint more than the site strictly needs. That's compute, not correctness, and the repo's own rule puts it a distant third.