@@ -149,25 +149,23 @@ function expanded(ds: Declaration[], system: DesignSystem): Declaration[] {
149149}
150150function inspect ( facts : Facts , file : string , system : DesignSystem ) : Checked {
151151 const out : Checked = { findings : [ ] , unchecked : [ ...facts . unchecked ] , governed : 0 , ungoverned : 0 }
152- const localVars = new Map (
153- ( facts . surfaces ?? [ ] ) . flatMap ( ( s ) =>
154- s . atoms
152+ for ( const surface of facts . surfaces ?? [ ] ) {
153+ const localVars = new Map (
154+ surface . atoms
155155 . filter ( ( a ) => a . kind === 'token' || a . property . startsWith ( '--' ) )
156156 . map ( ( a ) => [ a . property , a . value ] as const )
157157 )
158- )
159- const expand = ( value : string , seen = new Set < string > ( ) ) : string =>
160- value . replace ( / v a r \( \s * ( - - [ \w - ] + ) \s * \) / g, ( all , key : string ) => {
161- if (
162- system . variableFamilies . has ( key ) ||
163- ! localVars . has ( key ) ||
164- seen . has ( key ) ||
165- seen . size >= 12
166- )
167- return all
168- return expand ( localVars . get ( key ) as string , new Set ( seen ) . add ( key ) )
169- } )
170- for ( const surface of facts . surfaces ?? [ ] ) {
158+ const expand = ( value : string , seen = new Set < string > ( ) ) : string =>
159+ value . replace ( / v a r \( \s * ( - - [ \w - ] + ) \s * \) / g, ( all , key : string ) => {
160+ if (
161+ system . variableFamilies . has ( key ) ||
162+ ! localVars . has ( key ) ||
163+ seen . has ( key ) ||
164+ seen . size >= 12
165+ )
166+ return all
167+ return expand ( localVars . get ( key ) as string , new Set ( seen ) . add ( key ) )
168+ } )
171169 if ( surface . kind === 'integration' ) continue
172170 const surfaceFindings = new Set < string > ( )
173171 const emit = (
@@ -684,15 +682,27 @@ export class ConformanceLinter {
684682 if ( isRegistry ( file ) ) {
685683 const b = change . before ? JSON . parse ( read ( change . before ) ) : null
686684 const a = change . after ? JSON . parse ( read ( change . after ) ) : null
687- if ( canonical ( b ) !== canonical ( a ) )
685+ const stable = ( value : unknown ) : unknown =>
686+ Array . isArray ( value )
687+ ? value . map ( stable )
688+ : value && typeof value === 'object'
689+ ? Object . fromEntries (
690+ Object . entries ( value )
691+ . sort ( ( [ a ] , [ b ] ) => ( a < b ? - 1 : a > b ? 1 : 0 ) )
692+ . map ( ( [ key , value ] ) => [ key , stable ( value ) ] )
693+ )
694+ : value
695+ const beforePolicy = canonical ( stable ( b ) )
696+ const afterPolicy = canonical ( stable ( a ) )
697+ if ( beforePolicy !== afterPolicy )
688698 report . findings . push ( {
689699 kind : 'system-change' ,
690700 contract : 'central-definition' ,
691701 rule : 'central-definition' ,
692702 category : 'contracts' ,
693703 property : 'registry' ,
694- value : hash ( canonical ( a ) ) ,
695- before : hash ( canonical ( b ) ) ,
704+ value : hash ( afterPolicy ) ,
705+ before : hash ( beforePolicy ) ,
696706 reason : 'Design-system contract registry changed' ,
697707 file,
698708 line : 1 ,
0 commit comments