refactor(daemon): consolidate session-script test factories and drop saveScriptDefaultedHealedPath - #1508
refactor(daemon): consolidate session-script test factories and drop saveScriptDefaultedHealedPath#1508thymikee wants to merge 1 commit into
Conversation
…saveScriptDefaultedHealedPath Preparatory slice for P4a (#1478). No aggregate, no transaction type, no publication-writer migration — those land separately. Two things: 1. Name the session-script session states in the shared test factories (`makeAuthoringSession`, `makeRepairArmedSession`, `makeRepairCompleteSession`) and route 40 inline session literals across 11 test files through them. The `saveScript*` fields are not independent — recording without a boundary is ordinary authoring, a boundary without `saveScriptComplete` is an ARMED-but-uncommittable repair, and only the COMPLETE combination publishes — so re-deriving the combination per test buried the distinction each test was actually about. Pure refactor: the factories write today's fields and no assertion was weakened. 2. Delete `saveScriptDefaultedHealedPath`. It had zero production readers: the writer's refuse-on-exist guard has been uniform since #1235, so the flag was written in three places and never consulted. Removing it takes its R7 owner row with it and lowers the R10 baseline from 30/42 to 29/40 (the ratchet fails on a drop too, so this cannot be deferred). Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RXQLYV7etZx3gcXsUsrQJ8
Size Report
Startup median (7 runs, lower is better):
Top changed chunks:
|
|
Reviewed exact head What I verified:
Local exact-head checks:
GitHub checks are green so far, including integration, layering, Fallow, FreeRange, packaged CLI, typecheck, and platform-independent smokes. Coverage plus Android/iOS smoke/release jobs were still pending at review time, so merge readiness is conditional on those exact-head jobs finishing green. One scope clarification for the landing record: despite the P4a terminology, this PR is the test-factory/dead-field prep slice, not P4a’s aggregate or ownership migration itself. The body already states that clearly. |
|
Reviewed exact head
Exact-head CI is green, including integration, coverage, layering, typecheck, platform smokes, and native releases. This is ready to merge as the stated P4a prep slice (not the P4a ownership/state-machine migration itself). Residual risk: no separately authorized cross-vendor review was performed. |
Preparatory slice for P4a (#1478). This introduces no aggregate. No
ReplaySessionTransaction, noSessionScriptPublication, no tagged session-script cluster, and no production publication writer is migrated — all of that is the separate P4a PR. This exists so that PR is reviewable.1. Session-script test factories
~250 direct writes of
saveScript*/recordSessionwere spread across the daemon test tree as inline object literals. P4a proper has to change the shape of every one of them, so they get a name first.Three factories next to the existing
makeIosSessioninsrc/__tests__/test-utils/session-factories.ts:makeAuthoringSessionrecordSession, no repair boundarymakeRepairArmedSessionsaveScriptBoundary, the flag the writer'srepairArmedkeys offmakeRepairCompleteSession40 inline session literals across 11 test files now go through them. The heaviest is
session-script-writer.test.ts(24 literals, 20+ of which spelled out the same three-to-five-field combination). Named "authoring" rather than "recording" becausesession.recordingis the unrelated screen-capture state, anddaemon-runtime-recording-teardown.test.tsalready has a localmakeRecordingSessionmeaning that.The factories write today's fields — pure refactor, no production change, no behavior change, no assertion weakened.
Deliberately left explicit
session-action-recorder.test.ts/selector-recording.test.ts(9 sites) setsaveScriptBoundary: 0with norecordSession. That is the repair-armed marker in isolation, which is exactly the predicate those tests exercise; forcing them through a factory would add a field production couples but these tests deliberately don't.request-router-repair-expired.test.ts'stombstonedSession— a boundary plusrepairSourcePathwith no recording, one site, no repetition to remove.session-store.test.tskeeps its ownmakeSession: one test mutatessession.device.name, and the shared factories hand back the module-levelIOS_SIMULATORby reference, so routing it through them would make that mutation leak across tests. Only the dead-field lines were removed there.request-router-typed-error.test.tskeeps its tenant-scoped simulator (simulatorSetPath), now passed into the shared factories asTENANT_SESSION_DEFAULTSrather than re-spelled per test.session-replay-repair-loop/-empty-tail/-acceptance, the two integration scenarios,request-save-script-transports.test.ts) were left alone — they read the fields, they don't construct them.2.
saveScriptDefaultedHealedPathdeletedZero production readers, verified. A repo-wide grep finds only three writers (
session-replay-runtime.ts:867/870,session-action-recorder.ts:83), the type declaration, the R7 ownership row, and one test assertion. Nothing branches on it: the writer's refuse-on-exist guard (publishHealedScriptAtomically) has been uniform since #1235 — an explicit--save-script=<path>and the default.healed.adsibling are refused identically — so the flag has been bookkeeping with no consumer.Deleting it required, in the same commit:
SESSION_STATE_FIELD_OWNERSinscripts/layering/session-state.ts;scripts/layering/daemon-modularity.ts:writerOwnedFields30 -> 29,ownerFileClaims42 -> 40 (the field claimed two owner files). The ratchet fails on a drop as well as a growth, so this could not be deferred.scripts/layering/daemon-modularity.test.tsneeded no change — it asserts againstDAEMON_MODULARITY_BASELINEdynamically rather than against literals.scripts/layering/model.test.tswas checked: its AST fixture string usessaveScriptComplete, not the deleted field, and its field-count assertions derive from the tables, so it is unaffected.The one test that asserted on the flag (
session-script-writer.test.ts) kept its other concern — thatclose --save-script=<explicit path>re-points a defaulted-healed repair and publishes cleanly to the new target — and lost only the marker assertion.Gates
pnpm check:affected --base origin/main --run:format,lint,typecheck,layering,fallow,mcp-metadataandbuildall pass.vitest-relatedruns 236 files / 2269 tests with 1 pre-existing failure:src/daemon/handlers/__tests__/session-test-runner.test.ts("test dispatches per-platform scripts",['ios','android']vs['android','ios']). It reproduces unchanged onorigin/main(32b9db2d7) with this branch stashed, is in the P3 worker'ssession-test*.tsterritory, and is pulled into the related set only because this PR touchessrc/daemon/types.ts. Every test this PR actually edits passes.Coordination
The only shared-file edit is the two-line
writerOwnedFields/ownerFileClaimsbaseline inscripts/layering/daemon-modularity.ts— localized, well away from the R10 logical-module policies the P3 worker is editing.session-replay-runtime.tsis touched only at ~867 (the arming step), disjoint from P3's ~461.Refs #1478
🤖 Generated with Claude Code
https://claude.ai/code/session_01RXQLYV7etZx3gcXsUsrQJ8
Generated by Claude Code