Skip to content

Commit 2e4825e

Browse files
authored
refactor: tidy three post-extraction seams (#1551)
* refactor(replay): import REPLAY_VAR_KEY_RE from the codec package directly vars.ts re-exported the constant for a single consumer, recorded-input.ts. Point that consumer at @agent-device/ad-script and drop the shim, which also makes script.ts's doc comment ("recorded-input.ts imports it from this package") true. * refactor(ad-script): import the target-annotation shape from contracts directly The annotation shape types (TargetAncestryEntry, TargetAnnotationV1, TargetScrollRegion, TargetVerification) live in @agent-device/contracts/replay; the codec package re-exported them, and 21 files reached the shape through that detour. Point every consumer — root src, root tests, and the package's own tests — at contracts, then drop the re-export from the serde module and the façade. Type-only, so nothing changes at runtime. The package.json exports map is unchanged, so the R11 boundary assertion in scripts/layering/package-boundaries.test.ts still holds as written. * refactor(daemon): name the authoring-armed session read `kind === 'authoring' && status === 'armed'` was spelled out at three handler sites that all ask the same question. Give it a name next to isSessionScriptPublished, mirroring how isRepairArmedSession is housed in the repair projection, and route the three sites through it. abortAuthoring's own guard keeps its inline check: that one is the transition's legality test, not a session-level read.
1 parent 634073a commit 2e4825e

31 files changed

Lines changed: 60 additions & 55 deletions

packages/ad-script/src/index.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
* canonical field order, normalization, size caps, payload parsing). The
1313
* companion classification core (`classifyTargetBindingMatch`, local-identity
1414
* + ancestry-prefix matching) is NOT part of this codec — it stays in
15-
* `src/replay/target-identity.ts`, which imports the types below.
15+
* `src/replay/target-identity.ts`. The annotation SHAPE is not exported here
16+
* either: it lives in `@agent-device/contracts/replay`, which every consumer
17+
* (this package included) imports directly.
1618
*/
1719

1820
export {
@@ -49,9 +51,3 @@ export {
4951
TARGET_ANNOTATION_MAX_FIELD_BYTES,
5052
TARGET_ANNOTATION_MAX_PAYLOAD_BYTES,
5153
} from './internal/target-annotation-serde.ts';
52-
export type {
53-
TargetAncestryEntry,
54-
TargetAnnotationV1,
55-
TargetScrollRegion,
56-
TargetVerification,
57-
} from './internal/target-annotation-serde.ts';

packages/ad-script/src/internal/__tests__/script.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
REPLAY_METADATA_PLATFORMS,
88
} from '../script.ts';
99
import { formatPortableActionLine, formatTargetAnnotationLines } from '../script-formatting.ts';
10-
import type { TargetAnnotationV1 } from '../target-annotation-serde.ts';
10+
import type { TargetAnnotationV1 } from '@agent-device/contracts/replay';
1111
import type { SessionAction } from '@agent-device/contracts/session';
1212

1313
// `writeReplayScript` (the `--update` heal-and-rewrite serializer) was

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ import {
1111
TARGET_ANNOTATION_MAX_ANCESTRY,
1212
TARGET_ANNOTATION_MAX_FIELD_BYTES,
1313
TARGET_ANNOTATION_MAX_PAYLOAD_BYTES,
14-
type TargetAnnotationV1,
1514
TARGET_ANNOTATION_LINE_RE,
1615
} from '../target-annotation-serde.ts';
16+
import type { TargetAnnotationV1 } from '@agent-device/contracts/replay';
1717

1818
function baseEvidence(overrides: Partial<TargetAnnotationV1> = {}): TargetAnnotationV1 {
1919
return {

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

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88
*
99
* The record/replay-shared CLASSIFICATION core (`classifyTargetBindingMatch`,
1010
* local-identity + ancestry-prefix matching) is not part of this codec — it
11-
* stays in `src/replay/target-identity.ts`, which imports the types below
12-
* from this package (#1478 P5 scoping dossier, "the codec seam").
11+
* stays in `src/replay/target-identity.ts`, which imports the shared shape
12+
* types from `@agent-device/contracts/replay` (#1478 P5 scoping dossier,
13+
* "the codec seam").
1314
*/
1415

1516
import { AppError } from '@agent-device/kernel/errors';
@@ -36,14 +37,7 @@ export const TARGET_ANNOTATION_MAX_PAYLOAD_BYTES = 4096;
3637
export const TARGET_ANNOTATION_MAX_ANCESTRY = 8;
3738

3839
// The annotation SHAPE lives in contracts/ so the recorded-action type can be stated without
39-
// depending on this zone; re-exported here for existing consumers.
40-
export type {
41-
TargetAncestryEntry,
42-
TargetAnnotationV1,
43-
TargetRect,
44-
TargetScrollRegion,
45-
TargetVerification,
46-
} from '@agent-device/contracts/replay';
40+
// depending on this zone; every consumer imports it from there directly.
4741
import type {
4842
TargetAncestryEntry,
4943
TargetAnnotationV1,

src/commands/interaction/runtime/selector-wait.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
filterIdentitySet,
1212
} from '../../../replay/target-evidence-tree.ts';
1313
import { annotationLocalIdentity } from '../../../replay/target-identity.ts';
14-
import type { TargetAnnotationV1 } from '@agent-device/ad-script';
14+
import type { TargetAnnotationV1 } from '@agent-device/contracts/replay';
1515
import type { PublicPlatform } from '@agent-device/kernel/device';
1616
import { checkWaitText } from '../../../selectors/arguments.ts';
1717
import { listSelectorChainMatches } from '../../../selectors/index.ts';

src/daemon/__tests__/session-script-active-publication.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { describe, expect, test } from 'vitest';
2-
import type { TargetAnnotationV1 } from '@agent-device/ad-script';
2+
import type { TargetAnnotationV1 } from '@agent-device/contracts/replay';
33
import type { SessionAction } from '../types.ts';
44
import {
55
assertActivePublicationPortability,

src/daemon/__tests__/session-store.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ import { SessionStore } from '../session-store.ts';
77
import type { SessionState } from '../types.ts';
88
import { buildRequestFinishedEvent } from '../session-event-log.ts';
99
import { HEAL_COMPLETE_SENTINEL } from '../session-script-writer.ts';
10-
import { parseReplayScriptDetailed, type TargetAnnotationV1 } from '@agent-device/ad-script';
10+
import { parseReplayScriptDetailed } from '@agent-device/ad-script';
11+
import type { TargetAnnotationV1 } from '@agent-device/contracts/replay';
1112
import { repairPublication } from '../../__tests__/test-utils/session-factories.ts';
1213

1314
type RecordActionEntry = Parameters<SessionStore['recordAction']>[1];

src/daemon/handlers/__tests__/session-replay-repair-hint.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { test } from 'vitest';
22
import assert from 'node:assert/strict';
33
import type { RawSnapshotNode, SnapshotNode } from '@agent-device/kernel/snapshot';
4-
import type { TargetAnnotationV1 } from '@agent-device/ad-script';
4+
import type { TargetAnnotationV1 } from '@agent-device/contracts/replay';
55
import {
66
computeReplayRepairHint,
77
type ReplayRepairHintCapture,

src/daemon/handlers/__tests__/session-replay-repair.fixtures.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import type { DaemonInvokeFn, DaemonRequest, DaemonResponse } from '../../types.
1010
import { SessionStore } from '../../session-store.ts';
1111
import { isInteractiveObservation } from '../../session-action-recorder.ts';
1212
import { makeIosSession } from '../../../__tests__/test-utils/session-factories.ts';
13-
import type { TargetAnnotationV1 } from '@agent-device/ad-script';
13+
import type { TargetAnnotationV1 } from '@agent-device/contracts/replay';
1414

1515
export function freshEvidence(id: string, label: string): TargetAnnotationV1 {
1616
return {

src/daemon/handlers/__tests__/session-replay-target-classification-fixtures.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import assert from 'node:assert/strict';
22
import type { RawSnapshotNode, SnapshotNode } from '@agent-device/kernel/snapshot';
33
import { computeTargetEvidence } from '../../session-target-evidence.ts';
4-
import type { TargetAnnotationV1 } from '@agent-device/ad-script';
4+
import type { TargetAnnotationV1 } from '@agent-device/contracts/replay';
55

66
export function toSnapshotNodes(raw: RawSnapshotNode[]): SnapshotNode[] {
77
return raw.map((node, position) => ({ ...node, ref: `e${position + 1}` }));

0 commit comments

Comments
 (0)