Skip to content

fix(publication): prevent aged owner starvation - #1225

Merged
vincentkoc merged 3 commits into
mainfrom
fix/publication-starvation
Aug 22, 2026
Merged

vincentkoc merged 3 commits into
mainfrom
fix/publication-starvation

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Aug 22, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

Fixes an issue where an owner with aged publication work could remain queued while another owner's fresh or full batch kept winning departure selection. The alarm could also be scheduled from the selected fresh owner instead of the globally oldest eligible item, delaying the aged owner's next dispatch opportunity.

Why This Change Was Made

Departure and claim now share one owner-selection rule: the globally oldest aged owner's owner wins before cross-owner fresh/full optimization, while batches remain owner-homogeneous and existing within-owner ordering is preserved. The global oldest eligible timestamp remains the alarm boundary even while a different fresh owner is temporarily selected.

Both paths also use the same superseded-revision exclusion. An expired batch can no longer leave an aged stale revision eligible for departure while claim rejects it, which previously allowed that stale owner to trigger an early dispatch of another owner's fresh work.

This does not change capacity, configuration, telemetry, read models, publication payloads, or queue storage.

User Impact

Operators can expect aged publication work to receive a bounded dispatch opportunity instead of being indefinitely displaced by continuously arriving fresh work from another owner.

OpenClaw Bay Impact

OpenClaw Bay is unaffected. This changes internal publication batch owner selection and alarm timing only; Bay's observer-only projection, status fields, data contracts, and navigation remain unchanged.

Documentation Impact

Reviewed AGENTS.md and CONTRIBUTING.md. No documentation update is required because this repair does not add or change a public API, configuration option, workflow input, status field, or operator procedure.

Evidence

  • node --test --test-name-pattern='aged superseded publication|oldest publication aging deadline|fresh publication owner still wins' test/exact-review-publication-batches.test.ts — 3/3 passed; covers the superseded lifecycle regression plus both owner-ordering contracts.
  • node --test --test-name-pattern='exact-review batch preflight follows the publisher owner selection' test/dashboard-worker-queue-runtime.test.ts — 1/1 passed; preflight inspected beta items 9222/9223, dispatched one full beta batch, and left alpha queued.
  • node --test test/exact-review-publication-batches.test.ts — 69/69 passed.
  • Dashboard TypeScript build passed: ./node_modules/.bin/tsc -p tsconfig.dashboard.json --pretty false.
  • Dashboard queue-boundary and strict checks passed.
  • Targeted dashboard/test lint passed.
  • Targeted formatting and git diff --check passed.
  • Current branch delta: production +96/-46; tests +271/-10. The exact-head follow-up is production +24/-16 and tests +103/-0.

Real Behavior Proof

Claim: A real local Durable Object alarm preserves the globally oldest publication's aging deadline after an earlier wake, then departure preflight and the signed workflow claim agree on that aged owner despite a fresh competing owner.

Runtime surface: Exact head e709b11798d4136077dc1101f6a12844fc47e5db under [email protected] dev --local, using the repository's Worker entry point, persisted SQLite-backed ExactReviewQueue, automatic Durable Object alarms, signed internal enqueue/claim routes, GitHub App authentication, terminal preflight, and workflow dispatch code. The harness follows the existing docs/proof/alarm-hydration-dedup/run-proof.mjs Worker/alarm pattern and docs/proof/csw-127-phase0-6/run-proof.mjs signed claim pattern.

Command and environment:

node .artifacts/pr-1225-publication-runtime-proof/run-proof.mjs

Node 26.5.0; Wrangler 4.107.0 local runtime; disposable local Durable Object persistence; generated synthetic RSA/HMAC credentials; loopback-only GitHub API/workflow receiver.

Controlled scenario:

  • Enqueued aged owner aged/proof#140.
  • Waited 61 seconds, then enqueued fresh owner fresh/proof#141.
  • Enqueued review/proof#300 to force an earlier real alarm/wake.
  • Configured publication batch wait to 65 seconds and fresh max age to 60 seconds.
  • Captured the real batch workflow dispatch, then called /internal/exact-review/publication-batches/claim through the Worker with a valid synthetic signature and the captured dispatch identity.

Observable result:

old enqueue:               2026-08-22T09:03:33.965Z
early alarm/wake:          2026-08-22T09:04:36.416Z
old owner aging deadline:  2026-08-22T09:04:38.965Z
batch dispatch:            2026-08-22T09:04:39.130Z
dispatch from old enqueue: 65,165 ms
dispatch from fresh enqueue: 4,161 ms
time before fresh deadline: 60,839 ms
terminal preflight:        aged/proof#140
signed claim item:         aged/proof#140@publish:1040:1

The earlier review wake occurred 2,549 ms before the old owner's boundary. The subsequent real alarm dispatched 165 ms after that boundary, not at the fresh owner's later deadline. The loopback terminal preflight touched only the aged owner, the signed claim returned only the aged owner, and the persisted SQLite receipt contained one leased batch owned by pr-1225-runtime-worker with that exact member.

Artifacts: .artifacts/pr-1225-publication-runtime-proof/runtime-summary.json (local ignored evidence), SHA-256 4d2cf94447e8127c48479c52f2aaa543789274f6521a825abe63858cadcf9aa4; reproducible harness run-proof.mjs, SHA-256 62e2c754f05a68bb27dc738c04766d4e3b18266d517880606ac976be0ef78c2a. Supporting request trace and redacted Wrangler log are stored beside them.

Limits: GitHub App/API and workflow dispatch were terminated at a loopback receiver. No production Worker, GitHub repository, workflow, queue, secret, deployment, or live ClawSweeper state was contacted or mutated.

@clawsweeper

clawsweeper Bot commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@clawsweeper clawsweeper Bot added P2 Normal priority bug or improvement with limited blast radius. 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 Aug 22, 2026
@clawsweeper

clawsweeper Bot commented Aug 22, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 22, 2026, 5:09 AM ET / 09:09 UTC.

ClawSweeper review

What this changes

This PR makes publication-batch departure and claim select the same oldest eligible aged owner before fresh or full batches, while excluding superseded revisions consistently.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep open for maintainer review: the member-authored PR resolves the prior superseded-revision finding and source review found the alarm, preflight, and claim paths using the same eligibility and owner-selection rule.

Priority: P2
Reviewed head: e709b11798d4136077dc1101f6a12844fc47e5db
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Strong targeted runtime evidence and focused regressions support a correct patch, subject to normal maintainer approval of the scheduling policy.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The PR body provides an after-fix local Durable Object alarm, preflight, dispatch, and signed-claim trace for the exact head.
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 an after-fix local Durable Object alarm, preflight, dispatch, and signed-claim trace for the exact head.
Evidence reviewed 3 items Shared selection and revision eligibility: Departure excludes superseded pending publications and uses the shared selector; the claim candidate path applies the same superseded exclusion and selector before creating a lease.
Prior finding addressed: The new regression covers an aged superseded publication and verifies it cannot trigger early dispatch of a fresh owner; the aging-deadline test then verifies preflight and signed claim select the aged owner.
Feature-history routing: Recent history on the queue surface includes Martin Cleary’s merged queue/dashboard maintenance and the current PR’s follow-up commit from Vincent Koc.
Findings None None.
Security None None.

Live Verification

Command: node --test --test-name-pattern='aged superseded publication|oldest publication aging deadline|fresh publication owner still wins' test/exact-review-publication-batches.test.ts

Result: PASS (completed)

node --test --test-name-pattern='aged superseded publication|oldest publication aging deadline|fresh publication owner still wins' test/exact-review-publication
-batches.test.ts
runner@runnervm76f27:/tmp/clawsweeper-live-proof-1225-XDs1oC/target$ node --test --test-name-pattern='aged superseded publication|oldest publication aging deadl
ine|fresh publication owner still wins' test/exact-review-publication-batches.test.ts
✔ aged superseded publication does not dispatch a fresh owner before its deadline (156.089498ms)
✔ oldest publication aging deadline drives the alarm and then its owner claim (53.973577ms)
✔ fresh publication owner still wins when no owner's work has aged (14.584565ms)
ℹ tests 3
ℹ suites 0
ℹ pass 3
ℹ fail 0
ℹ cancelled 0
ℹ skipped 0
ℹ todo 0
ℹ duration_ms 450.292582
runner@runnervm76f27:/tmp/clawsweeper-live-proof-1225-XDs1oC/target$ node --test --test-name-pattern='aged superseded publication|oldest publication aging deadl
ine|fresh publication owner still wins' test/exact-review-publication-batches.test.ts
✔ aged superseded publication does not dispatch a fresh owner before its deadline (72.075358ms)
✔ oldest publication aging deadline drives the alarm and then its owner claim (83.491744ms)
✔ fresh publication owner still wins when no owner's work has aged (14.241979ms)
ℹ tests 3
ℹ suites 0
ℹ pass 3
ℹ fail 0
ℹ cancelled 0
ℹ skipped 0
ℹ todo 0
ℹ duration_ms 389.915707
runner@runnervm76f27:/tmp/clawsweeper-live-proof-1225-XDs1oC/target$






















Assertions:

  • PASS expect_output: pass

How this fits together

The exact-review queue groups publication work into owner-homogeneous batches. Durable Object alarms choose a batch for workflow dispatch, and the signed claim endpoint leases that same owner’s eligible work.

flowchart LR
  A[Queued publication work] --> B[Eligibility filtering]
  B --> C[Shared owner selection]
  C --> D[Durable Object alarm]
  D --> E[Workflow dispatch and preflight]
  E --> F[Signed claim and batch lease]
Loading

Decision needed

Question Recommendation
Should this member-authored publication scheduling repair be approved once the current required check completes on this exact head? Approve after current verification: Land the focused queue repair after the current-head required check completes successfully.

Why: Member-authored items are non-closeable and require explicit maintainer judgment even when the patch is technically sound.

Before merge

  • Resolve merge risk (P1) - This changes the alarm-to-workflow publication path; a future divergence between departure and claim selection could dispatch a batch for an unintended owner, although the current shared selector and probe path are aligned.
  • Complete next step (P2) - This member-authored PR is non-closeable and needs explicit maintainer approval after current-head verification, not an automated repair lane.
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Patch scope 3 files; production +96/-46, tests +271/-10 The implementation is concentrated in publication queue selection and adds focused regression coverage.

Merge-risk options

Maintainer options:

  1. Land with the current invariant coverage (recommended)
    Accept the bounded workflow-dispatch risk after the current required check verifies the exact head and the shared selection regressions remain green.
  2. Pause for scheduling-policy review
    Hold the change if maintainers want a different fairness policy between aged, fresh, and full owner batches.

Technical review

Best possible solution:

Retain one shared eligibility and owner-selection contract for alarm departure, terminal preflight, and signed claim, with the focused aged-owner and superseded-revision regressions guarding it.

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

Yes—the focused aged-versus-fresh and superseded-revision scenarios are clear in current source and the supplied local Durable Object proof, though this read-only review did not rerun them.

Is this the best way to solve the issue?

Yes—the shared selector plus identical superseded-revision exclusion is the narrowest maintainable way to prevent departure and claim from disagreeing.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 9a09faa3da3b.

Labels

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster 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 an after-fix local Durable Object alarm, preflight, dispatch, and signed-claim trace for the exact head.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.

Label justifications:

  • P2: This is a bounded reliability repair for publication workflow scheduling with limited blast radius.
  • merge-risk: 🚨 automation: The patch changes Durable Object alarm dispatch, preflight, and signed workflow-claim behavior.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster 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 an after-fix local Durable Object alarm, preflight, dispatch, and signed-claim trace for the exact head.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides an after-fix local Durable Object alarm, preflight, dispatch, and signed-claim trace for the exact head.

Evidence

What I checked:

  • Shared selection and revision eligibility: Departure excludes superseded pending publications and uses the shared selector; the claim candidate path applies the same superseded exclusion and selector before creating a lease. (dashboard/exact-review-queue.ts:5934, e709b11798d4)
  • Prior finding addressed: The new regression covers an aged superseded publication and verifies it cannot trigger early dispatch of a fresh owner; the aging-deadline test then verifies preflight and signed claim select the aged owner. (test/exact-review-publication-batches.test.ts:2832, e709b11798d4)
  • Feature-history routing: Recent history on the queue surface includes Martin Cleary’s merged queue/dashboard maintenance and the current PR’s follow-up commit from Vincent Koc. (dashboard/exact-review-queue.ts:12966, b853345fa6e3)

Likely related people:

  • Martin Cleary: Recent merged history shows repeated maintenance of the exact-review queue and dashboard surface. (role: recent area contributor; confidence: medium; commits: b853345fa6e3, 68a6dfcfc556, 43799a11fc26; files: dashboard/exact-review-queue.ts, dashboard/exact-review-read-model.ts)

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 (3 earlier review cycles)
  • reviewed 2026-08-22T08:08:33.304Z sha 66af7eb :: needs maintainer review before merge. :: none
  • reviewed 2026-08-22T08:24:26.875Z sha 2760c12 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-22T08:33:25.729Z sha 2760c12 :: found issues before merge. :: [P2] Exclude superseded publications before selecting departure

@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 22, 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 exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@vincentkoc
vincentkoc marked this pull request as ready for review August 22, 2026 08:30
@clawsweeper clawsweeper Bot added merge-risk: 🚨 automation 🚨 Merging this PR could break CI, automerge, proof capture, label sync, or automation. proof: sufficient Contributor real behavior proof is sufficient. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed 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 Aug 22, 2026
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 22, 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 exact_review_queue).
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: 🐚 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 status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Aug 22, 2026
@vincentkoc
vincentkoc merged commit 648ad35 into main Aug 22, 2026
19 checks passed
@vincentkoc
vincentkoc deleted the fix/publication-starvation branch August 22, 2026 18:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 automation 🚨 Merging this PR could break CI, automerge, proof capture, label sync, or automation. 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