Skip to content

Commit 36e0cff

Browse files
authored
refactor(replay): move source and target decisions into replay-port (#2663) (#3007)
* refactor(replay): move source and target decisions into replay-port * chore(gates): declare replay-port decision subpaths and dependencies
1 parent a212d9a commit 36e0cff

19 files changed

Lines changed: 38 additions & 22 deletions

‎packages/contracts/src/replay-divergence.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ export type ReplayDivergenceOverflow = {
181181
/**
182182
* ADR 0012 decision 6, R3: the daemon-computed repair routing hint. Always
183183
* defined (never absent/null) — the mapping in
184-
* `src/daemon/replay/internal/session-replay-repair-hint.ts` is total, defaulting
184+
* `packages/replay-port/src/daemon-port/repair-hint.ts` is total, defaulting
185185
* to `manual` whenever no safer routing can be proven. A small fixed token,
186186
* so it is carried at every response level (including `--level digest`) and
187187
* every projection (text, JSON, client `AppError`, MCP `structuredContent`).

‎packages/replay-port/package.json‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,23 @@
77
"description": "Daemon-side replay port: the adapter over the ad-replay, ad-script and replay-test engines.",
88
"dependencies": {
99
"@agent-device/ad-script": "workspace:*",
10-
"@agent-device/contracts": "workspace:*"
10+
"@agent-device/contracts": "workspace:*",
11+
"@agent-device/kernel": "workspace:*",
12+
"@agent-device/selectors": "workspace:*"
1113
},
1214
"exports": {
15+
"./target-token": {
16+
"types": "./src/daemon-port/target-token.ts",
17+
"default": "./src/daemon-port/target-token.ts"
18+
},
19+
"./repair-hint": {
20+
"types": "./src/daemon-port/repair-hint.ts",
21+
"default": "./src/daemon-port/repair-hint.ts"
22+
},
23+
"./script-source": {
24+
"types": "./src/daemon-port/script-source.ts",
25+
"default": "./src/daemon-port/script-source.ts"
26+
},
1327
"./session-replay-vars": {
1428
"types": "./src/session-replay-vars.ts",
1529
"default": "./src/session-replay-vars.ts"

src/daemon/replay/internal/__tests__/session-replay-repair-hint.test.ts renamed to packages/replay-port/src/daemon-port/__tests__/repair-hint.test.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@ import { test } from 'vitest';
22
import assert from 'node:assert/strict';
33
import type { RawSnapshotNode, SnapshotNode } from '@agent-device/kernel/snapshot';
44
import type { TargetAnnotationV1 } from '@agent-device/contracts/replay';
5-
import {
6-
computeReplayRepairHint,
7-
type ReplayRepairHintCapture,
8-
} from '../session-replay-repair-hint.ts';
5+
import { computeReplayRepairHint, type ReplayRepairHintCapture } from '../repair-hint.ts';
96

107
/**
118
* ADR 0012 decision 6, R3: `computeReplayRepairHint` must be a TOTAL mapping

src/daemon/__tests__/replay-script-source.test.ts renamed to packages/replay-port/src/daemon-port/__tests__/script-source.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { expect, test } from 'vitest';
22
import { AppError } from '@agent-device/kernel/errors';
3-
import { readReplayScriptSourceFile } from '../replay-script-source.ts';
3+
import { readReplayScriptSourceFile } from '../script-source.ts';
44

55
test('reading a file the bundle does not carry names the file and the entry', () => {
66
const bundle = { entry: '/flows/login.yaml', files: { '/flows/login.yaml': '---\n- back\n' } };

src/daemon/replay/internal/__tests__/session-replay-target-token.test.ts renamed to packages/replay-port/src/daemon-port/__tests__/target-token.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import type { SessionAction } from '@agent-device/contracts/session';
44
import { test } from 'vitest';
55
import assert from 'node:assert/strict';
6-
import { extractReplayTargetToken, readRefLabel } from '../session-replay-target-token.ts';
6+
import { extractReplayTargetToken, readRefLabel } from '../target-token.ts';
77

88
// ---------------------------------------------------------------------------
99

src/daemon/replay/internal/session-replay-repair-hint.ts renamed to packages/replay-port/src/daemon-port/repair-hint.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* ADR 0012 decision 6, R3: the daemon-side `repairHint` computation.
2+
* ADR 0012 decision 6, R3: the replay port's `repairHint` computation.
33
*
44
* Computed daemon-side at divergence time, never by the agent, from (i) the
55
* recorded `target-v1` evidence for the diverged action (decision 3's
@@ -13,8 +13,7 @@
1313
* evidence, or a sparse/unavailable capture — so `repairHint` is always
1414
* defined.
1515
*
16-
* Lives in the daemon zone because the container-presence test
17-
* below is a genuine structural containment check over `parentIndex` — the
16+
* The container-presence test below is a genuine structural containment check over `parentIndex` — the
1817
* same tree-walking machinery decision 3's own identity-set filter uses
1918
* (`buildAncestryChain`/`computeScrollRegionKey`, `@agent-device/selectors/target-evidence`)
2019
* — not a flat identity-string search.
File renamed without changes.

src/daemon/replay/internal/session-replay-target-token.ts renamed to packages/replay-port/src/daemon-port/target-token.ts

File renamed without changes.

‎pnpm-lock.yaml‎

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/daemon/__tests__/request-save-script-transports.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import net from 'node:net';
1818
import path from 'node:path';
1919
import { afterEach, expect, test } from 'vitest';
2020
import { LeaseRegistry } from '../lease-registry.ts';
21-
import { REPLAY_SCRIPT_SOURCE_REQUIRED_MESSAGE } from '../replay-script-source.ts';
21+
import { REPLAY_SCRIPT_SOURCE_REQUIRED_MESSAGE } from '@agent-device/replay-port/script-source';
2222
import { createRequestHandler } from './test-device-runtime-gateway.ts';
2323
import { SessionStore } from '../session-store.ts';
2424
import { createDaemonHttpServer } from '../server/http-server.ts';

0 commit comments

Comments
 (0)