Skip to content

refactor(limits): single canonical automation-limits module - #1104

Merged
steipete merged 3 commits into
mainfrom
steipete/unify-automation-limits
Aug 10, 2026
Merged

steipete merged 3 commits into
mainfrom
steipete/unify-automation-limits

Conversation

@steipete

@steipete steipete commented Aug 10, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

ClawSweeper had two copies of the scheduler capacity math: src/limits.ts and src/repair/limits.ts. They shared roughly 223 lines but had already drifted. The repair copy alone parsed lanes.exact_review.target_max_concurrent, exposed the assist lane, and implemented workerLimit("assist"). Keeping two owners for these derived budgets leaves review and repair runtimes vulnerable to mixed behavior after otherwise correct limit changes.

Why This Change Was Made

src/limits.ts is now the canonical superset. It contains the repair-only target and assist fields, all seven repair consumers import it directly, and the duplicate src/repair/limits.ts is deleted. The repair test imports the canonical compiled module as well.

Both TypeScript configurations compile the canonical module without configuration changes. tsconfig.json includes src/limits.ts directly; tsconfig.repair.json follows the rewritten repair imports to compile src/limits.ts and src/queue-pressure.ts. No include expansion was needed.

User Impact

No derived value or runtime limit changes. This removes the divergent implementation path so future automation-limit edits have one owner.

Drift Evidence

Before this change, the repair copy alone contained:

  • parsing and clamping for lanes.exact_review.target_max_concurrent
  • parsing and derivation for lanes.assist.max
  • the assist worker lane and workerLimit("assist")

The remaining capacity formulas were duplicated between the two files.

Real Behavior Proof

  • Claim: every exported config value, derived automation limit, and lane budget is identical before and after consolidation.
  • Exercised surface: the union of src/limits.ts and src/repair/limits.ts, including WORKER_CONFIG, AUTOMATION_LIMITS, readWorkerConfig(), deriveAutomationLimits() at worker maxima 64/128/256, and workerLimit() for every lane under default, active-worker, soft-pressure, hard-pressure, and unknown-pressure scenarios.
  • Scenario/fixture: the committed, re-runnable harness fetches origin/main, reconstructs both pre-change modules with git show, compiles them and the current canonical module in isolated temporary trees, serializes recursively sorted JSON, and requires an empty unified diff. origin/main had not changed the historical modules or config, so the run selected origin/main at 3a38d3622a9b9874fe40f813dc7d1235ea4a024b; merge base 35b5f622c968cf3acb2fbe8226ffeef801422a88 is recorded alongside it.
  • Command/environment: crabbox run --provider local-container --local-container-image node:24-bookworm --fresh-pr openclaw/clawsweeper#1104 --no-hydrate ... docs/proof/unify-automation-limits/run-proof.sh; Crabbox CLI 0.41.1, Docker 29.4.0 via OrbStack, Node v24.19.0, pnpm 11.10.0, Corepack enabled into $HOME/.local/bin.
  • Observable result: local PROOF_RC=0; container PROOF_RC=0; value_diff=empty; pnpm run check:limits passed. Container lease cbx_7f99f448f5d1 (harbor-barnacle), run run_da41fab8ff24, reviewed head 87a6ae8c4555e6350ff4559086bc2c03e76382b6, stopped automatically.
  • Artifact/trace: proof README and rerun command, pre-change union JSON, current canonical JSON, empty diff, Crabbox provenance, and captured container stdout.
  • Limits: this proves deterministic limit/config behavior and compilation for the recorded values and scenarios, not a live GitHub Actions dispatch or unrelated scheduler behavior.

Value diff output (verbatim; empty):

Validation

  • docs/proof/unify-automation-limits/run-proof.sh (local and Docker-backed Crabbox local-container)
  • pnpm run format:check
  • pnpm run check:limits
  • pnpm run build:all
  • pnpm run test:no-build
  • pnpm run lint
  • pnpm run check:active-surface
  • pnpm run check:dashboard-queue-boundary
  • pre-commit local autoreview: clean, no accepted/actionable findings
  • committed branch autoreview against origin/main: clean, no accepted/actionable findings
  • proof and provenance follow-up autoreviews: clean, no accepted/actionable findings

OpenClaw Bay Impact

None. This is an internal source-ownership consolidation with no lifecycle publication, queue/workflow behavior, status/telemetry, or dashboard data-contract change. OpenClaw Bay remains unaffected.

@clawsweeper

clawsweeper Bot commented Aug 10, 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 merge-risk: 🚨 automation 🚨 Merging this PR could break CI, automerge, proof capture, label sync, or automation. P3 Low-risk cleanup, docs, polish, ergonomics, or speculative feature. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 10, 2026
@clawsweeper

clawsweeper Bot commented Aug 10, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 10, 2026, 2:29 PM ET / 18:29 UTC.

ClawSweeper review

What this changes

The PR makes the top-level automation-limits module the single owner of worker-budget derivation and updates repair code and tests to use it.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep open for normal merge review. The branch removes a real duplicated limit implementation, redirects all seven repair consumers to the canonical module, and supplies strong container-backed equivalence proof; no actionable patch defect was found.

Priority: P3
Reviewed head: ec916e45a0e6ae020eef4b93ba681b57f32ccc44

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused consolidation with inspectable real-behavior equivalence evidence and no correctness finding.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (linked_artifact): The PR includes inspectable Docker-backed Crabbox provenance and output showing the current canonical module matches the historical union across documented configuration and pressure scenarios.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (linked_artifact): The PR includes inspectable Docker-backed Crabbox provenance and output showing the current canonical module matches the historical union across documented configuration and pressure scenarios.
Evidence reviewed 5 items Current duplication: Current main has separate limits implementations: the root module lacks the repair-only exact-review target and assist lane, while the repair module defines them and their scheduler behavior.
Consumer migration: The reviewed patch moves seven repair imports and the compiled repair test import to the top-level module, then deletes the repair-local duplicate.
Behavior proof: The committed Crabbox local-container provenance records a successful run against the behavior-bearing head, an empty value-equivalence diff, and a passing limits drift check; the final commit records that provenance.
Findings None None.
Security None None.

How this fits together

Automation limits are read from repository configuration and converted into lane budgets used by review and repair workflows. Those workflows use the resulting limits to cap worker concurrency and job dispatches.

flowchart LR
  A[Automation limits config] --> B[Canonical limits module]
  B --> C[Derived lane budgets]
  C --> D[Review automation]
  C --> E[Repair automation]
  D --> F[Review workers]
  E --> G[Repair job dispatch]
Loading

Before merge

  • Resolve merge risk (P1) - The canonical module becomes a shared automation-capacity boundary; a future limit edit must preserve coverage for both root and repair compilation paths.
  • Complete next step (P2) - No discrete repair is needed; await the normal current-head merge checks for this already-proven refactor.
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Patch composition production +34/-261, tests +1/-1, proof/docs +1081 The behavioral refactor is narrow; most added content is inspectable proof and provenance.
Repair consumers 7 imports redirected; 1 compiled test import updated This confirms the duplicate module’s known repair call sites are moved together.

Merge-risk options

Maintainer options:

  1. Land with the recorded proof (recommended)
    Accept the shared automation boundary because the container proof records unchanged derived values and the branch validates both TypeScript build paths.

Technical review

Best possible solution:

Land one canonical limits implementation while retaining the focused equivalence proof and dual-build validation as guardrails for future capacity changes.

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

Not applicable: this is a behavior-preserving refactor rather than a report of a user-observable failure. The relevant verification is deterministic limit equivalence across the affected scheduler scenarios.

Is this the best way to solve the issue?

Yes. Removing the duplicate owner and routing repair consumers to the existing top-level module is the narrowest maintainable way to eliminate the demonstrated drift.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 3a38d3622a9b.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR includes inspectable Docker-backed Crabbox provenance and output showing the current canonical module matches the historical union across documented configuration and pressure scenarios.
  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (linked_artifact): The PR includes inspectable Docker-backed Crabbox provenance and output showing the current canonical module matches the historical union across documented configuration and pressure scenarios.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.

Label justifications:

  • P3: This is an internal cleanup intended to preserve existing automation behavior.
  • merge-risk: 🚨 automation: The module controls concurrency and dispatch budgets used by both review and repair automation.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (linked_artifact): The PR includes inspectable Docker-backed Crabbox provenance and output showing the current canonical module matches the historical union across documented configuration and pressure scenarios.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR includes inspectable Docker-backed Crabbox provenance and output showing the current canonical module matches the historical union across documented configuration and pressure scenarios.

Evidence

What I checked:

  • Current duplication: Current main has separate limits implementations: the root module lacks the repair-only exact-review target and assist lane, while the repair module defines them and their scheduler behavior. (src/repair/limits.ts:13, 3a38d3622a9b)
  • Consumer migration: The reviewed patch moves seven repair imports and the compiled repair test import to the top-level module, then deletes the repair-local duplicate. (src/limits.ts:16, ec916e45a0e6)
  • Behavior proof: The committed Crabbox local-container provenance records a successful run against the behavior-bearing head, an empty value-equivalence diff, and a passing limits drift check; the final commit records that provenance. (docs/proof/unify-automation-limits/artifacts/crabbox-local-container-provenance.json:1, ec916e45a0e6)
  • Feature provenance: The duplicated repair limits surface appears to date to the same current-main commit that introduced the relevant target-concurrency and assist values. (src/repair/limits.ts:13, a47ccbacd24a)
  • Build boundary: The root build excludes repair sources, while the repair build includes repair sources; imported root modules are compiled through TypeScript dependency resolution, matching the PR's stated dual-build proof boundary. (tsconfig.repair.json:16, 3a38d3622a9b)

Likely related people:

  • Peter Steinberger: Current-main history attributes the relevant repair limits additions to the commit that introduced the assist and target-concurrency behavior. (role: introduced the current duplicated limits surface; confidence: high; commits: a47ccbacd24a; files: src/repair/limits.ts, src/limits.ts)
  • steipete: Authored the proposed consolidation and its current-head proof commits. (role: recent area contributor; confidence: high; commits: 9839bebb286d, 87a6ae8c4555, ec916e45a0e6; files: src/limits.ts, src/repair/limits.ts, docs/proof/unify-automation-limits/run-proof.sh)

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-10T18:14:12.870Z sha 9839beb :: needs real behavior proof before merge. :: none

@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 10, 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 repository_dispatch).
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 added proof: sufficient Contributor real behavior proof is sufficient. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Aug 10, 2026
@clawsweeper

clawsweeper Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper status: review started.

I am starting a fresh review of this pull request: refactor(limits): single canonical automation-limits module This is item 1/1 in the current shard. Shard 0/1.

This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking.

Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted.

@steipete
steipete merged commit 59904fe into main Aug 10, 2026
21 checks passed
@steipete
steipete deleted the steipete/unify-automation-limits branch August 10, 2026 18:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 automation 🚨 Merging this PR could break CI, automerge, proof capture, label sync, or automation. P3 Low-risk cleanup, docs, polish, ergonomics, or speculative feature. proof: sufficient Contributor real behavior proof is sufficient. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. 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