refactor(sessions): route new session store bypasses through the accessor#101179
Conversation
|
ClawSweeper status: review started. I am starting a fresh review of this pull request: refactor(sessions): route new session store bypasses through the accessor This is item 1/1 in the current shard. Shard 0/1. This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking. Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted. |
|
Codex review: needs maintainer review before merge. Reviewed July 6, 2026, 8:39 PM ET / 00:39 UTC. Summary PR surface: Source +56, Tests +129, Other +2. Total +187 across 11 files. Reproducibility: not applicable. this is a behavior-preserving refactor, not a bug report with a failing reproduction path. The review evidence is source-path comparison, focused tests in the diff, current-main inspection, and the PR body's A/B runtime proof. Review metrics: 2 noteworthy metrics.
Stored data model Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Next step before merge
Maintainer decision needed
Security Review detailsBest possible solution: Land the narrow accessor cleanup after maintainer review on the current base, with the boundary guard and focused session-state proof still green on the exact merge head. Do we have a high-confidence way to reproduce the issue? Not applicable: this is a behavior-preserving refactor, not a bug report with a failing reproduction path. The review evidence is source-path comparison, focused tests in the diff, current-main inspection, and the PR body's A/B runtime proof. Is this the best way to solve the issue? Yes: the accessor boundary is the right owner for these runtime persistence call sites, and I did not find a concrete patch defect. The safer alternative is not a different implementation but refreshing the branch and confirming the same proof on the current merge head. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 74bb2ad7a533. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +56, Tests +129, Other +2. Total +187 across 11 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
56dafb8 to
64a6513
Compare
What Problem This Solves
Recent features added session/transcript persistence that bypasses the session accessor (#88838's storage-neutral boundary): thread-compaction results persist via direct
updateSessionStoreinsrc/gateway/server-methods/sessions.ts(#98510), the cron isolated-agent guard read uses rawloadSessionStore({skipCache:true})(#98510), and session fork writes transcript JSONL files via rawfs.writeFile(#100814). Direct store/file calls in runtime code couple these features to the file layout and dodge the boundary guard.Why This Change Was Made
The accessor header states the contract: new runtime callers use the accessor, not
store.ts. This PR re-expresses the new call sites through the accessor with zero behavior change — persistence only, no product-logic movement:applySessionPatchProjection(the same APIsessions.patchfrom the same PR already uses), preserving the exact guard semantics (sessionId match, lifecycleRevision match, work-start error check, alias promote/prune, boolean persisted result).loadSessionEntry({readConsistency: "latest"})— the accessor already models the skip-cache need; freshness semantics unchanged.createForkedSessionTranscript(file-backed; samewx/0600/naming semantics; the SQLite mapping is documented on the method). Net −35 LOC in the fork runtime.readSessionTranscriptIndexcall insession-utils.fs.tsis legitimately file-tier (operates on an already-resolved artifact path inside the file backend the reader seam delegates to) — documented with a contract comment instead of rewired.Migrated files are added to the boundary guard's enforcement lists so they cannot regress.
User Impact
None — behavior-preserving refactor. Thread compaction, cron session admission, and session fork behave identically; existing tests for compaction guards, fork on-disk bytes, and cron lifecycle all pass unchanged.
Evidence
src/cron/isolated-agent/session.latest-read.test.ts(guard read observes latest persisted row past a still-current cache snapshot),src/config/sessions/session-accessor.fork-transcript.test.ts(fork header lineage + ordered record copy).server.sessions.compaction.test.ts(36 tests incl. stale-persist rejection and persistence-failure terminal events),server.sessions.create.test.ts,session-fork.runtime.test.ts+session-fork.test.ts, cronsession.test.ts,run.session-lifecycle.test.ts,delivery-dispatch.double-announce.test.ts.node scripts/check-session-accessor-boundary.mjspasses; tsgo core + core-test lanes clean; oxfmt/oxlint clean.Real behavior proof (A/B equivalence vs merge-base)
An identical scenario was run against a real gateway process (isolated temp state, no live models) at this head (
64a65136efa) and at the merge-base (e80e8a2b673); the normalized on-disk state dumps (session store + transcript bytes) are byte-identical across two runs per side, with 29/29 raw-byte assertions passing on both sides — demonstrating zero behavior change on all three rerouted paths.sessions.createfork over WebSocket; forked transcript verified on disk —<timestamp>_<sessionId>.jsonlnaming, mode0600,parentSessionlineage header, message records copied in order and byte-equal to the parent's, store entry referencing the fork.compactionCountadvanced, token/budget fields deleted, checkpoint + compaction record written). Negative probe: a second OS process rewriteslifecycleRevisionwhile the model response is held in flight — the guarded persist rejects withsession-changedand applies nothing.Scope disclosure: the cron leg invokes the production guard function (
loadCronSessionEntryLatest) directly rather than waiting on the full scheduler runtime; the cross-process freshness contract is what it proves, identically on both sides.