Repository navigation
feat(plugin-sdk): add worker-owned conversation binding APIs - #168483
Conversation
Plugin state callbacks can perform SQLite work on the Gateway thread, including APIs that return a Promise. Plugin authors gain a versioned worker-owned keyed store; existing synchronous and callback APIs keep their completion semantics through the current Plugin SDK major.
Native session bindings still expose host-thread persistence and synchronous preparation through harness adapters. Native binding preparation and ordinary lifecycle mutations can complete through the worker while released synchronous integrations remain supported.
Conversation presentation and capture read native ownership on the Gateway thread even when their callers can await prepared facts. Session rows and conversation capture retain their existing meaning while ordinary ownership preparation runs through workers.
Channel account inspection, setup and status can read persisted plugin state synchronously on the Gateway thread. Channels can prepare saved-account state asynchronously without losing configured-account, saved-login or explicit report-scope behavior.
Command authorization and approval routing can force channel persistence reads onto the Gateway thread. Command and approval preparation can await persisted channel state while retaining current authorization at dispatch and delivery.
Conversation binding APIs include synchronous writes and reads that prune state, and existing async methods can fall back to synchronous adapters. Plugin authors gain a V2 binding contract with required async operations and coherent source assertions; released structural adapters remain compatible.
|
Landing under Peter's relaxed landing v4. Main is integrated; final conflict-only correction preserves current main's memory/plugin-state owners and the prior SDK alias removal outside this part's own changes. No limits or budgets were increased. Exact-head remote proof: AWS Crabbox run_58c994d923df501af6b933925e9c9416, 51 tests passed across current-conversation worker bindings, async session-binding reads, and account-scoped conversation bindings (36.85s). Prior coordinator review/build proof is reused; these pushes only reconcile the integration. The known SDK export-budget policy excess from the preceding part remains a follow-up, not a claimed green gate. Reusing published-driver 2026.9.9 × candidate update proof from #168478, run_3d6590a7c9c48b16a12382d7e111cda1, as directed for intermediate PRs. Required CI is observed separately; the explicit native-stall fallback applies after ten minutes, with the final head pinned and any native submission reconciled first. |
Keep the committed-observation cache lint clean and document the explicit Worker receiver used by the race fixture. Account exactly for the intended async approval/command and V2 conversation binding APIs from #168480 and #168483; retain their released compatibility contracts. Validation: exact core oxlint, core tsgo, export-name collision guard, SDK surface check, formatting and diff checks pass. Focused Node tests: 74 passed, one platform skip across six files (82.64s total); plugin-state comparison 14 passed in 21.52s including preparation. Codex review found no actionable issues.
Account exactly for the Discord async session listing from #168483 and Matrix's two async binding timeout setters from #168485. Both migrations intentionally retain the synchronous exports. Preserve every runtime surface classification and exact export-list assertion. Linux proof: the unchanged guard fails on the new Discord export; the candidate passes all seven cases. pnpm test src/plugins/contracts/plugin-sdk-runtime-api-guardrails.test.ts --maxWorkers=1 took 16.38s. Full plugin contract command: 1,149 tests across 48 files in 88.20s. SDK surface report: six tests passed, already repaired by f9940dc and 7562fd2. P2 review is clean. Changed checks, owning test types, formatting, core and boundary lint pass. check-changed retains one independently reproduced base failure: Knip flags GatewayApprovalEventPublisherV2 in untouched Gateway code.
…w#168483) * refactor(plugin-sdk): share legacy persistence warning budgets * feat(plugin-sdk): add worker-owned keyed state Plugin state callbacks can perform SQLite work on the Gateway thread, including APIs that return a Promise. Plugin authors gain a versioned worker-owned keyed store; existing synchronous and callback APIs keep their completion semantics through the current Plugin SDK major. * refactor: move native binding preparation to workers Native session bindings still expose host-thread persistence and synchronous preparation through harness adapters. Native binding preparation and ordinary lifecycle mutations can complete through the worker while released synchronous integrations remain supported. * refactor: prepare conversation ownership off the Gateway thread Conversation presentation and capture read native ownership on the Gateway thread even when their callers can await prepared facts. Session rows and conversation capture retain their existing meaning while ordinary ownership preparation runs through workers. * refactor: resolve persisted channel accounts asynchronously Channel account inspection, setup and status can read persisted plugin state synchronously on the Gateway thread. Channels can prepare saved-account state asynchronously without losing configured-account, saved-login or explicit report-scope behavior. * refactor: prepare command and approval eligibility asynchronously Command authorization and approval routing can force channel persistence reads onto the Gateway thread. Command and approval preparation can await persisted channel state while retaining current authorization at dispatch and delivery. * feat(plugin-sdk): add worker-owned conversation binding APIs Conversation binding APIs include synchronous writes and reads that prune state, and existing async methods can fall back to synchronous adapters. Plugin authors gain a V2 binding contract with required async operations and coherent source assertions; released structural adapters remain compatible. * test: bind native lease fixtures to V2 action authority * test: await channel setup registry fixtures * test: complete keyed state runtime fixture * test: align Matrix recovery and channel target fixtures * test: retain approval replay subscriber across async eligibility * test: implement async listing in ACP binding fixture * refactor(plugin-state): separate offline migration entrypoints * refactor(codex): share binding helpers and contract fixtures * refactor: separate session row preparation and publications * refactor: share channel lifecycle and test helpers * refactor: colocate approval expiry observation * refactor(slack): colocate action summary formatting * test: synchronize approval client startup race * test: retain async status discovery arguments * test(codex): model current conversation inspection boundary * test(facetime): bind persistence barriers before runtime startup * fix(slack): resolve bound parent before thread fallback * docs: explain validated discussion account config * test: exercise native binding lifecycle through worker settlement * test: document isolated runtime dependencies * test: document isolated runtime dependencies * test: document isolated runtime dependencies * fix: preserve native binding method receivers * fix: bind model preparation authority to its reader * style: resolve approval runtime lint findings * style: keep Discord route reassignment local * chore: regenerate worker and test guard baselines * chore: regenerate worker and test guard baselines * chore: reconcile worker migration baselines * chore: reconcile async approval SDK baselines * chore: record versioned binding SDK surface * test: run native row ownership with the host broker * fix: include async approval caller in its migration * fix(plugin-sdk): preserve synchronous approval publication Add an awaited publisher companion while preserving numeric synchronous delivery and legacy publisher objects. Refuse async-only eligibility before legacy delivery and keep rejected preparation observed. Bundled approval dispatch selects the new method before publication. * chore: regenerate approval assertion baseline * fix(clickclack): fence discussion cleanup and reconciliation * test(clickclack): avoid shadowing store options * chore: retain current main owners in stack integration
Keep the committed-observation cache lint clean and document the explicit Worker receiver used by the race fixture. Account exactly for the intended async approval/command and V2 conversation binding APIs from openclaw#168480 and openclaw#168483; retain their released compatibility contracts. Validation: exact core oxlint, core tsgo, export-name collision guard, SDK surface check, formatting and diff checks pass. Focused Node tests: 74 passed, one platform skip across six files (82.64s total); plugin-state comparison 14 passed in 21.52s including preparation. Codex review found no actionable issues.
The async approval/command migration is openclaw#168482 (36a5eef), correcting the preceding commit message reference to openclaw#168480. The conversation migration is openclaw#168483 (fe8bc06). Record both at their source-owned budgets.
Account exactly for the Discord async session listing from openclaw#168483 and Matrix's two async binding timeout setters from openclaw#168485. Both migrations intentionally retain the synchronous exports. Preserve every runtime surface classification and exact export-list assertion. Linux proof: the unchanged guard fails on the new Discord export; the candidate passes all seven cases. pnpm test src/plugins/contracts/plugin-sdk-runtime-api-guardrails.test.ts --maxWorkers=1 took 16.38s. Full plugin contract command: 1,149 tests across 48 files in 88.20s. SDK surface report: six tests passed, already repaired by 69da208 and b999946. P2 review is clean. Changed checks, owning test types, formatting, core and boundary lint pass. check-changed retains one independently reproduced base failure: Knip flags GatewayApprovalEventPublisherV2 in untouched Gateway code.
…c-reply-anchor Resolves the import conflict with openclaw#168483, which added the thread-bindings import next to this branch's threading adapter import; both imports are kept. The fix itself is unchanged.
What Problem This Solves
Conversation binding APIs include synchronous writes and reads that prune state, and existing async methods can fall back to synchronous adapters.
User Impact
Plugin authors gain a V2 binding contract with required async operations and coherent source assertions; released structural adapters remain compatible.
Released synchronous binding forms are deprecated with named replacements and next-major removal. Their old completion behavior remains available to compatibility consumers. This change does not remove the later-stage final authority guards.
Why This Change Was Made
Adds the V2 session-binding service, adapter and account manager, then migrates bundled Discord, Feishu, iMessage, Slack and Telegram bindings and routing. Source assertions run after the final awaited preparation. The account manager routes pruning lookups and mutations through the existing worker.
This is part 6 of the nine-part S7 state/binding migration stack. Targets
dbasync/sw7b-5(parent PR); validation compares this part with its actual stack parentc12020afa3d6. The stack integrates pinned main413d5f9bb3f7.Evidence
Changed lines against the parent: production +940 / -287; tests and fixtures +243 / -91.
Focused integrated receipts cover worker binding lifecycle, V2/V1 adapter selection, and Slack/Telegram route preparation: 307 passed, 0 skipped, mapped to 14/14 changed test files. These are recorded integrated file versions, not independent runs of every prefix; per-part counts are not additive. Stack totals are 3,296 passing receipts, 3,295 after removing one known relocation duplicate, and three skipped cases across 177 files; no required focused file remains missing.
Recorded file spans total 103.387s. The relevant repaired integration batch took 496.047s wall time for 22 files; that is not a standalone timing for this part. File spans and invocation wall times are distinct; CI runner seconds were not measured.
Owner-reviewed native SDK digest:
a71d3fd8807c1e291ea95c815b1148b13a7efa1243f2f17b774440ea5d4eb9f7. Zero released export removals; the digest reconciles to this parent/head through the generated-only baseline change. The V2 return adds listBySessionAsync while retaining existing methods and results.The S7 family audit at c3667d2 resolved 18,862 inputs, 1,766 calls, 521 imports and 78 member references: 153 explicitly classified retained edges, zero unknown edges or async-contract errors. The publisher repair changed five scanned modules containing none of those captured family edges; retained-edge sources stayed unchanged. Final source differs from the passing repair head only by its generated assertion baseline. This preserves the original scan provenance rather than claiming a new full scan.
Core and extension production typechecks passed for all nine source prefixes; the final generated-only assertion-baseline adjustment does not change their code. The selected check-changed commands were executed, with the inherited failures below preserved.
Inherited failures remain explicit: Knip flags
.github/actions/setup-release-harness/narrow-lockfile.mjsandsrc/infra/sqlite-source-fence-admission.ts; the production export scan flagsPUBLIC_SESSION_ENTRY_SCRIPT; core lint has 10 unchanged max-lines findings; the environment-name count is 456/455, including unchangedOPENCLAW_PITCH. Relevant source/config blobs equal the pinned base. No blanket check-changed-green claim is made.Three scoped review rounds completed. Accepted correctness findings were repaired; remaining scoped follow-ups are recorded in the relevant PR descriptions.
Final repair checks passed at
4b7d96b620ea: scoped lint (30.02 s), affected test types (342.12 s), import-cycle guard (23.46 s), and Madge (14.91 s).Exact-final remote pnpm build passed in 369.642s. The qualified Matrix cold-import snapshot measured 104.992 MiB peak RSS, +58.199 MiB versus the empty baseline, and 383.791ms process CPU. Child/process-group cleanup and temporary-home removal were verified. This is a cold-import snapshot; the dependency closure is not attested. Statement-gate evidence follows separately; the update cell remains pending for the lander.
Statement gate: paired phases, attribution and supplemental samples
The gate uses the prespecified three alternating parent/head pairs on the same host. All phase durations are valid (candidate/base median ratio ≤1.5). Each adjacent edge shares its intermediate-prefix samples with the next edge. The table below reports primary medians; fourth-pair and cumulative results are retained separately for transparency. The fourth sweep was run for part 9's required RAW follow-up, not to replace these primary comparisons.
The first P4 workload completed successfully but its aggregation initially lacked a proof helper. Restoring the existing helper produced the identical summary hash; no workload was repeated. The later controller stopped before P6's fifth workload after P4/P5 had already completed incidental fifth samples. Those incidental samples are not substituted into the primary series.
The warmed increase is +3.4 SQL/turn (+0.338%), within the ≤0.5% unchanged-owner tolerance. Exact total-median samples are P5 run 1 and P6 run 2: 10059→10093 statements over ten turns. MAIN first/warmed counts are unchanged.
Corpus requests remain six: the difference is 20 schema/temp-cache initialization statements plus three repetitions of five existing metadata/row/participant/cache reads under
session-accessor.sqlite-entry-cache, revision and list readers. Patch commits remain 110; background row reads decrease 64→60. The changed binding-service sender still issues 40 resolves / 120 SQL on both sides; approval reads remain 20 / 40. Every native SQL-producing stack across the first four paired samples is outside this part's changed files.Non-turn increases also come from unchanged owners: boot +5 is four schema/version/admission statements and one metadata read; connect +4 reconciles entry inventory −24, media +9, cron schedule +7, plugin sweep +5, images +6, cron load +3 and native reads −2; second session +3 is read/cache/projection variation with unchanged mutation counts. Each is within ten statements. The original and cumulative whole-workload increases remain visible; they are not claimed as savings.
The published-driver × candidate update cell is pending (lander). No release, package publication or Plugin SDK major bump is included.