Skip to content

fix(loop): the audit checks that contractSync names files the repos have - #302

Merged
sydevs-bot merged 7 commits into
mainfrom
claude/fix-298-contract-paths
Nov 22, 2026
Merged

sydevs-bot merged 7 commits into
mainfrom
claude/fix-298-contract-paths

Conversation

@sydevs-bot

@sydevs-bot sydevs-bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • audit-contracts asserts every configured consumer path exists in that repo's origin/main.
  • Step 2 fetches that ref first: a routine clone's origin/main answers about a stale commit.
  • plugin.json moves to 5.11.0 — an install caches by version, and workflow/lib changed.
  • docs/why.md gains 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 paths entry a consumer
moved 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

 step 2 Copied contracts are current             workflow/skills/audit-contracts/SKILL.md
+  git fetch origin main, in each consumer's checkout    # both checks below read that ref
+  contract-paths.mjs <workspace>                        workflow/lib/contract-paths.mjs
+    for each consumer in contractSync.consumers         # its configured paths, in config order
+    present(checkout, that repo's paths)                # one ls-tree per repo
+      no checkout, or no origin/main → exit 2           # cannot tell is never a pass
+    PATHS MISSING → drift in the config, not the copy
+      point the entry at the file the repo builds from, in a loop-config.json PR here
   run the consumer's command, in its checkout, on origin/main
   git status -- <paths> clean → current; a diff → stale, open the sync PR

Contract — what the audit acts on

The verdict word, as budget.mjs and test-only.mjs do it, so the skill reads a word and never
an exit code. The exits are for a human running it by hand.

contract-paths.mjs <workspace-dir>
  PATHS PRESENT — 0 of 5 configured copies absent.    exit 0
  MISSING  <repo> <path>                              exit 1   one line per absent copy
  PATHS MISSING — 1 of 5 configured copies absent.
  <repo>: cannot read origin/main. …     (stderr)     exit 2   no checkout, or no ref

Test results

  • Lean gate: ✓ claude plugin validate ./workflow --strict && node --test workflow/lib/*.test.mjs — 161 tests, from the checkout and from a .claude/worktrees worktree.
  • Targeted specs: 5 passed (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.py on the changed skill: 5 violations, the same 5 origin/main has for that file.
  • comment-lint.mjs --base origin/main: no banned comment added.
  • Build: N/A — this repo builds nothing.

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.

  1. In a real clone of a consumer on origin/main, point one paths entry at a file that repo does not have, run node 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.
  2. On the next auditCalendar.monday turn for audit-contracts, confirm the run fetches each consumer and prints one line per configured copy before it diffs anything.

Notes for reviewer

  • The check went to the audit, not to check.sh. Failing a consumer's PR on an absent configured path reddens every PR there until the config catches up — the shape docs/why.md#a-contract-check-checks-what-a-pr-changes rejects, with a wider blast radius.
  • sources is 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.
  • One guard still reports "current" for a moved file at merge time: the contracts-sync job's git status --porcelain -- $SYNC_PATHS. A git cat-file -e line 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).
  • Dismissed, with reasons: a --config/--workspace flag like test-only.mjs's — the positional workspace matches comment-rule-sync.mjs .., the sibling line in this same skill, and nothing asked for an override. Exporting git/rev from base-ref.mjs to drop one duplicated try/catch — base-ref.mjs is 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:

Guard Why a moved path passes
.github/actions/contract-check/check.sh:21 git diff --name-only ... -- $paths is empty, so it prints No copied contract changed and exits 0
contracts-sync in dispatcher.yml git status --porcelain -- $SYNC_PATHS is clean on a path the command never writes
audit-contracts step 2 reads that same clean status as current

Rejected designs. Listing the old and the new path together through a move: git add on an
absent path exits 128, so contracts-sync would fail its job rather than go quiet (recorded in
the ticket). A warning-only annotation in check.sh: it still puts config drift in front of an
author whose PR did not cause it.

The simplify pass replaced one rev-parse per repo plus one cat-file per path with a single
ls-tree per repo — 8 git spawns to 3 on today's config — and the two answers stay apart: a
missing ref returns null, never an empty set, because absence without the ref proves nothing.
It also dropped a one-line missing() wrapper and the gone.some() re-derivation in the print
loop.

Membership is exact, so a paths entry spelled ./x, with a trailing slash, or naming a
directory would read as MISSING though the file is there. contract-paths.test.mjs holds the real
config 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. The
temp checkouts stand in only for clones, built by git itself, with refs/remotes/origin/main
written by hand because a clone normally writes it and the tests have no network.

Docs sync. Nothing enumerates workflow/lib's scripts: AGENTS.md:127 and docs/why.md cite
merge-gate.mjs as an example, not a list. README.md:188's one-liner for audit-contracts stays
true. docs/routine-setup.md already has sydevs-audit-nightly cloning all five repos, so the new
fetch step is executable where the audit runs.

## Preview is omitted because claude-workflow's .claude/workflow.json declares no
previewUrl and no fixture. No routine has pr-review-toolkit (ListPlugins returned nothing),
so the review pass was /code-review high beside /simplify, and /security-review ran because
the diff matches securityReview.triggerPattern; it reported no findings.

Closes #298


🤖 Generated with Claude Code

https://claude.ai/code/session_01Mg9rjZG7uf2opWm1dMXcYr

`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
@sydevs-bot sydevs-bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 21, 2026
@sydevs-bot

sydevs-bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 no session running

recent dispatches
  • 17:51Z resolve-conflicts · attempt 1 · session · done
  • 17:51Z resolve-conflicts · attempt 1 · session
  • 15:24Z address-review · attempt 1 · session · done
  • 15:24Z address-review · attempt 1 · session
  • 15:15Z review-pr · attempt 1 · session · done

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

@sydevs-bot sydevs-bot moved this from Pending to Working in SYDevelopers Technical Roadmap Nov 21, 2026

@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

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:48 configuredPaths flattens what line 91 regroups.
  • should-fix — contract-paths.mjs:75 verdict derives absent a second way, three lines away.
  • consider — audit-contracts/SKILL.md:49 the 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 cited why.md anchor.
  • Ladder, on the pieces new-pieces.mjs left out: REF hard-codes origin/main as doc-weight.mjs:98 does, and base-ref.mjs exports nothing that resolves a default branch — kept. .. and join(ws, repo) match comment-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.mjs and comment-rule-sync.mjs do the same, and start-run owns that case. Not raised.
  • Consumer side: nothing here is read by check.sh or contracts-sync, and no contractSync value moved.
  • Re-ran from a worktree: 163 tests pass, rule-delta 93 → 93, ste-lint 5 — the same 5 main has. check.sh:21, AGENTS.md:127 and README.md:188 read 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

Comment thread workflow/lib/contract-paths.mjs Resolved
Comment thread workflow/lib/contract-paths.mjs 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 Nov 21, 2026
`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
@sydevs-bot

Copy link
Copy Markdown
Contributor Author

Three findings from the adversarial review, all adopted, one commit each. Pushed ce50fe2..f2358cc.

Nothing rebutted, nothing asked. Branch was already current with main, so no merge.

Gate: 161 tests pass, from the checkout and from a worktree. rule-delta 93 → 93. ste-lint 5, the same 5 main has. /security-review ran again on the new diff: no findings. Body refreshed — the outline's flatten step and the two test counts.

🤖 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 Nov 21, 2026
@sydevs-bot
sydevs-bot marked this pull request as ready for review November 21, 2026 15:34
@sydevs-bot
sydevs-bot requested a review from Ardnived November 21, 2026 15:34
@sydevs-bot
sydevs-bot enabled auto-merge November 21, 2026 15:35
@sydevs-bot sydevs-bot moved this from Working to Awaiting in SYDevelopers Technical Roadmap Nov 21, 2026
@sydevs-bot sydevs-bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 22, 2026
@sydevs-bot sydevs-bot moved this from Awaiting to Working in SYDevelopers Technical Roadmap Nov 22, 2026
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
@sydevs-bot

Copy link
Copy Markdown
Contributor Author

Merged main in. One conflict, in docs/why.md.

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 audit-contracts/SKILL.md:50 and contract-paths.mjs:11 cite that anchor. I kept the section and dropped #297's paragraph rather than state the three guards twice. The one fact it had that the section lacked — WeMeditateWeb was the first consumer to move a copy — is folded in. Both anchors still resolve.

loop-config.json's move to types/payload/payload-types.ts merged clean and needs nothing here: contract-paths.test.mjs reads the real config instead of naming a path, and its spelling assertion still passes on the new one. Still 5 configured copies, so the body's counts hold.

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

@sydevs-bot sydevs-bot removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 22, 2026
@sydevs-bot sydevs-bot moved this from Working to Awaiting in SYDevelopers Technical Roadmap Nov 22, 2026
@sydevs-bot
sydevs-bot added this pull request to the merge queue Nov 22, 2026
@sydevs-bot sydevs-bot moved this from Awaiting to Pending in SYDevelopers Technical Roadmap Nov 22, 2026
Merged via the queue into main with commit e36b97f Nov 22, 2026
22 checks passed
@sydevs-bot
sydevs-bot deleted the claude/fix-298-contract-paths branch November 22, 2026 18:26
@sydevs-bot sydevs-bot moved this from Pending to Done in SYDevelopers Technical Roadmap Nov 22, 2026
sydevs-bot pushed a commit that referenced this pull request Nov 22, 2026
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
sydevs-bot pushed a commit that referenced this pull request Nov 22, 2026
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
sydevs-bot pushed a commit that referenced this pull request Nov 22, 2026
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
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.

fix(loop): a stale contractSync path makes every guard report current

3 participants