Skip to content

fix(review): reconcile terminal legacy publications - #892

Merged
brokemac79 merged 1 commit into
mainfrom
codex/csw-065-command-context-reconciliation
Jul 27, 2026
Merged

fix(review): reconcile terminal legacy publications#892
brokemac79 merged 1 commit into
mainfrom
codex/csw-065-command-context-reconciliation

Conversation

@brokemac79

@brokemac79 brokemac79 commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Summary

Reconcile stranded protocol-v1 exact-review publication rows when their target is terminal, without changing the direct-publication path, dashboard projection, publisher workflow, or state-writer behavior.

Problem

openclaw/openclaw#113313 was merged while its legacy row openclaw/openclaw#113313@publish:30091560737:1 remained ownerless in the public publication queue. The source workflow run 30091560737 completed successfully on 2026-07-24, before the later direct-publication change in #859. Protocol-v1 rows had no revision tuple, so the existing reconciliation route did not consider them.

Implementation

  • Add an explicit, bounded protocol-v1 terminal-reconciliation path to /publications/reconcile.
  • Require live_proceeded, a terminal target read, no active batch/lease, and no current or newer target authority.
  • Never reclaim command/status-context rows; their acknowledgement completion has no matching durable terminal receipt.
  • Index authority once per target before candidate selection, preserving the max_items bound without quadratic backlog scans.
  • Persist expired-lease recovery before apply-mode target reads, and make dry runs perform the same read without deleting rows.
  • Surface legacy candidate, selected, terminal-eligible, and changed counters through the maintenance client.

Validation

  • pnpm run build:all
  • pnpm run lint:dashboard
  • pnpm run lint:repair
  • node --test test/dashboard-worker.test.ts (246 passing)
  • node --test test/repair/exact-review-batch-coordinator.test.ts (7 passing)
  • codex review --uncommitted — final result: no actionable correctness issues.
  • git fetch origin main --prune && codex review --base origin/main — final result: no actionable correctness issues.

Focused coverage proves terminal removal, dry-run verification without mutation, expired-lease persistence, command acknowledgement retention, active batch/lease protection, and newer publication authority protection.

Representative Docker proof

Ran a Docker-backed Crabbox local-container scenario on the PR head (lease cbx_f9f31e55ac0f, auto-stopped, exit 0). It used the actual ExactReviewQueue implementation with an isolated local Durable Object and a live public GitHub read of the terminal target. No production queue, state, deployment, workflow event, replay, or apply path was touched.

The fixture contains the stranded ordinary v1 row, an awaiting-command v1 row, and a v1 row owned by an active batch. The exact root target read was openclaw/openclaw#113313, which GitHub returned as closed at 2026-07-24T13:00:16Z.

{
  "target": {
    "number": 113313,
    "state": "closed",
    "closed_at": "2026-07-24T13:00:16Z"
  },
  "dry_run": {
    "candidates": 1,
    "selected": 1,
    "eligible": 1,
    "changed": 0,
    "ordinary_row_retained": true
  },
  "capped_apply": {
    "max_items": 1,
    "eligible": 1,
    "changed": 1,
    "ordinary_row_removed": true
  },
  "protected_rows": {
    "command_context_retained": true,
    "active_batch_retained": true,
    "protected_batch_items": 1
  }
}

This is representative non-production evidence, not an authorization to mutate the live queue. A production operator should still inspect a live dry run before any bounded maintenance apply.

Risks and rollout

This changes only the explicit reconciliation endpoint. Each pass remains capped at 100 selected rows and uses bounded target reads; it does not deploy, poll broadly, alter the public dashboard, or mutate live queue state as part of this PR. Operators should inspect a dry run first, then apply one bounded pass and observe normal queue health.

Links

@brokemac79

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 27, 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 rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal priority bug or improvement with limited blast radius. labels Jul 27, 2026
@clawsweeper

clawsweeper Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 27, 2026, 8:58 AM ET / 12:58 UTC.

ClawSweeper review

What this changes

Adds bounded reconciliation for stranded protocol-v1 exact-review publication rows when a live target read is terminal, while retaining command-context, active-batch, leased, and newer-authority rows.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

This PR remains necessary: the merged direct-publication transition retained the legacy queue as a bounded fallback, while protocol-v1 rows lack the revision metadata used by the existing reconciliation route. The updated PR body now provides representative real-runtime proof for the new bounded path; I found no discrete correctness defect in the supplied diff, so this is ready for normal maintainer merge review with the stated live dry-run rollout precaution.

Priority: P2
Reviewed head: 00cecde3858c518ee561a149d79da439bc4215fa

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The PR has focused implementation and regression coverage plus representative real queue behavior proof; its remaining consideration is the deliberate operational rollout of durable-row deletion.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The PR body supplies after-fix Docker-backed output from the actual ExactReviewQueue with an isolated Durable Object and a live terminal target read; it shows dry-run non-mutation, capped apply removal, and retention of protected rows.
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 supplies after-fix Docker-backed output from the actual ExactReviewQueue with an isolated Durable Object and a live terminal target read; it shows dry-run non-mutation, capped apply removal, and retention of protected rows.
Evidence reviewed 5 items Protocol-v1 reconciliation implementation: The PR adds a legacy-reconciliation mode to terminal candidate handling, reclaims expired leases for eligible terminal candidates, builds a per-target authority index, and returns completed keys so only protected, terminal legacy rows proceed to removal.
Focused durable-queue coverage: The added queue tests cover terminal legacy removal, dry-run retention, command-context retention, active-batch protection, expired-lease handling, and newer-authority protection.
Maintenance-client contract coverage: The repair client now validates and exposes the legacy terminal reconciliation counters returned by the queue endpoint.
Findings None None.
Security None None.

How this fits together

Exact-review results enter a Durable Object-backed publication queue before they are reflected in the public state surface. The maintenance reconciliation endpoint examines stored publication rows, checks ownership and target status, then removes only rows whose terminal state has no active or newer publication authority.

flowchart LR
  A[Legacy publication rows] --> B[Reconciliation endpoint]
  B --> C[Batch and lease protection]
  C --> D[Bounded target-status reads]
  D --> E[Publication authority check]
  E --> F[Terminal row removal]
  F --> G[Maintenance counters]
Loading

Before merge

  • Resolve merge risk (P1) - A bounded apply can delete durable legacy publication rows after a terminal target read; although the PR protects the tested ownership cases, the first production use should follow the documented live dry run and one capped apply pass before broader maintenance use.
  • Complete next step (P2) - No concrete repair task remains: the supplied diff has no actionable review finding, and the remaining action is normal maintainer merge review plus the documented operator rollout.
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Changed surface 5 files affected; 694 additions, 33 deletions The runtime change is concentrated in the queue, its typed maintenance client, focused tests, and the operator rollout document.
Focused regression coverage 2 test files changed; 457 reported focused passing tests The supplied validation covers both Durable Object queue behavior and the maintenance-client response contract.

Merge-risk options

Maintainer options:

  1. Merge with the documented bounded rollout (recommended)
    Accept the narrowly scoped durable-queue maintenance risk and require the first production use to inspect a live dry run before one capped apply pass.
  2. Pause for additional production-like review
    Keep the PR open if maintainers want an additional controlled queue-state review before enabling any live reconciliation apply.

Technical review

Best possible solution:

Merge the bounded protocol-v1 reconciliation path, then have an operator inspect a live dry run and perform one max_items: 100 apply pass while observing normal queue health.

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

Yes, with medium confidence: an isolated ExactReviewQueue can be seeded with a live_proceeded protocol-v1 row whose target is closed, then /publications/reconcile demonstrates the pre-fix retained-row behavior and the post-fix bounded removal path. The supplied proof runs the after-fix case, but does not include a captured current-main pre-fix execution.

Is this the best way to solve the issue?

Yes: extending the existing explicit reconciliation endpoint is narrower and safer than changing direct publication, dashboard projection, publisher workflow, or state-writer behavior; the authority, lease, batch, and command-context guards keep the repair constrained.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 1082c407028d.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body supplies after-fix Docker-backed output from the actual ExactReviewQueue with an isolated Durable Object and a live terminal target read; it shows dry-run non-mutation, capped apply removal, and retention of protected rows.
  • 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 supplies after-fix Docker-backed output from the actual ExactReviewQueue with an isolated Durable Object and a live terminal target read; it shows dry-run non-mutation, capped apply removal, and retention of protected rows.
  • remove rating: 🧂 unranked krab: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: This is a bounded production queue-maintenance repair with limited blast radius rather than an active user-facing outage.
  • merge-risk: 🚨 other: Merging adds a new path that can remove legacy durable publication records after live terminal-state checks.
  • 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 supplies after-fix Docker-backed output from the actual ExactReviewQueue with an isolated Durable Object and a live terminal target read; it shows dry-run non-mutation, capped apply removal, and retention of protected rows.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body supplies after-fix Docker-backed output from the actual ExactReviewQueue with an isolated Durable Object and a live terminal target read; it shows dry-run non-mutation, capped apply removal, and retention of protected rows.

Evidence

What I checked:

  • Protocol-v1 reconciliation implementation: The PR adds a legacy-reconciliation mode to terminal candidate handling, reclaims expired leases for eligible terminal candidates, builds a per-target authority index, and returns completed keys so only protected, terminal legacy rows proceed to removal. (dashboard/exact-review-queue.ts:3492, 00cecde3858c)
  • Focused durable-queue coverage: The added queue tests cover terminal legacy removal, dry-run retention, command-context retention, active-batch protection, expired-lease handling, and newer-authority protection. (test/dashboard-worker.test.ts:5543, 00cecde3858c)
  • Maintenance-client contract coverage: The repair client now validates and exposes the legacy terminal reconciliation counters returned by the queue endpoint. (test/repair/exact-review-batch-coordinator.test.ts:211, 00cecde3858c)
  • Transition provenance: The related direct-publication transition merged as commit 4288d55 and explicitly retained the legacy queue as a bounded fallback; this PR addresses a legacy protocol-v1 fallback row outside that newer direct path. (dashboard/exact-review-queue.ts:3492, 4288d557fff1)
  • After-fix runtime proof: The PR body records a Docker-backed Crabbox run against the actual ExactReviewQueue with an isolated Durable Object and live GitHub target read: dry run selected one terminal legacy row without deleting it, capped apply removed it, and command-context and active-batch rows remained retained. (00cecde3858c)

Likely related people:

  • steipete: Authored the merged direct-Cloudflare-publication transition that retained the legacy queue fallback this repair reconciles. (role: introduced adjacent publication transition; confidence: medium; commits: 4288d557fff1; files: dashboard/exact-review-queue.ts)

Rank-up moves

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

  • During first production use, capture a redacted live dry-run result before the documented capped apply pass.

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.

History

Review history (2 earlier review cycles)
  • reviewed 2026-07-27T12:26:16.385Z sha 00cecde :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-27T12:31:46.823Z sha 00cecde :: needs real behavior proof before merge. :: none

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Jul 27, 2026
@brokemac79

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@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. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jul 27, 2026
@brokemac79
brokemac79 merged commit 2345e9f into main Jul 27, 2026
34 checks passed
@brokemac79
brokemac79 deleted the codex/csw-065-command-context-reconciliation branch July 27, 2026 13:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. P2 Normal priority bug or improvement with limited blast radius. 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