Skip to content

refactor(scripts): unify shrink-ratchet mechanics under one owner - #125301

Merged
steipete merged 4 commits into
mainfrom
steipete/ratchet-unification
Aug 17, 2026
Merged

steipete merged 4 commits into
mainfrom
steipete/ratchet-unification

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Three shrink-only repository checks independently implemented baseline loading, comparison, deterministic ordering, and pass/failure guidance. That duplication made policy changes easy to apply inconsistently and left the shared concept without a canonical owner.

Why This Change Was Made

This maintainer-requested refactor moves the shared mechanics into the concept-named scripts/lib/shrink-ratchet.mts owner while leaving each checker responsible for its domain counting. Existing baseline formats and all pass/failure text are preserved verbatim.

The chained-assertion exclusion ledger remains in type-assertion-guard-scope.mjs. It is live scope policy synchronously loaded by the plain-JS oxlint plugin, not a file-backed baseline; folding it into the owner would couple that runtime to git/fs machinery without reusing ratchet behavior.

User Impact

No user-visible behavior changes. Operators and CI receive the same checker results and byte-identical output, while future shrink-ratchet changes have one policy owner.

AI-assisted: yes. The final implementation was reviewed with the repository autoreview workflow.

Evidence

  • Current-tree before/after proof against origin/main, per checker:
    • max-lines: exit 0/0, stdout diff empty, stderr diff empty
    • assertion safety: exit 0/0, stdout diff empty, stderr diff empty
    • environment-variable count: exit 0/0, stdout diff empty, stderr diff empty
  • Controlled broken-probe proof, per checker:
    • max-lines: exit 1/1, stdout diff empty, stderr diff empty
    • assertion safety: exit 1/1, stdout diff empty, stderr diff empty
    • environment-variable count: exit 1/1, stdout diff empty, stderr diff empty
  • Focused checker/owner/changed-lane suite: 193 tests passed. Focused post-type-fix reruns: 28 tests and 16 tests passed.
  • pnpm lint: passed, including core, extensions, and scripts.
  • pnpm tsgo:scripts: passed.
  • pnpm tsgo:test:root: passed.
  • node scripts/check-changed.mjs: passed, including all three ratchets, formatting, script/test typechecks, erasability, and lint:scripts.
  • Final branch autoreview against origin/main: clean; no accepted/actionable findings.
  • Wrapper failure contract observed during the intentional first changed-gate failure: final stderr line remained [check:changed] FAILED (exit 1).
  • Judged LOC: production/tooling +396/-398 (net -2); tests +163/-28 (net +135).

@steipete
steipete marked this pull request as ready for review August 17, 2026 14:37
@openclaw-barnacle openclaw-barnacle Bot added scripts Repository scripts size: L maintainer Maintainer-authored PR labels Aug 17, 2026
@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.

@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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 17, 2026
@clawsweeper

clawsweeper Bot commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 17, 2026, 7:43 PM ET / 23:43 UTC.

ClawSweeper review

What this changes

The PR moves shared baseline loading, comparison, ordering, and reporting for three shrink-only repository checks into scripts/lib/shrink-ratchet.mts while keeping each check’s domain counting local.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

No blocking correctness finding found. This maintainer-owned, protected PR remains open for the explicit landing decision after its exact-head CI completes.

Priority: P3
Reviewed head: 0a2329fcb59f0bf3c06699d0af3902ae335817c6
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) The patch cleanly consolidates previously duplicated mechanics with focused behavioral coverage and no concrete review finding.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored internal tooling refactor is exempt from the external-contributor proof gate; its PR body nevertheless supplies controlled checker-output evidence.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored internal tooling refactor is exempt from the external-contributor proof gate; its PR body nevertheless supplies controlled checker-output evidence.
Evidence reviewed 5 items Shared owner behavior: The new owner centralizes reference resolution, worktree/index/reference baseline loading, rename discovery, deterministic comparisons, and report helpers; the three checkers retain their domain-specific collection and policy.
Caller and sibling coverage: The environment-variable, max-lines, and assertion-safety checkers each consume the shared helper, while check-changed schedules all three for changes to the new owner.
Current-main provenance: Current-main blame attributes the pre-refactor ratchet implementations and former shared base helper to Peter Steinberger in commit b834477; the PR keeps that behavior under one owner.
Findings None None.
Security None None.

How this fits together

Three CI ratchets inspect source and baseline files, compare them with a Git reference, and report debt growth or required cleanup. The changed-check planner invokes those ratchets when related source, baseline, or shared-helper files change.

flowchart LR
A[Source and baseline files] --> B[Domain-specific ratchet checks]
B --> C[Shared shrink-ratchet helper]
C --> D[Git reference comparison]
D --> E[Pass or failure guidance]
F[Changed-file planner] --> B
Loading

Decision needed

Question Recommendation
After exact-head CI completes, should this maintainer-requested ratchet consolidation land? Land after CI: Merge once the current head or refreshed merge result is green and no new review evidence appears.

Why: The PR is maintainer-authored and carries the protected maintainer label, so automated cleanup must not close or land it.

Before merge

  • Resolve merge risk (P1) - GitHub reports the branch as mergeable but behind main, with required exact-head checks still in progress; landing needs a current green merge result.
Agent review details

Security

None.

PR surface

Tests +135, Other -2. Total +133 across 11 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 5 163 28 +135
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 6 396 398 -2
Total 11 559 426 +133

Review metrics

Metric Value Why it matters
Production vs test LOC production/tooling +396/-398 (net -2); tests +163/-28 (net +135) The refactor removes slightly more production/tooling code than it adds while expanding direct coverage of the new shared owner.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Keep one generic file-backed ratchet owner and merge after exact-head CI confirms the preserved checker behavior.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Keep one generic file-backed ratchet owner and merge after exact-head CI confirms the preserved checker behavior.

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

Not applicable: this PR refactors deterministic repository checks rather than reporting a user-facing defect.

Is this the best way to solve the issue?

Yes: centralizing only shared file-backed ratchet mechanics preserves one canonical policy owner while leaving checker-specific counting and policy local.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 741250f5bb5d.

Labels

Label changes:

  • remove proof: sufficient: Current real behavior proof status is not_applicable, not sufficient.

Label justifications:

  • P3: This is an internal CI/tooling refactor with no claimed user-facing behavior change.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🌊 off-meta tidepool and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored internal tooling refactor is exempt from the external-contributor proof gate; its PR body nevertheless supplies controlled checker-output evidence.

Evidence

What I checked:

  • Shared owner behavior: The new owner centralizes reference resolution, worktree/index/reference baseline loading, rename discovery, deterministic comparisons, and report helpers; the three checkers retain their domain-specific collection and policy. (scripts/lib/shrink-ratchet.mts:34, 0a2329fcb59f)
  • Caller and sibling coverage: The environment-variable, max-lines, and assertion-safety checkers each consume the shared helper, while check-changed schedules all three for changes to the new owner. (scripts/check-changed.mts:541, 0a2329fcb59f)
  • Current-main provenance: Current-main blame attributes the pre-refactor ratchet implementations and former shared base helper to Peter Steinberger in commit b834477; the PR keeps that behavior under one owner. (scripts/check-env-var-count.mts:1, b83447756582)
  • Test contract: New tests cover baseline parsing, worktree/index/reference snapshots, deterministic comparisons, scalar enforcement, and output formatting; existing checker tests retain their domain-level behavior checks. (test/scripts/shrink-ratchet.test.ts:20, 0a2329fcb59f)
  • Submitted real behavior evidence: The PR body records equivalent success and controlled-failure output for all three checkers plus focused tests, lint, script typechecks, and the changed-file gate; required hosted checks were still in progress in the supplied state. (0a2329fcb59f)

Likely related people:

  • steipete: Current-main blame attributes the pre-refactor checker/helper lines to Peter Steinberger, and this maintainer-authored PR carries the consolidation. (role: introduced current ratchet implementation and current refactor owner; confidence: high; commits: b83447756582, 0a2329fcb59f; files: scripts/check-env-var-count.mts, scripts/check-max-lines-ratchet.mts, scripts/check-assertion-safety-ratchet.mts)

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 (3 earlier review cycles)
  • reviewed 2026-08-17T15:11:09.438Z sha 6908564 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-17T15:25:15.260Z sha 6908564 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-17T16:53:41.961Z sha 6908564 :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Aug 17, 2026
@steipete steipete self-assigned this Aug 17, 2026
@steipete
steipete force-pushed the steipete/ratchet-unification branch from 6908564 to 0a2329f Compare August 17, 2026 23:37
@clawsweeper clawsweeper Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Aug 17, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

Landing proof for exact head 0a2329fcb59f0bf3c06699d0af3902ae335817c6:

  • Rebased onto current main; GitHub reports the PR mergeable.
  • Old and refactored versions of all three checkers produced byte-identical stdout/stderr on the same passing tree (0/0) and the same isolated broken probe (1/1).
  • pnpm test test/scripts/check-assertion-safety-ratchet.test.ts test/scripts/check-env-var-count.test.ts test/scripts/check-max-lines-ratchet.test.ts test/scripts/shrink-ratchet.test.ts — 43 tests passed.
  • pnpm lint:scripts — passed.
  • node scripts/check-changed.mjs — passed, including all three ratchets, scripts/test typechecks, formatting, erasability, and scripts lint.
  • Branch autoreview against origin/main — clean, no accepted/actionable findings.
  • Exact-head CI — green: https://github.com/openclaw/openclaw/actions/runs/32081256340
  • Native OPENCLAW_TESTBOX=1 scripts/pr prepare-run 125301 — passed in hosted_exact_or_recent_parent mode using the exact-head hosted result; no separate remote lease was needed.

This satisfies ClawSweeper’s remaining current-green-merge-result move. No proof gaps remain.

@steipete
steipete merged commit 1fab280 into main Aug 17, 2026
144 checks passed
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

@steipete
steipete deleted the steipete/ratchet-unification branch August 17, 2026 23:46
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 18, 2026
…enclaw#125301)

* refactor(scripts): unify shrink-ratchet mechanics under one owner

* refactor(scripts): tighten shrink-ratchet owner

* fix(scripts): widen ratchet comparator type

* test(scripts): type heterogeneous ratchet fixtures
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: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. scripts Repository scripts size: L 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