Repository navigation
refactor(sessions): move target preparation callers into workers - #169340
Merged
Merged
Conversation
Move combined topology, search, cron, delivery, and runtime candidate preparation through the existing discovery and session workers. Keep native SDK and effect-boundary contracts explicit; remove repeated descriptive discovery checks.
Await cron delivery discovery outside synchronous writer publication, preserve wake authority at enqueue, and share explicit topology types without import cycles. Keep synchronous SDK and security-boundary discovery for the owning API cutover.
Reuse the media read owner for durable cleanup, preserving missing versus unavailable ownership. Keep unbound process-held incognito reads on their existing native owner until that owner cuts over. Remove duplicate durable discovery and its availability caches.
# Conflicts: # src/gateway/managed-image-attachments.sqlite-visibility.test.ts # src/gateway/managed-image-attachments.ts # src/gateway/managed-image-session-read.ts
Move channel avatar, direct status, companion context, and post-create session reads through the existing worker discovery owner. Preserve companion synchronous identity checks at execution and reply boundaries.
Await initial send target discovery and companion identity reads. Check current identity when reusing a thread and before execution or reply, replacing duplicate preparation reads. Preparation may be discarded at the effect boundary when its session changes.
Use existing worker readers for session creation, runtime target selection, terminal preparation, task suggestions, MCP, and file-route planning. Keep final execution and authority checks at their effect boundaries. Reuse the selected parent row for ordinary inheritance and trust successful session deletion receipts during suggested-task rollback. A session recreated after rollback is a new session and does not invalidate the completed deletion.
Skip the pending-table lookup for durable stores whose shared canonical readiness is already valid. Ordinary writers validate their serialized rows; offline import and repair still invalidate readiness before validation. False, unadmitted, in-memory, and Doctor validation paths remain intact. Name the existing worker/Doctor-only target availability leaf as a worker module and update every importer. Discovery T1 inventory falls from 5 to 4 (total repository T1: 612 to 611); this is a classification correction, not a claim that additional SQL moved off-thread. Accepted edge: independently initialized admission handles retain the existing cache lifecycle; no additional cross-thread handshake is added. Proof: the new fresh-reader regression fails on the base with one pending SELECT, then passes with zero and rejects invalid lineage after an in-process writer marks validation pending. All 15 canonical-validation tests pass (47.03s suite, 59.24s wrapper). Isolated Codex review: no P0-P2 findings.
Restore retired maintenance targets and native incognito project rows across the worker cutover. Align caller fixtures with asynchronous reads and settled notifications, remove the unused prepared synchronous reader, and delete the obsolete registry-close check test.
Refresh the wrapper inventory for the worker-only availability module and align session diff mocks with async discovery. Remove assertions that require repeat canonical validation after physical admission; retain row validation and effect-boundary tests.
# Conflicts: # src/gateway/server-methods/cron-wake.ts
steipete
enabled auto-merge (squash)
October 11, 2026 23:28
steipete
disabled auto-merge
October 11, 2026 23:34
Contributor
Author
|
Merged via squash auto-merge.
|
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Oct 12, 2026
…nclaw#169340) * refactor(sessions): await target discovery in gateway readers Move combined topology, search, cron, delivery, and runtime candidate preparation through the existing discovery and session workers. Keep native SDK and effect-boundary contracts explicit; remove repeated descriptive discovery checks. * refactor(sessions): complete async discovery caller chains Await cron delivery discovery outside synchronous writer publication, preserve wake authority at enqueue, and share explicit topology types without import cycles. Keep synchronous SDK and security-boundary discovery for the owning API cutover. * fix(cron): align local wake adapter with async contract * test: prune repaired session mock exceptions * fix(sessions): retain current visibility for async search * refactor: use worker discovery for managed media cleanup Reuse the media read owner for durable cleanup, preserving missing versus unavailable ownership. Keep unbound process-held incognito reads on their existing native owner until that owner cuts over. Remove duplicate durable discovery and its availability caches. * test(cron): simplify awaited wake assertion * fix(sessions): guard topology publication before installing rows * test(sessions): drop obsolete ambient listing rejection * fix(sessions): preserve unbound incognito discovery namespace * refactor(sessions): await discovery in auxiliary entrypoints Move channel avatar, direct status, companion context, and post-create session reads through the existing worker discovery owner. Preserve companion synchronous identity checks at execution and reply boundaries. * refactor(sessions): finish async send and companion discovery Await initial send target discovery and companion identity reads. Check current identity when reusing a thread and before execution or reply, replacing duplicate preparation reads. Preparation may be discarded at the effect boundary when its session changes. * refactor: move session target callers to async discovery Use existing worker readers for session creation, runtime target selection, terminal preparation, task suggestions, MCP, and file-route planning. Keep final execution and authority checks at their effect boundaries. Reuse the selected parent row for ordinary inheritance and trust successful session deletion receipts during suggested-task rollback. A session recreated after rollback is a new session and does not invalidate the completed deletion. * test: align target discovery fixtures with async readers * refactor(sessions): remove unused synchronous discovery exports * fix(sessions): retain process-local incognito federation * docs(sessions): clarify incognito discovery ownership * test(cron): align delivery fixtures with worker reads * refactor: keep session target preparation within owner modules * perf(sessions): reuse admitted canonical readiness Skip the pending-table lookup for durable stores whose shared canonical readiness is already valid. Ordinary writers validate their serialized rows; offline import and repair still invalidate readiness before validation. False, unadmitted, in-memory, and Doctor validation paths remain intact. Name the existing worker/Doctor-only target availability leaf as a worker module and update every importer. Discovery T1 inventory falls from 5 to 4 (total repository T1: 612 to 611); this is a classification correction, not a claim that additional SQL moved off-thread. Accepted edge: independently initialized admission handles retain the existing cache lifecycle; no additional cross-thread handshake is added. Proof: the new fresh-reader regression fails on the base with one pending SELECT, then passes with zero and rejects invalid lineage after an in-process writer marks validation pending. All 15 canonical-validation tests pass (47.03s suite, 59.24s wrapper). Isolated Codex review: no P0-P2 findings. * refactor(cron): drop unused routing import * refactor(cron): drop unused routing import * test(gateway): export hoisted cron mock after declaration * fix(sessions): preserve maintenance and incognito discovery Restore retired maintenance targets and native incognito project rows across the worker cutover. Align caller fixtures with asynchronous reads and settled notifications, remove the unused prepared synchronous reader, and delete the obsolete registry-close check test. * test(sessions): align cron and registry discovery fixtures * fix(sessions): retain requested discovery owners during recovery * test(cron): extract delivery target fixture * test(gateway): provide runtime snapshot for registry cleanup * test(sessions): update discovery cutover fixtures Refresh the wrapper inventory for the worker-only availability module and align session diff mocks with async discovery. Remove assertions that require repeat canonical validation after physical admission; retain row validation and effect-boundary tests. * test(sessions): document isolated discovery fixtures
This was referenced Oct 12, 2026
This was referenced Oct 12, 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.
Gateway session-target callers still performed synchronous discovery for media, attachments, terminal launch, companion context, and session creation. They now await the existing discovery and entry worker operations. Process-held incognito sessions retain their existing owner. The worker-only availability reader is renamed, and admitted canonical databases no longer repeat full canonical-row validation on ordinary reads.
This completes the bundled caller follow-up to #169311. There is no new schema, retention policy, configuration, migration, or service lifecycle behavior. The Doctor-context change only follows the availability module rename; it does not alter the migration path. No published-driver update cell is required for that import-only change.
Removed checks and accepted edges:
Main-thread inventory
Raw discovery T1 calls: 5 → 4.
targets-read-availability.worker.tsis now worker-only. The remaining four conservative mixed-kernel entries are:session-canonical-key.ts:assertCanonicalSqliteSessionKeysCurrentandmarkCanonicalSessionValidationPending. These kernels also serve native/incognito canonical validation and offline alias import/repair. First admission and real effect authority remain intact.targets.ts:listKnownSessionStoreAgentIdsandresolveExistingAgentSessionStoreTargets. Workers use these kernels, but the published synchronous complete-session SDK view (plugin-sdk/session-transcript-hit.ts) and legacy native lookup path still reach them. Completing that cutover requires the SDK/native owner migration; these shared files are not mislabeled worker-only.Three alternating measurement pairs
The shared harness ran M,C,M,C,M,C on one Hetzner lease at base
21939642b1952and candidate28544b47f9a11; run72c19e708cbc571d5d127621f34966d6. Later changes integrate main and repair fixtures; measurements are reused for unchanged runtime behavior.Warmed MAIN statements: 0→0. Warm duration 18.588→18.839s (ratio 1.014). Whole-workload statements +0.34%; requests +0.17%.
The warmed discovery operations emit identical statement/request counts. The +0.1 warmed statement median for acpSessions.metadata is at unchanged state-worker source with exactly 20 requests per 10 turns; domain publication and exact-entry request medians decrease.
First-turn publication redistributes from connect: database.domain.publish connect statement arrays [87,133,133]→[0,0,133], first-turn [95,51,53]→[184,184,52]. Combined boot+connect+first totals are base[3982,4026,4051], candidate[4035,4036,4019] (median +0.22%). First-turn standalone comparison must be read with this deferred startup attribution; the moved publication command is
schema.admit, confirmed in request-subtypes.csv.Whole workload owner medians (statements/requests): target-inventory 9/107→11/104; store-target 0/3→0/3; entry 51/10→56/11; list 35/4→33/4; exact 349/150→348/150; actor 53/53→52/52; corpus 52/9→51/9; lifecycle-artifact-plan 0/0→13/1. Cold moved-read growth fits the T1 +2% exception; no warmed discovery growth.
Verification and scope
Two final Codex autoreview rounds were scoped-clean; the requested two-round limit is retained. Prior proof includes 456 tests in 14 files, 105 tests in six Gateway files, six affected test type graphs, and SDK API/surface checks. The final merged tree additionally passes repaired canonical/session-creation/diff fixtures (112 tests in 9 files, 151s), cron validation (135 tests, 38s), partial-mock owner suites (71 tests in 5 files, 67s), and wrapper inventory closure (1 test, 5s). Commands use
pnpm test <listed files> --maxWorkers=1; aggregate final focused test wall time is 286s including the 7 runtime guard tests. There are no new behavioral tests in the final fixture-only cleanup.Final verified head:
3486f7d987bd256534eb595e2861a3d9b7e2e281. Final static gates pass: core (11s), affected config/Gateway type graphs (9s/12s), export collisions (24s), Madge (15s), SDK surface (4s), runtime guard (7 tests, 25s), T1 (6s), dialect (1s), and test-mock ratchet (18s). The only changed-file lint exception is inheritedsessions-files.tsmax-lines: candidate 777 versus main 782 (main blobd8faa4dbcf01870c99996fd447919a965afe4deb). Knip reports the exact same 84 entries as the parent baseline, with no additions or removals. Fullcheck:changedis not claimed; its affected type graphs and explicit static gates are recorded instead. Unrelated current CI UI typing failures are outside this diff.Fixture closeout removes obsolete repeated-admission assertions, supplies the async sessions.diff mock, updates the wrapper inventory, documents isolation for eight partial mocks, removes an unused import, and shrinks six stale mock baseline entries. No assertion is weakened to hide a product regression.
LOC versus landed parent before final comment/baseline cleanup: 55 files, +536/-467. Final cleanup is +8/-7 across eight files (comments, unused import, shrink-only baseline).
Landing follows the authorized relaxed v4 policy: no ClawSweeper wait or re-review request; required static gates remain mandatory, with inherited failures recorded explicitly. Remote proof was attempted through Testbox, AWS, then Hetzner; after capacity and transfer stalls, final checks use the allowed local proof slot. All task-owned remote leases and the remote slot are released.
Direct inherited-static proof: a fresh frozen install at current main
d0df645f66013c79290904ac9c4e69f9749b94fdreproduces exactly the final-head hosted type errors: TS2345 inmcp-app-unmount.test.ts:40and TS2339 inmcp-app-view.test.ts:801,804,815. The same UI-components type graph has no additional errors. Final-headsecurity-fastand all sevenSecurity Highchecks passed. The accepted native auto request was explicitly retired throughmerge-recover --cancel-autobefore the head-pinned v4 fallback.