Skip to content

fix: fence exact-review batch publication identity - #947

Merged
brokemac79 merged 1 commit into
mainfrom
codex/csw-075-publication-dual-identity
Jul 29, 2026
Merged

brokemac79 merged 1 commit into
mainfrom
codex/csw-075-publication-dual-identity

Conversation

@brokemac79

@brokemac79 brokemac79 commented Jul 29, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Implements the CSW-075 Workstream 1 post-cutover publication contract: batch state publication now carries a typed dual identity, with a bare canonical target key separated from the exact decorated queue fence key.

Related to #898. CSW-073 remains the audit and approval record.

Problem

The batch queue owns decorated keys such as owner/repo#42@publish:run:attempt, while canonical state validation accepts only owner/repo#42. Treating either representation as the other loses fencing or fails validation. Retried and concurrent batches also need per-member durable outcomes without allowing a stale fence to overwrite current canonical state.

Implementation

  • Add canonicalTargetKey and fenceKey to batch mutation plans, direct-publication payloads, Worker validation, and durable publication receipts.
  • Validate the bare target and exact fence independently. The Worker binds both to the owned queue decision and active batch membership; it does not trim or normalize a client key at the boundary.
  • Persist both identities in direct-publication rows and CLI batch receipts/outcomes. Retried accepted tuples dedupe across reclaimed claim generations, while reclaimed superseded tuples stay superseded.
  • Return independent member outcomes (accepted, deduped, superseded, retryable, or permanent) and continue healthy members when a peer plan is invalid.
  • Gate workflow post-effects on a matching accepted or deduped receipt. Source-drift supersession keeps its separate fenced route.
  • Keep revision ordering fence-local, then reject a batch publication if its durable per-target source head has advanced before the canonical write.
  • Preserve the existing legacy path by emitting its explicit bare canonical target alongside its decorated fence.

Validation

  • pnpm run build:repair
  • pnpm run build:dashboard
  • node --test test/dashboard-worker.test.ts test/exact-review-publication-batches.test.ts test/repair/exact-review-batch-cli.test.ts test/repair/exact-review-batch-publisher.test.ts
    • 327 tests passed locally.
  • Linux controlled proof (Docker-backed Crabbox, mcr.microsoft.com/playwright:v1.60.0-noble): the same builds plus test/repair/exact-review-batch-workflow.test.ts.
    • 337 tests passed, including the real Bash workflow syntax fixture.
  • git diff --check

actionlint is not installed on the host. The workflow’s Bash syntax test is a known baseline failure through this host's bash.exe/docker-desktop WSL route; the controlled Linux proof above exercised and passed that fixture. No platform files or CI matrix were changed.

Real Behavior Proof

Claim. A state-publication batch preserves a bare canonical target independently from the exact fence, fences ownership at the Worker, isolates poison members, and can retry publication transport without duplicating the stable effect path.

Exercised surface. The controlled Worker/Durable Object SQLite fixture exercised /internal/exact-review/publication-batch-results, batch membership fencing, direct-publication durable receipts, the batch CLI receipt/outcome protocol, and the existing batch workflow post-effect selector.

Scenarios and observed result.

  • An invalid member whose canonical key disagrees with its owned target is recorded as permanent; its healthy peer reaches accepted and is the only peer posted to the Worker.
  • A decorated active batch fence is accepted, repeated delivery is deduped, a bare-fence substitution is rejected, and a canonical target that disagrees with the owned fence is rejected.
  • A reclaimed accepted tuple dedupes across claim generations; a reclaimed superseded tuple remains superseded; independent fences are not globally ordered by their local queue revisions; and an older source revision is terminally superseded before it can overwrite canonical state.
  • The direct state-publication retry fixture makes only repeated signed requests to the Worker direct-publication endpoint with the same full dual-identity payload; it does not invoke a GitHub mutation path. Workflow post-effects run only for receipt outcomes that materialized state (accepted or deduped).

Command/environment.

Docker Engine 29.5.2; Crabbox local-container image mcr.microsoft.com/playwright:v1.60.0-noble

corepack pnpm install --frozen-lockfile
corepack pnpm run build:repair
corepack pnpm run build:dashboard
node --test test/exact-review-publication-batches.test.ts test/dashboard-worker.test.ts test/repair/exact-review-batch-cli.test.ts test/repair/exact-review-batch-publisher.test.ts test/repair/exact-review-batch-workflow.test.ts

Artifact/trace. Local-container lease cbx_9230d8582b40 (amber-krill-8f5d), stopped automatically. It synced the exact dirty branch, built repair/dashboard, and reported 337 passing tests with exit code 0.

Limits. This is a controlled Linux Worker/R2-style fixture with mocked external fetches; it does not mutate production Worker/R2 state, live queues, GitHub effects, workflows, or review gates.

Codex review closeout

  • Dirty patch: codex review --uncommitted — final result: no actionable correctness issues. Earlier findings on post-effect gating, reclaimed receipts, legacy dual identity, fence-local revision ordering, and durable source-head staleness were accepted, repaired, and reproven.
  • Branch against current base: rebased onto origin/main at 8365a79af8 (docs-only docs: clarify contributor proof lifecycle #945), then codex review --base origin/main — no actionable correctness issues.

Risks and non-goals

This intentionally does not implement Workstream 2 Completed/command-acknowledgement semantics, change Bay/Overview presentation, broaden scheduler policy, alter replay behavior, expand platform support, add CI, or mutate production state. The remaining evidence limit is live production behavior, which this PR deliberately does not exercise.

@brokemac79

Copy link
Copy Markdown
Contributor Author

@clawsweeper review

@clawsweeper

clawsweeper Bot commented Jul 29, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added 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. P1 Urgent regression or broken agent/channel workflow affecting real users now. merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. labels Jul 29, 2026
@clawsweeper

clawsweeper Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 29, 2026, 7:00 PM ET / 23:00 UTC.

ClawSweeper review

What this changes

Separates canonical record target keys from exact queue fence keys across exact-review batch publication, Worker validation, durable receipts, CLI outcomes, and workflow post-effect gating.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep this draft PR open for maintainer review. It addresses the active publication-protocol defect tracked by #898 with a coherent dual-identity design and substantial controlled proof, but the durable receipt and fence contract still needs the roadmap owner’s explicit approval before landing.

Priority: P1
Reviewed head: 4c00faeaf29dcddf4996705ad12e252a2f939e01
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) This is a substantial but focused protocol repair with credible controlled behavior proof and no discrete defect identified in the supplied diff.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The PR body provides controlled after-fix behavior evidence from a Linux Worker/Durable Object fixture, including partial member success, retry deduplication, ownership rejection, and receipt-gated workflow effects; it correctly states that production state was not mutated.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The PR body provides controlled after-fix behavior evidence from a Linux Worker/Durable Object fixture, including partial member success, retry deduplication, ownership rejection, and receipt-gated workflow effects; it correctly states that production state was not mutated.
Evidence reviewed 6 items Active canonical roadmap: The PR explicitly implements Workstream 1 of the active publication roadmap, and the linked roadmap documents the current defect as a decorated queue fence being rejected where canonical publication requires a bare target key.
Dual-identity propagation: The supplied head diff carries canonicalTargetKey and fenceKey through mutation plans, direct-publication payloads, Worker validation, durable receipt storage, batch outcomes, and the legacy direct path.
Fence ownership validation: The Worker-side queue path validates that the canonical target matches the queue-owned fence and checks active batch membership by fence key, revision, and claim generation before accepting deferred publication.
Findings None None.
Security None None.

How this fits together

Exact-review batches publish review records from the queue into ClawSweeper’s canonical Worker/Durable Object state. Queue members use decorated fence keys for ownership while canonical records use bare repository-and-item keys, and this change carries both identities through publication and receipt handling.

flowchart LR
  A[Exact-review batch manifest] --> B[Prepared publication plan]
  B --> C[Canonical target key]
  B --> D[Exact queue fence key]
  C --> E[Worker canonical tuple validation]
  D --> F[Queue and batch ownership check]
  E --> G[Durable publication receipt]
  F --> G
  G --> H[Workflow post-effect gate]
Loading

Decision needed

Question Recommendation
Should the active Workstream 1 publication contract formally adopt separate canonical target and exact queue-fence identities, including durable per-member receipt outcomes, as implemented by this PR? Approve the Workstream 1 contract: Accept the dual-identity receipt and fencing model as the approved narrow publication-protocol boundary, subject to the current proof and final checks.

Why: The patch is a focused repair for a documented current defect, but it establishes a durable Worker/queue protocol whose permanent semantics must be confirmed by the roadmap owner rather than inferred from a contributor branch.

Before merge

  • Resolve merge risk (P1) - The durable direct-publication receipt schema and ownership checks are compatibility-sensitive: an upgrade must continue to dedupe pre-envelope rows while rejecting a stale or foreign decorated fence.
  • Resolve merge risk (P1) - The PR is intentionally scoped to publication protocol correctness; it must not be treated as approval to change the separate lifecycle, acknowledgement, telemetry, or Bay semantics tracked by Track exact-review publication, lifecycle telemetry, and OpenClaw Bay correctness #898.
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Publication surface 13 files affected; 1,030 additions and 137 deletions The change crosses Worker storage, queue authorization, repair CLI behavior, workflow gating, and focused tests, so contract consistency matters more than any one file.
Focused proof 5 focused test files; 337 passing tests reported The reported controlled Linux run covers the Worker/Durable Object fixture and the Bash workflow syntax fixture for the changed batch path.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #898
Summary: This PR is a candidate implementation of the active Workstream 1 publication-protocol defect documented in the canonical roadmap.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Approve the migration contract before merge (recommended)
    Confirm that old single-key receipts remain dedupe-compatible and that the new canonical-target/fence-key separation is the intended durable upgrade contract.
  2. Pause for a narrower protocol decision
    Keep the draft open if maintainers want to revise receipt retention, retry semantics, or the permanent ownership boundary before accepting a storage migration.

Technical review

Best possible solution:

Approve or narrow the Workstream 1 dual-identity contract, then land this focused implementation only if the receipt migration preserves legacy deduplication and the exact-fence ownership boundary remains the sole authorization path.

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

Yes—high-confidence source and production-run evidence in #898 identifies the current failure path: a decorated publication fence is forwarded where canonical validation requires a bare target key. This review did not independently rerun the failure against the PR base.

Is this the best way to solve the issue?

Unclear—the dual-identity approach directly addresses the documented mismatch and preserves ownership fencing, but the durable receipt and retry contract needs explicit roadmap-owner approval before it becomes the accepted permanent interface.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 8365a79af804.

Labels

Label changes:

  • add P1: This repairs an active batch-publication correctness defect that can prevent canonical exact-review state from being accepted for real queue members.
  • add merge-risk: 🚨 compatibility: The PR changes persisted publication receipt fields and acceptance semantics, so an incorrect migration or identity interpretation could break retries or upgrades for existing queue state.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides controlled after-fix behavior evidence from a Linux Worker/Durable Object fixture, including partial member success, retry deduplication, ownership rejection, and receipt-gated workflow effects; it correctly states that production state was not mutated.
  • 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. Sufficient (live_output): The PR body provides controlled after-fix behavior evidence from a Linux Worker/Durable Object fixture, including partial member success, retry deduplication, ownership rejection, and receipt-gated workflow effects; it correctly states that production state was not mutated.

Label justifications:

  • P1: This repairs an active batch-publication correctness defect that can prevent canonical exact-review state from being accepted for real queue members.
  • merge-risk: 🚨 compatibility: The PR changes persisted publication receipt fields and acceptance semantics, so an incorrect migration or identity interpretation could break retries or upgrades for existing queue state.
  • 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. Sufficient (live_output): The PR body provides controlled after-fix behavior evidence from a Linux Worker/Durable Object fixture, including partial member success, retry deduplication, ownership rejection, and receipt-gated workflow effects; it correctly states that production state was not mutated.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides controlled after-fix behavior evidence from a Linux Worker/Durable Object fixture, including partial member success, retry deduplication, ownership rejection, and receipt-gated workflow effects; it correctly states that production state was not mutated.

Evidence

What I checked:

  • Active canonical roadmap: The PR explicitly implements Workstream 1 of the active publication roadmap, and the linked roadmap documents the current defect as a decorated queue fence being rejected where canonical publication requires a bare target key.
  • Dual-identity propagation: The supplied head diff carries canonicalTargetKey and fenceKey through mutation plans, direct-publication payloads, Worker validation, durable receipt storage, batch outcomes, and the legacy direct path. (src/repair/state-publication-mutation.ts:12, 4c00faeaf29d)
  • Fence ownership validation: The Worker-side queue path validates that the canonical target matches the queue-owned fence and checks active batch membership by fence key, revision, and claim generation before accepting deferred publication. (dashboard/exact-review-queue.ts:2398, 4c00faeaf29d)
  • Persisted-state compatibility path: The direct-publication store adds explicit canonical and fence columns and includes a migration path for existing receipt rows, which is the central upgrade-sensitive surface in this PR. (dashboard/exact-review-direct-publication.ts:178, 4c00faeaf29d)
  • Post-effect safety: The workflow now requires a matching accepted or deduped receipt for an eligible member before running its post-effects, while source-drift supersession remains separately routed. (.github/workflows/exact-review-batch-publish.yml:161, 4c00faeaf29d)
  • Controlled behavior proof: The PR body reports a controlled Linux Worker/Durable Object fixture that exercised rejected mismatched identities, accepted and deduped retries, reclaimed claims, partial batch success, source-head supersession, and workflow post-effect selection; it reports 337 passing focused tests. (test/exact-review-publication-batches.test.ts:220, 4c00faeaf29d)

Likely related people:

  • brokemac79: The linked active roadmap assigns sequencing for the exact-review publication workstream to this person, and the proposed implementation is the current concrete Workstream 1 slice. (role: publication roadmap owner and recent area contributor; confidence: medium; commits: 4c00faeaf29d; files: dashboard/exact-review-queue.ts, dashboard/exact-review-direct-publication.ts, src/repair/exact-review-batch-cli.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@brokemac79
brokemac79 marked this pull request as ready for review July 29, 2026 23:15
@brokemac79
brokemac79 requested a review from a team as a code owner July 29, 2026 23:15
@brokemac79
brokemac79 merged commit 05d864b into main Jul 29, 2026
25 checks passed
@brokemac79
brokemac79 deleted the codex/csw-075-publication-dual-identity branch July 29, 2026 23:16
azaj01 pushed a commit to azaj01/clawsweeper that referenced this pull request Sep 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. P1 Urgent regression or broken agent/channel workflow affecting real users now. 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