Repository navigation
ci: ratchet total test lines - #182230
ci: ratchet total test lines#182230
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8fef11b5d7
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| for (const file of files) { | ||
| const descriptor = fs.openSync(path.join(root, file), "r"); |
There was a problem hiding this comment.
Exclude unstaged deletions from the working-tree count
When a developer deletes a tracked test without staging the deletion, the documented pnpm check:test-lines-ratchet --prune cleanup flow fails with ENOENT instead of lowering the ceiling. git ls-files -h describes its default as “show cached files in the output,” so the deleted path remains in files, and this unconditional open throws before pruning can run. Skip paths deleted from the working tree in non-staged mode while preserving index-based counting for --staged.
Useful? React with 👍 / 👎.
Set the initial ceiling to 6,535,000 (main 8b7d54a total 6,525,641 plus ~9.4k headroom).
|
Codex review: needs changes before merge. What this changesAdds a repository-wide test-line ceiling that blocks net growth above the budget while allowing non-growing changes. Example: A comparison-based check finds 6,524,500 test lines against a ceiling of 6,524,466, with a net delta of -20.
Review scores
ProductKind: Maintenance · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Needs changes before merge - 2 items remain Keep this maintainer-authored PR open: the CI ceiling is useful, but unstaged deletions break pruning and the workflow addition causes a confirmed CI test failure. Priority: P2 Before merge
Findings
Agent review detailsHow this fits togetherThe repository CI ratchet runner invokes the new checker, which reads tracked test files, the comparison commit, and a committed ceiling to produce diagnostics and an exit status. flowchart TD
A[CI workflow] --> B[Baseline ratchet runner]
B --> C[Test line checker]
D[Tracked test files] --> C
E[Comparison commit] --> C
F[Committed ceiling] --> C
C --> G[Diagnostics and exit status]
Technical reviewBest possible solution: Keep the existing ratchet architecture and approved ceiling policy, handle unstaged deletions in the working-tree counter, and update the workflow fixture for the added command. Do we have a high-confidence way to reproduce the issue? Source establishes the unstaged-deletion failure, and exact-head CI reproduces the workflow fixture mismatch; no local execution was performed. Is this the best way to solve the issue? A domain-specific counter reusing the existing ratchet parser, snapshot helpers, and aggregate runner is appropriately scoped; no additional owner or framework is needed. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 4f2b1beecb99. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceAcceptance criteria:
What I checked:
Likely related people:
PR surfaceTests +57, Docs +12, Config +5, Other +142. Total +216 across 8 files. Added test files: 1. View PR surface stats
Review metrics
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed October 24, 2026, 1:17 AM ET / 05:17 UTC. |
|
Merged via explicitly authorized admin squash with attributed pre-existing CI failures.
|
* ci: ratchet total test lines * ci: gate over-budget test lines on net growth * fix(ci): count unstaged test deletions in the line ratchet Set the initial ceiling to 6,535,000 (main a370dc2 total 6,525,641 plus ~9.4k headroom). * test(ci): count the test-lines check in main push ratchets
What Problem This Solves
Test-reduction gains need a CI ceiling without blocking unrelated or test-deletion PRs when concurrent changes have already pushed main over that ceiling.
User Impact
With a comparison base, an ordinary check fails only when the tracked tree is above the ceiling and this change adds test lines overall. Zero-growth and shrinking changes pass with an over-ceiling notice. There is no runtime behavior change.
Why This Change Was Made
The checker counts newline-terminated lines like
wc -lover the campaign's exact tracked Git pathspecs, streaming files in 64 KiB chunks. It usesgit diff --numstat -z <base> -- <same pathspecs>to calculate this change's net delta, adding--cachedfor staged checks. Binary-entries contribute zero, and NUL-delimited rename paths are handled separately.When the total exceeds the ceiling and the delta is positive, the failure reports the total, ceiling, overage, and net delta. Contributors can offset their added lines by deleting or consolidating tests elsewhere, or manually raise
config/test-lines-baseline.txtwith PR justification. When no comparison base resolves, the ordinary check retains the absolute ceiling comparison.The ceiling is 6,535,000: main
8b7d54a9f2f82measured 6,525,641 tracked test lines, plus about 9.4k headroom so ordinary test additions keep passing while ongoing test-reduction batches land. Maintainers lower it with--pruneas cleanups land.pnpm check:test-lines-ratchet --pruneremains downward-only and still rejects an over-ceiling total, even for a shrinking change. The check joins the existingchecks-fast-baseline-ratchetsaggregate and main-push/frozen-target command lists, using the existing base-ref flags and scheduling.The focused test covers growing and shrinking over-ceiling changes in the existing single case. The new regression is 56 lines, plus one expectation in the existing aggregate-runner test. No production-code changes, new dependencies, or changes to other ratchets.
Evidence
node scripts/run-vitest.mjs test/scripts/check-test-lines-ratchet.test.ts: 1 test passed, 1.107s test time, 2.98s Vitest duration, 12.20s complete wrapper time. Hosted CI timing is pending.pnpm tsgo:scripts: passed.node scripts/run-oxlint.mjs --tsconfig config/tsconfig/oxlint.scripts.json scripts/check-test-lines-ratchet.mts: passed.node scripts/run-oxlint.mjs --tsconfig test/tsconfig/tsconfig.test.root.json test/scripts/check-test-lines-ratchet.test.ts: passed.pnpm exec oxfmt --check scripts/check-test-lines-ratchet.mts test/scripts/check-test-lines-ratchet.test.ts docs/ci/local-proof.md: passed.git diff --check: passed.node scripts/check-test-lines-ratchet.mts --base origin/main --no-merge-base: passed against56d79851163cee1b83886d290f0c2b3f93036d83, withTest lines OK: 6524464; ceiling: 6524466; slack: 2.Test lines OK: 6524408).node scripts/run-vitest.mjs test/scripts/check-test-lines-ratchet.test.ts: passed.No broad test suites were run.
Pre-existing CI failure evidence
CI run 40066738554, attempt 1, tests PR head
fda48d0e4415a8770e15313d8bc5a741247f06b1through merge commit7fc5bebf2578cb2945e85530a2c0350249bf7f1d, whose main parent is3a22d6f0124a19df56d8fce2604f08ed281f8ae5. The ratchet job passed with 6,527,870 lines; ceiling 6,535,000; slack 7,130. Security-fast, production types, and lint also passed. The overall CI result remains failed.A fresh detached main checkout at
f6f3874cdc099edf0e62b3a1abb5d414162eb6a4reproduced all three requested failures through the CI shard runner. Its clean source tree (4369205f099dcb75d0acfb0e6dc81dc4729ac4eb) was verified on Linux Testbox run 40070567878. The runtime matched CI: Node24.22.1, checksum-staged OpenClaw Bun1.4.4-canary.1+ef37c31de, and a private QA runtime build. The payload cleared its environment and used isolated HOME, temporary, and XDG state directories. Exactly three targets completed: 24 tests passed and the three named tests failed.telegram-model-picker-prepared-gateway.e2e.test.tsattempts: 0and receivedattempts: 1; 1 failed, 2 passed.cli-json-stdout.hooks.e2e.test.ts\nescapes on stderr where the assertion expects line breaks; 1 failed, 22 passed.gateway-timeout-recovery-subagent.e2e.test.tschild completion handoffwithexecution: terminal,outcome: ok,delivery: pending, andleasable: false; 1 failed.Preparation used
OPENCLAW_BUILD_PRIVATE_QA=1 VITEST=1 pnpm build qaRuntime. After staging the pinned Bun throughscripts/stage-openclaw-bun.shand adding it to PATH, the test invocation was:CI=true NODE_OPTIONS=--max-old-space-size=8192 \ OPENCLAW_E2E_USE_PREBUILT_DIST=1 \ OPENCLAW_CI_TEST_RUNTIME_POLICY=bun-all \ OPENCLAW_VITEST_MAX_WORKERS=2 \ OPENCLAW_NODE_TEST_PLAN_CONCURRENCY=1 \ OPENCLAW_NODE_TEST_PLAN_CONTINUE_ON_FAILURE=1 \ OPENCLAW_VITEST_NO_OUTPUT_TIMEOUT_MS=300000 \ OPENCLAW_NODE_TEST_TARGETS_JSON='["test/e2e/qa-lab/runtime/telegram-model-picker-prepared-gateway.e2e.test.ts","test/cli-json-stdout.hooks.e2e.test.ts","test/e2e/qa-lab/runtime/gateway-timeout-recovery-subagent.e2e.test.ts"]' \ node --import tsx scripts/ci-run-node-test-shard.mtsThe initial local macOS attempt used Node
26.12.1, installed the frozen dependencies, and built successfully. It hit the unchanged 300-second no-output watchdog during shared compiler preparation, before assertions ran; the behavioral evidence above comes from the completed Linux replay. The Testbox was stopped after the replay. Its payload exit status was 1, as expected for these reproduced failures; workflow cleanup does not turn that result into passing tests.The run also contains a fourth failed root,
checks-node-changed-compact-small-20:session-catalog.test.ts > keeps a delayed source off the catalog RPC path. This is separately attributable to main commitae2a9dd8ec744(#182242), already present in the CI main parent. That change replaced the partial-result condition!host.errorwith!entry.errorand now returns{ sessions: [], pending: true }while the unchanged test still expectsCATALOG_LOADING. The held source promise has noentry.error, so the new branch produces the exact CI-observed response. The test and owning source blobs match between the CI main parent, tested merge, and reproduced main snapshot. The same case passed under Bun on earlier scheduled main990a389cf6e2before that main change (job120780062432). This fourth attribution is source/history evidence; no fourth test file was executed.These four roots and their downstream
openclaw/ci-gatefailure are recorded for the authorized pre-existing-failure landing exception. No CI rerun was requested, and the PR head remains unchanged.