Repository navigation
refactor(plugins): settle native session bindings in the executing worker (compound 2a) - #164391
Conversation
Preserve reversible shared-state deletion before the agent commit, separate settlement receipts, conditional compensation, and unresolved generation custody. Keep released native adapters and message-cut transactions on their existing contracts.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Codex review: blocked before merge. Reviewed October 3, 2026, 12:48 PM ET / 16:48 UTC (Revision 3). ClawSweeper reviewWhat this changesMoves durable native-session binding deletion and conditional restoration into the executing database worker, while preserving synchronous plugin callbacks and cleanup after acknowledged session commits. Merge readiness⛔ Blocked before merge - 5 items remain This work remains necessary and has no newly identified correctness or security findings. The previous packaged-worker and released-plugin compatibility blockers remain unresolved; the latest fixture repair does not complete those checks. Priority: P2 Review scores
Verification
How this fits togetherNative-session bindings connect OpenClaw conversations to backend sessions such as Codex threads. Session deletion coordinates their shared-state records with the agent database, then publishes deletion and releases native resources. flowchart TD
A[Session deletion request] --> B[Prepare bindings and live authority]
B --> C[Executing database worker]
C --> D[Delete shared binding]
D --> E[Commit agent deletion]
E --> F[Publish deletion and release resources]
E --> G[Conditional binding restoration]
C --> H[Fence unknown outcomes]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +1403, Tests +1331, Docs +15, Other +2. Total +2751 across 55 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep the single worker settlement owner and retained public callback contract, with completed packaged-worker, released-plugin, and upgrade evidence before landing. Do we have a high-confidence way to reproduce the issue? Not applicable as a refactor: current-main source confirms the native deletion route still runs in process, and the submitted boundary evidence measures the intended worker cutover. No tests were executed during this read-only review. Is this the best way to solve the issue? Yes, the worker participant preserves the existing deletion owner and released callback contract without adding a competing storage service; packaged and upgrade validation remain necessary. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 4ed742a52184. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (2 earlier review cycles) |
Keep the canonical persisted parser and service-tier normalizer in pure plugin modules so source-only workers can load them. Preserve public callbacks and conditional settlement behavior, reuse the canonical database identity type, and give the registration fixture an accurate shared native handle. Remove redundant private re-exports and clarify native deletion ownership.
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
The host connection TEMP trigger cannot reject deletion on a separate worker connection. Refuse the real final agent commit through the existing admission hook and assert that the injection fired, preserving all initialization and binding rollback assertions.
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Merged via squash.
|
…rker (compound 2a) (openclaw#164391) * refactor(plugins): settle native bindings in the executing worker Preserve reversible shared-state deletion before the agent commit, separate settlement receipts, conditional compensation, and unresolved generation custody. Keep released native adapters and message-cut transactions on their existing contracts. * fix(codex): load native binding codecs without host SDK imports Keep the canonical persisted parser and service-tier normalizer in pure plugin modules so source-only workers can load them. Preserve public callbacks and conditional settlement behavior, reuse the canonical database identity type, and give the registration fixture an accurate shared native handle. Remove redundant private re-exports and clarify native deletion ownership. * test(codex): inject rollback failure at the worker commit boundary The host connection TEMP trigger cannot reject deletion on a separate worker connection. Refuse the real final agent commit through the existing admission hook and assert that the injection fired, preserving all initialization and binding rollback assertions.
What Problem This Solves
Durable session deletion still performs Codex and Agents API binding deletion and compensation on the Gateway thread. Those reversible precommit writes must veto the agent transaction on failure and conditionally restore the removed binding after a known rollback.
User Impact
Binding deletion and compensation now execute in the existing agent database worker. There is no intended change to session deletion, stored bytes, schema, retention, durability, configuration, or migrations. Released synchronous plugin callbacks retain their contract. The existing cross-database crash window remains; unknown outcomes block the affected generation without replay.
Why This Change Was Made
Use a typed native-binding participant over the existing connection-bound plugin-state kernel and captured physical store identity. Preserve separate shared-state (S) and agent (A) receipts, S-before-A ordering, current authority at transaction and commit grants, conditional exact-row restoration, and error-class identity. Quiesce renewal at readiness and join accepted renewal before transaction entry. Only an acknowledged A commit permits initialization publication and native cleanup; accepted work settles before workers close.
Canonical codecs come from the loaded plugin owner, including separately installed Codex packages. The Codex codec is a pure plugin module so clean compiled workers do not import host SDK runtime. The durable descendant basis is rechecked after the final host grant.
Builds on #163889, #163930, and #164197. Acquisition, renewal/release ownership, initiating lineage, and exact physical-client authority retain their existing owners. Personally verified sibling Codex HEAD
ade0ccacf9182e665cf784de041c51a79e35bc31:codex-rs/app-server/src/request_processors/thread_processor.rs:1011–1037takes the initiating connection ID and unsubscribes that connection only.Fork, rewind, and branch transactions remain out of scope.
withSqliteSessionDeletionWorkerParticipantis the extension point for compound 2b after the product decision on #162287.Evidence
Final candidate:
903173e5253609f743bf82f7a0451257b45a7253; tree:e1425c48ccd4b2c496db58935fbf52242b9834a0.OPENCLAW_*names.node scripts/check-changed.mjs --base b94391aa2c5a6e248ea60848cee6394759187f94passed after frozen dependency hydration: core/extension production and test typechecks, lint, guards, and zero import cycles. Final test-only repair additionally passed its full file, focused lint, and P2 review.2026-10-03T16:48:27.570Zwith no new correctness/security findings; its outstanding compatibility evidence is recorded here.Clean source-only verification used exact final-head checkouts with no built SDK artifact, preventing the original codec-loading failure from being masked:
pnpm test <file> --maxWorkers=1)The final native-binding suites also passed 22 tests in 67.85s on a clean Linux Blacksmith Testbox, lease
tbx_01m41aacgmp2xs8v38sf53zm6z, with the candidate SHA and complete tree verified before execution. The final initializer fixture also passed locally in 79.99s. Landing repairs add no test cases, waits, retries, or process boots.Released SDK and update compatibility
pnpm plugin-sdk:api:diff -- --base v2026.9.8 --head 903173e5253609f743bf82f7a0451257b45a7253completed. Baseline declaration render: 108.203s; candidate render: 129.734s. Report digest:fa2a9969eaade5178f6acb332bd15c90835e7f988a021d8f8c5e23671b66f0a8.The release-to-current-main report includes unrelated evolution: all eight removed subpaths were already absent at pinned PR base
b94391aa2c5a6e248ea60848cee6394759187f94. This PR changes neither package export inventory norapi.runtimetype ownership. There are no named report differences forAgentHarnessSessionDeletionMutation, keyed-store contracts, orPluginStateStoreError. The releasedcommit(): void/rollback(): voiddefinition and the extracted public error definition are unchanged. Internal worker signatures may change; the lifecycle codec option and private SDK helpers are additive. No released signature is deprecated or broken by this PR.The final package built in 7m58.5s and passed tarball integrity. Packaged build-info identifies exactly
903173e5253609f743bf82f7a0451257b45a7253; tarball SHA-256:75f62d23a082454ff63d4c7d7f0ff32cf9a826debb9d35a0b7b8ca91f85e9175.Final update precondition passed: the published
2026.9.8driver installed this exact candidate, with update exit 0 in 170.503s, recorded phase finished,/readyz200, and the serving build ID verified against the packaged candidate build ID (903173e52536). The wrapper recorded the exact source tree, exit 0, andsettled=true; total remote proof was 22m20.287s. All owned leases are stopped. Packaging repeated the prior UI startup-gzip warning (373,673 B versus 373,454 B); this PR changes no UI or performance baseline, and package integrity and update proof passed.Simplification and retained contracts
The host settlement module owns live authority, renewal, receipt acknowledgement, and unresolved native custody. The worker module owns A/S transactions and conditional compensation. The participant registry carries those facts through existing callbacks; lightweight transfer types and plugin-owned codecs keep the worker import boundary small.
The synchronous deletion/comparison/restoration path remains for the released opaque callback contract (
v2026.9.8src/plugin-sdk/agent-harness-runtime.ts:113andsrc/agents/harness/types.ts:490), incognito, and message-cut ownership. Branded bundled participants select worker settlement for durable entry deletion. The JavaScript-only lifecycle subpath is private, not a third-party SDK contract. Bothnative-session-binding.test-api.tsfixtures are excluded from production runtime entries by the delimited test-name filter inscripts/lib/bundled-plugin-build-entries.mjs.The duplicate participant identity shape was replaced with
DatabasePathIdentity, removing five production lines. Necessary codec isolation and redundant private-export cleanup contribute +22 net. Against the same pinned merge base, approved-head production was +1,489 / −203 / net +1,286; final production is +1,892 / −589 / net +1,303. Remaining growth implements separate receipts, compensation, and retained custody rather than a competing storage owner. Tests/support: +1,435 / −4; docs: +18 / −3; tooling: +2 / −0.Retained pre-existing host authority-read debt: current session at
src/gateway/server-methods/sessions-delete.ts:162; placement retirement atsrc/gateway/worker-environments/session-placement-lifecycle.ts:190throughsrc/gateway/worker-environments/placement-store.ts:248; drain turn claims atsrc/gateway/server-methods/sessions-lifecycle-drain.ts:103; shared ownership admission atsrc/state/openclaw-state-ownership.ts:126. These bounded reads keep other owners' revocation checks live inside grants; binding deletion/restoration SQL is worker-owned.CI failure attribution and repairs
Original CI failures were PR-caused: the Codex codec imported host SDK runtime from a compiled worker, the registration fixture omitted the shared native handle, and the new test namespace exposed an unused private type re-export. Each of the three original failing files reproduced its CI failures in five runs and passed five times on the untouched merge base. The codec failure also explains the initialization and descendant rollback failures. Repair:
315baa19e12f205517830e50a6a6a04e75dcf0c2.After that repair, CI exposed two initialization cases whose host TEMP trigger no longer reached the worker connection. Five predecessor runs reproduced exactly 2 failures / 19 passes. The final fixture rejects the actual final A commit through the existing admission hook and asserts the injection fired, preserving every entry, binding, and cleanup assertion. Repair:
903173e5253609f743bf82f7a0451257b45a7253. The PR-context template heading was corrected separately. A local lint compile interrupted by newly created Testbox metadata passed after inputs stabilized; no scanner or guard was weakened.Overlap: #163833 shares the deletion module;
withSqliteSessionMutationsremains unchanged. #164278/#164286 are incidental cleanup. #161609 is separate Agents API executor cleanup; preserve settle/retire-before-run ordering when combined. #162433 is the permitted inactive umbrella draft. No fork-at-message implementation from #162287 is included.