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 dcd8b65
Browse filesBrowse the repository at this point in the historyBrowse files
refactor(daemon): split src/daemon/types.ts into request types and session state (#2346)
* refactor(daemon): split daemon/types.ts into request and session-state modules
`src/daemon/types.ts` served two audiences from one file: the dispatch request
shape and the daemon's live session record. It also sat in the only daemon type
cycle — it imported `RefFrame` from `ref-frame.ts`, which imported `SessionState`
back — so neither file could be read in isolation.
Three modules replace it, each importing only downward:
- `daemon-request-wire.ts` declares `DaemonWireRequest`: a dispatched request
with no `internal` key and no property path to `SessionState` or `DeviceLease`,
so a consumer can read a request's command, flags and public metadata without
depending on the session record.
- `daemon-request.ts` adds the daemon-only half (`DaemonRequestInternal`, which
stays unexported) plus the response vocabulary.
- `session-state.ts` owns `SessionState` and the shapes only it holds.
The cycle is cut by `ref-frame-slot.ts`, declared below both `ref-frame.ts` and
`session-state.ts`: it owns the frame VALUE (the class stays unexported, so the
type remains nominal and unconstructible from outside), while `ref-frame.ts`
keeps every lifetime transition and every `session.refFrame` write.
No behavior change: every importer moves to the module owning the symbol it
uses, with no re-export shim at the old path. `client-normalizers.ts` takes
`SessionRuntimeHints` from `@agent-device/kernel/contracts`, which declares it.
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Ujrc8LYmvM249WY8921J1Y
* test(daemon): assert the wire request shape cannot reach session state
A type-level walk over `DaemonWireRequest` fails `tsc` if the shape regains an
`internal` key or grows a property path back to `SessionState` or `DeviceLease`.
Positive controls over `DaemonRequest` prove the walk finds both when they are
there, so a walk that never matches anything cannot pass by accident.
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Ujrc8LYmvM249WY8921J1Y
* test(daemon): keep the three over-budget test files at their base length
Splitting `daemon/types.ts` turns one combined import into two in every file
that used both halves. Three of those test files are already over the 1,000-line
tripwire, where the size ratchet allows no growth, so each sheds one line that
was carrying nothing:
- `snapshot-handler.test.ts` and `find.test.ts` each drop a `toHaveLength`
assertion an adjacent `toEqual` on an explicit array literal already makes.
- `session-replay-repair-transaction.test.ts` names the filtered close actions
instead of wrapping the expression across three lines inside `expect`.
No assertion is weakened and no test content is removed. Splitting these files
along the modules they mirror is the standing remedy, but none of those modules
split here, so it stays out of this change and is tracked in #2353.
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Ujrc8LYmvM249WY8921J1Y
* chore(gates): point the daemon modularity and wire-compat gates at the split modules
R7 now locates the `SessionState` declaration by the declaration itself rather
than by a recorded path: `sessionStateWritePressure` measures the merge-base
tree too, and that tree still declares it in `daemon/types.ts` — a path constant
would measure it as zero pressure and bank the headroom.
R10's external-importer ratchet covers all three modules that replaced
`daemon/types.ts`, so moving a symbol between them cannot reopen the boundary to
a new outside zone. The recorded membership is unchanged: `client-normalizers.ts`
and `remote/daemon-artifacts.ts` both import `daemon-request.ts` only.
The daemon RPC closure gate waives `DaemonRequest`, `DaemonResponse` and
`DaemonArtifact` by path, so those three keys follow the declarations to
`daemon-request.ts`. `DaemonRequest`'s rationale now says what it is — the
server-side narrowing of the kernel declaration that fixes the wire shape —
rather than calling it a re-export alias.
The `live-state-shape` and session-resource declaration sites move with
`SessionState`; the depgraph lookalike fixture takes a new plausible path now
that `daemon/session-state.ts` is the real root.
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Ujrc8LYmvM249WY8921J1Y
---------
Co-authored-by: Claude <[email protected]>
@@ -214,7 +223,8 @@ function checkDaemonTypesImporters(edges: readonly ResolvedImportEdge[]): Layeri
214
223
file,
215
224
line: edge.line,
216
225
message:
217
-
`external production imports of daemon/types.ts may only shrink from the recorded ${allowed.size}. `+
226
+
`external production imports of the daemon request/session-state modules may only shrink `+
227
+
`from the recorded ${allowed.size}. `+
218
228
'Use an existing neutral contract; do not move DaemonRequest into contracts to satisfy this gate.',
219
229
}));
220
230
for(constfileofallowed){
@@ -223,7 +233,7 @@ function checkDaemonTypesImporters(edges: readonly ResolvedImportEdge[]): Layeri
223
233
rule: 'R10 daemon-modularity',
224
234
file: 'scripts/layering/daemon-modularity.ts',
225
235
line: 1,
226
-
message: `${file} no longer imports daemon/types.ts — delete it from externalDaemonTypesImporters in the same change so the dependency cannot return.`,
236
+
message: `${file} no longer imports a daemon request/session-state module — delete it from externalDaemonTypesImporters in the same change so the dependency cannot return.`,
227
237
});
228
238
}
229
239
returnviolations;
@@ -309,7 +319,7 @@ export function daemonModularitySummary(reference: LayeringRatchets): string {
309
319
return(
310
320
`R10 holds R7 at the merge-base's ${session.writerOwnedFields} writer-owned fields / `+
311
321
`${session.ownerFileClaims} owner claims, R9 at its ${reference.largestTypeCycle.length} files per zone, `+
0 commit comments