Skip to content

fix(loop): an unbudgeted kind fails, and budget.mjs owns the marker rule - #157

Merged
Ardnived merged 8 commits into
mainfrom
claude/fix-155-budget-unbudgeted
Oct 6, 2026
Merged

Ardnived merged 8 commits into
mainfrom
claude/fix-155-budget-unbudgeted

Conversation

@sydevs-bot

Copy link
Copy Markdown
Contributor

Summary

  • budget.mjs's CLI exited 0 on UNBUDGETED, so a mistyped --kind read as a pass. Every verdict but OK exits 1, and the skills key on the printed word.
  • The "append identity.commentMarker" rule moves from prose into the script, as MISSING_MARKER, driven by writing.markerRequired.

One commit per behaviour, Phase 1 first: 296c175 (the verdict/exit contract) and df875ed (the marker check). 53c28b1 is the review pass over both, 106f376 the docs sync.

Change outline

Contract — what the CLI promises a caller

 node workflow/lib/budget.mjs --kind <kind> < artefact
-  exit 0   OK | UNBUDGETED              # a mistyped or unnamed kind read as a pass
-  exit 1   OVER
+  exit 0   OK
+  exit 1   OVER | UNBUDGETED | MISSING_MARKER
+  the verdict word on stdout is the answer; two of them need OPPOSITE
+  responses, so a boolean exit code cannot carry it
 node workflow/lib/budget.mjs --fit --kind journalEntry > fitted.md
   verdict on stderr, exit 1 on anything but OK   # both unchanged

Behaviour — check()

 check(text, kind, budgets, { markerRequired, marker })   workflow/lib/budget.mjs
   no budget for kind                      → UNBUDGETED
+  kind is marker-required, text lacks the marker
+    → MISSING_MARKER                      # answered BEFORE the overage: the
+                                          # marker is 124 chars and they count
   chars > limit                           → OVER
   else                                    → OK
+  both marker options default ON, like `budgets` — a budget-only
+  measurement passes `{ markerRequired: [] }` deliberately

Contract — loop-config.json

 writing:
   budgets: { comment, reviewReply, reviewBody, journalEntry }   # untouched, still integers
+  markerRequired: [comment, reviewReply, reviewBody]            # journalEntry posts no marker

Flow — how the two run-loaded skills respond

 handler-preflight — the budgets paragraph
-  over              → cut prose, never the marker, a finding, or a required section
+  OVER              → cut prose, never the marker, a finding, or a required section
+  UNBUDGETED        → fix the kind, and cut nothing
+  the marker rule stays in its one existing home, and names MISSING_MARKER there
 handler-journal — fitting the journal entry
-  exit 1            → cut prose from Friction
+  OVER              → cut prose from Friction
+  any other verdict → report it under ⚠️ Failed, and post unfitted
+  the verdict arrives on stderr, because the command beside it redirects stdout

Test results

  • Lean gate: ✓ claude plugin validate ./workflow --strict → √ Validation passed, exit 0
  • Targeted specs: node --test workflow/lib/budget.test.mjs → 21 passed, from 6 on main. node --test dispatcher/test/*.test.mjs → 106 passed
  • node workflow/lib/rule-delta.mjs --base origin/main workflow/skills → directives: 62 → 62, no directive disappeared
  • node workflow/lib/comment-lint.mjs --base origin/main → no banned comment added
  • python3 workflow/lib/ste-lint.py on both changed skills → 3 violations, 0 hard, baseline 0; all three are pre-existing lines
  • Build: N/A — no package manager here

Every command in the ticket's verification checklist was run. --kind nosuchkind exits 1 naming the kind, --fit --kind nosuchkind exits 1 printing UNBUDGETED not OVER, --kind comment exits 1 naming the missing marker and exits 0 with the real marker appended, --kind journalEntry exits 0.

Manual verification

  1. A supervised dispatch is the only real gate for the two skill changes. They take effect on the next run, never this one. BOT_DISPATCH=dry, then a scratch @sydevs-bot answer … watched end to end (docs/routine-setup.md §6).
  2. Confirm a journal comment still posts: journalEntry is deliberately outside markerRequired, because handler-journal's template carries no marker. Checked against the template in this run; a regression here would fail every run's last write.

Notes for reviewer

Two open questions from the ticket, both settled from the code.

  • --fit does not enforce the marker. It runs on journalEntry alone, which is not marker-required, so the interaction is unreachable. No guard added.
  • check() enforces it unconditionally, not behind a flag. A flag would have to be named in run-loaded prose, and a run that forgot it would get back the silence this ticket removes. The review pass took this further: the options now default on, so the opt-out is the thing you type.

One deliberate deviation from an acceptance criterion. The criterion says a required kind fails when the text "does not end with" the marker. It tests presence instead. A loop comment carries the harness attribution footer after the marker — this ticket's own comments do — so an ends-with test would fail a correct artefact to catch a failure nobody has made. What SahajAtlasWeb#233 shipped was no marker at all. Tighten it to position once #145's footer question is settled.

Findings raised and dismissed, with reasons.

  • Make the script append the marker (--append-marker), not grade it. Right, and out of scope: MISSING_MARKER only fires for a run that measures, so a run that skips the step still omits the marker — the fix(review-pr): name how to read a file as the branch has it #233 class survives. A generator is a different behaviour and wants its own PR. A PreToolUse hook would not cover the cloud routines at all, since hooks run in a maintainer's session.
  • Invert the polarity to writing.markerExempt: ["journalEntry"]. Genuinely safer — a new budget kind would default to checked rather than silently exempt — but it contradicts the criteria the ticket sets, which name markerRequired and a kind "declared to require" the marker. The gap is closed by a test instead: every budgeted kind must be listed in markerRequired or named exempt in the suite, so adding a kind fails until someone decides. Worth revisiting as a data edit.
  • Carry the distinction in exit codes (0/1/2/3), as comment-lint.mjs does with its exit 2. The ticket decided the opposite, from the code, and --fit was already keying on a boolean. Instead a test now holds the prose to the words: VERDICTS names what the script can print, and the suite fails if a skill keys on one it cannot.
  • Add --config, as payload.mjs and merge-verdict.mjs have. Out of scope: no skill passes it, and the test's cwd pin documents a real property of loadLoopConfig() rather than working around a missing flag.
  • Move the markerRequired membership test out of check() into the CLI. Declined: keeping it inside means one function answers "is this artefact acceptable for this kind", and that is what the unit tests exercise.

Two of the ticket's premises were stale by the time this ran, and neither changes the work. It says main and #153's branch are both at 2.5.0; main was at 2.7.0, so this raises it to 2.8.0. And it says to wait for #153 — #153 merged as ef83cfb and closed #145 before this fired.

Blast radius. budget.mjs is invoked by every run in all five repos, and handler-preflight and handler-journal are read on every dispatch. After this merges, a mistyped --kind fails a run instead of passing it, and a comment with no marker fails before it posts. No consumer repo file changes, so contractSync is not involved.

Detail

Why the exit code alone could not be the fix. --fit already exited 1 on UNBUDGETED, and handler-journal read that as "cut prose from Friction" — so a run that mistyped the kind was told, forever, to cut text that was never over budget. Fixing only the check path's exit code would have left the loop acting on the wrong signal on the other path.

Why markerRequired is a sibling of writing.budgets, not a shape change to it. budget.mjs is the only reader of that key, and both of its lookups require a number. Turning each budget into {chars, marker} would break them, break the fallback's deepEqual, and break every --kind call the skills make.

What the review pass removed. The if (!kind) guard printed its verdict on stderr while every other non---fit verdict goes to stdout — in the change whose premise is that skills read the printed word. Slicing process.argv is the whole fix: an absent flag is an empty kind, which is already UNBUDGETED. The argv read is flag() from config.mjs now, as in payload.mjs and merge-verdict.mjs.

Prose cost. handler-journal keys on OVER and "any other verdict" rather than enumerating one the corpus test makes unreachable. handler-preflight keeps the marker rule at the bullet that already stated it. The retrospective narratives in budget.mjs were cut back to one imperative plus the (why: …) anchor, and loop-config.json's $comment went back to naming the value, since that file holds values and not rules.

Test shape. Seven child-process spawns were 77% of the suite's runtime; five remain, each proving one thing. One parse of loop-config.json serves the file. The marker unit tests use frozen fixtures, so no live config value threads through the "frozen fixtures, not a copy of the config" contract the file already had. Two new drift tests: every budgeted kind declares its marker status, and every verdict word a skill keys on is one the script can print.

Anomaly, recorded not explained. The ticket reports claude plugin validate ./workflow --strict passing clean on main, against #145's three and #153's four ${CLAUDE_PLUGIN_ROOT} warnings. It passes clean here too, on ef83cfb and on this branch, under the CLI this session has.

Not verified. SahajAtlasWeb#233 and the other cited PRs live in repos outside this run's scope, so their measurements stand as the filing sessions' own. The 124-character marker length was re-measured here.

Closes #155

🤖 Generated with Claude Code

https://claude.ai/code/session_01Fqz8efubu3hcBmVgeCJkrK


Generated by Claude Code

sydevs-bot and others added 4 commits October 6, 2026 05:44
…dict word

`budget.mjs`'s CLI exited 0 on `UNBUDGETED`, so a typo'd or unnamed `--kind`
read as a pass. That silence hid the missing review-body budget for three
weeks (#145). Every verdict but `OK` now exits 1.

The exit code alone cannot carry the answer, and keying on it was the second
half of the same bug. `--fit` already exited 1 on `UNBUDGETED`, and
`handler-journal` read that as "cut prose from Friction" — so a run that
mistyped the kind was told to cut text that was never over budget. Both
skills now act on the printed verdict word: `OVER` means cut, `UNBUDGETED`
means fix the kind and cut nothing.

Two details the review caught. A missing `--kind` fell through to `argv[0]`
and reported the node binary as the kind, which the new rule would send a run
hunting for — it now names the missing flag. And `handler-journal` says what
`UNBUDGETED` means where only `journalEntry` is passed: the config lost the
key, so report it and post unfitted.

Five CLI tests cover the exit mapping, which no test reached before.

Refs #155

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Fqz8efubu3hcBmVgeCJkrK
`handler-preflight` asked for `identity.commentMarker` on every comment in
prose, and SahajAtlasWeb#233 shipped a review with no attribution while
following it. `CLAUDE.md` gives a mechanical rule to a script, and
`budget.mjs` already holds the artefact on stdin and the marker from
`loadLoopConfig()`.

`writing.markerRequired` lists the kinds that must carry it, as a sibling of
`writing.budgets` rather than a shape change to it: both of the script's
lookups need a number, so a per-kind `{chars, marker}` object would break
them, the fallback's `deepEqual`, and every `--kind` call the skills make.
`journalEntry` is absent, which is also why `--fit` never checks.

Two decisions the ticket left open, both taken here:

- **Presence, not position.** A loop comment carries the harness attribution
  footer after the marker, so an ends-with test would fail a correct artefact
  to catch a failure nobody has made.
- **Unconditional, not behind a flag.** A flag would have to be named in
  run-loaded prose, and a run that forgot it would get back the silence #155
  removes.

`MISSING_MARKER` is reported before `OVER`, because the marker is 124
characters and they count.

Refs #155

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Fqz8efubu3hcBmVgeCJkrK
Five review lenses over `origin/main...HEAD`. Each fix below is theirs.

**The marker rule now defaults on.** `check()`'s options defaulted to `[]`
and `''`, so the library function's unsafe behaviour was its default — the
per-caller flag `docs/why.md` argues against in the same paragraph. They
default to `DEFAULT_MARKER_REQUIRED` and `DEFAULT_MARKER`, like `budgets`,
and measuring a budget alone takes an explicit `{ markerRequired: [] }`.

**A new budget kind can no longer be silently marker-exempt.** `markerRequired`
is an allowlist, which is the shape of the silence #155 removes: `reviewBody`
went three weeks unmeasured for exactly that reason. A test now holds every
budgeted kind to declaring itself, listed there or exempt in the test, so
adding a kind fails the suite until someone decides.

**The verdict words are an interface, so a test holds the prose to them.**
`VERDICTS` names what the script can print, and the suite fails if a skill
keys on a word it cannot.

**The `if (!kind)` guard is gone.** It printed the verdict on stderr while
every other non-`--fit` verdict goes to stdout — in the change whose premise
is that skills read the printed word. Slicing `process.argv` is the whole fix:
an absent flag is an empty kind, which is already `UNBUDGETED`. The argv read
is `flag()` from `config.mjs` now, as in `payload.mjs` and `merge-verdict.mjs`.

**Run-loaded prose shrank.** `handler-journal` keys on `OVER` and "any other
verdict" instead of enumerating one that the corpus test makes unreachable,
and says which stream carries the word, since the command beside it redirects
stdout. `handler-preflight` keeps the marker rule in its one existing home and
names the verdict there. The retrospective copies in `budget.mjs` went back to
one imperative plus the anchor, and `loop-config.json`'s `$comment` back to
naming the value.

**Tests: 21, from 24.** Seven child-process spawns were 77% of the suite's
runtime; five remain, each proving one thing. One parse of `loop-config.json`
serves the file, and the marker unit tests use frozen fixtures, so no live
value threads through the "frozen fixtures, not a copy of the config" contract.

Refs #155

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Fqz8efubu3hcBmVgeCJkrK
The one sentence describing the script said it checks a character budget.
It also decides the marker, and its exit code no longer distinguishes the
verdicts, so a contributor editing it needs both facts here.

Refs #155

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Fqz8efubu3hcBmVgeCJkrK
@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
  • 07:17Z address-review · attempt 1 · session · done
  • 07:17Z address-review · attempt 1 · session
  • 07:08Z adversarial-review · attempt 1 · session · done
  • 07:08Z adversarial-review · attempt 1 · session

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

Both phases match #155, and nothing is smuggled in beside them. Phase 1 is the right fix: the exit code cannot carry two verdicts that need opposite responses, and --fit is correctly left alone rather than guarded.

The ticket bought two commits for separate revertability, and 53c28b1 spends it. It moves check()'s marker defaults from []/'' to the two constants df875ed adds, so reverting df875ed alone leaves the file naming constants that no longer exist. Squash the review pass into the two commits it edits.

The prose total is the other cost. ~16 lines of behaviour arrive with ~24 comment lines in budget.mjs, 49 in docs/why.md and 4 in AGENTS.md, and the verdict contract is now stated four times. Three homes, no overlap, is the rule.

Findings

  • should-fix — the new verdict-drift test cannot see MISSING_MARKER, the one word this PR adds to prose. budget.test.mjs:228.
  • should-fix — 53c28b1 breaks the revert path the two-commit split exists for. Above, no single line.
  • consider — --kind= is parsed by hand beside the new flag() call, and nothing uses it. budget.mjs:202.
  • consider — AGENTS.md:118 states the verdict contract a fourth time, and already drifts from it.

What was checked

Read whole on the branch, against all four commits: budget.mjs, budget.test.mjs, config.mjs's flag(), both changed skills, the why.md additions.

Verified by query: flag() is argv.indexOf('--'+name) alone, so it never reads =, and --kind= appears nowhere but line 202. The new DEFAULT_MARKER copy carries a drift test. fit() never calls check(), so the marker rule is unreachable on --fit. The verdict regex, run over every SKILL.md on the branch, returns OVER and UNBUDGETED and nothing else.

No contract surface outside this repo changes. Profile read.

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


Generated by Claude Code

Comment thread workflow/lib/budget.test.mjs Resolved
Comment thread workflow/lib/budget.mjs Resolved
Comment thread AGENTS.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 3 commits October 6, 2026 07:20
The scan required `means` or `→` after a backticked word, so it saw `OVER`
and `UNBUDGETED` and nothing else. `MISSING_MARKER` — the one verdict this
PR adds to run-loaded prose — reads "answers `MISSING_MARKER` until you do"
at handler-preflight/SKILL.md:68, which the regex escaped. Renaming that
verdict in the script would have left the test green and the skill naming a
word budget.mjs cannot print, which is the drift the test exists to catch.

Every backticked ALL-CAPS token in every SKILL.md now counts, and the nine
that are not verdicts — env vars, git refs, HTTP verbs, review states — are
named in NOT_VERDICTS. A new token fails until someone says which list it
belongs in, the same shape as MARKER_EXEMPT above it. The size>0 sanity
assertion is replaced by one that names MISSING_MARKER, so the gap cannot
reopen silently.

Verified: replacing MISSING_MARKER with a word VERDICTS lacks fails the
test; restoring it passes. 21 tests pass.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Ascs6E1jaFiN7KJuFWmqye
The `--kind=` branch had no caller: no skill, doc or test in the repo uses
that form, and `flag()` on the next line cannot read it. Two parsers for one
flag is a half-migration, and the surviving one is the shared `flag()` that
payload.mjs and merge-verdict.mjs already use.

Dropped rather than taught to `flag()` in config.mjs: widening `flag()`
changes three callers for a form nobody writes. `--kind=comment` now exits 1
with UNBUDGETED naming an empty kind, so the unsupported form fails loudly
instead of being half-supported.

Verified: `--kind comment` → MISSING_MARKER exit 1, no flag → UNBUDGETED
exit 1, `--kind nosuchkind` → UNBUDGETED naming the kind. 21 tests pass.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Ascs6E1jaFiN7KJuFWmqye
The paragraph stated the verdict/exit contract a fourth time, after
budget.mjs's header block, handler-preflight's budgets paragraph, and
docs/why.md#a-verdict-word-not-an-exit-code. It had already drifted from the
script it described: `--fit` prints its verdict to stderr and never checks
the marker, so "it prints a verdict word ... and exits non-zero" was true of
one of the two paths.

Three homes, no overlap: the value in loop-config.json, the rule in the
skill, the story behind the anchor. AGENTS.md keeps what a contributor needs
— the script exists, it grades the marker too, read the word not the code —
and cites the anchor for the rest.

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

Copy link
Copy Markdown
Contributor Author

Three threads adopted, one review-body finding declined. Pushed 4a8f415.

  • Drift scan → 24b11ea. Every backticked ALL-CAPS token counts; the nine non-verdicts sit in NOT_VERDICTS.
  • --kind= → 8c21132. One parser, flag(). The = form exits 1.
  • AGENTS.md:118 → 4a8f415. Cites the anchor. The fourth copy is gone.

Declined: squash 53c28b1. address-review forbids force-push, rebase and squash, so this handler cannot. The risk is real: 53c28b1 points check()'s marker defaults at constants df875ed adds, so reverting df875ed alone leaves the file naming constants that do not exist. Revert both together, or squash at merge.

Gate passed. 142 tests, rule-delta 62 → 62, lints unchanged. Body untouched: nothing became false.

🤖 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 07:25
@sydevs-bot
sydevs-bot requested a review from Ardnived October 6, 2026 07:25
@Ardnived
Ardnived merged commit 98cd544 into main Oct 6, 2026
4 checks passed
@Ardnived
Ardnived deleted the claude/fix-155-budget-unbudgeted branch October 6, 2026 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

3 participants