Skip to content

test: cover native restart recovery and tool attribution boundaries - #170336

Merged
fuller-stack-dev merged 7 commits into
openclaw:mainfrom
jjjhenriksen:fix/native-session-restart-recovery
Oct 16, 2026
Merged

fuller-stack-dev merged 7 commits into
openclaw:mainfrom
jjjhenriksen:fix/native-session-restart-recovery

Conversation

@jjjhenriksen

@jjjhenriksen jjjhenriksen commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Native restart recovery and deferred tool preparation need regression coverage that exercises saved operator custody and real effect boundaries, not only callback wiring or transcript classification.

User Impact

No production behavior changes remain against the integrated main base. This PR strengthens tests for existing recovery and authorization behavior; it adds no configuration, schema, credential, or permission changes.

Why This Change Was Made

The original recovery and prepared-requester-policy fixes are now upstream. This candidate preserves that implementation and adds coverage for native original input and steering, missing/delegated/cron sources, exact saved agent/session/incarnation/lifecycle ownership, and device/role revocation. Allowed continuations reach the real Gateway/Cron automation-write owner; refused continuations persist no job. Mismatched claims retain their original source and aborted state with the expected ownership refusal.

Built-in and catalog tool tests independently verify attribution invalidation before parameter preparation or effects. Missing-search guidance uses persisted dashboard metadata and inherited denial rather than a caller-invented policy. The new native fixture and existing creator-transport tests share the existing source-restoration owner; no parallel production classifier or authority owner is introduced.

The merge commit preserves @jjjhenriksen's original contribution and ancestry. The final delta against integrated main c03f83134081f087f20cacc52b65034bc3ea23af is five test/support files (+496/-38); obsolete production changes and duplicate recovery documentation are absent.

Evidence

Candidate: 61ffd2d6f0f68c72f8ada8ad5e7cc89ca7773cae, tree 3fd52451229f202c71e69a2625f0ccf583ce2d1e.

  • Final native cold-state recovery suite: 11/11 passed, complete exit 0 (50.48 seconds). Includes exact agent/session-key mismatch controls added after review.
  • Reused unchanged-input evidence: creator transports 17/17; typed operator recovery 13/13; tool construction/routing 12/12; prepared search/attribution 12/12. The original combined recovery run failed five native fixture expectations; those were reconciled with current upstream ownership and real model-availability validation, then the native suite passed separately. The original failed aggregate is not reported as green.
  • Mutation check: removing only the built-in factory attribution callback forwarding makes both built-in invalidation cases fail with built-in tool bypassed attribution; restored code passes. No raw-baseline-callback mutation is claimed.
  • Six scoped TypeScript graphs passed for the repaired inputs; the final affected gateway-server graph passed again. Targeted typed lint, formatting, whitespace checks, and recovery-doc MDX checks passed.
  • Two independent reviewers approved the prior candidate. Their documentation and saved-claim mismatch nits are resolved. Mandatory installed Codex autoreview of the final candidate completed scoped-clean through P3, through the existing API-key-only route. Its code pass covered all five changed files; a separate inventory-only pass did not assess implementation.

These are in-process cold-state reconstruction and real durable automation-effect tests, not an OS-process kill, signed native handshake, live provider execution, or live-service test. Provider/preflight collaborators are isolated; restoration and the durable effect owner are real. All runtime tests used private HOME/state/temp paths and a verified private managed-update handoff database. No live Gateway, real credentials, or provider configuration was changed.

The old 232-test and previous-head CI claims do not apply to this candidate. Required exact-head GitHub CI, security, and enforced review checks remain landing gates.

@clawsweeper

clawsweeper Bot commented Oct 12, 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.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 12, 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 ⚠️ Failed 2026-10-12T22:33:18.019670Z b6f4bf7 PR opened
ℹ️ 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 gateway Gateway runtime agents Agent runtime and tooling size: M labels Oct 12, 2026
@clawsweeper

clawsweeper Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR lets interrupted native-app turns reach authority restoration when their saved operator source exactly matches the interrupted session and run.

Example: A native-app turn in session requester-session retains its operator source when the Gateway restarts.

  • Before: Missing historical transcript provenance causes recovery to reject the turn and mark it failed.
  • After: The matching saved source reaches current-authority restoration, allowing the same session to continue while revoked or mismatched sources remain blocked.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused recovery repair with shipped Gateway proof, current-contribution final-effect controls, green exact-head gates, and no actionable findings.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (logs): Retained proof at 8581ef5 exercises signed native protocol chat through a real Gateway kill/restart, persisted historical missing-provenance state, production recovery, and a filesystem write; allowed input completes once, revoked input produces no write, and unowned delegated input never reaches recovery inference. Current contribution coverage additionally exercises cold-state restoration and real Cron persistence, including held writes rejected after token rotation, role downgrade, grant revocation, and claim retirement. The provider is synthetic and the protocol client is not the Mac UI app; current-head tests are not presented as another process-kill run.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A native-app task can become failed after restart even though its original authenticated operator source remains available.
Reason: The narrow repair restores an existing recovery contract, preserves current permission checks, and has explicit maintainer support for the direction.

Merge readiness

✅ Ready for maintainer review

This PR fixes a concrete native-session recovery failure still present on current main. No actionable correctness or security findings remain.

Priority: P1
Reviewed head: 88e776d1286de82b8052ab39b31e26dcfbdc8d47

Before merge

None.

Findings

None.

Agent review details

How this fits together

Gateway startup recovery reads persisted session claims and transcript checkpoints, classifies eligible interrupted turns, and dispatches them through the existing operator authority restorer before tools can produce effects.

flowchart TD
  A[Native app turn] --> B[Persisted operator source]
  B --> C[Startup recovery classifier]
  C --> D[Current authority restoration]
  D --> E[Recovered agent turn]
  E --> F[Guarded tool effect]
  C --> G[Reject unmatched source]
  D --> G
Loading

Technical review

Best possible solution:

Land the exact-source classifier repair while retaining the existing restoration, revocation, and final-effect authority owners.

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

Current-main source rejects an internal-ingress turn with missing provenance even when its exact operator source survives; the supplied baseline run records both native-input and steering failures.

Is this the best way to solve the issue?

The repair belongs at the recovery classifier: it recognizes existing source custody and delegates permission decisions to the established authority restorer without introducing another owner.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Delegated and unverified internal recovery refusal keeps the original intent (6b5fb4b: fix(security): stop delegated restart recovery #150702 intentionally prevents delegated or unverified internal input from resuming without surviving authority.)
  • Retained human-source steering classification keeps the original intent (3b93ac3: fix: steered sessions fail to resume after restart #170252 treats steering as context within the original human turn; this PR preserves that predicate and handles the distinct native source.)
  • Operator source restoration and final-effect authorization keeps the original intent (961f5c0: fix: preserve operator access after Control UI restart recovery #166553 restores exact persisted operator sources under current policy rather than granting System callers broader scopes.)
  • Terminal-redelivery authorization fixture keeps the original intent (158b707: The existing regression protects terminal replay retirement; the fixture now uses existing asynchronous authorization preparation and releases retained facts without weakening its assertions.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Current main still contains the failure: Current main rejects internal input with missing provenance without considering its retained operator source; the PR adds the exact-source exception. (src/agents/main-session-recovery/main-session-restart-recovery-store.ts:548, 976cc974fab1)
  • Narrow admission change: The introduced production change compares source run, agent, session key, session incarnation, and lifecycle before allowing recovery to proceed through existing dispatch. (src/agents/main-session-recovery/main-session-restart-recovery-store.ts:548, 88e776d1286d)
  • Existing authority owner remains authoritative: Restoration decodes the persisted source, verifies its current claim, and checks identity, device-token binding, authentication, role, grants, and original model restrictions; Gateway dispatch binds it to the exact replacement turn. (src/gateway/operator-run-recovery.ts, 88e776d1286d)
  • Production recovery proof: The full PR body supplies redacted logs from a real isolated Gateway at 8581ef5: process replacement resumes the matching native source and completes one filesystem write; device revocation prevents the offered write, and source-less delegated input produces no recovery provider request or write. (8581ef5701c1)
  • Current contribution strengthens final-effect coverage: The cold-state recovery tests invoke the real authority restorer and automation commit owner; creator-transport cases hold a real Cron mutation across token rotation, role downgrade, grant revocation, and claim retirement, asserting no additional persisted job. (src/gateway/server-methods/cron-creator-transports.integration.test.ts, 88e776d1286d)
  • Maintainer direction and contribution: Member fuller-stack-dev explicitly adopts this PR as the canonical native-session fix and records the published contribution, completed focused validation, and its limits. (88e776d1286d)

PR surface

Source +15, Tests +467, Docs +6. Total +488 across 9 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 2 37 22 +15
Tests 6 490 23 +467
Docs 1 7 1 +6
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 9 534 46 +488

Review metrics

Metric Value Why it matters
Production versus test changes Production +11/-0; tests and support +516/-45 The small classifier repair is supported by exact-binding, cold-state recovery, and durable-effect revocation coverage.

Labels

Label changes:

No label changes.

Label justifications:

  • P1: Authenticated native-app tasks can be permanently marked failed after a Gateway restart despite retaining a valid operator source.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

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 (9 earlier review cycles; latest 8 shown)
  • reviewed 2026-10-12T23:59:57.552Z sha 23b28f7 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-13T01:13:30.955Z sha 23b28f7 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-13T01:57:04.261Z sha 23b28f7 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-13T03:12:34.632Z sha 5804c06 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-13T03:55:22.974Z sha 5804c06 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-13T04:30:07.144Z sha 8581ef5 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-13T04:40:30.447Z sha 8581ef5 :: needs changes before merge. :: none
  • reviewed 2026-10-14T02:15:57.584Z sha 88e776d :: needs maintainer review before merge. :: none

Reviewed October 13, 2026, 10:35 PM ET / October 14, 2026, 02:35 UTC (Revision 10).

@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. 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. labels Oct 13, 2026
@openclaw-barnacle openclaw-barnacle Bot reopened this Oct 13, 2026
@openclaw-barnacle openclaw-barnacle Bot reopened this Oct 13, 2026
@openclaw-barnacle openclaw-barnacle Bot added the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Oct 13, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Oct 13, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Oct 13, 2026
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Oct 13, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Oct 13, 2026
@openclaw-barnacle openclaw-barnacle Bot added app: android App: android app: ios App: ios app: macos App: macos app: web-ui App: web-ui extensions: copilot-proxy Extension: copilot-proxy extensions: diagnostics-otel Extension: diagnostics-otel extensions: llm-task Extension: llm-task extensions: lobster Extension: lobster extensions: memory-core Extension: memory-core extensions: memory-lancedb Extension: memory-lancedb security Security documentation scripts Repository scripts docker Docker and sandbox tooling channel: feishu Channel integration: feishu channel: twitch Channel integration: twitch extensions: device-pair channel: irc extensions: acpx extensions: byteplus extensions: duckduckgo channel: qa-channel Channel integration: qa-channel extensions: qa-lab extensions: memory-wiki labels Oct 14, 2026
@fuller-stack-dev

fuller-stack-dev commented Oct 14, 2026 •

Copy link
Copy Markdown
Member

Published maintainer contribution at 88e776d1286de82b8052ab39b31e26dcfbdc8d47 (tree d69623250560981f17bc50258b0064abbc669fd3) by normal fast-forward from bb34a01a, preserving Jacqueline Henriksen's original ancestry. Production is unchanged from the independently reviewed parent. The one-file terminal-redelivery fixture repair uses existing asynchronous authorization preparation and releases retained facts in finally; current-authority checks and all terminal-replay assertions remain intact.

Final complete affected E2E file: 232/232 passed, with scoped lint/format/diff checks passing and a complete 643-line helper audit. Required independent manual/security and API-key-only delta review approved this exact head/tree with no actionable P0–P2 findings. The affected messaging type exit 0 is producer-recorded (empty log), not independently rerun proof. Prior 56-case real-boundary proof, seven type graphs, partial 161-case aggregate and original-author process-kill proof remain separately attributed in the description.

Fresh remote qualification completed October 14, 2026: CI 38499237380 and Security Review 38499231509 passed on attempt 1. Automatic post-CI review refresh 38500247475 passed and set openclaw/ci-gate, dependency review and security-sensitive review to success at 02:18 UTC. No blind rerun. ClawSweeper reviewed exact 88e776d1: zero findings, proof sufficient, 5/6, ready for maintainer review (comment 6133900447). Its needs-human / not_opted_in boundary remains; no merge authority is inferred.

Description separates current-head qualification from retained prior-head proof and its limits. Private SQLite/shared dependency custody preserved; no live service/database/config, new PR, force push, merge or deployment action.

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 P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: L 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.

2 participants