Skip to content

fix: keep gateway running when native completions hit database contention - #158286

Merged
fuller-stack-dev merged 19 commits into
openclaw:mainfrom
fuller-stack-dev:fix/codex-completion-contention-20260925
Sep 26, 2026
Merged

fuller-stack-dev merged 19 commits into
openclaw:mainfrom
fuller-stack-dev:fix/codex-completion-contention-20260925

Conversation

@fuller-stack-dev

@fuller-stack-dev fuller-stack-dev commented Sep 25, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

Fixes a gateway exit when a Codex native subagent completion encounters task-database contention.

User Impact

Completion persistence waits without blocking the gateway event loop. Temporary failures retain the result for recovery, and an accepted delivery is not sent again when its acknowledgement fails.

Why This Change Was Made

The error handler queried the same unavailable store again, allowing its recovery attempt to reject detached work. Completion attempts now retain ownership through persistence and retries, including acknowledgement after retry exhaustion. Callers without an explicit assignment receipt retain the first usable assignment before waiting for read preparation. Cold state takes one asynchronous snapshot, and genuinely absent state remains a supported empty discovery result. Current assignment checks still run before delivery. Metadata changes and unrelated activity do not block completion. Changes that precede a cold caller's first observation require an explicit producer receipt to distinguish; legacy callers remain best effort. Default task reads and exact-assignment writes use existing database workers. Late receipts and retired owners are rechecked after awaited writes. If an assignment is replaced during persistence, its old completion attempt releases custody promptly. Temporary failures on an unchanged assignment still retry; asynchronous lifecycle transitions preserve the existing assignment-receipt rules.

Evidence

Final published head: e5ab1ae8361215e708b91fe0775375d00b8ed143, incorporating canonical main 8681a848844a05afd0f944c1ad1900332d5d80bc. The final tree matches the independently reviewed correction and preserves shared history.

Final source-blind report, raw observations, executable fixture and SHA-256 manifest.

Manifest, raw baseline failure, original reproduction recovery, final runtime results and executable fixture.

  • The unmodified base reproduced the contention exception escaping the completion error handler. The same fixture passed after the fix.
  • Original proof covered 234 focused cases and five source-blind scenarios. The original baseline failure and exact commands remain in the linked evidence.
  • The final correction passed 380 tests across ten database-worker files in 87.48s. The Codex group produced 404 individual passes before a new fixture gate stalled; this is not claimed as an aggregate pass. After correcting the fixture, all three new timer/read/foreground controls passed together in 38.80s, with test bodies of 28ms, 11ms and 7ms. Earlier passing cases remain applicable because the subsequent changes only corrected those new fixtures and their cleanup.
  • Fresh source-blind validation passed all five contract clauses against real private SQLite stores. Pending results, coordinator release, repeated completion-owner requests, receipt retention, owner replacement/retirement and exhaustion settlement were observed. Two scenarios were rerun after the proof command exposed missing temporal observations. All seven fixture roots were removed. This exercises the native completion owner with a synthetic sink; it does not claim live Codex transport, model or channel delivery.
  • CI 36179560182 exposed five lint warnings and seven early custody snapshots. The exact 11-file shard reproduced 7 failures/100 passes, then passed 107/107 after joining actual persistence. CI 36182639767 found that submission recovery lacked the existing database-worker runner classification. Its unchanged assertions passed 5/5 with the correct process-based runner; the original 397 sibling cases also passed.
  • The broader lifecycle run exposed a rejected rotated receipt triggering an extra delivery attempt. A focused boundary reproduction proved one call before the receipt and two after it, before the normal timer expired. Receipt validation now preserves retry scheduling until acceptance, and an ordinary retry arriving during validation still proceeds. Accepted and rejected observer controls pass.
  • CI 36186804633 found five core custody failures. Joining actual asynchronous work exposed one product defect: replacement during finalization retained the old gateway root for retry. Exact assignment revalidation now releases it immediately, while unchanged assignments retain best-effort retries. The corrected core fixture passes all 20 cases in 43.19s; the monitor passes 101/101 in 76.48s and contention passes 10/10 in 65.13s, including transform/setup time. All scenarios and meaningful assertions remain.
  • Additional source-blind checks pass all five clauses for the final custody correction. Both replacement boundaries release before the first attempt returns and preserve the full successor record. Temporary finalization and status failures recover, and a read failure after accepted delivery retains the receipt without another send. All eight private fixtures were removed. The published manifest binds these observations to the final head.
  • CI 36190951954 passed the product and custody checks but found two lint suppressions in the new test helper. The helper now observes default call-through spy results, preserving real receivers, arguments and promises without suppressions. No allowlist changed. The final core fixture passes 20/20 in 86.40s; the static suppression guard passes 4/4 in 7.97s after incorporating current main.
  • CI 36192761266 found an upstream fixture incompatibility: compile-cache initialization now reads thread metadata, but the cleanup fixture replaced the entire module with only Worker. Preserving actual module exports while retaining the forbidden Worker sentinel fixes the unchanged lifecycle test. Local red reproduces in 16.84s; green passes in 9.57s, with all seven nested cases checked. Independent fixture review is clean through P2, confidence 0.98. On the final head, the same hosted group passes all 24 files and 997 tests with three existing skips in 226.15s; the lifecycle test takes 3.198s.
  • CI 36194424340 exposed a race in a session-read fixture. Its background catalog gate did not establish that the request had captured authority before role revocation. The original 570-case group passed locally, which did not resolve the flake. A real readiness observer reproduced the exact CI rejection in 32.88s. The fixture now requires in-flight cancellation and verifies that a fresh blocked-role request returns an empty list. All six existing cases pass after incorporating main, 99.44s including preparation. Independent review is clean through P2, confidence 0.98; production permissions are unchanged.
  • The final SDK correction addresses the receipt-free assignment race reported by ClawSweeper. On unchanged production, a real same-run replacement during the held read preparation incorrectly delivered the old completion, while the unchanged control passed: 1 failed / 1 passed, 42.84s. The corrected two complete SDK test files pass 44/44 in 77.98s. Ten new cases cover unchanged, replacement, removal, insertion, metadata, unrelated activity, cold state, known-empty state, cold-empty state and explicit receipts. Independent review is clean through P2, zero findings, confidence 0.94.
  • Source-blind SDK proof passes seven contract clauses across eight real private-SQLite invocations through the public completion API and actual announcement dispatcher. Unchanged, metadata, unrelated, cold and empty calls deliver their exact varied payload once. Replacement, insertion and explicit-receipt replacement produce zero final transport calls and preserve successors. There is no transport call while the read fence is held. All eight private roots and database/coordinator paths were independently confirmed removed. Only the final transport is synthetic; this does not claim live model or channel delivery. Contract, raw observations and executable fixture.
  • CI 36197382595 reported two failures in its 41-file gateway group: an empty authenticated task page and sessions.create returning false without the RPC reason. The group had passed 162/162 on the preceding run. The one same-group, two-worker local replay on 481ecd09 finished with 160 passed, one failed and one platform skip in 1029.55s. Both original failures passed, in 10.569s and 13.087s. A different WebChat startup-recovery fixture failed at line 214 because only one of two started turns had reached its followup queue before cancellation/recovery release. The existing IPv4-alias case skipped because 127.0.0.2 is unavailable on this Mac. The replay used macOS/Node 24.20.0, while CI used Linux/Node 24.19.0. No root cause or repair is established, and the original cases passing locally is not claimed as a fix. No retries, assertion changes or timeout increases were made. These RPC paths do not call the new SDK resident-capture helpers. The final candidate has a new substantive SDK correction and awaits its own hosted CI.
  • The cold SDK follow-up reproduces the same replacement race with an initially unloaded registry. On unchanged production, a real same-run replacement during the held read fence delivered the old payload. The automated red failed replacement, removal and insertion while four allowed cold controls passed. Final SDK files pass 49/49 in 116.06s; native snapshot checks pass 4/4 in 24.48s plus worker preparation. An opt-in empty discovery result for a missing database preserves fresh starts while strict persistence reads and retired-admission errors remain unchanged. The final design uses a detached worker snapshot and the existing effect checks, with no observer, global revision veto, mandatory receipt or manual rewind.
  • Final cold-path review is clean through P2 with zero findings, confidence 0.93. Source-blind observations cover all seven cold scenarios, including a never-created database and exact varied payloads at the final transport. Five initial invocations completed; metadata and unrelated activity initially reached the validator's 120-second process limit. Added phase observations showed a metadata completion in 38 seconds, and the serial unrelated diagnostic completed in 62.347 seconds under the same limit. All final successful fixtures are absent; the two interrupted synthetic fixtures were identified and removed after holder checks. The original timeouts remain documented, and passing diagnostics are not claimed as a timeout fix. Cold contract, report and raw observations.
  • The product correction and final fixture correction each have fresh independent review, clean through P2 with zero findings. Prior published head bc55bb passed CI36199624948; final corrected-head hosted CI is pending. Scoped type-aware lint, formatting and diff checks pass.

Validation limitations: pnpm build and the repository type-check wrapper reject this host's required canonical pnpm shared-store compiler links before compiling the candidate. Direct pinned TypeScript checks reach an existing ResponsesWSClientOptions/headers error in packages/ai/src/transports/openai-responses-websocket.ts. That path and its dependencies are unchanged. Live gateway deployment has not been performed.

Test audit and scope

Audited the entire contents of these files, including fixtures, helpers, imports, assertions and cleanup:

  • extensions/codex/src/app-server/native-subagent-completion-delivery.contention.test.ts
  • extensions/codex/src/app-server/native-subagent-monitor.test.ts
  • extensions/codex/src/app-server/native-subagent-monitor.completion-delivery.test.ts
  • extensions/codex/src/app-server/native-subagent-monitor.custody.test.ts
  • extensions/codex/src/app-server/native-subagent-monitor.history-owner.test.ts
  • extensions/codex/src/app-server/run-attempt.native-followup-custody.test.ts
  • extensions/codex/src/app-server/native-subagent-monitor.close.test.ts
  • extensions/codex/src/app-server/native-subagent-monitor.rotated-parent.test.ts
  • extensions/codex/src/app-server/native-subagent-monitor.submission-recovery.test.ts
  • src/plugin-sdk/agent-harness-task-runtime.test.ts
  • src/plugin-sdk/agent-harness-task-runtime.selection.test.ts
  • src/plugin-sdk/agent-harness-task-runtime.worker.test.ts
  • src/tasks/task-registry-snapshot-read.test.ts
  • src/agents/agent-harness-native-custody.test.ts
  • Shared support: extensions/codex/src/app-server/native-subagent-monitor.test-support.ts
  • test/non-isolated-runner.sqlite-fixtures.ts, plus its unchanged outer test and shutdown helper
  • src/gateway/server-plugin-in-process-dispatch.session-reads.test.ts

Kept distinct ownership, history, receipt and failure cases. Removed one mocked selector case duplicated by real-registry coverage and three repeated assertions with no intervening work. Replaced a clone-call-count assertion with single-owner delivery and ambiguous-owner rejection. Existing asynchronous tests now await actual persistence attempts; exhaustion checks prove custody remains retained until failed-status settlement and no extra delivery occurs. The new retry regression uses fake timers. The added custody-file audit retains all seven distinct scenarios and every assertion, including child completion after parent host closure. Three scheduler-turn guesses now await turn acceptance or actual completion; the fourth was unnecessary after acknowledged sessions_yield. Teardown aborts and joins owned work before closing the fixture. Prototype-method observations still call the real method with its original receiver. The final shared helper uses default call-through spies and joins their actual returned promises, removing its two unbound-method suppressions. The additional three files retain all close, rotated-parent and cold-recovery scenarios. Removed two more immediately repeated assertions without intervening work. New receipt-race cases cover a normal retry during validation, a transient read failure with an existing retry, and foreground receipt recovery followed by detachment. Their fixtures use consistent private requester/turn identities and explicitly retire their own pending delivery authority before disposal. A sequential fixture leak was confirmed by the failing case passing alone, then repaired without changing assertions. The core custody audit retains all 20 cases, covering nine assignment orderings, six history outcomes, two handoff modes and three stale producers. It removes one duplicate promise wait and an early repeated call count while retaining the final exact-once assertion. Teardown joins actual delivery and recovery work and restores the runtime. All 23 support exports have consumers. The SQLite fixture repair preserves every scenario and assertion; its complete generator, outer test and shutdown helper audit found no safe pruning needed. The session-read audit retains all six grant, zero-SQL, merged-profile and revocation cases. It replaces the race-dependent in-flight empty-list expectation with explicit cancellation and preserves the empty-list assertion for a fresh blocked-role request. Real handler execution is joined before projection disposal, and cleanup restores the observer even on errors. The final SDK audit covers both entire touched files and the native snapshot-reader file, retaining all original cases. Its fifteen additional SDK cases exercise distinct assignment transitions through real registry state and the actual announcement dispatcher; the five cold variants protect a distinct initialization path and the snapshot checks preserve strict missing-state and retirement coverage. No further pruning was warranted. New case bodies take 4–12ms after the initial 310ms fixture setup. No valid failing cases were skipped, assertions weakened or timeouts increased.

The incident logs identify the escaping contention error and automatic process restart. They do not identify the final historical lock holder. A suspected circular worker-admission deadlock was independently falsified; this patch changes neither coordinator pumping nor global rejection handling.

@clawsweeper

clawsweeper Bot commented Sep 25, 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.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation extensions: codex plugin: file-transfer size: XL labels Sep 25, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. 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 Sep 25, 2026
@clawsweeper

clawsweeper Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed September 25, 2026, 7:50 PM ET / 23:50 UTC (Revision 7).

ClawSweeper review

What this changes

The branch moves Codex native subagent completion reads and persistence through database workers, retains completion custody through retries, and updates Plugin SDK guidance and regression coverage.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

⛔ Blocked before merge - 6 items remain

The earlier replacement-during-read finding is addressed, and the linked SQLite observations support the contention repair. A receipt-free completion from a cold registry can still adopt a replacement task before its first worker snapshot, so the public SDK authority rule needs resolution before merge.

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

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The contention repair has substantial focused evidence, but one public cold-call authority window remains unresolved.
Proof confidence 🦐 gold shrimp (3/6) Needs stronger real behavior proof before merge: Authority-chain proof required: linked private-SQLite runs exercise the public completion API and announcement dispatcher and show allowed cold calls delivering once and post-snapshot replacements producing zero synthetic final transport calls. They do not cover a receipt-free replacement before the first worker snapshot. A redacted terminal trace of that final-effect case is needed after the authority rule is resolved; redact keys, IP addresses, phone numbers, and private endpoints. No stored schema or serialized-data contract changes were found. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🦐 gold shrimp (3/6) Security review found an item that needs attention.

Verification

Check Result Evidence
Real behavior Needs proof Needs stronger real behavior proof before merge: Authority-chain proof required: linked private-SQLite runs exercise the public completion API and announcement dispatcher and show allowed cold calls delivering once and post-snapshot replacements producing zero synthetic final transport calls. They do not cover a receipt-free replacement before the first worker snapshot. A redacted terminal trace of that final-effect case is needed after the authority rule is resolved; redact keys, IP addresses, phone numbers, and private endpoints. No stored schema or serialized-data contract changes were found. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 12 items Current main still captures receipt-free ownership synchronously: The current-main completion API calls listTaskRecords and captures the task before its first await; the central worker-backed contention change is still unique to this open PR.
Introduced cold selection window: Without an explicit expectedTask, delivery awaits captureTaskRegistryRunSelection before deriving a receipt. The cold implementation awaits a worker snapshot, so a same-run successor committed before that first snapshot can become the selected task.
First cold observation is asynchronous: The worker-backed mutation snapshot is awaited before the returned records are filtered. The source expressly defines that first SQL observation as the legacy selection point.
Findings 1 actionable finding [P1] Bind cold completion to its producer before the first worker read
Security Needs attention Cold task selection can rebind completion authority: The first asynchronous snapshot can select a newer assignment for an old result when no producer receipt was supplied. The supplied final-effect observations cover replacement after that snapshot, so they do not settle this authority window.

How this fits together

Codex app-server sends child completion events to OpenClaw's bundled Codex plugin. The plugin checks and persists the associated task in SQLite, then asks the Plugin SDK to announce the result to the parent session.

flowchart LR
 A[Codex child completion] --> B[Native completion monitor]
 B --> C[SQLite task worker]
 C --> D{Original assignment current?}
 D -- Yes --> E[Persist delivery status]
 E --> F[Parent announcement]
 D -- No --> G[Reject stale completion]
Loading

Decision needed

Question Recommendation
May a receipt-free completion from a cold registry treat its first worker snapshot as authority when the run was reassigned before that snapshot? Require producer identity: Keep persisted completion delivery bound to its original assignment and provide a compatible deprecation or migration path for receipt-free SDK callers.

Why: The branch knowingly preserves a best-effort legacy route, while requiring a receipt could affect existing public SDK callers; contributor discussion does not settle the authority and compatibility tradeoff.

Before merge

  • Add real behavior proof - Needs stronger real behavior proof before merge: Authority-chain proof required: linked private-SQLite runs exercise the public completion API and announcement dispatcher and show allowed cold calls delivering once and post-snapshot replacements producing zero synthetic final transport calls. They do not cover a receipt-free replacement before the first worker snapshot. A redacted terminal trace of that final-effect case is needed after the authority rule is resolved; redact keys, IP addresses, phone numbers, and private endpoints. No stored schema or serialized-data contract changes were found. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Bind cold completion to its producer before the first worker read (P1) - For a receipt-free call with a cold registry, this await can select a same-run successor committed before the first SQL snapshot. If that successor is terminal with delivery pending, the earlier result borrows its receipt, passes the later current-task check, and reaches the announcement effect. Current main captures the task synchronously at invocation; the new cold tests replace it only after the first snapshot. Preserve the original producer identity or block final I/O for unbound cold calls.
  • Resolve security concern: Cold task selection can rebind completion authority - The first asynchronous snapshot can select a newer assignment for an old result when no producer receipt was supplied. The supplied final-effect observations cover replacement after that snapshot, so they do not settle this authority window.
  • Resolve merge risk (P1) - Making the original assignment receipt mandatory for cold persisted completions would change today's optional public Plugin SDK contract; a compatible transition or an explicit acceptance of legacy behavior is needed.
  • Complete next step (P2) - Resolve the cold receipt-free authority gap with the SDK owner and add a redacted final-effect trace for an allowed cold call and reassignment before its first worker snapshot. Update the PR body to trigger re-review; if it does not, ask a maintainer to comment @clawsweeper re-review.
  • Resolve maintainer decision - Resolve the maintainer decision shown above before merge.

Findings

  • [P1] Bind cold completion to its producer before the first worker read — src/plugin-sdk/agent-harness-task-runtime.ts:440-443
  • [medium] Cold task selection can rebind completion authority — src/plugin-sdk/agent-harness-task-runtime.ts:442
Agent review details

Security

Needs attention: A cold receipt-free completion can derive task authority from a successor before final announcement; no dependency, credential, or supply-chain changes were found.

PR surface

Source +368, Tests +1128, Docs +14. Total +1510 across 28 files.

View PR surface stats
Area Files Added Removed Net
Source 8 516 148 +368
Tests 19 1694 566 +1128
Docs 1 14 0 +14
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 28 2224 714 +1510

Review metrics

Metric Value Why it matters
Code growth by layer production +413 net, tests +1083 net, docs +14 net The PR explains the worker custody and regression coverage growth, while the cold-call authority rule remains unsettled.

Merge-risk options

Maintainer options:

  1. Bind cold completion to its producer (recommended)
    Preserve the original assignment through cold preparation, define an upgrade path for legacy SDK callers, and prove a pre-snapshot replacement makes no final transport call.
  2. Own the legacy window
    A maintainer could explicitly accept the receipt-free reassignment window and document the resulting stale-delivery behavior.

Technical review

Best possible solution:

Bind persisted completion results to a producer-held assignment receipt, retain a documented compatibility path for existing SDK callers, and reject stale assignments at the final announcement effect.

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

Yes. The linked baseline trace shows the SQLite contention exception escaping the old completion claim path, which remains in current main; this reviewer did not execute the fixture.

Is this the best way to solve the issue?

No. Worker-backed persistence addresses the blocking read, but the receipt-free cold path still needs producer-bound authority or an explicit, documented compatibility decision.

Full review comments:

  • [P1] Bind cold completion to its producer before the first worker read — src/plugin-sdk/agent-harness-task-runtime.ts:440-443
    For a receipt-free call with a cold registry, this await can select a same-run successor committed before the first SQL snapshot. If that successor is terminal with delivery pending, the earlier result borrows its receipt, passes the later current-task check, and reaches the announcement effect. Current main captures the task synchronously at invocation; the new cold tests replace it only after the first snapshot. Preserve the original producer identity or block final I/O for unbound cold calls.
    Confidence: 0.86

Overall correctness: patch is incorrect
Overall confidence: 0.87

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 52c7502c8613.

Labels

Label changes:

No label changes.

Label justifications:

  • P1: Database contention can interrupt native completion delivery and exit the Gateway during an active agent workflow.
  • merge-risk: 🚨 compatibility: The public completion API still permits receipt-free calls, and safely closing the cold window may change those callers' behavior.
  • merge-risk: 🚨 message-delivery: A stale result can reach a newer assignment if the first cold worker snapshot observes its replacement.
  • merge-risk: 🚨 security-boundary: The cold receipt-free path can derive announcement authority from a successor task rather than the task that produced the result.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: Authority-chain proof required: linked private-SQLite runs exercise the public completion API and announcement dispatcher and show allowed cold calls delivering once and post-snapshot replacements producing zero synthetic final transport calls. They do not cover a receipt-free replacement before the first worker snapshot. A redacted terminal trace of that final-effect case is needed after the authority rule is resolved; redact keys, IP addresses, phone numbers, and private endpoints. No stored schema or serialized-data contract changes were found. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

Security concerns:

  • [medium] Cold task selection can rebind completion authority — src/plugin-sdk/agent-harness-task-runtime.ts:442
    The first asynchronous snapshot can select a newer assignment for an old result when no producer receipt was supplied. The supplied final-effect observations cover replacement after that snapshot, so they do not settle this authority window.
    Confidence: 0.84

What I checked:

  • Current main still captures receipt-free ownership synchronously: The current-main completion API calls listTaskRecords and captures the task before its first await; the central worker-backed contention change is still unique to this open PR. (src/plugin-sdk/agent-harness-task-runtime.ts:376, 52c7502c8613)
  • Introduced cold selection window: Without an explicit expectedTask, delivery awaits captureTaskRegistryRunSelection before deriving a receipt. The cold implementation awaits a worker snapshot, so a same-run successor committed before that first snapshot can become the selected task. (src/plugin-sdk/agent-harness-task-runtime.ts:440, e5ab1ae83612)
  • First cold observation is asynchronous: The worker-backed mutation snapshot is awaited before the returned records are filtered. The source expressly defines that first SQL observation as the legacy selection point. (src/tasks/task-registry-read.ts:171, e5ab1ae83612)
  • Final announcement uses the selected receipt: The selected task supplies taskReceipt; a successor with the same requester, run ID, terminal status, and pending delivery can pass isTaskCurrent and reach the announcement dispatcher with the earlier result. (src/plugin-sdk/agent-harness-task-runtime.ts:458, e5ab1ae83612)
  • New tests change assignments after initial selection: The selection test holds prepareTaskRegistryRead only after captureTaskRegistryRunSelection has completed; its replacement cases therefore do not cover reassignment before the first worker snapshot. (src/plugin-sdk/agent-harness-task-runtime.selection.test.ts:115, e5ab1ae83612)
  • Public SDK compatibility surface: expectedTask remains optional on the exported completion API. The SDK guide tells detached native callers to carry the original receipt through delivery, while the PR body explicitly retains receipt-free legacy calls as best effort. (src/plugin-sdk/agent-harness-task-runtime.ts:409, e5ab1ae83612)

Likely related people:

  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Vincent Koc: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Jason (Json): Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

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

  • Resolve the producer-receipt rule and compatible behavior for receipt-free cold SDK callers.
  • Show allowed and pre-snapshot replacement outcomes at the final announcement effect using redacted, source-bound observations.

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 (6 earlier review cycles)
  • reviewed 2026-09-25T19:31:22.428Z sha caa7c88 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-25T20:06:52.048Z sha d64b47b :: needs maintainer review before merge. :: none
  • reviewed 2026-09-25T21:55:30.240Z sha 1402d2e :: needs real behavior proof before merge. :: [P1] Pin implicit task ownership before the new read wait
  • reviewed 2026-09-25T22:07:57.527Z sha ae59cc6 :: needs real behavior proof before merge. :: [P1] Pin implicit task ownership before the read wait
  • reviewed 2026-09-25T22:42:50.142Z sha 1544b4b :: needs real behavior proof before merge. :: [P1] Pin receipt-free task ownership before the worker wait
  • reviewed 2026-09-25T23:14:12.606Z sha bc55bb2 :: needs real behavior proof before merge. :: [P1] Reject cold receipt-free replacements before announcement

@openclaw-barnacle openclaw-barnacle Bot added the agents Agent runtime and tooling label Sep 25, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. 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 Sep 25, 2026
@openclaw-barnacle openclaw-barnacle Bot added the gateway Gateway runtime label Sep 25, 2026
@fuller-stack-dev

Copy link
Copy Markdown
Member Author

The P1 receipt-free assignment race is fixed in bc55bb24817885b3be406096622e0bcf5670d804. Known resident identity is captured before the first worker wait and checked at the actual announcement boundary. Cold or uncertain state uses normal async preparation; metadata and unrelated updates still deliver.

The unchanged production path reproduced an incorrect replacement delivery. Both complete SDK test files now pass 44/44, and independent source-blind validation passes seven clauses across eight private-SQLite scenarios through the public SDK and actual announcement dispatcher. Allowed calls deliver the exact payload once; replacement and inserted tasks receive zero transport calls and remain unchanged. Only the final transport is synthetic. Independent review is clean through P2.

The updated PR Evidence section links the executable fixture, red/green output, raw final-effect observations and SHA-256 manifest, all fetched and verified after publication: https://gist.github.com/fuller-stack-dev/7fb9d6e7c8eb81c581abcbadd40a3221

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added the merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. label Sep 25, 2026
@fuller-stack-dev

Copy link
Copy Markdown
Member Author

Addressed the cold-assignment finding on e5ab1ae8361215e708b91fe0775375d00b8ed143. Receipt-free cold completion now retains a detached worker snapshot before joining normal read preparation, then rechecks the same assignment before the announcement effect. Missing database discovery remains valid, and metadata/unrelated work continues normally.

The unchanged public SDK/private-SQLite reproduction delivered an old payload after a cold same-run replacement. The automated red failed replacement/removal/insertion and passed four allowed controls. Final SDK tests pass 49/49, native snapshot tests 4/4, and the integrated lifecycle fixture passes. Independent review is clean through P2. The linked evidence now includes all seven cold delivery scenarios at the real SDK/announcement boundary, including a never-created database. Two initial validator deadline failures and their cleanup/diagnostic evidence are retained honestly in the report.

Legacy cold calls use their first authoritative SQL observation. They cannot reconstruct a producer identity replaced before that observation; callers needing that stronger guarantee already carry expectedTask, including native completion recovery. This preserves best-effort legacy starts without a mandatory receipt, blanket cold rejection, callback-based invalidation or manual rewind.

Final source hashes, contract, raw observations and review. The full staged/published tree and canonical ancestry were verified. Previous head CI passed; the corrected head has its own running CI.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@fuller-stack-dev

Copy link
Copy Markdown
Member Author

Maintainer decision for the completed review of e5ab1ae8361215e708b91fe0775375d00b8ed143: retain the documented best-effort path for legacy receipt-free SDK callers. Do not reject all cold calls or require a manual rewind.

The review correctly identifies the compatibility limit: an initially unloaded, receipt-free call can select a same-run replacement committed before its first SQL observation. We explicitly accept that limit for this legacy API. The first observation is the selection point; this PR does not claim invocation-time producer identity without a producer receipt. The PR body and source comment already document it.

Native Codex completion passes its retained expectedTask, so the failure being repaired retains producer-bound assignment checks. Warm legacy calls retain resident identity before yielding. Cold legacy calls retain their first snapshot, then revalidate it before announcement; replacement, removal and insertion after that observation are covered at the final delivery boundary. Existing allowed cold, metadata, unrelated and fresh-empty calls remain usable.

The review confirms the earlier replacement-during-preparation finding is addressed. Its remaining request for zero delivery after an unknown pre-snapshot reassignment would impose a stronger contract than the chosen legacy compatibility policy. That request is declined for this PR; no claim is made that the pre-snapshot window is closed. The published real-SQLite proof and its original validator-timeout qualifications remain unchanged.

@fuller-stack-dev
fuller-stack-dev merged commit 718ce15 into openclaw:main Sep 26, 2026
226 checks passed
@fuller-stack-dev

Copy link
Copy Markdown
Member Author

Merged via squash.

@fuller-stack-dev
fuller-stack-dev deleted the fix/codex-completion-contention-20260925 branch September 26, 2026 00:13
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 26, 2026
…tion (openclaw#158286)

* fix: keep native completions alive through task database contention

* test: await native completion persistence in custody fixtures

* fix: preserve completion retries during receipt validation

* fix: release replaced native completion assignments

* test: observe native completion through call-through spies

* test: preserve thread metadata in SQLite cleanup fixture

* test: order session read revocation after authority capture

* chore: align SQLite fixture for canonical merge

* fix: retain implicit completion assignment across async reads

* Align overlapping test fixtures for upstream integration

* fix: retain cold task selections before completion preparation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation extensions: codex gateway Gateway runtime merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P1 High-priority user-facing bug, regression, or broken workflow. plugin: file-transfer rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: XL status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant