Skip to content

feat(loop): a review body gets its own budget kind, and the rules that spend it - #153

Merged
Ardnived merged 5 commits into
mainfrom
claude/chore-145-review-body-budget
Oct 6, 2026
Merged

Ardnived merged 5 commits into
mainfrom
claude/chore-145-review-body-budget

Conversation

@sydevs-bot

Copy link
Copy Markdown
Contributor

Summary

  • A submitted review body gets its own reviewBody budget, so a review stops cutting a finding or its attribution to fit the 1200 meant for comments.
  • Over means cut now says what a cut may never take, in handler-preflight — the same exposure sits in three other skills.

Change outline

Contract — the budget kinds every run measures against

writing.budgets is the list a run checks its output against. A submitted review body was not in it, so adversarial-review measured its body as a comment.

 writing.budgets                                  loop-config.json
   comment: 1200                                  # a ticket or PR comment
   reviewReply: 600                               # a thread reply
+  reviewBody: 2000                               # a submitted review body
   journalEntry: 1500

DEFAULT_BUDGETS in workflow/lib/budget.mjs carries the identical four, reached only when no loop-config.json is found. Two tests take over checks a maintainer was doing by hand: the fallback equals the config, and every --kind any SKILL.md names is a key in it.

Behaviour — what a run does when it measures over

The never-cut rule is general, so it sits in the paragraph every dispatch reads, not only in the skill that tripped over it.

 handler-preflight, budgets and register          workflow/skills/handler-preflight/SKILL.md
   kinds: comment, reviewReply, journalEntry
+  kinds: … reviewBody — a submitted review body
-  over → cut
+  over → cut prose, never the marker, a finding, or a required section

 adversarial-review submits its body              workflow/skills/adversarial-review/SKILL.md
   holistic assessment, ranked findings, what was checked
-  measure --kind comment                         # 1200, the kind for a ticket comment
+  measure --kind reviewBody                      # the body's own kind
+  end with identity.commentMarker                # its own inline rule did not reach the body

Behaviour — the guard that enforces the commit order

check() returns UNBUDGETED for a kind no config names and the CLI exits 0, so a typo'd --kind passes silently. The new corpus test closes that for anything a skill names, and it is why the two commits cannot land out of order.

 every --kind a skill names is budgeted           workflow/lib/budget.test.mjs
   scan workflow/skills/**/SKILL.md for --kind <name>
   assert every name is a key in writing.budgets
+  commit 1 alone  → finds journalEntry           # green: nothing names reviewBody yet
+  commit 2 alone  → finds reviewBody, unbudgeted # red: the revert order is checkable

Phases

  • Phase 1 — the value: writing.budgets.reviewBody, the matching DEFAULT_BUDGETS entry, two tests, the version bump
  • Phase 2 — the rules: the kind named where the body is written, what a cut may never take, the docs/why.md story

Test results

  • Lean gate: ✓ claude plugin validate ./workflow --strict — 4 warnings, the same 4 origin/main reports (unquoted ${CLAUDE_PLUGIN_ROOT} in hooks.json, pre-existing and untouched)
  • Targeted specs: 8 passed — node --test workflow/lib/budget.test.mjs (6 before, 2 added), and 8 again run from an ancestor cwd
  • node --test dispatcher/test/*.test.mjs — 106 passed
  • node workflow/lib/rule-delta.mjs --base origin/main workflow/skills — 62 → 62 directives, none disappeared
  • node workflow/lib/comment-lint.mjs --base origin/main — no banned comment added
  • /security-review ran, since the diff matches two arms of securityReview.triggerPattern — no findings. No allowed-tools and no hook changed, and the new instruction is inside preflight's existing Bash(node:*).
  • Build: N/A

Manual verification

  1. Confirm 2000 is the number you want. It binds at the 1913 outlier on purpose — a budget that never binds is not one.
  2. Watch the next adversarial-review body. It is the one artifact no test here can check. It should carry identity.commentMarker, and its journal entry should report no trim.

Notes for reviewer

The ticket left four open questions. Three were decisions, and this PR took them.

  • The number: 2000. Measured, not guessed — the detail below has the arithmetic.
  • The hard split: two commits, one PR. CLAUDE.md forbids shipping a skill change and a ceiling change together; implement-issue forbids splitting a ticket across PRs. The split exists so a changed output has one candidate cause. Here neither commit changes any output alone — a kind no skill names returns UNBUDGETED — so there is one behaviour and one cause. Each phase is a separately revertable commit, Phase 1 first, and the corpus test now fails if they land the other way round. This is the judgement call to check.
  • The marker belongs on a review body, and its 124 characters sit inside the 2000. SahajAtlasWeb#233 shipped with no marker at 1197/1200, which is what that question cost.
  • Left open: reviewReply. The ticket's Phase 3, out of scope without evidence. The cited replies live in repos this run cannot read, and reflect/SKILL.md forbids raising a threshold without evidence it was the binding constraint.

The plugin bumps to 2.5.0, in Phase 1's commit rather than Phase 2's, so reverting the skill rules leaves the cache key ahead of the workflow/lib change that stays.

Detail

The overhead, measured in this run rather than quoted. identity.commentMarker is 124 characters, the harness attribution footer 58, review.bodyHeader 24 — 206 before a word of review. Observed review prose ran 1318–1913 (the ticket's figures, from SahajCloud#861's four rounds). 2000 clears the 1318–1659 band with room (1659 + 206 = 1865) and still binds at the outlier (1913 + 206 = 2119).

Refused: raising comment to buy that room. It would loosen every ticket and PR comment the loop writes in order to fix one artifact.

No code change beyond the fallback. check() looks its limit up by key (budget.mjs:51), so --kind reviewBody resolved from config the moment the key existed. fit() is untouched: it cuts list items from the end of 📄 Did and is journal-only, so a review body is checked, never fitted.

budget.mjs's CLI still exits 0 on UNBUDGETED (budget.mjs:194). The ticket names that under Notes and does not file it; changing the exit code is a live-behaviour change to shared infrastructure in all five repos and belongs in its own PR. The corpus test is the standing guard in the meantime: it catches any kind a skill names, which is every kind a run reaches without someone typing one by hand.

Review findings taken, from /simplify's four passes:

  • The drift test read loop-config.json from the cwd first, so run from an ancestor checkout it compared DEFAULT_BUDGETS against a different config and failed. Reproduced: 7 of 8 from the parent checkout, 8 of 8 from the worktree. Now resolved from import.meta.url.
  • The reviewBody-only test was a special case for the defect its own comment stated generally. Replaced with the corpus test.
  • writing.$comment in loop-config.json still said "Bodies are deliberately unbudgeted", three lines above the new key. Corrected, as docs/why.md and handler-preflight were.
  • The never-cut rule was filed as a review-body rule. Moved to handler-preflight.

Dismissed, with reasons:

  • Put the version bump in Phase 2, since cut-release ties version to the skill change. The documented revert order is Phase 2 first, and under it the bump must sit in Phase 1 or the cache key falls behind a workflow/lib change that stays.
  • Assert the measured overhead leaves a stated margin inside reviewBody. Real exposure — the marker and the header are data, and growing either silently eats the headroom. The fix needs a margin constant nobody has derived, and the harness footer is not in config at all. Worth a ticket, not an invented number here.
  • Drop --kind reviewBody from adversarial-review as duplicating preflight's list. Preflight lists the kinds; the skill at the call site is what makes one live. Per the ticket, a run uses reviewBody only because a skill names it.

Verification run, in the worktree:

  • printf 'x' | node workflow/lib/budget.mjs --kind reviewBody → OK — 1/2000 (config), exit 0
  • 2001 characters piped in → OVER — 2001 chars, 1 over the 2000 budget, exit 1
  • the fallback/config equality check from the ticket → fallback matches config, comment = 1200
  • the corpus test's logic against origin/main's config → unbudgeted: [ 'reviewBody' ], so it would have caught this

One correction to the ticket. It says --strict already fails on main with three unquoted-${CLAUDE_PLUGIN_ROOT} warnings. It is four, on main and on this branch alike.

Docs sync. AGENTS.md's budget line is generic and stays true. docs/cleanup.md's mention of a removed journalComment key is history, not a live reference. docs/why.md gains the section.

One anomaly. node workflow/lib/comment-rule-sync.mjs exits with canonical rule not found: ../claude-workflow/docs/code-comments.md — it resolves a sibling checkout, so it cannot run from inside this repo. Unrelated to this diff, and not retried.

Closes #145

🤖 Generated with Claude Code

https://claude.ai/code/session_01Fpw7GY9oDLCdrHMJBUBRwa


Generated by Claude Code

claude added 2 commits October 5, 2026 23:45
`writing.budgets` had no kind for a submitted review body, so
`adversarial-review` measured its body as `comment` (1200) while
prescribing a holistic assessment, ranked findings and a What-was-checked
section. Reviews paid for it: SahajAtlasWeb#237 cut evidence to land at
1200/1200, SahajCloud#874 dropped a PR-size note it did not think wrong,
and SahajAtlasWeb#233 shipped with no `identity.commentMarker` at
1197/1200. Trimming prose is what a budget is for. Dropping a finding and
losing the attribution are not.

2000 is set against overhead measured in this run, not guessed: the marker
is 124 characters, the harness footer 58, `review.bodyHeader` 24 — 206
before a word of review. Observed review prose ran 1318-1913, so 2000
clears the 1318-1659 band with room and still binds at the outlier. A
budget that never binds is not one.

`check()` resolves any key in `writing.budgets` (budget.mjs:51), so the
only code change is keeping `DEFAULT_BUDGETS` equal to the config, which
budget.mjs's own doc comment requires. Two tests take over checks a
maintainer was doing by hand: the fallback equals the config, and every
`--kind` a skill names is a key in it. The second is the general form —
`check()` returns UNBUDGETED for an unnamed kind and the CLI exits 0, so a
typo passes silently, and that silence is how this gap stayed invisible
for three weeks. Against this branch's skills and `main`'s config it
fails, naming `reviewBody`.

`writing.$comment` loses "Bodies are deliberately unbudgeted" for "Ticket
and PR bodies", which is what it always meant and is now load-bearing.

Bumps the plugin to 2.5.0. It lands in this commit, not the next, so a
revert of the skill rules leaves the cache key ahead of the
`workflow/lib` change that stays.

This commit moves no run's output by itself. A kind is inert until a skill
names it, so it lands first and reverts last.

Refs #145

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Fpw7GY9oDLCdrHMJBUBRwa
… take

A budget kind is inert until a skill names it. `check()` returns
UNBUDGETED for a kind nothing configured, and the CLI exits 0 on it, so
the previous commit moved no run's output. This commit is what spends it,
and it is the one to revert first.

`handler-preflight` enumerates the kinds, so leaving `reviewBody` out of
that list would have kept it unreachable. The same sentence now reads
"ticket and PR bodies are unbudgeted" — unqualified, "bodies" now reads as
covering the one body that is measured.

"Over means cut" becomes "cut prose, never `identity.commentMarker`, a
finding, or a section the skill requires", and it goes in preflight rather
than in `adversarial-review` alone. Nothing about SahajAtlasWeb#233
dropping its marker was specific to a review body: `answer-ticket`,
`address-review` and `revise-ticket` all require the marker inside the
1200 of `comment`, and preflight's "shorten by leaving things out" named
no exception. One line on the per-dispatch read now covers four skills
instead of one.

`adversarial-review` keeps only what is new where the body is written:
the kind to measure with, and the marker on a body that its own inline
rule did not reach.

`docs/why.md` takes the six cited reviews, the measured overhead, why the
never-cut rule is general, and why the value and the rules shipped as two
commits on one PR.

Refs #145

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Fpw7GY9oDLCdrHMJBUBRwa
@sydevs-bot sydevs-bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Oct 6, 2026
@sydevs-bot

sydevs-bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 no session running

recent dispatches
  • 03:53Z resolve-conflicts · attempt 1 · session · done
  • 03:53Z resolve-conflicts · attempt 1 · session
  • 00:44Z address-review · attempt 1 · session · done
  • 00:44Z address-review · attempt 1 · session
  • 00:33Z adversarial-review · attempt 1 · session · done

Written by the sydevs dispatcher. Sessions never edit this comment.

@sydevs-bot sydevs-bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧐 Adversarial review

This PR is the size of its ticket: two lines of value, thirteen of rule, two tests. Every number it claims verifies here: marker 124, header 24, and the four budgets match between config and fallback. The judgement call it flags is the right one — neither commit moves a run's output alone, so the hard split's purpose survives two commits on one PR, and the corpus test makes the revert order checkable.

What is unsettled is where the new rules stop. A review body now has two budgets, depending on which path posts it. The never-cut rule is prose, in a repo whose guide gives mechanical rules to scripts. Neither is a reason to hold the PR.

Findings

  • should-fix — adversarial-review/SKILL.md:101 — the fallback path posts the identical body as a PR issue comment, which preflight budgets at 1200. A 2000-character body cannot go through it.
  • consider — handler-preflight/SKILL.md:95 — "never the marker" is enforced by prose alone, and it is the one item in that list a script could decide.
  • consider — budget.test.mjs:102 — the root cause stays unfixed and unfiled. No open issue names the exit-0 silence.
  • consider — docs/why.md:567 — one paragraph is this PR's commit order, not the failure behind the rule.

What was checked

Read whole: budget.mjs, budget.test.mjs, config.mjs, handler-preflight, adversarial-review, handler-journal, ticket #145, CLAUDE.md, the profile. node --test workflow/lib/budget.test.mjs — 8 pass. loadLoopConfig(path) throws rather than searching, so the drift test's cwd fix holds. The corpus test sees journalEntry and reviewBody only, since preflight writes --kind <kind>; both other kinds are already keys. check() returns UNBUDGETED and the CLI exits 0 at budget.mjs:194. fit() cuts no required section — handler-journal omits an empty 📄 Did.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

Comment thread workflow/lib/budget.test.mjs Resolved
Comment thread docs/why.md Resolved
@sydevs-bot sydevs-bot added bot:working Lock: a cloud session is running on this item. Removed when it ends. and removed bot:working Lock: a cloud session is running on this item. Removed when it ends. labels Oct 6, 2026
claude added 2 commits October 6, 2026 00:48
The fallback path posts the identical review body as one PR issue comment,
and handler-preflight budgets a PR comment at 1200. With reviewBody at 2000
a body between 1201 and 2000 could not take that path without cutting what
the new never-cut rule forbids losing.

The budget follows the artifact, not the transport, so the fallback comment
is measured as reviewBody too.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FSG5aQgqzvqVh48dbpKJ1M
docs/why.md is scoped to the failure behind each rule, one heading per rule.
The closing paragraph was this PR's commit structure instead, already stated
nearly verbatim in the PR body, and it explained a process decision rather
than the budget the section is about.

The failure it carried stays: a kind no skill names is inert, which is how
the gap stayed invisible for three weeks.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FSG5aQgqzvqVh48dbpKJ1M
@sydevs-bot

Copy link
Copy Markdown
Contributor Author

Review round addressed: two commits, one follow-up ticket, one thread left for you.

Adopted

Filed

Open for you

Gate: 4 pre-existing --strict warnings, budget.test.mjs 8 pass, dispatcher 106 pass, rule-delta 62 → 62.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

@sydevs-bot sydevs-bot removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Oct 6, 2026
@sydevs-bot
sydevs-bot marked this pull request as ready for review October 6, 2026 00:53
@sydevs-bot
sydevs-bot requested a review from Ardnived October 6, 2026 00:53
@sydevs-bot sydevs-bot added bot:working Lock: a cloud session is running on this item. Removed when it ends. and removed awaiting labels Oct 6, 2026
Resolve the plugin version against #151.

main bumped to 2.6.0 after this branch took 2.5.0, so both sides wanted the
next cache key and neither number is still free. `version` keys the installed
plugin's cache directory, so it has to land strictly ahead of main or the
skill change never reaches an installed consumer. Resolved to 2.7.0, which is
what each side was asking for.

Everything else auto-merged into disjoint sections: this branch rewrote
preflight's Budgets paragraph while main rewrote its step 6, and this branch
added the review-body rules to adversarial-review while main corrected the
diff command in its Reads.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Sfnn5gDuQ2mqUiP6pDRVhZ
@sydevs-bot

Copy link
Copy Markdown
Contributor Author

Merged main in. One conflict, in workflow/.claude-plugin/plugin.json.

Resolved to 2.7.0. #151 took 2.6.0 after this branch took 2.5.0, so both sides wanted the next cache key and neither number is free now. version names the installed plugin's cache directory, so it has to land strictly ahead of main or this skill change never reaches an installed consumer. 2.7.0 is what each side was asking for. The body's "bumps to 2.5.0" line is superseded.

Everything else auto-merged into disjoint sections. handler-preflight: this branch rewrote the Budgets paragraph, main rewrote step 6. adversarial-review: this branch added the review-body rules, main fixed the diff command in its Reads.

Lean gate now passes with no warnings — main quoted ${CLAUDE_PLUGIN_ROOT} in hooks.json, so the 4 warnings the body reports are gone. node --test workflow/lib/budget.test.mjs — 8 passed.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

@sydevs-bot sydevs-bot added awaiting and removed bot:working Lock: a cloud session is running on this item. Removed when it ends. labels Oct 6, 2026
@Ardnived
Ardnived merged commit ef83cfb into main Oct 6, 2026
10 checks passed
@Ardnived
Ardnived deleted the claude/chore-145-review-body-budget branch October 6, 2026 05:30
sydevs-bot pushed a commit that referenced this pull request Oct 6, 2026
GitHub reported this PR conflicting after #151 and #153 merged. One hunk
conflicted: plugin.json's version. Both sides bump it for the same reason,
so neither side wins — main took 2.6.0 in #151 and 2.7.0 in #153, and the
plugin cache key is the version string, so this branch's 2.6.0 would have
resolved to a no-op and reached no installed plugin. 2.8.0 is the first
value above main's.

Everything else merged clean and additive: the incidental-finding bullet
sits beside #153's reviewBody rules in handler-preflight, findings beside
writing.budgets in loop-config.json, and main's budget.mjs, finalize-pr
and reflect changes come through untouched. rule-delta still reports
62 → 62 directives with the same one removal the body adjudicates, so the
merge dropped no rule.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013NdyinyrMRWyxZowgEtQ5D
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

chore(loop): a review body has no budget kind, so reviews cut their own evidence to fit

3 participants