Skip to content

Commit 9fa23c4

Browse files
committed
refactor(replay): dispatch through a neutral envelope and consume the daemon through typed capabilities
The replay unit no longer imports anything under src/daemon outside itself: request types come from the wire shape in contracts, nested dispatch carries a ReplayDispatchOptions bag the handler folds into the request's private half, the session is a structural ReplaySessionState slice, the coordinator is built by the handler and passed in, and the five daemon policy calls arrive as capabilities on the session and a dependencies bag.
1 parent aa109a2 commit 9fa23c4

63 files changed

Lines changed: 821 additions & 511 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.

‎packages/ad-script/package.json‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,13 @@
66
"type": "module",
77
"description": "Private canonical .ad replay script codec (read + write) for agent-device.",
88
"dependencies": {
9-
"@agent-device/capture-kit": "workspace:*",
109
"@agent-device/contracts": "workspace:*",
1110
"@agent-device/kernel": "workspace:*"
1211
},
1312
"exports": {
1413
".": {
1514
"types": "./src/index.ts",
1615
"default": "./src/index.ts"
17-
},
18-
"./target-evidence": {
19-
"types": "./src/target-evidence.ts",
20-
"default": "./src/target-evidence.ts"
2116
}
2217
}
2318
}

‎packages/ad-script/src/internal/__tests__/target-annotation-identity.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ test('matchesLocalIdentity: with no recorded id, role+label must both match, abs
7070
// ---------------------------------------------------------------------------
7171
// Shared id demotion. `idMatchCountInTree` / `demoteNonUniqueLocalIdentity`
7272
// are the ONE shared uniqueness predicate behind both id-demotion sites (the
73-
// `target-v1` identity tuple `@agent-device/ad-script/target-evidence` writes at record
73+
// `target-v1` identity tuple `@agent-device/selectors/target-evidence` writes at record
7474
// time, and the selector chain `buildSelectorChainForNode` builds — see
7575
// `src/__tests__/selectors-build.test.ts` for that consumer's own coverage). Neither
7676
// consumer test exercises the pair directly; these tests pin the shared

‎packages/ad-script/src/internal/target-annotation-classification.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* deviations"): this used to live in `@agent-device/ad-replay`'s
99
* `target-identity.ts`, reasoning that it was engine-owned policy rather
1010
* than script vocabulary. In practice its only real consumers were the
11-
* daemon's RECORD-time self-check (`target-evidence.ts`)
11+
* daemon's RECORD-time self-check (`@agent-device/selectors/target-evidence`)
1212
* and its REPLAY-time classification wrapper
1313
* (`src/daemon/replay/internal/session-replay-target-classification.ts`) — both
1414
* daemon files, neither reachable through `inspectAdReplay`/`runAdReplay`.

‎packages/ad-script/src/internal/target-annotation-identity.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* ADR 0012 decision 3: the record/replay-shared local-identity + ancestry-
33
* prefix matching over versioned `.ad` target-binding evidence, plus the
44
* bounded diagnostic diffs built on top of it. Both the writer (over
5-
* `SnapshotNode`-derived values, `target-evidence.ts`) and
5+
* `SnapshotNode`-derived values, `@agent-device/selectors/target-evidence`) and
66
* replay-time verification (`src/daemon/replay/internal/session-replay-target-classification.ts` and
77
* `src/commands/interaction/runtime/selector-wait.ts`) share this verbatim so both
88
* sides compute the SAME identity/ancestry match by construction (#1478 P5
@@ -49,7 +49,7 @@ type IdentityTreeNode = Pick<RawSnapshotNode, 'type' | 'identifier' | 'label'>;
4949
* ADR 0012 decision 3: the ONE snapshot-node local-identity reader —
5050
* normalized (NFC, label whitespace collapse, `normalizeType` role) AND
5151
* 256-byte field-capped, on every path. Shared by the record-time writer
52-
* (`target-evidence.ts`), replay-time verification
52+
* (`@agent-device/selectors/target-evidence`), replay-time verification
5353
* (`src/daemon/replay/internal/session-replay-target-verification.ts`), and the
5454
* dispatch-side post-resolution guard
5555
* (`src/commands/interaction/runtime/resolution.ts`), so all three compute

‎packages/ad-script/src/internal/target-annotation-serde.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* ADR 0012 decision 3: versioned `.ad` target-binding evidence — the
33
* comment-line SERDE half shared by the writer
4-
* (`target-evidence.ts`) and the parser
4+
* (`@agent-device/selectors/target-evidence`) and the parser
55
* (`packages/ad-script/src/internal/script.ts`). Owns the wire type,
66
* canonical field order, normalization, size caps, and payload
77
* parsing/validation.

‎packages/capture-kit/src/ios-snapshot-engine/index.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ export {
55
presentIosInteractiveSnapshot,
66
} from './semantic-index.ts';
77
export { collectIosStructuralIdentifierSuppression } from './noise-structural.ts';
8-
export { findNearestScrollableContainer, mergeReplacement, updateReplacement } from './tree.ts';
8+
export { mergeReplacement, updateReplacement } from './tree.ts';
99
export { IosSnapshotEngineError, toIosSnapshotEngineErrorDetails } from './types.ts';
1010
export type { SnapshotTreeRuleContext } from './tree.ts';

‎packages/contracts/src/daemon-wire-request.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ export type DaemonInstallSource = PublicDaemonInstallSource;
1414
* wire can express and the lease coordinates the router reads. Public throughout: nothing here
1515
* names live session state.
1616
*/
17-
export type DaemonWireRequestMeta = Omit<PublicDaemonRequestMeta, 'installSource' | 'lockPlatform'> & {
17+
export type DaemonWireRequestMeta = Omit<
18+
PublicDaemonRequestMeta,
19+
'installSource' | 'lockPlatform'
20+
> & {
1821
installSource?: DaemonInstallSource;
1922
lockPlatform?: PlatformSelector;
2023
leaseBackend?: LeaseBackend;

‎packages/selectors/package.json‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"private": true,
55
"sideEffects": false,
66
"type": "module",
7-
"description": "Shared selector matching, argument, and replay semantics for agent-device. `.` is string-only; `./ast` is the published parser surface behind `agent-device/selectors`; `./engine` is the resolve/list surface reserved for the selector-pipeline owner (R19); `./parameterized-recorded-fill` parameterizes recorded fill payloads against their selectors; the interaction-resolution subpaths (`./selector-pipeline`, `./interaction-targeting`, `./interaction-touch-point`, `./press-retarget`, `./absence-observation*`, …) host the engine execution surface owned by the pipeline; `./snapshot-geometry-fixtures` is the canonical home for the geometry/touch-point test fixtures this package and root tests both build on (it re-exports `makeSnapshotState` from `@agent-device/capture-kit/snapshot-state-fixtures`, its own canonical home).",
7+
"description": "Shared selector matching, argument, and replay semantics for agent-device. `.` is string-only; `./ast` is the published parser surface behind `agent-device/selectors`; `./engine` is the resolve/list surface reserved for the selector-pipeline owner (R19); `./parameterized-recorded-fill` parameterizes recorded fill payloads against their selectors; the interaction-resolution subpaths (`./selector-pipeline`, `./interaction-targeting`, `./interaction-touch-point`, `./press-retarget`, `./absence-observation*`, \u2026) host the engine execution surface owned by the pipeline; `./snapshot-geometry-fixtures` is the canonical home for the geometry/touch-point test fixtures this package and root tests both build on (it re-exports `makeSnapshotState` from `@agent-device/capture-kit/snapshot-state-fixtures`, its own canonical home).",
88
"dependencies": {
99
"@agent-device/ad-script": "workspace:*",
1010
"@agent-device/capture-kit": "workspace:*",
@@ -79,6 +79,10 @@
7979
"./touch-semantics": {
8080
"types": "./src/touch-semantics.ts",
8181
"default": "./src/touch-semantics.ts"
82+
},
83+
"./target-evidence": {
84+
"types": "./src/target-evidence.ts",
85+
"default": "./src/target-evidence.ts"
8286
}
8387
},
8488
"devDependencies": {
File renamed without changes.
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,21 @@ import type {
2929
TargetScrollRegion,
3030
TargetVerification,
3131
} from '@agent-device/contracts/replay';
32-
import { classifyTargetBindingMatch } from './internal/target-annotation-classification.ts';
3332
import {
33+
buildAncestryChain,
34+
buildIndexMap,
35+
classifyTargetBindingMatch,
3436
demoteNonUniqueLocalIdentity,
37+
filterIdentitySet,
3538
matchesLocalIdentity,
3639
readNodeLocalIdentity,
37-
siblingOrdinal,
38-
} from './internal/target-annotation-identity.ts';
39-
import {
4040
serializeTargetAnnotationV1,
41+
siblingOrdinal,
4142
utf8ByteLength,
43+
type LocalIdentity,
4244
TARGET_ANNOTATION_MAX_ANCESTRY,
4345
TARGET_ANNOTATION_MAX_PAYLOAD_BYTES,
44-
} from './internal/target-annotation-serde.ts';
45-
import { buildAncestryChain, buildIndexMap, filterIdentitySet } from './internal/target-evidence-tree.ts';
46-
import type { LocalIdentity } from './internal/target-annotation-identity.ts';
46+
} from '@agent-device/ad-script';
4747

4848
/** ADR 0012 decision 3: the resolved winner and the tree it was resolved from. */
4949
export type RecordedTargetCapture = {

0 commit comments

Comments
 (0)