Repository navigation
refactor(sdk): await session and preference preparation - #169122
Merged
Merged
Conversation
Expose async skill-command preparation through the existing SDK entries and migrate bundled Discord, Mattermost, Slack, and Telegram callers. Retain deprecated synchronous SDK methods through the next Plugin SDK major with bounded warnings.
Route bundled credential discovery, capability selection, profile writes, OAuth preparation, and setup reads through the existing auth worker owner. Preserve canonical versus runtime-overlay selection and current credential checks at effects. Profile upserts preserve neighboring committed profiles. Add async SDK peers and migrate bundled callers together. Retain deprecated synchronous APIs and required legacy provider hooks for external consumers. Prepare Discord voice provider facts once per room so per-speaker bridge creation still precedes first-audio capture. Remove duplicated native-search auth checks, xAI fallback store rereads, and auth-owner currency checks already covered by prepared read ownership. Document the accepted snapshot lifetimes and retained native owner gaps. Release-note context: plugin authors should await the documented async auth, provider-selection, and TTS APIs; synchronous contracts remain compatible through the next Plugin SDK major. No schema or retention changes. Validation so far: two Codex review rounds with compatibility and fixture findings addressed; formatting and diff checks. Remote behavior/static proof and alternating SQL measurements follow on this committed head.
Move bundled session, native command, Talk, and TTS preparation through existing worker readers. Add deprecated async replacement pairs for released SDK callers and reuse committed/prepared results instead of repeated bookkeeping reads. Accept the narrow same-session reset-during-history-fetch edge: an in-flight turn can retain its captured history. Channel policy and abort checks still apply. No schema or update behavior change.
Contributor
|
🦞👀 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. |
Contributor
Author
|
Reused prior owner, SDK API, and update-cell proof after conflict-only integration; final static gates passed on |
This was referenced Oct 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What Problem This Solves
Ordinary session and TTS preparation still reached SQLite on the Gateway thread through synchronous Plugin SDK and owner APIs. This moves those callers to the existing session/shared-state workers and keeps released synchronous SDK signatures as deprecated compatibility APIs, with warnings and documented async replacements.
User Impact
Session metadata, model menus, voice consults, and speech preparation use asynchronous storage reads. Existing plugin signatures remain available, with documented replacements. No schema or update migration is required. An in-flight same-session history fetch may retain its captured history across a concurrent reset; authorization and abort checks remain.
Why This Change Was Made
Design and caller cutover
getSessionEntry/readSessionUpdatedAtgetSessionEntryAsync/readSessionUpdatedAtAsyncresolveStoredModelOverrideresolveStoredModelOverrideAsyncwith an awaited parent loaderresolveCommandArgMenuresolveCommandArgMenuAsyncgetConversationSessiongetConversationSessionAsyncreadAmbientTranscriptWatermarkreadAmbientTranscriptWatermarkAsynclistSessionEntrieslistSessionEntriesAsyncthrough the existing session-summary workerresolveTtsPrefsPathresolveTtsPrefsPathAsyncor existing prepared preference factsThe new SDK peers are documented in
docs/plugins. Compatibility keeps the existing return types until the next Plugin SDK major. No schema, retained-data, config, update, or service-lifecycle change.listSessionEntriesAsyncis available onsession-store-runtimeandapi.runtime.agent.session. It requires an explicitagentId, accepts optionalstorePathandenv, and always performs a read-only metadata listing. It retains session identity, initialization status, plugin metadata, and derived participants without loading detached saved prompts and other snapshots. Callers needing a complete entry usegetSessionEntryAsync. Missing stores remain absent. The released synchronous listing keeps its full contract, with deprecation annotations and a one-time warning; its synchronous hydration/source-capture options are not added to the new metadata API.The final follow-up closes all five ordinary-read gaps found in the caller census: Discord thread-close listing, Codex pre-archive listing, pending-delivery notice lookup, cron delivery-context lookup, and Talk's initial-history session-ID lookup. Discord retains its expected-session-ID and update-time deletion predicates. Codex retains initialization, pending-supervision, ownership, descendant, and final archive checks. Pending-notice settlement retains its session/intent checks.
Final tool execution, model-lock, command/stop, disclosure, mutation ownership, and deletion checks retain their synchronous authority boundary. In particular, Talk's control callback still reads current policy immediately before execution; asynchronous consultation preparation does not replace that final check. Incognito-owned paths remain with their owner. Remaining live verbose callbacks (
agent-runner-helpersandfollowup-turn-execution) need a separate callback/owner cutover and are not claimed as removed. Deprecated external SDK implementations and real final authority reads also remain; this PR does not claim lexical T1 is zero. The last verified lexical inventory was 215 T1 files / 612 call expressions before and after on the prior source pins; refreshed inventory on this replacement head remains pending. Ordinary remaining owner work is explicit: live verbose callbacks need async callbacks or receipt-updated state; placement recovery needs an awaited construction-time census throughlistAsync; config health/observation recovery needs its remaining callers to await existing health read/patch operations; raw auth batch upsert needs a physical-target atomic batch with conditional rollback. These are owner-operation gaps, not schema blockers or security exemptions.Removed duplicate checks and accepted edges
Evidence
Final committed source is
cc7d775616ab507e11ef9244a566d5cc44523cf3, compared with stacked auth base8286e5eeae59170f5a8fcc091e8d8db34275c5ce(main through2c543afc5ec2f8aea8ad9753f9a06d941967fdca). Auth and skill-discovery changes in that base are outside this PR's delta. The final five-read follow-up was committed as136f0a71925cabefore integrating the auth base. The merge preserves main's extracted Slackslash-menu-model-contextowner and command-history recording. Async stored-model resolution now lives in that owner, with the two-pass parent-key capture removed. It also retains the explicit routed agent ID in Discord picker reads and the async in-process-write regression; main's intentionally removed duplicate parent-pin test stays removed.Two Codex autoreview rounds completed on the implementation. The first raised the explicitly accepted same-session history edge above; the second found no actionable P0/P1 issues in its reviewed scope. Later changes repair fixtures, close the five ordinary-read gaps through the async metadata listing and existing readers, and integrate the auth base. The reviews remain evidence for their reviewed scopes; no third round or fresh final-head review is claimed.
Owner regressions cover committed parent-model changes, verbose-menu replacement, conversation binding updates and rollback, watermark updates/reset isolation, Talk routing changes, and TTS committed preference updates while checking caller-thread SQL remains absent. The listing regression covers metadata after an owner write, missing-store absence, initialization metadata, omitted saved prompts/private fields, and no host-thread SQL. Discord's stale-list deletion and pending-notice replacement retain their safety assertions.
Focused behavior proof
Remote proof at
05aabfb4b1a63cbe8a9ddb5c5d9b40c418a16987passed 78 files / 1,311 tests in 1,086.77 seconds, plus three fixture files / 30 tests in 81.40 seconds, with no skips or failures. Both usedpnpm test <explicit file list> --maxWorkers=1. Logs, exact commands, source pins, results, and manifests are retained insession-final-remainingandsession-final-fixtures. Final-head source-equivalence attribution is being completed; these results are not relabeled as runs of the final commit.The three fixture replays resolve the concrete failures from session CI: pending-notice tests now wait for actual send entry and reset one-shot mocks; session SDK tests drain each completed case's owned database scopes; cron cancellation waits for the existing
onQueuedlifecycle event. Assertions, product behavior, timeouts, and worker capacity are unchanged. The other fixture repairs supply the awaited exports and let the Telegram hot-reloaded model-pin case read its real session store. The final Telegram lint correction uses the existing disposable-spy convention and typed async fixture mock; its validation is tracked with final static proof.Earlier successful files and groups remain proof only where their tests, owning code, and fixture inputs are unchanged. The prior 428-file census is historical evidence. The narrowed replay supplements successful
agent.test.ts(57 cases),session-store-runtime.recovery.test.ts(three cases), andsession-store-runtime.test.ts(15 cases) from completed CI groups. Auth-only passes do not count as session proof. Two E2E files and final static/API verification remain with the remote proof lane.The Codex
run-attempt.steering.test.tsvisible-output/steering failures occur in both auth-base CI and session CI; that test and owner are unchanged by this PR. The05aabstatic run passed production types, source contracts, baseline ratchets, general test types, and core test-type groups 1/3/4/5. Its core-2 type failure is the inheritedui/src/components/session-background.browser.test.ts:42configObjectmismatch; its Telegram lint failures were corrected afterward. These are exact-head evidence and named failures, not a claim that every enclosing job passed.Final measurements and static proof
The expected SDK surface is 3,695 public exports / 2,156 callables / 183 deprecated exports, versus 3,688 / 2,149 / 176 on the auth base: seven session additions/deprecations, including the listing pair. These are the documented deprecate-and-replace allowances; final compiler/API verification is tracked below.
05aab: 81 files / 1,341 tests passed, zero skips/failures; final reuse attribution and two E2E files pendingcheck:changed, type-aware lint, export/source contracts, Madge, KnipFinal tests, static checks, and measurements on the replacement head remain pending. No warmed-turn saving or final-head static pass is claimed before those results arrive. There is no schema, migration, update, plugin-loading, or service-lifecycle change requiring a published-driver update cell.
LOC against the exact auth base: 147 files, +1,362/−854: production/tooling 94 files, +742/−570; tests/support 49 files, +552/−270; docs four files, +68/−14. Test/support totals include the test-mock export baseline.