@@ -277,4 +277,35 @@ describe("upstream merge guards", () => {
277277 } )
278278 }
279279 } )
280+
281+ // altimate_change start — marker guard safety: ensure src/ files are never excluded
282+ describe ( "marker guard exclusions must never bypass src/ protection" , ( ) => {
283+ test ( "markerExcludePatterns in analyze.ts must not match packages/opencode/src/**/*.ts" , ( ) => {
284+ const analyzeContent = readFileSync ( join ( repoRoot , "script" , "upstream" , "analyze.ts" ) , "utf-8" )
285+ // Extract markerExcludePatterns array
286+ const match = analyzeContent . match ( / m a r k e r E x c l u d e P a t t e r n s \s * = \s * \[ ( [ \s \S ] * ?) \] / )
287+ expect ( match ) . not . toBeNull ( )
288+ const patternsBlock = match ! [ 1 ]
289+
290+ // These patterns must NEVER appear — they would bypass marker protection for source code
291+ const dangerousPatterns = [
292+ "packages/opencode/src/**" ,
293+ "packages/opencode/src/*.ts" ,
294+ "**/src/**" ,
295+ "**/*.ts" ,
296+ ]
297+ for ( const dangerous of dangerousPatterns ) {
298+ expect ( patternsBlock ) . not . toContain ( `"${ dangerous } "` )
299+ }
300+ } )
301+
302+ test ( "CI marker guard runs in strict mode for non-merge PRs" , ( ) => {
303+ const ciContent = readFileSync ( join ( repoRoot , ".github" , "workflows" , "ci.yml" ) , "utf-8" )
304+ // Must have --strict flag for regular PRs
305+ expect ( ciContent ) . toContain ( "--strict" )
306+ // Must detect merge branches to skip strict
307+ expect ( ciContent ) . toContain ( "merge-upstream-" )
308+ } )
309+ } )
310+ // altimate_change end
280311} )
0 commit comments