Repository navigation
refactor: move bundled session reads and authority into workers - #169622
Conversation
…t1cut-s2-entry-workers
|
🦞👀 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. |
|
Codex review: needs real behavior proof before merge. What this changesThis PR moves bundled session reads into existing database workers and carries committed facts through runtime authorization. Example: The Gateway reads session metadata for agent:main:main.
Review scores
ProductKind: Refactor · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 5 items remain Keep open: this maintainer-directed worker cutover has clear value, but both previously reported defects remain in the reviewed head. Priority: P2 Before merge
Findings
Provenance
Tests
Agent review detailsHow this fits togetherGateway routing, agent execution, plugins, and status rendering consume session metadata; database workers return prepared facts, while runtime owners authorize subsequent effects. flowchart LR
A[Gateway and bundled callers] --> B[Session read preparation]
B --> C[Database workers]
C --> D[Prepared session facts]
E[Committed write receipts] --> D
D --> F[Live authority checks]
F --> G[Execution and disclosure]
Technical reviewBest possible solution: Complete the worker cutover while preserving history authorization at argument disclosure and releasing request-owned voice facts. Do we have a high-confidence way to reproduce the issue? Source tracing establishes both remaining paths; no target code was executed during this read-only review. Is this the best way to solve the issue? Using existing workers and committed receipts fits the repository architecture, provided final-effect authorization and ownership cleanup remain intact. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 006e965aa47d. Provenance checked
TestingProof path: shipped entry point. SecurityNeeds attention: Private CLI history needs current disclosure authority through deferred argument transfer. EvidenceSecurity concerns:
What I checked:
Likely related people:
PR surfacePR surface statistics unavailable: the file list is incomplete. LabelsLabel changes: No label changes. Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (23 earlier review cycles; latest 8 shown)
Reviewed October 12, 2026, 6:47 PM ET / 22:47 UTC (Revision 24). |
What Problem This Solves
Ordinary session reads in Gateway routing, agent execution, sandbox policy, plugin operations, Memory SDK consumers, and status rendering still reached synchronous SQLite through owner and SDK APIs. Bundled callers now await the existing workers or consume prepared facts updated by committed write receipts. This follows #169620 (merged as
2c7cc827b309c6a2da1cd6c2aa5cb930eb326030).The Gateway remains the single database owner. Creation and transcript writers publish their committed rows before dependent effects. Superseded write receipts invalidate derived row projections even when their member-policy facts survive. Request authorization retains those facts through dispatch and releases them with the existing owner. Catalog import binds its creation to the existing sharing authorization, forwards its creation and registration receipts, and releases the authorization when the operation ends. First-store input registration runs its existing callback inside input-actor preparation, so the committed creation is visible before chat admission. Describe-only authorization prepares its exact session row, avoiding an unrelated listing projection. Exact-run Stop captures the active controller and command cancellation targets before metadata awaits. Local model patches skip remote runtime preparation, matching runtime startup. A late superseded receipt preserves newer metadata, but still revokes an observed security-policy change; member-only successors cannot certify policy. A policy change followed by a quick restoration can conservatively reject the prepared turn; retry prepares current authority. Retained-history SSE joins the existing publication completion before its final authorization, adding no SQL. Placement maintenance merges current in-process receipts instead of rejecting an unrelated inventory revision. No new SQL, foreign-commit probes, fencing, admission phases, or cross-thread handshakes were added by these publication repairs.
All ordinary bundled reads migrate together; the four named effect-boundary readers below remain. Public synchronous SDK APIs remain warned deprecated adapters with documented async replacements. Deprecated APIs will be removed in a later release after the deprecation has shipped in a stable release. Native-incognito paths remain with #169363, still open at integration. Doctor/CLI one-shots retain their synchronous exception. Large transcript projections stay bounded in SQL. Final authority checks remain at execution, mutation, disclosure, approvals, credentials, and external publication. CLI history authorization now runs after permission/pairing/child-readiness awaits at the private-input boundary.
The host-tool and model-boundary corrections add no SQL or requests to ordinary durable chat: its composed source scopes have no leaf scoped preparation. Cold completion recovery can read
readHarnessCompletionSource, and Workshop can revalidate through its anchor after a token change. Those cold paths are not claimed universally SQL-neutral or remeasured at the final head. Completed results retain their existing binding lifetime without a post-effect transcript read. Context transformation and model dispatch prepare their existing source scopes before checking authority, including a denied-tool result that bypasses tool dispatch. Cron run-now joins the existing startup owner before creating its run receipt, so startup recovery cannot mark that fresh run interrupted.The retained synchronous SDK contracts were verified in stable
v2026.10.2(tag commit67f65e14); no unshipped public synchronous adapter remains. Four bundled real-effect callers retain a single live check:extensions/discord/src/voice/agent-control.ts:54: current permission/tool overlay before steering or cancel injection.extensions/clickclack/src/discussions/binding-store.ts:39: current incarnation before cross-session disclosure or channel effects.extensions/clickclack/src/discussions/binding-retention.ts:122: current absence at revocation/delete commit, preventing deletion of a returned attachment.extensions/clickclack/src/discussions/service-open.ts:290: current credentials and active session before external channel creation, update, or publication.These checks protect security or user data at the effect boundary; they are not ordinary bookkeeping reads. Deprecated APIs remain until a later release after stable deprecation.
The updater notification destination uses the async session reader. The pre-integration published-driver update cell passed; its exact scope and reuse limits are recorded below.
Removed checks and accepted edge cases
Duplicate admission, bootstrap, cron, status, and recovery bookkeeping reads: descriptive state can lag until the next existing publication; effect owners retain current authority.
Participant-only pending-publication rejection: known participant changes keep unrelated policy current; unknown and policy-changing writes still revoke it.
Verbosity rereads: a turn uses prepared preferences and receipts through completion.
Steering identity recapture: the retained source remains selected; no third read or generation handshake.
Suggestion target projection and post-authorization row recapture: chat dispatch uses the retained target; final chat authorization still guards the effect, and a revoked suggestion may finish its prior bookkeeping.
Preliminary delivery/media checks: one check remains at delivery or transcript persistence.
Repeated recovery entry and settings reads: recovery carries its selected facts through its own authorized writes. Stop retains one worker-prepared branch check immediately at cancellation so a request bound to a visible branch cannot cancel work on a different branch.
Aborted-partial rereads: reset can discard the old run's partial with a warning while cancellation succeeds. A rowless buffered Stop warns and drops its partial.
Repository fork rereads: an unrelated destination change conservatively retains the prepared repository for cleanup.
Session delete/archive repeated loads and doomed derived usage refresh: cleanup uses selected identity and committed postimages; deletion can leave the derived cache unrefreshed until removal completes.
GitHub option/workspace duplicate preparation: a revoked prepared response is retired even if the original state is subsequently restored; retry prepares anew.
Custom administrator method preparation: requests outside run/tool, communication, progress, and captured-target boundaries use the existing administrator bypass before reading session storage.
Retained placement pending-result/ACK/journal refusal: bookkeeping may settle while a turn uses its authorized destination; claim changes and indeterminate ownership still refuse.
Post-effect node ACK source recheck: an already accepted effect can acknowledge after the source projection changes; the existing pre-effect execution and publication authority remains the boundary.
Node maintenance response dispatch-snapshot recheck: already-dispatched pruning can settle after placement changes; live node, pairing, and coordinator custody still gate its response.
Same-owner draft/lifecycle custody rechecks: accepted input may finish after internal draft closure; actual revocation, changed policy, and successor-owner checks remain.
Unknown-tool diagnostic lookup: without prepared sandbox facts, formatting preserves the provider error.
Unused native retention and legacy read-plan paths: deleted with obsolete tests.
Sandbox source-list recapture: the compatible worker-selected sibling remains selected; final execution authority and physical custody stay enforced.
Deletion predicate recapture after historical cleanup: history-only invalidation retains the selected entry until the final delete transaction checks exact identity and metadata.
Recovery checkpoint and workspace-binding recapture: recovery may advance its own checkpoint and complete its authorized repository-to-worktree handoff; session identity, writer ownership, physical source, and placement authority still guard the effect.
Creation-token bind-time rereads, identity/lifetime assertions, and duplicate-token rejection: a retired internal creation token contributes no provenance; committed writer receipts and final effect authority remain authoritative.
Broad prepared-transcript row recheck during a mutation and duplicate source-preparation row comparison: a write can temporarily mark its own projection pending; retained lifetime and exact worker-effect identity predicates still govern the commit.
Stop metadata lookup behind the writer being cancelled: capture cancellation targets before the await and read metadata through the existing read-only worker. Stop continues against those captured targets; a replacement session or writer keeps its data, and stale bookkeeping is skipped with a warning.
Rejection of the operation’s own child-registration write: its committed receipt refreshes all prepared witnesses through their existing exact receipt filters. Registering a child in its sibling store does not itself change the parent’s security policy; genuine policy changes still revoke the relevant witness.
Rebinding an already admitted input to its predecessor’s session ID: accepted input may finish after an owned compaction rotates the transcript; the existing reply-admission owner still checks lineage, current database, cancellation, and live access. Original request admission remains exact, and replacements or revoked authority still refuse.
Placement-maintenance whole-inventory revision rejection: merge current in-process placement receipts into preservation; an obsolete placement can conservatively preserve data until the next receipt. Pending postimages add protection only. The existing deletion guard, database lifetime, and indeterminate ownership remain enforced.
Post-effect host-tool transcript recheck: a completed result may settle after a benign transcript write; run cancellation, Gateway lifetime, session binding, caller receipts, and workspace authority still gate it. Current source preparation remains mandatory before the next real effect.
Raw model context/dispatch assertions without source preparation: a benign foreground transcript write can retire the old token; the existing source scope refreshes before the next model effect, preserving revocation and cancellation authority.
Startup recovery racing a newly requested cron run: run-now joins the existing startup promise before recording the run; no new owner, polling, or retry.
T1 accounting
These are source sites, not statements executed in a turn. This table preserves the original lexical classification; final CI supplies the current classifier totals. The cutover changes bundled caller routes; retained mixed kernels still serve deprecated public SDK/native-incognito contracts and workers.
This does not claim zero raw T1, zero runnable T1, or a complete T1-compat graph classification. #169620 removed one redundant cache identity query; extracting the selected-row primitive relocated one expression and is not counted as a saving. Exact
fad6192d2passed the full CI ratchet (115039311632): T1 live 463→463, deprecated-only 9→9, with dialect mechanical/design/engine-maintenance groups unchanged at 0/5/0; upstream inventory changes do not alter the scoped lexical caveat above.Live measurement
One alternating shared-harness baseline/candidate pair used isolated state and ports, with ten warmed turns per run. The values below are within-run medians and ranges. Baseline:
f2c48ebd379297acd04d5ec3598e3d6986230204; measured candidate:a7e54cd163567e1cb21534ae374a41f846ea47cf. This is integrated evidence, not an isolated measurement against the final merge base81ad3bf71935: it includes upstream changes, including usage-cost SQL falling from 75 to 6 per turn. The later first-store registration, cold describe, cancellation, diagnostic, and type/test fixes do not add work to the measured ordinary warmed path. The host-tool and model-boundary corrections have no leaf scoped preparation on ordinary durable chat; cold Workshop and completion-recovery revalidation can read, and those paths were not remeasured. No second final-head runtime measurement is claimed.All 13 turns, 40 RPCs, child execution, cron, compaction, and clean shutdown passed. Warm means were 394.3→263.2 SQL and 89.5→62.8 requests; the whole reduction is not attributed solely to this lane. The descriptive session-operation group fell from 164.7→153.4 SQL and 40.1→36.3 requests per turn, with MAIN 0→0; that group also overlaps upstream changes.
The families overlap and are not additive. The candidate has one extra legacy
session-entry-readin warmed turn 09 (0.1 per turn). Both runs call recoveryshouldSwitchToLiveModelten times; the extra request exposes only a transport stack, so its caller remains unproven. This is disclosed as a small tradeoff within the lower session-group total, not labeled inherited or timer noise. The extra standalone watermark per turn is upstream: commit23dee3070(#169974) addedscanSqliteUsageRollup→readGeneration; its three relevant files are unchanged in this PR against823ba031f. Both observations are recorded in the actor follow-ups.Selected complete operation deltas expose the affected read paths:
session-entry2.5→0 SQL/0.5→0 requests,session-entry-list0.8→0/0.2→0,session-exact-entries9.3→9.1/3.4→3.1,session.entry.read16.6→16/4.6→4, andsession.entry.patch.commit37→31/6→5.session-row-factsremains 5 SQL/1 request per turn. These operation groups likewise describe the integrated comparison rather than exclusive lane attribution.Evidence
Final candidate:
8f4a601a015c6a2dc23ddb2310434f8402f54014, integrating main81ad3bf71935d80c60a8b4a34492e51630d883c3. Completed affected CI at preceding headfad6192d21ded59a7c46b2b5ba4fe837284f8f12: https://github.com/openclaw/openclaw/actions/runs/38317384965. Prior affected-head CI (36b37d472): https://github.com/openclaw/openclaw/actions/runs/38315731739. Preceding-head82dd6305aPR CI: https://github.com/openclaw/openclaw/actions/runs/38313840692. Reused main-tier CI at that head: https://github.com/openclaw/openclaw/actions/runs/38313866450. Atfad6192d2, production and aggregate test types, all five core test-type stripes, aggregate/core/three extension lint, source contracts, architecture and baseline ratchets pass. Security also passes. The SDK report, package boundary and runtime API evidence are reused as scoped below. The preceding main integration resolved three fixture-only conflicts: shared Codex setup/cleanup, sharing-profile schema/foreground leases, and provider config restoration. Upstream and lane assertions are preserved. Knip completed with only the two documented inherited missing-root files; the SDK diff and package boundary also pass; wire behavior passes at that head. The integration preserves upstream session initialization options and this lane's committed creation publications. The latest fixture-only repairs provide the actual Memory store config, prepare the profile catalog before sticky-model scenarios, and register redacted wire-test failure diagnostics before setup awaits, using native stderr to preserve output with Vitest silent mode. Main integration preserves the upstream media config, queue config, board catalog setup and captured progress tracker. Assertions and production effect checks are preserved.The final
fad6192d2→8f4a601a0push resolves five conflicts only. The MCP scenario keeps main’s private log/sanitizer; the creation-race test keeps main’s comment; the registry fixture keeps main’sonTestFinishedcleanup and removes duplicate cleanup. The input actor preserves main’s captured execution and cold-only preparation while passing the lane’s registration callback as the existing fourth argument. GitHub session lookup preserves main’s parallel identity/personal/pending/latest reads and the lane’s authorization disposal, deleting the duplicate old identity-read block. Against final main, those production resolutions retain three actor callback lines and the GitHub lifetime disposal. Basic oxfmt, oxlint, shell syntax and whitespace checks pass. Completedfad6192d2static evidence below is reused for this reviewed conflict-only integration; it is not represented as exact-final-head CI, and no new full CI cycle or SQL measurement was requested.The final two-file implementation repair (
1b3515f88) reuses the captured corpus reference when Memory forget classifies session-backed sources, and returns through the existing non-session push policy path when no session scope exists. It changes no SDK declaration, exported signature, inventory or wire flow. The eight Memory-forget recovery variants pass at36b37d472(115034120872), and all five push-authority-router variants pass there (115034121339, 4–8 ms). All affected type/lint checks pass atfad6192d2; preceding-head SDK/package evidence is reused on those unchanged inputs.Two independent Codex autoreview rounds completed. Accepted P1 findings were fixed; no third review. The P2 voice-request authorization-release leak remains a follow-up under the two-round limit. Changed-file oxfmt, oxlint, and
git diff --checkpass. SQL measurement remains the valid earlier pair above; no final-head runtime measurement is claimed.fad6192d2passes production, aggregate tests, and all five core test stripesfad6192d2passes aggregate lint, both selected core stripes, and all three selected extension stripes; unchanged other core stripes passed at82dd6305afad6192d2passes export collisions, session accessor, transaction, transcript-reader, and schema-baseline contracts (115039312290)fad6192d2architecture passes (115039312145). Knip at82dd6305a(115026060266) passes production/full checks and all export scans; only the two inherited missing-root files below failfad6192d2passes (115039311632): T1 live 463→463, deprecated-only 9→9, and unchanged dialect groups 0/5/082dd6305apasses all seven runtime guards (115026059065). Reused executed surface check atcbc23a949: 154 entrypoints, 3,736 exports, 2,189 callables, 207 deprecated, with no unauthorized stable-v2026.10.2 removals.1d62b2c0a→82dd6305apassed (115026059408), artifact 11776573599: no added/removed entrypoints, no removed exports; 24 added exports, 17 signature changes, 196 reachable export changes. Package boundary passes (115026059332)The
82dd6305aSDK report includesSessionTranscriptCorpusOptions.config?: OpenClawConfig. Its 237 affected exports include 196 reachable-export changes; the separate declaration-detail section has 156 entries. Report digest:7f5b3ed94d59e0ad4e16b621855a5fddf2894466c4c0e6fe5031cf0200ca3d1d. The corpus option adds no entrypoint, exported symbol, callable, or deprecation, but does change a reachable declaration. SDK script ceilings are limits, not measured surface counts. SDK barrels, Memory host SDK and Gateway client are unchanged from82dd6305ato36b37d472; the two final fixes alter private implementation only. Main integration is shared by base and candidate. The report is reused with this scope, not represented as a final-head declaration build.Behavior evidence on
1cc34b0d8: orphaned recovery passed (115019295606, 11.383 seconds); Feishu rich-post transport twins and retained legacy replay passed (115019295841, 2.530 seconds); all 14 corpus cases passed, including discovery of the caller's configured store without a global runtime snapshot (115017394943, 6.774 seconds). The prior wire test timed out at 240 seconds (115019300014) without emitting its catch-path diagnostics. Exact82dd6305anow passesnode-worker-launch-wire.e2e.test.ts(115027770269): the device-runner transfer/reconcile case took 161.313 seconds, with the complete shard taking 230.66 seconds. The accompanying workspace-isolation, tool-policy-gates and workspace-mutation E2Es also pass. Failure hooks are registered before setup awaits and use redacted native-stderr diagnostics; timeouts and assertions were not relaxed. Earlier paired live proof covers all 13 turns, 40 RPCs, child execution, cron, compaction, and clean shutdown, as detailed above.Prior Knip findings are inherited: the three production exports in
delivery-queue-storage.tsandopenclaw-state-feature-schema.tsmatch scheduled main93087c17(38305224828/job114997826780). Three UI team-scale exports match scheduled main11a12460482f(38311154418/job115017223014). The cold-load benchmark/probe unused-file findings are source-proven inherited missing roots: candidate and main had identical file blobs, incoming-reference sets, scan implementation, all-exports config, and package commands. Main stopped at the earlier export failure, so no executed main unused-file result is claimed. Current82dd6305aindependently reports only those two unused files; production unused files and production/full/script export scans all pass. Inherited failures are recorded in the campaign redmain inbox.The unchanged cron current-session completion test matches scheduled main
93087c17(38305224828/job114997828380): cancellation prevents the transcript write, but leaves one attachment withcleanupPendingwhile the assertion expects no records. The non-isolated-runner failures match that main run (114997828832): nativerun-termination.jsresolution and a removed synchronous schema-version initializer. These are inherited failures, not passing tests. Other unrelated historical timeouts are omitted; exact-candidate failures will be classified from their logs.Preceding-head
82dd6305anon-blocking findings: ordinary PR Control UI i18n passes (115027763633), while the main-tier job passes verification then reports catalog fallback baseline drift in its second command (115026058950). The UI, catalogs, schemas and i18n scripts are unchanged against integrated main; no matching failed recent-main job is claimed. Current non-isolated runner failure (115026061782) repeats the native-module and removed-initializer classes already seen on scheduled main above. The config-readiness mutation/roster case times out at 120 seconds (115026062156); it passed in this lane at56fcin 60.082 seconds and on main97a2785in 38.712 seconds. Source diagnosis found the only later lane runtime change normalizes reset creation keys, while this case performs no reset; startup/reload changes come from main. This timeout is disclosed as an untouched-flow follow-up, not as a reproduced main timeout. These findings are assigned through the campaign redmain inbox.The
82dd6305acron fallback-transcript case finds two stopped assistant messages instead of one (115026062297). Main commit4944a6df7(#169773) addedpersistModelFallbackTranscriptNoticefromrun-entry.onFallbackStep; that notice usesdeliveryMirrorkindmodel-fallbackand matches the old broad assistant/stop assertion. The test and notice-producing owners are byte-identical to integrated main. Prior lane candidates1ccand56fcpassed this case in 12.981 and 24.759 seconds, before that main change was integrated. This is a source-proven inherited stale assertion assigned to that owner/redmain; no executed main failure is claimed.The worker-deadline fallback case reports zero dispatches before its fake-timer assertion (115026061995). Its test, WorkerTaskPool and model-fallback sources are unchanged against integrated main and exercise an independent pool deadline. This is assigned as an unrelated timing follow-up based on source diagnosis; no executed main failure or exact timing cause is claimed.
The Bun personal-file cases fail because the unchanged test mock returns a profile without
aliases, while main655d57552(#170228) now consumes those resident aliases (115027766429). The test and owner are byte-identical to integrated main. This is an inherited stale mock assigned to that owner/redmain; no executed main failure is claimed.The native Talk action test aborts during detached-work closure at
36b37d472(115034125334) and repeats unchanged atfad6192d2(115039314940). Its test, control and publication owners, event/row preparation, Gateway admission and AsyncWorkScope sources match integrated main. Maine1462be71(#170231) already moves lifecycle publication outside the producer scope, while the transcript queue still inherits the scope that detached execution drains. This is a source-attributed timing defect assigned to #170231/redmain. Cached main runs pass; no executed main failure is claimed.The
36b37d472artifact-API composition case times out on its finalagents.deleteRPC (30 seconds), after prior artifact, environment, restart and download checks pass (115034121202). The test and delete/reload owners match main395ea60; the lane change only forwards the existing session entry, and this case has no artifact-agent session or run. Prior lane candidates passed, and recent main passed in 105.861 seconds. This is assigned as an untouched delete-flow timing follow-up; no stalled internal await or reproduced main failure is claimed.Published-driver update passed at pre-integration
64b798a, run 38290268672/job114957477892. That result is reused for the lane's unchanged installed-updater and service-control contracts; it is not represented as an exact-current-head update run. The updater notification change awaits destination lookup. Later main integration brings upstream changes equally into base and candidate. No remote lease is held.Size
Against integrated main
81ad3bf71935at8f4a601a0: 1,140 files, +30,166/−18,491 (net +11,675). Test classification is path beginningtest/, or filename containing.test./.test-/.e2e./.e2e-: 567 test files, +9,074/−4,979; docs: 4 files, +81/−5; remaining production, tooling, and metadata: 569 files, +21,011/−13,507. Growth comes from the complete bundled caller/API cutover. Stable deprecated compatibility, the four named effect-boundary readers, and native-incognito contracts remain as described above.