Skip to content

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

Closed

Description

@admarble

Blocked by: #1104 Tier: judgment Doc: guard plan 2026-09-18 (16-bug classification; research: Uber SubmitQueue, Shopify merge queue, Google TAP)

Why

The main ruleset today enforces only deletion and non_fast_forward. There are no required status checks and no up-to-date requirement, so a PR can merge with stale or red CI. In practice that is what happened on 2026-09-10/11: PRs #1036, #1042 and #1048 each shipped with "3 pre-existing failures, unrelated to this diff" in the body. The failures were #1086 and stopped a gate run a week later. The structural fix used by every always-green-main team is the same: the gate tests the merge state, a red main is a revert, and there is no field for excusing a failure.

The mechanical half: an agent's "pre-existing" claim is unverifiable unless it attaches the same test's result at the base commit in the same worktree. The exec and qa skills now say so in prose; this makes it a script the skills call and qa checks.

Change

  1. Ruleset payload: scripts/ruleset-main.sh --print emits the JSON for ruleset CC (id 12393605) with conditions.ref_name.include: ["~DEFAULT_BRANCH"] (Phase 0 found it [], targeting no ref), the existing deletion and non_fast_forward rules, and a required_status_checks rule naming the test job with strict_required_status_checks_policy: true; docs/internal/graph-2026-09-guard/ruleset.md explains each field. The owner applies it in gate(owner): apply the main ruleset — target ~DEFAULT_BRANCH, require the test check, strict up-to-date #1109 (G-1). An agent never calls gh api -X PUT on the ruleset.
  2. Red-main rule in CLAUDE.md's hooks/commit section and the release skill: a failing push run on main is reverted first and debugged second; the revert PR references the run.
  3. scripts/settle-against-base.sh <test-file> [-t name]: commits nothing, checks out origin/main detached in the current worktree, runs the named test, restores HEAD, prints both results as a fenced block for the PR body. The exec skill's pre-PR gate calls it for every red test outside the diff; the qa skill rejects a "pre-existing" claim whose PR body has no such block.
  4. PR template: no "known failures" field.

Release-graph plan — guard-2026-09 (2026-09-20)

Graph: guard-2026-09 Tier: judgment Wave: 2
May touch: scripts/settle-against-base.sh, scripts/settle-against-base.test.ts, scripts/ruleset-main.sh, scripts/preexisting-claim-gate.test.ts, docs/internal/graph-2026-09-guard/ruleset.md, CLAUDE.md, exec SKILL.md ×3, qa SKILL.md ×3, release SKILL.md ×3 (the red-main line only), CHANGELOG.md

The npm run build && npm test AC is verified by the runner from a clean shell after the PR opens (PLAN I-1); the agent runs only the test files its ACs name. Mutation markers use failedTest starting with the test file path (I-4). Skill edits: mirrors byte-identical (npm run lint:skill-sync 44/44) and no SKILL.md may contain the word relay (I-3). AC-2/AC-3 run the script against a real temp git repo, no mocked git (I-6). .github/PULL_REQUEST_TEMPLATE.md does not exist on main, so AC-5 passes by absence; do not create one.

Acceptance criteria

  • AC-1: scripts/ruleset-main.sh --print exits 0 and prints JSON whose .conditions.ref_name.include is ["~DEFAULT_BRANCH"], whose [.rules[].type] contains deletion, non_fast_forward and required_status_checks, and whose required-check rule names test with strict_required_status_checks_policy: true — Verify: scripts/ruleset-main.sh --print | jq -e '.conditions.ref_name.include == ["~DEFAULT_BRANCH"] and ([.rules[].type] | index("required_status_checks")) and (.rules[] | select(.type=="required_status_checks") | .parameters.strict_required_status_checks_policy == true and (.parameters.required_status_checks | map(.context) | index("test")))' → exit 0. Applying it is gate(owner): apply the main ruleset — target ~DEFAULT_BRANCH, require the test check, strict up-to-date #1109's AC.
  • AC-2: scripts/settle-against-base.sh exits 0 and prints a ### Settled against base block containing both the base and head results for the named test — Verify: npx vitest run scripts/settle-against-base.test.ts (temp repo where the test fails at base and passes at head, and the reverse) → green.
  • AC-3: the script never loses work: run it with an uncommitted edit present and the edit survives — Verify: same test file, case "preserves uncommitted changes".
  • AC-4: gate test — the exec skill's pre-PR section names the script and the qa skill's verdict section rejects an unbacked "pre-existing" claim, in all three skill copies — Verify: npx vitest run scripts/preexisting-claim-gate.test.ts → green. Mutation-verified per CLAUDE.md §Testing: remove the script reference from one copy → the test fails; restore.
  • AC-5: .github/PULL_REQUEST_TEMPLATE.md (if present) has no known-failures or pre-existing-failures section — Verify: grep -ci "known failures\|pre-existing" .github/PULL_REQUEST_TEMPLATE.md → 0, or the file does not exist.
  • AC-6: npm run build && npm test green.
  • AC-7: gate test — CLAUDE.md states the red-main rule (a failing push run on main is reverted first, debugged second, the revert PR references the run) and the release skill repeats it in all three copies — Verify: npx vitest run scripts/preexisting-claim-gate.test.ts -t "red-main" → green, scoped to the section between the rule's heading and the next ##. Mutation-verified per CLAUDE.md §Testing: delete the rule from CLAUDE.md → the test fails; restore.

Not in scope

Auto-revert automation. A human reverts; the rule just says which order.

Activity

  1. added
    enhancement
    github_actions
    on Sep 19, 2026
  2. admarble commented on Sep 20, 2026

    @admarble
    ContributorAuthor

    Runner context — guard-2026-09 wave 2 launch, 2026-09-20. Base: origin/main at bef0ac98 (all seven wave-1 PRs merged: #1086 scrub, #1104 marker docs, #1053, #1106 ownership gate, #1095 parsers, #1096 conformance suite, #1070 failing verdicts post). These rules override the exec AND qa skills' defaults for this run:

    • No full npm test in the worktree — this applies to the qa phase too. Under concurrent phase agents that one call exceeds the 30-minute no-progress wall and the phase is killed (three wave-1 phases died this way). Verify each AC by its own command; run only the test files the ACs name. The runner runs the full suite once per PR from a clean shell and records it on the PR.
    • A named test file red before your change: the suite is now hermetic (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), so a red file is real. Name the issue number and the base-vs-head result in the PR body.
    • Mutation marker (gate-test ACs): <!-- SEQUANT_MUTATION: {"ac":"AC-N","mutation":"<what you deleted>","failedTest":"<test file path> > <describe> > <case>"} --> in the PR body. failedTest MUST start with the test file path. Run parseMutationMarkers on your body before opening the PR. Commit before mutating.
    • 30-minute no-progress wall per phase. Commit a WIP checkpoint before any long command; every command foreground, with timeout.
    • Commits: single-line git commit -m "...", no Co-Authored-By. Push the branch and open the PR yourself (one wave-1 exec forgot). Never rebase or force-push after pushing. One AC per line in the PR body, ids AC-N only.
    • Stop at the PR. Do not merge.

    Issue-specific: Judgment tier. You are the only node editing skills this wave: after editing, npm run lint:skill-sync must report 0 diverged (the count is 44 or 45 files — check the number, not the prose), and no SKILL.md may contain the word relay. Gate tests in scripts/ must import and call a production function (the tautology detector fails the full suite otherwise; a brace-bearing regex literal inside it() also trips it — use line matching). AC-1 only prints the ruleset payload; the owner applies it in #1109. The settle-against-base.sh test runs against a real temp git repo (I-6).

  3. admarble commented on Sep 20, 2026

    @admarble
    ContributorAuthor

    Plan — #1093 (merge gate + mechanical "pre-existing" proof)

    Complexity: Standard (7 ACs, 4 directories) · Blocker #1104 is CLOSED — unblocked. Worktree feature/1093-ci-gate-... exists at bef0ac98, no commits yet.

    AC Quality Check

    lintAcceptanceCriteria → ✅ all 7 clear and testable; all 7 parse on a single line. One format note: the ACs use Verify: rather than the house Evidence: clause, so extractAcceptanceCriteria sets verificationMethod: "manual" on all seven and AC.evidence is empty on all seven. Consequence: /qa §6h (declared_evidence_status) will read N/A and the testgen auto-detector sees zero declared evidence. Not worth an edit now — flagged so the QA verdict isn't read as a coverage signal.

    detectBehaviorRule → no AC triggers (0/7), so no Rule Touchpoints table. That is a false negative: AC-4 and AC-7 are textbook multi-touchpoint rules (3 skill copies each, plus CLAUDE.md). The issue enumerates the touchpoints itself, so nothing is lost here — the touchpoints are in the plan below. Worth a follow-up on the detector's keyword set.


    Scope Assessment

    Non-Goals: present as ## Not in scope ("auto-revert automation") — the parser looks for Non-Goals and reports it missing. Cosmetic.

    Metric Value Status
    Feature count 3 ❌
    AC items 7 ⚠️
    Directory spread 3 ⚠️

    Verdict: ❌ SCOPE_SPLIT_RECOMMENDED — do not split. The three "features" are keyword clusters the detector invented (ui from AC-1+AC-6, api from AC-4/5/7); there is one coherent change: make the gate mechanical. Splitting would break a fixed wave-2 graph contract. Recording the verdict honestly and overriding it.


    Blocking findings — resolve before /exec

    B1 — AC-1 names a status check that does not exist (would hard-block main)

    ci.yml has no job named test. Real contexts on PR #1118:

    build (22.x)   node-floor-guard   typecheck   validate-skills   validate-plugin   tautology-advisory
    

    npm test runs inside the build job (ci.yml:10-37: lint → build → test → CLI smoke), whose check-run context is build (22.x) because of its single-entry matrix (node-version: [22.x]). A ruleset requiring the context test with strict_required_status_checks_policy: true would require a check that never reports — every PR to main blocks permanently, and #1109 (G-1) is the owner applying it by hand.

    Confirmed current state of ruleset CC (12393605): conditions.ref_name.include: [], rules deletion + non_fast_forward, bypass_actors: [], current_user_can_bypass: "never". The payload must preserve enforcement: "active" and the empty bypass_actors.

    Three ways out — owner picks, and must rewrite the AC-1 line in the issue body (a decision comment does not re-open exec):

    Change Cost Risk
    A (recommended) Require build (22.x); AC-1's jq asserts index("build (22.x)") ruleset script only matrix-suffixed context — changing node-version silently stops matching and blocks main
    B Drop the single-entry matrix from build so the context is plain build; require build +ci.yml (not in May touch) none material; removes A's footgun
    C Add a test: job to ci.yml; keep AC-1 verbatim +ci.yml, duplicated install/build slowest CI

    Recommendation: B. It keeps the required context stable against matrix edits, which is the failure mode A carries forever, and it costs three deleted lines. Either way tautology-advisory must stay optional — it is if: github.event_name == 'pull_request' and never runs on push.

    B2 — AC-2/AC-3's test file lands in the 5 s unit project

    vitest.config.ts puts every **/*.test.ts without .integration. in the unit project at vitest's default 5 s testTimeout. scripts/settle-against-base.test.ts builds a real temp git repo and runs a test at base and at head — it will not finish in 5 s. Exact precedent in the same config: scripts/qa/tautology-detector-cli.test.ts is excluded from unit and listed in integration for this reason.

    Recommendation: keep the AC's filename and Verify: command byte-identical; add scripts/settle-against-base.test.ts to the integration project's include and to unit's exclude list, mirroring the tautology entry. vitest.config.ts must be added to May touch. (Renaming the file to .integration.test.ts would instead force an AC-2/AC-3 text edit — strictly more expensive.)

    B3 — AC-4's qa edit must wire a §7 gate, or lint:skill-gates fails CI

    npm run lint:skill-gates runs in the validate-skills job and enforces invariant I1: a /qa section declaring a verdict floor needs a status token in §7 step 2 and a branch on it in step 4. The two shipped defects it was written for (§2h, §6f) were exactly prose-only floors. So "the qa skill rejects an unbacked pre-existing claim" cannot be prose.

    Recommendation: add settle_evidence_status (Backed / Unbacked / N/A) to §7 step 2 (skills/qa/SKILL.md:2621-2630) and an ELSE IF settle_evidence_status == "Unbacked" floor in step 4 (~:2655-2661), alongside the existing trust_boundary_status / cli_registration_status branches. Natural home for the section itself: §2a Build Verification's "Pre-existing failure" row (:1349), which today says only "document it with a linked issue".


    Acceptance Criteria

    AC-1: ruleset payload prints with ~DEFAULT_BRANCH + required test, strict

    Verification: Integration Test — scripts/ruleset-main.sh --print | jq -e '...' → exit 0
    Scenario: Given no gh network call → When --print runs → Then stdout is a valid ruleset PUT body with include: ["~DEFAULT_BRANCH"], the three rule types, strict_required_status_checks_policy: true
    Assumptions: ⚠️ blocked by B1 — the required context is not test. Also: the script must never call gh api -X PUT; --print is its only mode.

    AC-2: settle-against-base.sh prints base and head results

    Verification: Integration Test — npx vitest run scripts/settle-against-base.test.ts
    Scenario: Given a temp git repo where a named test is red at base and green at head (and the reverse) → When the script runs → Then stdout carries a ### Settled against base fenced block with both results and exit 0
    Assumptions: ⚠️ blocked by B2. I-6 keeps git real; the test runner is substituted via an env override (below) — that substitution is a design decision, called out so QA does not read it as a mocked seam.

    AC-3: never loses work

    Verification: Integration Test — same file, case "preserves uncommitted changes"
    Scenario: Given an uncommitted edit (and an untracked file) → When the script runs → Then the edit is byte-identical afterwards, HEAD points at the original branch, and no stash entry is left behind

    AC-4: gate test — exec names the script, qa rejects an unbacked claim, ×3 copies

    Verification: Integration Test — npx vitest run scripts/preexisting-claim-gate.test.ts; mutation-verified
    Scenario: Given all three SKILL.md copies → When the gate test reads each pre-PR / verdict section → Then both assertions hold in all three
    Assumptions: ⚠️ blocked by B3

    AC-5: PR template has no known-failures field

    Verification: Manual — file absent on main
    Scenario: .github/PULL_REQUEST_TEMPLATE.md does not exist → AC passes by absence; do not create one
    Assumptions: Note grep -ci <pat> <missing-file> prints nothing and exits 2, not 0 — the AC's own "or the file does not exist" clause is what carries it. This AC is non-gating: nothing stops a future template from adding the field. Accepted as-is; not worth a test that asserts the absence of an absent file.

    AC-6: npm run build && npm test green

    Verification: Integration Test — runner-owned, from a clean shell after the PR opens (I-1). The agent runs only the test files its own ACs name.

    AC-7: gate test — red-main rule in CLAUDE.md + release skill ×3

    Verification: Integration Test — npx vitest run scripts/preexisting-claim-gate.test.ts -t "red-main"; mutation-verified
    Scenario: Given CLAUDE.md → When the test reads the region between the rule's heading and the next ## → Then it states revert-first/debug-second and that the revert PR references the run; and all three release/SKILL.md copies repeat it
    Assumptions: ⚠️ ambiguity — Change §2 says "CLAUDE.md's hooks/commit section", but AC-7 scopes to "the rule's heading → next ##". CLAUDE.md today has exactly four ## sections (Commit Rules, Hooks, Skills, Testing). Recommendation: give the rule its own ## Red main section so the scoping is unambiguous and deleting the rule fails exactly this test. Reading it as "inside ## Hooks" would make the mutation also delete unrelated hook prose.


    Implementation Plan

    Phase 1 — the script and its test (AC-2, AC-3)

    1. scripts/settle-against-base.sh <test-file> [-t name]. Preflight: refuse if HEAD is already detached or a rebase/merge is in progress. git stash push --include-untracked → git checkout --detach origin/main → run the test → restore → git stash pop, all guarded by a trap ... EXIT INT TERM that restores HEAD and pops before exiting. Read base via origin/main, never the main checkout (I-7).
    2. Unset every SEQUANT_* var for both runs — the suite is not hermetic against the orchestrator's env (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), and a base/head comparison under different envs proves nothing. The exec skill already documents the env $(printenv | grep -o '^SEQUANT_[A-Z_]*' | sed 's/^/-u /') form at skills/exec/SKILL.md:1226; reuse it verbatim.
    3. Distinguish "test file absent at base" from "test failed at base" in the printed block. A brand-new test file errors at base, and without this the block reads as proof of a pre-existing failure — the exact claim this issue exists to make unfakeable. See Derived ACs.
    4. SETTLE_TEST_CMD env override (default npx vitest run) so the temp-repo test can substitute a trivial runner. Git stays real (I-6); a nested real vitest per case would push the file toward the 30-min wall.
    5. scripts/settle-against-base.test.ts — real git init temp repo, four cases: red-at-base/green-at-head, the reverse, "preserves uncommitted changes", and test-file-absent-at-base. Add to integration per B2.

    Phase 2 — skill and doc edits (AC-4, AC-7)

    1. Edit .claude/skills/ first (canonical per scripts/check-skill-sync.ts:8), then npm run sync:skills; verify npm run lint:skill-sync reports 0 diverged — read the file count (44 or 45), not the prose (I-3). Confirm no SKILL.md gained the word relay.
      • exec/SKILL.md ~:1219-1229 — name scripts/settle-against-base.sh in the pre-PR gate, called for every red test outside the diff.
      • qa/SKILL.md §2a ~:1349 + §7 steps 2/4 — the settle_evidence_status wiring from B3.
      • release/SKILL.md — the red-main line only.
    2. CLAUDE.md: new ## Red main section (per AC-7's scoping note).
    3. scripts/preexisting-claim-gate.test.ts, modelled on scripts/exec-skill-marker.test.ts (docs(exec/qa): the SEQUANT_MUTATION failedTest contract (<test file> > <name>) is enforced by the classifier but never told to authors — tripped 2 of 4 gate PRs #1104): section-scoped markerSection-style reader, line matching not brace-bearing regex literals, and a real production import — collectFiles from scripts/check-skill-sync.ts to enumerate the three dirs structurally rather than hardcoding them. Both satisfies the tautology detector and makes "all three copies" survive a fourth mirror.

    Phase 3 — payload and docs (AC-1)

    1. scripts/ruleset-main.sh --print — --print only, no gh api -X PUT, preserving enforcement: "active" and bypass_actors: []. Gated on B1's resolution.
    2. docs/internal/graph-2026-09-guard/ruleset.md — field-by-field, including why the required context is spelled the way B1 settles on.
    3. CHANGELOG.md last, in one commit. ⚠️ Every wave-1 squash re-conflicted CHANGELOG.md, and the docs-2.16 worktree is also editing it — expect a merge round at PR time.

    Mutation records (AC-4, AC-7)

    Commit first (git status --short | wc -l = 0), then per CLAUDE.md §Testing. failedTest must start with the test file path (I-4) — run parseMutationMarkers on the PR body before opening:

    <!-- SEQUANT_MUTATION: {"ac":"AC-4","mutation":"removed the settle-against-base.sh reference from templates/skills/exec/SKILL.md","failedTest":"scripts/preexisting-claim-gate.test.ts > preexisting claim gate > exec skill names the settle script in all three copies"} -->
    

    Design Review

    1. Where does this logic belong? A shell script in scripts/, not TypeScript: it manipulates the worktree the test runner runs in, so it must survive the runner's own process. The skills only name it; the enforcement floor lives in /qa §7, which is the only place a verdict can actually be blocked.
    2. Simplest correct approach? In-place detach + stash with a restoring trap. Rejected: a throwaway git worktree add --detach at origin/main, which is structurally incapable of losing work — but a fresh worktree has no node_modules and triggers vitest.global-setup.ts's full build, which is how phases hit the 30-min wall. The trap is the cheaper guarantee, and AC-3 tests it.
    3. Existing pattern? scripts/exec-skill-marker.test.ts for the gate tests; scripts/qa/tautology-detector-cli.test.ts for the integration-project registration; §7's trust_boundary_status for the verdict floor. All three are in-repo and current.
    4. What would a senior reviewer challenge? "AC-3's test passes trivially." Fair — the happy path alone is near-tautological, since nothing in it exercises the trap. The honest bar is killing the script mid-run and asserting the tree is intact; that is Derived AC D3, and it is the only case that distinguishes a working trap from no trap at all.

    Feature Quality Planning

    • AC-5 is non-gating and stays that way — see AC-5 above.
    • AC-6 is runner-owned. Under concurrent wave-2 phases a full npm test in the worktree exceeds the 30-min no-progress wall; three wave-1 phases died that way.
    • npm run lint:skill-gates, lint:skill-sync, lint:skill-calls and the tautology detector all gate this diff in validate-skills — run them before the PR, they are seconds each.

    Derived ACs

    Source Derived AC Priority
    Correctness D1: the block distinguishes "test file absent at base" from "test failed at base" High
    Hermeticity D2: base and head runs execute with every SEQUANT_* var unset (#1086) High
    AC-3 rigor D3: SIGTERM mid-run leaves HEAD on the original branch, the edit intact, no stash left Medium
    B2 D4: scripts/settle-against-base.test.ts is registered in the integration project High

    Open Questions

    1. B1 — which status check does the ruleset require? Recommendation: option B (drop build's single-entry matrix, require build). Impact if wrong: applying the payload in gate(owner): apply the main ruleset — target ~DEFAULT_BRANCH, require the test check, strict up-to-date #1109 blocks every merge to main until the ruleset is hand-edited back. Needs an edit to the AC-1 line in the issue body, by the owner — a decision comment alone will not re-open exec.
    2. AC-7 heading placement — own ## Red main section vs inside ## Hooks. Recommendation: own section. Impact if wrong: the mutation deletes unrelated prose and the gate proves less than it claims.
    3. Does vitest.config.ts join May touch? Recommendation: yes (B2). Impact if wrong: AC-2/AC-3 are red at 5 s regardless of whether the script is correct.

    Recommended Workflow

    Phases: exec → qa
    Quality Loop: enabled
    Reasoning: testgen skipped deliberately, against the decision table's "Integration Test ACs → recommend testgen": here the test files are the deliverable (AC-2/3/4/7 are gate tests), and /testgen characteristically leaves todo stubs — a stub is the failure mode these ACs exist to prevent. Quality loop on: seven ACs across three mirrored skill copies plus a §7 verdict-gate wiring, where a single unsynced mirror fails CI. verify is not an orchestrated phase — /qa §11 script_verification_status already fires because scripts/ is modified, so script execution evidence is required in the QA pass.


    Label Review

    Current: enhancement, github_actions
    Recommended: add planned
    Reason: no .tsx/.jsx anywhere, so no ui label and no browser test. No complex label — 7 ACs sit in the Standard band.
    Quality Loop: enabled above by explicit reasoning, not by the scope heuristic (whose SPLIT verdict is overridden).


    Conflict Risk

    Four wave-2 worktrees are checked out at bef0ac98 with zero commits — no overlap yet. docs-2.16 has CHANGELOG.md + src/lib/settings.ts in flight; only CHANGELOG.md overlaps. Keep the CHANGELOG edit in its own final commit.

    Do not merge. Stop at the PR.

  4. added
    planned
    on Sep 20, 2026
  5. added a commit that references this issue on Sep 20, 2026
  6. admarble commented on Sep 20, 2026

    @admarble
    ContributorAuthor

    QA Verdict: AC_MET_BUT_NOT_A_PLUS

  7. added a commit that references this issue on Sep 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementgithub_actionsplanned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions