Skip to content

Commit 4454aef

Browse files
authored
refactor(layering): remove retired migration scaffolding (#2092)
* refactor(layering): remove retired migration scaffolding * test: remove retired focus test wording
1 parent d44df9b commit 4454aef

15 files changed

Lines changed: 21 additions & 99 deletions

scripts/layering/application-lifecycle-policy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { parseSync } from 'oxc-parser';
2-
import { memberName, visitAst } from './cutover-policy-ast.ts';
2+
import { memberName, visitAst } from './layering-ast.ts';
33
import type { LayeringViolation } from './model.ts';
44

55
type AstNode = Record<string, unknown>;

scripts/layering/check.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@
3737
// - Over PLATFORM PACKAGE COMPOSITION: six private metadata façades meet at the exact root
3838
// composition file; premature implementation loading and forbidden cross-boundary edges fail (R13).
3939
// - Over REQUEST-BOUND RUNTIME EXECUTION: facts remain the only admission authority and daemon
40-
// code cannot manufacture or repair a narrowed runtime proof (R66). The historical per-command
41-
// cutover table was deleted after the last legacy execution shape disappeared.
40+
// code cannot manufacture or repair a narrowed runtime proof (R66).
4241
// - Over CONTRACTS PRODUCTION SOURCE: contracts owns vocabulary only — host, process, and timer
4342
// mechanics belong in capture-kit or an adapter (R18).
4443
// Only `(root)` is unranked among src/ zones (see `UNRANKED_ZONES` in model.ts):

scripts/layering/daemon-modularity.test.ts

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { test } from 'node:test';
33
import {
44
checkDaemonModularityRatchets,
55
DAEMON_MODULARITY_BASELINE,
6-
LOGICAL_MODULE_POLICIES,
76
TYPE_CYCLE_BASELINE,
87
} from './daemon-modularity.ts';
98
import { SESSION_STATE_FIELD_OWNERS } from './session-state.ts';
@@ -28,18 +27,9 @@ function baselineDaemonTypesEdges(): ResolvedImportEdge[] {
2827
);
2928
}
3029

31-
function recordedMigrationEdges(): ResolvedImportEdge[] {
32-
return LOGICAL_MODULE_POLICIES.flatMap((module) =>
33-
(module.recordedMigrationImports ?? []).map((recorded) => {
34-
const [file, target] = recorded.split(' -> ');
35-
return importEdge(file!, target!);
36-
}),
37-
);
38-
}
39-
40-
/** Every recorded import present and nothing else forbidden: the quiet state of the ratchets. */
30+
/** Every baseline edge is present and nothing else is forbidden: the quiet state of the ratchets. */
4131
function baselineEdges(): ResolvedImportEdge[] {
42-
return [...baselineDaemonTypesEdges(), ...recordedMigrationEdges()];
32+
return baselineDaemonTypesEdges();
4333
}
4434

4535
/** Where a member of `zone` lives, so a zone count can be turned back into file paths. */
@@ -94,14 +84,14 @@ test('external daemon/types.ts importer membership changes require the baseline
9484
assert.match(violations[0]!.message, /may only shrink from the recorded 2/);
9585

9686
const removed = checkDaemonModularityRatchets(
97-
[...baselineDaemonTypesEdges().slice(1), ...recordedMigrationEdges()],
87+
baselineDaemonTypesEdges().slice(1),
9888
baselineTypeCycleMembers(),
9989
);
10090
assert.equal(removed.length, 1);
10191
assert.match(removed[0]!.message, /delete it from externalDaemonTypesImporters/);
10292
});
10393

104-
test('planned logical modules start with zero forbidden imports', () => {
94+
test('logical modules reject forbidden imports', () => {
10595
const edges = resolveImportEdges(
10696
new Map([
10797
[
@@ -168,22 +158,6 @@ test('replay-test may still import its own files inside the package', () => {
168158
);
169159
});
170160

171-
// #1478 P3 cleared every recorded replay-test migration import: the ADR 0012 divergence
172-
// vocabulary became a neutral contracts leaf, and the reporter tree now reads the progress
173-
// wire vocabulary from contracts instead of request-global plumbing. The rule enforces
174-
// unconditionally for replay-test from here on.
175-
test('replay-test carries no recorded migration imports', () => {
176-
assert.equal(
177-
LOGICAL_MODULE_POLICIES.find(({ name }) => name === 'replay-test')?.recordedMigrationImports,
178-
undefined,
179-
);
180-
assert.deepEqual(
181-
LOGICAL_MODULE_POLICIES.flatMap((module) => module.recordedMigrationImports ?? []),
182-
[],
183-
);
184-
assert.deepEqual(checkDaemonModularityRatchets(baselineEdges(), baselineTypeCycleMembers()), []);
185-
});
186-
187161
test('internal trees reject deep imports globally, including from daemon', () => {
188162
const edges = resolveImportEdges(
189163
new Map([

scripts/layering/daemon-modularity.ts

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,6 @@ type LogicalModulePolicy = {
4444
name: string;
4545
roots: readonly string[];
4646
forbiddenTargetRoots: readonly string[];
47-
/**
48-
* Imports that already violate `forbiddenTargetRoots` on the day the rule was written, recorded
49-
* as `source -> target`. The rule enforces immediately for everything else, so a new violation
50-
* cannot be added while the module waits for its extraction PR; each recorded edge must be
51-
* deleted from this list by the change that removes the import, and re-adding one is a diff a
52-
* reviewer sees.
53-
*/
54-
recordedMigrationImports?: readonly string[];
5547
};
5648

5749
/**
@@ -242,7 +234,6 @@ function checkDaemonTypesImporters(edges: readonly ResolvedImportEdge[]): Layeri
242234

243235
function checkLogicalModuleImports(edges: readonly ResolvedImportEdge[]): LayeringViolation[] {
244236
const violations: LayeringViolation[] = [];
245-
const observedMigrationImports = new Set<string>();
246237
for (const edge of edges) {
247238
const sourceModule = moduleForFile(edge.file);
248239
const targetModule = moduleForFile(edge.target);
@@ -265,34 +256,13 @@ function checkLogicalModuleImports(edges: readonly ResolvedImportEdge[]): Layeri
265256
// `src/replay/` engine root it may not import from.
266257
if (sourceModule.roots.some((root) => edge.target.startsWith(root))) continue;
267258
if (!sourceModule.forbiddenTargetRoots.some((root) => edge.target.startsWith(root))) continue;
268-
const migrationImport = `${edge.file} -> ${edge.target}`;
269-
if (sourceModule.recordedMigrationImports?.includes(migrationImport)) {
270-
observedMigrationImports.add(migrationImport);
271-
continue;
272-
}
273259
violations.push({
274260
rule: 'R10 daemon-modularity',
275261
file: edge.file,
276262
line: edge.line,
277263
message: `${sourceModule.name} must not import ${edge.target}; communicate through its façade and a narrow port with two real adapters.`,
278264
});
279265
}
280-
return [...violations, ...checkRecordedMigrationImports(observedMigrationImports)];
281-
}
282-
283-
function checkRecordedMigrationImports(observed: ReadonlySet<string>): LayeringViolation[] {
284-
const violations: LayeringViolation[] = [];
285-
for (const module of LOGICAL_MODULE_POLICIES) {
286-
for (const migrationImport of module.recordedMigrationImports ?? []) {
287-
if (observed.has(migrationImport)) continue;
288-
violations.push({
289-
rule: 'R10 daemon-modularity',
290-
file: 'scripts/layering/daemon-modularity.ts',
291-
line: 1,
292-
message: `${migrationImport} no longer exists — delete it from ${module.name}'s recordedMigrationImports in the same change so the import cannot return.`,
293-
});
294-
}
295-
}
296266
return violations;
297267
}
298268

@@ -322,14 +292,10 @@ function groupBy(
322292

323293
export function daemonModularitySummary(): string {
324294
const session = DAEMON_MODULARITY_BASELINE.sessionState;
325-
const recordedMigrationImports = LOGICAL_MODULE_POLICIES.reduce(
326-
(sum, module) => sum + (module.recordedMigrationImports?.length ?? 0),
327-
0,
328-
);
329295
return (
330296
`R10 pins R7 at ${session.writerOwnedFields} writer-owned fields / ` +
331297
`${session.ownerFileClaims} owner claims, R9 at ${TYPE_CYCLE_BASELINE} files with zone ceilings, ` +
332298
`${DAEMON_MODULARITY_BASELINE.externalDaemonTypesImporters.length} external daemon/types.ts importers, ` +
333-
`and zero forbidden logical-module imports beyond ${recordedMigrationImports} recorded migration import(s)`
299+
'and zero forbidden logical-module imports'
334300
);
335301
}

scripts/layering/daemon-platform-boundary.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,7 @@ import { isProductionSourceFile } from './tracked-sources.ts';
44
import type { LayeringViolation } from './model.ts';
55

66
/**
7-
* R65 is the terminal daemon/platform boundary.
8-
*
9-
* R3's old platforms seam deliberately tolerated dynamic and type-only edges while the
10-
* request-bound runtime migration was in flight. That tolerance is not a terminal property:
11-
* either edge still makes the daemon depend on a concrete platform implementation. This policy
12-
* closes the boundary completely for tracked production daemon sources. It is kept independent
13-
* from `check.ts` until the remaining live edges are removed, so the migration can plant and
14-
* verify the red forms before making the repository-wide gate fail.
7+
* R65 rejects every concrete-platform dependency from tracked production daemon sources.
158
*
169
* The module record supplies static imports and re-exports; the AST supplies dynamic imports and
1710
* TypeScript import types. Reading syntax through oxc-parser, rather than searching source text,
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/** A production file the cutover policies scan: repo-relative path plus its source. */
1+
/** Shared AST helpers for permanent layering policies. */
22
export type ProductionSource = Readonly<{ path: string; source: string }>;
33

44
export function memberName(node: Record<string, unknown>): string | undefined {

scripts/layering/platform-package-source-policy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { parseSync } from 'oxc-parser';
2-
import { memberPath } from './cutover-policy-ast.ts';
2+
import { memberPath } from './layering-ast.ts';
33
import { parseImports, type LayeringViolation } from './model.ts';
44

55
const RULE = 'R13 platform-package-substrate';

scripts/layering/record-runtime-mechanics-policy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { parseSync } from 'oxc-parser';
2-
import { memberName, type ProductionSource, visitAst } from './cutover-policy-ast.ts';
2+
import { memberName, type ProductionSource, visitAst } from './layering-ast.ts';
33

44
const DAEMON_RECORD_MECHANIC_CALLS = new Set([
55
'runCmd',

scripts/layering/record-runtime-registry-policy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { parseSync } from 'oxc-parser';
2-
import { memberName, type ProductionSource, visitAst } from './cutover-policy-ast.ts';
2+
import { memberName, type ProductionSource, visitAst } from './layering-ast.ts';
33

44
export function recordRuntimeRegistryJoinViolations(
55
sources: readonly ProductionSource[],

scripts/layering/runtime-execution-policy.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { parseSync } from 'oxc-parser';
2-
import { memberName, propertyName, visitAst } from './cutover-policy-ast.ts';
2+
import { memberName, propertyName, visitAst } from './layering-ast.ts';
33
import type { LayeringViolation } from './model.ts';
44

55
type AstNode = Record<string, unknown>;
@@ -10,15 +10,7 @@ const COMMAND_DESCRIPTOR_MODULE = 'src/core/command-descriptor/registry.ts';
1010
const RUNTIME_ADMISSION_MODULE = 'src/daemon/runtime-admission.ts';
1111
const RUNTIME_PROOF_TYPES = new Set(['AdmittedRuntimePlan', 'BoundDeviceRuntime']);
1212

13-
/**
14-
* Permanent runtime invariants after ADR 0019's command-by-command migration completed.
15-
*
16-
* The old cutover table named every retired symbol and every operation owner. Those were useful
17-
* assertions while two execution systems coexisted, but keeping them after the old system was
18-
* deleted made handler names and historical routes a second source of truth. The surviving
19-
* invariant is generic: facts are the only admission authority, and daemon code must not
20-
* manufacture or repair the proof carried by a narrowed runtime.
21-
*/
13+
/** Facts are the only admission authority, and daemon code must consume narrowed runtime proofs. */
2214
export function runtimeExecutionIntegrityViolations(
2315
sources: ReadonlyMap<string, string>,
2416
): LayeringViolation[] {

0 commit comments

Comments
 (0)