Skip to content

fix(agents): require human provenance for internal restart recovery - #160130

Merged
steipete merged 1 commit into
mainfrom
fix/r97-forward-5
Sep 28, 2026
Merged

steipete merged 1 commit into
mainfrom
fix/r97-forward-5

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Main-session restart recovery resumes an internal-ingress run only when the latest input carries human evidence. The provenance reader mapped every non-special kind (missing, invalid/unknown, and external_user alike) to a generic "other" source, which the recovery store treats like human input. A restart claim whose latest input had missing or invalid provenance was therefore resumed as if a human had sent it.

This correction was made on the abandoned release/2026.9.7 branch during review of 0862237 (fixture follow-up beab1d9, #159642) and never reached main; this forward-ports it before that branch is deleted.

Summary

  • readMainSessionRecoveryCheckpoint recognizes only verified external_user provenance as human; missing or unknown provenance maps to no source, so the existing tombstone path handles it.
  • The positive human-origin recovery fixture is marked with external_user provenance.
  • docs/gateway/restart-recovery.md states that recovery requires verified human provenance.

Evidence

  • New cases in main-session-harness-completion.test-harness.ts ("requires human evidence for internal recovery") reproduced all four missing/invalid provenance failures on unchanged main and pass with the fix; 229 related tests passed.
  • pnpm check:changed: production types, all test-type shards and the coercion guard passed locally before a host-load interruption; full result is on this PR's CI.
  • Autoreview: scoped-clean at P0/P1.

Forward-port the unknown-provenance correction from 0862237 and the positive human fixture correction from beab1d9. Missing or invalid input provenance cannot inherit human authority from an earlier turn, including when a final reply is prepared.

Co-authored-by: Vincent Koc <[email protected]>
Co-authored-by: RomneyDa <[email protected]>
@clawsweeper

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

@clawsweeper clawsweeper Bot added P0 Emergency: data loss, security bypass, crash loop, or unusable core runtime. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. 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 28, 2026
@clawsweeper

clawsweeper Bot commented Sep 28, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge. Reviewed September 28, 2026, 1:08 AM ET / 05:08 UTC.

ClawSweeper review

What this changes

The branch requires explicit human input provenance before resuming an internal agent turn after a Gateway restart, adds recovery cases, and clarifies the Gateway documentation.

Merge readiness

⛔ Needs changes before merge - 1 item remains

Current main still permits the reported internal restart-recovery path. The related merged fixture fix targeted the release branch, so this PR remains useful; source review found no discrete patch defect.

Priority: P0
Reviewed head: 333cbf320e452e922fd9e45bf07d8cc217e32052

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The small guard targets the existing recovery owner and has focused negative and positive coverage, with test-cost reporting still outstanding.
Proof confidence 🌊 off-meta tidepool Not applicable: This member-authored PR is exempt from the external-contributor setup-proof gate. The changed production classifier feeds the recovery store; added fixtures assert that missing or invalid latest-input provenance tombstones before Gateway dispatch, including with a prepared reply, while explicit human provenance resumes. The PR body reports pre-fix failures and after-fix tests, but this read-only review did not run them. No stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This member-authored PR is exempt from the external-contributor setup-proof gate. The changed production classifier feeds the recovery store; added fixtures assert that missing or invalid latest-input provenance tombstones before Gateway dispatch, including with a prepared reply, while explicit human provenance resumes. The PR body reports pre-fix failures and after-fix tests, but this read-only review did not run them. No stored-data contract changes.
Evidence reviewed 8 items Current-main defect: The current-main classifier maps missing, invalid, and external-user provenance to the same generic source.
Recovery decision: The recovery store tombstones an undefined source for internal ingress before the resume path; the current-main generic source does not meet that condition.
Introduced guard: The PR's pinned introduced patch distinguishes external-user provenance from missing or invalid provenance.
Findings None None.
Security None None.

How this fits together

After a restart, OpenClaw reads a persisted session claim and its transcript to decide whether an interrupted agent turn can resume. Unverified internal work is tombstoned; eligible work is dispatched through the Gateway.

flowchart LR
  A[Gateway restart] --> B[Saved session claim]
  B --> C[Transcript input provenance]
  C --> D{Recovery allowed?}
  D -->|Yes| E[Resume agent turn]
  D -->|No| F[Tombstone claim]
Loading

Before merge

  • Complete next step (P2) - Record the expanded recovery test file's measured one-worker wall time in the PR body, and add CI seconds once available.
Agent review details

Security

None.

PR surface

Source +4, Tests +69, Docs +2. Total +75 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 1 6 2 +4
Tests 2 72 3 +69
Docs 1 4 2 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 82 7 +75

Review metrics

Metric Value Why it matters
Production and test growth production +4 net lines, tests +69 net lines A small authorization guard carries six recovery combinations; the PR explains the regression they protect.

Root-cause cluster

Relationship: canonical
Canonical: #160130
Summary: The related merged PR repaired a release-branch fixture; this PR carries the corresponding production guard onto main.

Members:

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

Technical review

Best possible solution:

Keep the persisted latest-input provenance as the recovery authority check, refuse unverified internal claims before dispatch, and preserve the existing channel, Control UI, and child-completion recovery paths.

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

Yes. Current-main source maps missing or invalid provenance to a source that bypasses the internal-ingress tombstone condition; the PR body reports failing pre-fix recovery cases, which this review did not run.

Is this the best way to solve the issue?

Yes. The patch changes the existing provenance classifier at the recovery boundary and covers both refusal and permitted resume through the recovery-store fixture.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 02e1ac8391f8.

Labels

Label changes:

  • add P0: Current main can treat unverified internal input as human authority when automatically resuming agent work after a restart.
  • add merge-risk: 🚨 compatibility: Internal claims with missing provenance that main previously resumed will now tombstone; the maintainer-directed release work and this PR explicitly choose that authority boundary.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This member-authored PR is exempt from the external-contributor setup-proof gate. The changed production classifier feeds the recovery store; added fixtures assert that missing or invalid latest-input provenance tombstones before Gateway dispatch, including with a prepared reply, while explicit human provenance resumes. The PR body reports pre-fix failures and after-fix tests, but this read-only review did not run them. No stored-data contract changes.

Label justifications:

  • P0: Current main can treat unverified internal input as human authority when automatically resuming agent work after a restart.
  • merge-risk: 🚨 compatibility: Internal claims with missing provenance that main previously resumed will now tombstone; the maintainer-directed release work and this PR explicitly choose that authority boundary.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This member-authored PR is exempt from the external-contributor setup-proof gate. The changed production classifier feeds the recovery store; added fixtures assert that missing or invalid latest-input provenance tombstones before Gateway dispatch, including with a prepared reply, while explicit human provenance resumes. The PR body reports pre-fix failures and after-fix tests, but this read-only review did not run them. No stored-data contract changes.

Evidence

What I checked:

Likely related people:

  • Vincent Koc: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Peter Steinberger: 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.

  • Record the changed recovery test file's measured one-worker wall time in the PR body.

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.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime agents Agent runtime and tooling size: S labels Sep 28, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

CI note: run 36380218725 failed one unrelated shard (src/cli/update-finalization-output.process.test.ts:440, a timing-dependent restart-observation detail string: "Gateway did not settle" vs "Gateway restart observation timed out during health-wait:port-inspection"); the rest of the matrix was cancelled by fail-fast. This PR only touches restart-recovery provenance classification. The file passes locally on this head (18/18, --maxWorkers=1) and main CI is green, so I re-ran the failed jobs; if it recurs it needs its own flake fix.

ClawSweeper P2 (test cost): deferred; the expanded harness file's cost is dominated by the existing suite setup.

@steipete

Copy link
Copy Markdown
Contributor Author

Test cost (ClawSweeper P2): node scripts/run-vitest.mjs run --maxWorkers=1 src/agents/main-session-recovery/main-session-restart-recovery.test.ts exceeded 400 s wall on this heavily loaded host (load ~50) and was cut off by my timeout, so no clean local number; the added cases are fixture-only (no timers) in the existing harness. CI seconds from this PR's shard are authoritative. The other CI failure on attempt 2 is src/plugins/runtime.retention.test.ts on the Bun unit-fast shard ("Completed retirement retained a successor registry"), a GC-dependent test unrelated to this change; it passes locally under Node 3/3.

@steipete
steipete merged commit e7d6bd8 into main Sep 28, 2026
270 of 357 checks passed
@steipete
steipete deleted the fix/r97-forward-5 branch September 28, 2026 06:42
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 29, 2026
…penclaw#160130)

Restart recovery resumes an internal-ingress run only with verified external_user provenance; missing or unknown provenance no longer inherits human evidence.

Forward-port of release/2026.9.7 0862237 (provenance correction) and beab1d9 (openclaw#159642 fixture).

Co-authored-by: Vincent Koc <[email protected]>
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 merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P0 Emergency: data loss, security bypass, crash loop, or unusable core runtime. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S 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.

1 participant