@stateward/core 1.2.1 → 1.2.2

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.
package/dist/engine.js CHANGED
@@ -1,7 +1,9 @@
1
1
  import path from "node:path";
2
2
  import { readRollout } from "./rollout.js";
3
3
  import { ruleKey, sha1, summaryOf, summaryText, summaryValue } from "./cache.js";
4
+ import { fileLedger, ledgerKey, ledgerTraits, provesOf, tagRulesOf, withRule } from "./ledger.js";
4
5
  import { defaultOptions } from "./options.js";
6
+ import { declarationId, fileStated } from "./stated.js";
5
7
  import { codeOf, loadRule } from "./lazy.js";
6
8
  import { IGNORE_EXPLAIN, IGNORE_RULE_ID, applyIgnores, fileDirectives } from "./ignores.js";
7
9
  import { addonsWith, appliedOverrides, ruleIsOn, ruleSetting, ruleSettingWith, } from "./severity.js";
@@ -255,8 +257,12 @@ function ruleSets(config, selection) {
255
257
  if (entry.rule.kind === "project")
256
258
  return [entry];
257
259
  const setting = ruleSettingWith(config, applied, entry.plugin, entry.name, entry.rule.meta);
258
- if (setting === "off")
259
- return [];
260
+ if (setting === "off") {
261
+ if (entry.rule.summarize === undefined)
262
+ return [];
263
+ const quiet = entryOf(config, entry.plugin, entry.name, entry.rule, entry.severity, []);
264
+ return [{ ...quiet, key: `${quiet.key}:quiet`, quiet: true }];
265
+ }
260
266
  const prefix = `${entry.plugin}/`;
261
267
  const addons = addonsWith(config, applied)
262
268
  .filter((one) => one.startsWith(prefix))
@@ -348,15 +354,19 @@ function lower(a, b) {
348
354
  }
349
355
  /** The problem as the config shows it: at its kind's severity, or undefined when that kind is off. */
350
356
  function problemFinding(entry, problem) {
357
+ const linked = problem.guarantees !== undefined && problem.guarantees.length > 0;
358
+ const against = problem.stated === true || problem.against === true || linked;
351
359
  const setting = kindSetting(entry, problem.findingKind);
352
- if (setting === "off")
360
+ // A kind set to off hides the finding, unless it is against a stated guarantee: no setting
361
+ // makes a guarantee read proven, so it stays, as an info.
362
+ if (setting === "off" && !against)
353
363
  return undefined;
354
364
  // The config's severity for this kind wins; then the rule's own choice for this finding; then
355
365
  // the rule's severity. A finding's own choice can only lower it, never raise it above the rule.
356
366
  return {
357
367
  kind: "problem",
358
368
  ruleId: entry.id,
359
- severity: setting ??
369
+ severity: (setting === "off" ? "info" : setting) ??
360
370
  (problem.stated === true
361
371
  ? "error"
362
372
  : problem.severity === undefined
@@ -369,12 +379,35 @@ function problemFinding(entry, problem) {
369
379
  fixes: problem.fixes,
370
380
  ...(problem.findingKind === undefined ? {} : { findingKind: problem.findingKind }),
371
381
  ...(problem.about === undefined ? {} : { about: problem.about }),
382
+ ...(against ? { against: true } : {}),
383
+ ...(linked ? { guarantees: problem.guarantees } : {}),
372
384
  };
373
385
  }
374
- function fileContext(entry, sourceFile, types, findings) {
386
+ /**
387
+ * The ids of the declarations a rule says a finding is against: a node is the declaration itself,
388
+ * a symbol is looked up. None when it says `true` (the finding is linked from where it lies, in
389
+ * the proof), says nothing, or names a symbol with no declaration.
390
+ */
391
+ function declarationsAgainst(against, types) {
392
+ if (against === undefined || against === true)
393
+ return [];
394
+ const node = "kind" in against ? against : types.declarationOf(against)?.node;
395
+ return node === undefined ? [] : [declarationId(nodeLocation(node))];
396
+ }
397
+ /** The ids of the declarations a project rule names by where they are listed (`ProjectContext`). */
398
+ function declarationsAt(against) {
399
+ if (against === undefined || against === true)
400
+ return [];
401
+ return [...new Set(against.map(declarationId))];
402
+ }
403
+ function fileContext(entry, sourceFile, types, findings, ledger = [], marks = []) {
375
404
  const { id, addons, options, facts, shippedFacts } = entry;
376
405
  return {
377
406
  file: sourceFile.fileName,
407
+ ledger,
408
+ read(ref, outcome) {
409
+ marks.push({ ref: ref.id, trait: ref.trait, outcome });
410
+ },
378
411
  sourceFile,
379
412
  types,
380
413
  addons,
@@ -394,12 +427,15 @@ function fileContext(entry, sourceFile, types, findings) {
394
427
  ...(problem.findingKind === undefined ? {} : { findingKind: problem.findingKind }),
395
428
  ...(problem.severity === undefined ? {} : { severity: problem.severity }),
396
429
  ...(problem.stated === true ? { stated: true } : {}),
430
+ ...(problem.against === true ? { against: true } : {}),
431
+ guarantees: declarationsAgainst(problem.against, types),
397
432
  ...(problem.about === undefined ? {} : { about: nodeLocation(problem.about) }),
398
433
  });
399
434
  if (finding !== undefined)
400
435
  findings.push(finding);
401
436
  },
402
- unknown({ message, hint, node }) {
437
+ unknown({ message, hint, node, against }) {
438
+ const guarantees = declarationsAgainst(against, types);
403
439
  findings.push({
404
440
  kind: "unknown",
405
441
  ruleId: id,
@@ -407,14 +443,18 @@ function fileContext(entry, sourceFile, types, findings) {
407
443
  hint,
408
444
  location: nodeLocation(node),
409
445
  ...listedFlag(entry),
446
+ ...(guarantees.length > 0 ? { guarantees } : {}),
410
447
  });
411
448
  },
412
449
  };
413
450
  }
414
- function projectContext(entry, findings) {
451
+ function projectContext(entry, findings, marks = []) {
415
452
  const { id, options } = entry;
416
453
  return {
417
454
  options,
455
+ read(ref, outcome) {
456
+ marks.push({ ref: ref.id, trait: ref.trait, outcome });
457
+ },
418
458
  report(problem) {
419
459
  const finding = problemFinding(entry, {
420
460
  message: problem.message,
@@ -424,12 +464,24 @@ function projectContext(entry, findings) {
424
464
  fixes: problem.fixes ?? [],
425
465
  ...(problem.findingKind === undefined ? {} : { findingKind: problem.findingKind }),
426
466
  ...(problem.severity === undefined ? {} : { severity: problem.severity }),
467
+ ...(problem.stated === true ? { stated: true } : {}),
468
+ ...(problem.against === true ? { against: true } : {}),
469
+ guarantees: declarationsAt(problem.against),
427
470
  });
428
471
  if (finding !== undefined)
429
472
  findings.push(finding);
430
473
  },
431
- unknown({ message, hint, location }) {
432
- findings.push({ kind: "unknown", ruleId: id, message, hint, location, ...listedFlag(entry) });
474
+ unknown({ message, hint, location, against }) {
475
+ const guarantees = declarationsAt(against);
476
+ findings.push({
477
+ kind: "unknown",
478
+ ruleId: id,
479
+ message,
480
+ hint,
481
+ location,
482
+ ...listedFlag(entry),
483
+ ...(guarantees.length > 0 ? { guarantees } : {}),
484
+ });
433
485
  },
434
486
  };
435
487
  }
@@ -450,26 +502,46 @@ function failureFinding(rule, location, error) {
450
502
  function summaryMap(sorted) {
451
503
  return new Map(sorted.map(([file, summary]) => [file, summaryValue(summary)]));
452
504
  }
505
+ /** A rule's marks in a fixed order (by reference, trait, then outcome), so the cache is stable. */
506
+ function sortedMarks(marks) {
507
+ return [...marks].sort((a, b) => compareText(a.ref, b.ref) ||
508
+ compareText(a.trait, b.trait) ||
509
+ compareText(JSON.stringify(a.outcome), JSON.stringify(b.outcome)));
510
+ }
511
+ /** The run's marks in a fixed order: by rule, then as `sortedMarks`. */
512
+ function sortedLedger(marks) {
513
+ return [...marks].sort((a, b) => compareText(a.ruleId, b.ruleId) ||
514
+ compareText(a.ref, b.ref) ||
515
+ compareText(a.trait, b.trait) ||
516
+ compareText(JSON.stringify(a.outcome), JSON.stringify(b.outcome)));
517
+ }
518
+ /** Whether a finding names the guarantees it is about (`Finding.guarantees`). */
519
+ function isLinked(finding) {
520
+ return finding.kind !== "failure" && (finding.guarantees?.length ?? 0) > 0;
521
+ }
453
522
  /**
454
523
  * A project rule's findings as the files they are in see the rule: dropped where an override turns
455
524
  * the rule off, and at the severity that file has. The cache keeps the findings as the rule made
456
525
  * them, so an override changes this step only.
457
526
  */
458
- function atTheirFiles(sets, entry, found) {
527
+ function atTheirFiles(sets, entry, found, silenced) {
459
528
  if (!sets.perFile)
460
529
  return found;
461
530
  return found.flatMap((finding) => {
462
531
  if (finding.kind === "failure")
463
532
  return [finding];
464
533
  const setting = sets.settingAt(entry.id, finding.location.file);
465
- if (setting === "off")
534
+ if (setting === "off") {
535
+ if (isLinked(finding))
536
+ silenced.push(finding);
466
537
  return [];
538
+ }
467
539
  if (finding.kind === "unknown")
468
540
  return [finding];
469
541
  // A severity the config gives this kind of finding holds in every file the rule is on in.
470
542
  const own = kindSetting(entry, finding.findingKind);
471
543
  if (own === "off")
472
- return [];
544
+ return finding.against === true ? [{ ...finding, severity: "info" }] : [];
473
545
  return [{ ...finding, severity: own ?? setting }];
474
546
  });
475
547
  }
@@ -488,17 +560,19 @@ function failureFile(config, cwd, units) {
488
560
  * summary equal to one in `same` (by hash) is that object: several rules of a pack summarize the
489
561
  * same facts of a file, and one copy of the text (and of its parsed value) serves them all.
490
562
  */
491
- function runOnFile(entry, sourceFile, types, same) {
563
+ function runOnFile(entry, sourceFile, types, same, ledger) {
492
564
  const findings = [];
493
- const ctx = fileContext(entry, sourceFile, types, findings);
565
+ const marks = [];
566
+ const ctx = fileContext(entry, sourceFile, types, findings, ledger, marks);
494
567
  try {
495
568
  const value = runFileSide(entry.rule, ctx);
569
+ const marked = marks.length === 0 ? {} : { marks: sortedMarks(marks) };
496
570
  if (value === undefined)
497
- return { result: { findings }, failed: false };
571
+ return { result: { findings, ...marked }, failed: false };
498
572
  const made = summaryOf(value);
499
573
  const summary = same.get(made.hash) ?? made;
500
574
  same.set(summary.hash, summary);
501
- return { result: { findings, summary }, failed: false };
575
+ return { result: { findings, summary, ...marked }, failed: false };
502
576
  }
503
577
  catch (error) {
504
578
  const startOfFile = { file: sourceFile.fileName, start: 0, end: 0 };
@@ -553,6 +627,13 @@ nextFiles, cache, ignores, timing) {
553
627
  : undefined;
554
628
  const testsByPattern = new Map();
555
629
  const findings = [];
630
+ /** The linked findings of a rule the config turned off where they lie: not shown, still not proven. */
631
+ const silenced = [];
632
+ const stated = [];
633
+ const proves = provesOf(rules.map((entry) => entry.rule.meta.proves));
634
+ const ledgerAt = ledgerKey(proves);
635
+ const ledgerRefs = [];
636
+ const ledgerMarks = [];
556
637
  const summaries = new Map();
557
638
  const directives = new Map();
558
639
  let fileCount = 0;
@@ -620,6 +701,30 @@ nextFiles, cache, ignores, timing) {
620
701
  }
621
702
  // One file's queries for all its rules (`ProjectUnit.typesFor`), made when one runs.
622
703
  let fileTypes;
704
+ // The declarations that state a guarantee, for the guarantees no plugin lists.
705
+ const scanned = fileStated(results, () => {
706
+ const sourceFile = timing === undefined
707
+ ? boundSourceFile(unit, file)
708
+ : timed(timing, "program", () => boundSourceFile(unit, file));
709
+ if (sourceFile === undefined)
710
+ return undefined;
711
+ fileTypes ??= unit.typesFor(file);
712
+ return { types: fileTypes, sourceFile };
713
+ });
714
+ if (scanned.stored && cache !== undefined)
715
+ cache.changed = true;
716
+ stated.push(...scanned.stated);
717
+ const readLedger = () => fileLedger(results, ledgerAt, () => {
718
+ const sourceFile = boundSourceFile(unit, file);
719
+ if (sourceFile === undefined)
720
+ return undefined;
721
+ fileTypes ??= unit.typesFor(file);
722
+ return { types: fileTypes, sourceFile };
723
+ }, proves);
724
+ const ledger = timing === undefined ? readLedger() : timed(timing, "ledger", readLedger);
725
+ if (ledger.stored && cache !== undefined)
726
+ cache.changed = true;
727
+ ledgerRefs.push(...ledger.refs);
623
728
  for (const entry of sets.forFile(file)) {
624
729
  let result = reusable?.get(entry.key);
625
730
  if (result === undefined) {
@@ -631,8 +736,8 @@ nextFiles, cache, ignores, timing) {
631
736
  fileTypes ??= unit.typesFor(file);
632
737
  const types = fileTypes;
633
738
  const ran = timing === undefined
634
- ? runOnFile(entry, sourceFile, types, sameSummaries)
635
- : timing.fileSide(entry.id, entry.rule.kind, () => runOnFile(entry, sourceFile, timing.timedTypes(types), sameSummaries));
739
+ ? runOnFile(entry, sourceFile, types, sameSummaries, ledger.refs)
740
+ : timing.fileSide(entry.id, entry.rule.kind, () => runOnFile(entry, sourceFile, timing.timedTypes(types), sameSummaries, ledger.refs));
636
741
  result = ran.result;
637
742
  if (cache !== undefined)
638
743
  cache.changed = true;
@@ -647,7 +752,13 @@ nextFiles, cache, ignores, timing) {
647
752
  else {
648
753
  timing?.reused(entry.id, entry.rule.kind);
649
754
  }
650
- findings.push(...result.findings);
755
+ if (entry.quiet === true)
756
+ silenced.push(...result.findings.filter(isLinked));
757
+ else
758
+ findings.push(...result.findings);
759
+ // A rule off for this file still reads its references: the proof says "off" there.
760
+ if (result.marks !== undefined)
761
+ ledgerMarks.push(...withRule(entry.id, result.marks));
651
762
  if (result.summary !== undefined)
652
763
  summaries.get(entry.id)?.set(file, result.summary);
653
764
  }
@@ -685,8 +796,19 @@ nextFiles, cache, ignores, timing) {
685
796
  : undefined,
686
797
  notes: notesOf(units, rules),
687
798
  looseNulls: looseNullFiles(units),
799
+ silenced,
800
+ stated,
801
+ ledger: {
802
+ traits: ledgerTraits(proves),
803
+ refs: ledgerRefs,
804
+ marks: ledgerMarks,
805
+ ...withTagRules(tagRulesOf(rules.map((entry) => ({ id: entry.id, proves: entry.rule.meta.proves })))),
806
+ },
688
807
  };
689
808
  }
809
+ function withTagRules(tagRules) {
810
+ return tagRules === undefined ? {} : { tagRules };
811
+ }
690
812
  /** The rules' project sides: each project rule's check over the summaries, and the result. */
691
813
  export function runProjectPhase(config, phase, started, keepSummaries, cache, capped = true, timing) {
692
814
  return drain(projectPhaseSteps(config, phase, started, keepSummaries, cache, capped, timing));
@@ -697,6 +819,8 @@ export function runProjectPhase(config, phase, started, keepSummaries, cache, ca
697
819
  */
698
820
  export function* projectPhaseSteps(config, phase, started, keepSummaries, cache, capped = true, timing) {
699
821
  const { sets, findings, summaries, directives, fileCount, testsByPattern, tsconfigLocation } = phase;
822
+ const silenced = [...phase.silenced];
823
+ const marks = [...phase.ledger.marks];
700
824
  const rules = sets.anywhere;
701
825
  const total = rules.filter((entry) => entry.rule.kind === "project" && summaries.has(entry.id)).length;
702
826
  let done = 0;
@@ -725,23 +849,32 @@ export function* projectPhaseSteps(config, phase, started, keepSummaries, cache,
725
849
  const inputs = sha1(sorted.map(([file, summary]) => `${file}\u0000${summary.hash}`).join("\n"));
726
850
  const before = cache?.projects.get(entry.key);
727
851
  if (before?.inputs === inputs) {
728
- findings.push(...atTheirFiles(sets, entry, before.findings));
852
+ findings.push(...atTheirFiles(sets, entry, before.findings, silenced));
853
+ marks.push(...withRule(entry.id, before.marks ?? []));
729
854
  // Built only if a hover asks: a CLI run whose summaries are unchanged never parses them.
730
855
  keepSummaries?.set(entry.id, () => (before.summaries ??= summaryMap(sorted)));
731
856
  continue;
732
857
  }
733
858
  const own = [];
859
+ const read = [];
734
860
  const rule = entry.rule;
735
861
  const runCheck = () => {
736
862
  const asJson = summaryMap(sorted);
737
863
  keepSummaries?.set(entry.id, () => asJson);
738
- rule.check(asJson, projectContext(entry, own));
864
+ rule.check(asJson, projectContext(entry, own, read));
739
865
  return asJson;
740
866
  };
741
867
  try {
742
868
  const asJson = timing === undefined ? runCheck() : timing.projectSide(entry.id, runCheck);
869
+ const settledMarks = sortedMarks(read);
870
+ marks.push(...withRule(entry.id, settledMarks));
743
871
  if (cache !== undefined) {
744
- cache.projects.set(entry.key, { inputs, findings: own, summaries: asJson });
872
+ cache.projects.set(entry.key, {
873
+ inputs,
874
+ findings: own,
875
+ ...(settledMarks.length === 0 ? {} : { marks: settledMarks }),
876
+ summaries: asJson,
877
+ });
745
878
  cache.changed = true;
746
879
  }
747
880
  }
@@ -749,7 +882,7 @@ export function* projectPhaseSteps(config, phase, started, keepSummaries, cache,
749
882
  own.push(failureFinding(entry, tsconfigLocation, error));
750
883
  cache?.projects.delete(entry.key);
751
884
  }
752
- findings.push(...atTheirFiles(sets, entry, own));
885
+ findings.push(...atTheirFiles(sets, entry, own, silenced));
753
886
  }
754
887
  const covered = applyIgnores(withLooseNullFixes(oneCauseOneMessage(findings, rules), rules, phase.looseNulls), directives, ignoreScope(config, rules));
755
888
  covered.findings.sort(compareFindings);
@@ -760,6 +893,13 @@ export function* projectPhaseSteps(config, phase, started, keepSummaries, cache,
760
893
  findings: shown,
761
894
  hidden,
762
895
  ignored: covered.ignored,
896
+ ...(silenced.length === 0 ? {} : { silenced }),
897
+ ledger: {
898
+ traits: phase.ledger.traits,
899
+ refs: phase.ledger.refs,
900
+ marks: sortedLedger(marks),
901
+ ...withTagRules(phase.ledger.tagRules),
902
+ },
763
903
  ...(phase.notes === undefined ? {} : { notes: phase.notes }),
764
904
  stats: {
765
905
  files: fileCount,
@@ -844,6 +984,12 @@ function limitPerRuleAndFile(sorted) {
844
984
  .map((finding, index) => ({ finding, index }))
845
985
  .sort((a, b) => capRank(a.finding) - capRank(b.finding) || a.index - b.index);
846
986
  for (const { finding } of byRank) {
987
+ // A finding that names a guarantee it is against is never hidden: it is what keeps the
988
+ // guarantee from reading proven, and the list must show why.
989
+ if (isLinked(finding)) {
990
+ kept.add(finding);
991
+ continue;
992
+ }
847
993
  const key = JSON.stringify([finding.location.file, finding.ruleId]);
848
994
  const entry = seen.get(key) ?? {
849
995
  file: finding.location.file,
@@ -882,7 +1028,7 @@ function secondPass(units, sets, timing) {
882
1028
  const types = timing.timedTypes(unit.typesFor(file));
883
1029
  for (const entry of sets.forFile(file)) {
884
1030
  timing.warmSide(entry.id, entry.rule.kind, () => {
885
- runOnFile(entry, sourceFile, types, same);
1031
+ runOnFile(entry, sourceFile, types, same, []);
886
1032
  });
887
1033
  }
888
1034
  }
@@ -957,6 +1103,15 @@ function runFileSide(rule, ctx) {
957
1103
  }
958
1104
  }
959
1105
  /** Ids of the rules that `selection` runs somewhere (not off everywhere; the rollout applied for `configured`). */
1106
+ /**
1107
+ * Whether the config turns a rule off for a file (the rule off, or an `overrides` entry that
1108
+ * does): `stateward guarantees` reads it for the places a guarantee covers, where the rule never
1109
+ * looked. Built once; every rule counts, whatever the rollout.
1110
+ */
1111
+ export function ruleOffAtFn(config) {
1112
+ const sets = ruleSets(config, { kind: "all" });
1113
+ return (ruleId, file) => sets.settingAt(ruleId, file) === "off";
1114
+ }
960
1115
  export function activeRuleIds(config, selection) {
961
1116
  return new Set(ruleSets(config, selection).anywhere.map((entry) => entry.id));
962
1117
  }
@@ -1039,7 +1194,7 @@ export function runFileRules(config, cwd, units, files, started, capped = true,
1039
1194
  const startOfFile = { file, start: 0, end: 0 };
1040
1195
  let types;
1041
1196
  for (const entry of sets.forFile(file)) {
1042
- if (entry.rule.kind !== "file")
1197
+ if (entry.rule.kind !== "file" || entry.quiet === true)
1043
1198
  continue;
1044
1199
  const result = results.get(entry.key);
1045
1200
  if (result !== undefined) {
package/dist/fixes.js CHANGED
@@ -171,13 +171,15 @@ export function reviewFixes(findings, units, cache) {
171
171
  unchecked.push(outcome.form);
172
172
  }
173
173
  const rejected = mine.flatMap((trial) => trial.rejected);
174
- const [first] = rejected;
175
- const noFix = offered.length === 0 && unchecked.length === 0 && first !== undefined;
174
+ // The last form of the first fix is the one that goes furthest (it also writes what the
175
+ // earlier forms expect to find), so its error is the one that is left to fix.
176
+ const last = mine.find((trial) => trial.rejected.length > 0)?.rejected.at(-1);
177
+ const noFix = offered.length === 0 && unchecked.length === 0 && last !== undefined;
176
178
  return {
177
179
  finding: {
178
180
  ...finding,
179
181
  fixes: offered,
180
- hint: noFix ? `${finding.hint}\nno automatic fix: ${first.reason}` : finding.hint,
182
+ hint: noFix ? `${finding.hint}\nno automatic fix: ${last.reason}` : finding.hint,
181
183
  },
182
184
  unchecked,
183
185
  rejected,
@@ -1,41 +1,93 @@
1
- import type { CoveredNoun, Finding, StatedGuarantee } from "./types.js";
1
+ import type { CoveredNoun, Finding, IgnoredFinding, Ledger, Location, StatedGuarantee, UncheckedPlace } from "./types.js";
2
2
  type Problem = Extract<Finding, {
3
3
  kind: "problem";
4
4
  }>;
5
5
  /**
6
6
  * Where a stated guarantee stands after a check:
7
- * - `proven`: its rule ran and reported nothing about it;
8
- * - `unproven`: its rule reported these errors about it (each names the declaration);
9
- * - `unused`: nothing uses it, so there is nothing to prove (a dead marker);
10
- * - `off`: its rule is not on (the rollout has not reached it), so nothing proves it.
7
+ * - `proven`: its rule ran everywhere the guarantee reaches and no finding stands against it,
8
+ * whatever the ignore comments and settings say;
9
+ * - `unproven`: its rule reported these errors about it (each names the declaration), or an
10
+ * ignore comment hides these findings (`ignored`, each with the comment's reason): hidden from
11
+ * `check`, still not proven;
12
+ * - `unchecked`: a place uses the value in a way the rule cannot follow (`places`);
13
+ * - `unused`: no code refers to it (with a ledger, no reference to its declaration, or only
14
+ * imports, exports and types, `importsOnly`; without one, no place it covers), so there is
15
+ * nothing to prove (a dead marker);
16
+ * - `off`: its rule is not on (the rollout has not reached it), or is off for these places the
17
+ * guarantee covers (`places`, empty when off everywhere), so nothing proves it.
11
18
  */
12
19
  export type GuaranteeStatus = {
13
20
  readonly kind: "proven";
14
21
  } | {
15
22
  readonly kind: "unproven";
16
23
  readonly errors: readonly Problem[];
24
+ readonly ignored: readonly IgnoredProblem[];
25
+ } | {
26
+ readonly kind: "unchecked";
27
+ readonly places: readonly UncheckedPlace[];
17
28
  } | {
18
29
  readonly kind: "unused";
30
+ /** Only imports, exports and types refer to it: nothing that runs uses it. */
31
+ readonly importsOnly?: true;
19
32
  } | {
20
33
  readonly kind: "off";
34
+ readonly places: readonly Location[];
35
+ };
36
+ /** A finding an ignore comment hides, and the reason the comment gives ("" when it gives none). */
37
+ export type IgnoredProblem = {
38
+ readonly finding: Problem;
39
+ readonly reason: string;
21
40
  };
22
41
  export type GuaranteeProof = {
23
42
  readonly stated: StatedGuarantee;
24
43
  readonly status: GuaranteeStatus;
25
44
  };
45
+ /** What a proof reads besides the check's findings. */
46
+ export type ProofInputs = {
47
+ /**
48
+ * The findings ignore comments hide (`CheckResult.ignored`): they still stand against the
49
+ * guarantee. Empty when the check applied no ignores.
50
+ */
51
+ readonly ignored?: readonly IgnoredFinding[];
52
+ /**
53
+ * Whether the config turns a rule off for a file (an `overrides` entry, or the rule off): the
54
+ * rule never looked at the places the guarantee covers there. Absent: nowhere.
55
+ */
56
+ readonly ruleOffAt?: (ruleId: string, file: string) => boolean;
57
+ /**
58
+ * The findings of a rule the config turned off for the file they lie in, which the check left
59
+ * out (`CheckResult.silenced`): a guarantee one is linked to reads "not checked" there, never
60
+ * proven. Absent: none.
61
+ */
62
+ readonly silenced?: readonly Finding[];
63
+ /**
64
+ * The check's reference ledger (`CheckResult.ledger`): for a guarantee stated by a marker of a
65
+ * trait it lists, every reference its rule did not mark, marked not checked or only handed on is
66
+ * a place not checked, and the guarantee is unused only when it has no reference. Absent (a
67
+ * caller with no ledger): unused when the guarantee covers no place.
68
+ */
69
+ readonly ledger?: Ledger;
70
+ };
26
71
  /**
27
72
  * Each stated guarantee with its status, in file and offset order. `findings` are a check's
28
- * (after ignore comments, before a baseline: an accepted error still leaves it unproven);
29
- * `active` the rules that check ran. A finding is about a guarantee when it is a problem of the
30
- * guarantee's rule, not an info, that names its declaration in a note or lies in a place it
31
- * covers (`isAbout`).
73
+ * (after ignore comments, before a baseline: an accepted error still leaves it unproven), and
74
+ * `inputs.ignored` the ones ignore comments hid: a guarantee is proven only when no finding
75
+ * stands against it before ignores and settings. `active` the rules that check
76
+ * ran. A finding is about a guarantee when it names its declaration (`Finding.guarantees`), or,
77
+ * for a finding no rule linked, lies where the guarantee is stated or covered (`aboutByPlace`); it
78
+ * counts at any severity once linked, and unless it is a weaker signal the rule judged an info.
79
+ * An `unknown` finding that names a guarantee leaves it "not checked" at its place, whatever the
80
+ * config's `unknowns` setting shows of it. With the check's reference ledger (`inputs.ledger`), so
81
+ * does every reference to a marked declaration its rule did not read (unmarked, marked unchecked,
82
+ * or only handed on), and it is unused only when it has no reference.
32
83
  */
33
- export declare function proveGuarantees(stated: readonly StatedGuarantee[], findings: readonly Finding[], active: ReadonlySet<string>): GuaranteeProof[];
84
+ export declare function proveGuarantees(stated: readonly StatedGuarantee[], findings: readonly Finding[], active: ReadonlySet<string>, inputs?: ProofInputs): GuaranteeProof[];
34
85
  /** "1 switch", "2 switches": the count and the noun in its form for it, as the noun gives both. */
35
86
  export declare function counted(count: number, noun: CoveredNoun): string;
36
87
  /**
37
88
  * The status in a few words, the same in `stateward guarantees` and the editor: "proven for 3
38
- * readers", "not proven: 2 errors", "unused: nothing reads it", "not checked: … is not on".
89
+ * readers", "not proven: 2 errors", "not proven: 1 ignored — lives as long as the app", "unused:
90
+ * nothing reads it", "not checked: … is not on".
39
91
  */
40
92
  export declare function describeStatus(proof: GuaranteeProof): string;
41
93
  /** The guarantee whose declaration covers `offset` of `file` (a TypeScript path), if any. */