Repository navigation
Expand file tree
/
Copy pathdaemon-client-entry.ts
More file actions
39 lines (37 loc) · 2.01 KB
/
Copy pathdaemon-client-entry.ts
File metadata and controls
39 lines (37 loc) · 2.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import type { LayeringViolation, ResolvedImportEdge } from './model.ts';
import { DAEMON_SOURCE_ROOT } from './tracked-sources.ts';
export const DAEMON_CLIENT_ENTRY_RULE = 'R78 daemon-client-entry';
/**
* Catches: the client reaching daemon internals — any import, type-only or runtime, of a module
* under the daemon package. `src/daemon-client/**` composes the daemon over the network, not over
* its module graph. What the client shares with the daemon lives below both sides: the on-disk and
* protocol contracts in `packages/daemon-contracts`, the request shape in
* `@agent-device/contracts/command` (`DaemonWireRequest`) and the response vocabulary in
* `@agent-device/kernel/contracts`.
* Evidence: #2559 measured 13 client→daemon pairs (8 runtime) at the #2557 tip; the runtime half was
* driven to 0 then, and the wire-type half to 0 when the client moved to `DaemonWireRequest`.
* Cost: one rule registered in check.ts's whole-graph pass; not a standalone CI job.
* Kill criterion: a maintainer decision that the client may compose daemon internals directly.
*/
export function checkDaemonClientEntry(edges: readonly ResolvedImportEdge[]): LayeringViolation[] {
const violations: LayeringViolation[] = [];
const reported = new Set<string>();
for (const edge of edges) {
if (!edge.file.startsWith('src/daemon-client/')) continue;
if (!edge.target.startsWith(DAEMON_SOURCE_ROOT)) continue;
const key = `${edge.file} -> ${edge.target}`;
if (reported.has(key)) continue;
reported.add(key);
violations.push({
rule: DAEMON_CLIENT_ENTRY_RULE,
file: edge.file,
line: edge.line,
message:
`the daemon client imports daemon internals: ${key}. The client composes the daemon over ` +
`the network, not its module graph. Move the shared contract to packages/daemon-contracts, ` +
`or read DaemonWireRequest from @agent-device/contracts/command and DaemonResponse from ` +
`@agent-device/kernel/contracts.`,
});
}
return violations;
}