Skip to content

Commit bab218b

Browse files
committed
test(proof): isolate durable event aggregate failures
1 parent 60e51c0 commit bab218b

3 files changed

Lines changed: 79 additions & 12 deletions

File tree

‎docs/proof/csw-092/README.md‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,7 @@ local Worker route and Bay page rendering, not production telemetry or
77
production performance.
88

99
See `proof-summary.json` for the exact current head, environment, assertions,
10-
request classification, and fixture checksum. `01a-mini-control-board.jpg` is
11-
a representative current-head frame of the populated aggregate card.
10+
request classification, and fixture checksum. `runtime-transcript.md` records
11+
the exercised surfaces, observations, and fixture limits.
12+
`01a-mini-control-board.jpg` is a representative current-head frame of the
13+
populated aggregate card.
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# CSW-092 controlled runtime proof
2+
3+
Code exercised: `ef3b016046258f4d4b98dc473cd269e1863c2028`.
4+
This commit is the product-code parent of the evidence-only successor recorded
5+
in the pull request body. No application source changed in that successor.
6+
7+
## Environment and command
8+
9+
```text
10+
Crabbox lease: cbx_34f66acb8a77
11+
Provider: local-container (Docker)
12+
Image: mcr.microsoft.com/playwright:v1.60.0-noble
13+
Command: crabbox run --provider local-container --local-container-image \
14+
mcr.microsoft.com/playwright:v1.60.0-noble --no-hydrate --timing-json \
15+
--script docs/proof/openclaw-bay/run-proof.sh
16+
```
17+
18+
The controlled browser proof completed 48 assertions and wrote 23 frames. Its
19+
fixture intercepted zero external GitHub API requests and made zero queue,
20+
GitHub, or production mutations.
21+
22+
## Observations
23+
24+
- The real built Bay document rendered a populated **Recent durable events**
25+
card. The captured frame is
26+
[`01a-mini-control-board.jpg`](./01a-mini-control-board.jpg): the fixture's
27+
24-hour aggregate displayed direct `accepted 3`, `deduped 1`, and batch
28+
`retryable 2` counts.
29+
- The Worker route test exercised `/api/recent-durable-publication-events` for
30+
the six-hour window, checked a complete result and public redaction, then
31+
repeated that request and observed only the first direct/batch source reads
32+
(the 60-second in-memory per-window cache served the repeat).
33+
- The aggregate helper tests cover all allowed six-hour, 24-hour, and seven-day
34+
windows: every response has exactly 24 buckets; an empty complete window is
35+
idle; malformed, mixed, unavailable, and over-10,000-row sources produce
36+
`complete: false` and Unknown rather than partial counts.
37+
- The Worker status test simulates an unavailable aggregate route while a real
38+
queue `/stats` response succeeds. `/api/status` retains
39+
`exact_review_queue.pending: 0`, returns HTTP success, and exposes only the
40+
aggregate as unavailable with `recent_durable_publication_events_error`.
41+
This demonstrates the optional aggregate cannot turn core queue status into
42+
a failure.
43+
- The positive fixture and endpoint assertions contain no repository identity,
44+
receipt, fence, revision, or run identifier. Workflow-only activity remains
45+
outside the event schema and is never asserted or rendered as lifecycle
46+
completion.
47+
48+
## Limits
49+
50+
This is a controlled, synthetic fixture against the real built Worker/Bay
51+
surfaces, not a production traffic measurement. A cold per-window request can
52+
still issue the two indexed retained-event scans, each capped at 10,000 + 1;
53+
at high source rates it intentionally reports Unknown instead of partial data.
54+
The short-lived cache reduces repeat scans but is not a persistent rollup and
55+
does not make availability or seven-day source-rate guarantees.

‎test/dashboard-worker.test.ts‎

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9525,20 +9525,24 @@ test("optional exact-review telemetry failures do not freeze an idle status snap
95259525
globalThis.fetch = async () => {
95269526
throw new Error("shared snapshot should avoid GitHub requests");
95279527
};
9528+
const queue = new ExactReviewQueue({ storage: new MemoryDurableStorage() }, {});
95289529
let queueReads = 0;
9529-
const failingQueue = {
9530-
fetch: async () => {
9530+
const queueWithUnavailableAggregate = {
9531+
fetch: async (request: Request) => {
95319532
queueReads += 1;
9532-
return new Response(JSON.stringify({ error: "queue_read_failed" }), {
9533-
status: 503,
9534-
headers: { "content-type": "application/json" },
9535-
});
9533+
if (new URL(request.url).pathname === "/recent-durable-publication-events") {
9534+
return new Response(JSON.stringify({ error: "queue_read_failed" }), {
9535+
status: 503,
9536+
headers: { "content-type": "application/json" },
9537+
});
9538+
}
9539+
return queue.fetch(request);
95369540
},
95379541
};
95389542
const env = {
95399543
CACHE_TTL_SECONDS: "60",
95409544
STATUS_STORE: statusStore,
9541-
EXACT_REVIEW_QUEUE: new MemoryDurableNamespace(failingQueue),
9545+
EXACT_REVIEW_QUEUE: new MemoryDurableNamespace(queueWithUnavailableAggregate),
95429546
};
95439547

95449548
try {
@@ -9548,10 +9552,10 @@ test("optional exact-review telemetry failures do not freeze an idle status snap
95489552
{ waitUntil: () => undefined },
95499553
);
95509554
const status = await response.json();
9551-
assert.equal(status.exact_review_queue, null);
9555+
assert.equal(status.exact_review_queue.pending, 0);
95529556
assert.equal(status.recent_durable_publication_events, null);
95539557
assert.deepEqual(status.diagnostics.errors, []);
9554-
assert.equal(status.diagnostics.exact_review_queue_error, "queue_read_failed");
9558+
assert.equal(status.diagnostics.exact_review_queue_error, null);
95559559
assert.equal(status.diagnostics.recent_durable_publication_events_error, "queue_read_failed");
95569560

95579561
const cached = await worker.fetch(
@@ -9560,7 +9564,13 @@ test("optional exact-review telemetry failures do not freeze an idle status snap
95609564
{ waitUntil: () => undefined },
95619565
);
95629566
assert.equal(cached.headers.get("x-clawsweeper-cache"), "fresh");
9563-
assert.equal((await cached.json()).diagnostics.exact_review_queue_error, "queue_read_failed");
9567+
const cachedStatus = await cached.json();
9568+
assert.equal(cachedStatus.exact_review_queue.pending, 0);
9569+
assert.equal(cachedStatus.diagnostics.exact_review_queue_error, null);
9570+
assert.equal(
9571+
cachedStatus.diagnostics.recent_durable_publication_events_error,
9572+
"queue_read_failed",
9573+
);
95649574
assert.equal(queueReads, 2);
95659575
} finally {
95669576
globalThis.fetch = originalFetch;

0 commit comments

Comments
 (0)