Skip to content

Run the code-boundary ratchet in the push check and before the merge slot - #3390

Merged
mstomar125 merged 2 commits into
mainfrom
issue-3300-ratchet-push-check
Sep 30, 2026
Merged

mstomar125 merged 2 commits into
mainfrom
issue-3300-ratchet-push-check

Conversation

@mstomar125

Copy link
Copy Markdown
Contributor

Summary

Run scripts/check-pro-boundary.ts (the code-boundary ratchet from #3376) as a stage in the lint section of scripts/test-gate.ts, after check-version-sync.

  • Push: frontend-only and .md-only diffs skip the scripts tier in test:changed, so until now they met the ratchet only in the merge gate. A push now runs it.
  • Merge: the lint section runs before acquireGateLock, so a raised count fails in seconds instead of minutes into a run that holds the machine slot.

Also updates the test-gate.ts header (push bullet) and CLAUDE.md (gate callout push bullet, the Pro / Sync Boundary section's "where it runs" clause and its last bullet).

Closes #3300

Deviations from the issue text

The issue was written when the ratchet compared counts for equality. #3376 landed it one-way: it fails only when a count rises above its baseline, and a count below its baseline prints a notice and exits 0. So:

  • The stage comment says "a raised count fails", not "a stale baseline fails".
  • Acceptance criteria 2 and 3 ("removing a marker without lowering the baseline is blocked", the README nodespaced-pro deletion) no longer hold by design. I ran the README deletion through the push check: it passes, and the "lower it" notice with the paste block goes to the stage log (editionBranching 113 -> 112, plus the other lowered counts). The stage prints only ✓ for a passing run, so that notice is in the log file, not on screen.
  • CLAUDE.md gets one edit beyond the two in the issue: the section's bullet said the check "runs in bun run test:scripts (every merge gate)". That is now incomplete, so it also names the push check and the merge gate's lint section.

Ratchet delta

None. This change adds and removes no marker (the stage label and comment name the rule by its ADR and avoid the marker words). BASELINES is unchanged, and the check exits 0:

marker              count  baseline
proCommands           275       275
proSyncModule         368       368
proProtocol            95        95
proEvents              81        81
membershipService      54        54
editionBranching      113       113
cloudBindState        203       203
cloudSyncHooks          0         4
cloudWording           74        74
tenantWording         463       463
proWording            282       282
proNamedFiles          18        18

cloudSyncHooks is 0 against a baseline of 4, from an earlier removal that did not tighten. Left as is (the check itself is out of scope); it is 4 lines of headroom until someone lowers it.

Verification

bun run scripts/test-gate.ts (push mode), each change reverted afterwards:

Run Result
Clean tree passes; the new stage takes 1s
invoke('pro_example') added to a non-Pro Svelte file blocked at check-pro-boundary, exit 1; the stage log names pty-terminal.svelte:109 under "In files this branch changed"
README nodespaced-pro sentence deleted passes (one-way ratchet); notice in the stage log
Same marker run with --mode=merge fails at the new stage in 3.7s, before the machine slot is requested (no slot wait printed), "merge blocked"

Mutation check: with the stage removed from test-gate.ts, the marker-adding push passes (exit 0), so the block above comes from the new stage.

No unit test was added: test-gate.ts runs its gate at import, so it can't be imported by a test, and the issue specifies the runs above as the verification.

Note for follow-up (not changed here)

On a failing run the gate prints only the last 40 lines of the stage log. The ratchet prints the failure and "All hits" first and the notice block last, so on screen a failure shows the tail of the hit list and the notices, not the offending line. The log path is printed and the full log names the line. Reordering that output is a change to the check, which this issue excludes.

🤖 Generated with Claude Code

@mstomar125

mstomar125 commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor Author

Pragmatic Code Review: PR #3390 (initial review, medium depth)

Review Type: Tooling / gate wiring (scripts/test-gate.ts, CLAUDE.md). No product code. Reviewed at head 5c545b2f, which is based on current main (a7a19066); the PR is mergeable.

Requirements Check (issue #3300)

Acceptance criterion Status Notes
Push adding a marker line to a Svelte file is blocked at check-pro-boundary, and the stage log names the line ✅ The stage exits 1 through run(), so the push is blocked. The failure text includes "In files this branch changed" (check-pro-boundary.ts:428), and the full output goes to the stage log. The path uses the same changedFilesSinceMain and baselineFailures code the author exercised.
Push removing a marker without lowering the baseline is blocked with the lower-it message ❌ by design Not achievable. The landed ratchet is one-way: baselineFailures skips count <= baseline (check-pro-boundary.ts:419), and a lower count only prints a notice and exits 0. The PR body states this.
README-only deletion of the nodespaced-pro sentence is blocked ❌ by design Same cause as the row above. The PR reports it passes with the notice in the stage log.
Clean branch pushes, adding about a second ✅ I ran bun run scripts/check-pro-boundary.ts in the worktree: exit 0, 1.35s wall clock.
This PR's own merge-gate log shows the stage before the machine-slot wait ⏳ It can only be observed at merge time. By construction the stage sits before if (!merge) and before acquireGateLock, so it holds.
Header comment and CLAUDE.md push bullet list the new check ✅
BASELINES unchanged and the check exits 0 ✅ The printed table is identical to the PR body's delta table. The only notice is cloudSyncHooks 0 against a ceiling of 4, which already exists on main.

The three deviations in the PR body (stage comment says "a raised count fails", the two acceptance criteria that can't hold, and the third CLAUDE.md edit) are correct against check-pro-boundary.ts. The third CLAUDE.md edit, to the section's "where it runs" clause, is warranted: the old text named only test:scripts.

Verification of the specific concerns

  1. Placement and ordering. ✅ The stage (scripts/test-gate.ts:198-203) is the last lint stage. It comes after check-version-sync, before if (!merge) at line 205, and before acquireGateLock. It runs sequentially, so run()'s failed and killActiveStages handling is unaffected. A failure calls process.exit(1) before any lock is held, so nothing leaks. nice: !merge and the 5-minute timeoutMs match the sibling stages. The log name from stageLogName (gate-output.ts:12) is check-pro-boundary-adr-081-code-boundary-ratchet.log: parentheses and hyphens collapse to -, it is well under the 80-character cap, and it is unique among the stage labels.
  2. No marker added. ✅ I ran all 14 added lines of test-gate.ts against every MARKERS pattern and got 0 hits. The lowercase check-pro-boundary matches no pattern, and test-gate.ts is not a pro-named file. BASELINES is untouched. CLAUDE.md is outside the scan.
  3. Flakiness or slowness for unrelated pushes. No new risk from this PR.
    • The checker already removes GIT_DIR, GIT_WORK_TREE, GIT_INDEX_FILE, GIT_COMMON_DIR and GIT_PREFIX before shelling out (check-pro-boundary.ts:235-244), so the pre-push hook environment and linked worktrees are handled.
    • It derives REPO from import.meta.url, not from the cwd.
    • changedFilesSinceMain catches every error and returns [], so a missing origin/main or a shallow clone only loses the hit ordering, never fails the stage.
    • There is no network access.
    • Two pre-existing behaviours become visible at push time. They are by design and identical to what test:scripts already does at merge: the scan includes untracked, non-ignored files under packages/ and scripts/, so a stray scratch file containing a marker word blocks the push (the message names the file); and exemptionProblems fails on a stale EXEMPTIONS entry. I'm not raising either.
  4. Documentation accuracy. ✅ The header comment and the three CLAUDE.md edits are accurate. The remaining "lint only" strings (test-gate.ts:162 banner, CLAUDE.md:220, :267, :279, :293, test-changed.ts:4, merge-pr.ts:10) use "lint" as a category label for "no tests run". They stay true, and rewording them all would only add churn. The .husky/pre-push hook is just bun run scripts/test-gate.ts, so nothing else there describes the check. check-pro-boundary.test.ts:6 and :1178 call the bun-test the "enforcement path"; that is still true, and editing them is out of scope ("no change to the check").
  5. PR body claims. ✅
    • The passing-run notice does land only in the stage log, because runStage prints only ✓ <label> Ns on exit 0 (gate-stage.ts:214-217).
    • On failure the screen gets tail(…, 40) (gate-stage.ts:225).
    • Both the stage-order and "before the slot" claims match the code.
  6. No new unit test. ✅ Justified. test-gate.ts runs the gate at import time, so a test would have to spawn a full gate run and assert on the stage list. That is a slow, brittle source-shape test, and the underlying check is already covered by check-pro-boundary.test.ts, including the real-repo block at line 1176. The author's mutation check (stage removed, marker-adding push passes) covers the wiring.

Code Review Findings

No blockers.

🟢 Suggestion: file the follow-up issue for the failure output; the PR body mentions it but none exists.
📁 scripts/check-pro-boundary.ts:527-532 (order of output), scripts/gate-stage.ts:225 (tail of 40), scripts/merge-pr.ts:99 (EJECT_TAIL_LINES = 40)

  • What the screen shows. The checker prints the table, then the ❌ failures (hit lists of up to hundreds of lines), then the notices. The gate then keeps only the last 40 non-empty lines.
  • Today's tail is mostly a notice. cloudSyncHooks is 0 against a ceiling of 4, so a notice is always present: one line plus a 26-line paste block, about 28 lines. That leaves roughly 11 lines of the final marker's "All hits" list, and the ❌ <marker> … above its baseline headline plus the "In files this branch changed" block scroll off. The blocked push tells the author "Fix it (bun run quality:fix fixes most lint)" and shows a paste block labelled "Optional, not a failure", with the offending line only in the log file.
  • Same view at merge. The merge queue's eject comment is built from the same 40-line tail, so the author sees the same view there.
  • Not a regression. The failure previously surfaced through test:scripts with a similarly truncated tail, and this PR's acceptance criterion ("the stage log names the line") is met. The fix belongs in the checker, which the issue excludes. Suggest filing it now: print the ❌ headlines and the changed-file hits last, or print notices before failures. I searched open and closed issues and found none. Drive every Pro-boundary ratchet count to zero and make the check a hard ban #3371 will remove the cloudSyncHooks headroom once it drives every count to zero.

🟢 Nit: the CLAUDE.md line 116 clause reads "runs in bun run test:scripts (every merge gate), in the push check, and in the merge gate's lint section". It is accurate but says "merge gate" twice. Optional wording: "…in the push check and in every merge gate (its lint section, before the machine slot, and bun run test:scripts)".

Observation (no action): the merge gate now runs the ratchet twice, in the lint stage and in the test:scripts real-repo test, about 1s of duplication. That is what the issue specifies, and the early stage is the one that fails before the slot.

Recommendation

APPROVE. The change is small and atomic. The stage sits at the right point in the gate, adds no marker, changes no baseline, and its docs match the code. The deviations from the issue are correctly derived from the one-way ratchet that landed. Ready to merge through bun run merge 3390. GitHub blocks self-approval, so this is posted as a comment.

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

Automated pragmatic-code-review: APPROVE (posted as a comment — GitHub blocks self-approval). Full findings in the review comment above.

@mstomar125

Copy link
Copy Markdown
Contributor Author

Address-review summary

Review verdict was APPROVE with no blockers. Two non-blocking items:

  • ✅ Addressed: CLAUDE.md wording nit. The "where it runs" clause named the merge gate twice. Reordered so it reads "the push check, the merge gate's lint section before it takes the machine slot, and bun run test:scripts (every merge gate)". Commit 1537827. Wording only; CLAUDE.md is outside the ratchet's scan, and the ratchet still exits 0 with BASELINES unchanged.
  • ⏭️ Skipped: file a follow-up for the failure output. The fix is in check-pro-boundary.ts (print the ❌ headlines and changed-file hits last, or notices before failures). This issue excludes any change to the check, so it stays out of this PR. Noted in the PR body and passed to the coordinator, who can file it. I'd revisit it in this PR only if the issue's scope were widened.

The push check ran the new stage on this push (check-pro-boundary ... 1s, passed).

Re-Review Decision

Decision: NO RE-REVIEW NEEDED

Rationale: The only change since the review is one reordered clause in CLAUDE.md. No code, no script and no baseline moved.

🤖 Generated with Claude Code

mstomar125 and others added 2 commits September 30, 2026 13:30
…slot

Add a check-pro-boundary stage to the lint section of test-gate.ts, after the
app-version drift check. test:changed skips the scripts tier for frontend-only
and .md-only diffs, so until now such a change met the ratchet only in the merge
gate's test:scripts tier, after the machine slot. Both modes now run it in
about a second, and in merge mode a raised count fails before the slot is taken.

The stage's label and comment name the rule by its ADR and avoid the marker
words, so the change adds no marker and moves no baseline. CLAUDE.md lists the
check in the push bullet and says where it runs.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@mstomar125
mstomar125 force-pushed the issue-3300-ratchet-push-check branch from 1537827 to 1fe60eb Compare September 30, 2026 11:30
@mstomar125
mstomar125 merged commit c18e4b5 into main Sep 30, 2026
@mstomar125
mstomar125 deleted the issue-3300-ratchet-push-check branch September 30, 2026 11:30
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.

Run the Pro-boundary ratchet in the push check and before the merge slot

1 participant