@vantageos/mcp-doctor 0.17.0 → 0.19.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.
- package/CHANGELOG.md +32 -0
- package/README.md +327 -21
- package/dist/doctor.d.ts +344 -5
- package/dist/doctor.js +9444 -6571
- package/package.json +9 -1
package/dist/doctor.d.ts
CHANGED
|
@@ -81,7 +81,7 @@ declare class SubjectUnreadableError extends Error {
|
|
|
81
81
|
constructor(target: string, form: string);
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
type State = "present" | "absent" | "non-conforming" | "could-not-judge";
|
|
84
|
+
type State = "present" | "absent" | "non-conforming" | "could-not-judge" | "not-applicable";
|
|
85
85
|
/**
|
|
86
86
|
* One site on which a human verdict is due (C-23): the mechanical half of the rule ran in full and
|
|
87
87
|
* the remaining question is judgement, which an instrument may not answer.
|
|
@@ -383,10 +383,26 @@ interface Detector {
|
|
|
383
383
|
* (see `scripts/standard-coverage.ts`) — never from a hand-kept list.
|
|
384
384
|
*/
|
|
385
385
|
rule?: string;
|
|
386
|
+
/**
|
|
387
|
+
* Set INSTEAD of `rule` on a detector the standard itself declares as answering no numbered rule, with the reason
|
|
388
|
+
* and where the standard says so. A detector carries exactly one of `rule` / `noNumberedRule`
|
|
389
|
+
* (tests/detector-rule-declared.test.ts); never both, never neither.
|
|
390
|
+
*/
|
|
391
|
+
noNumberedRule?: string;
|
|
386
392
|
/** The standard commit this detector's `rule` was read against. Required
|
|
387
393
|
* alongside `rule`: a rule id with no pin is unverifiable against a moving
|
|
388
394
|
* doc. */
|
|
389
395
|
pin?: string;
|
|
396
|
+
/**
|
|
397
|
+
* How a rule DECLARES its applicability predicate: whether the rule applies to THIS target at
|
|
398
|
+
* all. Applicability is a property of the TARGET, decided ONCE up front by the engine BEFORE any
|
|
399
|
+
* run/runDynamic/runServed/runLive — the surface a detector would read never gates it, so a single
|
|
400
|
+
* static `isApplicable(tree)` governs every mode. When it returns false the engine pushes a
|
|
401
|
+
* synthetic `not-applicable` result and the detector's run is never called (the predicate failing
|
|
402
|
+
* IS the reason, so no reason is owed and no verdict is owed — not-applicable is decisive and does
|
|
403
|
+
* not affect conformance). Absent or returning true means the rule applies and runs as before.
|
|
404
|
+
*/
|
|
405
|
+
isApplicable?(tree: Tree): boolean;
|
|
390
406
|
/** Static verdict from the source tree. REQUIRED — static is never optional. */
|
|
391
407
|
run(tree: Tree): DetectorResult;
|
|
392
408
|
/**
|
|
@@ -474,6 +490,101 @@ interface LiveDetector {
|
|
|
474
490
|
*/
|
|
475
491
|
declare function isLiveDetector(d: Detector | LiveDetector): d is LiveDetector;
|
|
476
492
|
|
|
493
|
+
/**
|
|
494
|
+
* `--gate`: the publish gate a server's `prepublishOnly` calls.
|
|
495
|
+
*
|
|
496
|
+
* It decides ONLY from two inputs: the rows this run produced (exactly the rows the table prints) and
|
|
497
|
+
* the server's committed owed-verdicts file. It has no opinion of its own and changes no detector.
|
|
498
|
+
*
|
|
499
|
+
* - every `non-conforming` row refuses, always; nothing in the owed file can waive it (kind `violation`);
|
|
500
|
+
* - every `could-not-judge` row refuses unless its detector id is declared, with a reason, in the owed
|
|
501
|
+
* file (kind `undeclared`);
|
|
502
|
+
* - every declared id refuses when no row of that id is `could-not-judge` any more — the row became
|
|
503
|
+
* present, absent or non-conforming, or the run produced no row with that id (kind `stale`), so the
|
|
504
|
+
* file can never drift into a silent waiver list;
|
|
505
|
+
* - an owed file that cannot be read, or that breaks the format below, refuses naming what it could
|
|
506
|
+
* not read (kind `unreadable-owed`); it is NEVER read as an empty file.
|
|
507
|
+
*
|
|
508
|
+
* How the owed file relates to `owedVerdict` / `owedHumanVerdicts`: those are a DETECTOR's statement
|
|
509
|
+
* that a person's verdict is due on named sites (C-23), and `computeExitCode` lets such a row exit 0
|
|
510
|
+
* when its mechanical half is complete. The owed file is the MAINTAINER's committed declaration, one
|
|
511
|
+
* per could-not-judge row, of why that row is acceptable to publish with. The gate grants no exception
|
|
512
|
+
* for `mechanicalHalfComplete`: an owed-human row is a could-not-judge row and is declared like any
|
|
513
|
+
* other — the declaration is where the person records that the verdict was given.
|
|
514
|
+
*/
|
|
515
|
+
/** Default owed-verdicts file, at the root of the source tree; `--owed <file>` overrides it. */
|
|
516
|
+
declare const OWED_FILE_NAME = "mcp-doctor.owed.json";
|
|
517
|
+
type GateRefusalKind = "violation" | "undeclared" | "stale" | "unreadable-owed";
|
|
518
|
+
interface GateRefusal {
|
|
519
|
+
/** The detector id (the table's first column), or the owed file's path when the whole file is unreadable. */
|
|
520
|
+
id: string;
|
|
521
|
+
kind: GateRefusalKind;
|
|
522
|
+
/** What is wrong and what to fix. */
|
|
523
|
+
reason: string;
|
|
524
|
+
}
|
|
525
|
+
interface GateVerdict {
|
|
526
|
+
passed: boolean;
|
|
527
|
+
refusals: GateRefusal[];
|
|
528
|
+
/** The ids the owed file declares (empty when there is no file, or it could not be read). */
|
|
529
|
+
declared: string[];
|
|
530
|
+
/** The owed file read, or looked for (`null` only when the gate could not run at all). */
|
|
531
|
+
owedFile: string | null;
|
|
532
|
+
/** Whether that file exists (a missing DEFAULT file is no declaration, never an error). */
|
|
533
|
+
owedFileFound: boolean;
|
|
534
|
+
/** Set when the gate could not run (unreadable subject, detector failure): what stopped it. */
|
|
535
|
+
cannotRun?: string;
|
|
536
|
+
}
|
|
537
|
+
/** One declaration: a detector id and the reason the row may be published undecided. */
|
|
538
|
+
interface OwedEntry {
|
|
539
|
+
id: string;
|
|
540
|
+
reason: string;
|
|
541
|
+
}
|
|
542
|
+
type OwedRead = {
|
|
543
|
+
kind: "none";
|
|
544
|
+
path: string;
|
|
545
|
+
} | {
|
|
546
|
+
kind: "ok";
|
|
547
|
+
path: string;
|
|
548
|
+
entries: OwedEntry[];
|
|
549
|
+
} | {
|
|
550
|
+
kind: "unreadable";
|
|
551
|
+
path: string;
|
|
552
|
+
problems: {
|
|
553
|
+
id: string;
|
|
554
|
+
what: string;
|
|
555
|
+
}[];
|
|
556
|
+
};
|
|
557
|
+
/**
|
|
558
|
+
* Read and validate the owed-verdicts file.
|
|
559
|
+
*
|
|
560
|
+
* Format (strict; every deviation refuses, never ignored):
|
|
561
|
+
*
|
|
562
|
+
* { "owed": [ { "id": "C35 listing-kit", "reason": "..." }, ... ] }
|
|
563
|
+
*
|
|
564
|
+
* An array of entries rather than an id-keyed object, because `JSON.parse` keeps the last of two equal
|
|
565
|
+
* keys in silence: a duplicate id must be refused, and only an array lets the reader see it. One id per
|
|
566
|
+
* entry (never a list), a non-empty reason per entry, and no reason text shared by two entries — a
|
|
567
|
+
* reason copied across ids is a blanket waiver. Unknown keys refuse: a misspelt key would otherwise
|
|
568
|
+
* read as a declaration that says nothing.
|
|
569
|
+
*
|
|
570
|
+
* A missing DEFAULT file is `none`: a server with no could-not-judge row needs no file. A missing file
|
|
571
|
+
* named explicitly (`--owed`) is unreadable: the caller said where the declarations are and they are not there.
|
|
572
|
+
*/
|
|
573
|
+
declare function readOwedFile(path: string, opts: {
|
|
574
|
+
explicit: boolean;
|
|
575
|
+
}): OwedRead;
|
|
576
|
+
/** Judge one run's rows against the owed file. Pure: the rows and the file are its only inputs. */
|
|
577
|
+
declare function evaluateGate(results: DetectorResult[], owed: OwedRead): GateVerdict;
|
|
578
|
+
/**
|
|
579
|
+
* The gate's exit code, on the repository's convention (`computeExitCode`): 0 passed; 1 refused;
|
|
580
|
+
* 2 the gate could not run in full (an unreadable owed file, an unreadable subject). A violation takes
|
|
581
|
+
* precedence over "could not run", exactly as a violation takes precedence over an abstention in
|
|
582
|
+
* `computeExitCode`: the run already proves the server may not publish.
|
|
583
|
+
*/
|
|
584
|
+
declare function gateExitCode(v: GateVerdict): number;
|
|
585
|
+
/** The `gate:` block printed under the table. */
|
|
586
|
+
declare function renderGate(v: GateVerdict): string;
|
|
587
|
+
|
|
477
588
|
/** A remote streamable-HTTP MCP server judged the way a customer reaches it (`--url`). */
|
|
478
589
|
interface HttpEndpoint {
|
|
479
590
|
/** The MCP endpoint. https, or http on a loopback host only (a credential never travels in clear). */
|
|
@@ -513,6 +624,196 @@ declare function redactSecrets(text: string, secrets: string[]): string;
|
|
|
513
624
|
*/
|
|
514
625
|
declare function introspectEndpoint(ep: HttpEndpoint): RuntimeContext;
|
|
515
626
|
|
|
627
|
+
/**
|
|
628
|
+
* The events-ready probe: the DYNAMIC half the static S-29..S-33 detectors name as `owed:`
|
|
629
|
+
* (src/detectors/s29-events-declared.ts .. s33-signed-delivery.ts). It drives a running server the
|
|
630
|
+
* way an events host does — discover -> events/list -> events/subscribe -> callback verification ->
|
|
631
|
+
* signed delivery -> events/unsubscribe — against an HTTPS receiver it starts itself (a self-signed
|
|
632
|
+
* certificate generated in memory at run time, see selfSignedCert.ts), plus an SSRF canary listener.
|
|
633
|
+
*
|
|
634
|
+
* Contract read: mcp-server-standard.md @ STANDARD_PIN, S-29 (l.80) .. S-33 (l.84) and S-47 (l.121);
|
|
635
|
+
* protocol detail from the events analysis §2.2-2.6 (subscribe params `{name, arguments, delivery:
|
|
636
|
+
* {mode: "webhook", url, secret}, cursor, ttlMs}`, result `{id, refreshBefore, cursor, truncated}`,
|
|
637
|
+
* the `{"type": "verification", "challenge"}` envelope, -32602 / -32012 / -32015 with a categorical
|
|
638
|
+
* `data.reason`, the Standard Webhooks headers).
|
|
639
|
+
*
|
|
640
|
+
* Each check answers exactly one of present (pass), non-conforming (violation) or could-not-judge
|
|
641
|
+
* (named); `absent` only when the server neither declares nor serves events (S-30..S-34 n/a).
|
|
642
|
+
*
|
|
643
|
+
* DECLARED CHOICES (the places where the standard leaves the probe a decision, written here so the
|
|
644
|
+
* reader of a verdict can find them):
|
|
645
|
+
* - TRIGGER. The protocol has no method that causes an event. The caller names a tool that does
|
|
646
|
+
* (`trigger`, CLI `--events-trigger NAME --events-trigger-args JSON`); without it, the delivery
|
|
647
|
+
* checks (g, h) and the "no event to a failed receiver" half of (e) are could-not-judge, named.
|
|
648
|
+
* - PUBLIC CALLBACK. A real server must refuse a loopback callback (that is check i), so the
|
|
649
|
+
* receiver is reachable only through a caller-supplied public https URL that forwards to it
|
|
650
|
+
* (`callbackBase`, CLI `--events-callback-base URL`, with `--events-receiver-port` fixing the
|
|
651
|
+
* port the forwarder targets). Without it every check that needs the server to POST to the
|
|
652
|
+
* receiver (d, e, f, g, h, j, and the malformed-secret half of c) is could-not-judge, named.
|
|
653
|
+
* - ECHO FORM. The receiver echoes a challenge as `{"challenge": "<value>"}` with HTTP 200. A
|
|
654
|
+
* server that reads another echo form and refuses the conforming receiver makes (e) and the
|
|
655
|
+
* checks that need a live subscription could-not-judge, naming the refusal — never a violation.
|
|
656
|
+
* - OBSERVATION WINDOW. "Never redelivered" (h) and "a retry keeps eventId" (g) are judged within
|
|
657
|
+
* `observeMs` after the trigger (CLI `--events-observe-ms`, default 5000). A retry that does not
|
|
658
|
+
* arrive within the window leaves the retry half of (g) could-not-judge.
|
|
659
|
+
* - TRANSPORT REFUSAL. An unauthenticated request refused with HTTP 401/403 before the JSON-RPC
|
|
660
|
+
* layer says nothing about what events/subscribe answers: (b) is could-not-judge, named.
|
|
661
|
+
* - SSRF. The canary listens on the probe host's loopback. Over a remote URL the server's loopback
|
|
662
|
+
* is not the probe's, so a hit is observable only for a server on the same host; the decisive
|
|
663
|
+
* reading is the answer: -32602 (refused) passes, a result (accepted) or -32015 (the server tried
|
|
664
|
+
* to connect toward a loopback address) is red.
|
|
665
|
+
* - NOT PROBED (outside checks a..j): `data` against `payloadSchema` (S-33), another principal
|
|
666
|
+
* yielding another id and state surviving a restart (S-31), descriptors (S-30), access recheck
|
|
667
|
+
* (S-34). The probe holds one credential and no restart control; no verdict claims them.
|
|
668
|
+
*/
|
|
669
|
+
interface EventsReadyOptions {
|
|
670
|
+
endpoint: HttpEndpoint;
|
|
671
|
+
/** The tool whose call causes one event (there is no standard trigger method). */
|
|
672
|
+
trigger?: {
|
|
673
|
+
tool: string;
|
|
674
|
+
arguments: Record<string, unknown>;
|
|
675
|
+
};
|
|
676
|
+
/** The event subscribed to and its arguments; default: the first event events/list serves, `{}`. */
|
|
677
|
+
event?: {
|
|
678
|
+
name: string;
|
|
679
|
+
arguments: Record<string, unknown>;
|
|
680
|
+
};
|
|
681
|
+
/** A public https URL that forwards to the receiver (no trailing slash needed). */
|
|
682
|
+
callbackBase?: string;
|
|
683
|
+
/** The receiver's local port (0: any free port). */
|
|
684
|
+
receiverPort?: number;
|
|
685
|
+
/** How long deliveries are observed after the trigger, in ms (default 5000). */
|
|
686
|
+
observeMs?: number;
|
|
687
|
+
/** Per JSON-RPC request deadline, in ms (default 10000). */
|
|
688
|
+
requestTimeoutMs?: number;
|
|
689
|
+
}
|
|
690
|
+
declare function runEventsReady(opts: EventsReadyOptions): Promise<DetectorResult[]>;
|
|
691
|
+
|
|
692
|
+
/** Thrown when the vendored standard cannot be read: an input the INSTRUMENT needs, never a finding
|
|
693
|
+
* about the subject. A doctor should map it to its "could not run" exit (2), not to a violation. */
|
|
694
|
+
declare class StandardUnreadableError extends Error {
|
|
695
|
+
readonly path: string;
|
|
696
|
+
constructor(path: string, cause: unknown);
|
|
697
|
+
}
|
|
698
|
+
/** Thrown when the standard was read but the rule-id regex matched nothing: a wrong pattern or the
|
|
699
|
+
* wrong file, never "a standard with zero rules". */
|
|
700
|
+
declare class NoRuleIdsDerivedError extends Error {
|
|
701
|
+
readonly path: string;
|
|
702
|
+
readonly pattern: RegExp;
|
|
703
|
+
constructor(path: string, pattern: RegExp);
|
|
704
|
+
}
|
|
705
|
+
/** The trailing integer of a rule id (`R-12` -> 12, `S-3` -> 3). A id with none is a named error. */
|
|
706
|
+
declare function ruleNumber(id: string): number;
|
|
707
|
+
/** Distinct ids, sorted by their trailing number (numeric, so R-2 < R-10). */
|
|
708
|
+
declare function sortRuleIds(ids: Iterable<string>): string[];
|
|
709
|
+
/**
|
|
710
|
+
* Derive the rule list from a VENDORED standard text: every line is tested with `pattern`
|
|
711
|
+
* (capture group 1 = the id, else the whole match). Never typed, never a git call.
|
|
712
|
+
* Fails LOUD: unreadable file -> StandardUnreadableError; no match -> NoRuleIdsDerivedError.
|
|
713
|
+
*/
|
|
714
|
+
declare function deriveRuleIds(path: string, pattern: RegExp): string[];
|
|
715
|
+
|
|
716
|
+
/** A rank for EVERY member of the engine's State union. The key set is the State type itself, so a
|
|
717
|
+
* State added to the engine without a rank here is a compile error, never a silent hole. */
|
|
718
|
+
type StateRank = Record<State, number>;
|
|
719
|
+
/**
|
|
720
|
+
* The states, worst highest: every reduction (a rule's results, a merged rule) picks the worst.
|
|
721
|
+
* `not-applicable` is decisive-clean, the lowest: it never outranks non-conforming or
|
|
722
|
+
* could-not-judge, and a sibling `present` result wins over it (it says more).
|
|
723
|
+
*/
|
|
724
|
+
declare const STATE_RANK: {
|
|
725
|
+
"non-conforming": number;
|
|
726
|
+
"could-not-judge": number;
|
|
727
|
+
absent: number;
|
|
728
|
+
present: number;
|
|
729
|
+
"not-applicable": number;
|
|
730
|
+
};
|
|
731
|
+
/** Every State, derived from the rank's keys (which the type forces to be the whole union). */
|
|
732
|
+
declare const ALL_STATES: State[];
|
|
733
|
+
|
|
734
|
+
/** The rule id a result belongs to, from its leading id token, using the doctor's rule-id pattern
|
|
735
|
+
* (group 1 = the id, else the whole match). No tag is a named error. */
|
|
736
|
+
declare function ruleIdOf(result: DetectorResult, pattern: RegExp): string;
|
|
737
|
+
interface Tally {
|
|
738
|
+
/** rule-level state counts, one bin per State: they sum to `ruleTotal`. */
|
|
739
|
+
byState: Record<State, number>;
|
|
740
|
+
ruleTotal: number;
|
|
741
|
+
/** the number of raw DetectorResults reduced (>= ruleTotal). */
|
|
742
|
+
resultTotal: number;
|
|
743
|
+
/** reduced rule-level state, per rule id. */
|
|
744
|
+
ruleState: Map<string, State>;
|
|
745
|
+
}
|
|
746
|
+
/**
|
|
747
|
+
* Reduce DetectorResults to a rule-level tally: a rule's state is the WORST across its results
|
|
748
|
+
* (STATE_RANK). Two checks bite, each a named error naming the rules: every derived rule has a
|
|
749
|
+
* result, and no rule outside the derived list was tallied. (The state counts sum to the rule total
|
|
750
|
+
* by construction, since they are counted from the same map, so no assertion is spent on it.)
|
|
751
|
+
*/
|
|
752
|
+
declare function tallyRules(results: DetectorResult[], ruleIds: string[], pattern: RegExp): Tally;
|
|
753
|
+
/** The one-line machine tally string; every State is printed and the sum is shown against the total. */
|
|
754
|
+
declare function tallyLine(t: Tally): string;
|
|
755
|
+
|
|
756
|
+
interface CoverageReport {
|
|
757
|
+
ok: boolean;
|
|
758
|
+
ruleIds: string[];
|
|
759
|
+
checked: string[];
|
|
760
|
+
notCheckable: string[];
|
|
761
|
+
/** rules in NO bucket: the failure that names an incomplete doctor. */
|
|
762
|
+
uncovered: string[];
|
|
763
|
+
/** rules in MORE THAN ONE bucket: a rule cannot be two things at once. */
|
|
764
|
+
doubleCovered: string[];
|
|
765
|
+
/** bucket entries that are not a derived rule id: a stale bucket. */
|
|
766
|
+
unknown: string[];
|
|
767
|
+
}
|
|
768
|
+
/**
|
|
769
|
+
* Every derived rule must be in EXACTLY ONE of two buckets: CHECKED (a registry entry tags it) or
|
|
770
|
+
* NOT-CHECKABLE (listed with a written reason). All three inputs are required: the caller derives
|
|
771
|
+
* them (`deriveRuleIds`, `checkedRuleIds`, `Object.keys(bucket)`), nothing is defaulted here.
|
|
772
|
+
*/
|
|
773
|
+
declare function ruleCoverage(ruleIds: string[], checked: string[], notCheckable: string[]): CoverageReport;
|
|
774
|
+
/** A one-line assertion string naming any gap. */
|
|
775
|
+
declare function coverageSummary(r: CoverageReport): string;
|
|
776
|
+
|
|
777
|
+
/**
|
|
778
|
+
* One `could-not-judge` DetectorResult per NOT_MECHANICALLY_CHECKABLE entry, so every rule carries
|
|
779
|
+
* exactly one result (the tally invariant) without inventing a verdict a detector has not earned.
|
|
780
|
+
* `anchor` is the doctor's (its vendored standard, `file:0`). A blank reason is a named error: an
|
|
781
|
+
* abstention without a reason is a shrug.
|
|
782
|
+
*/
|
|
783
|
+
declare function notCheckableResults(bucket: Record<string, string>, anchor: string): DetectorResult[];
|
|
784
|
+
|
|
785
|
+
/** One registered detector: the rule it judges and the standard pin it was written against. */
|
|
786
|
+
interface RegistryEntry {
|
|
787
|
+
detector: Detector;
|
|
788
|
+
ruleId: string;
|
|
789
|
+
standardPin: string;
|
|
790
|
+
}
|
|
791
|
+
/** The rule ids a registry mechanically CHECKS: derived from its entries, distinct and sorted. */
|
|
792
|
+
declare function checkedRuleIds(entries: readonly RegistryEntry[]): string[];
|
|
793
|
+
|
|
794
|
+
interface ReportContext {
|
|
795
|
+
/** the doctor's name, for the first line (`<title> report`). */
|
|
796
|
+
title: string;
|
|
797
|
+
target: string;
|
|
798
|
+
/** gathered by the caller (CLI): the renderer never reads the clock. */
|
|
799
|
+
generatedAt: string;
|
|
800
|
+
/** doctor-specific header fields, printed in order as `key: value`. */
|
|
801
|
+
header?: ReadonlyArray<readonly [string, string]>;
|
|
802
|
+
results: DetectorResult[];
|
|
803
|
+
tally: Tally;
|
|
804
|
+
/** when given, its one-line summary is printed under the tally. */
|
|
805
|
+
coverage?: CoverageReport;
|
|
806
|
+
/** a precomputed coverage headline (e.g. clause-level), printed after the summary. */
|
|
807
|
+
coverageHeadline?: string;
|
|
808
|
+
/** pass-through to the engine's renderTable (what the run read / walked past). */
|
|
809
|
+
skipped?: SkippedDir[];
|
|
810
|
+
surface?: Coverage;
|
|
811
|
+
}
|
|
812
|
+
/** Pure renderer: tally line + the engine table + the derived exit code. No clock, no fs, no git. */
|
|
813
|
+
declare function renderReport(ctx: ReportContext): string;
|
|
814
|
+
/** Write the rendered report to `path`, creating its directory. */
|
|
815
|
+
declare function writeReport(path: string, ctx: ReportContext): void;
|
|
816
|
+
|
|
516
817
|
type RunMode = "static" | "dynamic" | "both";
|
|
517
818
|
interface RunDoctorOptions {
|
|
518
819
|
mode?: RunMode;
|
|
@@ -553,7 +854,35 @@ declare function runDoctor(target: string, detectorList?: Detector[], opts?: Run
|
|
|
553
854
|
declare function runDoctorReport(target: string, detectorList?: Detector[], opts?: RunDoctorOptions): {
|
|
554
855
|
results: DetectorResult[];
|
|
555
856
|
skipped: SkippedDir[];
|
|
857
|
+
coverage: Coverage;
|
|
556
858
|
};
|
|
859
|
+
/**
|
|
860
|
+
* What a run READ, stated beside what it concluded. Without it a verdict over 300 files and
|
|
861
|
+
* 108 tools reads the same as one over 2 files and none.
|
|
862
|
+
*
|
|
863
|
+
* `tree` mode: the source files the scan read (the same `tree.files` every detector reads) and
|
|
864
|
+
* the registered tools the shared tool reader read (`findRegisteredTools`, the reader D8 and the
|
|
865
|
+
* per-tool rules use). A tool count the reader could not establish is `unreadable` with the
|
|
866
|
+
* reason, never 0: an SDK-first or tool-serving tree where no registration was located has tools
|
|
867
|
+
* the reader did not see. `0` is printed only when the tree shows no tool surface at all.
|
|
868
|
+
* `endpoint` mode (`--url`): no source tree is read.
|
|
869
|
+
*/
|
|
870
|
+
type Coverage = {
|
|
871
|
+
mode: "endpoint";
|
|
872
|
+
} | {
|
|
873
|
+
mode: "tree";
|
|
874
|
+
sourceFiles: number;
|
|
875
|
+
unscannedSource: string[];
|
|
876
|
+
tools: {
|
|
877
|
+
read: number;
|
|
878
|
+
unresolvedSites: string[];
|
|
879
|
+
} | {
|
|
880
|
+
unreadable: string;
|
|
881
|
+
};
|
|
882
|
+
};
|
|
883
|
+
declare function readCoverage(tree: Tree): Coverage;
|
|
884
|
+
/** The coverage line printed under `surface:`. */
|
|
885
|
+
declare function renderCoverage(coverage: Coverage | undefined): string;
|
|
557
886
|
/**
|
|
558
887
|
* Async runner — the ADDITIVE extension for *dynamique* rules that must CALL a
|
|
559
888
|
* running server. It is a superset of the sync `runDoctor` static path, never a
|
|
@@ -582,7 +911,7 @@ declare function runDoctorAsync(target: string, opts?: {
|
|
|
582
911
|
* rendered: an empty list says "none", it is never omitted.
|
|
583
912
|
*/
|
|
584
913
|
declare function renderSkipped(skipped: SkippedDir[]): string;
|
|
585
|
-
declare function renderTable(surface: string, results: DetectorResult[], skipped?: SkippedDir[]): string;
|
|
914
|
+
declare function renderTable(surface: string, results: DetectorResult[], skipped?: SkippedDir[], coverage?: Coverage): string;
|
|
586
915
|
/** Total owed human-verdict sites across the results — counted from the structured field. */
|
|
587
916
|
declare function countOwedHumanVerdicts(results: DetectorResult[]): number;
|
|
588
917
|
/**
|
|
@@ -596,7 +925,15 @@ declare function renderOwedVerdicts(results: DetectorResult[]): string;
|
|
|
596
925
|
* the owed-human-verdict count, so a consumer reads "a verdict is owed" from a field and never from
|
|
597
926
|
* prose.
|
|
598
927
|
*/
|
|
599
|
-
declare function renderJson(surface: string, results: DetectorResult[], skipped: SkippedDir[]): string;
|
|
928
|
+
declare function renderJson(surface: string, results: DetectorResult[], skipped: SkippedDir[], coverage?: Coverage, gate?: GateVerdict): string;
|
|
929
|
+
declare function renderResults(surface: string, results: DetectorResult[], coverageLine: string): string;
|
|
930
|
+
/**
|
|
931
|
+
* The per-state tally: every State is its own bin, counted across the run. A consumer reads a clean
|
|
932
|
+
* count per state (so `not-applicable` is distinct from `could-not-judge` by construction, and
|
|
933
|
+
* `byState` agrees with the rows). Every known State key is always present, even at zero — a zero is
|
|
934
|
+
* a stated count, never a missing key a reader must infer.
|
|
935
|
+
*/
|
|
936
|
+
declare function countByState(results: DetectorResult[]): Record<State, number>;
|
|
600
937
|
/**
|
|
601
938
|
* The process exit code a run's results carry, three-way with precedence:
|
|
602
939
|
* 1 — a VIOLATION: at least one detector is `non-conforming` (something IS
|
|
@@ -604,10 +941,12 @@ declare function renderJson(surface: string, results: DetectorResult[], skipped:
|
|
|
604
941
|
* 2 — an ABSTENTION with zero violations: at least one `could-not-judge`
|
|
605
942
|
* ("I did not look" must NOT reach a caller as a clean 0).
|
|
606
943
|
* 0 — fully judged and conformant: nothing non-conforming, nothing abstained.
|
|
944
|
+
* A `not-applicable` result is DECISIVE and does not affect conformance —
|
|
945
|
+
* it falls through to 0 like present/absent.
|
|
607
946
|
* The rendered table already draws this distinction; this only lets a machine
|
|
608
947
|
* reading the exit code (CI, the foreign-bite probes) see what the table says.
|
|
609
948
|
*/
|
|
610
949
|
declare function computeExitCode(results: DetectorResult[]): number;
|
|
611
950
|
|
|
612
|
-
export { SubjectUnreadableError, computeExitCode, countOwedHumanVerdicts, endpointSecrets, introspectEndpoint, isLiveDetector, redactSecrets, renderJson, renderOwedVerdicts, renderSkipped, renderTable, runDoctor, runDoctorAsync, runDoctorReport };
|
|
613
|
-
export type { HttpEndpoint, LiveDetector, RunDoctorOptions, RunMode, Session };
|
|
951
|
+
export { ALL_STATES, NoRuleIdsDerivedError, OWED_FILE_NAME, STATE_RANK, StandardUnreadableError, SubjectUnreadableError, checkedRuleIds, computeExitCode, countByState, countOwedHumanVerdicts, coverageSummary, deriveRuleIds, endpointSecrets, evaluateGate, gateExitCode, introspectEndpoint, isLiveDetector, notCheckableResults, readCoverage, readOwedFile, redactSecrets, renderCoverage, renderGate, renderJson, renderOwedVerdicts, renderReport, renderResults, renderSkipped, renderTable, ruleCoverage, ruleIdOf, ruleNumber, runDoctor, runDoctorAsync, runDoctorReport, runEventsReady, sortRuleIds, tallyLine, tallyRules, writeReport };
|
|
952
|
+
export type { Coverage, CoverageReport, DetectorResult, EventsReadyOptions, GateVerdict, HttpEndpoint, LiveDetector, RegistryEntry, ReportContext, RunDoctorOptions, RunMode, Session, State, StateRank, Tally };
|