Repository navigation
refactor(sessions): validate chat leaves through workers - #169659
Merged
Merged
Conversation
Carry active-path facts through the existing session entry reader for chat admission, and await the same owner before Stop cancellation. Remove redundant recovery leaf rereads and their timing-only coverage. Read archive classification through the existing Memory corpus worker and delete the unused synchronous discovery path. Preserve native incognito behavior for its separate owner cutover. Basic lint retains only the existing chat-abort-runtime line-cap violation, with the exact baseline count preserved. Tests and typechecks are deferred to PR CI by the campaign workflow.
# Conflicts: # docs/reference/database-schemas/worker-access-inventory.md
Contributor
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review in progressClawSweeper is reviewing this revision. This supersedes any previous blocked status. |
Use the existing commit-only native deletion participant for initialization rollback, including sessions without native bindings. The worker receipt consumes the host initializer only when its row was deleted. Retain native transactions only for opaque SDK callbacks. Cover caller-thread SQL and rollback completion for bound and unbound initializers.
# Conflicts: # docs/reference/database-schemas/worker-access-inventory.md # docs/reference/database-schemas/worker-access.md # packages/memory-host-sdk/src/host/session-transcript-corpus.test.ts # scripts/database-worker-inventory.mjs # scripts/pr-lib/wrapper-components.txt # src/auto-reply/status.test.ts # src/config/sessions/session-accessor.sqlite-deletion.ts
…t1cut-s1-memory # Conflicts: # docs/reference/database-schemas/worker-access-inventory.md
…t1cut-s1-memory # Conflicts: # docs/reference/database-schemas/worker-access-inventory.md
…t1cut-s1-memory # Conflicts: # docs/reference/database-schemas/worker-access-inventory.md # src/gateway/server-methods/chat-abort-runtime.ts
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
Durable chat admission and Stop still reached synchronous session SQL even though their surrounding operations were asynchronous. This stacked follow-up to #169608 carries active-path facts from the existing reader worker to those callers.
User Impact
Chat admission, Stop, archive indexing, and failed-creation rollback preserve their existing outcomes. No public SDK signature, schema, retention, migration, or update behavior changes. Native incognito stays with its separate owner cutover.
Design
The session-entry worker returns active-path facts in the same snapshot as the selected entry. Chat admission consumes those facts; Stop awaits the worker before cancellation. The selection assembly lives with the existing transcript-anchor reader. Recovery no longer rereads the active leaf while recording internal admission bookkeeping.
Memory classification and initialization rollback were also cut over during this work, and equivalent production changes independently landed on main. This PR keeps those implementations, adds Memory ingestion coverage across ordinary → dreaming → cron owner writes, and strengthens the initializer regression to reject all caller-thread session SQL with and without a native binding. The worker commits deletion before its existing commit-only participant consumes initialization. Only opaque released SDK deletion callbacks retain the native transaction adapter.
Removed check and accepted edge case: the recovery bookkeeping leaf reread is gone. A concurrent leaf change may leave bookkeeping describing the already-admitted attempt; the next actual admission validates its own active path. Current authorization and cancellation checks at effects remain.
T1 and SQL
Shared native kernels are deliberately not relabeled worker-only. This PR claims 0 raw T1-site reduction: the identity primitive moved from active-events to the existing narrow transcript-anchor owner, so their combined count remains 7 → 7 (active-events 5 → 4 and transcript-anchor 2 → 3). Ordinary durable chat admission, Stop, recovery bookkeeping, and Memory classification now use worker-backed reads. The seven original archive/conversation modules still contain 18 mixed T1 primitives with native incognito, deprecated SDK, opaque callback, and offline CLI callers recorded in the inventory.
The seven retained mixed modules contain: conversation-registry 1, archive-read 1, archive-store-kernel 6, archive-transaction 1, conversation-read 1, conversation 7, and delete-snapshot 1. Durable conversation reads, archive enumeration/publication, and deletion snapshots use their existing workers; the remaining native consumers are recorded in the inventory. Deprecated SDK readers and opaque released callbacks retain their documented replacement/removal path. Native incognito remains outside this slice.
One live combined-lane pair was run under the current validation policy: baseline
9c54108f9f20a, candidate22bf8aa966027a499abbeb784f6e2aab9e44a397. This candidate includes the prerequisite, this PR, and the currentness cutover; it is not an isolated measurement of this PR's head. Successful SQL executions reconcile exactly with the worker census and shared statement-count CSV. Requests count one worker send per key, excluding continuation frames; prepare and failed SQL executions are excluded.Within-run warmed median [min–max]: statements 294.5 [291–340] → 357.5 [344–514]; requests 81 [79–95] → 100 [95–128]. These are ten observed turns within one pair, not medians across three pairs. The candidate's warmed window was approximately 6.08× longer and its whole workload 6.36× longer. No SQL saving or controlled performance improvement is claimed from this slice.
Warmed owner-operation totals across ten turns:
The 13 additional lifecycle statements are one existing temporary generation-tracker setup batch, not new lifecycle requests. The two warmed MAIN statements are unchanged scheduled GitHub OAuth maintenance outside this lane. Repeated background Memory refresh accounts for 12 extra writable entry reads and 12 each of corpus, tombstone, and transcript requests: 3 refresh cycles occurred during the baseline warmed window and 15 during the longer candidate window. Existing Memory publication and WAL maintenance also ran more often.
The shared-family audit traces the five additional admitted ordered reads to same-database Memory commits 3.5–12.5ms earlier. Those unscoped writes invalidate the existing session token. Five corresponding prompt reads refill participant coverage: the existing full-entry actor fallback after a Memory-invalidated patch lacks participants. Two read-only FIFO misses and three additional early hydrations likewise follow Memory commits. The remaining one C05 entry-admission miss is not causally cleared by the original observer, which records worker reply posting but not main-thread receipt installation or cache-decision reasons. No claim that every raw increase is unrelated is made before the diagnostic disposition below.
All 13 measured
chat.sendcalls omitexpectedLeafEntryId. The new active-path transcript projection is therefore disabled for those calls; its intentional row-cache bypass does not explain this measured increase. That projection remains required when a client explicitly pins a leaf.The combined live run is not a fully passing end-to-end run: all 13 agent turns, cron, child terminal, compaction, and shutdown succeeded, but
mentions.dismissreturned retryableUNAVAILABLEduring the control-plane phase. The outer all-RPC assertion failed despite the driver'sok: true. There were no failed SQL executions in that phase; the existing generic catch hides the underlying exception, so its cause is not claimed as established.Evidence
Two isolated Codex reviews completed without actionable findings. Basic changed-file oxfmt, oxlint, and whitespace checks pass. No new local suite or remote lease was required under RELAXED TESTING v6.
The pinned-main merge
f43e2acb29531dbb593adaa1b79e64ecc35fe7eeincorporatesfe79a0ff62af6054619dcb5af5144ae96f6469d6. The three source conflicts preserve both transcript selection and lifecycle facts in the same existing worker snapshot; no extra read was introduced. The fourth conflict was the generated inventory, regenerated canonically: 627 files / 2392 expressions, T1 540, compatibility 2, T2 403, T3 261, W 1186. The original 17 lane files retain 42 raw T1 expressions.Final-head static qualification is complete at
1a9fb1108ee2293883c19cc4a84f94e57a2e019e, which additionally incorporates main1248e1eaa663874ec2546c05068bed758f688667. Its single source conflict preserves both incoming prepared-watermark reuse and active-path facts in one existing worker result. No extra query or check was introduced. Prior headed5a2d70a4e55349d2ef29feae66a09b72c4faa3passed all static checks in PR CI and main-tier CI: production/test types, lint, Knip, source contracts, database ratchets, and runtime topology/Madge. The latter run was stopped after static checks settled; canceled jobs are not passing coverage. Earlier complete CI at2e631903584bd142ac1dc36641023be18b36bfd2also passed the runtime suites.Regression coverage exercises Memory classification after ordinary, dreaming, and cron owner writes, plus rollback without caller-thread SQL, active-path admission, projection repair, and cancellation. Earlier CI found and drove repairs to an import cycle, a missing async cancellation await, and repair scheduling; all were resolved before this integration.
Inherited static exception independently reproduced on main
fe79a0ff62af6054619dcb5af5144ae96f6469d6:pnpm test src/plugins/contracts/boundary-invariants.test.ts --maxWorkers=1fails the typed-hook allowlist rule atboundary-invariants.test.ts:369with the same extra pathextensions/x/src/work-origin.ts(11 other cases pass; 314.40 seconds). Neither the rule nor X registration is changed here. Other prior runtime failures involved unchanged cron/retirement/background-fault fixtures; the mismatched-window fixture is repaired by the pinned main integration.No update cell is required: update, Doctor, schema/migration, plugin loading, and service lifecycle are unchanged. Against merged main
52dce97d15dff, the final diff is 33 files, +679/-541. Production is +297/-123, tests/test support +98/-195, docs +223/-222, and inventory tooling +61/-1. Final main-tier CI covers the complete static suite, including Knip omitted by the ordinary PR manifest.Final-head inherited failures: the eight Knip-reported worker-contract files are byte-identical between this head, its integrated main
1248e1eaa663, and observed main9bd2fe918222. The eager-import failure names the same unchanged user-turn transcript wrapper inventory and transcript-rewrite-effects source. The retirement fixture still expects only two entry fields instead of six; the Bash background-fault counter is also the same unchanged prior-head failure. These are not represented as passing coverage.Landing qualification at
1a9fb1108ee2293883c19cc4a84f94e57a2e019e: PR CI 38235348594 and main-tier CI 38235434498 pass production/test types including all five core stripes, type-aware lint stripes, source contracts, T1/dialect/worker ratchets, and runtime architecture/Madge (zero cycles). Security-fast and all seven Security High checks pass. No SDK/API surface changes occur in this PR's final diff; its optional SDK report is not a gate.The failing Knip production scan is independently reproduced on clean main
1248e1eaa663874ec2546c05068bed758f688667: exit 1, exactly the same eight unused worker-contract files and no extra findings. The prior full Knip scan passed ated5a2d70a4e55; later lane changes are the inspected conflict-only integrations. Remaining known runtime failures are the unchanged cron worker-mock cases, retirement projection fixture, background-fault counter, and transcript-wrapper extraction; X hook allowlist and locale fallback drift are inherited. The native provisioning exception uses head-pinned REST squash under the authorized inherited-failure route, with these failures retained as failures rather than passing coverage.Current-main Knip citation: scheduled main CI 38237812441, dependency job 114773017152 on main
d2154d5reports exactly the same eight unused worker-contract files. This independently corroborates the isolated main1248reproduction.Shared read-family audit
The tightened attribution rule also counts shared read families (successful SELECT executions, classified by the first non-infrastructure SQL source). These are per-turn means across the ten warmed turns in the same immutable pair, not new measurements.
The original-pair attribution limits are preserved above; the completed entire-workload recheck and final disposition follow below.
Latest conflict-only integration:
c2d5f01380e1467326a05b8cdb0778fcbcab14b5merges main52dce97d15dffd6dad9b8814a0f5661f030975fd. Only the generated inventory conflicted; canonical regeneration reports 628 files / 2391 expressions, whole-repository T1 536 and original-lane T1 42. The source auto-merge reuses main's existing transcript-anchor equality helper without adding SQL. Basic lint/format and whitespace checks pass; exact-head static qualification is complete.Inherited merge-ref compile failure after actor revert #169811: main
483b8fdaa602e115b2827054001f590a82a29eb5restoressession-actor-memory-reports.ts, which imports missingisSteerConfirmationRewriteat line 26. Main CI 38241498196, production types job 114785384700 reports the identical TS2305. PR2 exact headc2d5does not contain that file and leaves the export owner unchanged from its main base. This is an inherited main failure, not a reason to restore the deleted helper in this lane.Final entire-workload recheck and landing disposition
After two diagnostic candidate attempts timed out during connection before any turn, the replacement candidate used the original successful-pair harness and passed every RPC, all 13 turns, child completion, cron, compaction and shutdown. Source is still pinned to baseline
9c54108f9f20aand combined candidate22bf8aa966027. The diagnostic baseline has extra cache-decision logging; SQL semantics are unchanged, but this asymmetric instrumentation means neither timing nor a controlled performance saving is claimed.This satisfies the RAW TURN INCREASE entire-workload recheck: total statements, requests and every required shared-family total decrease, while warm-window work is redistributed. The two replacement admission misses follow real Memory commits by 11.52ms and 4.27ms. The two extra warm snapshots are one extra Memory corpus cycle and one registry request sent in first-turn but executed in the warm window. Three added ordered writer reads and two reader misses also follow Memory commits. The original C05 admission and one replacement turn-01 ordered writer miss still lack a recorded cache-rejection reason; they are retained as individual attribution limits, not declared proven noise. Their shared families add no whole-workload work. The extra MAIN statements are unchanged scheduled GitHub OAuth maintenance, outside this lane.
Per-operation recheck: warmed transcript hydration remains 240 statements / 20 requests, anchors 110/10, entry patch commit 370/60 and patch preparation 60/30. Row facts are 270/54 → 255/51. The lifecycle projection's 120/10 → 133/10 is one existing tracker initialization batch; no new lifecycle request. No SQL saving is claimed for this owner/API cutover.
Latest exact-head qualification at
c2d5f01380e1467326a05b8cdb0778fcbcab14b5: same-revision main-tier CI 38241479721 passes production and general test types, all five core test-type stripes, all five core lint stripes, source contracts, database ratchets, guards and full architecture/Madge (job 114785227939). All seven Security High slices, OpenGrep and Critical Quality pass. Production Knip repeats exactly the eight known main findings. The earlier manual run 38241142044 stopped at preflight because incompatible main-tier/qualification inputs were selected; it ran no test and was replaced with the supported same-revision dispatch.Landing uses the authorized inherited-failure exception: PR
openclaw/ci-gate114786809230 is red from the independently confirmed main-only stale import and the documented inherited fixtures. Exact-head static and security checks above pass; corrected-run packaging/build jobs were still running at submission and are not reported as passes. The head remainsc2d5f01380e1467326a05b8cdb0778fcbcab14b5.Post-merge: package-boundary job 114785228128 passed. After recording qualification and verifying merge
8239692596a9199b532b0fcd8e35800bfa901a8e, cancellation was requested for remaining optional work in main-tier run 38241479721 to release CI capacity; ordinary run 38241088102 had already completed. Unfinished or canceled jobs are not passing coverage.