@@ -6,37 +6,84 @@ import type { UnruledViolation } from './runtime-command-cutover-model.ts';
66type AstNode = Record < string , unknown > ;
77
88const SNAPSHOT_ROUTE_FILE = 'src/daemon/snapshot-runtime.ts' ;
9+ const SNAPSHOT_COMMAND_FILE = 'src/daemon/snapshot-command-runtime.ts' ;
910const SNAPSHOT_BINDING_FILE = 'src/daemon/snapshot-runtime-binding.ts' ;
1011
1112/** R32 admits only through the shared facts-first seam selected by the normalized runtime plan. */
1213export function snapshotPlatformPolicyBranchViolations (
1314 sources : ReadonlyMap < string , string > ,
1415) : UnruledViolation [ ] {
15- const source = sources . get ( SNAPSHOT_ROUTE_FILE ) ;
16- if ( source === undefined ) return [ violation ( 1 , 'snapshot runtime route is missing' ) ] ;
16+ const routeSource = sources . get ( SNAPSHOT_ROUTE_FILE ) ;
17+ if ( routeSource === undefined ) {
18+ return [ violation ( SNAPSHOT_ROUTE_FILE , 1 , 'snapshot runtime route is missing' ) ] ;
19+ }
20+ const commandSource = sources . get ( SNAPSHOT_COMMAND_FILE ) ;
21+ if ( commandSource === undefined ) {
22+ return [ violation ( SNAPSHOT_COMMAND_FILE , 1 , 'snapshot runtime command owner is missing' ) ] ;
23+ }
24+ const bindingSource = sources . get ( SNAPSHOT_BINDING_FILE ) ;
25+ if ( bindingSource === undefined ) {
26+ return [ violation ( SNAPSHOT_BINDING_FILE , 1 , 'snapshot runtime binding is missing' ) ] ;
27+ }
1728
18- const program = parseSync ( SNAPSHOT_ROUTE_FILE , source ) . program as AstNode ;
19- const route = namedFunction ( program , 'dispatchSnapshotViaRuntime' ) ;
20- if ( route === undefined ) return [ violation ( 1 , 'snapshot public runtime route is missing' ) ] ;
29+ const routeProgram = parseSync ( SNAPSHOT_ROUTE_FILE , routeSource ) . program as AstNode ;
30+ const route = namedFunction ( routeProgram , 'dispatchSnapshotViaRuntime' ) ;
31+ if ( route === undefined ) {
32+ return [ violation ( SNAPSHOT_ROUTE_FILE , 1 , 'snapshot public runtime route is missing' ) ] ;
33+ }
34+ const commandProgram = parseSync ( SNAPSHOT_COMMAND_FILE , commandSource ) . program as AstNode ;
35+ const commandOwner = namedFunction ( commandProgram , 'dispatchSnapshotRuntimeCommand' ) ;
36+ if ( commandOwner === undefined ) {
37+ return [ violation ( SNAPSHOT_COMMAND_FILE , 1 , 'snapshot runtime command owner is missing' ) ] ;
38+ }
39+ const bindingProgram = parseSync ( SNAPSHOT_BINDING_FILE , bindingSource ) . program as AstNode ;
40+ const owner = namedFunction ( bindingProgram , 'resolveBoundSnapshotCaptureRuntime' ) ;
41+ if ( owner === undefined ) {
42+ return [
43+ violation ( SNAPSHOT_BINDING_FILE , 1 , 'snapshot bound capture owning interface is missing' ) ,
44+ ] ;
45+ }
2146
2247 const violations : UnruledViolation [ ] = [ ] ;
23- if ( countNamedCalls ( route , 'resolveSnapshotRuntimePlan' ) !== 1 ) {
48+ if ( countNamedCalls ( route , 'dispatchSnapshotRuntimeCommand' ) !== 1 ) {
49+ violations . push (
50+ violation (
51+ SNAPSHOT_ROUTE_FILE ,
52+ lineOf ( routeSource , route ) ,
53+ 'snapshot route must delegate exactly once to the shared runtime command owner' ,
54+ ) ,
55+ ) ;
56+ }
57+ if ( countNamedCalls ( commandOwner , 'resolveBoundSnapshotCaptureRuntime' ) !== 1 ) {
2458 violations . push (
25- violation ( lineOf ( source , route ) , 'snapshot route must select exactly one normalized plan' ) ,
59+ violation (
60+ SNAPSHOT_COMMAND_FILE ,
61+ lineOf ( commandSource , commandOwner ) ,
62+ 'snapshot runtime command owner must resolve one bound capture' ,
63+ ) ,
64+ ) ;
65+ }
66+ if ( countNamedCalls ( owner , 'resolveSnapshotRuntimePlan' ) !== 1 ) {
67+ violations . push (
68+ violation (
69+ SNAPSHOT_BINDING_FILE ,
70+ lineOf ( bindingSource , owner ) ,
71+ 'snapshot owning interface must select exactly one normalized plan' ,
72+ ) ,
2673 ) ;
2774 }
2875
29- const admissions = namedCalls ( route , 'inspectRequiredRuntimeUse' ) ;
76+ const admissions = namedCalls ( owner , 'inspectRequiredRuntimeUse' ) ;
3077 if ( admissions . length !== 1 || ! hasExactAdmissionInput ( admissions [ 0 ] ) ) {
3178 violations . push (
3279 violation (
33- lineOf ( source , admissions [ 0 ] ?? route ) ,
34- 'snapshot route must admit exactly once through inspectRequiredRuntimeUse(device, plan.use, inspectFacts)' ,
80+ SNAPSHOT_BINDING_FILE ,
81+ lineOf ( bindingSource , admissions [ 0 ] ?? owner ) ,
82+ 'snapshot owning interface must admit exactly once through inspectRequiredRuntimeUse(device, plan.use, inspectFacts)' ,
3583 ) ,
3684 ) ;
3785 }
3886
39- const bindingSource = sources . get ( SNAPSHOT_BINDING_FILE ) ?? '' ;
4087 if ( bindingSource . includes ( 'inspectSnapshotCaptureAdmission' ) ) {
4188 violations . push ( {
4289 file : SNAPSHOT_BINDING_FILE ,
@@ -82,6 +129,6 @@ function isNode(node: unknown, type: string): node is AstNode {
82129 return node !== null && typeof node === 'object' && ( node as AstNode ) . type === type ;
83130}
84131
85- function violation ( line : number , message : string ) : UnruledViolation {
86- return { file : SNAPSHOT_ROUTE_FILE , line, message } ;
132+ function violation ( file : string , line : number , message : string ) : UnruledViolation {
133+ return { file, line, message } ;
87134}
0 commit comments