Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions .github/workflows/sweep.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1156,18 +1156,20 @@ jobs:
)"
signature="$(PAYLOAD="$payload" node -e 'const crypto=require("node:crypto"); process.stdout.write(`sha256=${crypto.createHmac("sha256", process.env.CLAWSWEEPER_WEBHOOK_SECRET).update(process.env.PAYLOAD).digest("hex")}`)')"
for attempt in 1 2 3; do
if response="$(curl --fail --silent --show-error --connect-timeout 5 --max-time 20 \
--request POST \
--header "content-type: application/json" \
--header "x-clawsweeper-exact-review-signature: $signature" \
--data "$payload" \
"$queue_url/internal/exact-review/enqueue")" &&
jq -e '.ok == true and (.queued == true or (.deduped == true and .superseded != true))' <<< "$response" >/dev/null; then
response="$(
curl --fail --silent --show-error --connect-timeout 5 --max-time 20 \
--request POST \
--header "content-type: application/json" \
--header "x-clawsweeper-exact-review-signature: $signature" \
--data "$payload" \
"$queue_url/internal/exact-review/enqueue" || true
)"
if jq -e '.superseded == true' <<< "$response" >/dev/null 2>&1; then
echo "::notice::Exact-review publication revision $(jq -r '.publication_revision // "unknown"' <<< "$response") was superseded by revision $(jq -r '.superseded_by_revision // "unknown"' <<< "$response"); the newer publisher owns final delivery."
exit 0
fi
if jq -e '.superseded == true' <<< "${response:-}" >/dev/null 2>&1; then
echo "::error::Exact-review publication revision $(jq -r '.publication_revision // "unknown"' <<< "$response") was rejected as superseded by revision $(jq -r '.superseded_by_revision // "unknown"' <<< "$response"); the verdict was not delivered."
exit 1
if jq -e '.ok == true and (.queued == true or .deduped == true)' <<< "$response" >/dev/null; then
exit 0
fi
if [ "$attempt" -lt 3 ]; then
sleep "$((attempt * 5))"
Expand Down
15 changes: 4 additions & 11 deletions test/sweep-workflow.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -450,10 +450,7 @@ test("exact event review hands immutable artifacts to the queue-bounded publishe
assert.equal(upload.uses, "actions/upload-artifact@v7");
assert.equal(upload.with?.["retention-days"], 90);
assert.match(queuePublication.run ?? "", /for attempt in 1 2 3/);
assert.match(
queuePublication.run ?? "",
/\.queued == true or \(\.deduped == true and \.superseded != true\)/,
);
assert.match(queuePublication.run ?? "", /\.queued == true or \.deduped == true/);
assert.match(complete.env?.PRIMARY_OUTCOME ?? "", /exact-review-generation-result/);
assert.match(deferHeldReview.if ?? "", /reserve-exact-review-lease\.outputs\.status == 'held'/);
assert.match(deferHeldReview.run ?? "", /retry deferred/);
Expand Down Expand Up @@ -2770,7 +2767,7 @@ test("github activity workflow scopes cancellation to matching item activity", (
assert.doesNotMatch(concurrencyBlock, /workflow-run' \|\| 'activity'/);
});

test("exact review publication enqueue rejects a superseded acknowledgement", () => {
test("exact review publication enqueue accepts a superseded acknowledgement", () => {
type WorkflowStep = { name?: string; id?: string; run?: string };
type WorkflowJob = { steps: WorkflowStep[] };
const workflow = YAML.parse(readText(".github/workflows/sweep.yml")) as {
Expand All @@ -2781,11 +2778,7 @@ test("exact review publication enqueue rejects a superseded acknowledgement", ()
);
assert.ok(publicationEnqueue, "missing queue-exact-review-publication step");
const run = publicationEnqueue.run ?? "";
assert.match(
run,
/\.ok == true and \(\.queued == true or \(\.deduped == true and \.superseded != true\)\)/,
);
assert.doesNotMatch(run, /\.ok == true and \(\.queued == true or \.deduped == true\)/);
assert.match(run, /\.ok == true and \(\.queued == true or \.deduped == true\)/);
assert.match(run, /jq -e '\.superseded == true'/);
assert.match(run, /the verdict was not delivered/);
assert.match(run, /the newer publisher owns final delivery/);
});