Skip to content

Commit 26cd576

Browse files
committed
test(queue): document the saved-lease authority repro
1 parent b0e7588 commit 26cd576

5 files changed

Lines changed: 866 additions & 0 deletions

File tree

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
# Saved lease authority repro
2+
3+
- Status: proposed proof methodology; this folder contains no execution receipt
4+
- Owner: ClawSweeper queue maintainers
5+
- Source of truth: [queue](../../../dashboard/exact-review-queue.ts),
6+
[lifecycle tests](../../../test/dashboard-worker-publication-lifecycle.test.ts),
7+
and [workflow tests](../../../test/sweep-workflow.test.ts)
8+
- Baseline: `659dee73d0706fee9776f7986d9861e82b897d24`
9+
- Prepared candidate: `b0e75888d4341a98bc0db0b5f5cb9f3cd566eb0f`
10+
- Update when: the compared source, lease authority, terminal lifecycle,
11+
forwarding protocol, Bay projection, or pinned toolchain changes
12+
13+
This is a focused follow-up to <https://github.com/openclaw/clawsweeper/pull/1251>.
14+
The original lost-completion repair is already in the baseline. The claim here
15+
is that direct requeue authority belongs to the saved lease's accepted or
16+
deduplicated receipt: a mutable current decision cannot invent or remove that
17+
authority, and a superseded receipt cannot authorize a requeue completion.
18+
19+
The public source makes the experiment inspectable without access to private
20+
artifact portals. It does not establish that this integrated candidate has
21+
passed runtime proof. Record fresh execution observations in the main PR body,
22+
bound to its exact head and base; never present these expected results as an
23+
executed receipt.
24+
25+
## Run
26+
27+
Use an already provisioned Linux environment with Bash, Node 24, pnpm 11.10.0,
28+
Git, tar, curl, `setsid`, installed repository dependencies, and an installed
29+
Wrangler **4.107.0** executable with its Miniflare/workerd dependencies. The
30+
driver verifies versions and records the workerd binary version. It installs
31+
nothing, fetches no source, and allocates no cloud resources. For maintained
32+
proof, the operator supplies the configured AWS Crabbox environment and records
33+
the actual provider, image, lease, and run separately.
34+
35+
From the candidate checkout, including this entire folder:
36+
37+
```bash
38+
SAVED_LEASE_SOURCE_DIR="$PWD" \
39+
SAVED_LEASE_OUTPUT=/tmp/saved-lease-proof-results \
40+
SAVED_LEASE_WRANGLER=/absolute/path/to/installed/wrangler \
41+
bash docs/proof/saved-lease-authority/run-proof.sh
42+
```
43+
44+
The output must be a new absolute directory. `SAVED_LEASE_SOURCE_DIR` defaults
45+
to the current directory; `SAVED_LEASE_PORT` defaults to 8795. A Git index and
46+
HEAD are required to enumerate candidate source and record its identity. Run
47+
against clean committed source for final proof; the manifest records any
48+
tracked working-tree changes and hashes the actual copied source.
49+
50+
The baseline object must be available, or supply `SAVED_LEASE_BASELINE_ARCHIVE`
51+
with an archive created by this exact command:
52+
53+
```bash
54+
git archive --format=tar 659dee73d0706fee9776f7986d9861e82b897d24 \
55+
dashboard src config .github/workflows/sweep.yml package.json \
56+
> /tmp/saved-lease-baseline.tar
57+
```
58+
59+
Its SHA-256 must be
60+
`f1873d20690bbc76f53257949caf6f55301f47279a844c2e416a0ed637fafd07`.
61+
The driver rejects a different digest, unsafe archive paths, and links. It
62+
extracts into temporary directories, preserves all baseline dependencies, and
63+
uses the candidate checkout's installed dependencies for both modes.
64+
65+
## Exercised surface and expected observations
66+
67+
[run-proof.sh](run-proof.sh) starts real workerd with isolated SQLite Durable
68+
Objects for each mode. [worker.ts](worker.ts) supplies narrow fixture operations
69+
through the real signed forwarding path. [drive-proof.mjs](drive-proof.mjs)
70+
drives publication, terminal disposition, enqueue, completion, reconciliation,
71+
and the public Bay projection over loopback HTTP. Modes are explicit; no source
72+
symbol or grep-based detection selects expected behavior.
73+
74+
Each mode exercises 17 scenarios. Accepted/deduplicated receipts cover delivered
75+
completion and a realistic lost callback: the finalizer's terminal `requeue`
76+
is written before `/complete` is deliberately omitted. Both modes should recover
77+
those cases. The four distinguishing authority controls are:
78+
79+
| Control | Baseline expectation | Candidate expectation |
80+
| --- | --- | --- |
81+
| Superseded receipt with requeue completion | Incorrectly accepts requeue | Rejects completion with HTTP 400 |
82+
| Missing saved lease decision | Incorrectly borrows current authority | Does not requeue |
83+
| Wrong saved source action | Incorrectly borrows current authority | Does not requeue |
84+
| Current plan changed after lease | Drops saved requeue authority | Requeues from the saved lease |
85+
86+
Other controls cover superseded/no-lifecycle receipts, a real signed newer
87+
command, wrong run attempt or claim generation, ambiguous ownership, unsigned
88+
reconciliation, failed/cancelled publication retries, repeated reconciliation,
89+
and late old completion. Assertions inspect pending revision and decision,
90+
lease clearance, lifecycle identity, terminal outcome, counters, and public
91+
Bay projection. They retain existing newer-command and retry behavior.
92+
93+
[annotation-proof.mjs](annotation-proof.mjs) compares the unchanged workflow
94+
failure gate across 192 feasible Boolean contexts and executes its actual Bash
95+
block for six synthetic cases in each mode. No workflow edit is claimed.
96+
97+
OpenClaw Bay needs no schema or UI change. The proof checks the existing
98+
observer-only projection and SQLite Bay row counts, including preservation of
99+
the old terminal fact without invented success/failure, router, or
100+
acknowledgement receipts. It includes current-main telemetry dependencies.
101+
102+
## Artifacts and limits
103+
104+
Generated output includes source, lockfile, and driver hashes; HEAD/tree and
105+
baseline identity; toolchain versions; exact runtime commands; request/response
106+
traces; scenario assertions; workflow annotation observations; and Wrangler
107+
logs. Keep raw output outside committed source. The main PR body must record
108+
normalized observations, exact command, head/base, provider/image/lease, and
109+
limits after execution. If later source changes, rerun affected proof or state
110+
and verify exact source/hash equivalence before carrying observations forward.
111+
112+
Admission and malformed/ambiguous authority preconditions are seeded. Terminal
113+
run observations use signed supplied `terminal_runs`, without a GitHub lookup.
114+
The harness disables alarm dispatch only after asserting exactly one pending
115+
item. Outbound Worker fetch throws and is counted; any unexpected alarm state
116+
fails. Wrangler receives an allowlisted environment and an empty temporary home.
117+
All identifiers and signing material are synthetic. No credentials, live queue
118+
mutation, GitHub writes, deployed-edge behavior, Actions admission, complete
119+
hosted workflow, or model inference are exercised.
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
import assert from "node:assert/strict";
2+
import { spawnSync } from "node:child_process";
3+
import { readFileSync, writeFileSync } from "node:fs";
4+
import YAML from "yaml";
5+
const [baselineDir, candidateDir, output] = process.argv.slice(2);
6+
const step = (dir) =>
7+
YAML.parse(readFileSync(`${dir}/.github/workflows/sweep.yml`, "utf8")).jobs[
8+
"event-review-apply"
9+
].steps.find((s) => s.name === "Fail unsuccessful exact review generation");
10+
const before = step(baselineDir),
11+
after = step(candidateDir);
12+
assert.equal(after.if, before.if, "the failure gate must be byte-identical");
13+
function evaluate(template, values) {
14+
const expression = template
15+
.replace(/^\s*\$\{\{\s*|\s*\}\}\s*$/g, "")
16+
.replace(/\balways\(\)/g, "true")
17+
.replace(/steps\.([a-z0-9-]+)\.(outputs\.([a-z0-9_]+)|outcome)/g, (_m, id, access, out) =>
18+
JSON.stringify(values[`${id}.${out ?? access}`] ?? ""),
19+
);
20+
return Function(`"use strict"; return (${expression});`)();
21+
}
22+
const assertions = [];
23+
let truthTableCases = 0;
24+
for (let mask = 0; mask < 256; mask++) {
25+
const [claimed, accepted, completed, superseded, held, itemSuperseded, generated, deferred] =
26+
Array.from({ length: 8 }, (_, bit) => Boolean(mask & (1 << bit)));
27+
if (superseded && held) continue;
28+
const values = {
29+
"claim-exact-review-queue.claimed": String(claimed),
30+
"direct-exact-review-publication.accepted": String(accepted),
31+
"complete-exact-review-queue.outcome": completed ? "success" : "failure",
32+
"reserve-exact-review-lease.status": superseded ? "superseded" : held ? "held" : "posted",
33+
"review-exact-event-item.superseded": String(itemSuperseded),
34+
"exact-review-generation-result.outcome": generated ? "success" : "failure",
35+
"exact-review-generation-result.retry_kind": deferred ? "throttle" : "",
36+
};
37+
const generationFailed = !generated && !deferred && !held && !superseded;
38+
const expected =
39+
claimed && ((!accepted && !completed && !superseded && !itemSuperseded) || generationFailed);
40+
for (const entry of [before, after]) {
41+
assert.equal(evaluate(entry.if, values), expected);
42+
assert.equal(
43+
evaluate(entry.env.CLASSIFICATION, values),
44+
generationFailed ? "codex_or_content_failure" : "queue_completion_failure",
45+
);
46+
}
47+
truthTableCases++;
48+
}
49+
for (const [name, process, generation, retry, reservation, completion, classification] of [
50+
["completion-only", "success", "success", "", "posted", "failure", "queue_completion_failure"],
51+
[
52+
"held-deferral",
53+
"skipped",
54+
"failure",
55+
"coordination",
56+
"held",
57+
"failure",
58+
"queue_completion_failure",
59+
],
60+
[
61+
"typed-throttle",
62+
"failure",
63+
"failure",
64+
"throttle",
65+
"posted",
66+
"failure",
67+
"queue_completion_failure",
68+
],
69+
[
70+
"content-failure-exit-zero",
71+
"success",
72+
"failure",
73+
"",
74+
"posted",
75+
"success",
76+
"codex_or_content_failure",
77+
],
78+
[
79+
"simultaneous-failures",
80+
"failure",
81+
"failure",
82+
"",
83+
"posted",
84+
"failure",
85+
"codex_or_content_failure",
86+
],
87+
["review-only", "failure", "failure", "", "posted", "success", "codex_or_content_failure"],
88+
]) {
89+
const values = {
90+
"claim-exact-review-queue.claimed": "true",
91+
"direct-exact-review-publication.accepted": "false",
92+
"complete-exact-review-queue.outcome": completion,
93+
"reserve-exact-review-lease.status": reservation,
94+
"review-exact-event-item.outcome": process,
95+
"review-exact-event-item.exit_code": process === "failure" ? "1" : "0",
96+
"exact-review-generation-result.outcome": generation,
97+
"exact-review-generation-result.retry_kind": retry,
98+
};
99+
for (const [mode, entry] of [
100+
["baseline", before],
101+
["candidate", after],
102+
]) {
103+
assert.equal(evaluate(entry.if, values), true);
104+
const env = Object.fromEntries(
105+
Object.entries(entry.env).map(([key, value]) => [
106+
key,
107+
String(evaluate(String(value), values)),
108+
]),
109+
);
110+
const result = spawnSync("bash", ["-c", entry.run], { env, encoding: "utf8" });
111+
assert.equal(result.status, 1);
112+
assert.equal(result.stderr, "");
113+
assert.match(result.stdout, new RegExp(`classification=${classification} `));
114+
assert.match(result.stdout, new RegExp(`queue_completion=${completion}`));
115+
assertions.push({
116+
mode,
117+
name,
118+
exit: result.status,
119+
annotation: result.stdout.trim(),
120+
status: "PASS",
121+
});
122+
}
123+
}
124+
writeFileSync(
125+
output,
126+
JSON.stringify(
127+
{ gate_unchanged: true, truth_table_cases: truthTableCases, assertions },
128+
null,
129+
2,
130+
) + "\n",
131+
);
132+
console.log(
133+
`annotation proof: ${truthTableCases} gate cases and ${assertions.length} shell executions passed`,
134+
);

0 commit comments

Comments
 (0)