You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 67f3d09
Browse filesBrowse the repository at this point in the historyBrowse files
refactor(daemon): session script publication behind one capability (#1478 P4a) (#1532)
* refactor(daemon): add the tagged script-publication aggregate
First step of P4a. Nine co-resident optional SessionState fields encode two
lifecycles plus a shared output target, with nothing in the shape saying the
lifecycles are disjoint — so readers re-derived that from field combinations
and writers had to remember which siblings to clear.
The aggregate makes both invariants structural: a session publishes nothing,
authors ordinarily, or is under repair; and force lives inside the target, so
retargeting replaces the authorization along with the path.
Three corrections after an adversarial review of the first draft:
- The target is a default|explicit union, not a mandatory path. A bare
'open --save-script' arms with no path and lets the writer resolve a
daemon-owned destination at write time, and force can be granted before any
path exists. Eagerly materializing a default path would have silently changed
retarget semantics, because today's check requires a previously persisted
path — so 'open --save-script --force' then 'close --save-script=out.ad' is
not currently a retarget and the grant survives. That behavior is preserved
here and flagged in the docblock as a probable #1258 gap; tightening it is a
product change and belongs in its own commit.
- The repair status relation is not linear. A failed commit followed by
'replay --from' demotes complete back to armed, so demoteRepairToArmed exists
and deliberately RETAINS the close receipt: the platform close already
succeeded for that operation identity, and dropping it would re-dispatch a
close on retry — which is also how a migrator ends up reaching for the
caller-computed platformCloseSucceeded boolean the brief forbids.
- The receipt doc no longer claims it is set only at close-succeeded and later,
since the demotion path makes {armed, receipt set} reachable.
Still to come in this PR: both projections, and the writer migration. Note the
brief's seven-file writer inventory omits session-open.ts, which holds the only
two writers of the authoring armed/aborted states.
Refs #1478
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01RXQLYV7etZx3gcXsUsrQJ8
* refactor(daemon): migrate script publication onto the tagged aggregate (#1478 P4a)
The eight co-resident SessionState fields (scriptRecordingState, saveScriptPath,
saveScriptForce, saveScriptBoundary, saveScriptComplete, saveScriptCommitted,
repairPlatformCloseReceipt, repairSourcePath) are gone; SessionState.scriptPublication
holds the aggregate, and every writer migrated in this commit — no shadow state.
Two daemon-private projections own the writes, enforced by the R7 ownership gate:
- session-replay-transaction.ts (ReplaySessionTransaction): repair arm/demote/
complete/abort, close receipts, and the uncommitted/boundary/sourcePath reads
that idle-reap, tombstones, divergence-hold, and the recorder's exclusion key off.
- session-script-publication-capability.ts (SessionScriptPublication): authoring
arm on open, the recorded --save-script flag ingress, active publication, the
published transitions, and the effective per-target force decision (#1258).
The writer keeps the commit transition so idempotence stays colocated with the
atomic publish.
Failure/retry transitions pinned as the brief requires: platform-close failure
leaves state unchanged (no receipt, retry re-dispatches); publication failure
retains target+force+receipt (same-identity retry skips close dispatch); committed
and aborted are explicit terminal states that drop the receipt.
Design decisions resolved:
- Force retention across a default->explicit retarget is preserved as-is and
still flagged in resolveScriptTarget's docblock as a probable #1258 gap;
tightening it stays a separate product change.
- The never-armed 'close --save-script' whole-log publication folds into the
authoring lifecycle (armed at the recorded close, published in the same
request) instead of a fourth variant: every close path that reaches the write
deletes the session, so the transient armed state cannot leak into
'session save-script' eligibility, whose not-armed-before-this-journey
rejection is untouched.
One real bug caught by the migrated tests and fixed in resolveScriptTarget: a
bare (pathless) re-arm collapsed an already-materialized explicit target back to
the daemon default, wiping the healed-sibling path on every per-step repair
re-arm and defeating the persisted-force preflight bypass. A bare re-arm now
keeps the previous target and only adds a live force grant.
R7 rows consolidated to one scriptPublication entry (three owners) and the
recordSession row narrowed; the R10 baseline drops to 22 writer-owned fields /
28 owner claims so the consolidation cannot regrow.
Gates: typecheck, lint, format, layering clean; 624 files / 5220 tests pass
(two known contention-flake timeouts reproduce only under full-suite load and
pass in isolation).
Refs #1478
Co-Authored-By: Claude <[email protected]>
* refactor(daemon): satisfy the Fallow gate by extracting decisions, not suppressing
- scriptPublicationTarget is module-private; both public target reads
(scriptTargetPath/scriptTargetForce) go through it and nothing else did.
- validatePublicationEligibility splits into a pure ineligibility classifier
and an error table, so the four rejections read as one decision each.
- prepareSaveScriptSession hands its two arm-time rejections (authoring
re-arm, EEXIST preflight) to rejectSaveScriptArming and keeps only the
demote-and-arm flow.
- The repair-record-exclusion provider scenario extracts its three phases
(arm-and-hold, exclusion contrast, healed-script contract) into named
helpers; the test body is the journey again.
Refs #1478
Co-Authored-By: Claude <[email protected]>
---------
Co-authored-by: Claude <[email protected]>
0 commit comments