Skip to content

fix(goals): retain admitted continuation custody across restart - #193136

Draft
GoatInAHat wants to merge 3 commits into
openclaw:mainfrom
GoatInAHat:fix/native-goal-recovery
Draft

GoatInAHat wants to merge 3 commits into
openclaw:mainfrom
GoatInAHat:fix/native-goal-recovery

Conversation

@GoatInAHat

Copy link
Copy Markdown
Contributor

Related: #192988. Depends on #193103 and #193024.

What Problem This Solves

An accepted Goal continuation can disappear during a Gateway restart, leaving an active Goal with no execution owner.

User Impact

Admitted Goal work can resume after restart using its original operator permissions and tool/delivery restrictions. Earlier accepted human input keeps priority, and Stop, Pause, clear, or replacement cancels stale pursuit.

This dependent draft is not live-qualified or ready to merge. Recovery refuses unavailable original authority, source-bound capabilities, and required workers rather than broadening permissions. Unanswered human-decision durability and Codex autonomous pursuit are not implemented by this slice.

Why This Change Was Made

The existing session store records the accepted continuation before its predecessor releases it. Startup and child settlement use the ordinary input/execution owners to recover that exact receipt. Writer cleanup preserves pursuit custody, while explicit Stop and Goal/session changes invalidate it. A narrowly guarded adoption transition permits a restart-interrupted execution to reacquire its Goal without weakening the native owner check.

Storage, publication, restoration, acquisition, and final delivery ship together: splitting these would leave a stored receipt without a safe consumer. No new scheduler, queue, timer, or state store is introduced. This branch includes the unchanged prerequisites; the stage-only comparison isolates this change.

Evidence

Checked recovery commit: 41f1d1aab017a0ec0268621ec01d11d873347ee1.

  • Final owning/consumer batch: 594 passing tests across 29 files.

  • Eight canonical production/test type projects pass. Scoped lint, formatting, MDX and exact incremental test allocation (1,690 LF) pass.

  • All 49 committed paths match the independently reviewed final source and index hashes.

  • Original production reproduces writer receipt loss and interrupted execution rejection before any model call. Five cancellation controls pass on that baseline.

  • Corrected running and already-killed recovery cases pass. A second interrupted recovery completes through a fresh Gateway context over the same store; expired occurrence authority remains expired. All eleven execution scenarios have passing results across full and focused runs.

  • Independent source review resolves both production findings; final fixture-delta review is clear.

  • Physical two-process restart, real provider inference and final external delivery remain unqualified. Mocked provider and same-process restart tests are not presented as live proof.

@clawsweeper

clawsweeper Bot commented Nov 5, 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 gateway Gateway runtime agents Agent runtime and tooling extensions: anthropic size: XL labels Nov 5, 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. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. 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 Nov 5, 2026
@clawsweeper

clawsweeper Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

This PR persists admitted Goal continuation custody and restores it through ordinary execution admission after a Gateway restart.

Example: The Goal “Verify the checked deliverable” has an accepted continuation when the Gateway restarts.

  • Before: The active Goal can survive while its process-local continuation disappears.
  • After: A durable receipt lets startup recover the same obligation under its original restrictions, or visibly pause it when recovery is refused.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The implementation is coherent and no discrete introduced defect was established, but required runtime, authority, and upgrade qualification is incomplete.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🦐 gold shrimp (3/6) Security review found an item that needs attention.

Product

Kind: Feature · Worth it: Needs a maintainer decision · Fix scope: Partial
User problem: An active Goal can remain visible after restart while its accepted continuation has no execution owner.
Reason: The submission has concrete value, but adds stronger durability and native-runtime behavior beyond the deliberately bounded existing contract; the linked issue also contains capabilities this slice expressly leaves unfinished.

Merge readiness

⛔ Blocked before merge - 4 items remain

Keep this dependent draft open: it contains distinct recovery work, but changes an intentional restart tradeoff and needs an owner decision before merge.

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

Decision needed

  • Question: Should admitted Goals gain durable original-caller recovery and Claude-native pursuit, changing the intentionally lossy restart contract and introducing the native adapter’s rejection rules?
  • Recommendation: Approve a bounded durable Goal contract: Approve recovery only for recorded admitted obligations through existing owners, explicitly accepting the original-source restoration and supported native-runtime boundaries after qualification.
  • Why: The merged restart redesign explicitly favored shutdown-only capture and accepted loss, while current Goal documentation limits supported runtimes; no maintainer approval of this expansion appears in the inspected discussion.

Before merge

  • Add real behavior proof - Authority-chain proof required: supplied tests exercise real session persistence, admission, managed MCP, and synthetic native transport, but inference and process replacement are simulated; the author explicitly leaves physical restart, real provider execution, and external delivery unqualified. Show an allowed restricted principal, forbidden sibling action, and revocation or reassignment rejected before further I/O. No latest-stable upgrade evidence establishes preservation of existing settings, Goals, and transcripts. Redact credentials, IPs, and non-public endpoints from supplied traces. After adding proof, update the PR body, then request a new review with @clawsweeper re-review. The PR author or someone with repository write access can request it.
  • Resolve security concern: Qualify original-principal authority after recovery - Recovery consumes persisted source facts and retains independent continuation authority; existing tests cover Goal invalidation and occurrence expiry, but do not establish forbidden sibling-agent rejection and principal revocation or reassignment before recovered provider, tool, and delivery effects.
  • Resolve merge risk - The contributor must establish that authority retained through restart and successor execution cannot permit a forbidden sibling-agent action or effects after principal revocation or reassignment.
  • 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

  • [medium] Qualify original-principal authority after recovery — src/gateway/session-goal-successor-recovery.ts:216

Tests

  • Missing end-to-end proof: Supply redacted shipped-Gateway evidence for physical restart, recovered inference and final delivery, native pursuit and cancellation, plus forbidden-principal and revocation controls; reported baseline regressions do not establish those scenarios.
Agent review details

How this fits together

Goal execution and child settlement produce continuation receipts in the existing session store; Gateway startup restores their original authority and submits ordinary session input, yielding agent execution and user replies.

flowchart TD
  A[Admitted Goal execution] --> B[Existing session store]
  B --> C[Gateway startup recovery]
  C --> D[Original authority and Goal checks]
  D --> E[Ordinary input admission]
  E --> F[Harness or CLI execution]
  F --> G[Goal settlement and user reply]
Loading

Technical review

Best possible solution:

Use the existing session store and admission owners for an owner-approved durable Goal contract, with the handoff and native prerequisites qualified as separate coherent stages.

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

Current-main source keeps Goal-return custody in memory and lacks the proposed successor receipt; this establishes the persistence gap, while supplied regressions report baseline failures and this review ran no target code.

Is this the best way to solve the issue?

The required invariant is that an accepted Goal obligation retains one owner until successor acquisition or explicit invalidation; the proposed producer/store/recovery cutover reuses existing owners, but its stronger durability guarantee changes an intentional product tradeoff.

AGENTS.md: found and applied where relevant.

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

Merge-risk options

Maintainer options:

  1. Qualify restored authority before merging (recommended)
    The contributor should demonstrate allowed restricted execution, forbidden sibling-agent denial, and revocation or reassignment preventing subsequent provider, tool, and delivery effects.
  2. Pause the dependent stack
    Keep this draft pending while the maintainer settles the durable Goal contract and its prerequisite capabilities.

Provenance checked

Testing

Proof path: in-process harness.

Security

Needs attention: Live guards are present, but restored and retained authority remains unqualified at the final effects.

Evidence

Security concerns:

  • [medium] Qualify original-principal authority after recovery — src/gateway/session-goal-successor-recovery.ts:216
    Recovery consumes persisted source facts and retains independent continuation authority; existing tests cover Goal invalidation and occurrence expiry, but do not establish forbidden sibling-agent rejection and principal revocation or reassignment before recovered provider, tool, and delivery effects.
    Confidence: 0.93

What I checked:

PR surface

Source +2050, Tests +3015, Docs +67, Other +7. Total +5139 across 77 files. Added test files: 10.

View PR surface stats
Area Files Added Removed Net
Source 52 2799 749 +2050
Tests 19 3229 214 +3015
Docs 2 79 12 +67
Config 0 0 0 0
Generated 0 0 0 0
Other 4 7 0 +7
Total 77 6114 975 +5139

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Review metrics

Metric Value Why it matters
New public capability 1 optional CLI execution capability prepareNativeGoal adds a third-party-visible SDK contract whose lifetime and compatibility behavior need owner agreement.

Root-cause cluster

Relationship: partial_overlap
Canonical: #192988
Summary: This PR addresses the restart-custody portion of the linked umbrella report and includes two prerequisite stages; the older Codex restart PR overlaps but is not a qualified replacement.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: The change addresses bounded Goal continuation failures without evidence of an urgent release-wide regression.
  • merge-risk: 🚨 security-boundary: Persisted source facts restore an original principal and transfer authority into execution that survives the predecessor occurrence.
  • merge-risk: 🚨 compatibility: The stack expands the public CLI SDK and changes active Claude Goal execution with explicit native-version, objective, and token-budget restrictions.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Rank-up moves

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

  • Add final-effect proof for a restricted original principal, forbidden sibling-agent access, and revocation or reassignment during recovered execution.
  • Demonstrate a physical Gateway restart through recovered inference and final delivery, including the inherited Claude-native behavior.
  • Show a latest-stable upgrade preserving existing settings, Goal state, and transcript data.

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 November 4, 2026, 9:43 PM ET / November 5, 2026, 02:43 UTC.

This branch has not been deployed

No deployments
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: anthropic gateway Gateway runtime merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. 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