@blundergoat/gruff-ts 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/CHANGELOG.md +41 -1
  2. package/README.md +16 -6
  3. package/SECURITY.md +2 -1
  4. package/docs/README.md +1 -4
  5. package/docs/agent-hook.md +14 -2
  6. package/docs/configuration.md +32 -1
  7. package/docs/dashboard.md +3 -3
  8. package/docs/reports-and-ci.md +15 -0
  9. package/docs/rules.md +35 -29
  10. package/package.json +1 -1
  11. package/src/analyser.ts +163 -53
  12. package/src/baseline.ts +39 -3
  13. package/src/blocks.ts +116 -77
  14. package/src/changed-regions.ts +59 -11
  15. package/src/class-rules.ts +226 -76
  16. package/src/cli-program.ts +61 -14
  17. package/src/cli.ts +1 -0
  18. package/src/comment-rules.ts +58 -13
  19. package/src/comment-scanner.ts +27 -0
  20. package/src/complexity-metrics.ts +244 -0
  21. package/src/config.ts +56 -16
  22. package/src/constants.ts +1 -1
  23. package/src/context-doc-rules.ts +9 -10
  24. package/src/discovery.ts +39 -19
  25. package/src/doc-rules.ts +22 -53
  26. package/src/findings-helpers.ts +127 -1
  27. package/src/findings.ts +4 -0
  28. package/src/fixture-purpose-rules.ts +39 -5
  29. package/src/github-actions-rules.ts +24 -1
  30. package/src/hook-contract.ts +85 -14
  31. package/src/init-config.ts +15 -5
  32. package/src/line-rules.ts +54 -5
  33. package/src/naming-pushers.ts +26 -5
  34. package/src/parsed-script.ts +652 -0
  35. package/src/process-exec-metadata.ts +16 -6
  36. package/src/profiles.ts +14 -0
  37. package/src/project-config-rules.ts +15 -10
  38. package/src/public-exports.ts +220 -0
  39. package/src/report-renderers.ts +55 -4
  40. package/src/rules.ts +11 -11
  41. package/src/scoring.ts +13 -4
  42. package/src/security-flow-rules.ts +169 -24
  43. package/src/sensitive-data-rules.ts +132 -78
  44. package/src/source-text.ts +4 -46
  45. package/src/test-block-rules.ts +118 -14
  46. package/src/test-fixtures.ts +4 -1
  47. package/src/text-scans.ts +8 -1
  48. package/src/types.ts +5 -3
@@ -32,11 +32,23 @@ interface HookReport {
32
32
  contractVersion: "gruff.hook.v1";
33
33
  analyzer: { name: "gruff-ts"; version: string };
34
34
  findings: HookFinding[];
35
+ // File-scoped parse/read diagnostics relevant to the analysed change, reported in-band. The
36
+ // default hook exit stays 0; only an explicit --fail-on-diagnostics run turns these into exit 2.
37
+ diagnostics: HookDiagnostic[];
35
38
  suppressed: { count: number };
36
39
  ignored: { paths: SkippedPath[] };
37
40
  config: { schemaOk: boolean; error: string | null };
38
41
  }
39
42
 
43
+ // One diagnostic projected into the hook contract: what kind of problem, where, and the message a
44
+ // consumer can surface. `file`/`line` are absent for operational diagnostics with no anchor.
45
+ interface HookDiagnostic {
46
+ type: string;
47
+ message: string;
48
+ file?: string;
49
+ line?: number;
50
+ }
51
+
40
52
  // A finding projected into the hook contract, with enum scope and non-null remediation, keyed for
41
53
  // new-only tracking by the stable identity and fingerprint.
42
54
  interface HookFinding {
@@ -47,6 +59,9 @@ interface HookFinding {
47
59
  file: string;
48
60
  line?: number;
49
61
  endLine?: number;
62
+ // One-based match column, present when the scanner pinpointed the occurrence. Two secrets on one
63
+ // line share every other field, so this is the only thing that lets a consumer tell them apart.
64
+ column?: number;
50
65
  symbol: string | null;
51
66
  message: string;
52
67
  remediation: string;
@@ -86,8 +101,11 @@ export function renderHookCapabilities(): string {
86
101
  stableIdentity: true,
87
102
  ignoreReport: true,
88
103
  newOnly: true,
104
+ // Producer advertisement only: diagnostics are always reported in-band; the advertised
105
+ // failOnDiagnostics flag is the explicit consumer request that changes exit semantics.
106
+ diagnostics: true,
89
107
  },
90
- flags: { changedRanges: "--changed-ranges", diff: "--diff", baseline: "--baseline" },
108
+ flags: { changedRanges: "--changed-ranges", diff: "--diff", baseline: "--baseline", failOnDiagnostics: "--fail-on-diagnostics" },
91
109
  flagOrder: "any" satisfies FlagOrder,
92
110
  }, null, 2) + "\n";
93
111
  }
@@ -119,24 +137,45 @@ export function renderHookConfigError(message: string, remediation: string): str
119
137
  return JSON.stringify(hookReport(undefined, [], 0, false, error), null, 2) + "\n";
120
138
  }
121
139
 
122
- // Assembles the gruff.hook.v1 envelope (sorted findings, suppressed count, ignored paths, config)
123
- // as the stable gruff.hook.v1 output contract.
140
+ // Assembles the gruff.hook.v1 envelope (sorted findings, diagnostics, suppressed count, ignored
141
+ // paths, config) as the stable gruff.hook.v1 output contract.
124
142
  function hookReport(report: AnalysisReport | undefined, findings: HookFinding[], suppressedCount: number, isSchemaOk: boolean, error: string | null): HookReport {
125
143
  return {
126
144
  contractVersion: HOOK_CONTRACT_VERSION,
127
145
  analyzer: analyzerInfo(),
128
146
  findings: sortHookFindings(findings),
147
+ diagnostics: (report?.diagnostics ?? []).map(toHookDiagnostic),
129
148
  suppressed: { count: suppressedCount },
130
149
  ignored: { paths: report?.paths.skipped ?? [] },
131
150
  config: { schemaOk: isSchemaOk, error },
132
151
  };
133
152
  }
134
153
 
154
+ // Projects one run diagnostic into the hook contract's shape; never throws - absent anchors are omitted.
155
+ function toHookDiagnostic(diagnostic: { diagnosticType: string; message: string; filePath?: string; line?: number }): HookDiagnostic {
156
+ return {
157
+ type: diagnostic.diagnosticType,
158
+ message: diagnostic.message,
159
+ ...(diagnostic.filePath === undefined ? {} : { file: diagnostic.filePath }),
160
+ ...(diagnostic.line === undefined ? {} : { line: diagnostic.line }),
161
+ };
162
+ }
163
+
164
+ // Counts the diagnostics in a rendered gruff.hook.v1 envelope so the CLI can apply the explicit
165
+ // --fail-on-diagnostics exit policy without re-running analysis or duplicating envelope knowledge.
166
+ export function hookRenderedDiagnosticsCount(renderedEnvelope: string): number {
167
+ const payload = JSON.parse(renderedEnvelope) as { diagnostics?: unknown[] };
168
+ return Array.isArray(payload.diagnostics) ? payload.diagnostics.length : 0;
169
+ }
170
+
135
171
  // Analyzer identity block shared by the capability and report envelopes.
136
172
  function analyzerInfo(): { name: "gruff-ts"; version: string } {
137
173
  return { name: "gruff-ts", version: VERSION };
138
174
  }
139
175
 
176
+ // Builds the hook finding list: changed-region scoping drops inherited file findings, then
177
+ // new-only filtering re-admits file/project findings absent from the base identities.
178
+ // Invariant: suppressed.count arithmetic must stay exact across both filtering stages.
140
179
  function hookFindings(
141
180
  currentReport: AnalysisReport,
142
181
  scopedReport: AnalysisReport,
@@ -149,7 +188,9 @@ function hookFindings(
149
188
  const withNewFileAndProject = hasChangedRegion && baseIdentities
150
189
  ? [...scopedFindings, ...newFileAndProjectFindings(currentReport, scopedFindings, baseIdentities)]
151
190
  : scopedFindings;
152
- return baseIdentities ? withNewFileAndProject.filter((finding) => !baseIdentities.has(finding.stableIdentity)) : withNewFileAndProject;
191
+ return baseIdentities
192
+ ? withNewFileAndProject.filter((finding) => !baselineMatchIdentities(finding).some((identity) => baseIdentities.has(identity)))
193
+ : withNewFileAndProject;
153
194
  }
154
195
 
155
196
  // Collects file- and project-scope findings that are new since the base, excluding any already
@@ -187,6 +228,7 @@ function toHookFinding(finding: Finding): HookFinding {
187
228
  file: finding.filePath,
188
229
  ...(finding.line === undefined ? {} : { line: finding.line }),
189
230
  ...(finding.endLine === undefined ? {} : { endLine: finding.endLine }),
231
+ ...(finding.column === undefined ? {} : { column: finding.column }),
190
232
  symbol: finding.symbol ?? null,
191
233
  message: finding.message,
192
234
  remediation: finding.remediation ?? DESCRIPTORS.get(finding.ruleId)?.remediation ?? "Review and address this finding.",
@@ -253,15 +295,38 @@ function metricMetadata(measured: unknown, threshold: unknown, unit: string): Re
253
295
  // Hashes (ruleId, filePath, scope component) into the 16-hex hook identity; line-insensitive so it
254
296
  // stays the stable cross-edit key for new-only filtering.
255
297
  function hookStableIdentity(finding: Finding, scope: HookScope): string {
256
- const component = stableIdentityComponent(finding, scope);
298
+ return identityHash(finding.ruleId, finding.filePath, stableIdentityComponent(finding, scope));
299
+ }
300
+
301
+ // The one place the 16-hex identity is derived, so every caller hashes the same tuple.
302
+ function identityHash(ruleId: string, filePath: string, component: string): string {
257
303
  return createHash("sha256")
258
- .update([finding.ruleId, finding.filePath, component].join("\0"))
304
+ .update([ruleId, filePath, component].join("\0"))
259
305
  .digest("hex")
260
306
  .slice(0, 16);
261
307
  }
262
308
 
263
- // Derives the per-occurrence component of the stable hook identity: scope token, symbol, or message.
264
- function stableIdentityComponent(finding: { message: string; ruleId: string; symbol?: string }, scope: HookScope): string {
309
+ // Identities one emitted finding answers to when matched against a base set. gruff.baseline.v1
310
+ // stores no column, so a baseline recomputes the column-free key; a finding that now reports a
311
+ // column must still recognise it, or every previously accepted secret comes back on the next run.
312
+ // Same-line occurrences share that older key, which is the baseline limitation ADR-017 documents:
313
+ // accepting one accepts every secret on its line. The wire identity stays column-aware, so a
314
+ // consumer tracking findings by identity still sees the two occurrences as separate.
315
+ function baselineMatchIdentities(finding: HookFinding): string[] {
316
+ if (finding.column === undefined) {
317
+ return [finding.stableIdentity];
318
+ }
319
+ const columnFreeComponent = stableIdentityComponent({
320
+ message: finding.message,
321
+ ruleId: finding.ruleId,
322
+ ...(finding.symbol === null ? {} : { symbol: finding.symbol }),
323
+ }, finding.scope);
324
+ return [finding.stableIdentity, identityHash(finding.ruleId, finding.file, columnFreeComponent)];
325
+ }
326
+
327
+ // Derives the per-occurrence component of the stable hook identity: scope token, symbol, or message
328
+ // plus match column.
329
+ function stableIdentityComponent(finding: { message: string; ruleId: string; symbol?: string; column?: number }, scope: HookScope): string {
265
330
  if (scope === "file") {
266
331
  return scope;
267
332
  }
@@ -276,11 +341,14 @@ function stableIdentityComponent(finding: { message: string; ruleId: string; sym
276
341
  }
277
342
  // Symbol-less line findings (e.g. each hardcoded secret) key on the message so several same-rule
278
343
  // findings in one file get distinct identities. A value-insensitive `metric:${scope}` token
279
- // collapsed them all, letting one baselined finding suppress later new ones in the same file. The
280
- // message carries the per-occurrence discriminator (redacted preview) and no line number, so it
281
- // stays stable across surrounding edits. file scope above stays fully value-insensitive; project
282
- // scope folds in a canonical symbol when one is present.
283
- return `message:${finding.message}`;
344
+ // collapsed them all, letting one baselined finding suppress later new ones in the same file. file
345
+ // scope above stays fully value-insensitive; project scope folds in a canonical symbol when present.
346
+ const messageComponent = `message:${finding.message}`;
347
+ // The redacted preview alone stopped separating occurrences once short secrets became fully
348
+ // masked: two 20-character keys on one line produce the same preview, so the same message. The
349
+ // match column separates them and names no line, so an edit above the finding still keeps the
350
+ // identity stable. Scanners that report a whole line supply no column and keep the older key.
351
+ return finding.column === undefined ? messageComponent : `${messageComponent}\0column:${finding.column}`;
284
352
  }
285
353
 
286
354
  // Builds the base identity set (from a baseline file and/or a diff base) that new-only filtering
@@ -312,7 +380,8 @@ function stableIdentitiesFromBaseline(path: string): Set<string> {
312
380
  }
313
381
 
314
382
  // Resolves one baseline entry to hook identities: its stored identity, or a recomputed one from
315
- // ruleId, filePath, and scope.
383
+ // ruleId, filePath, and scope. The recomputed key carries no column because gruff.baseline.v1 stores
384
+ // none; `baselineMatchIdentities` is what lets a column-bearing finding still match it.
316
385
  function stableIdentityFromBaselineEntry(entry: BaselineEntry): string[] {
317
386
  if (typeof entry.stableIdentity === "string") {
318
387
  return [entry.stableIdentity];
@@ -346,6 +415,8 @@ function baselineScopeForRule(ruleId: string): HookScope {
346
415
  return "line";
347
416
  }
348
417
 
418
+ // Replays the diff base ref and returns its findings' stable hook identities for new-only filtering.
419
+ // Writes a temp tree, spawns git to materialize base files, and must clean both up afterward.
349
420
  function stableIdentitiesFromDiffBase(
350
421
  runAnalyse: HookAnalysisRunner,
351
422
  options: AnalysisOptions,
@@ -1,5 +1,6 @@
1
- // Renders the default .gruff-ts.yaml file from the rule descriptor registry so `gruff-ts init`
2
- // can drop a config into a fresh project that mirrors the analyser's effective defaults.
1
+ // Renders the default .gruff-ts.yaml file from the rule descriptor registry.
2
+ // `gruff-ts init` uses it to give a new project the analyser's effective defaults.
3
+ // Users reach this file through the generated config they review before their first scan.
3
4
  import { existsSync, writeFileSync } from "node:fs";
4
5
  import { join } from "node:path";
5
6
  import { createInterface } from "node:readline/promises";
@@ -24,7 +25,7 @@ const RULE_OPTION_DEFAULTS: Readonly<Record<string, Readonly<Record<string, numb
24
25
  // Universal-programming abbreviations that earn their place across nearly any codebase; project-specific
25
26
  // vocabulary (domain acronyms) should be appended in the user's config rather than added here.
26
27
  const DEFAULT_ACCEPTED_ABBREVIATIONS: readonly string[] = [
27
- "age", "app", "cb", "db", "fn", "fs", "id", "io", "key", "log", "max", "min", "now", "raw", "rx", "tx", "ui", "url",
28
+ "age", "app", "db", "fs", "id", "io", "key", "log", "max", "min", "now", "raw", "rx", "tx", "ui", "url",
28
29
  ];
29
30
 
30
31
  // Result of an init write attempt, including the no-clobber branch for existing config files.
@@ -192,12 +193,15 @@ function renderPathsSection(ignoredPaths: readonly string[]): string {
192
193
  ].join("\n");
193
194
  }
194
195
 
195
- // `acceptedAbbreviations` is emitted as a block sequence for reviewability; the seven naming
196
- // allowlists below it stay commented out so users see the override knobs without changing defaults.
196
+ // Shows users which short identifier terms avoid naming findings in a newly initialized project.
197
+ // The other naming allowlists stay commented so users can discover them without changing defaults.
197
198
  function renderAllowlistsSection(): string {
198
199
  return [
199
200
  "allowlists:",
201
+ " # Abbreviations listed here are accepted in identifiers without a naming finding.",
202
+ " # Replace this list with the short terms reviewers accept in this project.",
200
203
  " acceptedAbbreviations:",
204
+ // Each family term is visible so a user can review or replace the complete list in generated YAML.
201
205
  ...DEFAULT_ACCEPTED_ABBREVIATIONS.map((abbreviation) => ` - ${abbreviation}`),
202
206
  " secretPreviews: []",
203
207
  " # Names that trigger naming.generic-function. Each key replaces the built-in",
@@ -207,6 +211,12 @@ function renderAllowlistsSection(): string {
207
211
  " # Exact public/CLI/DTO boolean names accepted by naming.boolean-prefix.",
208
212
  " # Default: [all, apply, check, dev, enabled, force, fresh, harness, json, ok, verbose, yes]",
209
213
  " # acceptedBooleanNames: [all, apply, check, dev, enabled, force, fresh, harness, json, ok, verbose, yes]",
214
+ " # Exact fileBase:ClassName pairs accepted by naming.class-file-mismatch.",
215
+ " # Default: []",
216
+ " # acceptedClassFilePairs: [focusModeTranscript:TranscriptFocusController]",
217
+ " # Exact wire_name:internalName alias pairs accepted within one naming owner.",
218
+ " # Default: []",
219
+ " # acceptedCasingPairs: [note_id:noteId]",
210
220
  " # Accepted prefixes for boolean identifiers. Names without one of these",
211
221
  " # prefixes trigger naming.boolean-prefix.",
212
222
  " # Default: [is, has, can, should, does, did, was, will, may, in, scan, supports, requires, allow, check, enable, exclude, include, omit, skip, with, without]",
package/src/line-rules.ts CHANGED
@@ -9,7 +9,7 @@ import { type SourceFile } from "./discovery.ts";
9
9
  import { makeFinding } from "./findings.ts";
10
10
  import { escapeRegex, finding, isCommentedOutCode } from "./findings-helpers.ts";
11
11
  import { type NamingSurface, pushBooleanPrefixAt, pushIdentifierQualityAt, pushNegativeBooleanAt, pushShortVariableAt } from "./naming-pushers.ts";
12
- import { processExecMetadata } from "./process-exec-metadata.ts";
12
+ import { processExecMetadata, type ProcessExecArgumentSource, type ProcessExecMetadata } from "./process-exec-metadata.ts";
13
13
  import { analyseReliabilityLine, analyseSwallowedCatches, analyseTypeSafetyLine, analyseUselessCatches } from "./safety-rules.ts";
14
14
  import { analyseSecurityFlowLine } from "./security-flow-rules.ts";
15
15
  import { codeLineForMatching } from "./source-text.ts";
@@ -571,22 +571,71 @@ function analyseProcessExecCalls(file: SourceFile, rawSource: string, codeSource
571
571
  if (isSafeProcessExecCall(file, callName, rawSource, start, rawSegment, codeSegment)) {
572
572
  continue;
573
573
  }
574
+ const metadata = processExecMetadata(callName, rawSource, start, rawSegment, codeSegment);
575
+ const grade = processExecGrade(metadata);
574
576
  findings.push(
575
577
  makeFinding({
576
578
  ruleId: "security.process-exec",
577
- message: "Child-process execution is used; validate arguments are not user-controlled.",
579
+ message: grade.message,
578
580
  filePath: file.displayPath,
579
581
  line: byteLine(codeSource, start),
580
- severity: "warning",
582
+ severity: grade.severity,
581
583
  pillar: "security",
582
584
  confidence: "high",
583
- remediation: "Review the command source and shell mode; prefer fixed command vectors with shell disabled.",
584
- metadata: processExecMetadata(callName, rawSource, start, rawSegment, codeSegment),
585
+ remediation: grade.remediation,
586
+ metadata: {
587
+ callName: metadata.callName,
588
+ argumentSource: metadata.argumentSource,
589
+ shellEnabled: metadata.isShellEnabled,
590
+ },
585
591
  }),
586
592
  );
587
593
  }
588
594
  }
589
595
 
596
+ // Every command-source shape has one compile-time class, so adding a metadata variant cannot fall
597
+ // through to a quieter grade until its security posture is chosen explicitly.
598
+ const PROCESS_EXEC_SOURCE_CLASSES = {
599
+ literal: "fixed",
600
+ "process-exec-path": "fixed",
601
+ "local-const": "fixed",
602
+ "local-builder": "dynamic",
603
+ parameter: "dynamic",
604
+ member: "dynamic",
605
+ template: "dynamic",
606
+ unknown: "dynamic",
607
+ } as const satisfies Record<ProcessExecArgumentSource, "dynamic" | "fixed">;
608
+
609
+ /*
610
+ * Severity follows the evidence the metadata already carries: only a shell-enabled call with a
611
+ * dynamic command keeps the warning. A fixed vector with the shell disabled becomes advisory and
612
+ * its message says what would make it dangerous instead of implying it already is; everything in
613
+ * between stays advisory with the review prompt, so the security pillar is not permanently
614
+ * occupied by calls the reviewer cannot change.
615
+ */
616
+ function processExecGrade(metadata: ProcessExecMetadata): { severity: Severity; message: string; remediation: string } {
617
+ const sourceClass = PROCESS_EXEC_SOURCE_CLASSES[metadata.argumentSource];
618
+ if (metadata.isShellEnabled && sourceClass === "dynamic") {
619
+ return {
620
+ severity: "warning",
621
+ message: "Child-process execution is used; validate arguments are not user-controlled.",
622
+ remediation: "Review the command source and shell mode; prefer fixed command vectors with shell disabled.",
623
+ };
624
+ }
625
+ if (!metadata.isShellEnabled && sourceClass === "fixed") {
626
+ return {
627
+ severity: "advisory",
628
+ message: "Child-process execution uses a fixed command with shell disabled.",
629
+ remediation: "No action needed while the command stays fixed; revisit if the command or its arguments start deriving from user input or a shell gets enabled.",
630
+ };
631
+ }
632
+ return {
633
+ severity: "advisory",
634
+ message: "Child-process execution is used; validate arguments are not user-controlled.",
635
+ remediation: "Review the command source and shell mode; prefer fixed command vectors with shell disabled.",
636
+ };
637
+ }
638
+
590
639
  // Excludes ordinary member calls such as `pattern.exec(...)`; module receivers like `cp.exec(...)`
591
640
  // remain valid process-exec candidates.
592
641
  function isMemberProcessExecFalsePositive(codeSource: string, start: number, hasProcessReceiver: boolean): boolean {
@@ -12,6 +12,27 @@ import type { Config, Finding } from "./types.ts";
12
12
  */
13
13
  export type NamingSurface = "declaration" | "parameter" | "destructure" | "interface-field";
14
14
 
15
+ /**
16
+ * Selects the report guidance for a boolean's source surface. Contract fields point users to the
17
+ * complete replacement allowlist or a serialization map; local code receives a safe rename action.
18
+ * @param surface Naming origin shown in finding metadata; interface-field means a contract surface.
19
+ * @returns Remediation text and action metadata for the finding emitter.
20
+ */
21
+ export function booleanPrefixGuidance(surface: NamingSurface): { remediation: string; remediationAction: "APPLY" | "CONFIGURE"; configurationKey?: "allowlists.acceptedBooleanNames" } {
22
+ // Interface and named type-literal fields may be external keys that a rename would break.
23
+ if (surface === "interface-field") {
24
+ return {
25
+ remediation: "If this is an external contract key, include it in the complete replacement list at `allowlists.acceptedBooleanNames` or map it at the serialization boundary; otherwise rename the field with an intent-revealing prefix.",
26
+ remediationAction: "CONFIGURE",
27
+ configurationKey: "allowlists.acceptedBooleanNames",
28
+ };
29
+ }
30
+ return {
31
+ remediation: "Rename this boolean with an intent-revealing prefix such as is, has, can, should, or will.",
32
+ remediationAction: "APPLY",
33
+ };
34
+ }
35
+
15
36
  /*
16
37
  * Negative-framed booleans (disableX, noX, preventX, …) read as double negations at call sites.
17
38
  * `negativeBooleanAllowed` is the user-curated exemption list. Reports the stable
@@ -41,14 +62,14 @@ export function pushNegativeBooleanAt(file: SourceFile, line: number, name: stri
41
62
  }
42
63
 
43
64
  /*
44
- * Booleans should announce their boolean-ness with an `is`/`has`/`can`/… prefix. The accepted set
45
- * lives in `config.booleanPrefixes` so projects can tune it. Reports the stable
46
- * `naming.boolean-prefix` finding.
65
+ * Reports typed booleans without an accepted prefix or exact contract name. The finding keeps its
66
+ * stable identity while its surface selects safe local-rename or contract configuration guidance.
47
67
  */
48
68
  export function pushBooleanPrefixAt(file: SourceFile, line: number, name: string, config: Config, findings: Finding[], surface: NamingSurface): void {
49
69
  if (hasBooleanPrefix(name, config.booleanPrefixes) || isAcceptedBooleanStateName(name) || isAcceptedContractBooleanName(name, config, surface)) {
50
70
  return;
51
71
  }
72
+ const { remediation, ...remediationMetadata } = booleanPrefixGuidance(surface);
52
73
  findings.push(
53
74
  makeFinding({
54
75
  ruleId: "naming.boolean-prefix",
@@ -59,8 +80,8 @@ export function pushBooleanPrefixAt(file: SourceFile, line: number, name: string
59
80
  pillar: "naming",
60
81
  confidence: "medium",
61
82
  symbol: name,
62
- remediation: "Use a prefix such as is, has, can, should, or will.",
63
- metadata: { identifierName: name, surface },
83
+ remediation,
84
+ metadata: { identifierName: name, surface, ...remediationMetadata },
64
85
  }),
65
86
  );
66
87
  }