@@ -7,6 +7,7 @@ const ruleDescriptions = {
77 ARCH002 : "Public modules may only reach internals through their designated implementation seam" ,
88 ARCH003 : "Core internals may only refer back to Machine through type-only imports" ,
99 ARCH004 : "The planner may not depend on process or runtime execution" ,
10+ ARCH005 : "Machine semantic layers may only depend inward" ,
1011 ARCH006 : "The runtime may not depend on machine semantics or process orchestration" ,
1112 ARCH007 : "Production modules may not depend on testing internals" ,
1213 ARCH008 : "Black-box tests may not depend on implementation internals" ,
@@ -219,6 +220,65 @@ export const checkArchitecture = ({
219220 [ "src/unstable/reactivity/AtomMachine.ts" , "src/internal/machine/atom.ts" ] ,
220221 [ "src/unstable/cluster/ClusterMachine.ts" , "src/internal/machine/cluster.ts" ]
221222 ] )
223+ const forbiddenSemanticDependencies = new Map ( [
224+ [ "src/internal/machine/topology.ts" , new Set ( [
225+ "src/internal/machine/protocol.ts" ,
226+ "src/internal/machine/configuration.ts" ,
227+ "src/internal/machine/serialization.ts" ,
228+ "src/internal/machine/planner.ts" ,
229+ "src/internal/machine/command.ts" ,
230+ "src/internal/machine/executionPlan.ts" ,
231+ "src/internal/machine/commandRuntime.ts" ,
232+ "src/internal/machine/process.ts" ,
233+ "src/internal/machine/runtime.ts"
234+ ] ) ] ,
235+ [ "src/internal/machine/protocol.ts" , new Set ( [
236+ "src/internal/machine/configuration.ts" ,
237+ "src/internal/machine/serialization.ts" ,
238+ "src/internal/machine/planner.ts" ,
239+ "src/internal/machine/command.ts" ,
240+ "src/internal/machine/executionPlan.ts" ,
241+ "src/internal/machine/commandRuntime.ts" ,
242+ "src/internal/machine/process.ts" ,
243+ "src/internal/machine/runtime.ts"
244+ ] ) ] ,
245+ [ "src/internal/machine/configuration.ts" , new Set ( [
246+ "src/internal/machine/serialization.ts" ,
247+ "src/internal/machine/planner.ts" ,
248+ "src/internal/machine/command.ts" ,
249+ "src/internal/machine/executionPlan.ts" ,
250+ "src/internal/machine/commandRuntime.ts" ,
251+ "src/internal/machine/process.ts" ,
252+ "src/internal/machine/runtime.ts"
253+ ] ) ] ,
254+ [ "src/internal/machine/serialization.ts" , new Set ( [
255+ "src/internal/machine/planner.ts" ,
256+ "src/internal/machine/command.ts" ,
257+ "src/internal/machine/executionPlan.ts" ,
258+ "src/internal/machine/commandRuntime.ts" ,
259+ "src/internal/machine/process.ts" ,
260+ "src/internal/machine/runtime.ts"
261+ ] ) ] ,
262+ [ "src/internal/machine/command.ts" , new Set ( [
263+ "src/internal/machine/executionPlan.ts" ,
264+ "src/internal/machine/commandRuntime.ts" ,
265+ "src/internal/machine/process.ts" ,
266+ "src/internal/machine/runtime.ts"
267+ ] ) ] ,
268+ [ "src/internal/machine/planner.ts" , new Set ( [
269+ "src/internal/machine/serialization.ts" ,
270+ "src/internal/machine/executionPlan.ts" ,
271+ "src/internal/machine/commandRuntime.ts" ,
272+ "src/internal/machine/process.ts" ,
273+ "src/internal/machine/runtime.ts"
274+ ] ) ] ,
275+ [ "src/internal/machine/executionPlan.ts" , new Set ( [
276+ "src/internal/machine/serialization.ts" ,
277+ "src/internal/machine/commandRuntime.ts" ,
278+ "src/internal/machine/process.ts" ,
279+ "src/internal/machine/runtime.ts"
280+ ] ) ]
281+ ] )
222282
223283 for ( const edge of edges ) {
224284 if ( entrypoints . has ( edge . source ) && edge . target . includes ( "/internal/" ) ) {
@@ -261,7 +321,12 @@ export const checkArchitecture = ({
261321 if (
262322 edge . source === "src/internal/machine/planner.ts" &&
263323 ! edge . typeOnly &&
264- ( edge . target === "src/internal/machine/process.ts" || edge . target === "src/internal/machine/runtime.ts" )
324+ [
325+ "src/internal/machine/commandRuntime.ts" ,
326+ "src/internal/machine/executionPlan.ts" ,
327+ "src/internal/machine/process.ts" ,
328+ "src/internal/machine/runtime.ts"
329+ ] . includes ( edge . target )
265330 ) {
266331 diagnostics . push ( diagnostic (
267332 "ARCH004" ,
@@ -271,10 +336,20 @@ export const checkArchitecture = ({
271336 `Planner has a runtime dependency on ${ edge . target } `
272337 ) )
273338 }
339+ if ( forbiddenSemanticDependencies . get ( edge . source ) ?. has ( edge . target ) ) {
340+ diagnostics . push ( diagnostic (
341+ "ARCH005" ,
342+ edge . sourceFile ,
343+ edge . node ,
344+ edge . source ,
345+ `Semantic layer depends outward on ${ edge . target } `
346+ ) )
347+ }
274348 if (
275349 edge . source === "src/internal/machine/runtime.ts" &&
276350 [
277- "src/internal/machine/model.ts" ,
351+ "src/internal/machine/configuration.ts" ,
352+ "src/internal/machine/executionPlan.ts" ,
278353 "src/internal/machine/planner.ts" ,
279354 "src/internal/machine/process.ts"
280355 ] . includes ( edge . target )
0 commit comments