Skip to content

fix(subagents): settle missing completion sources once - #174850

Merged
steipete merged 3 commits into
mainfrom
steipete/perf-micro-operator-source-every-boot-20260919
Oct 17, 2026
Merged

steipete merged 3 commits into
mainfrom
steipete/perf-micro-operator-source-every-boot-20260919

Conversation

@steipete

@steipete steipete commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes repeated subagent completion-authority warnings on every Gateway restart when legacy individual runs have no saved original operator source. Two consecutive startup logs contained 127 and 129 distinct affected runs; all 127 from the first startup recurred in the second.

Related: #174177, which settles requester cohorts rather than individual completion restorations.

User Impact

Individual terminal completions now persist permanent non-delivery through the existing completion writer. Subsequent restarts skip their missing-source restoration while retaining the child execution outcome and captured result. Quiet completions receive the same durable suppression; already-delivered receipts and their timestamps survive both restoration and cleanup. No requester message is synthesized without authority.

Why This Change Was Made

The restoration owner previously recorded this refusal only in process memory. It now commits the existing blocked-completion state with current database, Gateway, lifecycle, and run ownership. Correlated queued deliveries retain their queue owner until settlement, including success already acknowledged before restart; failed individual queue settlement also suppresses unauthorized notifications. Cohort settlement and replaced-store notifications retain their existing owners. Durable replaced-store suspension is preserved across later boots without skipping authority restoration for unfinished handoffs. Temporary worker overload, unavailable access policy, and rejected settlement writes remain retryable; unfinished execution retains its normal interruption owner.

No schema, configuration, retention, or permission changes. Production LOC: +51 net (65 added / 14 removed, excluding tests and docs). This growth implements the missing durable transition, its no-notification cause, delivery-receipt preservation, and existing store-retirement precedence; it reuses the native completion writer rather than adding another state owner or cache.

Evidence

  • Two-restart SQLite regression: the original restoration code repeats all 3 original fixture warnings on boot two. The final expanded fixture covers 4 states (successful, interrupted, quiet, already delivered) and produces 0 repeat warnings, preserving results and receipts.
  • Rejected-write coverage verifies that the existing sweep can retry settlement; the delivery queue remains empty.
  • Focused proof: 87 tests passed across subagent-registry.completion-authority.test.ts and subagent-completion-admission.expired-receipt.test.ts (91.12 s Vitest wall time). After review, the 2 expanded restart cases and delivered-receipt cleanup regression passed (7.15 s + 14.13 s shard wall time; cleanup test 44 ms). Changed-file oxlint, oxfmt, and git diff --check passed.
  • The completion-writer file passes all 16 tests (10.70 s Vitest wall time), including pending, already-acknowledged, and failed legacy queue settlement. This addresses the automated review finding about retaining correlated queue ownership.
  • Independent Codex autoreview is clean through P2 for both the original fix and the queue follow-up after resolving the receipt-preservation findings.
  • PR CI caught a store-replacement restart regression and a generic worker-probe type error; both were fixed. The two focused registry files passed 85 tests (90.17 s Vitest wall time), followed by the final store-restart case and both missing-source/rejected-write cases after narrowing the handoff guard. The final write-retry cases passed in 10.93 s. Independent review of the CI repair is clean through P2.
  • Broad checks: PR CI. No Testbox/Crabbox lease or benchmark was needed for this correctness fix. Production post-deploy verification remains pending.

Persist permanent non-delivery for legacy individual completions without an original operator source. Preserve execution results and delivered receipts, suppress unauthorized notifications, and retain transient settlement retries. Prove durable suppression across two restarts.
@clawsweeper

clawsweeper Bot commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@steipete
steipete marked this pull request as ready for review October 16, 2026 23:46
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-17T00:17:00.569199Z f2681a0 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation agents Agent runtime and tooling size: S labels Oct 16, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d08f4d1df9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 16, 2026
@clawsweeper

clawsweeper Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

This PR durably settles individual completions missing their original operator evidence while preserving results and delivery receipts.

Example: The stored legacy-delivered run lacks operator evidence and has deliveredAt and announcedAt equal to 260.

  • Before: Each restart attempts restoration again and emits another authority warning.
  • After: Persisted suppression prevents repeated restoration while preserving both delivery timestamps.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Focused implementation with meaningful persisted-state regressions; the previous queue-ownership finding is addressed.
Proof confidence 🦐 gold shrimp (3/6) Ordinary contributor proof is exempt for this maintainer-authored PR; the supplied evidence exercises real SQLite owners in process, but does not demonstrate upgrading a v2026.10.4 store through the shipped Gateway while preserving results, queue receipts, and settings across two restarts.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: The same retained subagent completions produce authority-restoration warnings on every Gateway restart.
Reason: The maintainer-authored direction addresses observed repeated failures without adding a configuration option or expanding authority.

Merge readiness

⛔ Blocked before merge - 1 item remains

Keep open: this maintainer-authored PR addresses a distinct restart-recovery defect still present on main; I found no introduced code defect.

Priority: P2
Reviewed head: f2681a0f75cf52a3556af5b7aede4227608e429e

Before merge

  • Add data-model compatibility proof - The review found that existing stored data may not work after upgrade. Show that existing data still loads and works with this change.

Findings

None.

Tests

  • Missing end-to-end proof: No latest-stable-to-candidate upgrade run demonstrates retained results and receipts surviving settlement and subsequent Gateway restarts.
Agent review details

How this fits together

Gateway startup restores saved subagent runs; the completion owner reconciles authority, queue receipts, and cleanup into durable registry state.

flowchart TD
  A[Gateway startup] --> B[Restore subagent registry]
  B --> C[Completion source owner]
  C --> D[Existing completion writer]
  C --> E[Existing queue settlement]
  D --> F[Durable registry state]
  E --> F
  F --> G[Cleanup and later restart]
Loading

Technical review

Best possible solution:

Keep durable refusal with the existing completion writer and preserve the queue, store-retirement, and cleanup owners.

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

Current main reaches the warning again after each cold restoration because the individual missing-source refusal is only process-local; the PR reports matching startup logs and a failing baseline regression.

Is this the best way to solve the issue?

The fix belongs in the existing restoration and completion owners, and the reviewed implementation retains transient retries and established delivery ownership.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Original operator-source restoration keeps the original intent (37d210e: Restore requester continuation under freshly validated original operator restrictions instead of reusing authority from the retired Gateway.)
  • Permanent versus transient restoration failure keeps the original intent (ce9d859: Settle definitively unrestorable requester cohorts once while retaining retries for unavailable startup dependencies.)
  • Blocked-completion notification changes intended behavior with a stated reason (1c10f70: Atomically persist blocked completion state and its requester alert; the new exception suppresses that alert when original authority is unavailable.)
  • Correlated queue recovery keeps the original intent (1fea5ee: Keep settlement bound to the original database and native owner, preserving committed receipts without replaying transport.)
  • Replaced-store notification retirement keeps the original intent (6abc70a: Prevent delayed child notifications from reaching a replacement physical session store or reviving when the old store is selected again.)
  • Acknowledged cleanup keeps the original intent (969ae09: Await durable cleanup publication before dependent effects; preserving a delivered receipt maintains that terminal fact.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit ce9d859 adds src/agents/subagents/registry/subagent-registry-gateway-owner.ts:33 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: ce9d859d68ab; files: src/agents/subagents/registry/subagent-registry-gateway-owner.ts)
  • Sho Jikumaru: Raw commit 1c10f70 adds src/agents/subagents/completion/subagent-completion-delivery.ts:203 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 1c10f70d9c86; files: src/agents/subagents/completion/subagent-completion-delivery.ts)
  • joshavant: Raw commit d9393bd adds src/agents/subagent-completion-delivery.ts:135 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: d9393bd3cbe1; files: src/agents/subagent-completion-delivery.ts)

PR surface

Source +51, Tests +204, Docs +5. Total +260 across 10 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 5 65 14 +51
Tests 4 210 6 +204
Docs 1 5 0 +5
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 10 280 20 +260

Review metrics

Metric Value Why it matters
Production versus regression coverage Production +51 net lines; tests/support +204 net lines Production growth reuses the existing writer; regression growth covers restart persistence, rejected writes, correlated receipts, and cleanup.

Labels

Label changes:

  • add P2: Repeated warnings affect retained legacy completions on restart, with no demonstrated outage or new loss of results.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.

Label justifications:

  • P2: Repeated warnings affect retained legacy completions on restart, with no demonstrated outage or new loss of results.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.

Rating scale

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

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (1 earlier review cycle)
  • reviewed 2026-10-17T00:01:23.440Z sha 2ab30bc :: blocked before merge. :: none

Reviewed October 16, 2026, 8:19 PM ET / October 17, 2026, 00:19 UTC (Revision 2).

Defer pending notifications to the existing store-retirement owner and retain its durable suspension across restarts. Keep unfinished handoffs eligible for original-authority restoration. Correct the rejection probe typing and extend the existing restart fixtures.
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@steipete
steipete merged commit 2b83983 into main Oct 17, 2026
125 of 127 checks passed
@steipete
steipete deleted the steipete/perf-micro-operator-source-every-boot-20260919 branch October 17, 2026 00:25
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 17, 2026
* fix(subagents): settle missing completion sources once

Persist permanent non-delivery for legacy individual completions without an original operator source. Preserve execution results and delivered receipts, suppress unauthorized notifications, and retain transient settlement retries. Prove durable suppression across two restarts.

* fix(subagents): retain queued completion settlement ownership

* fix(subagents): preserve replaced-store completion settlement

Defer pending notifications to the existing store-retirement owner and retain its durable suspension across restarts. Keep unfinished handoffs eligible for original-authority restoration. Correct the rejection probe typing and extend the existing restart fixtures.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. docs Improvements or additions to documentation size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant