Skip to content

ci(#1093): required checks on main, red-main revert rule, and mechanical proof for "pre-existing failure" claims - #1126

Merged
admarble merged 4 commits into
mainfrom
feature/1093-ci-gate-required-checks-on-main-up-to-date-rule-re
Sep 20, 2026
Merged

admarble merged 4 commits into
mainfrom
feature/1093-ci-gate-required-checks-on-main-up-to-date-rule-re

Conversation

@admarble

@admarble admarble commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Makes the merge gate on main mechanical, and makes any "pre-existing failure" claim provable.

  • scripts/ruleset-main.sh --print emits the corrected ruleset payload for CC (12393605). --print is its only mode — it makes no network call, so no agent can apply it. The owner applies it in gate(owner): apply the main ruleset — target ~DEFAULT_BRANCH, require the test check, strict up-to-date #1109.
  • scripts/settle-against-base.sh <test-file> [-t <name>] runs a named test at HEAD and again at the base commit, in the same worktree, with every SEQUANT_* var unset, and prints both results as a ### Settled against base block for the PR body. It commits nothing and restores the branch and any uncommitted work on every exit path.
  • /exec calls it for every red test outside the diff; /qa §2a sets settle_evidence_status and §7 step 4 floors an unbacked claim at AC_MET_BUT_NOT_A_PLUS.
  • CLAUDE.md gains a ## Red main rule, repeated in the release skill's pre-flight checks.

Decision taken on the spec's blocking finding B1

/spec flagged that AC-1 names a required check context (test) that did not exist: npm test ran inside a job called build carrying a single-entry matrix, so its real context was build (22.x). Applying a ruleset requiring test would have blocked every merge to main permanently. No owner decision was posted, so this PR resolves it by making the context real rather than by rewriting AC-1:

.github/workflows/ci.yml's build job is renamed test and loses its single-entry matrix, so the context it reports is the plain, stable string test. This satisfies AC-1 verbatim and removes the matrix footgun in spec option A (a node-version bump silently stops matching a required context). ci.yml was not in the issue's May touch list; options B and C both required it, and option A is the only one that avoids it — at the cost of contradicting AC-1's literal text.

Side effect, called out rather than left silent: settings.markdownOnlySafeCiPatterns defaults to ["build (*)", "Plugin Structure Validation"], so sequant's own markdown-only PRs no longer get the test check relaxed while pending. The default is deliberately left unchanged — it is a consumer-facing default where build (*) still matches, and relaxing a check the ruleset requires under strict_required_status_checks_policy would be exactly the "field for excusing a failure" this issue removes.

Acceptance criteria

  • AC-1: MET — scripts/ruleset-main.sh --print | jq -e '...' exits 0; [.rules[].type] is ["deletion","non_fast_forward","required_status_checks"], include is ["~DEFAULT_BRANCH"], strict policy true, context test. Applying it stays gate(owner): apply the main ruleset — target ~DEFAULT_BRANCH, require the test check, strict up-to-date #1109's AC.
  • AC-2: MET — npx vitest run scripts/settle-against-base.test.ts → 7 passed. Real temp git repo per case (init, bare origin, commits, branches); red-at-base/green-at-head and the reverse both assert the block carries both runner outputs.
  • AC-3: MET — same file, case "preserves uncommitted changes": the tracked edit and an untracked file are byte-identical afterwards, HEAD is back on the original branch, and no stash entry survives.
  • AC-4: MET — npx vitest run scripts/preexisting-claim-gate.test.ts → 4 passed, across all three skill copies. Mutation-verified.
  • AC-5: MET — .github/PULL_REQUEST_TEMPLATE.md does not exist; passes by absence, and none was created.
  • AC-6: PENDING — runner-owned per the wave-2 launch rules (full npm test from a clean shell after the PR opens). npm run build, npm run lint, npx tsc --noEmit and npm run typecheck:scripts all pass locally; see "Checks run" below.
  • AC-7: MET — npx vitest run scripts/preexisting-claim-gate.test.ts -t "red-main" → 2 passed, 2 skipped. Mutation-verified.

Mutation verification

Four mutations were run, each from a clean tree (git status --short | wc -l = 0), each failing exactly the intended test, each restored:

AC Mutation Test that failed
AC-4 removed the settle script reference from templates/skills/exec/SKILL.md exec skill names the settle script in its red-test section, in all three copies (1 failed, 3 passed)
AC-4 removed the settle_evidence_status step-4 branch from skills/qa/SKILL.md qa skill rejects an unbacked pre-existing claim, in all three copies (1 failed, 3 passed)
AC-7 deleted the ## Red main section from CLAUDE.md red-main rule is stated in CLAUDE.md (1 failed, 1 passed, 2 skipped)
AC-7 reworded revert-first/debug-second out of skills/release/SKILL.md red-main rule is stated in CLAUDE.md + red-main rule is repeated by the release skill in all three copies (2 failed)

Design notes

  • Where the qa gate lives. §2a is retitled Build & Red-Test Verification and now triggers on a pre-existing test claim as well as a failing build. It declares settle_evidence_status (Backed/Unbacked/N/A) with a real §7 gate — a step-2 token attributed to Section 2a and a step-4 branch on it. Prose alone would have failed npm run lint:skill-gates invariant I1 (the §2h and §6f defects it was written for). npm run lint:skill-gates: no violations.
  • ABSENT AT BASE is not support for a pre-existing claim. A brand-new test file errors at base, and reporting the runner's "no test files found" as a base failure would fake the exact claim this script exists to make unfakeable. The script distinguishes the two and the qa section says so; covered by the case distinguishes a test file absent at base from a failure at base.
  • Hermeticity. Both runs execute with every SEQUANT_* var unset (bug(test): suite isn't hermetic against the SEQUANT_* env phases inject — exec sees red tests it didn't cause and opens no PR #1086). A base-vs-head comparison under two different environments proves nothing.
  • Restore, not stash-pop. The stash stack is shared across worktrees and sessions, so the script tags its entry, re-finds it by tag, and apply + drops it rather than using positional pop. An EXIT/INT/TERM trap does the restore; a failed restore exits 4 and names the tag rather than exiting quietly.
  • Real git, substituted runner. Per I-6 the fixture repos are real (git init, a bare origin, real commits and checkouts). SETTLE_TEST_CMD substitutes a trivial runner so the file does not nest a real vitest per case — the behaviour under test is the checkout/stash/restore dance, not vitest.
  • vitest.config.ts gains scripts/settle-against-base.test.ts in the integration project (and unit's exclude list), mirroring scripts/qa/tautology-detector-cli.test.ts. It cannot finish inside unit's 5s default.
  • scripts/generate-constitution-dod.ts gains a label for the new gate, and both constitution.md copies are regenerated — the new §7 branch otherwise fails npm run lint:constitution-dod.

Checks run

Check Result
npm run build pass
npm run lint pass
npx tsc --noEmit pass
npm run typecheck:scripts pass
npm run lint:skill-sync 44 synced, 0 diverged, 0 missing
npm run lint:skill-gates no violations
npm run lint:skill-calls no violations (129 files)
npm run lint:constitution-dod in sync
tautology detector (--base origin/main) all tests call production code
bash -n on both new scripts pass (shellcheck not installed locally)
npx vitest run scripts/settle-against-base.test.ts 7 passed
npx vitest run scripts/preexisting-claim-gate.test.ts 4 passed
12 test files coupled to the edited skills + constitution 212 passed

No red tests were seen in this worktree, so no ### Settled against base block is attached. Per the wave-2 launch rules the full npm test is the runner's, from a clean shell — it was deliberately not run here (the 30-minute no-progress wall).

Test coverage

Changed file Tier Tests
scripts/settle-against-base.sh Standard scripts/settle-against-base.test.ts (7 cases)
scripts/ruleset-main.sh Standard none — see gap below
.claude/skills/** ×3, CLAUDE.md Standard scripts/preexisting-claim-gate.test.ts (4 cases, mutation-verified)
scripts/generate-constitution-dod.ts Standard scripts/check-constitution-dod.test.ts + the CI gate
.github/workflows/ci.yml, vitest.config.ts Optional config

Known gap: scripts/ruleset-main.sh has no test file. AC-1's verification is the jq -e command in the AC itself, which is run above and is the whole of the script's contract (it prints one fixed document). A test would restate the same jq assertion against the same literal. Flagging it rather than adding a restatement; say the word and I will add one.

Closes #1093

🤖 Generated with Claude Code

Runner verification (guard-2026-09 wave 2, 2026-09-20)

  • qa (judgment tier, opus): AC_NOT_MET, then AC_MET_BUT_NOT_A_PLUS on 6a11d760. The first round found the release skill's new red-main pre-flight read whichever push run was newest (Scorecard, not CI) and never stopped; runner fix: --workflow ci.yml and exit 1 on non-success in all three mirrors, gated by the AC-7 test (mutation: dropping --workflow from one mirror fails exactly that case; restored).
  • Runner ran AC-1 (ruleset-main.sh --print: ~DEFAULT_BRANCH, deletion + non_fast_forward + required_status_checks, context test, strict), AC-2/3 (settle test, 7 passed), AC-4/7 gate (4 passed), AC-5 (no PR template); markers classifier-valid; lint:skill-sync 44/44; no SKILL.md mentions relay.
  • Review note: this PR renames the CI job build → test and drops its single-entry matrix so the required context is exactly test (AC-1). gate(owner): apply the main ruleset — target ~DEFAULT_BRANCH, require the test check, strict up-to-date #1109 applies the ruleset by hand after merge.
  • Full npm test from a clean shell on 6a11d760: 331 files, 6626 passed, 3 expected fail, 3 skipped, 352 s. CI green (context now test).

@admarble
admarble merged commit 391eb5d into main Sep 20, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ci(gate): required checks on main, up-to-date rule, red-main revert, and mechanical proof for any "pre-existing failure" claim

1 participant