@@ -187,4 +187,47 @@ describe('architecture boundaries', () => {
187187 expectNoViolations ( findRelativeImportViolations ( srcDir , / f r o m \s + [ ' " ] .* l a y o u t - e n g i n e \/ / ) ) ;
188188 } ) ;
189189 } ) ;
190+
191+ describe ( 'Guard D: painter-dom is a dumb final renderer with no upstream dependencies' , ( ) => {
192+ it ( 'painter-dom runtime src does not import @superdoc/pm-adapter' , ( ) => {
193+ const srcDir = path . join ( LAYOUT_ENGINE_ROOT , 'painters/dom/src' ) ;
194+ expectNoViolations ( findImportViolations ( srcDir , '@superdoc/pm-adapter' ) ) ;
195+ } ) ;
196+
197+ it ( 'painter-dom runtime src does not import @superdoc/layout-bridge' , ( ) => {
198+ const srcDir = path . join ( LAYOUT_ENGINE_ROOT , 'painters/dom/src' ) ;
199+ expectNoViolations ( findImportViolations ( srcDir , '@superdoc/layout-bridge' ) ) ;
200+ } ) ;
201+
202+ it ( 'painter-dom runtime src does not import @superdoc/layout-resolved (test-only utility)' , ( ) => {
203+ const srcDir = path . join ( LAYOUT_ENGINE_ROOT , 'painters/dom/src' ) ;
204+ // _test-utils.ts is test-only and excluded from runtime collection. The
205+ // architecture-boundary check passes when no runtime file imports
206+ // layout-resolved.
207+ const files = collectRuntimeSources ( srcDir ) . filter ( ( f ) => ! f . endsWith ( '_test-utils.ts' ) ) ;
208+ const violations : { file : string ; line : string } [ ] = [ ] ;
209+ const pattern = new RegExp ( `['"]@superdoc/layout-resolved(?:[/'"]|$)` ) ;
210+ for ( const file of files ) {
211+ const raw = fs . readFileSync ( file , 'utf-8' ) ;
212+ const processed = preprocessSource ( raw ) ;
213+ const lines = processed . split ( '\n' ) ;
214+ for ( const ln of lines ) {
215+ if ( pattern . test ( ln ) ) {
216+ violations . push ( { file : path . relative ( LAYOUT_ENGINE_ROOT , file ) , line : ln . trim ( ) } ) ;
217+ }
218+ }
219+ }
220+ expectNoViolations ( violations ) ;
221+ } ) ;
222+
223+ it ( 'painter-dom runtime src does not import relative pm-adapter paths' , ( ) => {
224+ const srcDir = path . join ( LAYOUT_ENGINE_ROOT , 'painters/dom/src' ) ;
225+ expectNoViolations ( findRelativeImportViolations ( srcDir , / f r o m \s + [ ' " ] .* p m - a d a p t e r \/ / ) ) ;
226+ } ) ;
227+
228+ it ( 'painter-dom runtime src does not import relative layout-bridge paths' , ( ) => {
229+ const srcDir = path . join ( LAYOUT_ENGINE_ROOT , 'painters/dom/src' ) ;
230+ expectNoViolations ( findRelativeImportViolations ( srcDir , / f r o m \s + [ ' " ] .* l a y o u t - b r i d g e \/ / ) ) ;
231+ } ) ;
232+ } ) ;
190233} ) ;
0 commit comments