Repository navigation
refactor: resolve persisted channel accounts asynchronously - #168481
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.
|
Landing under Peter's relaxed landing v4 and native-stall exception. Final head: 0804ef8. Merged current main, preserving the earlier stack repairs and async channel account/credential hooks. The SDK surface check exposed one extra public alias; removed that unused newly introduced alias while preserving the existing ChannelApprovalAdapter.nativeAsync contract. Independent P0/P1 review of this one-line fix is scoped-clean. The public-export budget remains unchanged at 3656. Reuse published-driver 2026.9.9 × candidate update proof from #168478, run_3d6590a7c9c48b16a12382d7e111cda1, per the stack instruction. Exact-head SDK surface result is recorded below before submission. Required CI was still pending at the last observation; no green CI claim. Native review traversal exceeded ten minutes, encountered damaged worktree metadata, then needed refresh after the small fix; using the explicitly authorized head-pinned REST squash route. No pending native merge request was submitted. Other non-data/security/money review findings remain follow-ups under v4. Exact-head remote check passed: |
#168481 added an async resolveChannelDmPolicy to account-resolution.ts next to the SDK-exported resolveChannelDmPolicy in dm-access.ts, so check-source-contracts failed on every pull request with an export-name collision (main pushes skip that job). Rename the internal plugin-facing resolver to resolvePluginDmPolicy, the alias channel-pairing already used.
Finish the failures reported by scheduled run 38095292949 after the async channel-account, approval, and plugin-state campaigns (#168481, #168482, forwarding to its receiver, and supply the async status report in the install compensation fixture. Preserve the separately landed core DM resolver and observation-cache lint fixes when rebasing onto current main. Remove unused new async exports and duplicate broad-barrel re-exports. Migrate bundled consumers to the existing narrow SDK entrypoints and keep Discord's plugin-local async binding lookup out of its runtime API. The remaining five callable/export budget additions are intentional sync-to-async replacement pairs, retaining each shipped sync contract: - inspectConversationBinding -> inspectConversationBindingAsync: permit inspection of worker-owned binding state. - resolveCommandAuthorization -> resolveCommandAuthorizationAsync: await persisted account authorization in Discord, Slack, and Telegram. - createApproverRestrictedNativeApprovalCapability -> Async: await native approval eligibility through the narrow approval delivery entrypoint. - createChannelApprovalNativeRuntimeAdapter -> Async: support Matrix's async eligibility callbacks without changing the sync adapter contract. - createLazyChannelApprovalNativeRuntimeAdapter -> Async: preserve lazy Matrix approval loading with the same async callback contract. Document the replacements and retain four deprecated synchronous conversation contracts until the next Plugin SDK major. Reduce the broad SDK budget to the actual retained surface instead of absorbing unused exports. No shipped SDK export is removed. Validation: export-name collision guard; type-aware core, script, and extension oxlint; Knip exported-type check; SDK surface check; exact runtime API guardrail, SDK surface, and install-compensation tests. The two changed test suites passed 23 tests in 255.16s with maxWorkers=1; no tests or CI test seconds are added. Command authorization, DM-policy audit, and Feishu binding tests also passed. Codex P1 review is clean. Runtime/plugin bundles and native load guards passed. The broader package declaration build and optional Gateway/channel smoke attempts did not complete; no assertion failure was reported in those attempts.
…#168481) * 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. * 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 * 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 * test: retain async status discovery arguments * test(codex): model current conversation inspection boundary * test(facetime): bind persistence barriers before runtime startup * docs: explain validated discussion account config * test: exercise native binding lifecycle through worker settlement * test: document isolated runtime dependencies * test: document isolated runtime dependencies * fix: preserve native binding method receivers * fix: bind model preparation authority to its reader * chore: regenerate worker and test guard baselines * chore: regenerate worker and test guard baselines * chore: reconcile worker migration baselines * test: run native row ownership with the host broker * fix(clickclack): fence discussion cleanup and reconciliation * test(clickclack): avoid shadowing store options * refactor: keep async approval adapter within existing SDK contract
openclaw#168481 added an async resolveChannelDmPolicy to account-resolution.ts next to the SDK-exported resolveChannelDmPolicy in dm-access.ts, so check-source-contracts failed on every pull request with an export-name collision (main pushes skip that job). Rename the internal plugin-facing resolver to resolvePluginDmPolicy, the alias channel-pairing already used.
Finish the failures reported by scheduled run 38095292949 after the async channel-account, approval, and plugin-state campaigns (openclaw#168481, openclaw#168482, forwarding to its receiver, and supply the async status report in the install compensation fixture. Preserve the separately landed core DM resolver and observation-cache lint fixes when rebasing onto current main. Remove unused new async exports and duplicate broad-barrel re-exports. Migrate bundled consumers to the existing narrow SDK entrypoints and keep Discord's plugin-local async binding lookup out of its runtime API. The remaining five callable/export budget additions are intentional sync-to-async replacement pairs, retaining each shipped sync contract: - inspectConversationBinding -> inspectConversationBindingAsync: permit inspection of worker-owned binding state. - resolveCommandAuthorization -> resolveCommandAuthorizationAsync: await persisted account authorization in Discord, Slack, and Telegram. - createApproverRestrictedNativeApprovalCapability -> Async: await native approval eligibility through the narrow approval delivery entrypoint. - createChannelApprovalNativeRuntimeAdapter -> Async: support Matrix's async eligibility callbacks without changing the sync adapter contract. - createLazyChannelApprovalNativeRuntimeAdapter -> Async: preserve lazy Matrix approval loading with the same async callback contract. Document the replacements and retain four deprecated synchronous conversation contracts until the next Plugin SDK major. Reduce the broad SDK budget to the actual retained surface instead of absorbing unused exports. No shipped SDK export is removed. Validation: export-name collision guard; type-aware core, script, and extension oxlint; Knip exported-type check; SDK surface check; exact runtime API guardrail, SDK surface, and install-compensation tests. The two changed test suites passed 23 tests in 255.16s with maxWorkers=1; no tests or CI test seconds are added. Command authorization, DM-policy audit, and Feishu binding tests also passed. Codex P1 review is clean. Runtime/plugin bundles and native load guards passed. The broader package declaration build and optional Gateway/channel smoke attempts did not complete; no assertion failure was reported in those attempts.
What Problem This Solves
Channel account inspection, setup and status can read persisted plugin state synchronously on the Gateway thread.
User Impact
Channels can prepare saved-account state asynchronously without losing configured-account, saved-login or explicit report-scope behavior.
Existing config-only synchronous callbacks remain supported. The bundled Matrix build requires the matching V2 host. Official release sync owns the external plugin API floor; this PR does not claim Matrix package compatibility with pre-V2 hosts. Doctor, backup and recovery callers await repair completion.
Why This Change Was Made
Adds optional async companions for account, allowlist, DM-policy, auth-presence and setup/Doctor preparation, and migrates the host callers. Matrix state and credentials use worker-owned stores. Plugin reports intersect effective IDs with the caller's explicit normalized scope, including an empty scope.
This is part 4 of the nine-part S7 state/binding migration stack. Targets
dbasync/sw7b-3(parent PR); validation compares this part with its actual stack parente19d2678d21e. The stack integrates pinned main413d5f9bb3f7.Evidence
Changed lines against the parent: production +921 / -485; tests and fixtures +513 / -375.
Focused integrated receipts cover persisted Matrix credentials, account discovery/status, and outbound target resolution: 625 passed, 0 skipped, mapped to 32/32 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 JSON file spans total 97.963s. 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:
39859ef4a47d91cbebde6060de71fa2d256a8e7966fe7cc9ec299c15c268476c. Zero released export removals; the digest reconciles to this parent/head through the generated-only baseline change. Optional async account hooks and separate async adapter types preserve existing callbacks.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.
pnpm test src/commands/onboard-channels.e2e.test.ts --maxWorkers=1passed 11/11 at the final source. Displayed file time was 2.932 s (JSON span 2.921 s), native Vitest wall time 38.76 s, and full invocation 417.725 s including artifact preparation. The earlier local attempt stopped at the managed-artifact isolation guard before tests; the successful proof used the remote isolated checkout.Paired statement and request evidence
SQL statement gate
The native measurement group completed with exit 0. Its outer wrapper later returned 7 while reporting terminal telemetry; native completion receipts were reconciled, and the workload was not rerun merely for that reporting failure.
Accepted for
e19d2678d21e → 3abbba26c39e. Same synthetic workload, ten warmed turns per run; three original alternating pairs followed by two extra pairs. All five pairs are retained. Adjacent-prefix comparisons in this PR stack share intermediate samples; each filtered base/head sequence remains alternating. Values below are base→head medians; warmed SQL/requests are per turn, while warmed wall time covers all ten turns. MAIN is Gateway-main-thread SQL. Wall ratio is head/base; no duration skew.The warmed increase is +1.4 SQL/turn (+0.1393%), within the ≤0.5% unchanged-owner tolerance. Every warmed native SQL stack and sender stack across all five pairs was checked against this PR's changed files; none intersects them. MAIN remains 6.9 SQL/turn. The exact total-median samples are run 1 on both sides, for both primary3 and cumulative5.
Row/shared-fact requests rise 64→66: exact-entry refreshes remain ten, background refreshes rise 54→56 through the unchanged
refreshBatch → drainowner. Row-request counts across the five runs are base[64,65,66,64,66], head[66,64,66,65,66]; the variation remains inside the baseline range. Outbound recovery comes throughdrainPendingDeliveriesCore; every full workload has exactly nine such requests, so its warmed increase is phase redistribution. Every warmed window retains 110 patch commits, ten turn commits, ten lifecycle projections and 50 domain publications.The connect increase 1173→1287 (+9.72%) is assessed with the permitted combined startup window, not ordinary phase tolerance. Memory
schema.admitperforms exactly one request / 128 SQL in every run, moving between connect and first turn through the unchangedMemoryIndexDatabase.retryPublicationowner. Its binding/close work and existing delivery/bootstrap/generated-HTML maintenance also move across that boundary.[6002,6047,6118][6103,5999,6021][6002,6047,6118,5992,6143][6103,5999,6021,5999,6120]Second-session +8 SQL and cron +5 stay within ten statements. These come from existing projection/schema validation and cron recovery/identity-evidence validation, with unchanged mutation counts. The first-turn median decreases; the warmed increase is accepted specifically as attributed unchanged-owner variation. Whole-workload SQL remains 21942→21961 (+19); extra4 is +19 SQL with five fewer requests, and extra5 is +44 SQL with 13 more requests. Those positive pairs are retained, not relabeled as lower-whole-workload RAW follow-ups or product savings.
The published-driver × candidate update cell is pending (lander). No release, package publication or Plugin SDK major bump is included.