Skip to content

fix(ci): ratchet env budget to actual and enforce pre-merge - #125189

Merged
steipete merged 1 commit into
mainfrom
steipete/env-budget-repair
Aug 17, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/env-budget-repair

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Resolves a CI gap where pull requests could change the counted production environment-variable surface without running the environment-budget ratchet in the pre-merge baseline lane. The mismatch would otherwise first surface on main.

Why This Change Was Made

The existing environment gate requires the committed budget to equal the actual distinct OPENCLAW_* count, rejects stale headroom, and permits only named owner-approved growth relative to the branch fork. Cleanup may therefore ratchet the budget down, but ordinary changes cannot silently raise it.

PR #124812 (a917c99e92c) moved the internal OPENCLAW_PROCESS_NODE_VERSION_CHECK helper out of the scanned production roots, dropping the counted set from 502 to 501. PR #125185 (87a0493ae27) restored the budget to that actual count. This follow-up closes the remaining timing gap.

PR #124720 established checks-fast-baseline-ratchets as the owner of one frozen fork-point ref. Instead of changing the workflow again, its existing max-lines script entry now chains the environment-budget gate with the same forwarded --base or --staged snapshot before the assertion-safety check. This preserves the exact-tree semantics and avoids a workflow-file authorization dependency.

User Impact

No user-visible product behavior changes. Maintainers now get environment-budget failures on the pull request that introduces them rather than after merge.

Evidence

$ node --import tsx scripts/check-max-lines-ratchet.mts --base origin/main
max-lines ratchet OK: 904 grandfathered suppressions.
OPENCLAW_* count 501/501

$ node scripts/run-vitest.mjs test/scripts/ci-workflow-guards.test.ts
exit 0

$ pnpm check:changed
exit 0

Autoreview reported no accepted or actionable findings and classified the patch as correct with 0.99 confidence.

@clawsweeper

clawsweeper Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@steipete steipete self-assigned this Aug 17, 2026
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation scripts Repository scripts size: XS maintainer Maintainer-authored PR labels Aug 17, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper review

@clawsweeper

clawsweeper Bot commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper

clawsweeper Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 17, 2026, 5:29 AM ET / 09:29 UTC.

ClawSweeper review

What this changes

This PR adds the existing environment-variable budget check to the pre-merge baseline-ratchet entrypoint and documents and tests that CI coverage.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

No blocking correctness finding: the change forwards the same base/staged snapshot into the existing environment-budget guard, and its exact-head baseline-ratchet CI check passed. This maintainer-labeled PR remains open for normal exact-head CI completion and maintainer merge handling.

Priority: P3
Reviewed head: 013187009f9d8c49032afce220b80e0a33dd5f05

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused implementation, source-backed guard contract, regression coverage, and successful exact-head baseline CI support a normal-good rating.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored internal CI change is outside the external-contributor real-behavior-proof gate; the supplied exact-head CI result is relevant supplemental evidence.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored internal CI change is outside the external-contributor real-behavior-proof gate; the supplied exact-head CI result is relevant supplemental evidence.
Evidence reviewed 7 items Current-main gap: Current main's baseline-ratchet workflow invokes only the max-lines and assertion-safety commands, so the environment budget is not part of this pre-merge task.
PR implementation: The branch adds a wrapper that preserves only --staged and --base when calling the existing environment-budget guard after max-lines succeeds.
Callee contract: The existing environment guard validates its arguments, derives the fork merge base, rejects unapproved budget growth, and requires the actual count to equal the committed budget.
Findings None None.
Security None None.

How this fits together

The fast CI baseline lane checks repository budgets against one frozen pull-request base before merge. Its ratchet script now passes that same base or staged snapshot to the environment-variable budget guard, producing a CI pass or failure before the assertion-safety check runs.

flowchart LR
  A[Pull request merge tree] --> B[Frozen base reference]
  B --> C[Baseline ratchet entrypoint]
  C --> D[Max-lines budget]
  C --> E[Environment-variable budget]
  D --> F[Pre-merge CI result]
  E --> F
Loading

Before merge

  • Resolve merge risk (P1) - This changes a pre-merge CI execution path and is behind current main, so merge should wait for exact-head CI to complete after the final merge-base refresh.
  • Complete next step (P2) - No repair is needed; the maintainer label keeps final merge handling human-owned while exact-head CI finishes.
Agent review details

Security

None.

PR surface

Tests +5, Docs 0, Other +22. Total +27 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 1 6 1 +5
Docs 1 2 2 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 23 1 +22
Total 3 31 4 +27

Review metrics

Metric Value Why it matters
Production versus test delta tooling +23/-1 (net +22); tests +6/-1 (net +5); docs +2/-2 The tooling growth is the wrapper that carries the existing environment guard through the frozen-baseline entrypoint; test growth pins that integration.
Pre-merge budget coverage 1 existing environment-budget guard added to 1 baseline CI path The change makes mismatched production environment-variable budgets fail on the pull request rather than first appearing on main.

Merge-risk options

Maintainer options:

  1. Require final exact-head CI (recommended)
    Refresh the mergeable head and require the baseline-ratchet job plus remaining required checks to pass before merging this CI-path change.

Technical review

Best possible solution:

Keep one frozen base reference for all three ratchets and land after the combined guard passes on the final mergeable head.

Do we have a high-confidence way to reproduce the issue?

Yes, source-reproducible: current main's baseline-ratchet task omits the environment-budget command, while the PR head's successful baseline-ratchet CI run exercises the added path.

Is this the best way to solve the issue?

Yes: reusing the existing CI-invoked ratchet entrypoint preserves the frozen base and delegates policy to the established environment-budget guard instead of duplicating its logic in the workflow.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 1df264d3f510.

Labels

Label changes:

  • add P3: This is focused internal CI maintenance with no runtime product behavior change.
  • add merge-risk: 🚨 automation: The PR changes how the pre-merge baseline-ratchet task executes and fails.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.

Label justifications:

  • P3: This is focused internal CI maintenance with no runtime product behavior change.
  • merge-risk: 🚨 automation: The PR changes how the pre-merge baseline-ratchet task executes and fails.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.

Evidence

What I checked:

  • Current-main gap: Current main's baseline-ratchet workflow invokes only the max-lines and assertion-safety commands, so the environment budget is not part of this pre-merge task. (.github/workflows/ci.yml:1937, 1df264d3f510)
  • PR implementation: The branch adds a wrapper that preserves only --staged and --base when calling the existing environment-budget guard after max-lines succeeds. (scripts/check-max-lines-ratchet.mts:390, 013187009f9d)
  • Callee contract: The existing environment guard validates its arguments, derives the fork merge base, rejects unapproved budget growth, and requires the actual count to equal the committed budget. (scripts/check-env-var-count.mts:113, 013187009f9d)
  • Changed-surface test: The CI workflow guard test verifies that the fast baseline lane retains the frozen-base invocation and that the max-lines entry imports and calls the environment-budget guard. (test/scripts/ci-workflow-guards.test.ts:5728, 013187009f9d)
  • Exact-head CI proof: The supplied check context records checks-fast-baseline-ratchets as successful for this PR head, exercising the combined entrypoint in CI. (013187009f9d)
  • History and ownership: Blame attributes the new forwarding wrapper to this PR commit; the surrounding baseline-ratchet implementation dates to the prior merged CI alignment work. (scripts/check-max-lines-ratchet.mts:390, 013187009f9d)

Likely related people:

  • steipete: Authored the current PR and the preceding merged environment-budget and baseline-ratchet work that owns this path. (role: recent CI ratchet contributor; confidence: high; commits: 013187009f9d, 87a0493ae272, 569835e8b0aa; files: scripts/check-max-lines-ratchet.mts, scripts/check-env-var-count.mts, .github/workflows/ci.yml)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Refresh the mergeable head and let all required exact-head checks finish before merge.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@steipete

Copy link
Copy Markdown
Contributor Author

ClawSweeper's P1 is technical merge drift only. Exact-head CI completed green on 013187009f9d8c49032afce220b80e0a33dd5f05, including checks-fast-baseline-ratchets and openclaw/ci-gate; there are no code findings to repair. The native scripts/pr prepare gate will refresh and validate the final merge base before merge, so no patch change is needed for this rank-up move.

@steipete
steipete merged commit fbd910d into main Aug 17, 2026
148 checks passed
@steipete
steipete deleted the steipete/env-budget-repair branch August 17, 2026 09:33
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation maintainer Maintainer-authored PR scripts Repository scripts size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant