Skip to content

Commit 49e3d0f

Browse files
committed
refactor(move): move every daemon file into its layer folder
Daemon-root-relative mapping applied by codemod (git mv plus every importer repo-wide, package-subpath and vi.mock specifiers, the package exports map, markdown docs, and repo-path literals included), with the repository-wide format sweep the rewritten lines require. The folder under the daemon root becomes the layer declaration; the manifest still carries the claim until the gate commit retires it. 655 moves over 665 tracked package files (10 cross-layer test-support leaves stay identity in the top-level __tests__/support/), 2,884 relative-spec rewrites in 581 files, 539 repo-path literal rewrites, 634 package-subpath rewrites, 16 exports-map keys, and markdown retargets confined to paths whose files exist at head.
1 parent b03b59e commit 49e3d0f

941 files changed

Lines changed: 3653 additions & 3164 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.device-evidence/CHECKLIST.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ appended warning:
9999
### Proof the review asked for on this lane
100100

101101
The false-attribution class is covered by unit tests rather than a device run, because the device
102-
cannot show a cache hit on command: `packages/daemon/src/__tests__/capture-disclosure-target-activation.test.ts`
102+
cannot show a cache hit on command: `packages/daemon/src/core/__tests__/capture-disclosure-target-activation.test.ts`
103103
pins that a cache-reused tree discloses nothing, and
104104
`src/__tests__/daemon-composition/interaction/interaction-capture-disclosure.test.ts` pins that
105105
a press which consumed no capture is not disclosed against an older tree.

‎.fallowrc.json‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
"scripts/help-conformance-sample-outputs.d.mts",
6969
"scripts/help-conformance-runner-output.d.mts"
7070
],
71-
"dynamicallyLoaded": ["packages/daemon/src/interaction/index.ts"],
71+
"dynamicallyLoaded": ["packages/daemon/src/execution/interaction/index.ts"],
7272
"ignoreDependencies": [
7373
"@theme",
7474
// @agent-device/maestro owns the source import, while the published root
@@ -243,7 +243,7 @@
243243
},
244244
{
245245
// The interaction facade exposes #2178's named route inputs and deferred handlers, plus the existing ref mutation response consumed by help conformance. Fallow's production graph cannot follow the request-handler-chain dynamic imports, so this exact list is the facade contract.
246-
"file": "packages/daemon/src/interaction/index.ts",
246+
"file": "packages/daemon/src/execution/interaction/index.ts",
247247
"exports": [
248248
"FindRouteInput",
249249
"refMutationAdmissionResponse",
@@ -363,7 +363,7 @@
363363
},
364364
{
365365
// #1458: getSessionCommandKind's former production consumer (the session.ts if-chain) was replaced by SESSION_COMMAND_HANDLER_IMPLS, which encodes command-kind groupings directly via shared handler references instead of a kind lookup. The accessor and its SessionCommandKind classification remain covered by daemon-command-registry.test.ts, a test-tree file outside --production analysis.
366-
"file": "packages/daemon/src/daemon-command-registry.ts",
366+
"file": "packages/daemon/src/core/daemon-command-registry.ts",
367367
"exports": ["getSessionCommandKind"]
368368
},
369369
{
@@ -380,7 +380,7 @@
380380
]
381381
},
382382
{
383-
// packages/daemon/src/__tests__/request-runtime-binding.test.ts drives the daemon's exact bind through the recovery authority, whose cancellation race is what rejects; production reaches it only through finishRecoveredDurableCapture and recoverDurableCaptureResource in the same package.
383+
// packages/daemon/src/core/__tests__/request-runtime-binding.test.ts drives the daemon's exact bind through the recovery authority, whose cancellation race is what rejects; production reaches it only through finishRecoveredDurableCapture and recoverDurableCaptureResource in the same package.
384384
"file": "packages/capture-kit/src/durable-capture/index.ts",
385385
"exports": ["acquireDurableCaptureRecoveryAuthorityBeforeDeadline"]
386386
},

‎AGENTS.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ Read the declaration rather than maintaining a prose copy:
4949

5050
- commands and their surface, runtime-use, batch, and timeout traits:
5151
`packages/command-registry/src/registry.ts`
52-
- daemon route ownership and request-policy traits: `packages/daemon/src/daemon-command-registry.ts`
52+
- daemon route ownership and request-policy traits: `packages/daemon/src/core/daemon-command-registry.ts`
5353
- interaction paths and guarantees: `packages/contracts/src/interaction-guarantees.ts`
5454
- canonical command names: `packages/command-registry/src/catalog.ts`
5555
- device runtime-use declarations and fact admission:
56-
`packages/command-registry/src/registry.ts`, `packages/daemon/src/runtime-admission.ts`, and
56+
`packages/command-registry/src/registry.ts`, `packages/daemon/src/core/runtime-admission.ts`, and
5757
`src/platform-runtime-gateway.ts`
5858
- common command input fields, and which surface may write an input key (model, operator, retired):
5959
`src/commands/common-input-fields.ts` and `src/commands/input-audience.ts`
@@ -110,7 +110,7 @@ under `contracts/fixtures/`.
110110
## Runtime and diagnostics seams
111111

112112
Diagnostics use `@agent-device/host-kit/diagnostics`. Request diagnostics belong in the session request log;
113-
session artifact paths come from `packages/daemon/src/session-artifact-paths.ts`. App/device logs remain in `app.log`;
113+
session artifact paths come from `packages/daemon/src/core/session-artifact-paths.ts`. App/device logs remain in `app.log`;
114114
Apple runner and xcodebuild output remains in `runner.log`.
115115

116116
Normalize failures with `normalizeError` and preserve `hint`, `diagnosticId`, `logPath`, and typed

‎docs/adr/0003-daemon-command-registry.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ to public command identity, and it required duplicate command sets to stay align
2121
Keep public command identity in `src/command-catalog.ts` and public input/output contracts in
2222
`src/commands/**`.
2323

24-
Add `packages/daemon/src/daemon-command-registry.ts` as the daemon-side source of truth for command route
24+
Add `packages/daemon/src/core/daemon-command-registry.ts` as the daemon-side source of truth for command route
2525
ownership and daemon request-policy traits. Request modules consume predicate functions from the
2626
registry instead of recreating command string sets. Handler modules own execution logic only; they do
2727
not export duplicate coverage tables to prove route membership.
@@ -85,5 +85,5 @@ derived daemon registry is therefore permitted **only if** it preserves all of t
8585
A single flat public descriptor whose daemon fields leak into public views is **not** permitted — that is
8686
the "collapse daemon policy into a public command registry" failure this ADR exists to prevent. Compose
8787
facets owned by their domains; derive the registry from them. Until that derivation lands and is pinned
88-
by the registry tests, the hand-authored `packages/daemon/src/daemon-command-registry.ts` remains the source of
88+
by the registry tests, the hand-authored `packages/daemon/src/core/daemon-command-registry.ts` remains the source of
8989
truth and the operating rule in `AGENTS.md` is unchanged.

‎docs/adr/0004-ios-snapshot-backend-strategy.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ facet in `@agent-device/capture-kit` owns snapshot policy generally rather than
115115
stated as a duration budget; the loop derives the deadline from the window's `markedAt` itself, so
116116
the budget is always spent from the action and a caller has no absolute instant it could get
117117
wrong.
118-
`packages/daemon/src/session-snapshot-freshness.ts` keeps only what needs a session: reading and retiring
118+
`packages/daemon/src/core/session-snapshot-freshness.ts` keeps only what needs a session: reading and retiring
119119
the window on store-owned `SessionState`, and choosing the comparison baseline from snapshot
120120
lineage. It remains the declared R7 owner of `androidSnapshotFreshness`.
121121
- **Timeout evidence.** Whether a capture failed because the hierarchy never arrived is decided
@@ -150,7 +150,7 @@ those roots and are outside that gate. It carries a positive control, because a
150150
matching would look identical to a boundary being obeyed.
151151

152152
The residual call sites #1983 also named are audited and deliberately left in place.
153-
`packages/daemon/src/direct-ios-selector.ts` carries no presentation policy: `isLocalIosRunnerSession` and
153+
`packages/daemon/src/core/direct-ios-selector.ts` carries no presentation policy: `isLocalIosRunnerSession` and
154154
`readSimpleIosSelectorTarget` are session routing (device family, provider ownership, the
155155
stabilization window), while `deriveDirectIosNodeSelector` and `isDirectIosSelectorFallbackError`
156156
are selector derivation and ADR 0011 delegation-on-error. The latter two are pure and

‎docs/adr/0008-command-descriptor-registry.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Accepted
2424
A command's identity is restated, by hand, across roughly ten tables that must stay aligned by
2525
convention: `PUBLIC_COMMANDS` (`src/command-catalog.ts`), the per-command metadata and family facets
2626
(`src/commands/**`), the capability matrix (`src/core/capabilities.ts`), the daemon command registry
27-
(`packages/daemon/src/daemon-command-registry.ts`, ADR 0003), the structured-batch allowlist
27+
(`packages/daemon/src/core/daemon-command-registry.ts`, ADR 0003), the structured-batch allowlist
2828
(`src/batch-policy.ts`), the MCP exposure sets, the Node client interface and impl (`src/client-types.ts`,
2929
`src/client.ts`), and the generic-dispatch `switch` (`src/core/dispatch.ts`, whose `default: throw` makes a
3030
missing or renamed command a runtime error, not a compile error). Adding one command touches ~24 files, the

‎docs/adr/0012-interactive-replay.md‎

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,7 @@ path — no text editing, no silent similarity-heal.
730730

731731
**Core mechanism — the healed script IS `session.actions`.** No new splice engine. `session.actions`
732732
already accumulates every executed action for the session's lifetime
733-
(`packages/daemon/src/session-action-recorder.ts:37`, unconditional push), and the divergence refusal is
733+
(`packages/daemon/src/core/session-action-recorder.ts:37`, unconditional push), and the divergence refusal is
734734
pre-dispatch (target verification refuses before the device action, decision 3), so a divergent step is
735735
never pushed. Across a repair session: original steps that verified and dispatched land in
736736
`session.actions`; the divergent step is absent (refused pre-dispatch, never recorded); the agent's
@@ -766,7 +766,7 @@ works" and "healed scripts are always valid":
766766
steps are re-executed during the repair replay; only if recording is armed from the start do they land
767767
in `session.actions` with fresh `target-v1` evidence. Arming late yields a hybrid healed script (an
768768
annotated corrective step glued to a bare, unannotated prefix) that re-diverges on its own next replay
769-
(`packages/daemon/src/interaction/internal/interaction-common.ts:64-65` attaches evidence only when `recordSession` was
769+
(`packages/daemon/src/execution/interaction/internal/interaction-common.ts:64-65` attaches evidence only when `recordSession` was
770770
true when the step ran).
771771
- **R2 — `--from` continuation only; never re-run the full replay on the same session.** After a
772772
divergence at step N and the corrective action, the agent must continue with `replay --from k
@@ -808,8 +808,8 @@ works" and "healed scripts are always valid":
808808
instead of leaving it to agent judgment.
809809
- **R4 — corrective actions must materialize to selector form; the writer fails loudly on a bare `@ref`
810810
cross-session export.** A `press @e12` normally resolves a `selectorChain` at runtime
811-
(`packages/daemon/src/interaction/internal/interaction-touch-targets.ts`), which `buildOptimizedActions`
812-
(`packages/daemon/src/session-script-writer.ts:69-83`) rewrites to a selector line. If no `selectorChain` was
811+
(`packages/daemon/src/execution/interaction/internal/interaction-touch-targets.ts`), which `buildOptimizedActions`
812+
(`packages/daemon/src/core/session-script-writer.ts:69-83`) rewrites to a selector line. If no `selectorChain` was
813813
captured, the writer must refuse to emit a bare `@ref` line into a persisted `.ad` — a session-bound
814814
ref will not resolve in a fresh run. It **fails loudly**: an error surfaced to the user with a non-zero
815815
exit, never a swallowed or silently-dropped line (existing session-write paths swallow such failures;
@@ -893,7 +893,7 @@ by construction. The healed `.ad` is written only when the repair ends (below) a
893893
- The healed `.ad` is published when a teardown commits the transaction at state `COMPLETE` — normally the
894894
agent's own `close`/`close --save-script <out>`, but any teardown of a completed transaction commits
895895
(see the commit state machine below) — reusing the existing `session.actions` serializer
896-
(`SessionScriptWriter.write`, `packages/daemon/src/session-script-writer.ts:30-52`) over the post-watermark slice
896+
(`SessionScriptWriter.write`, `packages/daemon/src/core/session-script-writer.ts:30-52`) over the post-watermark slice
897897
only (R6). When no
898898
`<out>` path is given, the default is the **`<original-stem>.healed.ad` sibling**: the original script's
899899
path with its `.ad` extension replaced by `.healed.ad` (e.g. `flows/login.ad` → `flows/login.healed.ad`),
@@ -943,7 +943,7 @@ a separate naming change, not part of this decision.
943943

944944
**Scope: this refusal is uniform across repair AND ordinary recording, not repair-only.** Everything
945945
above is written in the context of decision 6's repair-armed heal, but `publishHealedScriptAtomically`
946-
(`packages/daemon/src/session-script-writer.ts`) is the single publish primitive `SessionScriptWriter.write` calls
946+
(`packages/daemon/src/core/session-script-writer.ts`) is the single publish primitive `SessionScriptWriter.write` calls
947947
for every `--save-script` target, with no repair-armed-vs-ordinary branch — a repair-armed heal
948948
(`saveScriptBoundary` set) and an ordinary, non-repair `open --save-script`/`close --save-script`
949949
recording (`saveScriptBoundary` absent) publish through the exact same exclusive `linkSync`. Before this
@@ -1002,10 +1002,10 @@ The tombstone itself expires after its bounded window, after which the key is fu
10021002
> Provenance travels as `internal.replayPlanStep`, stamped by `invokeResolvedReplayAction`
10031003
> (`src/daemon/handlers/session-replay-action-runtime.ts`) — the single point every plan step is
10041004
> dispatched, so the marker covers annotated and unannotated steps alike. `internal` is a daemon-only
1005-
> channel (`toDaemonRequest`, `packages/daemon/src/server/http-rpc-methods.ts`, never copies it off the wire), so
1005+
> channel (`toDaemonRequest`, `packages/daemon/src/server/server/http-rpc-methods.ts`, never copies it off the wire), so
10061006
> authored provenance cannot be spoofed by a client; this is the same channel `replayTargetGuard` and
10071007
> `findResolvedTarget` already use. The rule is written once, in `isInteractiveObservation`
1008-
> (`packages/daemon/src/session-action-recorder.ts`), and both recording call sites consume it.
1008+
> (`packages/daemon/src/core/session-action-recorder.ts`), and both recording call sites consume it.
10091009
>
10101010
> **2. The corrective-read trap: why even out-of-band reads need an opt-in.** Excluding every out-of-band
10111011
> read is still not safe on its own: a divergence's **correction** can itself be a read. In the wave-3 E3 drift, the diverged step **was** a `get`, so its corrective replacement is a
@@ -1044,11 +1044,11 @@ The tombstone itself expires after its bounded window, after which the key is fu
10441044
>
10451045
> **4. How the rule projects across CLI/Node/MCP surfaces.** The exclusion is enforced at a single
10461046
> daemon-side choke point — `isExcludedRepairSegmentObservation` in `recordActionEntry`
1047-
> (`packages/daemon/src/session-action-recorder.ts`), gated on `session.saveScriptBoundary !== undefined` (set ONLY
1047+
> (`packages/daemon/src/core/session-action-recorder.ts`), gated on `session.saveScriptBoundary !== undefined` (set ONLY
10481048
> by a repair-armed `replay --save-script`; an ordinary, non-repair `open --save-script`/`close --save-script`
10491049
> authoring recording never sets it — see decision 6's "Scope" note above) and on the entry's
10501050
> `interactiveObservation` marker, which both recording call sites
1051-
> (`packages/daemon/src/selector-recording.ts` for `get`/`is`/read-only `find`, `packages/daemon/src/snapshot-runtime.ts` for
1051+
> (`packages/daemon/src/core/selector-recording.ts` for `get`/`is`/read-only `find`, `packages/daemon/src/sessions/snapshot-runtime.ts` for
10521052
> `snapshot`) compute from the shared `isInteractiveObservation` predicate rather than each re-deriving it.
10531053
> Every surface reaches this same function because every surface's request reaches the same daemon.
10541054
>
@@ -1159,8 +1159,8 @@ above and the gates they name are the authoritative record of current behavior.
11591159

11601160
At acceptance, replay was deterministic. `.ad` scripts were plain text — one action per line, `#`
11611161
comments, and a `context platform=... device=... theme=...` header (`src/replay/script.ts`) — recorded
1162-
via `open --save-script` (`packages/daemon/src/session-action-recorder.ts`,
1163-
`packages/daemon/src/session-script-writer.ts`) or hand-written, and executed step-by-step by
1162+
via `open --save-script` (`packages/daemon/src/core/session-action-recorder.ts`,
1163+
`packages/daemon/src/core/session-script-writer.ts`) or hand-written, and executed step-by-step by
11641164
`runReplayScriptFile`
11651165
(`src/daemon/handlers/session-replay-runtime.ts`) under the daemon's `replay`/`test` commands
11661166
(`src/daemon/handlers/session-replay.ts`). Recorded touch/fill/get targets are selector chains with
@@ -1289,15 +1289,15 @@ both `.ad` and Maestro paths) grounds the same conclusions from the caller's sea
12891289
"Retry with --debug and inspect diagnostics log for details." (`defaultHintForCode`,
12901290
`src/kernel/errors.ts:253-254`).
12911291
- **Recordings contain zero verification steps.** The script writer strips every recorded `snapshot`
1292-
action (`buildOptimizedActions`, `packages/daemon/src/session-script-writer.ts:69`: `if (action.command ===
1292+
action (`buildOptimizedActions`, `packages/daemon/src/core/session-script-writer.ts:69`: `if (action.command ===
12931293
'snapshot') continue;` — only synthetic ref-scoped snapshots are re-inserted, as resolution aids, not
12941294
observations), and the record-time flag allowlist (`SANITIZED_FLAG_KEYS`,
1295-
`packages/daemon/src/session-action-recorder.ts:46-77`) carries neither `settle`/`settleQuietMs` nor `verify`,
1295+
`packages/daemon/src/core/session-action-recorder.ts:46-77`) carries neither `settle`/`settleQuietMs` nor `verify`,
12961296
so `--settle`/`--verify` are dropped from recorded steps. A recording therefore replays actions with
12971297
no outcome observation at all — exactly the gap decision 3's record-time identity evidence fills.
12981298

12991299
A related, currently under-used precedent: recorded `@ref` steps already carry an optional identity
1300-
hint in the `.ad` file. `appendRefLabel` (`packages/daemon/src/session-script-writer.ts:235-240`) writes the
1300+
hint in the `.ad` file. `appendRefLabel` (`packages/daemon/src/core/session-script-writer.ts:235-240`) writes the
13011301
node's label as a trailing token, parsed back into `action.result.refLabel`
13021302
(`src/replay/script.ts:269,295,315`). Today that label is used only as a fallback LOOKUP key
13031303
(`tryResolveRefNode`'s `fallbackLabel`, `resolution.ts:393,413-430`) when the ref itself fails to

‎docs/adr/0014-session-ref-frame-lifetime.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ ref-frame vocabulary is promoted into `CONTEXT.md`.
2020
issuance scope) — kept separate from the latest operational observation (`session.snapshot`).
2121
The frame is one value on `SessionState`, replaced whole by a transition and never edited in
2222
place; its type is nominal (`#`-private fields), so no module outside
23-
`packages/daemon/src/ref-frame.ts` can construct a frame, edit one, or derive one from an existing
23+
`packages/daemon/src/core/ref-frame.ts` can construct a frame, edit one, or derive one from an existing
2424
frame. What the type cannot judge is a whole frame moved unchanged — clearing the field, or
2525
assigning another session's frame — which the field-owner gate still covers.
2626
- A complete snapshot activates an `all` frame; `find`, settled diffs, and replay divergence

‎docs/adr/0016-active-session-script-publication.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
## Status
44

5-
Accepted; implemented on `main` (`packages/daemon/src/handlers/session-script-publication.ts`,
6-
`packages/daemon/src/session-script-active-publication.ts`), including the #1349 identity-level
5+
Accepted; implemented on `main` (`packages/daemon/src/sessions/handlers/session-script-publication.ts`,
6+
`packages/daemon/src/core/session-script-active-publication.ts`), including the #1349 identity-level
77
destination-guard amendment.
88

99
## Rules at a glance

0 commit comments

Comments
 (0)