Skip to content

Commit 59904fe

Browse files
authored
refactor(limits): single canonical automation-limits module (#1104)
src/limits.ts and src/repair/limits.ts shared ~223 identical lines deriving lane limits from config/automation-limits.json and had already drifted: only the repair copy parsed target_max_concurrent, the assist lane, and workerLimit("assist"). Divergent copies of the scheduler's capacity math are the same bug class as this week's mixed-case publication incident -- two implementations of one contract disagreeing silently. src/limits.ts is now the single canonical superset module; the repair copy is deleted and its seven importers rewritten. Net -227 lines. Equivalence proof: docs/proof/unify-automation-limits reconstructs the pre-change modules from git history, dumps every exported limit and derived lane budget from both old modules and the new canonical module across representative worker budgets, and passes only on an empty diff -- verified empty, locally and in a Docker-backed Crabbox local-container on the reviewed head, with check:limits green inside the proof.
1 parent 3a38d36 commit 59904fe

22 files changed

Lines changed: 1116 additions & 262 deletions
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Automation-limits unification value-equivalence proof
2+
3+
This proof establishes that consolidating `src/limits.ts` and `src/repair/limits.ts` into the
4+
canonical `src/limits.ts` preserves the union of their runtime value surfaces.
5+
6+
## Claim
7+
8+
Every exported config value, derived automation limit, and lane budget is identical before and
9+
after the consolidation. The old union includes the repair-only exact-review target and assist
10+
values as well as every value shared with the root module.
11+
12+
## Scenario
13+
14+
Run `docs/proof/unify-automation-limits/run-proof.sh` from a checkout of this branch. The script:
15+
16+
1. fetches `origin/main`, computes its merge base with the checked-out head, and selects
17+
`origin/main` when the historical modules and config still match the merge base;
18+
2. reconstructs the pre-change `src/limits.ts` and `src/repair/limits.ts` with `git show` in
19+
isolated temporary module trees, then compiles both historical modules and the current
20+
canonical module with the repository's TypeScript compiler;
21+
3. imports all three compiled modules and writes canonical, recursively key-sorted JSON for
22+
`WORKER_CONFIG`, `AUTOMATION_LIMITS`, `readWorkerConfig()`, `deriveAutomationLimits()`, and
23+
`workerLimit()`;
24+
4. exercises worker maxima 64, 128, and 256, all eight union lanes, and default, active-worker,
25+
soft-pressure, hard-pressure, and unknown-pressure scenarios;
26+
5. requires an empty unified diff and runs `pnpm run check:limits`.
27+
28+
If `origin/main` changes any historical limit module or `config/automation-limits.json` after the
29+
branch base, the script pins the merge-base SHA instead and records that decision. Set
30+
`UNIFY_AUTOMATION_LIMITS_PROOF_OUTPUT` to write artifacts outside the repository.
31+
32+
## Observations
33+
34+
The committed local run selected `origin/main` because its historical modules and config remain
35+
identical to merge base `35b5f622c968cf3acb2fbe8226ffeef801422a88`. The pre-change union and
36+
current canonical JSON dumps are byte-identical, so
37+
[`artifacts/value-equivalence.diff`](artifacts/value-equivalence.diff) is empty.
38+
[`artifacts/check-limits.log`](artifacts/check-limits.log) records the passing repository drift
39+
check. [`artifacts/baseline.json`](artifacts/baseline.json) records the resolved source SHAs.
40+
41+
## Limits
42+
43+
This proves deterministic config parsing, limit derivation, and lane-budget behavior for the
44+
recorded scenarios. It does not dispatch GitHub Actions, exercise production queues, or claim that
45+
unrelated scheduler behavior is unchanged.
46+
47+
## Crabbox provenance
48+
49+
The same script passed unchanged at reviewed head
50+
`87a6ae8c4555e6350ff4559086bc2c03e76382b6` inside a Docker-backed Crabbox
51+
`local-container`, using Crabbox CLI 0.41.1, image `node:24-bookworm`, Docker 29.4.0 via OrbStack,
52+
and lease `cbx_7f99f448f5d1` (`harbor-barnacle`). The run used a clean
53+
`--fresh-pr openclaw/clawsweeper#1104 --no-hydrate` checkout, enabled Corepack in the unprivileged
54+
container user's `~/.local/bin`, produced an empty value diff, completed with `PROOF_RC=0`, and
55+
stopped the lease automatically.
56+
57+
See the [machine-readable provenance](artifacts/crabbox-local-container-provenance.json) and
58+
[captured container stdout](artifacts/crabbox-local-container-stdout.log).
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"selected_ref": "origin/main",
3+
"selected_sha": "3a38d3622a9b9874fe40f813dc7d1235ea4a024b",
4+
"reason": "origin/main matches the merge-base limit modules and config",
5+
"merge_base_sha": "35b5f622c968cf3acb2fbe8226ffeef801422a88",
6+
"origin_main_sha": "3a38d3622a9b9874fe40f813dc7d1235ea4a024b"
7+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
$ node scripts/check-limits.ts

‎docs/proof/unify-automation-limits/artifacts/compile.log‎

Whitespace-only changes.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"schema": "clawsweeper-crabbox-proof-provenance/v1",
3+
"claim": "docs/proof/unify-automation-limits/run-proof.sh preserves the pre-change limits union on the reviewed PR head inside a Docker-backed Crabbox local-container.",
4+
"crabbox": {
5+
"cli_version": "0.41.1",
6+
"provider": "local-container",
7+
"lease_id": "cbx_7f99f448f5d1",
8+
"slug": "harbor-barnacle",
9+
"run_id": "run_da41fab8ff24",
10+
"machine_type": "node_24-bookworm",
11+
"image": "node:24-bookworm",
12+
"container_engine": "Docker 29.4.0 (OrbStack)",
13+
"checkout": "--fresh-pr openclaw/clawsweeper#1104 (clean remote checkout, --no-hydrate)",
14+
"workdir": "/work/crabbox/cbx_7f99f448f5d1/fresh-pr-openclaw-clawsweeper-1104",
15+
"sync_ms": 8894,
16+
"command_ms": 4673,
17+
"total_ms": 13592,
18+
"end_to_end_ms": 24184,
19+
"exit_code": 0,
20+
"run_status": "succeeded",
21+
"lease_stopped": true
22+
},
23+
"runtime": {
24+
"node": "v24.19.0",
25+
"pnpm": "11.10.0"
26+
},
27+
"reviewed_head": "87a6ae8c4555e6350ff4559086bc2c03e76382b6",
28+
"baseline": {
29+
"selected_ref": "origin/main",
30+
"selected_sha": "3a38d3622a9b9874fe40f813dc7d1235ea4a024b",
31+
"merge_base_sha": "35b5f622c968cf3acb2fbe8226ffeef801422a88"
32+
},
33+
"result": {
34+
"proof_rc": 0,
35+
"value_diff": "empty",
36+
"check_limits": "passed"
37+
}
38+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
== environment ==
2+
node=v24.19.0
3+
head=87a6ae8c4555e6350ff4559086bc2c03e76382b6
4+
pnpm=11.10.0
5+
== select pre-change source ==
6+
baseline_ref=origin/main
7+
baseline_sha=3a38d3622a9b9874fe40f813dc7d1235ea4a024b
8+
merge_base_sha=35b5f622c968cf3acb2fbe8226ffeef801422a88
9+
origin_main_sha=3a38d3622a9b9874fe40f813dc7d1235ea4a024b
10+
== compile historical and canonical modules ==
11+
== dump canonical value surfaces ==
12+
== compare pre-change union with current canonical module ==
13+
value_diff=empty
14+
== repository limit drift check ==
15+
$ node scripts/check-limits.ts
16+
PROOF_RC=0

0 commit comments

Comments
 (0)