Repository navigation
perf(sessions): reuse rows across unrelated subagent updates - #165932
Conversation
Key frozen row views by their actual runtime, child, and sharing facts instead of global subagent publications. Preserve live authorization and output snapshot isolation while avoiding unchanged row reconstruction and cloning.
|
🦞👀 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, 12:05 AM ET / 04:05 UTC (Revision 3). ClawSweeper reviewWhat this changesThe PR reuses unchanged session-list rows across unrelated subagent publications while refreshing runtime state and child navigation. Merge readiness✅ Ready for maintainer review This remains a useful, focused performance improvement absent from the inspected main revision. No introduced correctness defect was found; the latest CI failure is a database-lock assertion whose connection to this patch is unproven. Priority: P2 Review scores
Verification
How this fits togetherThe Gateway combines stored session metadata, current run state, and viewer permissions into session rows. Those rows feed session lists and event delivery to connected clients. flowchart TD
A[Stored session metadata] --> D[Session row projection]
B[Subagent publications] --> D
D --> E[Compare current row facts]
C[Viewer permissions and clock] --> E
E --> F[Reuse or rebuild frozen row]
F --> G[Session lists and events]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +1, Tests +32. Total +33 across 4 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep row reuse governed by current derived facts, with live viewer checks and immutable output snapshots. Do we have a high-confidence way to reproduce the issue? Yes: inspected main keys row reuse on global subagent publications, and the recorded baseline handler regression demonstrates unnecessary rebuilding after an unrelated ownership publication. This review did not execute that path. Is this the best way to solve the issue? Yes: comparing the facts actually consumed by presentation removes unnecessary invalidation while retaining the existing projection, permission, and snapshot owners. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against ad99343036ff. 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
History |
…w#165932) Key frozen row views by their actual runtime, child, and sharing facts instead of global subagent publications. Preserve live authorization and output snapshot isolation while avoiding unchanged row reconstruction and cloning.
What Problem This Solves
An unrelated subagent publication invalidates frozen
sessions.listrows and rebuilds their output snapshots even when those sessions have not changed.User Impact
Session lists and event readers reuse unchanged frozen row presentations during unrelated subagent activity. Current run state, viewer permissions, child navigation, and expiring display fields remain live. Sidebar, full/compact lists, and the Sessions board share this presenter;
sessions.catalog.listuses a separate native catalog pipeline.Why This Change Was Made
The row-view cache included the global subagent revision. Compare the row's actual derived runtime and child facts instead, reuse unchanged child-owner vectors, and preserve equivalent swarm summaries. The existing owners still control invalidation; no new revision, timer, configuration, or schema is introduced.
Materialized inputs are mutable: preview, profile, and lineage publishers update them in place. The deep copy therefore remains when producing a genuinely changed output, preserving snapshot isolation. Quiet polls already avoided that copy on the baseline; this change removes copies triggered by unrelated publications.
Production LOC: 14 added, 13 removed (net +1). The small growth preserves all seven mutable runtime fields after removing the global revision guard. Explicit scalar comparisons avoid allocating a temporary values array for each unchanged row; the redundant global invalidators and child-owner revision state are removed.
Evidence
Synthetic Linux rig, 5,000 sessions (2,300 unarchived), 25 viewers, the same seeded identities and fixed presentation clock. The retained-allocation comparison issues 710 sidebar requests over 600 seconds, with an unrelated subagent publication before every request. The harness uses the real list/projection owner with serialized-row delivery and request active-run context. Measurement base:
c20c6e5822d741c03831cac8ad805aace1735de3.present()self + descendant row-clone retained bytes, ten-minute windowLive-only sampling uses a 4 KiB interval and measures allocations made during the window that remain alive at its end. Zero sampled bytes is not a claim of zero process memory or a leak fix. Both runs use the same workload. All 75 quiet viewer/mode row-payload hashes and all 25 publication/poll row hashes match exactly. All 75 full-response hashes also match after normalizing only the fixture-specific top-level state path; no other field is normalized.
The under-100 KB unchanged-request allocation target remains unmet. With 512-byte all-allocation sampling after warmup, unchanged requests measured:
Those quiet polls already made zero row constructions/clones on the baseline. Remaining allocations include repeated authorization and temporal-signature preparation. The original lane 481 evidence scripts were unavailable, so this harness was reconstructed from the repository's session-list viewer benchmark; its absolute figures are not an exact replay of the earlier 469 KB/request result. Shared-host timing is secondary and is not used to claim a quiet-poll speedup.
The regression exercises the real
sessions.listhandler. It fails on the baseline after an unrelatedcommitOwnershippublication because the unchanged row is rebuilt, and asserts stable row identity plus no row construction or cloning after the fix.Blacksmith Testbox
tbx_01m47fyzmvs8fgrsg1a2npzm86, profileopenclaw-check:node scripts/check-changed.mjs --staged: passed on the source-hash-verified final candidate (all 27 test typecheck graphs, lint, export scans, and repository guards). Earlier attempts caught test-spy typing and a redundant shadowed test declaration; both were corrected.tbx_01m47kt2wddh8yjpxq88jv7w02, same provider/profile: final presentation/event/serialization files 10 tests passed (40.18 s Vitest / 42.23 s wrapper). Standalonepnpm test src/gateway/session-list-serialization.test.ts --maxWorkers=1: 3 passed, 8.46 s Vitest / 10.49 s wrapper, 2.09 s test time. Both leases are stopped/completed.Codex autoreview of the production change and complete owner/sharing context: scoped-clean, no P0–P2 findings. Rebased onto current
mainbefore publication; all four candidate files retained identical SHA256 hashes. Exact-head CI run 37409317865 on0d1187ed3e32b895ef6122b3a5ce4b47b6d50e3ecompleted with 44 successful jobs, including all 19 selected Node test jobs. Those shared Node jobs consumed 3,642 runner-seconds (92–342 seconds each); this is whole-shard cost, not isolated cost for the added regression.CI is blocked by two inherited main failures:
security-fast: production[email protected]fails GHSA-68fv-2mgg-jv7q. The identical advisory fails main run 37408159153 at14fe10d01c75. This PR changes no dependency files. The dedicated fix is fix: unblock CI with patched source-map-js #165902, still pending on main.check-test-types-core-4:src/flows/doctor-health.migration-refusal.test.ts:84and:182have incompletebeginDoctorMaintenancemocks after refactor(cli): deslop CLI and commands #165900 removed the broader return annotation. Missing fields areserviceUpdateVerdict,warnings,failureFacts, and (in the first fixture)databaseWrites. The affected test blob is identical on this branch and current main (1056faefbc6d52378202559975048e63ff674392); neither the test nor the Doctor owner is changed here. The aggregateopenclaw/ci-gatefailure follows these upstream failures.The main recheck at
3b9c3e35de61still has both conditions. No rerun, dependency change, unrelated fixture fix, or merge was used to conceal these failures. The lane remains four files and one focused commit.Remote command record
All Testbox commands used
blacksmith-testbox, profileopenclaw-check, with normal Crabbox sync. Initial gate/development runs usedtbx_01m47fyzmvs8fgrsg1a2npzm86; final focused tests and standalone cost used replacementtbx_01m47kt2wddh8yjpxq88jv7w02. Dependencies were initially absent:pnpm install --frozen-lockfilepassed once;pnpm docs:listalso passed.node scripts/run-vitest.mjs src/gateway/session-list-serialization.test.ts --maxWorkers=1node scripts/run-vitest.mjs src/gateway/session-list-serialization.test.ts src/gateway/session-row-presentation.test.ts src/gateway/session-row-event-parity.test.ts src/gateway/session-row-projection.invalidation.test.ts src/gateway/session-row-projection.subagent-index.test.ts --maxWorkers=1node scripts/check-changed.mjs --stagednode scripts/run-vitest.mjs src/gateway/session-list-serialization.test.ts src/gateway/session-row-presentation.test.ts src/gateway/session-row-event-parity.test.ts --maxWorkers=1tbx_01m47kt2wddh8yjpxq88jv7w02passed all 10 tests, 42.23 s wrapper.pnpm test src/gateway/session-list-serialization.test.ts --maxWorkers=1The Linux rig ran the standalone synthetic harness through
nice -n 10 ionice -c3 node --import ./scripts/tsx.mjs, withTMPDIRinside its task worktree. Quiet allocation runs usedRIG_CALLS=250after 125 warmup calls. Paired retention runs usedRIG_MODES=sidebar RIG_CHURN=1 RIG_LIVE_SECONDS=600; both exited 0. Full-envelope parity runs usedRIG_HASH_ONLY=1; baseline and candidate both exited 0. Sampling precedes coverage/call instrumentation to avoid measuring coverage-induced deoptimization. An intermediate signature using an array spread was rejected after attribution showed extra quiet-poll allocation; the tables above use the final explicit-scalar implementation. The rig worktree and its processes have been removed.