Skip to content

feat(dispatcher): approve a contract sync that matches its source - #280

Merged
Ardnived merged 2 commits into
mainfrom
claude/dispatcher-contract-verify
Nov 19, 2026
Merged

Ardnived merged 2 commits into
mainfrom
claude/dispatcher-contract-verify

Conversation

@Ardnived

@Ardnived Ardnived commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • contracts-sync vouches for what it writes. After each push to contractSync.branch, it posts the commit status sydevs / contract-sync (contractSync.attestContext) on that commit, as sydevs-bot. The job already ran the consumer's command on main and wrote exactly those bytes.
  • contracts-verify is one script step in dispatcher.yml. It runs on that status event, or on a PR event on the sync branch. It approves a ready, same-repo bot PR into the default branch that changes only the copy's paths, but only when the head carries the bot's status. The approval uses the consumer's own token, as github-actions[bot], pinned to that head. The dispatcher already arms auto-merge at mark-ready, so the merge queue runs CI and merges.
  • The check withdraws its own approval. On a head the sync didn't write, or one the gate refuses, it explicitly dismisses its earlier approval. It finds that approval by a marker in the review body, so a person's approval is never touched. This covers fix(dispatcher): dismiss a contract approval the head outgrew #282.
  • decide alone asks the reviewer, never at a contract-only sync's mark-ready. It asks when:
    • the PR changes more than the copy;
    • the sync didn't write the head (a hand edit or a fix-ci push);
    • GitHub's own reviewDecision shows the ruleset doesn't count the check's approval;
    • a vouched-for head is still unapproved after contractSync.approveWithinMinutes (30), meaning the check failed or never ran. The sweeper catches this one.

The first commit re-ran the sync command in the consumer and diffed the result. The second removes that: no consumer checkout, pnpm or node, no verdict status, no CI filter, and no false mismatch when SahajCloud main moves between the sync and the check.

Failure this prevents

Every contract-sync PR (17 of the 32 small bot merges in the eight weeks to 2026-10-20) waited on the owner's approval, though it has one correct content. sydevs/WeMeditateWeb#292 sat BLOCKED with green CI and auto-merge armed. The approveWithinMinutes and reviewDecision asks also close the gap the critic raised: if the approval is refused or doesn't count, the PR would otherwise stall silently.

Safety

  • Runs no PR code. Nothing from the PR is checked out.
  • Only the bot can vouch. The status counts only when sydevs-bot posted it. Sessions act as sydevs-bot only through the GitHub MCP server, which can't write a status.
  • Approval stays tied to the sync's own commit. It covers exactly that head, and is dismissed explicitly on any head the check can't vouch for. The ruleset's dismiss_stale_reviews_on_push is on today, but the guarantee doesn't depend on it.
  • Rulesets unchanged. No bypass actor. Every other PR keeps the owner-approval flow.

⚠ Rollout order

All five callers must grant pull-requests: write on their dispatch job before this merges. A reusable job asking for more than its caller grants fails the whole dispatcher run in that repo. Merge these first, in any order:

A sync PR already open when this merges carries no status, so it is asked for review as before. That includes sydevs/WeMeditateWeb#292, whose head is a hand edit anyway.

Test results

  • node --test dispatcher/test/*.test.mjs: 385 pass, 0 fail. The tests cover:
    • the gate: draft, closed, non-bot, fork, other branch, retargeted base, extra file, empty list, producer
    • the status: only the bot's success counts
    • approval: pinned and given once; a status event finds its PR; dry run
    • dismissal: only the check's own earlier approval is dismissed, never a person's
    • asking the reviewer: decide asks in each of the four cases, waits inside the window, and stays quiet once approved and counted
    • gather: reads the bot's status and GitHub's reviewDecision
  • node --test workflow/lib/*.test.mjs: 143 pass.
  • dispatcher.yml parses. It hasn't run end to end. The first sync after rollout is the supervised check.

Closes #282.

🤖 Generated with Claude Code

A contract-sync PR has one correct content, yet each waited on the owner's
approval: the ruleset needs one, and sydevs-bot cannot approve its own PR.

A new contracts-verify job in dispatcher.yml re-runs the consumer's
contractSync command on its own main and compares the result with the PR
head. A byte-for-byte match on a ready bot PR that changes nothing but the
copy is approved with the consumer's own token, as github-actions[bot],
pinned to that head. Nothing from the PR executes: the head is only
fetched and diffed.

The verdict is posted as the contractSync.verifyContext commit status, as
sydevs-bot so it wakes the dispatcher. decide asks the reviewer only on a
failure or error verdict, never at a contract-only sync's mark-ready; the
status is read only from the bot and kept out of CI, and the job's own
check run joins ci.ignoreCheckNames.

Needs every caller to grant pull-requests: write on its dispatch job first:
a reusable job asking for more than its caller grants fails the whole run.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@sydevs-bot

sydevs-bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

🤖 no session running

recent dispatches
  • 23:14Z address-review · attempt 1 · session · done
  • 23:14Z address-review · attempt 1 · session
  • 23:06Z review-pr · attempt 1 · session · done
  • 23:06Z review-pr · 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

Choose a reason for hiding this comment

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

🧐 Adversarial review

The shape is right, and narrower than #279: only a job in the consumer's own event can approve the bot's PR, the callers stay thin, and decide keeps the reviewer request. The re-derivation earns its cost — the gate alone would pass the one hand edit this has actually seen (WeMeditateWeb#292). The diff is the size of that problem. One gap: it withdraws the reviewer request on the strength of an approval the body itself says is unverified.

Findings

  • should-fix — dispatcher/decide.mjs:663: a success or missing verdict asks nobody, and mark-ready no longer asks either. If the ruleset does not count the github-actions[bot] approval, a sync stalls silently and so does the next.
  • should-fix — PR body, ⚠ Rollout order: "Those PRs are linked below" links nothing. Four of the five caller grants live in other repos; only #281 is reachable from here, and the merge order is the one thing a reader must get right.
  • consider — .github/workflows/dispatcher.yml:370: a runner starts on every claude/* PR event in five repos, though the gate only ever passes one branch.

What was checked

contracts.mjs and dispatcher.yml whole, decide.mjs (evaluateGreenPr, route), the gather status filter, loop-config.json, this repo's workflow-state.yml, and the why.md anchor. Ladder on the six new functions and the job: no repo or platform equivalent — Actions has no job-level step reuse, and why.md rules out a ruleset bypass. node --test on the branch: 386 and 143 pass, as claimed. Not raised: no pnpm install, and pnpm/action-setup on a consumer with no pnpm, both of which mirror contracts-sync as it runs today.

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


Generated by Claude Code

Comment thread dispatcher/decide.mjs Resolved
Comment thread .github/workflows/dispatcher.yml Resolved
@sydevs-bot

Copy link
Copy Markdown
Contributor

From #279's run, which was superseded before it could land this. Its branch security review found that the contract check never dismisses its own approval: a head the gate later refuses still carries the approval of an earlier one, with auto-merge armed and no reviewer asked.

Filed as #282, with a fix and tests on claude/verify-contract-sync (07d4b6d). It is not one of the four critic findings this PR takes.

🤖 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 19, 2026
@sydevs-bot sydevs-bot moved this from Working to Pending in SYDevelopers Technical Roadmap Nov 19, 2026
@sydevs-bot sydevs-bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 19, 2026
@sydevs-bot sydevs-bot moved this from Pending to Working in SYDevelopers Technical Roadmap Nov 19, 2026
contracts-verify re-ran the consumer's sync command and diffed the
result: a checkout, pnpm and node per sync PR, the same code from the same
main as contracts-sync, and a false mismatch whenever the producer moved
between the two runs.

contracts-sync now posts contractSync.attestContext on each commit it
pushes to the sync branch, as sydevs-bot. contracts-verify is one script
step: on that status event, or a PR event on the sync branch, it approves
a ready contract-only bot PR into main whose head carries the bot's
status, with the consumer's token, and explicitly dismisses its own
earlier approval when the head carries none (#282).

decide asks the reviewer when the PR outgrows the copy, the sync did not
write its head, GitHub's reviewDecision shows the ruleset does not count
the check's approval, or a vouched-for head is still unapproved after
contractSync.approveWithinMinutes, so a check that never runs cannot
stall a sync silently. The verdict status, its CI filter and the
three-state mapping are gone.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Ardnived

Copy link
Copy Markdown
Contributor Author

Redesigned in b6d1113: contracts-sync now vouches for each commit it writes, and contracts-verify is one script step. The critic's findings and #282 are folded in; see the updated body. Earlier review threads on the removed compare/verdict code no longer apply.

Ardnived added a commit to sydevs/SahajCloud that referenced this pull request Nov 19, 2026
sydevs/claude-workflow#280 adds a contracts-verify job that approves a
contract-sync PR matching its source, with this repo's own token. A
reusable job asking for more than its caller grants fails the whole
dispatcher run, so this grant must merge before #280. Unused until then.

Co-authored-by: Claude Opus 5.5 <[email protected]>
Ardnived added a commit to sydevs/SahajAtlasWeb that referenced this pull request Nov 19, 2026
sydevs/claude-workflow#280 adds a contracts-verify job that approves a
contract-sync PR matching its source, with this repo's own token. A
reusable job asking for more than its caller grants fails the whole
dispatcher run, so this grant must merge before #280. Unused until then.

Co-authored-by: Claude Opus 5.5 <[email protected]>
Ardnived added a commit to sydevs/WeMeditateWeb that referenced this pull request Nov 19, 2026
sydevs/claude-workflow#280 adds a contracts-verify job that approves a
contract-sync PR matching its source, with this repo's own token. A
reusable job asking for more than its caller grants fails the whole
dispatcher run, so this grant must merge before #280. Unused until then.

Co-authored-by: Claude Opus 5.5 <[email protected]>
Ardnived added a commit to sydevs/SahajAtlasWordpress that referenced this pull request Nov 19, 2026
sydevs/claude-workflow#280 adds a contracts-verify job that approves a
contract-sync PR matching its source, with this repo's own token. A
reusable job asking for more than its caller grants fails the whole
dispatcher run, so this grant must merge before #280. Unused until then.

Co-authored-by: Claude Opus 5.5 <[email protected]>
Ardnived added a commit that referenced this pull request Nov 19, 2026
#280 adds a contracts-verify job that approves a
contract-sync PR matching its source, with this repo's own token. A
reusable job asking for more than its caller grants fails the whole
dispatcher run, so this grant must merge before #280. Unused until then.

Co-authored-by: Claude Opus 5.5 <[email protected]>
@sydevs-bot

Copy link
Copy Markdown
Contributor

Nothing pushed — b6d1113 answered the critic first. It landed mid-run, while this session was building the same two fixes on 79e2b22. Mine were dropped.

  • decide.mjs:663 — resolved. contractSyncPlan reads GitHub's own reviewDecision, plus approveWithinMinutes for a check that never ran. A refused approval is observed, not assumed.
  • dispatcher.yml:370 — resolved. The if: matches contractSync.branch and the attest status, not every claude/* PR.
  • Review body, ⚠ Rollout order — the five caller grants are now linked. Fixed by your rewrite.

Branch security review on b6d1113: both of #279's findings are closed here — contracts.mjs:140 refuses a PR not targeting the default branch, contracts.mjs:183 dismisses only the check's own marked approval. #282's criteria read as met, docs/why.md:1402 included.

Gates on b6d1113: validate passed, dispatcher 385, lib 143.

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


Generated by Claude Code

@Ardnived
Ardnived merged commit db48db3 into main Nov 19, 2026
29 of 31 checks passed
@Ardnived
Ardnived deleted the claude/dispatcher-contract-verify branch November 19, 2026 23:30
@sydevs-bot sydevs-bot moved this from Working to Done in SYDevelopers Technical Roadmap Nov 19, 2026
@sydevs-bot sydevs-bot removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 19, 2026
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(dispatcher): dismiss a contract approval the head outgrew

2 participants