Skip to content

Commit b330aca

Browse files
committed
refactor: dissolve caller-side replay ownership
1 parent 6900117 commit b330aca

54 files changed

Lines changed: 239 additions & 223 deletions

Some content is hidden

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

‎docs/adr/0018-unified-event-journal.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ redaction discipline, and sink (inventoried 2026-07-24):
7272
request via `meta.requestProgress`; disabled under `--json`. Events are written to the wire
7373
**unredacted** today.
7474
4. **Replay timing trace** (`src/daemon/handlers/session-replay-trace.ts`,
75-
`session-test-runtime.ts`, read by `src/replay/test/trace.ts`). Per-**attempt**
75+
`session-test-runtime.ts`, read by `src/cli/replay-test/trace.ts`). Per-**attempt**
7676
`replay-timing.ndjson` files whose paths are created dynamically inside each attempt — written
7777
by **two different helpers, one of which redacts and one of which does not**
7878
(`appendReplayTraceEvent` vs `appendReplayTestTimingEvent`).

‎docs/adr/0020-composable-recorded-fragments.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ violation before the production change is trusted.
562562

563563
The audited seam tests are `packages/ad-script/src/internal/__tests__/script.test.ts`,
564564
`packages/ad-replay/src/internal/__tests__/plan-digest.test.ts`,
565-
`src/replay/__tests__/script-source-bundle.test.ts`, and
565+
`src/commands/replay/script-source-bundle.test.ts`, and
566566
`packages/maestro/src/internal/__tests__/replay-plan.test.ts`,
567567
`source-closure.test.ts`, `program-loader.test.ts`,
568568
`src/daemon/handlers/__tests__/session-replay-runtime.test.ts`. The planted-red checks below are

‎fallow-baselines/health.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@
604604
"packages/provider-webdriver/src/webdriver-utils.ts:high impact",
605605
"src/utils/keyed-lock.ts:high impact",
606606
"src/daemon/request-progress-protocol.ts:high impact",
607-
"src/replay/test/reporters/format.ts:high impact",
607+
"src/cli/replay-test/reporters/format.ts:high impact",
608608
"src/daemon/handlers/session-test-infrastructure.ts:high impact",
609609
"src/daemon/handlers/session-test-artifacts.ts:high impact",
610610
"packages/platform-android/src/app-parsers.ts:high impact",

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,7 @@ test('formatDivergenceActionLabel categorically drops fill/type text but keeps t
680680
});
681681

682682
// The property test asserting "serializing a parsed script is a fixed point
683-
// for generated scripts" stays at `src/replay/__tests__/ad-script-round-trip.test.ts`:
683+
// for generated scripts" stays at `src/commands/replay/ad-script-round-trip.test.ts`:
684684
// its script generator (`replayScriptArb`) is derived from the root command
685685
// catalog and selector grammar (`src/__tests__/test-utils/property-arbitraries.ts`),
686686
// which this package cannot import without an R11 package→root-src escape

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33
* prefix matching over versioned `.ad` target-binding evidence, plus the
44
* bounded diagnostic diffs built on top of it. Both the writer (over
55
* `SnapshotNode`-derived values, `src/daemon/session-target-evidence.ts`) and
6-
* replay-time verification (`src/daemon/handlers/session-replay-target-classification.ts`,
7-
* `src/commands/interaction/runtime/selector-wait.ts`, and the shared
8-
* replay-zone tree helpers in `src/replay/`) share this verbatim so both
6+
* replay-time verification (`src/daemon/handlers/session-replay-target-classification.ts` and
7+
* `src/commands/interaction/runtime/selector-wait.ts`) share this verbatim so both
98
* sides compute the SAME identity/ancestry match by construction (#1478 P5
109
* review, "genuinely shared recording vocabulary" relocated to its owner).
1110
*

‎scripts/layering/check.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ import { listTrackedProductionSources, listTrackedTypeScriptFiles } from './trac
100100
import { runtimeExecutionIntegrityViolations } from './runtime-execution-policy.ts';
101101
import { sourceExecutionCompatibilityViolations } from './source-execution-policy.ts';
102102
import { sessionResourceOwnershipViolations } from './session-resource-ownership.ts';
103+
import { replayOwnershipViolations } from './replay-ownership.ts';
103104
import { applicationLifecycleOwnershipViolations } from './application-lifecycle-policy.ts';
104105

105106
const repoRoot = execFileSync('git', ['rev-parse', '--show-toplevel'], {
@@ -547,6 +548,7 @@ export const LAYERING_RULE_IDS = [
547548
'package-boundaries',
548549
'platform-package-policy',
549550
'platforms-root-shape',
551+
'replay-ownership',
550552
] as const;
551553

552554
export type LayeringRuleId = (typeof LAYERING_RULE_IDS)[number];
@@ -586,6 +588,7 @@ export const LAYERING_RULES: Readonly<Record<LayeringRuleId, LayeringRule>> = {
586588
),
587589
'platforms-root-shape': (context) =>
588590
checkPlatformsRootShape([...context.allTypeScriptSources.keys()]),
591+
'replay-ownership': (context) => replayOwnershipViolations(context.sourceFiles),
589592
};
590593

591594
export function main(): number {

‎scripts/layering/daemon-modularity.test.ts‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,15 @@ test('replay-test rejects request-global and engine-internal imports', () => {
118118
'packages/replay-test/src/internal/scheduler.ts',
119119
[
120120
"import { emitRequestProgress } from '../../../../src/request/progress.ts';",
121-
"import { readReplayScriptMetadata } from '../../../../src/replay/script.ts';",
121+
"import { readReplayScriptMetadata } from '../../../../src/daemon/handlers/session-replay-runtime.ts';",
122122
"import { parseMaestroProgram } from '../../../../src/compat/maestro/program-ir-parser.ts';",
123123
].join('\n'),
124124
],
125125
['src/request/progress.ts', 'export function emitRequestProgress() {}'],
126-
['src/replay/script.ts', 'export function readReplayScriptMetadata() {}'],
126+
[
127+
'src/daemon/handlers/session-replay-runtime.ts',
128+
'export function readReplayScriptMetadata() {}',
129+
],
127130
['src/compat/maestro/program-ir-parser.ts', 'export function parseMaestroProgram() {}'],
128131
]),
129132
);
@@ -136,7 +139,7 @@ test('replay-test rejects request-global and engine-internal imports', () => {
136139
violations.map(({ message }) => message.replace(/;.*/, '')),
137140
[
138141
'replay-test must not import src/request/progress.ts',
139-
'replay-test must not import src/replay/script.ts',
142+
'replay-test must not import src/daemon/handlers/session-replay-runtime.ts',
140143
'replay-test must not import src/compat/maestro/program-ir-parser.ts',
141144
],
142145
);

‎scripts/layering/daemon-modularity.ts‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ export const LOGICAL_MODULE_POLICIES: readonly LogicalModulePolicy[] = [
7474
'src/platforms/',
7575
'src/providers/',
7676
'src/request/',
77-
'src/replay/',
7877
'src/compat/',
7978
'packages/maestro/',
8079
'packages/ad-replay/',
@@ -85,7 +84,6 @@ export const LOGICAL_MODULE_POLICIES: readonly LogicalModulePolicy[] = [
8584
const ENGINE_FILE_PREFIXES = [
8685
'packages/ad-replay/src/',
8786
'packages/maestro/src/',
88-
'src/replay/',
8987
'src/daemon/handlers/session-replay',
9088
'packages/replay-test/src/',
9189
] as const;
@@ -241,8 +239,7 @@ function checkLogicalModuleImports(edges: readonly ResolvedImportEdge[]): Layeri
241239
}
242240

243241
if (!sourceModule) continue;
244-
// A module's own files are never a forbidden target: `replay-test` sits inside the wider
245-
// `src/replay/` engine root it may not import from.
242+
// A module's own files are never a forbidden target.
246243
if (sourceModule.roots.some((root) => edge.target.startsWith(root))) continue;
247244
if (!sourceModule.forbiddenTargetRoots.some((root) => edge.target.startsWith(root))) continue;
248245
violations.push({

‎scripts/layering/model.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ const TARGET_DAG_RANK = new Map([
3636
['contracts', 1],
3737
['maestro', 1],
3838
['recording', 1],
39-
['replay', 1],
4039
['replay-test', 1],
4140
['request', 1],
4241
['screenshot-diff', 1],
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import assert from 'node:assert/strict';
2+
import { test } from 'node:test';
3+
import { REPLAY_OWNERSHIP_RULE, replayOwnershipViolations } from './replay-ownership.ts';
4+
5+
test('R71 rejects a planted production file under retired src/replay by name', () => {
6+
const violations = replayOwnershipViolations(['src/replay/planted-production-file.ts']);
7+
8+
assert.deepEqual(violations, [
9+
{
10+
rule: REPLAY_OWNERSHIP_RULE,
11+
file: 'src/replay/planted-production-file.ts',
12+
line: 1,
13+
message:
14+
'src/replay/ is retired; caller source acquisition belongs under src/commands/replay/ ' +
15+
'and replay-test presentation belongs under src/cli/replay-test/.',
16+
},
17+
]);
18+
});
19+
20+
test('R71 accepts the current replay owners', () => {
21+
assert.deepEqual(
22+
replayOwnershipViolations([
23+
'src/commands/replay/script-source-bundle.ts',
24+
'src/cli/replay-test/reporting.ts',
25+
'src/daemon/replay-script-source.ts',
26+
]),
27+
[],
28+
);
29+
});

0 commit comments

Comments
 (0)