Skip to content

fix(plugins): continue self-held session sends after reload - #187095

Merged
fuller-stack-dev merged 9 commits into
mainfrom
openclaw/plaid-shell
Oct 29, 2026
Merged

fuller-stack-dev merged 9 commits into
mainfrom
openclaw/plaid-shell

Conversation

@fuller-stack-dev

@fuller-stack-dev fuller-stack-dev commented Oct 28, 2026 •

Copy link
Copy Markdown
Member

Why

A root session's original sessions_send can be lost when the admission guard refuses to wait while that turn holds a reloading plugin. The target has not accepted the send; re-running the model is not a safe substitute for retaining that exact send.

Changes

  • Retain the original send only after a private NoAccept refusal proves that admission did not occur. Join the obsolete owner before using the replacement outcome to continue.
  • Replay the original send once only when the exact replacement operation has a healthy outcome. Settle the retained operation with one completion wake, including on failure. Failed or unknown outcomes do not replay.
  • Keep the original conversation-policy identity and selected participant/source authority pinned. Re-evaluate current authorization and sandbox policy before replay without weakening a restriction captured earlier.
  • Keep classification and policy preparation separate from the executor. Retain the classification entry’s sandbox predicates through final admission using the existing source-authority owner; the classification helper no longer performs a post-effect recheck that replaces a known accepted result with an uncertain result.
  • Normalize retained resume arguments to admission-only execution. Keep explicit invalid resume timeout/watch requests rejected.
  • Include late channel-recovery failures in private replacement health without changing the public restored projection. Forward product-test cancellation to the existing managed child owner.

Impact

This is root-originating continuation only. A root send to a native child is supported; a native-originating send is still denied. Collector, cron, worker and remote-originating contexts remain unsupported and reject early.

Retention is process-local, not a durable restart queue. Stop does not claim to retract an already accepted send, and restart does not recover retained sends. There is no new configuration or public reload-status change.

Base integration

main was merged at a919e5ecc4f6c579e16ab21499ccda3acaa1fb07 in merge commit c8ab8cd64ff98cb17e65461b42bc2f6b64634d36 (tree aeec667762151057b95750de4f9f9f59e96d7dc4), joining the earlier PR head 5aff0439b5c2d0d5426d7ee1dfcbbce9b8ca97e7 (feature commit f239726aa340123954d1450d0873739776c29008, tree b59ba20c230b8fc111d55066e9c4fe75e69ca4da).

  • main was merged because the PR conflicted with it. Three paths conflicted: config/test-lines-baseline.txt, src/agents/tools/sessions-send-communication.ts and src/gateway/agent-turn/agent-run-admission-phase.ts. Both source conflicts come from refactor: resume running sessions after graceful restarts #185730, which removed the subagent terminalOwner field and restart-recovery admission. The resolution keeps those removals and every line this PR adds; it introduces no new behavior.
  • For 36 of the 37 PR paths, the lines added and removed relative to the new base match those relative to the old base. Seven of those files also changed on main, in separate hunks: attempt.ts, session-tool-handoff.ts, sessions-send-communication.ts, agent-run-admission-phase.ts, agent-run-admission-types.ts, agent-turn-service.ts and server-plugin-in-process-authority.ts. config/test-lines-baseline.txt now equals main's, so this PR no longer changes it.
  • Two independent reviews and a lead review accepted the resolution and found no conflict-resolution defect. One reviewer read the seven overlapping modules and the product test files whole; the other checked those modules only at the hunk level.

Static repair after merge CI

Source commit 979c83811135cd8c95d740a5cd93a6c6db5cfb6c (tree 5413b1353c838a274febc9dfc990a7caa8531970) was published as head 83c2faf2f75d372f31c396a5a1cee49b492d581c.

CI run 40795074130 tested the previous head 7595b27 merged into main at 71d954df153317e7ce83fbc0509be20405299258. It found these PR-caused failures, which 979c838 addresses without behavior changes:

  • 12 TypeScript errors in this PR's files (check-prod-types, check-test-types*, declaration build, SDK boundary): a follow-up failure result without selfHeld, a replay-port result type, an untyped mutable refusal stage, a closure over a possibly undefined child, and test-only typing in attempt.sessions-yield.test.ts, sessions-send-self-hold.test.ts and server-plugin-reload-lifecycle.test.ts. The fixes are type-only, except that the follow-up failure now carries an explicit selfHeld: undefined. That path runs only after an accepted start, so it is never retained.
  • One import cycle (madge-import-cycles, 84 modules): agent-admission-refusal.ts imported agent-run-admission-types.ts for a type, closing a cycle through the agent tools. It now declares the two dispatch ports it uses locally. The runtime import-cycle check was already clean.
  • The assertion-safety ratchet flagged a new type assertion in agent-admission-refusal.ts; the typed refusal removes it.
  • The PR wrapper inventory omitted the new src/plugins/plugin-replacement-operation.ts, which failed eager-import-closure (2 tests) and pr-worktree-provision (3 tests). The file is now listed in scripts/pr-lib/wrapper-components.txt.

Local evidence for the repair:

  • Of the 12 type errors, only the 5 production sites were reproduced locally first, with the experimental oxlint --type-check diagnostic; the 7 test-type errors were seen only in CI. After the repair, that diagnostic reports no problems in all 36 changed TypeScript files. It is not the canonical type check: local pnpm tsgo:core still refuses its input before analysis ("Declaration input escapes checkout"), so canonical type and declaration analysis did not run locally.
  • pnpm check:madge-import-cycles reproduced the same 84-module cycle, then reports 0 cycles after the repair.
  • eager-import-closure passes 35/35. Of the three failing pr-worktree-provision cases, two pass locally and the third is skipped on macOS.
  • On the exact repaired tree, the self-hold suite passes 25/25. A supporting run with the same TypeScript source, before the inventory line was added, passed communication (47), requester continuation (11), reload lifecycle (14), attempt.sessions-yield (12), server.agent-late-admission (1) and sessions-send-reply-flow.requester (4). Formatting, diff, test-line (6,245,435 against 6,320,000) and assertion-safety checks pass.

Remaining CI failures on run 40795074130 that this PR does not cause, as far as the evidence shows:

  • Inherited from main: the mock-exports ratchet (its inputs are byte-identical to main), and server.channels-start-outcomes, server.approval-forwarding and server-startup-secret-owner-isolation, which fail with the same titles in scheduled main CI.
  • Probably inherited: subagent-registry "does not restore a superseded lifecycle after a successor is released" asserts gateway root work that fix: finish process-owned shutdown within its cleanup deadline #187090 removed on main. This PR touches neither file. Inferred, not reproduced on main.
  • Unclassified: server.context-prewarm.remote-proof measured 1,340 ms against a 500 ms budget.

CI run 40802305283 tested 83c2faf merged into main at 7074b619ff3087cb61d0825e3ff3457300ccb9ad. The canonical production and test type checks, declaration build, SDK boundary and import-cycle check passed there. Its remaining failures:

  • Test-line ratchet: 6,247,272 lines against a ceiling of 6,243,924; this PR adds 2,417. main had lowered the ceiling after this PR's base and has since restored it to 6,320,000 (chore: restore measured test-code headroom #187162). This PR does not change the ceiling; the next run passed against the restored ceiling.
  • Lint: a missing-braces error in sessions-send-tool.admission.test.ts, a file this PR does not change. It came from main (fix(agents): keep top-level Slack requests' sessions_send completions top-level #187065), also failed scheduled main CI, and is fixed on main (fix: restore lint compliance in sessions-send admission tests #187144).
  • Unclassified: server.context-prewarm.remote-proof failed again (844 ms; 1,340 ms on the previous head). Its 500 ms budget is the largest gap between 20 ms heartbeat callbacks during the post-ready warmup window, not warmup or request latency. The test and the four core modules it exercises are identical on this PR, its CI base and the CI merge, and no causal path from this PR is established; it is also not shown to be inherited.

Revocation proof

Current head: b31e43ac536d40585d28e19bc6c9a29131ca87ce, an empty publication bookkeeping commit on test commit 20068cd16f0fba183851189a7782e60f1b1029eb. Tree: 20b00d8a25926d85ae091dadec0b210d38ec62d4. CI run 40808307564 passed on this head, merged into main at 960debc51780c899df913ea2ddf3cf971a80ea02.

The new product test server.plugin-reload-send-revocation.product.test.ts answers the earlier review's request for end-to-end proof that revoking the selected participant during a retained replay prevents the target effect. It runs a real Gateway with trusted-proxy TLS and two paired operator devices, Alice and Bob, in a shared session; Bob joins through the real session.members.add RPC. No authority, participant or executor is mocked.

  1. Alice's turn holds the reloading plugin. Bob's steer joins her running turn, and the model selects Bob as the sessions_send user only after it has seen that steer.
  2. Admission refuses the send because the turn holds the reloading plugin, so it is retained with not_accepted / plugin_reload_self_hold. The healthy replacement then replays it once with the same idempotency key.
  3. A pass-through spy on the Gateway transport arms only on that retained receipt and fires exactly once, after the root turn has ended and the replacement has settled. It records state only and does not decide the outcome.

Results:

  • Bob allowed (control): one target effect, one target transcript receipt and one settlement wake in Alice's conversation; no undelivered notice.
  • Bob revoked: in the barrier, a real device.token.revoke revokes Bob's device and his own next request is refused. The replay is then refused by the retained Gateway continuation, whose captured authority is Bob's: the outcome is error with "Gateway continuation authority is no longer active". That check fires earlier than agent admission. The target receives no model request, provider effect or transcript receipt for the message. Because the settlement wake runs under the same revoked source, Alice gets no model wake; the host writes exactly one durable "could not continue this conversation automatically" notice to her conversation instead. Alice's own authority still works.
  • In both cases there is one original send and no accepted retry, plugin retention returns to 0, target pending inputs are empty, and the managed child process tree is joined.

Each case needs a real Gateway, model fixture, plugin reload, two TLS operator clients and a real revocation, which is why the cases take tens of seconds rather than using callback ports. The test keeps the default 120,000 ms budget, binds private handoff stores before imports, and reuses a small plugin fixture helper extracted from the existing product test without changing its behavior. Two independent reviews and a lead review accepted the proof tree.

Evidence

  • Exact-head CI passed. Run 40808307564 on b31e43a completed successfully and openclaw/ci-gate passed, including canonical production and test type checks, the declaration build, SDK boundary, import-cycle checks, duplicates (no test clones), lint and ratchets (6,249,477 test lines against a ceiling of 6,320,170). Under Bun, the new revocation test passed in 64 s with the same oracles as locally (allowed: one effect, one wake, outcome accepted; revoked through device.token.revoke: no effects, no target model requests, no wakes, one notice, outcome error). The existing three-case test passed in 74 s (effects 1, 1 and 0; one wake each), and server.context-prewarm.remote-proof passed in 12 s. CI did not run these product tests under Node.
  • On the proof tree, normal wrapper runs pass locally: the existing three-case test in 89.6 s (Node) and 104.4 s (Bun), and the new two-case revocation test in 90.3 s (Node) and 81.9 s (Bun). Earlier, on a heavily loaded host, the existing test had timed out at 120,000 ms on the merged tree under both runtimes; no timeout was changed.

Historical evidence for the reviewed feature tree b59ba20, before the merge. Reviewed change snapshot: 062aafd6dbe1d6c25f4696b7e84b609e499ae3c2d53ada981b4c59f2a5005281 (binary diff SHA-256 from base 228596060e33dfcddbb6740416f381daac6f84fe).

  • The 97 focused tests passed. Late channel failure and newly enabled sandbox denial have failing-before/passing-after evidence. Removing only retained-resume normalization reproduces the real admission-only rejection; restoring it passes the real-factory default-resume case. Explicit invalid resume controls remain rejected.
  • Same-config regression barriers remove a per-session sandbox opt-out through the real durable or memory storage owner. Preparation and pre-executor changes refuse with zero executor calls; a change at the executor’s final source check has zero effects and retains the conservative uncertain status. Five original causal failures pass, including preservation of a known result after an accepted effect. A no-change positive and a newly sandboxed-but-allowed row verify one replay and the executor sandbox flag. Handoff and executor are explicit unit-test ports; these are not sessions.patch RPC tests.
  • Local ClawSweeper was unavailable in this environment. The selected maintainer fallback is local AutoReview plus one hosted ClawSweeper review.
  • Local AutoReview: one actual run, P0–P3, INCOMPLETE (exit 2), not a clean review. It reviewed the old base against prior local snapshot 660111f3b78ffa52dc495d82c7854912436af127dfd74e2dcba80bc1b9d7cfab, with 37 changed full-file bodies and 62 unchanged contracts. All 24 partition reports returned, but that is not 24 complete assessments: required caller/full-body context was not guaranteed to accompany each assigned change.
  • All six review findings are accounted for. Four (API1, API3, API5 and API6) are implemented: late recovery health, current sandbox classification, retained resume normalization and product-child cancellation. Two (API2 and API4) concerned historical index-only variants at 381e0ec3d153c5f02063ea21622b753de8c60fda and were replaced in the committed candidate. They were valid findings, not false positives.
  • Independent A/B affected verification of snapshot 062aafd6 passed with no findings, and lead review accepted tree b59ba20. Independent and lead reviews of the static repair tree 5413b13 found no code defects; a reviewer's correction to the evidence wording is reflected here.

Gaps

  • ClawSweeper re-reviewed head b31e43a: ready for maintainer review, with no findings. Its remaining test note is that a complete Gateway scenario failing on the merge base is not shown; the failing-before evidence above comes from focused tests, not that scenario.
  • server.context-prewarm.remote-proof passed on this head, and passed in isolated runs at both the earlier CI merge and its base. The heartbeat gaps it measured in the two earlier CI runs (1,340 ms and 844 ms) remain unexplained.
  • CI ran the normal product tests only under Bun; the Node runs above are local.
  • Historical, not current evidence: local pnpm tsgo:core refused its input before analysis, and the one local AutoReview is INCOMPLETE and covers neither the merge nor the later commits.
  • The late channel-recovery producer alias is statically reviewed and lifecycle health is unit-tested. The real channel-recovery producer wiring is not exercised by a failing-channel fixture.
  • Native Windows runtime proof is unrun. Existing Windows ownership/prequalification coverage is not a native Windows product run.
  • Combined Gateway plus attempt/CodeMode completion-cohort behavior is not proved by the separate boundary tests. These gaps are disclosed, not waived.

@clawsweeper

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

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime agents Agent runtime and tooling size: XL labels Oct 28, 2026
@github-actions

github-actions Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components.

No secops approval is required. This comment is informational because the PR author has Maintain or Admin access.

  • Current SHA: b31e43ac536d40585d28e19bc6c9a29131ca87ce
  • Maintainer: @fuller-stack-dev
  • Repository role: maintain

These security sensitive changes were made:

  • src/gateway/server-plugin-in-process-authority.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.

Carefully review these changes before merging.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 28, 2026
@clawsweeper

clawsweeper Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR retains a session send refused during plugin reload and submits it once after turn cleanup and a healthy replacement outcome.

Example: Alice’s root turn holds send-continuation-proof while sending ORIGINAL-CONTINUATION-91ce to its paused child.

  • Before: Admission refuses the send, leaving the child without the continuation.
  • After: The original send is retained and submitted once after cleanup; failed replacement prevents delivery.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Useful repair with no actionable correctness finding and meaningful production-owner coverage; evidence remains a source-run Gateway harness with synthetic model HTTP rather than a packaged entry-point demonstration.
Proof confidence 🦐 gold shrimp (3/6) Sufficient (live_output): The inspected production-path Gateway harness and reported Node/Bun runs cover allowed replay, failed replacement and actual selected-device revocation before replay. The revoked case records zero target requests, effects and transcript receipts, while the allowed control records one effect and one settlement wake; this satisfies the previous authority-chain request without treating callback-only tests as proof.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A session’s intended message can disappear when plugin reload admission refuses it while the sending turn holds the plugin.
Reason: The maintainer-approved direction restores a concrete workflow without new configuration, durable queues or broader caller privileges.

Merge readiness

✅ Ready for maintainer review

Keep this maintainer-authored PR open: it repairs a current send-loss path, and no actionable patch defect was found. The new revocation scenario addresses the previous review’s authority concern; exact-head CI remains pending.

Priority: P2
Reviewed head: b31e43ac536d40585d28e19bc6c9a29131ca87ce

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: Focused causal red/green checks are reported, but a complete Gateway scenario failing on the merge base is not shown.
Agent review details

How this fits together

Session tools submit messages through Gateway admission, which acquires plugin-backed model runtimes; the existing handoff owner carries refused sends across turn cleanup and returns their outcomes to the requesting conversation.

flowchart TD
  A[Root session send] --> B[Gateway admission]
  B --> C[Private nonacceptance receipt]
  C --> D[Existing turn handoff]
  D --> E[Exact reload outcome]
  E --> F[Current authority and policy checks]
  F --> B
  B --> G[Target input and completion]
Loading

Technical review

Best possible solution:

Preserve the deadlock refusal and retain only demonstrably unaccepted sends through the existing handoff, executor, authority and reload owners.

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

Current-main source exposes the refusal-before-acceptance path and the executor’s terminal error return; the submitted Gateway scenarios exercise that overlap, but this read-only review ran no reproduction.

Is this the best way to solve the issue?

The change preserves the intentional deadlock guard and reuses one send executor and the existing handoff rather than asking the model to reconstruct or retry a possibly accepted operation.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Self-held model-runtime admission keeps the original intent (a718c1c: Reject work whose wait would deadlock the reload draining that same work.)
  • Reload finalization and recovery keeps the original intent (b5134de: Keep preparation, drain, publication and retirement under Gateway-owned reload lifecycle control.)
  • Recovery resource ownership keeps the original intent (967a868: Complete predecessor cleanup before replacement ownership, restoring captured prior code only when cleanup permits.)
  • Session-tool handoff authority keeps the original intent (7c9cb97: Retain bounded source authority across turn cleanup while preserving normal Gateway authorization and revocation.)
  • Paused-child resume keeps the original intent (0f28bcd: Resume the existing task without creating a competing completion owner.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

PR surface

Source +959, Tests +3293, Other +1. Total +4253 across 40 files. Added test files: 9.

View PR surface stats
Area Files Added Removed Net
Source 26 2232 1273 +959
Tests 13 3363 70 +3293
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 0 +1
Total 40 5596 1343 +4253

Labels

Label changes:

  • add P2: A specific overlap between a root session send and plugin reload loses intended work, with limited blast radius.
  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: A specific overlap between a root session send and plugin reload loses intended work, with limited blast radius.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • 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 (1 earlier review cycle)
  • reviewed 2026-10-29T00:03:26.050Z sha 5aff043 :: needs real behavior proof before merge. :: none

Reviewed October 28, 2026, 10:56 PM ET / October 29, 2026, 02:56 UTC (Revision 2).

# Conflicts:
#	config/test-lines-baseline.txt
#	src/agents/tools/sessions-send-communication.ts
#	src/gateway/agent-turn/agent-run-admission-phase.ts
OpenClaw-Publication: 61346614-9ff7-464b-a586-63e3237b2d45
OpenClaw-Publication: dafc7126-ecd3-4e4f-b608-3f19253ba72c
@openclaw-barnacle openclaw-barnacle Bot added the scripts Repository scripts label Oct 29, 2026
@fuller-stack-dev

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 29, 2026
@fuller-stack-dev
fuller-stack-dev merged commit bca8823 into main Oct 29, 2026
200 checks passed
@fuller-stack-dev
fuller-stack-dev deleted the openclaw/plaid-shell branch October 29, 2026 05:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling gateway Gateway runtime P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. scripts Repository scripts security-sensitive-changed size: XL 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