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 c137b5b
Browse filesBrowse the repository at this point in the historyBrowse files
refactor(daemon): make the layer folders the declaration (PR 10) (#3520)
* refactor(move): move every daemon file into its layer folder
Codemod-only: 662 renames of packages/daemon/src files under the five
layer folders (core, resources, execution, sessions, server), with
every relative specifier, path mention, and package-manifest entry
retargeted by the same pass. The map is the layer-manifest claim plus
deterministic owner-layer rules for tests and support files; two
support-only tests fall to core, and the one fixture a testing pattern
consumes across layer folders follows its pattern's members so
./testing/interaction/internal/__tests__/* keeps a single target. The
former transport folder does not fold onto its layer's name: the map
places it at server/http/, so the package never carries a server/server
path. The narrowed facade keeps every export KEY and rewrites only
TARGETS: 107 named entries follow their file, and the four
./testing/<dir>/* pattern folders follow the folder their consumed
members move into. Importers outside the package are untouched.
Generated with assistance.
* docs(adr): name the live path for row 23 of the hop trace
The row cited src/daemon/device-claim-admission.ts, stale since the
package extraction; it now names the file's home in the resources
layer. The other src/daemon/ citations in the ADRs name files the
tree no longer carries at all and keep their historical spelling.
(cherry picked from commit 563b382)
* fix(gates): retarget the teardown closure probe the extraction left stale
The probe walked src/daemon/session-teardown.ts, a path the package
extraction had already orphaned; it now resolves through
packages/daemon/src/sessions/, where the move put the teardown owner.
The non-vacuity pins (closure size, materialized-path-registry
membership) carry over unchanged.
(cherry picked from commit 7937155)
(cherry picked from commit 5d943ca)
# Conflicts:
# src/__tests__/daemon-composition/session-teardown-import-closure.test.ts
* refactor(gates): R81 derives the daemon layer from its folder
The five layer folders now carry the claim the manifest carried: the
first path segment under the daemon root is the file's layer, an
unknown segment or a production file at the zone root fails, and the
edge rule over core < resources < execution < sessions < server is
unchanged. The manifest JSON and its drift check retire with this
commit — the folder is the declaration, so ownership moves with the
file and cannot decay into fiction separately from the tree. The rule
derives its root from the shared DAEMON_SOURCE_ROOT constant and
refuses an empty input set, so a stale scan filter cannot pass it
silently.
* chore(gates): retarget fallow config, URL-based ownership probe, and audit scope
The route-handler and interaction-facade fallow entries follow their
files into the sessions/execution layers. The atomic-publish
ownership probe reads its judged sources through new URL(...)
relative to the test, so its specifiers follow the move by hand.
The daemon-shaped test-support file the move brought into the audit
diff joins the per-file test-support exemption: every consumer is
test-tree code --production analysis cannot see.
(cherry picked from commit 687b53d)
(cherry picked from commit 977fbd7)
* chore(gates): retarget source-reading test probes to layer paths
Ownership probes and eager-closure walks that read daemon modules by
path follow them into their layer folders: the replay ownership scan's
synthetic probe locations move one folder deeper, and the daemon-
shaped test-support fallow entry settles on the one file the move
actually brought into the audit diff.
(cherry picked from commit 41fa23b,
minus the lease.test.ts plugin-manifest hop: the 11b lineage removed
that probe's file body, so nothing follows the move there)
(cherry picked from commit 665850c)
* chore(gates): settle self-review findings on the package base
Dead oxlint override for a file deleted before this stack, the
vacuous device-lane fixture pin (now asserts the fixture exists, at
its path in this tree), the R81 helpers that never needed to leave
their module, and the closure-probe hops that follow the interaction
routes and replay probes into their layer folders.
(cherry picked from commit baebba2;
the ime-capture fixture pin tracks its 11b home under
packages/platform-android/src/fixtures/)
(cherry picked from commit 5e88063)
* refactor(gates): measure R75 in head coordinates only
The review caught that mergeBaseRatchets already canonicalizes every
merge-base path onto its head path through renamedSince, so the
overlay's pre-fold handlers/ root, the pre-fold SessionStore spelling,
and the handlerKey fold matched nothing in either measured tree, and
the record-owner regex carried the same dead alternatives. R75 now
keeps only the two live handler roots and the single store target; its
tests moved onto those paths, so the live roots are what the suite
exercises.
* refactor(gates): hold R75 and its fixtures to the live layer roots
The first pass dropped the dead spellings but still hardcoded the two
handler roots as literals and left the rest of scripts/layering planting
synthetic daemon fixtures under the pre-fold handlers/ root. R75 now
derives both roots and the SessionStore target from DAEMON_SOURCE_ROOT,
gains an end-to-end classification case for each live handler folder
(the pre-fold spelling stays measurable but out of the ratcheted
subset, and each root is bite-proofed against a rename), and gains a
case that measures the real merge-base through mergeBaseRatchets and
asserts its handler-owned set arrives in head coordinates and the base
really held src/daemon/handlers/. Nine synthetic fixtures moved onto
sessions/handlers/. The R10 retired-handler path lists keep their
historical spelling on purpose: they name deleted files, and retargeting
them would reject legitimate new files in the live folders.
* refactor(gates): measure the rename canonicalization on a fixture repo
The merge-base overlay test read the real merge-base and asserted the
base tree still held src/daemon/handlers/. That pins one repo state —
this stack's — and starts failing on main and every later PR the moment
the stack lands, because check:layering runs these tests. The test now
builds a fixture repo whose base commit holds the pre-rename flat
handlers/ layout (padded so the specifier-rewriting move stays
rename-pairable) and whose head is the git mv into layer folders, then
injects that base through mergeBaseRatchets' new baseRef override and
asserts the rule: every base handler member survives canonicalization,
arrives under a live handler root, and the non-handler importer stays
out of the scoped set. No fetched origin/main, no repo history.
* fix(gates): name the layer path in the two comments the sweep skipped
The move sweep's path lookahead refused any match followed by a period,
so comment literals ending a sentence ("...device-claim-conflict.ts.
This path...") kept their pre-fold spelling. The owner's review caught
the help-conformance sample; the same class left one cross-reference in
the offscreen double-check test. Both now name the live layer paths.
The codemod kit's lookahead is fixed alongside (#3520 re-run kit, not a
repo file), so the next re-run sweeps these forms automatically.
* chore(gates): re-flow the lines the move and its retargets widened
The codemod lengthened retargeted specifiers and path literals past the
print width; oxfmt settles them. Formatting only, no semantics.
Generated with assistance.
* refactor(gates): call daemonLayerOf from rankedPair directly
layerOfEdgeEnd only wrapped daemonLayerOf — a leftover from the manifest
version of R81 — so rankedPair, its only caller, names the layer owner
itself (#3520 review). Behavior unchanged; the layering suite and R81's
reported edges are identical.
* refactor(gates): own the handler-folder rule once as isDaemonHandlerFile
The split of the old handlers/ tree into sessions/handlers/ and
execution/handlers/ was pasted as a pair of path roots in four places:
three arrays in architecture-ownership.ts and HANDLER_ROOTS in
session-authority-overlay.ts. The rule is the folder shape — any
<layer>/handlers/ folder under a declared layer — so daemon-layers.ts,
which already owns the layer folders, exports isDaemonHandlerFile and
the policies gained forbiddenTargetShapes beside the path roots. A
handler folder planted under another layer now joins R75's ratchet and
the facade policies with no rule edit; pinned by planted cases at both
gates (the pre-fold two-path rule fails exactly those pins).
// @agent-device/maestro owns the source import, while the published root
@@ -155,19 +155,23 @@
155
155
},
156
156
{
157
157
// Daemon route handlers are reached only through the dynamic `import()` table in request-handler-chain.ts, which --production analysis cannot follow to a consumer.
// The react-native route handler lives in the execution layer with its mechanics; same dynamic-loader exemption as the sessions-side route handlers above.
// The interaction facade exposes #2178's deferred route 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.
// 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.
258
+
// 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.
Copy file name to clipboardExpand all lines: docs/adr/0012-interactive-replay.md
+15-15Lines changed: 15 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -730,7 +730,7 @@ path — no text editing, no silent similarity-heal.
730
730
731
731
**Core mechanism — the healed script IS `session.actions`.** No new splice engine. `session.actions`
732
732
already accumulates every executed action for the session's lifetime
733
-
(`packages/daemon/src/session-action-recorder.ts:92`, unconditional push), and the divergence refusal is
733
+
(`packages/daemon/src/core/session-action-recorder.ts:92`, unconditional push), and the divergence refusal is
734
734
pre-dispatch (target verification refuses before the device action, decision 3), so a divergent step is
735
735
never pushed. Across a repair session: original steps that verified and dispatched land in
736
736
`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":
766
766
steps are re-executed during the repair replay; only if recording is armed from the start do they land
767
767
in `session.actions` with fresh `target-v1` evidence. Arming late yields a hybrid healed script (an
768
768
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
770
770
true when the step ran).
771
771
-**R2 — `--from` continuation only; never re-run the full replay on the same session.** After a
772
772
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":
808
808
instead of leaving it to agent judgment.
809
809
-**R4 — corrective actions must materialize to selector form; the writer fails loudly on a bare `@ref`
810
810
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:368-377`) 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:368-377`) rewrites to a selector line. If no `selectorChain` was
813
813
captured, the writer must refuse to emit a bare `@ref` line into a persisted `.ad` — a session-bound
814
814
ref will not resolve in a fresh run. It **fails loudly**: an error surfaced to the user with a non-zero
815
815
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
893
893
- The healed `.ad` is published when a teardown commits the transaction at state `COMPLETE` — normally the
894
894
agent's own `close`/`close --save-script <out>`, but any teardown of a completed transaction commits
895
895
(see the commit state machine below) — reusing the existing `session.actions` serializer
896
-
(`SessionScriptWriter.write`, `packages/daemon/src/session-script-writer.ts:120-158`) over the post-watermark slice
896
+
(`SessionScriptWriter.write`, `packages/daemon/src/core/session-script-writer.ts:120-158`) over the post-watermark slice
897
897
only (R6). When no
898
898
`<out>` path is given, the default is the **`<original-stem>.healed.ad` sibling**: the original script's
899
899
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.
943
943
944
944
**Scope: this refusal is uniform across repair AND ordinary recording, not repair-only.** Everything
945
945
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
947
947
for every `--save-script` target, with no repair-armed-vs-ordinary branch — a repair-armed heal
948
948
(`saveScriptBoundary` set) and an ordinary, non-repair `open --save-script`/`close --save-script`
949
949
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
1002
1002
> Provenance travels as `internal.replayPlanStep`, stamped by `invokeResolvedReplayAction`
1003
1003
> (`src/daemon/handlers/session-replay-action-runtime.ts`) — the single point every plan step is
1004
1004
> 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/http/http-rpc-methods.ts`, never copies it off the wire), so
1006
1006
> authored provenance cannot be spoofed by a client; this is the same channel `replayTargetGuard` and
1007
1007
> `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.
1009
1009
>
1010
1010
> **2. The corrective-read trap: why even out-of-band reads need an opt-in.** Excluding every out-of-band
1011
1011
> 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
1044
1044
>
1045
1045
> **4. How the rule projects across CLI/Node/MCP surfaces.** The exclusion is enforced at a single
1046
1046
> 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
1048
1048
> by a repair-armed `replay --save-script`; an ordinary, non-repair `open --save-script`/`close --save-script`
1049
1049
> authoring recording never sets it — see decision 6's "Scope" note above) and on the entry's
1050
1050
> `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
1052
1052
> `snapshot`) compute from the shared `isInteractiveObservation` predicate rather than each re-deriving it.
1053
1053
> Every surface reaches this same function because every surface's request reaches the same daemon.
1054
1054
>
@@ -1159,8 +1159,8 @@ above and the gates they name are the authoritative record of current behavior.
1159
1159
1160
1160
At acceptance, replay was deterministic. `.ad` scripts were plain text — one action per line, `#`
1161
1161
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
1164
1164
`runReplayScriptFile`
1165
1165
(`src/daemon/handlers/session-replay-runtime.ts`) under the daemon's `replay`/`test` commands
1166
1166
(`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
1289
1289
"Retry with --debug and inspect diagnostics log for details." (`defaultHintForCode`,
1290
1290
`src/kernel/errors.ts:253-254`).
1291
1291
-**Recordings contain zero verification steps.** The script writer strips every recorded `snapshot`
0 commit comments