Skip to content

fix(sessions): settle unrestorable requester recovery once - #174177

Merged
steipete merged 2 commits into
mainfrom
steipete/perf-micro-r138-restart-recovery-20260919
Oct 16, 2026
Merged

steipete merged 2 commits into
mainfrom
steipete/perf-micro-r138-restart-recovery-20260919

Conversation

@steipete

@steipete steipete commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Requester continuations whose original operator authority cannot be restored remained recovery candidates on every Gateway boot, repeating the same preparation failure across startup retries.

User Impact

Definitively unrestorable inputs now settle once as interrupted. The session, transcript, workspace, and successful child results remain available for a fresh authenticated message. Any saved replayable reply is retained in the local interruption notice. Recovery does not send an external notice or create a system-authorized follow-up.

Why This Change Was Made

The existing registry restoration owner distinguishes missing/mismatched evidence and an explicit current-grant denial from transient startup failures. Its existing batch settlement operation retires the exact cohort wake. Main-session recovery atomically writes one idempotent interruption notice and clears the old claims; startup marking respects that terminal result instead of creating another claim merely because the session remains interrupted.

Recovery condition Outcome
Missing original operator evidence, mismatched cohort evidence, or explicitly denied current grant Settle the exact old cohort/input once; later passes and boots exclude it
Original cohort no longer exists after complete registry restoration Settle the orphaned parent input once
Gateway binding not ready, worker overload, or access-policy availability failure Retain custody and retry

The scheduler keeps bounded retries for transient failures because readiness can change without a session-row revision. Permanent failures no longer trigger repeated preparation. No retry cache, schema migration, configuration option, permission expansion, or retention change is introduced.

Follow-up to #174134.

Evidence

  • The startup regression fails against the previous recovery store: settled=0, failed=2. With this change, the first pass reports settled=1, failed=1; the second retries only the temporary failure, and the next boot discovers 0 candidates for the legacy input. Exactly one transcript notice remains, with saved reply text preserved.
  • Full startup recovery file: 17/17 passed. Cold-loaded registry authority file: 75/75 passed, including missing evidence, denied grants, pre-binding retry, and unavailable-policy recovery.
  • Completion settlement file: 36 tests passed initially; one new assertion expected an explicitly present undefined property after JSON persistence. Corrected that assertion; both authority-loss cases passed, preserving child results and proving no system event is queued.
  • Real Gateway restart regression: 2/2 affected cases passed after updating the former retry-forever expectations; the other 14 cases passed in the preceding CI run. The session fixture now uses its actual SessionEntry type to satisfy the test typecheck. Incremental independent review is scoped clean.
  • Guarded transcript updates: 2/2 passed, including a concurrent replacement pending-final intent. Final cold-restart matrix after test-helper simplification: 12/12 passed. Changed-file formatting/lint and export-name collision guard passed.
  • Import-closure guards: 18/18 and 3/3 passed. Independent review: scoped clean, no actionable P0–P2 findings. All required checks passed on exact head 23f912d780e85e35ea44ac8f267bd881ceba07ef, including the session test typecheck, Gateway tests, baseline ratchets, security check, and PostgreSQL conformance: CI run.

Simplification uses the existing batch mutation, transcript transaction, terminal fences, and worker filter. The redundant inner preparation catch is removed. Production code grows by 195 lines (tests: +337 lines) because the requested durable terminal outcome and permanent/transient distinction were missing; there is no new state schema or competing recovery owner.

Validation uses synthetic state only. No production restart or deployment was performed, and there is no new production startup timing measurement. Broad validation belongs to PR CI; no Testbox lease was allocated.

The earlier CI run exposed two test-only issues: an inferred-union fixture type and existing Gateway expectations for the old retry-forever behavior. Both are corrected. Its unrelated media assertion-baseline mismatch was reproduced identically on the PR and main; the baseline check now passes on the current CI merge tree.

Retire historical requester inputs after missing original authority or an explicit
current-grant denial, preserving their sessions and captured results. Keep
startup availability failures retryable and avoid re-marking terminal
interrupted work on the next boot.
@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.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@steipete
steipete marked this pull request as ready for review October 16, 2026 11:41
@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-16T11:58:46.891735Z 23f912d 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: L labels Oct 16, 2026
@openclaw-barnacle openclaw-barnacle Bot added the gateway Gateway runtime label Oct 16, 2026
@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. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed 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 16, 2026

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

This PR settles permanently unrestorable requester inputs once, preserves their results, and keeps temporary recovery failures retryable.

Example: Gateway startup discovers agent:main:main with source announce:requester-settle:legacy-cohort and no restorable operator authority.

  • Before: The same input remains recoverable and fails preparation again on later startup passes and boots.
  • After: Recovery writes one interruption notice, preserves the saved reply and workspace, clears the old claims, and excludes that input on subsequent boots.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Useful, coherent recovery repair with meaningful Gateway harness coverage and no actionable code findings; saved-state upgrade acceptance remains unproven.
Proof confidence 🦐 gold shrimp (3/6) The ordinary contributor proof gate does not apply to this maintainer-authored PR; inspected evidence exercises real Gateway restart and persistence owners with controlled agent execution. The saved-state compatibility gate remains incomplete: synthetic cold reloads do not establish an upgrade from v2026.10.4 with existing settings and data intact.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: An interrupted requester input that can never regain its original authority repeatedly fails recovery instead of receiving a final recorded outcome.
Reason: The maintainer-authored direction is established, and the change preserves sessions and captured results while ending an unrecoverable obligation without widening permissions.

Merge readiness

⛔ Blocked before merge - 1 item remains

Keep this PR open: it addresses a current restart-recovery retry loop, has established maintainer direction, and introduces no definite code defect found in this review.

Priority: P2
Reviewed head: 23f912d780e85e35ea44ac8f267bd881ceba07ef

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: Provide a latest-stable upgrade run preserving settings, transcripts, child results, and workspace data while proving one-time settlement and continued recovery of temporary failures.
Agent review details

How this fits together

Gateway startup recovery reads persisted session claims and subagent cohorts, restores current operator authority, and either admits a requester continuation or records a terminal interruption through the existing persistence owners.

flowchart TD
  A[Gateway startup] --> B[Session recovery claims]
  B --> C[Registry cohort restoration]
  C --> D[Current operator policy]
  D --> E[Authorized requester continuation]
  C --> F[Permanent failure settlement]
  F --> G[Transcript notice and terminal claims]
Loading

Technical review

Best possible solution:

Retire only definitively unrestorable inputs through the existing owners, preserve their results, and retain retry custody for temporary failures.

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

Current main visibly retains failed requester-recovery claims, and the supplied startup regression reports the expected failing baseline; no target code was executed during this read-only review.

Is this the best way to solve the issue?

The patch addresses the retained obligation at its existing registry and session owners, preserves transient retries, and avoids introducing fallback authority or a competing recovery store.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Requester-settle recovery custody changes intended behavior with a stated reason (da07630: Resume unfinished requester work under its original operator restrictions and retain owed work when authority is unavailable.)
  • Cold registry authority restoration keeps the original intent (37d210e: Replace old Gateway custody with freshly validated, scope-limited operator authority and never substitute system authority for missing evidence.)
  • Startup orphan marking keeps the original intent (4754d39: Recover interrupted sessions whose shutdown markers were missed; the patch excludes interruptions already backed by terminal evidence while retaining genuine claims.)
  • Blocked completion settlement changes intended behavior with a stated reason (6652f7e: Keep completion ownership with retained native/session owners after Tasks retirement; authority-loss settlement now deliberately avoids generating a system-authorized follow-up.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit da07630 adds src/agents/subagents/registry/subagent-registry-restart-recovery.ts:120 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: da07630c114a; files: src/agents/subagents/registry/subagent-registry-restart-recovery.ts)

PR surface

Source +195, Tests +337, Docs +3. Total +535 across 15 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 9 249 54 +195
Tests 5 423 86 +337
Docs 1 6 3 +3
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 15 678 143 +535

Review metrics

Metric Value Why it matters
Production versus test growth Production +195 lines; tests and test support +337 lines Production growth implements failure classification and durable settlement through existing owners; test growth covers restart exclusion, retained results, temporary failures, and concurrent pending-final replacement.

Labels

Label changes:

  • add P2: The change repairs repeated startup failures for historical requester inputs without evidence of a current core outage or broader user-data loss.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.

Label justifications:

  • P2: The change repairs repeated startup failures for historical requester inputs without evidence of a current core outage or broader user-data loss.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.

Rank-up moves

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

  • Demonstrate the latest-stable upgrade scenario described in the compatibility assessment.

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.

Reviewed October 16, 2026, 8:12 AM ET / 12:12 UTC.

@steipete
steipete merged commit ce9d859 into main Oct 16, 2026
152 of 153 checks passed
@steipete
steipete deleted the steipete/perf-micro-r138-restart-recovery-20260919 branch October 16, 2026 12:19
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 17, 2026
…174177)

* fix(sessions): settle unrestorable requester recovery once

Retire historical requester inputs after missing original authority or an explicit
current-grant denial, preserving their sessions and captured results. Keep
startup availability failures retryable and avoid re-marking terminal
interrupted work on the next boot.

* test(sessions): verify terminal requester recovery through Gateway
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 gateway Gateway runtime P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant