Skip to content

Commit e00b556

Browse files
committed
docs(path-guard): sync paths-allowlist.yml schema docs + check-paths.mts.tmpl
The schema docs in paths-allowlist.yml drifted from canonical. The old comment claimed line tolerance is ±2 (FALSE since Gap 2; lines are now strict-exact) and didn't mention snippet_hash or --show-hashes. Also brings the path-guard skill reference template up to date.
1 parent ac76425 commit e00b556

2 files changed

Lines changed: 28 additions & 13 deletions

File tree

.claude/skills/path-guard/reference/check-paths.mts.tmpl

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,8 @@ const loadAllowlist = (): AllowlistEntry[] => {
229229
blockLines = []
230230
return
231231
}
232-
;(current as any)[key] = key === 'line' ? Number(unquote(trimmed)) : unquote(trimmed)
232+
;(current as any)[key] =
233+
key === 'line' ? Number(unquote(trimmed)) : unquote(trimmed)
233234
}
234235
if (line.startsWith('- ')) {
235236
if (current && current.reason) {
@@ -317,8 +318,7 @@ const isAllowlisted = (finding: Finding): boolean =>
317318
const hashProvided =
318319
typeof entry.snippet_hash === 'string' && entry.snippet_hash.length > 0
319320
if (lineProvided || hashProvided) {
320-
const lineMatches =
321-
lineProvided && entry.line === finding.line
321+
const lineMatches = lineProvided && entry.line === finding.line
322322
const hashMatches =
323323
hashProvided && entry.snippet_hash === snippetHash(finding.snippet)
324324
if (!(lineMatches || hashMatches)) {
@@ -382,7 +382,8 @@ const STRING_LITERAL_RE = /(['"])((?:\\.|(?!\1)[^\\])*)\1/g
382382
// (including those with `${...}` placeholders) so Rule A also catches
383383
// path construction via template literals like
384384
// `${buildDir}/out/Final/${binary}` or `build/${mode}/out/Final`.
385-
const TEMPLATE_LITERAL_RE = /`((?:\\.|(?:\$\{(?:[^{}]|\{[^{}]*\})*\})|(?!`)[^\\])*)`/g
385+
const TEMPLATE_LITERAL_RE =
386+
/`((?:\\.|(?:\$\{(?:[^{}]|\{[^{}]*\})*\})|(?!`)[^\\])*)`/g
386387
387388
/**
388389
* Convert a template-literal body into a synthetic forward-slash path

.github/paths-allowlist.yml

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,35 @@
77
#
88
# Schema (all top-level keys optional except `reason`):
99
#
10-
# - rule: Rule letter (A, B, C, D, F, G). Omit to match any rule.
11-
# file: Substring match against the relative file path.
12-
# pattern: Substring match against the offending snippet.
13-
# line: Line number; matches if within ±2 of the finding.
14-
# reason: Why this site is genuinely exempt. Required.
10+
# - rule: Rule letter (A, B, C, D, F, G). Omit to match any rule.
11+
# file: Substring match against the relative file path.
12+
# pattern: Substring match against the offending snippet.
13+
# line: Exact line number. Strict — no fuzz tolerance.
14+
# snippet_hash: 12-char SHA-256 prefix of the normalized snippet
15+
# (whitespace collapsed). Drift-resistant: the entry
16+
# keeps matching after reformatting that doesn't
17+
# change the offending construction. Get the hash by
18+
# running `node scripts/check-paths.mts --show-hashes`.
19+
# reason: Why this site is genuinely exempt. Required.
1520
#
16-
# Prefer narrow entries (rule + file + line + pattern) over blanket
17-
# `file:` entries that exempt the whole file. Genuine exemptions are
18-
# rare — most "false positives" should be reported as gate bugs.
21+
# Match policy: if `line` is provided it must match exactly. If
22+
# `snippet_hash` is provided it must match exactly. Both may be set —
23+
# either one matching is sufficient (so a code reformat that keeps
24+
# the snippet but moves the line still matches via hash, and a
25+
# reformat that changes the snippet but keeps the line still matches
26+
# via line). If neither is set, `file` + `pattern` + `rule` matching
27+
# is used (broader; prefer narrow entries when possible).
28+
#
29+
# Prefer narrow entries (rule + file + snippet_hash + pattern) over
30+
# blanket `file:` entries that exempt the whole file. Genuine
31+
# exemptions are rare — most "false positives" should be reported
32+
# as gate bugs.
1933
#
2034
# Example:
2135
#
2236
# - rule: A
2337
# file: packages/foo/scripts/legacy-build.mts
24-
# line: 42
38+
# snippet_hash: a1b2c3d4e5f6
2539
# pattern: "path.join(testDir, 'out', 'Final')"
2640
# reason: |
2741
# legacy-build.mts is scheduled for removal in v2.0; refactoring

0 commit comments

Comments
 (0)