Skip to content

refactor(tests): deduplicate max-lines ratchet fixtures - #132372

Merged
steipete merged 1 commit into
mainfrom
codex/cleanup20k-ratchet-fixtures-20260829
Aug 29, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/cleanup20k-ratchet-fixtures-20260829

Conversation

@steipete

@steipete steipete commented Aug 29, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

The max-lines ratchet tests repeat the same temporary-repository setup and directory bookkeeping across independent cases. That duplication makes fixture maintenance harder without adding behavioral coverage.

Why This Change Was Made

Reuse the existing temporary-directory tracker and consolidate nine identical, ordered Git initialization/configuration/commit sequences in a private fixture helper. All 12 original cases and assertions remain. The NUL-framed filename case remains init-only; divergent histories, staged versus unstaged content, commit messages, and the mock-restoration-before-cleanup order are preserved.

The tracker receives an explicit system temporary root to preserve its original spelling. Its existing cleanup policy includes bounded filesystem removal retries and retains tracked directories if cleanup throws; this is adoption of the canonical fixture lifecycle, not a claim of identical exceptional cleanup timing. No production code, shared helper, public API, test retry, test timeout, or assertion is changed.

User Impact

No user-visible behavior change. This is an AI-assisted, maintainer-requested test-fixture cleanup: production +0/-0; tests +36/-107, net -71 lines. The meaningful ratchet checks remain independent.

Evidence

Actual local proof on macOS used Node 24.19.0, the repository-pinned pnpm 12.0.0 through normal Corepack resolution, and the same canonical five-suite command before and after:

OPENCLAW_VITEST_MAX_WORKERS=2 node scripts/run-vitest.mjs \
  test/scripts/check-max-lines-ratchet.test.ts \
  test/helpers/temp-dir.test.ts \
  test/scripts/shrink-ratchet.test.ts \
  test/scripts/check-assertion-safety-ratchet.test.ts \
  test/scripts/check-env-var-count.test.ts \
  --reporter=verbose

Baseline and candidate each passed all 60 cases across five files, with the complete named-case multiset preserved, including embedded-newline names and duplicate titles. There were no skips on this macOS host; the existing Windows-only filename-case skip remains unchanged.

Scoped formatting and git diff --check passed. The full canonical changed gate passed all 14 selected commands, including root test typechecking, script lint, temporary-directory ownership reporting, and the relevant repository guards:

node scripts/check-changed.mjs --dry-run \
  --base 59dad71c416bcd9d649323c5f17fecdc31fd526a \
  -- test/scripts/check-max-lines-ratchet.test.ts
node scripts/check-changed.mjs --timed \
  --base 59dad71c416bcd9d649323c5f17fecdc31fd526a \
  -- test/scripts/check-max-lines-ratchet.test.ts

One normal independent Codex precommit review completed with no actionable P0 findings. The ordinary commit hook ran and preserved the reviewed afterimage; signed commit 4cba0a3f472554205bc24ac4609f8160de37bb1d has the exact one-file diff above.

The first candidate preflight was refused before tests because its raw Git index bytes differed from the prior observation. The old raw bytes were not archived, so historical cause, actor, and exact field delta remain unknown. A complete index/flag/source audit established the intended state; a separately admitted candidate run then passed, without resetting the index or replaying installation/baseline tests. Original diagnostic failures remain retained, including a case-log parser correction for multiline names and a review-packet correction that relabeled unchanged lockfile/CI-guide context accurately. None required a product or assertion change.

Full tracked-source, semantic-index/flags, dependency, output, and current-runtime checks passed around review and commit; known processes and isolated review homes were verified absent. Normal Vitest cache creation/result updates were retained and disclosed.

Hosted exact-head CI, any published-head review, current-main integration, and native landing remain pending. No product build, live external API, Linux/Windows execution, performance improvement, or landed cleanup credit is claimed.

Subsequent Proof Update — 2026-08-29

This update supersedes only the pending proof statuses above; the original evidence and limitations are retained verbatim.

CI run 33234787464, attempt 1 for exact head 4cba0a3f472554205bc24ac4609f8160de37bb1d, completed successfully with 100 successful jobs and 18 skipped jobs. The canonical exact-head CI watcher exited 0. Its raw rollup reported FAILURE, zero pending and 53 superseded checks before GREEN; this is not a claim that every raw check across earlier runs passed.

Actual hosted logs contain the same 60 named passing cases as both local runs, including multiline names and duplicate titles: core-tooling-1 has 12 max-lines and 6 temporary-directory helper cases; core-tooling-3 has 20 environment-variable and 5 assertion-safety cases; core-tooling-6 has 17 shrink cases. Each owning group ended with exit 0. No skipped case is counted as a pass.

Those jobs checked out merge ref 8d3792e4b58488bdc1728945cafad26741aa540f, combining this head with base 293c433a10bcd4727b11505caa1c8a995618a18f. A separate read-only comparison against main checkpoint 015546cb8bd8866e5d76b7f264474e7e641f6a80 found the owned test beforeimage unchanged and no relevant fixture/selector conflict in the inspected current-main deltas. The complete object-map composition predicts a one-file change on that checkpoint; it is not a performed merge or new local/hosted execution on 015546....

One normal independent Codex published-head review completed with no actionable P0 findings. Its actual process closure and source/index/dependency/output/runtime checks passed. The ClawSweeper review on this head had no findings; its outstanding CI verification is now backed by the exact-head run and named-case audit above. No redundant review request or comment was needed.

Native integration, final live mergeability and landing remain separate gates. No Windows execution, live external API, performance improvement, or landed cleanup credit is claimed by this update.

@clawsweeper

clawsweeper Bot commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@steipete
steipete marked this pull request as ready for review August 29, 2026 04:50
@openclaw-barnacle openclaw-barnacle Bot added size: S maintainer Maintainer-authored PR labels Aug 29, 2026
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 29, 2026
@clawsweeper

clawsweeper Bot commented Aug 29, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 29, 2026, 1:51 AM ET / 05:51 UTC.

ClawSweeper review

What this changes

The PR replaces repeated temporary Git-fixture setup and manual cleanup in max-lines ratchet tests with the shared temporary-directory tracker and a local commit helper.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

No introduced correctness defect was found in this focused test-only refactor. The PR is member-authored and carries the protected maintainer label, so it remains for normal maintainer integration rather than automated cleanup.

Priority: P3
Reviewed head: 4cba0a3f472554205bc24ac4609f8160de37bb1d

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, maintainable test refactor with no actionable correctness or security finding in the introduced diff.
Proof confidence 🌊 off-meta tidepool Not applicable: This member-authored, test-only cleanup has no user-visible production behavior to demonstrate; the reported targeted and hosted test runs are supplemental validation.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This member-authored, test-only cleanup has no user-visible production behavior to demonstrate; the reported targeted and hosted test runs are supplemental validation.
Evidence reviewed 6 items Introduced fixture refactor: The sole introduced file imports the existing tracker, uses it for every temporary repository, and funnels the formerly repeated ordered init/config/add/commit sequence through one private helper.
Shared-helper contract: The reused tracker records each directory, creates it below an explicit or canonical temporary root, and removes tracked directories during cleanup; supplying os.tmpdir() keeps this test's original explicit-root spelling.
Behavior-preserving test coverage: The unchanged assertions still exercise baseline growth, all-rule disables, verified renames, divergent histories, disconnected histories, staged content, embedded-newline filenames, untracked files, and unstaged deletions through the production guard entry point.
Findings None None.
Security None None.

How this fits together

The max-lines ratchet test creates isolated Git repositories to verify that the source-size suppression guard rejects baseline growth and broad lint disables. Each fixture feeds the guard with branch, staging, rename, and worktree states and asserts its result.

flowchart LR
  A[Test cases] --> B[Temporary Git fixture]
  B --> C[Git history and staged files]
  C --> D[Max-lines ratchet guard]
  D --> E[Validation result]
  F[Shared directory cleanup] --> B
Loading

Before merge

  • Complete next step (P2) - The member-authored, maintainer-labeled PR is not eligible for automated closure, and no narrow repair is needed.
Agent review details

Security

None.

PR surface

Tests -71. Total -71 across 1 file.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 1 36 107 -71
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 36 107 -71

Review metrics

Metric Value Why it matters
Production versus test delta production 0, tests +36/-107 (net -71) The single-file change consolidates test setup without expanding runtime behavior or public surface.

Technical review

Best possible solution:

Keep the shared fixture lifecycle and local Git setup helper, then integrate it through the normal exact-current-main maintainer check.

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

Not applicable: this PR refactors test fixtures rather than reporting a user-facing failure. The relevant ratchet scenarios remain present in the reviewed test source.

Is this the best way to solve the issue?

Yes: it reuses the repository's existing temporary-directory lifecycle instead of retaining duplicated cleanup and Git setup sequences, while preserving the test-specific ordering differences.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 09be104e941c.

Labels

Label justifications:

  • P3: This is a behavior-neutral test-fixture cleanup with no intended user-facing effect.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This member-authored, test-only cleanup has no user-visible production behavior to demonstrate; the reported targeted and hosted test runs are supplemental validation.

Evidence

What I checked:

  • Introduced fixture refactor: The sole introduced file imports the existing tracker, uses it for every temporary repository, and funnels the formerly repeated ordered init/config/add/commit sequence through one private helper. (test/scripts/check-max-lines-ratchet.test.ts:13, 4cba0a3f4725)
  • Shared-helper contract: The reused tracker records each directory, creates it below an explicit or canonical temporary root, and removes tracked directories during cleanup; supplying os.tmpdir() keeps this test's original explicit-root spelling. (test/helpers/temp-dir.ts:58, ad5536d56f1c)
  • Behavior-preserving test coverage: The unchanged assertions still exercise baseline growth, all-rule disables, verified renames, divergent histories, disconnected histories, staged content, embedded-newline filenames, untracked files, and unstaged deletions through the production guard entry point. (test/scripts/check-max-lines-ratchet.test.ts:104, 4cba0a3f4725)
  • Exact merge surface: The verified test merge differs from its main parent only at the reviewed test file, matching the supplied PR-introduction evidence. (test/scripts/check-max-lines-ratchet.test.ts:48, 8d3792e4b584)
  • Feature history: History identifies the shared tracker as an established test-helper pattern and shows the current test file was recently maintained by the same contributor; the review commit owns the new local helper and cleanup call. (test/helpers/temp-dir.ts:58, 5ff247b99ec1)
  • Current-main limitation: The local partial clone could not materialize the fetched current-main test blob because GitHub DNS resolution failed; therefore this review makes no obsolete-on-main claim. (09be104e941c)

Likely related people:

  • Peter Steinberger: Authored the reviewed commit and the prior current-file maintenance commit; blame attributes the new fixture helper and cleanup adoption to this commit. (role: recent test and tooling contributor; confidence: high; commits: 4cba0a3f4725, ad5536d56f1c; files: test/scripts/check-max-lines-ratchet.test.ts, test/helpers/temp-dir.ts)
  • Mason Huang: History records the earlier auto-cleaning temporary-directory helper work that established the reused tracker pattern. (role: shared-helper introducer; confidence: medium; commits: 5ff247b99ec1; files: test/helpers/temp-dir.ts)

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.

History

Review history (1 earlier review cycle)
  • reviewed 2026-08-29T04:58:40.274Z sha 4cba0a3 :: needs maintainer review before merge. :: none

@steipete steipete self-assigned this Aug 29, 2026
@steipete
steipete merged commit d8458b6 into main Aug 29, 2026
194 of 201 checks passed
@steipete
steipete deleted the codex/cleanup20k-ratchet-fixtures-20260829 branch August 29, 2026 06:24
@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

maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant