Skip to content

Commit 3a8fd89

Browse files
anandgupta42claude
andcommitted
test: add marker guard safety tests to prevent bypass
- Verify `markerExcludePatterns` never matches `src/` source files - Verify CI uses `--strict` mode for non-merge PRs - Prevents future changes from accidentally disabling marker protection Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent b61090d commit 3a8fd89

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

packages/opencode/test/branding/upstream-guard.test.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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(/markerExcludePatterns\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

Comments
 (0)