Skip to content

refactor: build terminal-finalization requests with the typed queue request command - #1812

Merged
obviyus merged 1 commit into
mainfrom
exact-review-terminal-finalization-requests
Oct 9, 2026
Merged

obviyus merged 1 commit into
mainfrom
exact-review-terminal-finalization-requests

Conversation

@obviyus

@obviyus obviyus commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

What

Third lane for the typed queue request command (after #1796 and #1802): the event-review-terminal-finalization steps that run after checkout.

  • src/repair/exact-review-queue-request.ts:
    • New subcommand terminal-finalization <attempt|skip>. It reads the claimed lease tuple through the existing EXACT_REVIEW_* / GITHUB_RUN_* reader, so the lease rules are the same ones the heartbeat uses. The skip reason must be locked_conversation|missing_status_comment.
    • Two records join the existing lifecycle subcommand, because they post to /lifecycle/command-ack/* and use the same lifecycle target: command-ack-failed and command-ack-observed. observed checks the comment ids, completed_at and a success|failure outcome.
    • --status-marker / --status-comment-id address the command status comment, and an empty value means no such address. As before, the attempt, skip and observed bodies need at least one address, and failed may have none.
  • sweep.yml, event-review-terminal-finalization, four inline builders replaced:
    • "Begin fenced terminal acknowledgement"
    • "Update final command status once" (its command-ack/failed body)
    • "Record verified terminal acknowledgement receipt"
    • "Complete locked terminal acknowledgement skip"
  • The attempt and skip steps now name the lease env EXACT_REVIEW_ITEM_KEY / EXACT_REVIEW_LEASE_ID / EXACT_REVIEW_LEASE_REVISION / EXACT_REVIEW_CLAIM_GENERATION, like the review steps. They drop RUN_ATTEMPT (it was github.run_attempt, which the runner already exports as GITHUB_RUN_ATTEMPT). The STATUS_STATE == "Failed" → failure mapping for the observed receipt is now three shell lines next to the call.
  • All four steps run after checkout and after setup-pnpm with build:repair, so dist/repair/exact-review-queue-request.js is present.
  • Still inline, because these steps can run before checkout: "Claim committed terminal finalization" and "Requeue unobserved terminal acknowledgement". The second sources the RUNNER_TEMP helper when checkout failed. Both are for the bootstrap slice.

Copy counts (event-review-terminal-finalization inline body builders):

before after
post-checkout node -e builders 4 0
pre-checkout / checkout-optional builders 2 2 (bootstrap slice)

Why

agent://SlopWorkflows/report finding 2. The four builders repeated the lease tuple and the status-address rules in two shapes. Validation had drifted: the observed builder checked the comment id, but attempt and skip turned a non-numeric comment id into null and still sent the request.

Proof

  1. Body byte identity. Each old builder is extracted from origin/main:sweep.yml and run with its own env names. The new command runs with the renamed env and flags for the same values, with Date.now frozen in both processes for observed_at:
IDENTICAL  Begin fenced terminal acknowledgement (marker only | comment id only | marker and comment id)
IDENTICAL  Complete locked terminal acknowledgement skip (3 addresses × locked_conversation, missing_status_comment)
IDENTICAL  Update final command status once: command-ack/failed (3 addresses + no address)
IDENTICAL  Record verified terminal acknowledgement receipt (3 addresses × Failed, Completed)
19/19 terminal-finalization bodies byte-identical
  1. Lane e2e in a Linux container (node:24-bookworm). There was no existing harness that runs these steps, so a proof driver (not committed) serves the real ExactReviewQueue Durable Object from test/dashboard-worker-harness.ts over HTTP and checks the HMAC on /lifecycle/*. It parks a command the same way test/parked-command-finalization.test.ts does and claims its terminal-finalization driver. It then runs the checked-in step shells with the real control-plane-curl.sh, and evaluates each step's env: block from its expressions, so the env renames are exercised too. The same scenarios run with the fac77558d workflow and with this branch's workflow:
fail-then-observe: base [attempt allowed; status write failed, command-ack/failed recorded, item still parked; attempt allowed; command-ack/observed accepted, parked item retired]
                 branch [same]
  4 queue requests, IDENTICAL between base and branch
missing-comment-skip: base [attempt allowed; skip completed as skipped_missing_comment, parked item retired]
                    branch [same]
  2 queue requests, IDENTICAL between base and branch

(The status write is a stubbed pnpm that fails, which takes the command-ack/failed path. Lease and attempt ids are random per queue and are masked before comparison.) In the same container, on both commits: test/terminal-finalization-cancellation-workflow.test.ts + test/parked-command-finalization.test.ts 57/57 pass, and scripts/e2e/control-plane-checkout-cleanup.mjs (covers the unchanged requeue step) passes. scripts/e2e/manual-review-publication.mjs does not run this job, so I did not use it here; its pre-existing batch-lane failure on main is unchanged by this PR.

  1. test/repair/exact-review-queue-request.test.ts runs the built command for the new bodies and every rejection.

  2. pnpm run check: 6969 pass, 2 fail. Both failures are the known command-proof-consumer timeouts under load; the file passes alone (29/29). codex review --base origin/main: "No actionable defects found." Saved real reports re-rendered with render-comments.mjs: 6/6 byte-identical.

Codex dispositions

  • codex review --base origin/main: no findings.

Merge Danger

  • Door: two-way. Bodies are byte-identical, with no stored data and no queue protocol change. Revert restores the inline builders.
  • Blast radius: final command acknowledgement for parked/terminal commands. If the command rejected input, the attempt step would fail before any request, and the run fails as it did before on a bad tuple. The unchanged requeue step re-arms the driver, and the queue's lease fence is unchanged.

@obviyus
obviyus requested a review from a team as a code owner October 9, 2026 10:01
@clawsweeper

clawsweeper Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper clawsweeper Bot added P3 Low-risk cleanup, docs, polish, ergonomics, or speculative feature. proof: sufficient Contributor real behavior proof is sufficient. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 9, 2026
@clawsweeper

clawsweeper Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

The review workflow uses one typed command to build requests that finish command status updates, replacing four copied inline builders.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A useful consolidation with production workflow and HTTP queue proof, preserved contracts, and no actionable correctness finding.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): Supplied terminal traces exercise the changed CLI through actual workflow shells and real curl transport against ExactReviewQueue in a Node 24 Linux container: a failed acknowledgement retries and is observed, and a missing-comment skip retires the parked item, matching the base. GitHub status writes are stubbed and the proof driver is uncommitted, limiting coverage to serialization and queue handoff. No stored-data contract changes require migration.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Refactor · Worth it: Yes
Reason: Four copied request builders become one existing typed owner with consistent validation. The maintenance benefit outweighs the small production increase, and the established finalization behavior is preserved.

Merge readiness

✅ Ready for maintainer review

Keep open: this is a useful, bounded consolidation that current main does not contain. No actionable patch defect was found.

Priority: P3
Reviewed head: ab6f2036b2e9b33bf339f29efdde9c73562eaa24

Before merge

None.

Findings

None.

Agent review details

How this fits together

GitHub Actions sends final command acknowledgements to ClawSweeper’s review queue. The queue checks ownership and records whether the command finished, needs another attempt, or completed without a status comment.

flowchart TD
  A[Claimed workflow lease] --> C[Typed request command]
  B[Status address and completion] --> C
  C --> D{Valid inputs?}
  D -->|No| E[Stop before sending]
  D -->|Yes| F[Existing HTTP client]
  F --> G[Queue ownership checks]
  G --> H[Record acknowledgement or skip]
Loading

Technical review

Best possible solution:

Keep request serialization in the existing typed command while retaining queue authorization and HTTP transport with their current owners.

Do we have a high-confidence way to reproduce the issue?

Not applicable: this PR consolidates request construction rather than reporting a user-facing failure; source confirms the four copied builders and their differing validation.

Is this the best way to solve the issue?

Yes: extending the existing serializer replaces duplicate construction without adding a competing transport or changing the queue’s authorization contract.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against d559d9e498e4.

Provenance checked

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Repository policy: Read the complete root AGENTS.md; no nested AGENTS.md or maintainer-notes directory was found. Applied narrow-change, proof, build-availability, changelog, and observer-only Bay guidance. (AGENTS.md:1, ab6f2036b2e9)
  • Introduced changes: The pinned introduction replaces four workflow serializers with the existing command. Request routes, transport, response handling, status-write conditions, and requeue behavior remain intact. (.github/workflows/sweep.yml:3832, ab6f2036b2e9)
  • Build availability: The terminal-finalization job builds repair commands after checkout and before the migrated steps. The repair compiler includes src/repair/**/*.ts; bootstrap and checkout-optional requests remain inline. (.github/workflows/sweep.yml:3826, ab6f2036b2e9)
  • Queue contract and security: The unchanged queue validates the terminal lease tuple, requires active ownership, and checks acknowledgement addresses and attempt identity. This refactor does not materially change authority, credentials, permissions, or the principals permitted to write command status. (dashboard/exact-review-queue.ts:10639, ab6f2036b2e9)
  • Recorded behavior proof: The fully supplied PR body, captured source revision 1868ebd60f6ad57c01267b5fb05d1823d0f7545b9d81ac29f2e496a12f1230cf, records Linux node:24-bookworm proof through checked-in workflow shells and real control-plane-curl.sh against the production ExactReviewQueue served over HTTP. Failure followed by observation releases and retries the acknowledgement, then retires the parked item; missing-comment skip also retires it. Base and branch requests match, alongside 19 byte-identical body comparisons. The GitHub status write was stubbed, and the uncommitted proof driver was not available for independent inspection. (ab6f2036b2e9)
  • Production proof owner: The named dashboard harness imports the production Worker and ExactReviewQueue implementation rather than substituting a mocked queue. Its controlled environment supplies synthetic target metadata; proof establishes workflow serialization and queue transitions, rather than deployed GitHub execution. (test/dashboard-worker-harness.ts:14, ab6f2036b2e9)

Likely related people:

  • Ayaan Zaidi: Raw commit 373cf3e adds src/repair/exact-review-queue-request.ts:4 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 373cf3e3a1a7; files: src/repair/exact-review-queue-request.ts)
  • Martin Cleary: Raw commit 746186d adds .github/workflows/sweep.yml:3129 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 746186da68f0; files: .github/workflows/sweep.yml)

Review metrics

Metric Value Why it matters
Request builder consolidation 4 post-checkout builders replaced; 2 bootstrap builders retained The changed lane shares validation without introducing another bootstrap mechanism.
Production versus test changes Production +138/-88; tests +210/-22 The modest net production growth centralizes lease and acknowledgement validation while removing copied workflow logic.

Labels

Label changes:

  • add P3: This is bounded maintenance that preserves existing command finalization behavior.
  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P3: This is bounded maintenance that preserves existing command finalization behavior.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only; repair and merge need explicit maintainer commands such as @clawsweeper autofix or @clawsweeper automerge.

Reviewed October 9, 2026, 6:04 AM ET / 10:04 UTC.

@obviyus
obviyus merged commit 109dd16 into main Oct 9, 2026
23 checks passed
@obviyus
obviyus deleted the exact-review-terminal-finalization-requests branch October 9, 2026 10:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P3 Low-risk cleanup, docs, polish, ergonomics, or speculative feature. proof: sufficient Contributor real behavior proof is sufficient. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant