Skip to content

Commit bc80861

Browse files
committed
fix(api): keep the public per-item review read contract
1 parent 8569752 commit bc80861

4 files changed

Lines changed: 69 additions & 15 deletions

File tree

‎dashboard/worker.ts‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -739,6 +739,8 @@ export default {
739739
);
740740
if (url.pathname === "/api/exact-review-queue/item" && request.method === "GET")
741741
return exactReviewQueueRequest(env, `/item-status?${url.searchParams.toString()}`);
742+
if (url.pathname === "/api/exact-review-queue/reviews" && request.method === "GET")
743+
return emptyPerItemReviewsJson(url.searchParams);
742744
if (url.pathname === "/api/review-observability" && request.method === "GET")
743745
return exactReviewQueueRequest(env, `/review-observability?${url.searchParams.toString()}`);
744746
if (url.pathname === "/api/review-coverage" && request.method === "GET")
@@ -7210,6 +7212,23 @@ function json(value, status = 200) {
72107212
);
72117213
}
72127214

7215+
function emptyPerItemReviewsJson(search: URLSearchParams) {
7216+
const repo = String(search.get("repo") || "").trim();
7217+
const itemNumber = Number(search.get("item_number"));
7218+
const limit = search.has("limit") ? Number(search.get("limit")) : 20;
7219+
if (
7220+
!/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/.test(repo) ||
7221+
!Number.isInteger(itemNumber) ||
7222+
itemNumber < 1 ||
7223+
!Number.isInteger(limit) ||
7224+
limit < 1 ||
7225+
limit > 100
7226+
) {
7227+
return json({ error: "invalid_review_telemetry_query" }, 400);
7228+
}
7229+
return json({ ok: true, repo, item_number: itemNumber, reviews: [] });
7230+
}
7231+
72137232
function html(value) {
72147233
return new Response(value, {
72157234
headers: {

‎docs/proof/dead-review-telemetry/README.md‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ The behavior contract is:
1212
retired schema before the proof asserts that the retired objects are gone;
1313
- `/api/status` omits `exact_review_queue.review_telemetry_health` while `/api/health` remains OK;
1414
- a signed run-level telemetry write appears in the four-row `/api/review-observability` lane view;
15-
- the removed internal per-item write route and public per-item read route return 404.
15+
- the removed internal per-item write route returns 404;
16+
- the documented public per-item read route returns its stable HTTP 200 envelope with an empty
17+
`reviews` array.
1618

1719
The proof first boots the Worker to create the real queue database, stops it, and seeds the retired
1820
table plus its three indexes. The stop terminates the full Wrangler process tree and confirms the
@@ -28,15 +30,17 @@ Run `docs/proof/dead-review-telemetry/run-proof.sh`. Set
2830
Worker/Durable Object evidence; it does not deploy or mutate production and does not validate
2931
production traffic volume.
3032

31-
## Crabbox provenance
33+
## Earlier Crabbox provenance
3234

33-
The proof ran unchanged on reviewed head `087100c3ab9343563c42ac57243cde03ad1733a5`
35+
The removal-only revision of this proof ran on reviewed head
36+
`087100c3ab9343563c42ac57243cde03ad1733a5`
3437
inside a Docker-backed Crabbox `local-container` using Crabbox CLI 0.39.0, image
3538
`node:24-bookworm`, Docker 29.4.0 via OrbStack, lease `cbx_7e5d92b51d8b`, and a clean
3639
`--fresh-pr` checkout. It completed with `PROOF_RC=0`. See the
3740
[Crabbox provenance](artifacts/crabbox-local-container-provenance.json) and
3841
[captured stdout](artifacts/crabbox-local-container-stdout.log). Corepack is enabled into the
39-
container user's `~/.local/bin` because the lease user is unprivileged.
42+
container user's `~/.local/bin` because the lease user is unprivileged. Current fresh-PR container
43+
provenance belongs in the pull request's `pr-behavior-proof` section.
4044

4145
Earlier revisions passed on macOS and failed in the container because `stop_worker` killed only the
4246
Wrangler parent and left the child `workerd` alive, so the restart was a no-op and the Durable Object

‎docs/proof/dead-review-telemetry/run-proof.sh‎

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -206,10 +206,21 @@ removed_post_status="$(http_status "${output_dir}/removed-review-telemetry-post.
206206
-H "x-clawsweeper-exact-review-signature: sha256=${removed_signature}" \
207207
--data-binary "$removed_body" \
208208
"http://127.0.0.1:${worker_port}/internal/exact-review/review-telemetry")"
209-
removed_get_status="$(http_status "${output_dir}/removed-reviews-get.txt" \
209+
reviews_get_status="$(http_status "${output_dir}/reviews-get.txt" \
210210
"http://127.0.0.1:${worker_port}/api/exact-review-queue/reviews?repo=openclaw%2Fopenclaw&item_number=674")"
211211
test "$removed_post_status" = "404"
212-
test "$removed_get_status" = "404"
212+
test "$reviews_get_status" = "200"
213+
node -e '
214+
const assert = require("node:assert/strict");
215+
const fs = require("node:fs");
216+
const body = JSON.parse(fs.readFileSync(process.argv[1], "utf8"));
217+
assert.deepEqual(body, {
218+
ok: true,
219+
repo: "openclaw/openclaw",
220+
item_number: 674,
221+
reviews: [],
222+
});
223+
' "${output_dir}/reviews-get.txt"
213224

214225
stop_worker
215226
node "$sqlite_helper" assert-proof-run-record "$queue_db" "$proof_run_id"
@@ -230,7 +241,7 @@ RUN_POST_STATUS="$run_post_status" \
230241
PROOF_RUN_ID="$proof_run_id" \
231242
OBSERVABILITY_STATUS="$observability_status" \
232243
REMOVED_POST_STATUS="$removed_post_status" \
233-
REMOVED_GET_STATUS="$removed_get_status" \
244+
REVIEWS_GET_STATUS="$reviews_get_status" \
234245
node -e '
235246
const fs = require("node:fs");
236247
const body = JSON.parse(fs.readFileSync(process.argv[1], "utf8"));
@@ -244,7 +255,7 @@ node -e '
244255
"POST /internal/exact-review/review-run-telemetry: HTTP " + process.env.RUN_POST_STATUS,
245256
"/api/review-observability: HTTP " + process.env.OBSERVABILITY_STATUS + "; lanes exact_event,hot_intake,normal_backfill,recovery; normal_backfill run_count " + lane.run_count + "; item_count " + lane.item_count + "; last_run_at " + lane.last_run_at,
246257
"POST /internal/exact-review/review-telemetry: HTTP " + process.env.REMOVED_POST_STATUS,
247-
"GET /api/exact-review-queue/reviews: HTTP " + process.env.REMOVED_GET_STATUS,
258+
"GET /api/exact-review-queue/reviews: HTTP " + process.env.REVIEWS_GET_STATUS + "; envelope { ok: true, repo: openclaw/openclaw, item_number: 674, reviews: [] }",
248259
"run-level storage after upgrade: exact_review_run_telemetry present; posted run_id " + process.env.PROOF_RUN_ID + " present in inspected queue database"
249260
];
250261
fs.writeFileSync(process.argv[2], lines.join("\n") + "\n");

‎test/dashboard-worker.test.ts‎

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27533,7 +27533,7 @@ test("exact-review queue drops the retired per-item review telemetry table", asy
2753327533
);
2753427534
});
2753527535

27536-
test("removed per-item review telemetry routes return not found", async () => {
27536+
test("removed per-item review telemetry write routes return not found", async () => {
2753727537
const queue = new ExactReviewQueue({ storage: new MemoryDurableStorage() }, {});
2753827538
const env = {
2753927539
CLAWSWEEPER_WEBHOOK_SECRET: "test-token-placeholder",
@@ -27550,14 +27550,34 @@ test("removed per-item review telemetry routes return not found", async () => {
2755027550
}),
2755127551
env,
2755227552
);
27553-
const publicRoute = await worker.fetch(
27554-
new Request("https://clawsweeper.openclaw.ai/api/exact-review-queue/reviews"),
27555-
env,
27553+
assert.deepEqual([queuePost.status, queueGet.status, internal.status], [404, 404, 404]);
27554+
});
27555+
27556+
test("public per-item review read contract returns a stable empty envelope", async () => {
27557+
const response = await worker.fetch(
27558+
new Request(
27559+
"https://clawsweeper.openclaw.ai/api/exact-review-queue/reviews?repo=openclaw%2Fopenclaw&item_number=674&limit=100",
27560+
),
27561+
{},
2755627562
);
27557-
assert.deepEqual(
27558-
[queuePost.status, queueGet.status, internal.status, publicRoute.status],
27559-
[404, 404, 404, 404],
27563+
assert.equal(response.status, 200);
27564+
assert.deepEqual(await response.json(), {
27565+
ok: true,
27566+
repo: "openclaw/openclaw",
27567+
item_number: 674,
27568+
reviews: [],
27569+
});
27570+
});
27571+
27572+
test("public per-item review read contract rejects invalid queries", async () => {
27573+
const response = await worker.fetch(
27574+
new Request(
27575+
"https://clawsweeper.openclaw.ai/api/exact-review-queue/reviews?repo=openclaw&item_number=0&limit=101",
27576+
),
27577+
{},
2756027578
);
27579+
assert.equal(response.status, 400);
27580+
assert.deepEqual(await response.json(), { error: "invalid_review_telemetry_query" });
2756127581
});
2756227582

2756327583
test("review observer write is signed while aggregate telemetry remains read-only", async () => {

0 commit comments

Comments
 (0)