Repository navigation
refactor(agents): prepare watched-session prompts from worker reads - #164288
Conversation
Move live-turn, compaction, and bundled harness watched-session preparation to the existing shared-state and exact-entry readers. Capture store identity and current disclosure authority across waits, preserving deterministic prompt bytes. Keep the released synchronous SDK helper as deprecated third-party compatibility and require a live host assertion for its async replacement. Record the approved additive SDK surface and compiled-wrapper dependency.
|
🦞👀 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. |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Codex review: blocked before merge. Reviewed October 3, 2026, 9:08 AM ET / 13:08 UTC (Revision 5). ClawSweeper reviewWhat this changesMoves watched-session prompt preparation into existing database workers across agent turns, compaction, and bundled harnesses while retaining the synchronous plugin helper. Merge readiness⛔ Blocked before merge - 1 item remains This PR remains useful and has no supported blocking findings. The prior migration-proof concern is resolved: the introduced changes do not alter persisted data or schemas, and the released synchronous SDK contract remains intact. Priority: P2 Review scores
Verification
How this fits togetherWatched-session preparation turns durable group-watch records and session titles into a bounded prompt section describing readable conversations. Agent turns, compaction, and bundled harnesses consume that section before model execution. flowchart TD
A[Agent turn or compaction] --> B[Session and tool visibility gates]
B --> C[Shared-state worker reads watches]
C --> D[Session worker reads titles]
D --> E[Recheck authority and store identity]
E --> F[Render bounded prompt section]
E --> G[Reject or omit stale facts]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +280, Tests +175, Docs +27, Other +4. Total +486 across 26 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Technical reviewBest possible solution: Use the existing worker-backed readers for bundled prompt preparation while preserving deterministic prompt bytes and the documented third-party SDK compatibility window. Do we have a high-confidence way to reproduce the issue? Not applicable as a behavior-preserving refactor; current-main source directly establishes the synchronous reads being moved, and the inspected suite exercises the replacement boundary. Is this the best way to solve the issue? Yes. Reusing the existing shared-state and session readers preserves ownership, and retaining the released synchronous helper avoids breaking third-party plugins. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 60e1aa9bdb1c. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (4 earlier review cycles)
|
Resolve adjacent worker-access documentation additions by retaining both. Production changes merged without conflicts; the integrated ambient cutover received a clean independent P2 review.
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Model the actual worker context and read-context capture so pruning settlement tests reach the worker. The incomplete fixture reproduced four CI failures in five candidate runs; five base runs passed. All 11 repaired tests and the targeted typecheck pass, with a clean independent P2 review.
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Main's SQLite cleanup introduced import-time query-cache factories. Keep those helpers real while retaining the fixture's forbidden SQL calls. The missing-export failure reproduced five times on main and five times on the exact CI merge; all 28 tests in the repaired CI group and the targeted typecheck pass, with a clean P2 review.
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Merged via squash.
|
…penclaw#164288) * refactor(agents): prepare watched-session prompts from worker reads Move live-turn, compaction, and bundled harness watched-session preparation to the existing shared-state and exact-entry readers. Capture store identity and current disclosure authority across waits, preserving deterministic prompt bytes. Keep the released synchronous SDK helper as deprecated third-party compatibility and require a live host assertion for its async replacement. Record the approved additive SDK surface and compiled-wrapper dependency. * test(sessions): align worker control fixture with admissions Model the actual worker context and read-context capture so pruning settlement tests reach the worker. The incomplete fixture reproduced four CI failures in five candidate runs; five base runs passed. All 11 repaired tests and the targeted typecheck pass, with a clean independent P2 review. * test(sessions): preserve query factories in worker fixture Main's SQLite cleanup introduced import-time query-cache factories. Keep those helpers real while retaining the fixture's forbidden SQL calls. The missing-export failure reproduced five times on main and five times on the exact CI merge; all 28 tests in the repaired CI group and the targeted typecheck pass, with a clean P2 review.
What Problem This Solves
Live-turn and compaction prompt preparation read ambient watch cursors and exact session titles synchronously on the Gateway thread. Bundled harnesses reached those reads through the released synchronous SDK helper.
User Impact
Prompt text and behavior stay unchanged: sorted rows, the 20-row cap, UTF-16-safe title truncation, same-agent/main-session gating, sandbox visibility, and tool hints are preserved. No schema, stored-data, retention, durability, configuration, or update migration changes are required. No new
OPENCLAW_*names are introduced.Why This Change Was Made
Prepare watch targets through the existing shared-state reader and exact titles through the session reader, then render the existing prompt section. Capture physical stores and caller authority before waits; recheck identity, watch admission, and visibility after reads and cleanup. Reset, deletion, and pruning invalidate live read admissions; watch rows and grants are not cached.
All bundled callers await
prepareWatchedSessionsHarnessContextwith current host authority. The releasedbuildWatchedSessionsHarnessContextkeeps its parameters and synchronousstring | undefinedresult. Its deprecation record and migration documentation retain compatibility until an explicitly approved Plugin SDK major. The record is static compatibility metadata, not a data migration. Native provider input carriers are unchanged.Evidence
Final head:
511f2d67bb87ac324fe25c9644adc2226631556b; tree:1aab1208fb9ab2b6ce07bdd3ba9e619461c5a903.pnpm plugin-sdk:api:diff --base v2026.9.8 --head 511f2d67bb87ac324fe25c9644adc2226631556b --json <report> --summary <summary> --evidence <evidence>passed and reviewed, 231.02 s. The retained synchronous declaration is byte-identical; the async helper is additive. The retained helper'sreachableclassification reflects transitive type evolution since the release, not a declaration change. Report digest:d01cb84b3015bf2cb19fa9bed7dc24fca5f6f2146dd5323073ad02082d06108c.pnpm test <files> --maxWorkers=1: 35 passed, 36.08 s wall on the exact final head. Coverage includes real worker prompt preparation, SDK types, runtime process build graph, import closure, and the repaired control fixture.tbx_01m40xv62s7hh7c1eps3qtj19f(allocation run). The wrapper settled with exit 0 and the exact source tree above; the lease was stopped afterward. Allocation cleanup is not a test result.check-changed(725.21 s), build (476.49 s), zero import cycles, database-worker ratchet, and compiled-wrapper inventory. Runtime production delta remains +319/-39; the synchronous SDK paths retain their named compatibility contract.CI repairs and integration
Merge commit
202c8817bc45b38069a162879291d7c580854e85integrated main5f52ff0f863c544519ec80bbd7eeea4248bbf4d3. The only conflict was adjacent worker-access documentation additions; both were retained. Production changes merged cleanly.CI first exposed a PR-caused fixture mismatch: the mock lacked the admission identity and read-context capture used by pruning. Five candidate runs reproduced the same four failures; five merge-base runs passed. Fix
64b6f5f295b5102e1724a12c6b9439736ab05f74makes the fixture satisfy the actual worker-context type. All 11 tests then passed at the normal timeout (22.08 s wall). Diagnostic comparisons used one worker and a 10-second bound for blocked mock waits; committed test timeouts and assertions were unchanged.SQLite cleanup #164271 subsequently exposed an inherited import-time mock failure. Five main
c28042dade02951be3648174b7b23066ae0c4ff5runs and five exact CI mergeb8e6c2b9513d161017659331377c7480884848a0runs reproduced it. Fix511f2d67bb87ac324fe25c9644adc2226631556bpreserves real query factories while retaining the existing forbidden SQL-call guards. The repaired three-file CI group passed 28 tests (48.43 s suite duration); targeted types passed in 6.8 s. This overlap was incidental; no production restructuring was adopted. Both fixes are test-only. No CI retry or admin bypass was used.