@telorun/analyzer 0.65.0 → 0.67.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 (142) hide show
  1. package/dist/analyzer.d.ts +1 -1
  2. package/dist/analyzer.d.ts.map +1 -1
  3. package/dist/analyzer.js +194 -65
  4. package/dist/builtins.d.ts.map +1 -1
  5. package/dist/builtins.js +67 -16
  6. package/dist/call-graph.d.ts.map +1 -1
  7. package/dist/call-graph.js +7 -1
  8. package/dist/cel-environment.d.ts +12 -0
  9. package/dist/cel-environment.d.ts.map +1 -1
  10. package/dist/cel-environment.js +35 -19
  11. package/dist/cel-scope.d.ts +8 -0
  12. package/dist/cel-scope.d.ts.map +1 -1
  13. package/dist/cel-scope.js +89 -11
  14. package/dist/definition-registry.d.ts +41 -0
  15. package/dist/definition-registry.d.ts.map +1 -1
  16. package/dist/definition-registry.js +76 -0
  17. package/dist/dependency-graph.d.ts.map +1 -1
  18. package/dist/dependency-graph.js +65 -0
  19. package/dist/eval-paths.d.ts +68 -0
  20. package/dist/eval-paths.d.ts.map +1 -1
  21. package/dist/eval-paths.js +138 -0
  22. package/dist/flatten-for-analyzer.d.ts +37 -1
  23. package/dist/flatten-for-analyzer.d.ts.map +1 -1
  24. package/dist/flatten-for-analyzer.js +104 -5
  25. package/dist/import-resolution-diagnostics.d.ts +1 -1
  26. package/dist/import-resolution-diagnostics.js +1 -1
  27. package/dist/index.d.ts +12 -8
  28. package/dist/index.d.ts.map +1 -1
  29. package/dist/index.js +8 -6
  30. package/dist/inline-imports.d.ts.map +1 -1
  31. package/dist/inline-imports.js +1 -0
  32. package/dist/manifest-visitor.d.ts +4 -0
  33. package/dist/manifest-visitor.d.ts.map +1 -1
  34. package/dist/manifest-visitor.js +36 -1
  35. package/dist/migrations/entries/index.d.ts.map +1 -1
  36. package/dist/migrations/entries/index.js +2 -0
  37. package/dist/migrations/entries/schema-prepare-bucket.json +27 -0
  38. package/dist/peer-binding.d.ts +232 -0
  39. package/dist/peer-binding.d.ts.map +1 -0
  40. package/dist/peer-binding.js +418 -0
  41. package/dist/precompile.d.ts.map +1 -1
  42. package/dist/precompile.js +8 -0
  43. package/dist/ref-slot.d.ts +13 -0
  44. package/dist/ref-slot.d.ts.map +1 -1
  45. package/dist/ref-slot.js +26 -0
  46. package/dist/reference-field-map.d.ts +28 -0
  47. package/dist/reference-field-map.d.ts.map +1 -1
  48. package/dist/reference-field-map.js +25 -0
  49. package/dist/referrer-rule.d.ts +17 -0
  50. package/dist/referrer-rule.d.ts.map +1 -1
  51. package/dist/referrer-rule.js +4 -1
  52. package/dist/release/index.d.ts +1 -1
  53. package/dist/release/index.js +1 -1
  54. package/dist/resolve-ref-sentinels.d.ts.map +1 -1
  55. package/dist/resolve-ref-sentinels.js +14 -1
  56. package/dist/resource-input.d.ts +75 -0
  57. package/dist/resource-input.d.ts.map +1 -0
  58. package/dist/resource-input.js +90 -0
  59. package/dist/resource-rule.d.ts +40 -27
  60. package/dist/resource-rule.d.ts.map +1 -1
  61. package/dist/resource-rule.js +61 -7
  62. package/dist/rule-condition.d.ts +11 -0
  63. package/dist/rule-condition.d.ts.map +1 -1
  64. package/dist/rule-condition.js +13 -0
  65. package/dist/schema-projection.d.ts +119 -4
  66. package/dist/schema-projection.d.ts.map +1 -1
  67. package/dist/schema-projection.js +213 -18
  68. package/dist/system-kinds.d.ts +7 -2
  69. package/dist/system-kinds.d.ts.map +1 -1
  70. package/dist/system-kinds.js +7 -2
  71. package/dist/telo-version.d.ts +1 -1
  72. package/dist/telo-version.js +1 -1
  73. package/dist/template-body.d.ts +50 -0
  74. package/dist/template-body.d.ts.map +1 -0
  75. package/dist/template-body.js +58 -0
  76. package/dist/validate-cel-context.d.ts +1 -17
  77. package/dist/validate-cel-context.d.ts.map +1 -1
  78. package/dist/validate-cel-context.js +73 -78
  79. package/dist/validate-identifier-names.d.ts.map +1 -1
  80. package/dist/validate-identifier-names.js +17 -2
  81. package/dist/validate-reference-forms.d.ts +10 -0
  82. package/dist/validate-reference-forms.d.ts.map +1 -1
  83. package/dist/validate-reference-forms.js +23 -0
  84. package/dist/validate-references.d.ts +17 -0
  85. package/dist/validate-references.d.ts.map +1 -1
  86. package/dist/validate-references.js +77 -18
  87. package/dist/validate-referrer-rules.d.ts +38 -4
  88. package/dist/validate-referrer-rules.d.ts.map +1 -1
  89. package/dist/validate-referrer-rules.js +139 -31
  90. package/dist/validate-resource-inputs.d.ts +35 -0
  91. package/dist/validate-resource-inputs.d.ts.map +1 -0
  92. package/dist/validate-resource-inputs.js +319 -0
  93. package/dist/validate-resource-rules.d.ts +11 -2
  94. package/dist/validate-resource-rules.d.ts.map +1 -1
  95. package/dist/validate-resource-rules.js +18 -12
  96. package/dist/validate-schema-projection.d.ts.map +1 -1
  97. package/dist/validate-schema-projection.js +33 -2
  98. package/dist/validate-template-dispatch.d.ts +27 -0
  99. package/dist/validate-template-dispatch.d.ts.map +1 -0
  100. package/dist/validate-template-dispatch.js +95 -0
  101. package/dist/with-synthetic-positions.d.ts +1 -1
  102. package/dist/with-synthetic-positions.js +1 -1
  103. package/package.json +3 -3
  104. package/src/analyzer.ts +236 -70
  105. package/src/builtins.ts +69 -16
  106. package/src/call-graph.ts +7 -1
  107. package/src/cel-environment.ts +48 -19
  108. package/src/cel-scope.ts +113 -19
  109. package/src/definition-registry.ts +78 -0
  110. package/src/dependency-graph.ts +66 -0
  111. package/src/eval-paths.ts +152 -0
  112. package/src/flatten-for-analyzer.ts +117 -4
  113. package/src/import-resolution-diagnostics.ts +1 -1
  114. package/src/index.ts +57 -4
  115. package/src/inline-imports.ts +1 -0
  116. package/src/manifest-visitor.ts +41 -1
  117. package/src/migrations/entries/index.ts +2 -0
  118. package/src/migrations/entries/schema-prepare-bucket.json +27 -0
  119. package/src/peer-binding.ts +641 -0
  120. package/src/precompile.ts +8 -0
  121. package/src/ref-slot.ts +36 -0
  122. package/src/reference-field-map.ts +42 -0
  123. package/src/referrer-rule.ts +20 -1
  124. package/src/release/index.ts +1 -1
  125. package/src/resolve-ref-sentinels.ts +12 -1
  126. package/src/resource-input.ts +132 -0
  127. package/src/resource-rule.ts +69 -7
  128. package/src/rule-condition.ts +15 -0
  129. package/src/schema-projection.ts +302 -20
  130. package/src/system-kinds.ts +7 -2
  131. package/src/telo-version.ts +1 -1
  132. package/src/template-body.ts +104 -0
  133. package/src/validate-cel-context.ts +73 -78
  134. package/src/validate-identifier-names.ts +18 -3
  135. package/src/validate-reference-forms.ts +22 -0
  136. package/src/validate-references.ts +85 -16
  137. package/src/validate-referrer-rules.ts +215 -28
  138. package/src/validate-resource-inputs.ts +367 -0
  139. package/src/validate-resource-rules.ts +26 -12
  140. package/src/validate-schema-projection.ts +50 -1
  141. package/src/validate-template-dispatch.ts +99 -0
  142. package/src/with-synthetic-positions.ts +1 -1
@@ -29,8 +29,22 @@ import {
29
29
  readReferrerRules,
30
30
  type ReferrerRule,
31
31
  } from "./referrer-rule.js";
32
- import { celSourceOf, findDynamicLeaf, readNodes } from "./resource-rule.js";
33
- import { RULE_BUDGET_MS, compileRuleCondition, conditionRefusals } from "./rule-condition.js";
32
+ import type { PeerBinder, PeerBindingFailure, PeersTarget } from "./peer-binding.js";
33
+ import {
34
+ celSourceOf,
35
+ findDynamicLeaf,
36
+ type DynamicLeaf,
37
+ isTaggedCondition,
38
+ pointerSegments,
39
+ pointerToPath,
40
+ readNodes,
41
+ } from "./resource-rule.js";
42
+ import {
43
+ RULE_BUDGET_MS,
44
+ UNTAGGED_CONDITION,
45
+ compileRuleCondition,
46
+ conditionRefusals,
47
+ } from "./rule-condition.js";
34
48
 
35
49
  export interface ReferrerRuleIssue {
36
50
  code: "REFERRER_RULE_INVALID";
@@ -51,14 +65,40 @@ export interface Referrer {
51
65
  /** One rule's verdict on one referrer. */
52
66
  export type ReferrerRuleFinding =
53
67
  | { kind: "violation"; rule: ReferrerRule; referrer: Referrer; message: string }
54
- | { kind: "skipped"; rule: ReferrerRule; referrer: Referrer; dynamicAt: string }
68
+ | { kind: "skipped"; rule: ReferrerRule; referrer: Referrer; dynamic: DynamicLeaf }
69
+ | { kind: "unbound"; rule: ReferrerRule; referrer: Referrer; failure: PeerBindingFailure }
55
70
  | { kind: "failed"; rule: ReferrerRule; referrer?: Referrer; reason: string }
56
71
  | { kind: "over-budget"; rule: ReferrerRule; referrer: Referrer; elapsedMs: number };
57
72
 
73
+ /** What a peer rule needs beyond the referrers themselves: the binder that
74
+ * resolves a referrer's collection into declarations. Absent for a host that
75
+ * cannot resolve one — a rule declaring `peers:` then reports as unbound rather
76
+ * than running with the binding missing, which would evaluate a condition
77
+ * against names that are simply not there.
78
+ *
79
+ * ONE binder per analysis, because it caches each referrer's resolved
80
+ * collection and both the evaluation and the exercised check ask for it. */
81
+ export interface ReferrerRuleContext {
82
+ readonly peerBinder?: PeerBinder;
83
+ }
84
+
58
85
  function isObject(value: unknown): value is Record<string, unknown> {
59
86
  return !!value && typeof value === "object" && !Array.isArray(value);
60
87
  }
61
88
 
89
+ /** What a `peers:` pointer names in the referrer kind it is filtered to. Defined
90
+ * with the binding vocabulary; re-exported here because this is the surface
91
+ * that consumes it. The caller resolves it — only it holds the definition
92
+ * registry, and only after every kind is registered, since a rule may name a
93
+ * kind declared later in the same file. */
94
+ export type { PeersTarget };
95
+
96
+ export interface ReferrerRuleDeclarationContext {
97
+ /** Resolves a rule's `peers:` against its `referrer:` kind. Omit to skip the
98
+ * check — the safe direction for a host with no registry. */
99
+ readonly peersTarget?: (referrerKind: string, pointer: string) => PeersTarget;
100
+ }
101
+
62
102
  /**
63
103
  * Report every way a kind's referrer-rule declarations are malformed. Runs on
64
104
  * the `Telo.Definition` / `Telo.Abstract` doc, so a defect lands on the line the
@@ -68,7 +108,10 @@ function isObject(value: unknown): value is Record<string, unknown> {
68
108
  * declaring module's scope by `resolveSchemaRefKinds`, the only pass holding
69
109
  * that scope, and a name resolving to nothing is reported from there.
70
110
  */
71
- export function validateReferrerRuleDeclarations(manifest: ResourceManifest): ReferrerRuleIssue[] {
111
+ export function validateReferrerRuleDeclarations(
112
+ manifest: ResourceManifest,
113
+ context: ReferrerRuleDeclarationContext = {},
114
+ ): ReferrerRuleIssue[] {
72
115
  const own = (manifest as unknown as Record<string, unknown>).schema;
73
116
  const raw = readRawReferrerRules(own);
74
117
  if (raw === undefined) return [];
@@ -137,6 +180,12 @@ export function validateReferrerRuleDeclarations(manifest: ResourceManifest): Re
137
180
  issue(`${at}.severity`, "'severity' must be 'error' or 'warning'.");
138
181
  }
139
182
 
183
+ if (condition !== undefined && condition.length > 0 && !isTaggedCondition(entry.condition)) {
184
+ issue(`${at}.condition`, UNTAGGED_CONDITION);
185
+ }
186
+
187
+ validatePeersDeclaration(entry, at, issue, context);
188
+
140
189
  if (condition) {
141
190
  for (const refusal of conditionRefusals(condition)) issue(`${at}.condition`, refusal);
142
191
  }
@@ -145,6 +194,59 @@ export function validateReferrerRuleDeclarations(manifest: ResourceManifest): Re
145
194
  return issues;
146
195
  }
147
196
 
197
+ /** The strict half of `peers:` — the binding that lets a rule reach a referrer's
198
+ * OTHER entries, which is also the one that fails invisibly: a pointer naming a
199
+ * collection nothing in resolves would leave the rule seeing no declaration at
200
+ * all, and a check that never sees its subject reads as passing. */
201
+ function validatePeersDeclaration(
202
+ entry: Record<string, unknown>,
203
+ at: string,
204
+ issue: (path: string, message: string) => void,
205
+ context: ReferrerRuleDeclarationContext,
206
+ ): void {
207
+ const { peers } = entry;
208
+ if (peers === undefined) return;
209
+ if (typeof peers !== "string") {
210
+ issue(
211
+ `${at}.peers`,
212
+ "'peers' is a JSON Pointer naming a collection OF THE REFERRER (e.g. /tables), whose " +
213
+ "other entries bind as 'peers' and whose own entry binds as 'entry'.",
214
+ );
215
+ return;
216
+ }
217
+ if (pointerSegments(peers) === undefined || peers === "" || peers === "/") {
218
+ issue(
219
+ `${at}.peers`,
220
+ `'peers' must be a JSON Pointer to a collection, e.g. /tables — '${peers}' is not one.`,
221
+ );
222
+ return;
223
+ }
224
+ if (typeof entry.referrer !== "string" || entry.referrer.length === 0) {
225
+ issue(
226
+ `${at}.peers`,
227
+ "'peers' names a collection of the REFERRER, so the rule must also declare 'referrer:' — " +
228
+ "without a kind there is nothing to check the pointer against, and a pointer that " +
229
+ "resolves to nothing disables the rule in silence.",
230
+ );
231
+ return;
232
+ }
233
+ const target = context.peersTarget?.(entry.referrer, peers);
234
+ if (target === "absent") {
235
+ issue(
236
+ `${at}.peers`,
237
+ `'${entry.referrer}' declares no collection at '${peers}'. A pointer that resolves to ` +
238
+ "nothing binds no peers, so the rule would never see a sibling declaration.",
239
+ );
240
+ } else if (target === "plain") {
241
+ issue(
242
+ `${at}.peers`,
243
+ `'${peers}' on '${entry.referrer}' holds plain data — nothing in it is a reference, so ` +
244
+ "no entry resolves to a declaration and the rule would run against values it cannot " +
245
+ "compare. Name a collection whose items are, or contain, a reference.",
246
+ );
247
+ }
248
+ }
249
+
148
250
  /**
149
251
  * Run a kind's referrer rules against every resource that references one of its
150
252
  * resources.
@@ -154,6 +256,11 @@ export function validateReferrerRuleDeclarations(manifest: ResourceManifest): Re
154
256
  * manifest identity, since a name alone is module-scoped — because the condition
155
257
  * reads the two manifests and nothing about the site, so a second site could only
156
258
  * produce the identical verdict at a different path.
259
+ *
260
+ * **A rule declaring `peers:` is the exception, and evaluates once per ENTRY.**
261
+ * That is a deliberate departure from judge-once rather than an inconsistency: a
262
+ * rule that binds `entry` is about the entry, so a resource listed twice has two
263
+ * entries to answer for, and the two sites can genuinely disagree.
157
264
  */
158
265
  export function evaluateReferrerRules(
159
266
  manifest: ResourceManifest,
@@ -163,6 +270,7 @@ export function evaluateReferrerRules(
163
270
  * Liskov-substitutable, so a child of the named kind matches. Supplied by the
164
271
  * caller, which holds the definition registry. */
165
272
  kindMatches: (filter: string, kind: string) => boolean,
273
+ context: ReferrerRuleContext = {},
166
274
  ): ReferrerRuleFinding[] {
167
275
  const rules = readReferrerRules(definitionSchema);
168
276
  if (rules.length === 0) return [];
@@ -171,7 +279,11 @@ export function evaluateReferrerRules(
171
279
  const findings: ReferrerRuleFinding[] = [];
172
280
 
173
281
  for (const rule of rules) {
174
- const compiled = compileRuleCondition(rule.condition, ["self", "referrer"]);
282
+ const perEntry = rule.peers !== undefined;
283
+ const compiled = compileRuleCondition(
284
+ rule.condition,
285
+ perEntry ? ["self", "referrer", "entry", "peers"] : ["self", "referrer"],
286
+ );
175
287
  if ("reason" in compiled) {
176
288
  findings.push({ kind: "failed", rule, reason: compiled.reason });
177
289
  continue;
@@ -186,29 +298,47 @@ export function evaluateReferrerRules(
186
298
  const started = Date.now();
187
299
  for (const referrer of referrers) {
188
300
  if (rule.referrer !== undefined && !kindMatches(rule.referrer, referrer.kind)) continue;
189
- if (seen.has(referrer.manifest)) continue;
190
- seen.add(referrer.manifest);
301
+ if (!perEntry) {
302
+ if (seen.has(referrer.manifest)) continue;
303
+ seen.add(referrer.manifest);
304
+ }
305
+
306
+ const scope: Record<string, unknown> = {
307
+ self,
308
+ referrer: referrer.manifest as unknown as Record<string, unknown>,
309
+ };
310
+ if (perEntry) {
311
+ const bound = context.peerBinder
312
+ ? context.peerBinder.bind(referrer.manifest, referrer.kind, rule.peers!, referrer.path)
313
+ : ({
314
+ ok: false,
315
+ failure: { reason: "unknown-shape", at: pointerToPath(rule.peers!) },
316
+ } as const);
317
+ if (!bound.ok) {
318
+ findings.push({ kind: "unbound", rule, referrer, failure: bound.failure });
319
+ continue;
320
+ }
321
+ scope.peers = bound.binding.peers;
322
+ scope.entry = bound.binding.entry;
323
+ }
191
324
 
192
325
  // Only the nodes this condition READS decide whether it can run — the
193
326
  // resource-rule reasoning, and it bites harder here: the referrer is a
194
327
  // whole manifest, so scanning all of it would disable the rule for any
195
328
  // server carrying one unrelated expression.
196
- let dynamicAt: string | undefined;
197
- for (const node of readNodes(chains, {
198
- self,
199
- referrer: referrer.manifest as unknown as Record<string, unknown>,
200
- })) {
201
- dynamicAt = findDynamicLeaf(node);
202
- if (dynamicAt !== undefined) break;
329
+ let dynamic: DynamicLeaf | undefined;
330
+ for (const node of readNodes(chains, scope)) {
331
+ dynamic = findDynamicLeaf(node);
332
+ if (dynamic !== undefined) break;
203
333
  }
204
- if (dynamicAt !== undefined) {
205
- findings.push({ kind: "skipped", rule, referrer, dynamicAt });
334
+ if (dynamic !== undefined) {
335
+ findings.push({ kind: "skipped", rule, referrer, dynamic });
206
336
  continue;
207
337
  }
208
338
 
209
339
  let held: unknown;
210
340
  try {
211
- held = parsed({ self, referrer: referrer.manifest });
341
+ held = parsed(scope);
212
342
  } catch (err) {
213
343
  findings.push({
214
344
  kind: "failed",
@@ -239,10 +369,23 @@ export function referrerRuleExercised(
239
369
  rule: ReferrerRule,
240
370
  referrers: readonly Referrer[],
241
371
  kindMatches: (filter: string, kind: string) => boolean,
372
+ context: ReferrerRuleContext = {},
242
373
  ): boolean {
243
- if (rule.referrer === undefined) return referrers.length > 0;
244
- const filter = rule.referrer;
245
- return referrers.some((referrer) => kindMatches(filter, referrer.kind));
374
+ const matching =
375
+ rule.referrer === undefined
376
+ ? referrers
377
+ : referrers.filter((referrer) => kindMatches(rule.referrer!, referrer.kind));
378
+ if (matching.length === 0) return false;
379
+ if (rule.peers === undefined) return true;
380
+ // A peer rule that ran against an EMPTY peer set proved nothing — and an empty
381
+ // set everywhere is exactly what a typo in `peers:` looks like from outside,
382
+ // which is silence that reads as passing. Asked through the binder, so it
383
+ // shares the resolution the evaluation already paid for.
384
+ const binder = context.peerBinder;
385
+ if (!binder) return false;
386
+ return matching.some((referrer) =>
387
+ binder.hasPeers(referrer.manifest, referrer.kind, rule.peers!, referrer.path),
388
+ );
246
389
  }
247
390
 
248
391
  /** Where a referrer-rule finding is reported, and how loudly. Plain data, so the
@@ -262,6 +405,29 @@ export interface ReferrerRuleDiagnostic {
262
405
  rule: string;
263
406
  }
264
407
 
408
+ /** Why a peer binding could not be produced, as the sentence a reader acts on. */
409
+ function peerBindingReason(failure: PeerBindingFailure): string {
410
+ switch (failure.reason) {
411
+ case "no-collection":
412
+ return `'${failure.at}' holds no collection to bind 'peers' from.`;
413
+ case "unresolved":
414
+ return (
415
+ `a reference at '${failure.at}' names a declaration this analysis does not hold, ` +
416
+ "so a peer would bind to nothing."
417
+ );
418
+ case "dynamic":
419
+ return (
420
+ `a value at '${failure.at}' holds ${failure.what ?? "a value"}, which is not known ` +
421
+ "until the resource is created, so the comparison would run against a placeholder."
422
+ );
423
+ case "unknown-shape":
424
+ return (
425
+ `which paths under '${failure.at}' hold references is not known here, so nothing ` +
426
+ "could be resolved into a declaration."
427
+ );
428
+ }
429
+ }
430
+
265
431
  const nameOf = (manifest: ResourceManifest): string =>
266
432
  (manifest.metadata?.name as string | undefined) ?? "<unnamed>";
267
433
 
@@ -305,8 +471,8 @@ export function reportReferrerRules(
305
471
  message:
306
472
  `${finding.referrer.kind}/${nameOf(finding.referrer.manifest)}: rule ` +
307
473
  `'${finding.rule.code}' from ${declaringKind} did not run at ` +
308
- `'${finding.referrer.path}' — the value holds a CEL expression at ` +
309
- `'${finding.dynamicAt}', which is not known until the resource is created. ` +
474
+ `'${finding.referrer.path}' — the value holds ${finding.dynamic.what} at ` +
475
+ `'${finding.dynamic.path}', which is not known until the resource is created. ` +
310
476
  "Reported rather than dropped: a check whose coverage varies invisibly reads as passing.",
311
477
  manifest: finding.referrer.manifest,
312
478
  path: finding.referrer.path,
@@ -314,6 +480,21 @@ export function reportReferrerRules(
314
480
  });
315
481
  continue;
316
482
  }
483
+ if (finding.kind === "unbound") {
484
+ out.push({
485
+ code: "REFERRER_RULE_SKIPPED",
486
+ severity: "information",
487
+ message:
488
+ `${finding.referrer.kind}/${nameOf(finding.referrer.manifest)}: rule ` +
489
+ `'${finding.rule.code}' from ${declaringKind} did not run at ` +
490
+ `'${finding.referrer.path}' — ${peerBindingReason(finding.failure)}` +
491
+ " Reported rather than dropped: a check whose coverage varies invisibly reads as passing.",
492
+ manifest: finding.referrer.manifest,
493
+ path: finding.referrer.path,
494
+ rule: finding.rule.code,
495
+ });
496
+ continue;
497
+ }
317
498
 
318
499
  const because =
319
500
  finding.kind === "failed"
@@ -360,12 +541,18 @@ export function reportUnexercisedReferrerRule(
360
541
  code: "REFERRER_RULE_UNEXERCISED",
361
542
  severity: "information",
362
543
  message:
363
- `Referrer rule '${rule.code}' never ran: nothing` +
364
- (rule.referrer === undefined ? "" : ` of kind '${rule.referrer}'`) +
365
- " references a resource of this kind, so nothing has proven the condition." +
366
- (rule.referrer === undefined
367
- ? ""
368
- : " A 'referrer' naming a kind no manifest uses disables the rule in silence."),
544
+ rule.peers !== undefined
545
+ ? `Referrer rule '${rule.code}' never ran with peers to compare: nothing` +
546
+ (rule.referrer === undefined ? "" : ` of kind '${rule.referrer}'`) +
547
+ ` references a resource of this kind while '${rule.peers}' held another ` +
548
+ "declaration, so nothing has proven the condition. An empty peer set " +
549
+ "everywhere is what a typo in 'peers:' looks like from outside."
550
+ : `Referrer rule '${rule.code}' never ran: nothing` +
551
+ (rule.referrer === undefined ? "" : ` of kind '${rule.referrer}'`) +
552
+ " references a resource of this kind, so nothing has proven the condition." +
553
+ (rule.referrer === undefined
554
+ ? ""
555
+ : " A 'referrer' naming a kind no manifest uses disables the rule in silence."),
369
556
  manifest: definition,
370
557
  path: `schema.${REFERRER_RULES_ANNOTATION}[${rule.index}]`,
371
558
  rule: rule.code,