Repository navigation
fix(loop): the audit checks that contractSync names files the repos have - #302
Conversation
`contractSync.consumers.<repo>.paths` is the only thing the three contract guards read, and a stale entry makes all three report success about a file the consumer no longer builds from. `contract-check` diffs an absent path, finds nothing touched and passes. `contracts-sync` finds `git status` clean on a path its command never writes, and opens nothing. `audit-contracts` reads that same clean status as current. That is the silence `wisdom_sidetext` was hand-edited into a copy under (WeMeditateWeb#269), restored by a config edit nobody re-checks. So `audit-contracts` step 2 now asserts, before it diffs anything, that every configured path exists in that consumer's `origin/main`. `workflow/lib/contract-paths.mjs` owns the check: it reads the pairs from `loop-config.json`, names each repo and path it cannot find, and exits 2 rather than 0 when a checkout or its `origin/main` is missing — absence proves nothing without the ref. The check lives in the audit, not in `contract-check`, because failing a consumer's PR on an absent configured path reddens every PR in that repo until the config catches up. That is the shape WeMeditateWeb#310 was rejected for, and drift on `main` is already the sync's and the audit's. A miss is fixed here, in a `loop-config.json` PR. Closes #298 Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjWHPyWFsS4etH8mgCN
One `git ls-tree` per consumer answers both questions the script asks — the ref resolves, and which configured paths that tree holds — so `hasRef` and the per-path `cat-file` go, 8 git spawns become 3, and the two answers stay apart: no ref returns null, never an empty set. `missing()` was a one-line filter around the caller's own predicate, and the print loop re-derived each pair's membership from the result. The CLI now builds each row once and `verdict()` reads the rows. The tests reach the CLI, where the audit does: exit 0 with `PATHS PRESENT` against checkouts holding what the config names, exit 1 naming the repo and the path when one moves, and exit 2 on a checkout with no `origin/main`. Every temp directory is cleaned up. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjWHPyWFsS4etH8mgCN
…he code Three findings from the review pass. The script reads each consumer's `origin/main`, and `start-run` step 6 sets up only the handler's own checkout. A ref left where a clone seeded it answers confidently about the commit it was left at, so step 2 fetches first — the diff below it reads the same ref. The header claimed `paths` is all the three guards read. `sources` drives the dispatcher's trigger (dispatcher/contracts.mjs), so a producer that moves one stops firing syncs. That staleness still reaches the audit's own diff, so the claim is corrected rather than the scope widened. Membership against `ls-tree` is exact, so a `paths` entry spelled `./x` or as a directory would read as MISSING though the file is there. The test holds the real config to one spelling. A ref it cannot read no longer claims to be unfetched when the directory is not a checkout at all. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjWHPyWFsS4etH8mgCN
|
🤖 no session running recent dispatchesWritten by the sydevs dispatcher. Sessions never edit this comment. |
sydevs-bot
left a comment
There was a problem hiding this comment.
🧐 Adversarial review
The diff is the size of #298: one guard, its tests, the skill prose that calls it, and the version bump. Nothing is smuggled — the git fetch in ce50fe2 is what makes the new check read the right commit, and the contracts-sync cat-file line stays out for a reason AGENTS.md agrees with.
The shape is right too: the config is checked where drift on main is already fixed, so no consumer's CI reddens for drift it did not cause.
Two pieces do not pay rent, and the new story has no docs/why.md home. Neither changes the design.
Findings
should-fix—contract-paths.mjs:48configuredPathsflattens what line 91 regroups.should-fix—contract-paths.mjs:75verdictderivesabsenta second way, three lines away.consider—audit-contracts/SKILL.md:49the three-guards story is told twice, anchored nowhere.
What was checked
- Read whole, as the branch has them:
contract-paths.mjs, its test,audit-contracts/SKILL.md,docs/documentation.md, the citedwhy.mdanchor. - Ladder, on the pieces
new-pieces.mjsleft out:REFhard-codesorigin/mainasdoc-weight.mjs:98does, andbase-ref.mjsexports nothing that resolves a default branch — kept...andjoin(ws, repo)matchcomment-rule-sync.mjs:55. No dependency added. - Streamliner: 4 pieces, 2 kept. Both findings held against the code and the tests.
- Exit 2 prints no verdict word —
test-only.mjsandcomment-rule-sync.mjsdo the same, andstart-runowns that case. Not raised. - Consumer side: nothing here is read by
check.shorcontracts-sync, and nocontractSyncvalue moved. - Re-ran from a worktree: 163 tests pass,
rule-delta93 → 93,ste-lint5 — the same 5mainhas.check.sh:21,AGENTS.md:127andREADME.md:188read as the body describes. No## Preview. - Profile read. No question threads.
🤖 Written by the sydevs autonomous loop — see what this is
Generated by Claude Code
`configuredPaths` flattened `contractSync.consumers` to `{repo, path}` pairs
that the CLI loop immediately regrouped by repo. Iterating
`Object.entries(consumers)` drops the round trip and one export: same rows, in
the same config order, with the same exits. A consumer configuring no paths is
skipped rather than demanding a checkout, which the flattened form did by
contributing no pair.
The empty-config exit 2 moves after the loop, where `rows` is the thing being
judged. Its test asserts over the config directly, and the pure-function test
that only exercised the dropped flattening goes with it.
Addresses the adversarial review on #302.
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjZG7uf2opWm1dMXcYr
`verdict` asked `rows.every(r => r.found)` three lines from where `absent` counts the same rows, so the printed word and the exit code were derived twice and could disagree. The word now reads off `absent`, the one fact the exit uses. Its unit test goes: the two CLI tests already assert both words through the script, and flipping the ternary fails them. Addresses the adversarial review on #302. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjZG7uf2opWm1dMXcYr
The story had no anchor, so the skill told it and `contract-paths.mjs`'s header told it again, while the anchor both cited covers only why a check fails a PR for its own change. The cited anchor is now the new entry's, and each caller keeps a rule and a pointer: the skill its imperative, the header one sentence of intent. The entry records what the two citations never did — which read makes each of the three guards go quiet, and the back-to-back merge that mitigated it by hand (#297, WeMeditateWeb#327). Addresses the adversarial review on #302. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjZG7uf2opWm1dMXcYr
|
Three findings from the adversarial review, all adopted, one commit each. Pushed
Nothing rebutted, nothing asked. Branch was already current with Gate: 161 tests pass, from the checkout and from a worktree. 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
main (#297) recorded the moved-path hazard as a paragraph under *A contract check checks what a PR changes*; this branch records it as its own anchored section, which audit-contracts/SKILL.md:50 and contract-paths.mjs:11 both cite. Keeping both would state the same three guards twice, so the section stays and main's one fact it lacked — that WeMeditateWeb was the first consumer to move a copy — is folded into it. The anchor both callers cite survives, and so does main's. main's loop-config.json move to types/payload/payload-types.ts merged clean and needs no follow-up here: contract-paths.test.mjs reads the real config rather than naming a path, and its spelling assertion still passes. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjWijDNPGjupHZWKA8D
|
Merged Both sides wrote up the same hazard. #297 appended a paragraph to A contract check checks what a PR changes; this branch gives it its own section, and
Lean gate green from the worktree: 161 lib tests, plus 399 dispatcher tests for the test files #297 changed. 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
Conflict: workflow/.claude-plugin/plugin.json version. main bumped 5.10.0 -> 5.11.0 for #302's new workflow/lib/contract-paths.mjs; this branch stood at 5.10.1 for its merge-gate.mjs export. Resolved to 5.11.1 — main's minor stands, and this branch's workflow/lib change still carries a bump above it, so the plugin cache key moves for both. Nothing else conflicted, and nothing incoming touches the moved modules: #302 and #297 changed only workflow/lib, the audit-contracts skill, docs/why.md, loop-config.json's WeMeditateWeb contract paths, and two dispatcher tests that import gather.mjs and fire.mjs, neither of which this branch moved a symbol out of. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjVAr3C2hHbsKE6d9bg
One conflict: the plugin version. Both sides bumped it, for the same reason and past the same older number. This branch took 5.10.1 in 4975cfe to clear the `test` check's "plugin files changed but version is still 5.10.0". #302 then took 5.11.0 on main. An install's cache directory is named after `version`, so the branch's `workflow/lib/payload.mjs` change still needs a string strictly past main's. Resolved to 5.11.1, which keeps both sides' intent: the patch digit is the branch's own reasoning in 4975cfe — the one shipped change is a guard on a handler name, and a minor is reserved for a feature. Everything else merged clean. main's #297 moved WeMeditateWeb's payload-types copy to types/payload/ in `contractSync`, and #302 added `workflow/lib/contract-paths.mjs` with the audit that checks those paths; this branch's own `loop-config.json` additions (`identity.dispatcherLogins`, `dispatch.rateLimitFloor`, `githubRetry.rateLimitMaxWaitSeconds`) are untouched beside them. Gates from the merge result: `claude plugin validate ./workflow --strict` passed, `node --test workflow/lib/*.test.mjs` 162 passed (the 5 new ones are #302's), `node --test dispatcher/test/*.test.mjs` 425 passed, `claude plugin validate .` passed. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjWg3VTaQeP1j8FCSva
One conflict: `workflow/.claude-plugin/plugin.json`. Both sides claimed `5.11.0` — this branch bumped `5.10.0` to `5.11.0` on its first commit, and #302 took the same number on main meanwhile. Kept this branch's `5.11.2`. The requirement is that the merged tip's version differs from the version an install cached, and `5.11.2` is strictly above main's `5.11.0` and has never appeared on main, so #302's change and this one do not share a cache directory. Reverting to `5.11.0` would have made them share it. docs/why.md auto-merged with both sides' sections intact: #302's "A moved contract path silences every guard" and this branch's additions to "A body is read to disk before it is edited". Lean gate from this worktree: `claude plugin validate ./workflow --strict` passed, `node --test workflow/lib/*.test.mjs` 161/161 (156 before, #302 added `contract-paths.test.mjs`). `node --test dispatcher/test/*.test.mjs` 399/399. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjWSas5xXMtfHHv46Wf
Summary
audit-contractsasserts every configured consumer path exists in that repo'sorigin/main.origin/mainanswers about a stale commit.plugin.jsonmoves to 5.11.0 — an install caches byversion, andworkflow/libchanged.docs/why.mdgains A moved contract path silences every guard, the story both callers cite.Change outline
The change is one new step in the audit, and the script it calls. A
pathsentry a consumermoved is the one input that makes all three contract guards report success about a file nobody
builds from, so the config is checked before the copy.
Flow — audit-contracts step 2
Contract — what the audit acts on
The verdict word, as
budget.mjsandtest-only.mjsdo it, so the skill reads a word and neveran exit code. The exits are for a human running it by hand.
Test results
claude plugin validate ./workflow --strict && node --test workflow/lib/*.test.mjs— 161 tests, from the checkout and from a.claude/worktreesworktree.workflow/lib/contract-paths.test.mjs). Two pure-function tests went with the helpers the review dropped; both verdict words are still asserted through the CLI, and flipping the ternary fails those two tests.rule-delta.mjs --base origin/main workflow/skills: 93 → 93 directives, no directive disappeared. Nothing was removed.ste-lint.pyon the changed skill: 5 violations, the same 5origin/mainhas for that file.comment-lint.mjs --base origin/main: no banned comment added.Manual verification
A skill edit takes effect in the next session, and this routine's GitHub access covers only
claude-workflow, so no consumer could be cloned here.origin/main, point onepathsentry at a file that repo does not have, runnode workflow/lib/contract-paths.mjs .., and confirm it names that repo and that path. Restore the entry. Here it ran against checkouts built from the real config instead, which is what the two CLI tests do.auditCalendar.mondayturn foraudit-contracts, confirm the run fetches each consumer and prints one line per configured copy before it diffs anything.Notes for reviewer
check.sh. Failing a consumer's PR on an absent configured path reddens every PR there until the config catches up — the shapedocs/why.md#a-contract-check-checks-what-a-pr-changesrejects, with a wider blast radius.sourcesis deliberately not checked. A producer that moves one stops the dispatcher firing syncs (dispatcher/contracts.mjs), but the consumer's copy then goes stale and step 2's own diff catches it. Silence is the thing being fixed, and that case is not silent. The script's header claim was corrected rather than its scope widened.contracts-syncjob'sgit status --porcelain -- $SYNC_PATHS. Agit cat-file -eline before its sync command would close it where it is loudest. Left for its own PR —.github/workflows/changes behaviour in all five repos on the next event, and its real gate is a supervised dispatch (docs/routine-setup.md§6).--config/--workspaceflag liketest-only.mjs's — the positional workspace matchescomment-rule-sync.mjs .., the sibling line in this same skill, and nothing asked for an override. Exportinggit/revfrombase-ref.mjsto drop one duplicated try/catch —base-ref.mjsis loaded by three run-time scripts, and this would widen the diff for no behaviour change.Detail
Where the three guards go quiet today, each verified by reading it:
.github/actions/contract-check/check.sh:21git diff --name-only ... -- $pathsis empty, so it printsNo copied contract changedand exits 0contracts-syncindispatcher.ymlgit status --porcelain -- $SYNC_PATHSis clean on a path the command never writesaudit-contractsstep 2Rejected designs. Listing the old and the new path together through a move:
git addon anabsent path exits 128, so
contracts-syncwould fail its job rather than go quiet (recorded inthe ticket). A warning-only annotation in
check.sh: it still puts config drift in front of anauthor whose PR did not cause it.
The simplify pass replaced one
rev-parseper repo plus onecat-fileper path with a singlels-treeper repo — 8 git spawns to 3 on today's config — and the two answers stay apart: amissing ref returns
null, never an empty set, because absence without the ref proves nothing.It also dropped a one-line
missing()wrapper and thegone.some()re-derivation in the printloop.
Membership is exact, so a
pathsentry spelled./x, with a trailing slash, or naming adirectory would read as MISSING though the file is there.
contract-paths.test.mjsholds the realconfig to one spelling, so a config edit that would mislead the audit fails the gate instead.
Fixture pre-mortem. The tests invent no config: every repo name and path comes from the real
loop-config.json, which is why a consumer added or a copy moved is read rather than assumed. Thetemp checkouts stand in only for clones, built by git itself, with
refs/remotes/origin/mainwritten by hand because a clone normally writes it and the tests have no network.
Docs sync. Nothing enumerates
workflow/lib's scripts:AGENTS.md:127anddocs/why.mdcitemerge-gate.mjsas an example, not a list.README.md:188's one-liner foraudit-contractsstaystrue.
docs/routine-setup.mdalready hassydevs-audit-nightlycloning all five repos, so the newfetch step is executable where the audit runs.
## Previewis omitted becauseclaude-workflow's.claude/workflow.jsondeclares nopreviewUrland nofixture. No routine haspr-review-toolkit(ListPluginsreturned nothing),so the review pass was
/code-review highbeside/simplify, and/security-reviewran becausethe diff matches
securityReview.triggerPattern; it reported no findings.Closes #298
🤖 Generated with Claude Code
https://claude.ai/code/session_01Mg9rjZG7uf2opWm1dMXcYr