Skip to content

Commit 9ff38c2

Browse files
committed
chore(gates): forbid the daemon importing the CLI schema layer
R10 (scripts/layering/daemon-modularity) now rejects any daemon import of src/cli-schema/, value or type. The last two value edges into command-schema.ts are gone, so a total boundary is available, and an explicit rule beats a rank that would let the next daemon module reach the CLI schema layer again. Part of #2545 / #2543.
1 parent 1d258c0 commit 9ff38c2

2 files changed

Lines changed: 57 additions & 0 deletions

File tree

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

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,38 @@ test('R10 banks an R7 shrink with no edit anywhere', () => {
106106
);
107107
});
108108

109+
test('R10 forbids the daemon importing the CLI schema layer, value or type', () => {
110+
const valueEdge: ResolvedImportEdge = {
111+
...importEdge('src/daemon/request-execution-scope.ts', 'src/cli-schema/command-schema.ts'),
112+
typeOnly: false,
113+
};
114+
const typeEdge = importEdge(
115+
'src/daemon/session-action-recorder.ts',
116+
'src/cli-schema/command-schema.ts',
117+
);
118+
const violations = checkDaemonModularityRatchets(
119+
[...baselineEdges(), valueEdge, typeEdge],
120+
REFERENCE,
121+
REFERENCE,
122+
);
123+
assert.deepEqual(
124+
violations.map(({ rule, file }) => ({ rule, file })),
125+
[
126+
{ rule: 'R10 daemon-modularity', file: 'src/daemon/request-execution-scope.ts' },
127+
{ rule: 'R10 daemon-modularity', file: 'src/daemon/session-action-recorder.ts' },
128+
],
129+
);
130+
assert.match(violations[0]!.message, /must not import src\/cli-schema\/command-schema\.ts/);
131+
});
132+
133+
test('R10 permits a non-daemon importer of the CLI schema layer', () => {
134+
const cliEdge = importEdge('src/cli/parser/args.ts', 'src/cli-schema/command-schema.ts');
135+
assert.deepEqual(
136+
checkDaemonModularityRatchets([...baselineEdges(), cliEdge], REFERENCE, REFERENCE),
137+
[],
138+
);
139+
});
140+
109141
test('external daemon request/session-state importer membership changes require the baseline to change', () => {
110142
const edges = resolveImportEdges(
111143
new Map([

‎scripts/layering/daemon-modularity.ts‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,35 @@ export function checkDaemonModularityRatchets(
7272
...checkSessionStateBaseline(measured.sessionState, reference.sessionState),
7373
...checkTypeCycleBaseline(measured.largestTypeCycle, reference.largestTypeCycle),
7474
...checkDaemonTypesImporters(edges),
75+
...checkDaemonCliSchemaBoundary(edges),
7576
...checkLogicalModuleImports(edges),
7677
];
7778
}
7879

80+
// The daemon resolves command routes through the registry and fills request defaults through the
81+
// command registry, so it never needs the CLI schema layer. #2543 cut the last two value edges
82+
// (`request-execution-scope.ts` and `session-action-recorder.ts`); this pins that decoupling so a
83+
// future daemon module cannot reach `src/cli-schema/` again and re-pull the parser closure.
84+
const DAEMON_FORBIDDEN_CLI_SCHEMA_ROOT = 'src/cli-schema/';
85+
86+
function checkDaemonCliSchemaBoundary(edges: readonly ResolvedImportEdge[]): LayeringViolation[] {
87+
return edges
88+
.filter(
89+
(edge) =>
90+
edge.file.startsWith('src/daemon/') &&
91+
matchesDeclaredRoot(edge.target, DAEMON_FORBIDDEN_CLI_SCHEMA_ROOT),
92+
)
93+
.map((edge) => ({
94+
rule: 'R10 daemon-modularity',
95+
file: edge.file,
96+
line: edge.line,
97+
message:
98+
`${edge.file} must not import ${edge.target}: the daemon resolves routes through ` +
99+
'@agent-device/command-registry and must not load the CLI schema layer. Declare the shared ' +
100+
'shape in the command registry or contracts, not in src/cli-schema/.',
101+
}));
102+
}
103+
79104
export function checkRetiredSessionLifecyclePaths(
80105
sourceFiles: readonly string[],
81106
): LayeringViolation[] {

0 commit comments

Comments
 (0)