Skip to content

Commit 4a083b9

Browse files
committed
fix(audits): stop the canonical-index guard flagging its own source
The audit holds `buildCanonicalIndex(` and `createCanonicalModeGates(` as string literals to search for, and its own regex matched them — the arg-count rule then fired on the literal. It passed locally only because the file was still untracked when it ran, so `git ls-files` did not list it; committing it made the audit scan itself and fail CI on the first run. Exempts the audit's own source alongside the module that defines the primitives. Verified the guard still fails on both regression shapes after the exemption.
1 parent 2d53b4a commit 4a083b9

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

scripts/check-canonical-index-surface.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,18 @@ const ROOT = path.resolve(import.meta.dir, '..')
3636
const ANNOTATION = 'canonical-index-unscoped:'
3737

3838
/**
39-
* Where the surface-scoping primitives are defined. `buildCanonicalIndexForSurface` has to call
40-
* the raw `buildCanonicalIndex`, so the defining module is exempt rather than annotated.
39+
* Files that hold the guarded names without calling them.
40+
*
41+
* `buildCanonicalIndexForSurface` has to call the raw `buildCanonicalIndex`, so its defining
42+
* module is exempt rather than annotated. This audit's own source carries both names as string
43+
* literals to search for — without the exemption it flags itself, which is not hypothetical: it
44+
* passed locally while the file was still untracked and failed the moment it was committed and
45+
* `git ls-files` started listing it.
4146
*/
42-
const DEFINING_MODULE = 'apps/sim/lib/workflows/subblocks/visibility.ts'
47+
const NOT_CALLERS = new Set([
48+
'apps/sim/lib/workflows/subblocks/visibility.ts',
49+
'scripts/check-canonical-index-surface.ts',
50+
])
4351

4452
/** The `triggerSurface` argument's position in `createCanonicalModeGates`. */
4553
const GATES_SURFACE_ARG_COUNT = 4
@@ -108,7 +116,7 @@ if (listed.status !== 0) {
108116
const files = listed.stdout
109117
.toString('utf8')
110118
.split('\0')
111-
.filter((entry) => entry.length > 0 && !entry.includes('.test.') && entry !== DEFINING_MODULE)
119+
.filter((entry) => entry.length > 0 && !entry.includes('.test.') && !NOT_CALLERS.has(entry))
112120

113121
const offenders: Offender[] = []
114122
let scanned = 0

0 commit comments

Comments
 (0)