Skip to content

fix(plugin-sdk): keep restart recovery state private - #107450

Closed
zhangguiping-xydt wants to merge 7 commits into
openclaw:mainfrom
zhangguiping-xydt:fix/problem-pr96230-dispatch-boundary
Closed

zhangguiping-xydt wants to merge 7 commits into
openclaw:mainfrom
zhangguiping-xydt:fix/problem-pr96230-dispatch-boundary

Conversation

@zhangguiping-xydt

@zhangguiping-xydt zhangguiping-xydt commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where plugins could observe or overwrite core-owned mainRestartRecovery state through ACP, injected agent/channel runtimes, or combined transcript helpers even though the public SessionEntry type does not expose that field. The deprecated whole-store API could also silently lose the state when a plugin moved an unchanged session identity to a new store key.

Follow-up to #96230 after its session recovery implementation landed on main.

Why This Change Was Made

All plugin-facing session paths now share one projection and reconciliation facade. It removes only mainRestartRecovery, preserves the existing public restartRecovery* contract, rejects attempted private-field injection, preserves recovery for stable session identities and unique key moves, and clears recovery triggers when the session ID rotates or a key move has ambiguous destinations.

ACP continues to return the real, stable AcpSessionManager instance, so instanceof, prototype, and constructor identity remain compatible. Its dependency and metadata-write seams are ECMAScript-private instead of being runtime-accessible TypeScript-private properties.

User Impact

Plugin authors receive runtime values that match the published SessionEntry type and cannot accidentally corrupt core restart coordination. Existing ACP class identity and the rest of the recovery-related public fields remain unchanged.

Evidence

  • 122 focused and full affected tests passed across direct/legacy session store APIs, ACP manager behavior, injected agent session creation and mutation, channel metadata, and transcript projection.
  • A bounded standalone runtime proof exercised the real SQLite session accessor plus production Plugin SDK, injected agent/channel, ACP, transcript, and whole-store entrypoints. It observed private-state hiding, injection rejection, ACP class compatibility, hidden write escapes, preservation across a unique key move, and clearing of ambiguous-move recovery triggers before startup observation.
  • Targeted Oxlint and Oxfmt checks passed.
  • Plugin SDK surface and session-accessor boundary checks passed.
  • Full local check:test-types/build lanes were not run because the daily-fix resource guard could not attest memory/CPU/PID limits in this cgroup-v1 environment; remote CI remains the authoritative lane for those checks.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: XS labels Jul 14, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. 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. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. labels Jul 14, 2026
@clawsweeper

clawsweeper Bot commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 17, 2026, 3:21 PM ET / 19:21 UTC.

Summary
The branch centralizes plugin-facing session projection and mutation handling so mainRestartRecovery remains core-private across Plugin SDK, ACP, injected runtime, channel, transcript, and legacy whole-store paths.

PR surface: Source +11, Tests +451, Generated 0. Total +462 across 16 files.

Reproducibility: yes. at source level: seed an internal session with mainRestartRecovery, invoke each Plugin SDK or injected runtime read/mutation path, and verify the field remains hidden and preserved or cleared under the documented identity rules. The supplied PR evidence also describes this exercise against the real SQLite accessor.

Review metrics: none identified.

Stored data model
Persistent data-model change detected: serialized state: src/plugin-sdk/session-store-runtime-internal.ts, serialized state: src/plugin-sdk/session-store-runtime-mutations.ts, serialized state: src/plugin-sdk/session-store-runtime.key-move.test.ts, serialized state: src/plugin-sdk/session-store-runtime.ts, serialized state: src/plugin-sdk/session-transcript-hit.test.ts, serialized state: src/plugin-sdk/session-transcript-hit.ts, and 8 more. Confirm migration or upgrade compatibility proof before merge.

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🦞 diamond lobster
Patch quality: 🐚 platinum hermit
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • Let the exact-head Plugin SDK/session checks finish before the armed automerge path lands the branch.

Risk before merge

  • [P1] The branch intentionally changes runtime-observable values for plugins that had relied on an undocumented escape hatch to core session state; confirm exact-head compatibility checks and mergeability before landing.
  • [P1] The reconciliation logic preserves private recovery only for stable identities or unique key moves and clears it for rotated or ambiguous moves, so the session-state regression tests are material merge protection rather than incidental coverage.

Maintainer options:

  1. Complete exact-head compatibility validation (recommended)
    Allow the armed merge path to proceed only after the current head passes its Plugin SDK, session-accessor, and mergeability gates.
  2. Accept undocumented-plugin exposure risk
    Merge with an explicit maintainer decision that plugins reading the private field were never supported and may now observe only the documented session shape.

Next step before merge

  • [P2] No mechanical repair is established; the opted-in automerge lane should wait for the current head's compatibility checks and clean merge result.

Security
Cleared: The supplied diff changes session-boundary code and tests without adding dependencies, workflows, credential handling, artifact execution, or broader privileges; no concrete security or supply-chain defect is evident.

Review details

Best possible solution:

Land the single canonical projection/reconciliation boundary once the exact-head validation completes, retaining ACP class identity while enforcing the published SessionEntry visibility contract.

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

Yes, at source level: seed an internal session with mainRestartRecovery, invoke each Plugin SDK or injected runtime read/mutation path, and verify the field remains hidden and preserved or cleared under the documented identity rules. The supplied PR evidence also describes this exercise against the real SQLite accessor.

Is this the best way to solve the issue?

Yes. A shared projection/reconciliation facade is a narrower and more maintainable solution than independently filtering each Plugin SDK, ACP, channel, transcript, and legacy-store entrypoint.

AGENTS.md: unclear because the file could not be read completely.

Codex review notes: model internal, reasoning high; reviewed against 1d999b817fac.

Label changes

Label changes:

  • add P2: This is a bounded Plugin SDK/session-state correctness fix with a meaningful but non-emergency compatibility surface.
  • add merge-risk: 🚨 compatibility: Plugin-visible session results are deliberately tightened to the documented public shape, which can affect plugins relying on undocumented runtime fields.
  • add merge-risk: 🚨 session-state: The change reconciles hidden recovery state across session patches, replacements, and key moves, so incorrect handling could alter restart-recovery coordination.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • remove P3: Current review triage priority is P2, so this older priority label is no longer current.
  • remove rating: 🦞 diamond lobster: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.

Label justifications:

  • P2: This is a bounded Plugin SDK/session-state correctness fix with a meaningful but non-emergency compatibility surface.
  • merge-risk: 🚨 compatibility: Plugin-visible session results are deliberately tightened to the documented public shape, which can affect plugins relying on undocumented runtime fields.
  • merge-risk: 🚨 session-state: The change reconciles hidden recovery state across session patches, replacements, and key moves, so incorrect handling could alter restart-recovery coordination.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 🚀 automerge armed: This PR is in ClawSweeper's automerge lane. Sufficient (live_output): The PR provides a bounded real SQLite/runtime proof across the affected public entrypoints, supplemented by successful proof automation; redact any private runtime details if further logs are posted.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR provides a bounded real SQLite/runtime proof across the affected public entrypoints, supplemented by successful proof automation; redact any private runtime details if further logs are posted.
Evidence reviewed

PR surface:

Source +11, Tests +451, Generated 0. Total +462 across 16 files.

View PR surface stats
Area Files Added Removed Net
Source 10 429 418 +11
Tests 5 454 3 +451
Docs 0 0 0 0
Config 0 0 0 0
Generated 1 2 2 0
Other 0 0 0 0
Total 16 885 423 +462

What I checked:

  • Active sponsored PR: This PR is open, non-draft, and GitHub reports it as mergeable; member hxy91819 assigned it and explicitly requested approval/automerge in the discussion, so none of the conservative cleanup close reasons apply. (28f7b42b18c8)
  • Canonical projection boundary: The proposed session-store-facade is the shared owner for plugin-visible reads and mutations, replacing duplicated SDK/runtime helpers and stripping the private recovery aggregate before values reach plugin-facing paths. (src/plugins/runtime/session-store-facade.ts:1, 28f7b42b18c8)
  • ACP compatibility preservation: The ACP manager continues to return the real AcpSessionManager while projecting the stored entry, preserving class identity and narrowing only the returned session data. (src/acp/control-plane/manager.core.ts:73, 28f7b42b18c8)
  • Related merged recovery implementation: The underlying restart-recovery state was introduced by merged PR fix(session): stop repeated restart recovery after retry budget #96230; this PR addresses the distinct follow-up boundary that prevents that core-owned state escaping through plugin-facing APIs. (0a868179e4c7)
  • After-fix behavior evidence: The PR body describes a real SQLite/runtime exercise across production Plugin SDK, ACP, injected agent/channel, transcript, and whole-store entrypoints; GitHub also records proof: sufficient and a successful Real behavior proof check. (28f7b42b18c8)

Likely related people:

  • zhangguiping-xydt: Authored the merged restart-recovery implementation and this follow-up isolation work, connecting the internal recovery state with the plugin-facing session boundary. (role: feature introducer and recent area contributor; confidence: medium; commits: 0a868179e4c7; files: src/plugins/runtime/session-store-facade.ts, src/acp/control-plane/manager.core.ts)
  • hxy91819: Assigned this PR and repeatedly requested ClawSweeper approval/automerge after reviewing the compatibility discussion. (role: review sponsor; confidence: high; files: src/plugins/runtime/session-store-facade.ts, src/plugin-sdk/acp-runtime.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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.

How this review workflow works
  • 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.
Review history (8 earlier review cycles)
  • reviewed 2026-07-14T15:41:14.929Z sha 0a94174 :: needs maintainer review before merge. :: none
  • reviewed 2026-07-14T16:12:15.376Z sha 166b22c :: needs maintainer review before merge. :: none
  • reviewed 2026-07-14T16:35:02.945Z sha 166b22c :: needs maintainer review before merge. :: none
  • reviewed 2026-07-14T17:00:26.031Z sha 166b22c :: needs maintainer review before merge. :: none
  • reviewed 2026-07-14T17:27:21.339Z sha 166b22c :: needs maintainer review before merge. :: none
  • reviewed 2026-07-14T18:01:27.446Z sha 166b22c :: needs maintainer review before merge. :: none
  • reviewed 2026-07-16T02:09:02.186Z sha 03c107f :: needs maintainer review before merge. :: none
  • reviewed 2026-07-16T06:21:49.241Z sha 03c107f :: needs maintainer review before merge. :: none

@hxy91819

Copy link
Copy Markdown
Member

@clawsweeper automerge

@clawsweeper

clawsweeper Bot commented Jul 15, 2026 •

Copy link
Copy Markdown
Contributor

🦞🔧
ClawSweeper automerge is enabled.

Draft PRs stay fix-only until GitHub marks them ready for review. Pause with /clawsweeper stop.

Automerge progress:

  • 2026-07-15 05:20:22 UTC review queued 03c107ff79d0 (queued)
  • 2026-07-16 16:11:46 UTC review queued 03c107ff79d0 (queued)

@clawsweeper clawsweeper Bot added the clawsweeper:automerge Maintainer opted this PR into bounded ClawSweeper-reviewed automerge label Jul 15, 2026
@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 🚀 automerge armed This PR is in ClawSweeper's automerge lane. clawsweeper:human-review Needs maintainer review before ClawSweeper can continue and removed 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 Jul 16, 2026
@clawsweeper

clawsweeper Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

🦞✅
ClawSweeper is pausing this repair loop for human review.

Source: clawsweeper[bot]
Reason: - [P2] No repair job is needed; the remaining action is the opted-in automerge lane's normal current-base refresh, exact-head checks, and mergeability gate.; Cleared: The diff adds no dependencies, workflow permissions, secret handling, downloaded code, persistence, or wire-protocol changes, and no concrete security or supply-chain concern was found. (sha=03c107ff79d03ef3b872408db728bf3e84c14bfa)

Why human review is needed:
This item has security-sensitive risk. ClawSweeper is pausing instead of making an autonomous change that could affect trust, credentials, permissions, or exposure.

What the maintainer can do as a next step:
If the maintainer accepts the current risk and wants ClawSweeper to continue merge gates, comment @clawsweeper approve. If the security-sensitive detail still needs changes, describe the safe path or push the fix, then comment @clawsweeper automerge. If the risk should not be automated, keep the PR paused for manual review or comment @clawsweeper stop.

I added clawsweeper:human-review and left the final call with a maintainer.

@hxy91819

Copy link
Copy Markdown
Member

@clawsweeper approve

@clawsweeper clawsweeper Bot removed the clawsweeper:human-review Needs maintainer review before ClawSweeper can continue label Jul 16, 2026
@hxy91819

Copy link
Copy Markdown
Member

@clawsweeper automerge

@clawsweeper

clawsweeper Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Command router queued. I will update this comment with the next step.

@hxy91819

Copy link
Copy Markdown
Member

Regarding the Stored data model note: this is a false positive from the added test, not a persistent-model change.

packages/gateway-client/src/client.watchdog.test.ts uses JSON.parse(String(send.mock.calls[0]?.[0])) only to recover the synthetic request id and feed a response back into the in-memory test client. It does not read or write persisted state.

The production request frame remains:

JSON.stringify({ type: "req", id, method, params })

The new onDispatched field is an optional process-local callback on GatewayProtocolRequestOptions; it is not included in that frame and is not stored in SQLite, config, session state, files, or any migration-owned shape. Therefore this PR has no persistent-data migration or upgrade-compatibility requirement. The only contract change is an additive optional internal request observer.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation size: XL and removed gateway Gateway runtime size: S labels Jul 17, 2026
@zhangguiping-xydt zhangguiping-xydt changed the title refactor(gateway-client): expose request dispatch boundary fix(plugin-sdk): keep restart recovery state private Jul 17, 2026
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. clawsweeper:human-review Needs maintainer review before ClawSweeper can continue and removed rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. labels Jul 17, 2026
@clawsweeper

clawsweeper Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

🦞✅
ClawSweeper is pausing this repair loop for human review.

Source: clawsweeper[bot]
Reason: - [P2] No mechanical repair is established; the opted-in automerge lane should wait for the current head's compatibility checks and clean merge result.; Cleared: The supplied diff changes session-boundary code and tests without adding dependencies, workflows, credential handling, artifact execution, or broader privileges; no concrete security or supply-chain defect is e... (sha=28f7b42b18c8fca6aa9060ff6a7ba14c8f9df6ef)

Why human review is needed:
This item has security-sensitive risk. ClawSweeper is pausing instead of making an autonomous change that could affect trust, credentials, permissions, or exposure.

What the maintainer can do as a next step:
If the maintainer accepts the current risk and wants ClawSweeper to continue merge gates, comment @clawsweeper approve. If the security-sensitive detail still needs changes, describe the safe path or push the fix, then comment @clawsweeper automerge. If the risk should not be automated, keep the PR paused for manual review or comment @clawsweeper stop.

I added clawsweeper:human-review and left the final call with a maintainer.

@zhangguiping-xydt

Copy link
Copy Markdown
Contributor Author

Since this PR has diverged significantly from the original, I've decided to close it and continue this work from a fresh branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clawsweeper:automerge Maintainer opted this PR into bounded ClawSweeper-reviewed automerge clawsweeper:human-review Needs maintainer review before ClawSweeper can continue docs Improvements or additions to documentation merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XL status: 🚀 automerge armed This PR is in ClawSweeper's automerge lane.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants