Repository navigation
refactor: separate session row materialization and presentation - #149771
Conversation
|
🦞👀 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. |
Capture 17 fixtures at three clocks from the unchanged row builder before separating committed metadata from request-time presentation. Keep the expected wire-byte hashes compact and emit mismatch JSON for diagnosis.
|
Codex review: needs maintainer review before merge. Reviewed September 16, 2026, 3:01 AM ET / 07:01 UTC (Revision 2). ClawSweeper reviewWhat this changesSeparates Gateway session-row input preparation, stable metadata construction, and time-dependent presentation while preserving existing response fields. Merge readiness✅ Ready for maintainer review This remains a useful, distinct refactor with no blocking correctness findings. The rebased head addresses the previous integration concern; neither related merged PR supplies this separation, and maintainer-authored work is protected from cleanup closure. Priority: P2 Review scores
Verification
How this fits togetherGateway session reads combine stored session metadata, subagent runs, model metadata, and transcript usage into rows consumed by session lists, descriptions, and event snapshots. This refactor separates those inputs from presentation without adding cross-request caching. flowchart TD
A[Stored sessions and transcript usage] --> C[Prepare row inputs]
B[Registry and model metadata] --> C
C --> D[Materialize stable fields]
D --> E[Present current row]
F[Clock and current run facts] --> E
E --> G[Lists descriptions and snapshots]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +62, Tests +653, Other -1. Total +714 across 15 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep one session-row owner that reuses prepared metadata while evaluating temporal fields at presentation time and leaving authorization with existing callers. Do we have a high-confidence way to reproduce the issue? Not applicable: this PR prepares an internal refactor rather than claiming a newly reproduced bug; its temporal and serialization contracts have focused regression coverage. Is this the best way to solve the issue? Yes: the split stays within the existing row owner, consumes the registry's captured inputs, and preserves caller-owned filtering and decoration without introducing another cache. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against b7d2835c93c7. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
Separate committed metadata from request clocks so later row reuse can preserve live status, child retention, and run-dependent cost display. Keep viewer decoration at its existing authorization boundary and capture raw run candidates before pure materialization. Preserve lightweight cost gating and metadata discovery ordering. Remove the redundant assertion and shrink its baseline entry from one to zero.
69ebd90 to
4aa6d0d
Compare
|
Merged via squash.
|
…claw#149771) * test: pin session row serialization across clocks Capture 17 fixtures at three clocks from the unchanged row builder before separating committed metadata from request-time presentation. Keep the expected wire-byte hashes compact and emit mismatch JSON for diagnosis. * refactor: separate session row materialization and presentation Separate committed metadata from request clocks so later row reuse can preserve live status, child retention, and run-dependent cost display. Keep viewer decoration at its existing authorization boundary and capture raw run candidates before pure materialization. Preserve lightweight cost gating and metadata discovery ordering. Remove the redundant assertion and shrink its baseline entry from one to zero.
Related: #149387
What Problem This Solves
Session row construction mixes committed metadata with request-time state, so reusing a constructed row can freeze status expiry, child retention, and the selected run's control owner or fallback cost. This is PR 1 of the session row projection series.
User Impact
No intended user-visible change. Session lists, descriptions, and event snapshots preserve their existing row values and serialized property order. No configuration, protocol, storage, cache, or invalidation behavior changes.
Why This Change Was Made
One module now owns input preparation, pure
materializeSessionRow, and clock-dependentpresentSessionRow. The list, describe, and single-row snapshot paths compose the same pair.buildGatewaySessionRowremains a thin composition helper for its remaining callers. The materialize/present names are retained.Filtering and viewer decoration stay at their existing caller locations. Sharing, visibility, activity permissions, placement, and active-run facts therefore retain their current authorization and post-yield freshness boundaries.
The registry index exposes its already captured snapshot map and exact in-memory winners through a narrow internal
inputscontract. This approved owner extension preserves #149466's worker-prepared index and removes Gateway's duplicate snapshot-reading scaffolding; it adds no SQLite read or plugin SDK export.Raw run candidates are required: when an older unended run ages out, a newer ended run can become the display run, changing both its controller and transcript fallback cost. Preparation reads transcript usage once for the candidate variants; presentation selects the appropriate result. Lightweight rows continue to permit token fallback while exposing only persisted cost.
The assertion-safety baseline removes exactly the row builder's obsolete one-count entry, recording the authorized shrink from 1 to 0 without restoring its redundant cast.
Series LOC ledger
PR 3 is planned to remove the 316-line
sessions-list-cache.tswhole-result cache and fence, fence-only counter readers, and duplicate row preparation across list/describe/search/snapshot paths. Those removals fund the projection implementation; the complete series remains required to be net-negative. None of that later work is included here.Evidence
7b47d7a65a17e7a49d943795a5b112ae4adcfe3c; every hash is unchanged. That base-compatible test was also executed in an isolated checkout. A mismatch writes canonical JSON under Vitest's temporary directory and reports its path, both hashes, and JSON in the failure log.expected undefined to be defined) and passes afterward. It verifies ungrouped snapshot rows, exact in-memory winners captured before a yield, and replay from those inputs. The lightweight-cost regression also retains its fail-before/pass-after proof.node scripts/check-changed.mjsandgit diff --checkpass. Fresh independent review of the rebased diff is scoped-clean through P2, with no actionable findings.Fixtures cover status expiry, runs and goal timestamps, child/swarm state, placement and ACP metadata, observer ordering, inherited settings, and draft/incognito visibility. No live Gateway or release operation was performed. Documentation is unchanged because the external behavior is preserved.