Skip to content

Commit c145b45

Browse files
authored
refactor(dashboard): extract page renderers from worker.ts (#1116)
worker.ts carried 4,115 lines of parameter-only HTML/CSS/client-JS page generation alongside routing, JSON APIs, caching, and StatusStore I/O. The renderers (issueTriagePageConfig, prProofTriagePageConfig, escapeHtml, externalHttpUrl, the four theme helpers, serializedPageConfig, triageHtml, dashboardHtml, DashboardEnv, and the renderer-only CrabFleet constant) now live in dashboard/dashboard-pages.ts. Pure move: the contiguous function block is byte-identical; worker.ts shrinks 11,316 to 7,207 lines. Existing bay-page.ts rendering keeps its current owner. Proof (docs/proof/extract-dashboard-pages): the real local Worker serves /, /triage, and /pr-proof-triage at the merge base and at this head -- raw response hashes match identically, before any normalization. Verified in a Docker-backed Crabbox local-container with committed provenance.
1 parent 5a964da commit c145b45

14 files changed

Lines changed: 4820 additions & 4116 deletions

‎dashboard/dashboard-pages.ts‎

Lines changed: 4119 additions & 0 deletions
Large diffs are not rendered by default.

‎dashboard/worker.ts‎

Lines changed: 7 additions & 4116 deletions
Large diffs are not rendered by default.
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Dashboard page renderer extraction proof
2+
3+
## Claim
4+
5+
Extracting the server-side dashboard page renderers from `dashboard/worker.ts` into
6+
`dashboard/dashboard-pages.ts` does not change the rendered bytes for `/`, `/triage`, or
7+
`/pr-proof-triage`.
8+
9+
## Exercised surface
10+
11+
[`run-proof.sh`](run-proof.sh) starts the real local Wrangler Worker twice: once from the exact
12+
`origin/main` merge base in a detached temporary worktree and once from the current committed head.
13+
It fetches all three moved page surfaces, normalizes ISO timestamps and generated 40-character
14+
hexadecimal SHAs, and requires the normalized diff to be empty. The source-blind validator executes
15+
the separate [`behavior contract`](behavior-contract.md) through HTTP only.
16+
17+
## Artifacts
18+
19+
- `artifacts/page-comparison.json`: base/head byte counts, raw hashes, normalized hashes, and equality
20+
- `artifacts/normalized.diff`: the normalized page diff; this file is empty on success
21+
- `artifacts/behavior-validation.json`: source-blind HTTP behavior report
22+
- `artifacts/provenance.json`: local runtime and exact base/head commits
23+
- `artifacts/base-worker.log` and `artifacts/head-worker.log`: real Wrangler startup/request traces
24+
25+
## Run
26+
27+
From the repository root on Node 24 or newer:
28+
29+
```bash
30+
docs/proof/extract-dashboard-pages/run-proof.sh
31+
```
32+
33+
The script prints `PROOF_RC=0` on success.
34+
35+
## Local observation
36+
37+
The committed local run compared merge base `5a964dadc8131e6e6dc33e9be3536b8141d1d107` with head
38+
`22d7808c136a10503fc9929fd9ba5904e005542f` on macOS arm64, Node 24.19.0, pnpm 11.10.0,
39+
and Wrangler 4.107.0. All three raw response hashes and byte counts matched before normalization;
40+
the normalized diff was empty, the source-blind behavior contract passed, and the harness completed
41+
with `PROOF_RC=0`.
42+
43+
## Crabbox container observation
44+
45+
The same proof passed from a clean `--fresh-pr openclaw/clawsweeper#1116 --no-hydrate`
46+
checkout at pushed head `a00e31c5ae40e33ab8718facac74d39d198dd994` inside Docker-backed Crabbox
47+
`provider=local-container`, image `node:24-bookworm`, lease `cbx_36172f52e311`
48+
(`golden-crayfish-3c9c`). Corepack supplied pnpm 11.10.0, and the upstream jq 1.8.1 checksum
49+
manifest verified `jq-linux-amd64: OK` before execution. The real Worker comparison completed with
50+
`PROOF_RC=0` and `CONTAINER_PROOF_RC=0`; the normalized diff was empty, and Crabbox stopped the
51+
lease automatically. The container run exercised the exact proof rather than the full suite, so the
52+
known three-failure blob-hydration baseline was not applicable.
53+
54+
See the [machine-readable Crabbox provenance](artifacts/crabbox-local-container-provenance.json).
55+
56+
## Limits
57+
58+
This proves page-shell rendering and route-level HTTP behavior. It does not exercise JSON API data,
59+
browser interaction, GitHub writes, queue or state mutation, production deployment, or `/bay-demo`.
60+
The `/bay-demo` renderer already lives in `dashboard/bay-page.ts` and is not part of the moved
61+
surface.
62+
63+
## OpenClaw Bay impact
64+
65+
None. The rendered output is byte-identical, and this ownership-only move changes no Bay data
66+
contract, lifecycle projection, observer-only boundary, or controls.
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
2+
⛅️ wrangler 4.107.0 (update available 4.120.1)
3+
───────────────────────────────────────────────
4+
Your Worker has access to the following bindings:
5+
Binding Resource Mode
6+
env.STATUS_STORE (StatusStore) Durable Object local
7+
env.EXACT_REVIEW_QUEUE (ExactReviewQueue) Durable Object local
8+
env.STATE_SNAPSHOTS (clawsweeper-state-snapshots) R2 Bucket local
9+
env.CLAWSWEEPER_REPO ("openclaw/clawsweeper") Environment Variable local
10+
env.CLAWSWEEPER_APP_CLIENT_ID ("Iv23liOECG0slfuhz093") Environment Variable local
11+
env.CLAWSWEEPER_CRABFLEET_URL ("https://crabfleet.openclaw.ai") Environment Variable local
12+
env.TARGET_REPOS ("openclaw/openclaw,openclaw/clawhub,op...") Environment Variable local
13+
env.APPLY_TARGET_REPOS ("openclaw/openclaw") Environment Variable local
14+
env.APPLY_OPTIONAL_TARGET_REPOS ("openclaw/clawhub") Environment Variable local
15+
env.CLAWSWEEPER_ENABLE_CLAWHUB ("1") Environment Variable local
16+
env.WORKER_BUDGET ("128") Environment Variable local
17+
env.EXACT_REVIEW_ACTIONS_BUDGET ("194") Environment Variable local
18+
env.WORKER_DETAIL_RUN_LIMIT ("128") Environment Variable local
19+
env.WORKER_JOB_FETCH_CONCURRENCY ("12") Environment Variable local
20+
env.WORKER_JOB_CACHE_TTL_SECONDS ("60") Environment Variable local
21+
env.WORKER_HEALTH_CACHE_TTL_SECONDS ("120") Environment Variable local
22+
env.WORKER_HEALTH_FETCH_CONCURRENCY ("10") Environment Variable local
23+
env.AUTOMERGE_CACHE_TTL_SECONDS ("300") Environment Variable local
24+
env.RECENT_CLOSED_CACHE_TTL_SECONDS ("300") Environment Variable local
25+
env.CACHE_TTL_SECONDS ("20") Environment Variable local
26+
env.INCLUDE_CI_STATUS ("1") Environment Variable local
27+
env.EXACT_REVIEW_QUEUE_MAX_CONCURRENT ("128") Environment Variable local
28+
env.EXACT_REVIEW_TARGET_MAX_CONCURRENT ("120") Environment Variable local
29+
env.EXACT_REVIEW_PUBLICATION_MIN_CONCURRENT ("8") Environment Variable local
30+
env.EXACT_REVIEW_PUBLICATION_BASE_CONCURRENT ("32") Environment Variable local
31+
env.EXACT_REVIEW_PUBLICATION_MAX_CONCURRENT ("40") Environment Variable local
32+
env.EXACT_REVIEW_DISPATCH_LEASE_MS ("360000") Environment Variable local
33+
env.EXACT_REVIEW_EXECUTION_LEASE_MS ("7800000") Environment Variable local
34+
env.EXACT_REVIEW_HEARTBEAT_GRACE_MS ("1200000") Environment Variable local
35+
env.EXACT_REVIEW_WORKFLOW_PAUSED_RETRY_MS ("60000") Environment Variable local
36+
env.EXACT_REVIEW_DISPATCH_DEBOUNCE_MS ("90000") Environment Variable local
37+
env.EXACT_REVIEW_DISPATCH_DEBOUNCE_MAX_MS ("180000") Environment Variable local
38+
env.EXACT_REVIEW_PENDING_SOFT_LIMIT ("600") Environment Variable local
39+
env.EXACT_REVIEW_TARGET_RATE_PER_HOUR ("300") Environment Variable local
40+
env.EXACT_REVIEW_TARGET_BURST ("30") Environment Variable local
41+
env.STATE_APPEND_DRAIN_LEASE_MS ("5400000") Environment Variable local
42+
env.EXACT_REVIEW_PUBLICATION_BATCHING_ENABLED ("1") Environment Variable local
43+
env.EXACT_REVIEW_DIRECT_PUBLICATION_ENABLED ("1") Environment Variable local
44+
env.EXACT_REVIEW_STATE_REPO ("openclaw/clawsweeper-state") Environment Variable local
45+
env.EXACT_REVIEW_STATE_REF ("state") Environment Variable local
46+
env.EXACT_REVIEW_PUBLICATION_BATCH_SIZE ("8") Environment Variable local
47+
env.EXACT_REVIEW_PUBLICATION_BATCH_MAX_CONCURRENT ("8") Environment Variable local
48+
env.EXACT_REVIEW_PUBLICATION_FRESH_LANE_ENABLED ("1") Environment Variable local
49+
env.EXACT_REVIEW_PUBLICATION_FRESH_LANE_MAX_ITEMS ("2") Environment Variable local
50+
env.EXACT_REVIEW_PUBLICATION_FRESH_LANE_MAX_AGE_MS ("900000") Environment Variable local
51+
env.EXACT_REVIEW_PUBLICATION_BATCH_WAIT_MS ("60000") Environment Variable local
52+
env.EXACT_REVIEW_PUBLICATION_BATCH_DISPATCH_COOLDOWN_MS ("5000") Environment Variable local
53+
env.EXACT_REVIEW_PUBLICATION_BATCH_DISPATCH_RESERVATION_MS ("600000") Environment Variable local
54+
env.REVIEW_OBSERVABILITY_REQUIRED ("0") Environment Variable local
55+
env.REVIEW_RECOVERY_ENABLED ("0") Environment Variable local
56+
57+
▲ [WARNING] Scheduled Workers are not automatically triggered during local development.
58+
59+
To manually trigger a scheduled event, run:
60+
curl "http://localhost:61904/cdn-cgi/handler/scheduled"
61+
For more details, see https://developers.cloudflare.com/workers/configuration/cron-triggers/#test-cron-triggers-locally
62+
63+
64+
⎔ Starting local server...
65+
[wrangler:info] Ready on http://localhost:61904
66+
[wrangler:info] GET / 200 OK (10ms)
67+
[wrangler:info] GET / 200 OK (2ms)
68+
[wrangler:info] GET /triage 200 OK (2ms)
69+
[wrangler:info] GET /pr-proof-triage 200 OK (2ms)
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
{
2+
"overall_behavior": "satisfies_contract",
3+
"overall_confidence": 1,
4+
"target": {
5+
"type": "web app",
6+
"access": "http://127.0.0.1:61904"
7+
},
8+
"checks": [
9+
{
10+
"contract_clause": "User task 1",
11+
"status": "pass",
12+
"severity": null,
13+
"evidence": "/ returned stable HTTP 200 HTML (162536 bytes, sha256 319af378a93ab82c5b20af7dbab40d04a0596606b1d1dab8b7db0ac34e2c52df).",
14+
"reproduction_steps": [
15+
"GET /",
16+
"GET / again",
17+
"Compare response bytes"
18+
],
19+
"confidence": 1
20+
},
21+
{
22+
"contract_clause": "User task 2",
23+
"status": "pass",
24+
"severity": null,
25+
"evidence": "/triage returned stable HTTP 200 HTML (36015 bytes, sha256 3cb7bac49a71f1c5fe7be9420b31a087ff6c00d696b23f3b48cb99fb5dbb03b5).",
26+
"reproduction_steps": [
27+
"GET /triage",
28+
"GET /triage again",
29+
"Compare response bytes"
30+
],
31+
"confidence": 1
32+
},
33+
{
34+
"contract_clause": "User task 3",
35+
"status": "pass",
36+
"severity": null,
37+
"evidence": "/pr-proof-triage returned stable HTTP 200 HTML (35833 bytes, sha256 ded1952e9e89e99407cadfd754162e31b87caa4d4d8886d6c3673da290c69dc8).",
38+
"reproduction_steps": [
39+
"GET /pr-proof-triage",
40+
"GET /pr-proof-triage again",
41+
"Compare response bytes"
42+
],
43+
"confidence": 1
44+
}
45+
],
46+
"anti_cheat_probes": [
47+
{
48+
"probe": "Repeated every page fetch",
49+
"result": "All repeated bodies were byte-identical"
50+
},
51+
{
52+
"probe": "Compared route hashes",
53+
"result": "All three rendered page hashes were distinct"
54+
},
55+
{
56+
"probe": "Fetched an unknown route",
57+
"result": "Worker returned HTTP 404"
58+
}
59+
],
60+
"blockers": []
61+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{
2+
"schema": "clawsweeper-crabbox-proof-provenance/v1",
3+
"generated_at": "2026-08-11T02:14:24Z",
4+
"claim": "The real local Worker emits byte-identical normalized dashboard page HTML before and after renderer extraction in a clean pushed-PR container checkout.",
5+
"crabbox": {
6+
"cli_version": "0.38.3-5-g2a79805d",
7+
"provider": "local-container",
8+
"lease_id": "cbx_36172f52e311",
9+
"slug": "golden-crayfish-3c9c",
10+
"machine_type": "node_24-bookworm",
11+
"image": "node:24-bookworm",
12+
"runtime": "docker",
13+
"checkout": "--fresh-pr openclaw/clawsweeper#1116 --no-hydrate",
14+
"workdir": "/work/crabbox/cbx_36172f52e311/fresh-pr-openclaw-clawsweeper-1116",
15+
"sync_ms": 13465,
16+
"command_ms": 10475,
17+
"total_ms": 23942,
18+
"exit_code": 0,
19+
"run_status": "succeeded",
20+
"lease_stopped": true
21+
},
22+
"runtime": {
23+
"node": "v24.19.0",
24+
"pnpm": "11.10.0",
25+
"jq": "jq-1.8.1",
26+
"jq_checksum_source": "https://github.com/jqlang/jq/releases/download/jq-1.8.1/sha256sum.txt",
27+
"jq_checksum_result": "jq-linux-amd64: OK"
28+
},
29+
"proof": {
30+
"base_sha": "5a964dadc8131e6e6dc33e9be3536b8141d1d107",
31+
"head_sha": "a00e31c5ae40e33ab8718facac74d39d198dd994",
32+
"routes": [
33+
"/",
34+
"/triage",
35+
"/pr-proof-triage"
36+
],
37+
"proof_rc": 0,
38+
"container_proof_rc": 0,
39+
"normalized_diff_empty": true,
40+
"behavior": "satisfies_contract"
41+
},
42+
"suite_scope": {
43+
"full_suite_run": false,
44+
"blob_hydration_baseline": "not applicable; this container run exercised the exact real-Worker proof"
45+
}
46+
}

0 commit comments

Comments
 (0)