Skip to content

refactor: prepare message action discovery asynchronously - #168484

Merged
steipete merged 114 commits into
mainfrom
dbasync/sw7b-7-discovery
Oct 10, 2026
Merged

steipete merged 114 commits into
mainfrom
dbasync/sw7b-7-discovery

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Message-action discovery can synchronously load saved channel state while preparing a turn or dispatching a message action.

User Impact

Saved-login Matrix accounts retain their actions, schemas, and capabilities when discovery runs through worker-owned storage. The host awaits discovery once and carries the prepared catalog into tool creation and dispatch.

Why This Change Was Made

Migrates bundled action-discovery consumers to the async contract and removes obsolete internal synchronous wrappers. The released synchronous Matrix callback retains its compatibility behavior and names its replacement. Action authorization still revalidates before the effect.

This is part 7 of the nine-part S7 state/binding migration stack. Targets dbasync/sw7b-6 (parent PR); validation compares this part with its actual stack parent fa00fb0fc9bd. The stack integrates pinned main 413d5f9bb3f7.

Evidence

Changed lines against the parent: production +494 / -281; tests and fixtures +221 / -79.

Focused integrated receipts cover asynchronous action discovery, message parameters, and tool integration: 112 passed, 0 skipped, mapped to 5/5 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 8.843s; these passing file receipts came from the original 2,879.229s mixed-result batch. Its failures and subsequent repairs remain in the ledger. File spans and invocation wall times are distinct; CI runner seconds were not measured.

Owner-reviewed native SDK digest: 05484b81d65957c29b8ba10b05d53e122a4e6d88ee8c4770c63793e6dadd8d7f. Zero released export removals; the digest reconciles to this parent/head through the generated-only baseline change. The adapter adds an optional async member; removed discovery helpers are internal.

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.mjs and src/infra/sqlite-source-fence-admission.ts; the production export scan flags PUBLIC_SESSION_ENTRY_SCRIPT; core lint has 10 unchanged max-lines findings; the environment-name count is 456/455, including unchanged OPENCLAW_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.

Phase All-thread SQL MAIN SQL Worker requests Wall seconds
Boot 2320→2315 1933→1929 59→59 9.894→9.845 (0.9950×)
Connect 1194→1201 126→126 58→57 1.219→1.235 (1.0131×)
First turn 2575→2582 94→94 352→353 7.969→8.554 (1.0734×)
Warmed mean/turn 1009.3→1010.6 6.9→6.9 195.4→196.2 20.232→20.485 (1.0125×)
Second session 3862→3871 117→117 658→658 8.136→8.14 (1.0005×)
Control plane 422→422 33→33 73→73 1.123→1.132 (1.0080×)
Cron 1149→1151 30→30 171→171 5.486→5.496 (1.0018×)
Compaction 406→407 25→25 84→84 1.499→1.483 (0.9893×)
Shutdown 195→195 129→129 14→15 0.768→0.784 (1.0208×)
Whole workload 22221→22219 2554→2552 3424→3422 57.309→56.93 (0.9934×)
Series First-turn SQL Warmed SQL/turn Whole SQL Whole requests Whole wall ratio
Primary three pairs 2575→2582 1009.3→1010.6 22221→22219 3424→3422 0.9934×
Cumulative four pairs 2571.5→2584 1008.45→1010.45 22202.5→22227 3425.5→3424 1.0064×

The first-turn increase is +7 SQL (+0.272%); warmed increases +1.3 SQL/turn (+0.129%). Both satisfy the ≤0.5% tolerance only with the unchanged-owner attribution below. Exact total-median samples are P6 run 3/P7 run 2 for first turn, and P6 run 2/P7 run 3 for warmed turns. MAIN first/warmed counts are unchanged.

Existing owner group First-turn SQL delta Ten warmed turns SQL delta
Memory domain bind/execute/close +43 +17
Plugin lock/entry work +17 −8
Exact-entry projection +8 included below
Native version checks/memory lease rollback +5 included below
Outbound recovery +4 included below
Existing startup/target inventory −70 included below
Row/shared facts — +49
Pending-input validation — +9
Other positive reads — +9
Corpus inventory — −35
Patch validation — −16
Other read/recovery offsets — −12
Total +7 +13

Background row refreshes change 60→67 and shared facts 60→68. The changed tool-construction sender retains the same approval reads: 20 requests / 40 SQL warmed, 3 / 6 first turn. Every native SQL-producing stack across the first four paired samples is outside the changed files. The other changed sender ancestry covers existing second-session/cron/compaction exact-entry reads, not a new SQL operation.

Non-turn increases are within ten statements: connect +7 combines generic listing +24 with startup schedule/media/image/queue offsets −17; second session +9 is existing schema initialization (four CREATE IF NOT EXISTS statements, contract INSERT, canonical-schema query, schema/user PRAGMAs and sqlite_schema query), with other row/cache offsets canceling; cron +2 and compaction +1 are existing read/validation work. Neither first-turn nor warmed attribution is presented as reduced work.

The published-driver × candidate update cell is pending (lander). No release, package publication or Plugin SDK major bump is included.

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.
@openclaw-barnacle openclaw-barnacle Bot removed docs Improvements or additions to documentation channel: discord Channel integration: discord channel: imessage Channel integration: imessage channel: signal Channel integration: signal channel: slack Channel integration: slack channel: telegram Channel integration: telegram channel: zalouser Channel integration: zalouser cli CLI command changes scripts Repository scripts channel: feishu Channel integration: feishu extensions: qa-lab extensions: codex plugin: file-transfer extensions: crabbox extensions: onepassword 1Password plugin plugin: facetime FaceTime plugin extensions: clickclack extensions: agentsapi labels Oct 10, 2026
@clawsweeper clawsweeper Bot added status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 10, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

Landing under Peter's relaxed landing v4. Final head 6a2dd44 merges main while preserving its current owners outside this part's message-action changes. No budget or limit increased.

AWS Crabbox run_de5be8b8ec837a92cb375dfc570cbc72 passed all 89 focused tests for channel tools, message-action discovery, and action parameters (59.151s total command). Coordinator review/build proof remains applicable; the merge was conflict-only. Required CI was pending at last observation; no green CI claim.

Reusing the passing published-driver 2026.9.9 × candidate update proof from #168478, run_3d6590a7c9c48b16a12382d7e111cda1, per the intermediate-stack instruction. Native allocation/preparation is subject to the explicit ten-minute fallback, with the final head pinned and any submission reconciled first. Remaining non-product policy failures are follow-ups under v4.

@steipete
steipete merged commit 3d819f2 into main Oct 10, 2026
72 of 90 checks passed
@steipete
steipete deleted the dbasync/sw7b-7-discovery branch October 10, 2026 23:23
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 11, 2026
…68484)

* 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

* refactor: prepare message action discovery asynchronously

* 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

* 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: avoid mutating action discovery entries

* 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

* chore: prune migrated discovery mocks

* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling channel: matrix Channel integration: matrix commands Command implementations gateway Gateway runtime merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. 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