Skip to content

feat(ci): a shared contract check that fails only a PR's own change - #283

Merged
Ardnived merged 3 commits into
mainfrom
claude/contract-check
Nov 20, 2026
Merged

Ardnived merged 3 commits into
mainfrom
claude/contract-check

Conversation

@Ardnived

@Ardnived Ardnived commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Adds .github/actions/contract-check/, a composite action. Each contract consumer (WeMeditateWeb, SahajAtlasWeb, SahajAtlasWordpress) runs it as a step in its existing required CI job.
  • The rule: a PR that changes a contractSync copy must leave it exactly as that consumer's sync command writes it. A PR that leaves the copy alone passes, however far the source has moved.
    • Only the copies the PR touched are compared, so a sibling copy that drifted on main never fails it.
    • A deleted copy counts as a change.
    • A failing command is annotated ci.infraLabel, so the dispatcher re-runs it instead of firing fix-ci.
    • A mismatch is re-checked twice, 150 s apart, because raw.githubusercontent.com serves main up to about 5 minutes stale after a merge.
  • Inputs: paths and command (both optional) cover a copy outside contractSync. WeMeditateWeb uses them for its English mirror of production translations.
  • Joined: contractSync's $comment now says its paths and command drive this required check in three repos. A maintainer edits those values there, not in AGENTS.md.
  • Config and docs: a repo the action is called from without a config entry fails loudly, never passes. Docs are in docs/why.md#a-contract-check-checks-what-a-pr-changes, plus the "CI for the other four" paragraph in AGENTS.md and the CI line in the README.

Failure this prevents

  • Hand edits pass every check. wisdom_sidetext was hand-typed into WeMeditateWeb's generated types and its English mirror (WeMeditateWeb#269). It passed every check, because nothing compared the copy with its source, and production rendered the raw key path.

  • The fix in ci(contracts): fail the gate when the generated types or the English mirror drift from SahajCloud WeMeditateWeb#310 fails PRs for the wrong reason. It compared every PR's copy with SahajCloud main. One producer merge would then:

    • redden every open PR until the sync lands;
    • fire fix-ci on each open bot PR;
    • fail the merge queue.

    It was also red by design until an unrelated SahajCloud PR shipped. WordPress's required URL contract in sync job already has that shape.

  • Precedent: this follows the same rule as #dependency-review-checks-what-a-pr-adds. Drift on main stays the job of the contract sync, which now merges itself, and of audit-contracts.

Rollout

Merge this first. The consumers reference sydevs/claude-workflow/.github/actions/contract-check@main, so their PRs' CI fails until this is on main:

  • WeMeditateWeb (types and the English mirror)
  • SahajAtlasWeb
  • SahajAtlasWordpress (replaces the URL contract in sync job's steps, keeping its required name)

Then close sydevs/WeMeditateWeb#310.

⚠ This is shared CI. A broken edit to the action, or to contractSync in loop-config.json, blocks merges in all three consumers at once.

Test results

  • node --test dispatcher/test/*.test.mjs: 390 pass, 0 fail. The new contract-check.test.mjs runs check.sh against a throwaway git repo:
    • an untouched copy passes, even when the command would fail;
    • a matching change passes;
    • one copy synced correctly passes while a sibling copy the PR never touched has drifted;
    • a hand edit fails with a file annotation;
    • a deleted copy fails;
    • a failing command is marked as infrastructure;
    • config defaults are read;
    • a repo with no config entry fails;
    • a push event has nothing to compare.
  • Lean gate (claude plugin validate ./workflow --strict, workflow/lib tests): 143 pass, 0 fail.
  • action.yml parses, and bash -n passes on check.sh. It hasn't run on GitHub yet: the consumer PRs are its first runs.

🤖 Generated with Claude Code

A hand-typed key in WeMeditateWeb's generated types and English mirror
(WeMeditateWeb#269) passed every check, because nothing compared a copy
with its source. The proposed gate (WeMeditateWeb#310) compared every
PR's copy with SahajCloud main, which reddens every open PR on each
producer merge, fires fix-ci on each open bot PR, and fails the queue.
WordPress's required URL-contract job already does that.

.github/actions/contract-check is a composite action each consumer runs
as a step in its required CI job. A PR that changes a contractSync copy
must leave it exactly as the sync command writes it; a PR that leaves it
alone passes. paths and command inputs cover a copy outside
contractSync. A mismatch is re-checked twice for raw.githubusercontent
caching; a failing command is marked ci.infraLabel.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@sydevs-bot sydevs-bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 20, 2026
@sydevs-bot

sydevs-bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

🤖 no session running

recent dispatches
  • 00:11Z address-review · attempt 1 · session · done
  • 00:11Z address-review · attempt 1 · session
  • 00:04Z review-pr · attempt 1 · session · done
  • 00:04Z 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: a step inside each consumer's existing required job, scoped to what the PR changes, mirroring dependency-review.yml. The diff is no bigger than the problem.

One blocker. check.sh:38 measures the consumer's whole paths, not the copies this PR touched, so a PR that syncs one copy correctly still fails when a sibling copy has drifted on main. That is the WeMeditateWeb#310 failure this PR exists to remove, it contradicts the rule the body and README state, and it lands in shared CI for three repos. I reproduced it.

Findings

  • blocker — check.sh:38 fails a PR for drift in a copy it never touched. -- $touched, not -- $paths.
  • consider — check.sh:43 spends 5 minutes re-checking where no remote source is read.
  • consider — loop-config.json's contractSync.$comment still names only audit-contracts/SKILL.md. These values now also drive required CI in three repos, and a maintainer editing paths reads that comment, not AGENTS.md. No diff hunk to anchor it to.

What was checked

  • Read action.yml and check.sh whole. github.action_path/../../../loop-config.json resolves to the repo root of a @main action checkout, and the BASE_SHA fallbacks match ci.yml's.
  • Ran check.sh from a scratch copy against throwaway repos: two paths, one synced and one drifted (fails — the blocker), the same with -- $touched (passes), and a deleted copy under that fix (still fails).
  • Ladder: no shared action exists to extend. dispatcher/contracts.mjs already resolves consumers[repo], but in node, which a PHP consumer's job has no reason to carry. Composite action over reusable workflow is argued in why.md.
  • ci.infraLabel is used as an annotation title, as loop-config.json describes.
  • CLAUDE.md is a symlink to AGENTS.md, so no second copy went stale.

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


Generated by Claude Code

Comment thread .github/actions/contract-check/check.sh Resolved
Comment thread .github/actions/contract-check/check.sh Resolved
@sydevs-bot sydevs-bot removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 20, 2026
@sydevs-bot sydevs-bot moved this from Working to Pending in SYDevelopers Technical Roadmap Nov 20, 2026
@sydevs-bot sydevs-bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 20, 2026
@sydevs-bot sydevs-bot moved this from Pending to Working in SYDevelopers Technical Roadmap Nov 20, 2026
The match check ran `git status --porcelain -- $paths`, the consumer's whole
copy set, after the sync command had rewritten all of them. A PR that synced
one copy correctly then failed because a sibling copy it never touched had
drifted on `main` — the WeMeditateWeb#310 failure this action exists to
remove, and the rule the body, README and why.md all state. SahajAtlasWeb has
three copies, so it was the likely first casualty, and the file annotation
would have named the one correct file.

`-- $touched` is the set the PR changed, which the annotation loop already
uses. The two diff prints that follow a failure are scoped the same way, so
the evidence shows the copies that failed, not unrelated drift.

Every existing test passed one path, so the suite could not see this. The new
case seeds a second copy, syncs only the first, and moves the second's source:
it fails on the old line and passes on the new one. A deleted copy still
fails — the command writes it back untracked, which status reports.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjY3fXbmP1FSZ6B8kWD
A maintainer editing `paths` or `command` reads this `$comment`, not AGENTS.md.
It named only audit-contracts, so nothing on the way in said these values are
now a required check in three repos, where a wrong path fails every PR that
touches a copy.

One sentence, in the file the edit happens in. The story stays in why.md.

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

Copy link
Copy Markdown
Contributor

Pushed b03ed04. Both critic threads answered and resolved.

Adopted — the whole paths set. git status --porcelain -- $touched in a162486, with the two diff prints after a failure scoped the same way, and the two-path case the suite could not see.

Rebutted — the 150 s re-check. pnpm types:cms curls payload-types.ts from SahajCloud's main (cross-repo.md:11-14), so all three consumers read a remote source. I built the gate, then reverted it on that evidence.

Joined — the review body's third point. contractSync's $comment now warns that paths and command drive required CI in three repos (b03ed04).

Security review ran on loop-config.json and dispatcher/: no findings. Lean gate 143 pass, dispatcher suite 390 pass. Docs checked, nothing stale.

🤖 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 20, 2026

@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.

Approved for Ardnived, who wrote it: GitHub refuses an author's own approval. CI is green and the automated review has run. Enable auto-merge when you want it merged: the queue tests it against its base. 🤖 Written by the sydevs autonomous loop — see what this is

@sydevs-bot sydevs-bot moved this from Working to Pending in SYDevelopers Technical Roadmap Nov 20, 2026
@sydevs-bot sydevs-bot moved this from Pending to Awaiting in SYDevelopers Technical Roadmap Nov 20, 2026
@Ardnived
Ardnived merged commit c24e8b4 into main Nov 20, 2026
48 of 50 checks passed
@Ardnived
Ardnived deleted the claude/contract-check branch November 20, 2026 00:24
@sydevs-bot sydevs-bot moved this from Awaiting to Done in SYDevelopers Technical Roadmap Nov 20, 2026
Ardnived added a commit to sydevs/WeMeditateWeb that referenced this pull request Nov 20, 2026
Calls sydevs/claude-workflow's contract-check action. A PR that changes a
copied contract must leave it exactly as its sync command writes it; a PR
that leaves the copy alone passes, however far SahajCloud has moved. Drift
on main is the contract sync's to fix.

Needs sydevs/claude-workflow#283 on main first.

Co-authored-by: Claude Opus 5.5 <[email protected]>
Ardnived added a commit to sydevs/SahajAtlasWordpress that referenced this pull request Nov 20, 2026
Calls sydevs/claude-workflow's contract-check action. A PR that changes a
copied contract must leave it exactly as its sync command writes it; a PR
that leaves the copy alone passes, however far SahajCloud has moved. Drift
on main is the contract sync's to fix.

Needs sydevs/claude-workflow#283 on main first.

Co-authored-by: Claude Opus 5.5 <[email protected]>
Ardnived added a commit to sydevs/SahajAtlasWeb that referenced this pull request Nov 20, 2026
Calls sydevs/claude-workflow's contract-check action. A PR that changes a
copied contract must leave it exactly as its sync command writes it; a PR
that leaves the copy alone passes, however far SahajCloud has moved. Drift
on main is the contract sync's to fix.

Needs sydevs/claude-workflow#283 on main first.

Co-authored-by: Claude Opus 5.5 <[email protected]>
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.

3 participants