Skip to content

ci: ratchet total test lines - #182230

Merged
steipete merged 4 commits into
mainfrom
steipete/test-lines-ratchet
Oct 24, 2026
Merged

steipete merged 4 commits into
mainfrom
steipete/test-lines-ratchet

Conversation

@steipete

@steipete steipete commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

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 -l over the campaign's exact tracked Git pathspecs, streaming files in 64 KiB chunks. It uses git diff --numstat -z <base> -- <same pathspecs> to calculate this change's net delta, adding --cached for 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.txt with PR justification. When no comparison base resolves, the ordinary check retains the absolute ceiling comparison.

The ceiling is 6,535,000: main 8b7d54a9f2f82 measured 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 --prune as cleanups land. pnpm check:test-lines-ratchet --prune remains downward-only and still rejects an over-ceiling total, even for a shrinking change. The check joins the existing checks-fast-baseline-ratchets aggregate 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

  • Regression proof: the updated test failed on the prior checker because the over-ceiling shrinking case returned exit 1; it passes with this change.
  • 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.
  • Independent review: no accepted/actionable P0–P2 findings.
  • node scripts/check-test-lines-ratchet.mts --base origin/main --no-merge-base: passed against 56d79851163cee1b83886d290f0c2b3f93036d83, with Test lines OK: 6524464; ceiling: 6524466; slack: 2.
  • Unstaged deletion: moved the new test file out of the tree without staging; the check counted it as zero lines instead of failing on the missing path (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 fda48d0e4415a8770e15313d8bc5a741247f06b1 through merge commit 7fc5bebf2578cb2945e85530a2c0350249bf7f1d, whose main parent is 3a22d6f0124a19df56d8fce2604f08ed281f8ae5. 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 f6f3874cdc099edf0e62b3a1abb5d414162eb6a4 reproduced 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: Node 24.22.1, checksum-staged OpenClaw Bun 1.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.

Test file Main result, matching PR CI
telegram-model-picker-prepared-gateway.e2e.test.ts Recovery completed, but the final ingress-state assertion expected attempts: 0 and received attempts: 1; 1 failed, 2 passed.
cli-json-stdout.hooks.e2e.test.ts The remote-Gateway configuration error contains literal \n escapes on stderr where the assertion expects line breaks; 1 failed, 22 passed.
gateway-timeout-recovery-subagent.e2e.test.ts Timed out in child completion handoff with execution: terminal, outcome: ok, delivery: pending, and leasable: false; 1 failed.

Preparation used OPENCLAW_BUILD_PRIVATE_QA=1 VITEST=1 pnpm build qaRuntime. After staging the pinned Bun through scripts/stage-openclaw-bun.sh and 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.mts

The 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 commit ae2a9dd8ec744 (#182242), already present in the CI main parent. That change replaced the partial-result condition !host.error with !entry.error and now returns { sessions: [], pending: true } while the unchanged test still expects CATALOG_LOADING. The held source promise has no entry.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 main 990a389cf6e2 before that main change (job 120780062432). This fourth attribution is source/history evidence; no fourth test file was executed.

These four roots and their downstream openclaw/ci-gate failure are recorded for the authorized pre-existing-failure landing exception. No CI rerun was requested, and the PR head remains unchanged.

@clawsweeper

clawsweeper Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-24T05:35:53.912118Z fda48d0 New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation scripts Repository scripts size: S labels Oct 24, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +54 to +55
for (const file of files) {
const descriptor = fs.openSync(path.join(root, file), "r");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@clawsweeper clawsweeper Bot added the clawsweeper:intake:feature Preliminary submission classification; full source review pending. label Oct 24, 2026
Set the initial ceiling to 6,535,000 (main 8b7d54a total 6,525,641 plus ~9.4k headroom).
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:feature Preliminary submission classification; full source review pending. labels Oct 24, 2026
@clawsweeper

clawsweeper Bot commented Oct 24, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

What this changes

Adds 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.

  • Before: CI has no aggregate test-line budget check.
  • After: The new check reports the overage and passes because the change reduces test lines.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The intended policy has concrete CLI and real-Git evidence, but two actionable defects remain, including a confirmed CI failure.
Proof confidence 🐚 platinum hermit (4/6) This maintainer-authored tooling PR is outside the contributor proof gate; its body records the real checker entry point succeeding on the source checkout, supported by an in-process real-Git fixture for growth, shrinkage, staged reads, and pruning.
Patch quality 🦪 silver shellfish (2/6) 2 actionable review findings remain.

Product

Kind: Maintenance · Worth it: Yes · Fix scope: Complete
User problem: Contributors need test-reduction gains protected without blocking unrelated or shrinking changes when main already exceeds the budget.
Reason: Maintainer authorship establishes direction, and the new aggregate budget complements existing per-file and domain ratchets.

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
Reviewed head: 8fef11b5d7fca57584a30c5ff5317e9c9e21b52e

Before merge

  • Skip unstaged deletions when counting the working tree (P2) - Deleting a tracked test without staging it leaves its path in git ls-files. This unconditional open then throws ENOENT, and main returns 1 before either the shrinking-change allowance or --prune can run. Handle missing working-tree paths as deletions while preserving index-based counting for --staged, and extend the existing regression to cover both views.
  • Update the ratchet-base fixture for the new main-push check (P2) - This invocation makes the main-push workflow execute seven ratchet commands, but test/scripts/ci-ratchet-base.test.ts still expects six. Both historical-parser cases consequently fail at line 147, as confirmed by exact-head CI. Update that fixture's command inventory and expected count while retaining its prepared-base and historical-parser assertions.

Findings

  • [P2] Skip unstaged deletions when counting the working tree — scripts/check-test-lines-ratchet.mts:54-55
  • [P2] Update the ratchet-base fixture for the new main-push check — .github/workflows/ci.yml:1785
Agent review details

How this fits together

The 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]
Loading

Technical review

Best 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:

  • [P2] Skip unstaged deletions when counting the working tree — scripts/check-test-lines-ratchet.mts:54-55
    Deleting a tracked test without staging it leaves its path in git ls-files. This unconditional open then throws ENOENT, and main returns 1 before either the shrinking-change allowance or --prune can run. Handle missing working-tree paths as deletions while preserving index-based counting for --staged, and extend the existing regression to cover both views.
    Confidence: 0.99
  • [P2] Update the ratchet-base fixture for the new main-push check — .github/workflows/ci.yml:1785
    This invocation makes the main-push workflow execute seven ratchet commands, but test/scripts/ci-ratchet-base.test.ts still expects six. Both historical-parser cases consequently fail at line 147, as confirmed by exact-head CI. Update that fixture's command inventory and expected count while retaining its prepared-base and historical-parser assertions.
    Confidence: 1

Overall correctness: patch is incorrect
Overall confidence: 0.97

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 4f2b1beecb99.

Provenance checked

  • Aggregate CI scheduling and frozen-target fallback keeps the original intent (cc14a17: Overlap the same checks in two managed slots while retaining aggregate failures, cancellation cleanup, and historical command compatibility.)
  • Shared ratchet mechanics keeps the original intent (refactor(scripts): unify shrink-ratchet mechanics under one owner #125301: Centralize file-backed baseline mechanics while leaving each checker responsible for its domain counting.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

Acceptance criteria:

  • node scripts/run-vitest.mjs test/scripts/check-test-lines-ratchet.test.ts test/scripts/ci-baseline-ratchets.test.ts test/scripts/ci-ratchet-base.test.ts --maxWorkers=1
  • pnpm tsgo:scripts
  • node scripts/run-oxlint.mjs --tsconfig config/tsconfig/oxlint.scripts.json scripts/check-test-lines-ratchet.mts
  • node scripts/run-oxlint.mjs --tsconfig test/tsconfig/tsconfig.test.root.json test/scripts/check-test-lines-ratchet.test.ts test/scripts/ci-ratchet-base.test.ts
  • git diff --check

What I checked:

  • Verified introduced change: The pinned introduction adds the checker, ceiling, package command, CI wiring, documentation, and focused tests; these additions are absent from fetched main. (scripts/check-test-lines-ratchet.mts:91, 8fef11b5d7fc)
  • Unstaged deletion failure: The working-tree counter enumerates index paths and opens every path unconditionally, so an unstaged tracked deletion produces ENOENT before pruning; this independently confirms the existing discussion at ci: ratchet total test lines #182230 (comment). (scripts/check-test-lines-ratchet.mts:55, 8fef11b5d7fc)
  • Diff-caused CI failure: The new main-push command increases the fixture's observed ratchet calls from six to seven; exact-head CI reports that mismatch at test/scripts/ci-ratchet-base.test.ts:147. (.github/workflows/ci.yml:1785, 8fef11b5d7fc)
  • Additional CI attribution: The full check list also includes a failing test-lines invocation without counts in its annotation. Artifact publication reports ENOTFOUND, and the transcript-worker inventory failure is independently documented in fix: restore CI inventories for transcript readers #182259 with a failing scheduled-main run. Other runtime and Rust failures remain unattributed; the job-log download was blocked by the host allowlist. (8fef11b5d7fc)
  • Existing ratchet ownership: The aggregate runner's introducing commit intentionally uses two managed slots and preserves frozen-target commands; this PR retains both decisions and reuses the shared ratchet argument and snapshot owner. (scripts/ci-baseline-ratchets.mts:13, cc14a17e5f1e)
  • Recorded CLI evidence: The full PR body records a real checker invocation returning 6,524,464 lines, ceiling 6,524,466, and slack 2; an independent read-only newline count of the checkout agrees. (config/test-lines-baseline.txt:1, 8fef11b5d7fc)

Likely related people:

  • Peter Steinberger: Raw commit cc14a17 adds scripts/ci-baseline-ratchets.mts:13 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: cc14a17e5f1e; files: scripts/ci-baseline-ratchets.mts)

PR surface

Tests +57, Docs +12, Config +5, Other +142. Total +216 across 8 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 2 57 0 +57
Docs 1 12 0 +12
Config 2 5 0 +5
Generated 0 0 0 0
Other 3 142 0 +142
Total 8 216 0 +216

Review metrics

Metric Value Why it matters
Repository test-line ceiling 6,524,466 lines The new committed budget permits downward pruning and deliberate manual increases; the reviewed checkout has only two lines of slack.

Labels

Label changes:

  • add P2: The defects affect contributor cleanup and CI validation without changing the shipped agent runtime.
  • add merge-risk: 🚨 automation: The added workflow invocation demonstrably breaks the existing CI ratchet-base contract test.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🐚 platinum hermit and patch quality is 🦪 silver shellfish.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • P2: The defects affect contributor cleanup and CI validation without changing the shipped agent runtime.
  • merge-risk: 🚨 automation: The added workflow invocation demonstrably breaks the existing CI ratchet-base contract test.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🐚 platinum hermit and patch quality is 🦪 silver shellfish.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 24, 2026, 1:17 AM ET / 05:17 UTC.

@steipete
steipete merged commit ab8293d into main Oct 24, 2026
232 of 238 checks passed
@steipete
steipete deleted the steipete/test-lines-ratchet branch October 24, 2026 07:30
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via explicitly authorized admin squash with attributed pre-existing CI failures.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 25, 2026
* 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
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 merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. scripts Repository scripts size: M status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant