Repository navigation
refactor: prepare command and approval eligibility asynchronously - #168482
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.
|
Landing under Peter's relaxed landing v4. Head d259d5f integrates main and preserves the prior stack fixes, async approval eligibility, and released synchronous publisher compatibility. Exact-head AWS Crabbox run_c3d7b595b1b9b4c52fd5e98715169bf0 passed 29 tests across approval native runtime, delivery helpers, Gateway publication, and released compatibility. SDK surface policy check remains red: 3668 public exports against the unchanged 3656 budget, attributable to the intended twelve async command/approval exports. This is a recorded policy follow-up under v4, not a claimed passing check; no budget was raised and no proven product regression was observed. Reusing the passing published-driver 2026.9.9 × candidate update cell from #168478 (run_3d6590a7c9c48b16a12382d7e111cda1), as directed for intermediate stack PRs. Required CI was pending at last observation. Native artifacts record the policy failure honestly; native workflow and admission are subject to the explicit ten-minute fallback. |
… entries #168576 (shared presentation primitives) and #168657 (Solid chat render lifecycle) land before their page and chat consumers, so Knip reported 18 files and their exports as unused in scheduled run 38095292949. Register them as ui production entries with the existing removal condition (drop each with its first production importer), and stop exporting SettingsSegmentedOption, which is only used in-module. Both deadcode:full passes now report only GatewayApprovalEventPublisherV2, which belongs to #168482.
Repair scheduled checks-node-compact-large-11 (infra) and checks-node-compact-large-21 (gateway-methods), both independently bisected to 4128f11 (#168482), with its parent passing. The authorization await moved ahead of Stop's ownership capture and let later human work enter cancellation. Capture root and child selections first, then authorize in the existing beforeKill gate before any effect. The same commit added a current-pending-record delivery guard, exposing an unregistered approval fixture. Register that record and retain every delivery assertion. The documented /stop behavior remains unchanged. Proof on Testbox tbx_01m4m51050agatsdqgn1y0re2c, run 38097808740: - pnpm test src/gateway/server-methods/approval-request-delivery.test.ts --maxWorkers=1: 16 passed, 30.13s wall. - pnpm test src/auto-reply/reply/abort.target-owner.test.ts --maxWorkers=1: 32 passed, 16.15s wall. - pnpm test src/auto-reply/reply/abort.test.ts --maxWorkers=1: 15 passed, 17.85s wall. - pnpm run tsgo:core and the changed Gateway test type graph passed. - Touched-file oxfmt, oxlint, and git diff --check passed. - Independent review: no actionable P0-P2 findings.
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.
Keep the internal async approval handler factory and Claude display-prefix helper private. Remove the redundant async adapter re-export from the approval runtime and have its existing test import the canonical adapter module. The public Plugin SDK entrypoint, synchronous wrappers, and runtime behavior remain unchanged. Complete the full-tree findings by removing the unused catalog-fixture re-export, deleting the uncalled Skill Workshop reconnect test helper, and keeping the codemod diagnostic annotation private. Workshop's last helper consumer was removed by 224c0bc (#168656). No assertions or runtime function bodies change. Correct the preceding UI cleanup's historical attribution: git log -S shows that the approval exports originated in 4128f11 (#168482), and were retained through 8fc31c9; they were not introduced by 8fc31c9. The unused Claude helper export came from 667b2e5 (#166080). Validation: 15 existing approval tests passed in 31.33s; 34 existing Claude import/display tests passed in 43.65s. Core production types passed in 45.92s, the owning infra test graph in 38.93s, and targeted type-aware lint passed for all six files. Formatting and diff checks passed. No tests were added and existing assertions are unchanged. Fresh independent review of all six files found no actionable P0-P2 issues. The exact pnpm deadcode:full gate passed both production and full-tree scans on the final six-file patch in 171.64s.
…enclaw#168482) * 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. * 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 * 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 * 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 * 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 * 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 * 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
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.
… entries openclaw#168576 (shared presentation primitives) and openclaw#168657 (Solid chat render lifecycle) land before their page and chat consumers, so Knip reported 18 files and their exports as unused in scheduled run 38095292949. Register them as ui production entries with the existing removal condition (drop each with its first production importer), and stop exporting SettingsSegmentedOption, which is only used in-module. Both deadcode:full passes now report only GatewayApprovalEventPublisherV2, which belongs to openclaw#168482.
Repair scheduled checks-node-compact-large-11 (infra) and checks-node-compact-large-21 (gateway-methods), both independently bisected to 36a5eef (openclaw#168482), with its parent passing. The authorization await moved ahead of Stop's ownership capture and let later human work enter cancellation. Capture root and child selections first, then authorize in the existing beforeKill gate before any effect. The same commit added a current-pending-record delivery guard, exposing an unregistered approval fixture. Register that record and retain every delivery assertion. The documented /stop behavior remains unchanged. Proof on Testbox tbx_01m4m51050agatsdqgn1y0re2c, run 38097808740: - pnpm test src/gateway/server-methods/approval-request-delivery.test.ts --maxWorkers=1: 16 passed, 30.13s wall. - pnpm test src/auto-reply/reply/abort.target-owner.test.ts --maxWorkers=1: 32 passed, 16.15s wall. - pnpm test src/auto-reply/reply/abort.test.ts --maxWorkers=1: 15 passed, 17.85s wall. - pnpm run tsgo:core and the changed Gateway test type graph passed. - Touched-file oxfmt, oxlint, and git diff --check passed. - Independent review: no actionable P0-P2 findings.
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.
Keep the internal async approval handler factory and Claude display-prefix helper private. Remove the redundant async adapter re-export from the approval runtime and have its existing test import the canonical adapter module. The public Plugin SDK entrypoint, synchronous wrappers, and runtime behavior remain unchanged. Complete the full-tree findings by removing the unused catalog-fixture re-export, deleting the uncalled Skill Workshop reconnect test helper, and keeping the codemod diagnostic annotation private. Workshop's last helper consumer was removed by 5bc8e47 (openclaw#168656). No assertions or runtime function bodies change. Correct the preceding UI cleanup's historical attribution: git log -S shows that the approval exports originated in 36a5eef (openclaw#168482), and were retained through 6f9dc11; they were not introduced by 6f9dc11. The unused Claude helper export came from d075300 (openclaw#166080). Validation: 15 existing approval tests passed in 31.33s; 34 existing Claude import/display tests passed in 43.65s. Core production types passed in 45.92s, the owning infra test graph in 38.93s, and targeted type-aware lint passed for all six files. Formatting and diff checks passed. No tests were added and existing assertions are unchanged. Fresh independent review of all six files found no actionable P0-P2 issues. The exact pnpm deadcode:full gate passed both production and full-tree scans on the final six-file patch in 171.64s.
Upstream first-parent #1297, stopping just before #1298 (tool-call XML grouping) so that change gets its own step. Four conflicts: - delivery-queue-sqlite-bound: keep both imports, upstream's emptyOutboundDeliveryQueueAdmission (openclaw#168643) and our row codec type. - attempt-execution: keep our startAttemptContinuation; take upstream's resolveCommandAuthProfileSelection (openclaw#168392). Upstream's other edits in the file (inlined pinnedHarnessId, internal-continuation promptCacheKey) merged cleanly; our resolveClaudeCliFallbackPrelude extraction is untouched by upstream. - session.test: keep our custody test state; take upstream's buildCommandContextForTest (openclaw#168482). - plugin-sdk-surface-report: measured 3683/2137 (upstream 3672/2133, +11/+4). Also: test-mock-exports baseline pruned 10162 -> 10142 (20 stale rows from #1433's fixes; shrink only, check --prune), worker-access-inventory regen. pnpm install after the lockfile change. tsgo core/core-test/ext/ext-projects 0; sdk --check 0; inventory 0; config docs 0; mock-export ratchet OK. db-worker ratchet 706 -> 709 vs upstream is #1432 (unchanged vs step 25). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Jhynq2GVpzuVQQieebEubg
What Problem This Solves
Command authorization and approval routing can force channel persistence reads onto the Gateway thread.
User Impact
Command and approval preparation can await persisted channel state while retaining current authorization at dispatch and delivery.
Generic synchronous config callbacks and released command-authorization exports remain supported. The released approval publisher keeps its immediate numeric result for synchronous subscribers;
publishRequestedAsynchandles worker-backed eligibility. The legacy method refuses asynchronous eligibility before delivering to any subscriber. Final authority checks in provider login, Discord and internal webchat control stay synchronous.Why This Change Was Made
Adds async command authorization and approval eligibility/surface companions and migrates ordinary runtime callers, including Matrix saved-login eligibility. Approval routing rechecks stopped accounts after eligibility awaits and checks current record and authority before forwarding or accepting a route. Bundled publication selects the async companion before dispatch, while older structural publisher objects keep their synchronous fallback. A failed async publication is never replayed through that fallback.
This is part 5 of the nine-part S7 state/binding migration stack. Targets
dbasync/sw7b-4(parent PR); validation compares this part with its actual stack parent3abbba26c39e. The stack integrates pinned main413d5f9bb3f7.Known follow-up: if an account stops while a later channel's eligibility check awaits, an earlier channel can retain an ambiguous-owner verdict and skip its native approval card. Final authority remains fail-closed. A follow-up should recompute group verdicts after all eligibility waits.
Evidence
Changed lines against the parent: production +998 / -417; tests and fixtures +576 / -204.
Focused integrated receipts cover command authorization, native/channel approval coordination, and released publisher compatibility: 485 passed, 0 skipped, mapped to 24/24 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 315.213s. Actual separate publisher/shared/exec/registry invocations took 79.254/63.096/3.981/2.572s; the released fixture passed 4/4 in a preserved child report whose parent failed on reporter configuration. The numeric-result regression failed on the old source as expected. File spans and invocation wall times are distinct; CI runner seconds were not measured.
Owner-reviewed native SDK digest:
248993930a5c50c411d32eea02509feed2c0ca525b6f5623aee4e73de675bd05. Zero released export removals; the digest reconciles to this parent/head through the generated-only baseline change. The released publisher again returns number; its async companion is optional. Old publisher objects remain accepted.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.
First and warmed medians both decrease in the primary series. Native SQL stacks across the first four paired samples do not intersect this part's changed files; changed dispatch/prepare-execution sender wrappers retain the same operations. MAIN first/warmed counts are unchanged.
These increases are each within ten statements and come from unchanged SQL owners. Whole-workload requests are 3421→3422; this is not a claimed request reduction.
The cumulative-four first median rises 2516→2574.5 because adding a fourth sample changes median composition around an earlier low baseline. The fourth pair itself decreases 2450→2445 in first-turn SQL, 22263→22248 in whole SQL, and 3431→3425 in requests; its warmed count is 1023.5→1027. The incidental fifth pair is also disclosed: first 2615→2579, warmed 1004.2→1005.2, whole SQL 22192→22219 and requests 3418→3424. It does not clear a RAW whole-workload condition and is not used to claim a saving. Acceptance uses the original three-pair series, not a newly selected cumulative series.
The published-driver × candidate update cell is pending (lander). No release, package publication or Plugin SDK major bump is included.