Repository navigation
perf(agents): revalidate question authority through session readers (session authority B2) - #165552
Conversation
… workers Move current chat admission, reply authority, lifecycle preparation, verbosity, and maintenance reads through existing workers. Retain physical source identity and foreign-commit freshness, preserve accepted lifecycle settlement through close, and carry prepared transcript selection facts.
Join accepted event batches and listener settlement in fixtures. Keep restart metadata preparation with the work-admission owner and make callback this contracts explicit.
Merge main to resolve session admission and event-test conflicts. Preserve the qualified worker-backed admission owner from #164682 and main's consolidated tests, awaiting asynchronous event handling where required. Reuse internal-effects filtering across both Gateway read paths.\n\nThe complete candidate is clean through P2 autoreview. Focused conflict tests and remaining changed-check and published-driver update gates are tracked on #165028.
Use the existing async-aware event subscription helper in the consolidated verbosity test. The previous merge retained the plain unsubscribe callback while awaiting its drain method, causing a TypeError before the assertions. The corrected event-handler file passes all 82 tests. Together with the four unchanged passing files, the integrated focused group covers 163 cases. The one-line fixture correction is clean through P2 autoreview.
Merge main's transcript-context lane while retaining its prepared-start validation and released callback compatibility. Use the captured session initialization binding instead of a caller-thread session read, and combine context validation with lifecycle facts in the final anchor snapshot. Focused reply, anchor, context, runtime-build and import checks pass. P2 review raised a conditional global-alias concern, rejected after independent source tracing: the final read uses an admission receipt created from the selected stored key, and mismatched admission/session keys are refused beforehand. No actionable review finding remains.
Await asynchronous agent-event consumers and projection disposal. Move lifecycle fault injection to prepared callbacks, and track accepted writes through owner-controlled persistence before fixture cleanup. Initialize runtime config before observing row publications.
Use partial mocks for lifecycle preparation, session entry writes, and worker reads. Remove the three obsolete mock-factory baseline entries. The five affected tests, typed core lint, mock-export scanner, and P2 review pass.
Merge main 228ff57 to incorporate the host-owned cron test routing fix. Read session currentness before the final transcript anchor snapshot, then recheck live routing and run authority without another worker lookup. A real branch switch during the old final lookup returned stale delivered state; the new regression proves the repair. Move the unchanged transcript reply text helper and its existing tests to the reply-input owner, updating every internal caller. Released callback contracts remain unchanged.
Merge main dc518bf for the real session-store conflicts introduced by snapshot-only entry hydration. Retain main's projection types and selection defaults alongside physical source identity retention and internal-effect filtering. The four focused worker/currentness/anchor cases, typed core lint, diff checks, and fresh P2 review pass. Earlier unchanged proof retains its original source attribution.
Join the physical-store writer queue before inserting the malformed fixture row. Session replacement starts asynchronous maintenance; an uncoordinated synchronous host write can block the admission callback a worker needs to release its SQLite lock. Preserve the raw bytes, post-admission position, lack of publication, and all assertions. The original lock reproduced in CI and one of five head controls; the targeted repaired case, typed lint, formatting, and P2 review pass. The separate slow handle-cap case remains recorded in local controls.
Keep run-owned policy preparation separate from caller lifetime bindings so released unbound V1 backends remain usable. Explicit caller assertions still require the guarded path, and legacy dispatch revalidates current owner and policy. Retain terminal availability classification and update indirect fixtures for real fingerprints, awaited question registration, and optional steering preparation. Focused proof: 299 tests in 11 files passed in 535.58 seconds; fresh P2 autoreview is clean. No schema, retention, durability, or configuration change.
Treat completion or abortion of the captured target during fingerprint preparation as follow-up admission. Keep caller revocation and live-target route changes fenced, and let the existing completion barrier settle before draining the next turn. Deferred-read regressions fail on the prior head and prove exactly-once follow-up at both await boundaries, revoked caller rejection, and aborted-owner settlement. All 26 focused tests, production/messaging types, lint and formatting pass; fresh P2 autoreview is clean.
Compose fresh question policy reads with the existing final session-reader boundary and migrate bundled input adapters to awaited preparation. Retain live creator, caller, backend, physical-store, and session-generation checks before resolving or cancelling a question. Keep released synchronous/custom dispatch contracts with pinned native assertions. Refuse a replacement policy session even when its fingerprint matches, and preserve unknown-answer custody without replay.
|
🦞👀 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 maintainer review before merge. Reviewed October 6, 2026, 3:51 AM ET / 07:51 UTC (Revision 7). ClawSweeper reviewWhat this changesThe branch moves question-answer and cancellation policy reads into session workers, rechecks current authority before effects, and adds optional asynchronous plugin callbacks while preserving released synchronous contracts. Merge readiness✅ Ready for maintainer review This PR remains useful: current main does not cover its remaining work. The pinned diff has no actionable correctness or security findings, and the supplied boundary evidence supports normal merge review. Priority: P2 Review scores
Verification
How this fits togetherOpenClaw’s question subsystem receives answers and cancellations from agent and inbound-message adapters. It checks the question creator, caller policy, and session ownership before resolving a question or storing a secret. flowchart TD
A[Answer or cancellation] --> B[Agent input adapter]
B --> C[Question reservation]
C --> D[Session worker policy reads]
D --> E[Current authority checks]
E --> F[Resolve or cancel question]
E --> G[Guarded secret write]
E --> H[Refuse stale input]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +648, Tests +404, Docs +32. Total +1084 across 30 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep final question effects under the existing session and question owners, with fresh policy checks and the documented synchronous SDK compatibility window. Do we have a high-confidence way to reproduce the issue? Yes, a focused boundary regression replaces the classification session during awaited persistence while preserving its policy fingerprint, then checks refusal before resolution. The supplied before/after results support that path; this read-only review did not execute it. Is this the best way to solve the issue? Yes, composing fresh reads with the existing final question boundary preserves one authority owner and avoids a competing policy implementation. Released callbacks retain their signatures and compatibility checks. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against ca43d1919788. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (6 earlier review cycles)
|
|
Preserve landed session-authority preparation, alias-aware read plans, FIFO input custody, and released synchronous SDK callbacks while composing question policy reads at the final effect boundary. Retain existing other-owner session checks before secret-write grants without reacquiring reader admission. No schema, retention, permissions, or update migration changes.
Keep Codex question handlers beside their authority helper within the existing module. Exercise retained session policy against the canonical offline-maintenance fence, use valid persisted sandbox state, and align landed authority fixtures with the closure-bound async projector. Preserve released synchronous contracts and existing input custody.
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Merged via squash.
|
…session authority B2) (openclaw#165552) * perf(sessions): serve remaining per-turn session authority reads from workers Move current chat admission, reply authority, lifecycle preparation, verbosity, and maintenance reads through existing workers. Retain physical source identity and foreign-commit freshness, preserve accepted lifecycle settlement through close, and carry prepared transcript selection facts. * refactor(sessions): finish async admission cutover Join accepted event batches and listener settlement in fixtures. Keep restart metadata preparation with the work-admission owner and make callback this contracts explicit. * test(sessions): drain the merged event subscription fixture Use the existing async-aware event subscription helper in the consolidated verbosity test. The previous merge retained the plain unsubscribe callback while awaiting its drain method, causing a TypeError before the assertions. The corrected event-handler file passes all 82 tests. Together with the four unchanged passing files, the integrated focused group covers 163 cases. The one-line fixture correction is clean through P2 autoreview. * test(gateway): finish async lifecycle fixture cutover Await asynchronous agent-event consumers and projection disposal. Move lifecycle fault injection to prepared callbacks, and track accepted writes through owner-controlled persistence before fixture cleanup. Initialize runtime config before observing row publications. * test(gateway): preserve lifecycle fixture module exports Use partial mocks for lifecycle preparation, session entry writes, and worker reads. Remove the three obsolete mock-factory baseline entries. The five affected tests, typed core lint, mock-export scanner, and P2 review pass. * test(gateway): serialize malformed-row fixture writes Join the physical-store writer queue before inserting the malformed fixture row. Session replacement starts asynchronous maintenance; an uncoordinated synchronous host write can block the admission callback a worker needs to release its SQLite lock. Preserve the raw bytes, post-admission position, lack of publication, and all assertions. The original lock reproduced in CI and one of five head controls; the targeted repaired case, typed lint, formatting, and P2 review pass. The separate slow handle-cap case remains recorded in local controls. * perf(agents): prepare tool authority through session readers * fix(agents): retain all steering guards and exact sandbox reads * test(gateway): import the steering contract from its owner * test(reply): retain acceptance coverage with preparation tests * fix(agents): preserve legacy steering during worker preparation Keep run-owned policy preparation separate from caller lifetime bindings so released unbound V1 backends remain usable. Explicit caller assertions still require the guarded path, and legacy dispatch revalidates current owner and policy. Retain terminal availability classification and update indirect fixtures for real fingerprints, awaited question registration, and optional steering preparation. Focused proof: 299 tests in 11 files passed in 535.58 seconds; fresh P2 autoreview is clean. No schema, retention, durability, or configuration change. * fix(reply): retain input when its steering target completes Treat completion or abortion of the captured target during fingerprint preparation as follow-up admission. Keep caller revocation and live-target route changes fenced, and let the existing completion barrier settle before draining the next turn. Deferred-read regressions fail on the prior head and prove exactly-once follow-up at both await boundaries, revoked caller rejection, and aborted-owner settlement. All 26 focused tests, production/messaging types, lint and formatting pass; fresh P2 autoreview is clean. * perf(agents): revalidate question authority through session readers Compose fresh question policy reads with the existing final session-reader boundary and migrate bundled input adapters to awaited preparation. Retain live creator, caller, backend, physical-store, and session-generation checks before resolving or cancelling a question. Keep released synchronous/custom dispatch contracts with pinned native assertions. Refuse a replacement policy session even when its fingerprint matches, and preserve unknown-answer custody without replay. * fix(agents): finish question authority integration Keep Codex question handlers beside their authority helper within the existing module. Exercise retained session policy against the canonical offline-maintenance fence, use valid persisted sandbox state, and align landed authority fixtures with the closure-bound async projector. Preserve released synchronous contracts and existing input custody.
What Problem This Solves
Question answers and cancellations still projected session policy on the Gateway thread, and a matching fingerprint did not establish current authority at the final effect. Compatibility dispatch could also accept a replaced classification session with equivalent policy.
User Impact
Ordinary prepared question resolution and cancellation move their caller-policy session reads off the Gateway thread while retaining live creator, caller, backend, and session-incarnation checks. Released synchronous dispatchers remain compatible. There is no schema, configuration, retention, durability, permission, or update migration, and no new
OPENCLAW_*name.Why This Change Was Made
Compose caller-policy reads with the existing question session-reader batch and consume them immediately before the effect. Secret commits acquire retained readers before worker grants and keep their existing short indexed other-owner checks. Uncertain dispatch outcomes retain custody and are never replayed.
Integrated main
98262d8b5fdawith a merge commit after B1 #165370 and native creation writes #165819 landed. The resolution preserves main's complete alias/source read plans, partial-capture compatibility, native/incognito behavior, FIFO preparation, and final queue guards. Retained native reads now reuse the same alias-selection owner. The two Codex question handlers live beside their authority helper in the existing steering module.Released SDK check: compared
v2026.10.1-beta.1andv2026.9.8public harness/runtime contracts. Existing synchronous callbacks and parameters remain intact; async question companions are optional, documented in the compatibility record, and type-tested. The new async reply projector was absent from the latest tag; its closure-bound signature needs no receiver, and two landed fixtures now capture it directly.Follow-up native-read debt remains at
src/auto-reply/reply/reply-tool-authority.ts:660,src/gateway/session-utils-store-worker.ts:367, andsrc/gateway/question-session-access.ts:616/:625. These pre-existing short indexed other-owner reads retain current authority during secret grants; readers are acquired before grants, with no maintenance re-admission or snapshot subprocess inside them. Released custom dispatchers and process-native incognito compatibility are excluded from the moved-path zero-SQL claim.Overlap: #146847 (question ingress/authority), #165122 (compatible input steering/runtime), and #162433 (umbrella design). Integration retains their landed semantics and keeps this delta focused on question authority.
Evidence
pnpm test <listed files> --maxWorkers=1invocation took 1,232.37s; a duplicated tooling summary is excluded from the count. The two indirect auto-reply suites passed in their existing routes, so no worker-routing change was needed.pnpm test src/gateway/session-utils-store-worker.test.ts --maxWorkers=1then passed all three cases in 288.61s wall (Vitest 230.20s, 92% transform; new retained-reader case 2.429s). CI seconds are not isolated from the shared test shard..bind(operation)calls; no production contract was widened or cast. Core lint, extension lint, fixture lint, formatting, andgit diff --checkpassed. The final extension type replays took 11.89s and 10.51s; core lint took 334.66s and extension lint 631.53s, including artifact ownership and SDK declaration preparation.98262d8b5fda→ integration commit06a51f5af5a3passed in 1,607.73s, acknowledgement digest64b79729. No entrypoints or exports were removed. The directcallGatewayToolsignature change preserves its existing authority fields and adds optional preparation; other rows describe reachable declaration changes. Later corrections only move private Codex implementation and fix tests; SDK source and public signatures are unchanged from that report.Current published candidate:
b927127394324734a3eabdef971ea12858a29499. Exact-head CI run 37429456950 passed on attempt 1, with no failed checks or reruns. ClawSweeper revision 6 completed on this head at 2026-10-06 07:37 UTC with no actionable correctness or security findings and no before-merge items. All execution evidence above is local; earlier performance measurements below retain their original revision scope and are not new latency claims.Historical proof on the original approved head, retained for context
Evidence
The initial three failures were fixture failures: the real claim returned true, the real handler ran once, and all six intercepted reads used the independent policy key. The fixture had waited for the execution key. Correcting that gate retained refusal, pending-state, and zero-SQL assertions. The original three cases then passed in 121.25s.
The session-incarnation regression uses the real session writer during awaited persistence and explicitly proves the policy fingerprint remains equal. Both legacy-function and custom V2 cases failed before the pinned check (accepted
true; 140.41s wall). A raw SQL prototype was discarded as evidence because canonical admission rejected its missing writer proof before the intended identity boundary.Focused Vitest commands use
--maxWorkers=1; timings include shared-host worker preparation and cleanup.gateway-question.authority-worker.test.tsgateway-question.test.tsandserver-methods/question.test.tsExplicit import gate:
test/scripts/runtime-process-build-graph.test.ts,src/auto-reply/reply/get-reply.imports.test.ts,src/state/openclaw-state.worker.imports.test.ts,src/worker/worker.runtime-imports.test.ts,src/gateway/worker-environments/worker-turn-launcher.imports.test.ts, andtest/scripts/eager-import-closure.test.ts. Indirect callers were exercised; the existing host-owned/fork routing already covers this cutover, so no routing change was needed. CI seconds are not yet measured.Final SQLite worker ratchet passed against B1
1e2b52ce7b1aebdf1f7fab6f432ef50dcdf52d9c; final-source Madge reports 0 cycles (183.49s wall). Line-cap, max-lines, assertion, timeout-race, and environment-name guards passed; the environment count remains 473/473.Final SDK comparison passed in 2,604.47s against B1
1e2b52ce, acknowledgement digesteb6b7c20, with no removed entrypoints or exports. Public named changes are the intended optional preparation and async claim/cancel companions. Its*module closures include pre-existing internal worker types; those are not new callable SDK dispatch inputs. Production sources remain identical to that SDK candidate after the final fixture type corrections.All selected
check-changedsteps passed across the full run and its same-source continuation. The full invocation took 2,029.08s and passed all four type lanes, dead-export scans (zero entries), and core lint before SDK declaration preparation hit its 300-second build deadline. Using the existingOPENCLAW_PLUGIN_SDK_BOUNDARY_ROOT_SHIMS_TIMEOUT_MS=1800000setting, extension lint passed in 1,310.20s; every remaining command from the unchanged dry-run plan then passed. The complete continuation took 2,153.83s. No source, test timeout, assertion, or guard changed for this recovery, and no selected check was skipped.Testbox, AWS, and Hetzner attempts stalled in local source-capsule preparation before native provider allocation. They ran no remote checks and created no leases; all task-owned processes were stopped. All execution evidence above is local.
Measurement scope: exact B1
aee090ace971e77b8a39279939d7bad8b131449eversus an earlier B2 source snapshot, using the same question fixture. Executed caller-thread session SELECTs 27 → 0; both revisions accepted the input and answered through the real handler. This attributes statements, not latency. Final question regressions independently assert zero caller-thread SQL for the moved paths. Current static scanner T1 inventory: 887 → 887; the earlier 895 count used a stale inventory.The ordinary Gateway workload does not exercise questions. Its B1 production baseline
b2b681b644732ce05e0421b138c112b073dd1dc4(production-identical toaee090a) versus B2 tree64fd998534336097a24082534c925b733b689015measured warmed MAIN 160.7 → 161.1 statements/turn, whole MAIN 7,029 → 6,961, all threads 51,942 → 51,965. All 13 turns and 37 RPCs, child spawn, cron, compaction, and clean shutdown passed; three failed BEGIN IMMEDIATE lock attempts were excluded under the existing counting method. Build 658.49s; workload 277.59s. These measurements predate the final compatibility/ordering refinements and are not presented as a final-head latency benchmark.Landing verification
Released SDK source comparison: checked
v2026.9.8publicagent-harness-runtimeexports, question dispatcher, and V2 reply injection contracts. Released synchronous callbacks and parameters remain intact; the async companions and preparation fields are optional. The existing compatibility record and public-subpath type tests cover this boundary.Rechecked final question authority: ordinary resolution/cancellation and embedded/local settlement consume fresh caller-policy reads immediately before the effect. Secret-store commits retain the agent-database reader before the shared-state grant; their documented short indexed other-owner reads do not reacquire maintenance admission or invoke snapshot fallback inside the grant. Same-fingerprint session replacement is rejected by session identity and lifecycle revision.
Additional indirect-worker routing proof on
3f5ef914cf4357afcc4185e51d144dc9ef5260b8, each with--maxWorkers=1:src/gateway/mcp-http.question-authority.test.tspassed all 12 tests (474.28s wall);src/auto-reply/dispatch.question-input.test.tsplussrc/auto-reply/reply/agent-runner-steer-adoption.question-recovery.test.tspassed all 31 tests (167.80s wall). All passed in their existing project routes; no route or assertion changed. These timings include worker preparation/imports and cleanup; additional CI seconds are not measured.