@vantageos/mcp-doctor 0.18.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 CHANGED
@@ -4,6 +4,18 @@ All notable changes to `@vantageos/mcp-doctor` are documented here.
4
4
  This project adheres to [Semantic Versioning](https://semver.org/).
5
5
  Unreleased changes live as one fragment per pull request in `changelog.d/`, folded in here at release time.
6
6
 
7
+ ## 0.19.0 — 2026-11-07
8
+
9
+ ### Added
10
+ - **`not-applicable`: a rule DECLARES its scope, and the engine decides it before running the detector.** A detector may carry an `isApplicable(tree): boolean` predicate; applicability is a property of the TARGET, decided once up front (so one static predicate governs the static, dynamic and served modes). When it returns false the engine pushes a synthetic `not-applicable` row and the detector's `run` is never called — the predicate failing IS the reason, so the row carries no `reason` and no `owedVerdict`. `not-applicable` is DECISIVE: it is not a fifth UNDECIDED state, it is not a could-not-judge (it stays out of that section), the gate treats it as clean (no violation, no undeclared, no stale), and it falls through to exit 0. `--json` gains a `byState` tally with every state as its own bin (every key present, zero stated not inferred). An `owedVerdict` on a `not-applicable` result is refused, as on any non-could-not-judge state. Proof: tests/not-applicable-state.test.ts (gate-before-run with a throwing run, no reason owed, exit 0, owedVerdict refused, out of the could-not-judge section, byState bin, gate clean) and tests/v080-owed-verdict.test.ts (the State union now ends in not-applicable; the owed field stays a field, no undecided state reopened). (README: #states-and-exit-codes)
11
+ - **A public doctor kit: the generic halves of what two downstream doctors each copied.** `deriveRuleIds` (rule ids from a vendored standard by a regex, a named error when the file is unreadable or nothing matches), `ruleCoverage`, `notCheckableResults`, `tallyRules` (one `STATE_RANK` typed over the whole `State` union, `not-applicable` included), `RegistryEntry` / `checkedRuleIds`, and `renderReport` / `writeReport`; a doctor now passes only its own constants. (README: #doctor-kit)
12
+
13
+ ### Changed
14
+ - **"Did not look" is never `absent`: eight sites now say what they measured.** Nothing measured is could-not-judge (exit 2), naming what was not measured: C21 on a static run of an MCP server (the connection load is measured live), D3 and D4 on an MCP server where nothing in the tree shapes a response, C26 when every deployment site is skipped as not npm-managed (C-26 is not npm-only). Four sites now read their rule's scope condition and quote it in the row: DServer14 and S5 (S-5, multi-tenant / multi-client: absent for a non-server or a stdio-only server, judged over HTTP with a tenancy statement, could-not-judge over HTTP with none or with no transport wired), A7 (A-7, an App or a tree that calls tools: absent when neither, an ungated App or call exposed as a site), S48 (S-48, force-installed for a member: absent for a non-server, could-not-judge for a server that signs no member in, because no tree states it). The server notion is one predicate shared by these reads (S-14's surface, SDK-first registration, tool surface, stdio transport). A static run of an MCP server therefore exits 2 until C21 (and S48 where no member signs in) is declared in the owed file for `--gate`. A11, C14, D16, C20, DAppI18n and C27 stay `absent` and are listed open in the README, pending the standard owner's decision on each rule's text. (README: #states-and-exit-codes)
15
+
16
+ ### Fixed
17
+ - **Ten detector sites no longer report "required and missing" as `absent`.** Where a rule applies and its required item is missing, the row is now non-conforming (exit 1) or, where the static read cannot decide, could-not-judge (exit 2), so the violation reaches the exit code and the publish gate: D9 and DExt8 (C-3, no `CHANGELOG.md`), DExt5 (C-1, an FR piece missing beside a manifest, as D10 already read it), D8 (C-5, tools registered and no `evals/evals.json`), D3 and D4 (S-2 / S-3, a hand-rolled builder writing neither field; could-not-judge on `@modelcontextprotocol/server` >= 2, whose served response is the one the rule reads), D6 (A-6, an App serving a `ui://` resource with no GA key), D12 (S-1, an MCP server with no transport signal is could-not-judge; D12 also reads a stdio `transport` declared in `mcp.json` / `mcp-server.json`, the surface the S-1 detector row names), DExt1 (E-1, a `defineExtension` call with no `identifier`, each call judged on its own), and D7 (its "hand-rolled builders" verdict is now decided by the hand-rolled builder reader, never asserted). Each site keeps `absent` where its rule does not govern the tree, proven per site on a plain-library fixture (exit 0). Fourteen `absent` sites still await a ruling and are named in the README. (README: #states-and-exit-codes)
18
+
7
19
  ## 0.18.0 — 2026-11-02
8
20
 
9
21
  ### Added
package/README.md CHANGED
@@ -32,11 +32,11 @@ coverage: 3 source files read (.ts/.tsx, excluding .d.ts and .test.ts); 12 regis
32
32
  item | file:line | state | verdict
33
33
  -----------------------------------------------------------------------------
34
34
  D2 stateless | - | present | stateless (no mcp-session-id session-keying)
35
- D3 resultType | server.ts:589 | absent | list/read builder returns {content} without resultType -> add via protocol-kit
36
- D4 CacheableResult | server.ts:579,595 | absent | list/read builders lack ttlMs/cacheScope -> add CacheableResult
35
+ D3 resultType | server.ts:589 | non-conforming | list/read builder returns {content} without resultType -> add via protocol-kit
36
+ D4 CacheableResult | server.ts:579,595 | non-conforming | list/read builders lack ttlMs/cacheScope -> add CacheableResult
37
37
  D5 server/discover | - | absent | no server/discover handler -> add via protocol-kit
38
- D6 mcp-apps ui-key | - | absent | no MCP Apps UI key (no _meta ui)
39
- D7 protocol-kit | package.json | absent | hand-rolled builders, protocol-kit not a dependency
38
+ D6 mcp-apps ui-key | - | absent | no MCP Apps UI key and no ui:// resource: the tree is not an App — A-6 n/a
39
+ D7 protocol-kit | package.json | absent | no hand-rolled result builder ... and protocol-kit not a dependency: nothing for the kit to replace — D7 n/a
40
40
  ```
41
41
 
42
42
  The path is the root of the MCP server sources (the folder holding `server.ts` / `transport/` /
@@ -106,11 +106,13 @@ exit: 0 clean, 1 a violation, 2 an abstention with no violation (including a tar
106
106
  | `present` | the standard item is satisfied | none |
107
107
  | `absent` | the detector found nothing to judge — see the caveat below | none |
108
108
  | `non-conforming` | the item is present and wrong (this includes a manifest that parses but holds a wrong value) | **exit 1** |
109
- | `could-not-judge` | the detector could not read its input and says so in the row — malformed JSON, a computed or non-literal value, no `package.json` above the root; the run completes and the row names the file | **exit 2**, unless something else is non-conforming |
109
+ | `could-not-judge` | the detector could not read its input and says so in the row — malformed JSON, a computed or non-literal value, no `package.json` above the root, a value only a live session measures, a rule's scope condition the tree does not state; the run completes and the row names what was not read | **exit 2**, unless something else is non-conforming |
110
+ | `not-applicable` | the rule DECLARES itself out of scope for this target (its `isApplicable(tree)` returned false): the engine decides applicability up front, pushes a synthetic row, and the detector's `run` is never called. It is DECISIVE — it carries no reason and no `owedVerdict` (the predicate failing is the reason), and it is NOT a could-not-judge | none |
110
111
 
111
112
  The exit code keeps three outcomes distinct, which is what makes the tool safe in CI:
112
113
 
113
- - **0** — clean.
114
+ - **0** — clean. A `not-applicable` row (0.19.0) falls through here: the rule declared itself out of
115
+ scope for this target, so it is decisive and never raises an exit code.
114
116
  - **1** — at least one violation.
115
117
  - **2** — no violation, but at least one detector abstained. **An abstention is never a pass**: it
116
118
  means part of the tree was not judged, and the row names which part and why.
@@ -135,12 +137,51 @@ A directory holding even one file is a subject and is judged, so a missing READM
135
137
  still a violation (exit 1). Inside a judged tree, a subdirectory that cannot be listed is named under
136
138
  `skipped directories`; it is never dropped in silence.
137
139
 
138
- **One known limit in 0.3.2, stated rather than hidden:**
139
-
140
- - **`absent` currently means two things.** It is used both for "this rule does not apply here" and,
141
- for some detectors, "this is required and missing". The second should move the exit code and
142
- today does not. Until that is split, read an `absent` row against the rule it names rather than
143
- treating it as harmless.
140
+ **`absent` means "this rule does not apply here" — one known limit, stated rather than hidden:**
141
+
142
+ - **Ten sites that read "required and missing" as `absent` now report it.** A rule that applies and
143
+ whose required item is missing moves the exit code: D9 and DExt8 (C-3, no `CHANGELOG.md`), DExt5
144
+ (C-1, an FR piece missing beside a manifest), D8 (C-5, tools registered and no `evals/evals.json`),
145
+ D3 and D4 (S-2 / S-3, a builder writes neither field; could-not-judge where `@modelcontextprotocol/server`
146
+ >= 2 shapes the served response), D6 (A-6, an App — a `ui://` resource is served — with no GA key),
147
+ D12 (S-1, an MCP server with no transport signal: could-not-judge), DExt1 (E-1, a `defineExtension`
148
+ call with no `identifier`), and D7 (a constructor written by hand with no kit). Each keeps `absent`
149
+ only where its rule does not govern the tree.
150
+ - **"Did not look" is never `absent`.** Eight sites that answered `absent` without reading what their
151
+ rule needs now say what they did:
152
+ - **Nothing measured — `could-not-judge`, naming what was not measured.** C21 on a static run of an
153
+ MCP server (the connection load is measured on a live session: `--mode=dynamic|both`); D3 and D4 on
154
+ an MCP server where nothing in the tree shapes a response (no builder, no SDK-first registration,
155
+ no tool surface); C26 when every deployment site is skipped as not npm-managed (the rule is not
156
+ limited to npm, so the lockfile of each was not measured). A tree that is not an MCP server at all
157
+ stays `absent` on C21, D3 and D4, and C26 stays `absent` with no deployment configuration.
158
+ - **The rule's scope condition is read — `absent` only where it is false, quoted in the row.**
159
+ DServer14 and S5 (S-5: « obligatoire pour tout serveur multi-tenant / multi-client »): `absent` for a
160
+ tree that is not an MCP server or a server served over stdio only; judged when the server is served
161
+ over HTTP and partitioned by organisation (a `tenancy: per-organisation` upstream, or an
162
+ organisation claim such as `verifiedOrg` / `orgId` / `tenantId` in code); `could-not-judge` when it
163
+ is served over HTTP and states no tenancy, or wires no transport the tree shows. A7 (A-7: « L'App/hôte
164
+ ... gate tout appel d'outil »): `absent` when the tree is neither an App (a `ui://` resource) nor
165
+ calls a tool; with no confirmation anywhere, an App or a tool call is exposed as a site for a verdict
166
+ (`could-not-judge`), as is a JSON-RPC request whose method is an expression. S48 (S-48: « A server
167
+ force-installed for a member »): `absent` for a tree that is not an MCP server; a server that signs
168
+ no member in is `could-not-judge`, because whether it is force-installed is an administrator's
169
+ choice on the host that no source tree states.
170
+ - **Consequence:** a static run of any MCP server now leaves C21 open, and S48 too when the server
171
+ signs no member in, so it exits 2. The publish gate passes such a server once those rows are
172
+ declared in its owed file (see [Publish gate](#publish-gate---gate)).
173
+ - **Six `absent` sites stay open, pending the standard owner's decision on each rule's text.** They do
174
+ not move the exit code, and none is claimed closed:
175
+ - A11 (A-11) — whether a stdio-only App is "servie à Claude", while the rule's own row names
176
+ could-not-judge when the served URL is unknown;
177
+ - C14 (C-14) — whether a package with no `mcpCatalog` block is out of the rule, which applies "à chaque
178
+ publication stable" and names no n/a outcome;
179
+ - D16 (S-7) — whether a server with neither a `server/discover` handler nor a `/health` route is
180
+ exempt or red ("version ... absente");
181
+ - C20 and DAppI18n (C-20) — whether a missing `i18n/` folder is out of the rule, while C-1 requires two
182
+ languages and the red set does not name a missing folder;
183
+ - C27 (C-27) — whether a deployable sub-package with no `tsconfig*.json` is exempt from the type-check
184
+ in isolation.
144
185
 
145
186
  By design, a detector whose own internal self-check fails stops the run — that is the instrument
146
187
  reporting that it is broken, and silencing it would hide the fault behind a normal-looking table.
@@ -224,6 +265,35 @@ material...), recorded by the walks as they skip them. `renderTable` prints it a
224
265
  through; called with two arguments, `renderTable` prints a "NOT REPORTED" line in its place.
225
266
  `runDoctor(target)` still returns the results alone.
226
267
 
268
+ ## Doctor kit
269
+
270
+ A doctor built on this engine (a second instrument that judges another standard) used to copy the same
271
+ five modules. They are now public and parameterised: the doctor keeps its own constants (the vendored
272
+ standard's path and pin, the rule-id regex, its detectors, its not-checkable entries, its severity map)
273
+ and imports the rest.
274
+
275
+ | Export | What it does |
276
+ | --- | --- |
277
+ | `deriveRuleIds(path, pattern)` | Rule ids from a vendored standard text (capture group 1, else the whole match), sorted numerically. An unreadable file throws `StandardUnreadableError`; a pattern matching nothing throws `NoRuleIdsDerivedError`. Never an empty list. |
278
+ | `ruleCoverage(ruleIds, checked, notCheckable)` / `coverageSummary` | Every derived rule sits in exactly one bucket; reports `uncovered`, `doubleCovered`, `unknown` and `ok`. |
279
+ | `notCheckableResults(bucket, anchor)` | One could-not-judge result per `{ ruleId: reason }` entry; a blank reason throws. |
280
+ | `tallyRules(results, ruleIds, pattern)` / `tallyLine` / `ruleIdOf` | Rule-level worst-state reduce over `STATE_RANK`. A derived rule with no result throws, naming it; a tallied rule outside the list throws, naming it. `pattern` here reads RESULT ids (for example `R-3 some detector`), not standard lines. |
281
+ | `STATE_RANK` / `StateRank` / `ALL_STATES` | One rank per member of the `State` union (typed `Record<State, number>`: a new state is a compile error). `not-applicable` ranks lowest, so it never outranks `non-conforming` or `could-not-judge`. |
282
+ | `RegistryEntry` / `checkedRuleIds(entries)` | `{ detector, ruleId, standardPin }` and the distinct checked ids derived from the entries. |
283
+ | `renderReport(ctx)` / `writeReport(path, ctx)` | Tally line plus `renderTable`, with doctor-specific header fields passed as `ctx.header`; the exit code is derived with `computeExitCode`. Pure: the caller supplies the date. |
284
+
285
+ ```ts
286
+ import { deriveRuleIds, tallyRules, ruleCoverage, checkedRuleIds } from "@vantageos/mcp-doctor";
287
+
288
+ const RULE = /^\*\*(R-[0-9]+)/; // reads the standard's rule lines, e.g. "**R-3 — ..."
289
+ const RESULT = /^(R-\d+)\b/; // reads result ids, e.g. "R-3 pagination"
290
+ const ids = deriveRuleIds("./fixtures/my-standard.md", RULE);
291
+ const t = tallyRules(results, ids, RESULT);
292
+ const cov = ruleCoverage(ids, checkedRuleIds(REGISTRY), Object.keys(NOT_CHECKABLE));
293
+ ```
294
+
295
+ `State` and `DetectorResult` are also exported as types.
296
+
227
297
  ## What it checks (MCP 2026-07-28)
228
298
 
229
299
  Each detector maps one standard item and is proven **bipolar** on real material: a genuine defect
@@ -232,11 +302,11 @@ Each detector maps one standard item and is proven **bipolar** on real material:
232
302
  | ID | Standard item | Verdict shape |
233
303
  |----|---------------|---------------|
234
304
  | **D2** stateless | `sessionIdGenerator: undefined`, no `Mcp-Session-Id` session-keying, no hand-rolled `initialize` gate | conforming (stateless) / non-conforming (session-keyed) |
235
- | **D3** resultType | `resultType` present on list/read result builders | present / absent |
236
- | **D4** CacheableResult | `ttlMs` / `cacheScope` on the list/read result types | present / absent |
305
+ | **D3** resultType | `resultType` present on list/read result builders | present / non-conforming (a builder, no `resultType` written) / could-not-judge (the builder's response is shaped by `@modelcontextprotocol/server` >= 2, read on the served response) / absent (not an MCP server) / could-not-judge (an MCP server with no builder, no SDK-first registration and no tool surface: unmeasured) |
306
+ | **D4** CacheableResult | `ttlMs` / `cacheScope` on the list/read result types | present / non-conforming (builders, neither field written) / could-not-judge (the builders' response is shaped by `@modelcontextprotocol/server` >= 2, read on the served response) / absent (not an MCP server) / could-not-judge (an MCP server with no builder, no SDK-first registration and no tool surface: unmeasured) |
237
307
  | **D5** server/discover | a `server/discover` handler is registered (absence-based, with a positive control) | present / absent |
238
- | **D6** mcp-apps ui-key | MCP Apps UI key is the GA nested `_meta.ui.resourceUri` — not flat `ui/resourceUri`, not community `io.modelcontextprotocol/ui` | GA-nested / flat-deprecated / community-nonGA / none |
239
- | **D7** protocol-kit | `@vantageos/mcp-protocol-kit` listed in `package.json` **and actually called** (builder invoked, not merely declared) | listed+called / listed-not-called / hand-rolled. Conformant too on `@modelcontextprotocol/server` >= 2 with no hand-rolled result builder (the kit is required only where builders are written by hand) |
308
+ | **D6** mcp-apps ui-key | MCP Apps UI key is the GA nested `_meta.ui.resourceUri` — not flat `ui/resourceUri`, not community `io.modelcontextprotocol/ui` | GA-nested / flat-deprecated / community-nonGA / non-conforming (an App — a `ui://` resource is served — with no GA key) / absent (no key and no `ui://` resource: not an App) |
309
+ | **D7** protocol-kit | `@vantageos/mcp-protocol-kit` listed in `package.json` **and actually called** (builder invoked, not merely declared) | listed+called / listed-not-called / hand-rolled (a constructor of `resultType`, `ttlMs` or `cacheScope` written by hand, read by the same reader on every path). Conformant too on `@modelcontextprotocol/server` >= 2 with no hand-rolled result builder (the kit is required only where builders are written by hand); absent where no kit, no SDK v2 and no hand-rolled builder |
240
310
  | **D15** cache-coherence | Server Rule 15 — every tool-set mutation (RegisteredTool `.enable/.disable/.update/.remove`, `unregisterTool`) is correlated with a `notifications/tools/list_changed` emission | present / absent / non-conforming / could-not-judge |
241
311
  | **D16** version-observable | Server Rule 16 — `server/discover` (or an HTTP `/health` route) exposes a `version` field sourced from `package.json`, reachable pre-auth; an SDK v2 `new McpServer({ name, version })` carrying a `package.json`-derived version counts (pre-auth reach is the dynamic half) | present / absent / non-conforming / could-not-judge |
242
312
  | **DLocalIdentity** no-local-identity | No MCP server defines its own identity primitive: resolving a caller to a tenant or agent (local JWT verify, a populated allow-list attached to a bearer), asserting org membership or role, filtering rows by caller scope (`fromAllowList`, a name allow-list, a row's `orgId` or acting-name field such as `createdBy` / `assignedTo` compared to the caller's, by `===`, `==`, `Object.is` or after `toLowerCase()`), or validating a credential (local `timingSafeEqual`, a digest of a presented value, HMAC; a hash over a static literal, or over local content — file bytes, a directory listing, a digest of them, i.e. a content fingerprint of the built tree — is not a site). A call to a binding imported from `@vantageos/cloud-identity` is not a site. Minting/signing sites (`new SignJWT`, `jwt.sign`, a private-key import) are listed as `MINTING/SIGNING` and not counted; verification and claim reads stay violations whoever issued the token (no issuer carve-out). | present (0, or EXEMPT) / non-conforming (count > ceiling, default 0) / could-not-judge |
@@ -248,11 +318,11 @@ Registered detectors that no description table above or below documents, in regi
248
318
 
249
319
  | ID | Rule | The static run reads | Verdicts |
250
320
  |----|------|----------------------|----------|
251
- | **D8** eval-suite-coverage | C-5 (the >=3-cases count half) | registered tools against the case count per tool in `evals/evals.json` | absent (no tool, or no eval file) / present / non-conforming / could-not-judge |
252
- | **D9** semver+changelog | C-3 | `package.json` `version` against strict SemVer, and `CHANGELOG.md` beside it | absent (no `CHANGELOG.md`) / present / non-conforming / could-not-judge |
321
+ | **D8** eval-suite-coverage | C-5 (the >=3-cases count half) | registered tools against the case count per tool in `evals/evals.json` | absent (no tool) / present / non-conforming (including tools registered and no eval file) / could-not-judge |
322
+ | **D9** semver+changelog | C-3 | `package.json` `version` against strict SemVer, and `CHANGELOG.md` beside it | present / non-conforming (including no `CHANGELOG.md`) / could-not-judge |
253
323
  | **D10** bilingual | C-1 | `description_fr` in `package.json` or in source, `README.fr.md`, and its listing in `files[]` | present / non-conforming / could-not-judge |
254
324
  | **D11** zod-schemas | C-4 | `z.any()` per line, and tool registrations against `outputSchema` occurrences tree-wide (not per tool) | absent (no tool) / present / non-conforming / could-not-judge |
255
- | **D12** stdio-transport | S-1 | `StdioServerTransport` or a `package.json` `bin` entry, against an HTTP/Streamable transport | absent (no transport signal) / present / non-conforming / could-not-judge (unparseable `package.json`) |
325
+ | **D12** stdio-transport | S-1 | `StdioServerTransport`, a `package.json` `bin` entry, or a stdio `transport` declared in the server manifest (`mcp.json` / `mcp-server.json`), against an HTTP/Streamable transport | absent (no transport signal and no MCP server surface) / present / non-conforming / could-not-judge (an MCP server with no transport signal, or an unparseable `package.json`) |
256
326
  | **C7** artifact-verifiable | C-7 | `README.md` / `README.fr.md`: one-command install naming a registry, version pin, two obtain channels, provenance or checksum | present / non-conforming / could-not-judge |
257
327
  | **C8** authority-declared | C-8 | each registered tool's `authRead` / `authWrite` pair in the closed 5-tier set (a folded `auth` refused) | absent (no tool) / present / non-conforming / could-not-judge |
258
328
  | **C9** verb-declared | C-9 | each registered tool's `annotations.verb` in the closed set (`rpc` refused) | absent (no tool) / present / non-conforming / could-not-judge |
@@ -267,26 +337,26 @@ Registered detectors that no description table above or below documents, in regi
267
337
  | **C18** structure-manifest | C-18 | the root `mcp.json` / `mcp-server.json` or `extension.json`: required fields and version against `package.json` | present / non-conforming / could-not-judge |
268
338
  | **C19** served-descriptions | C-19 | an inline source description on each registered tool (presence proxy; the served text is the dynamic run) | absent (no tool) / present / non-conforming / could-not-judge |
269
339
  | **C20** locales-derived | C-20 | locale files under `src/i18n/` against hardcoded locale enumerations elsewhere | absent (no `src/i18n/`) / present / non-conforming |
270
- | **C21** progressive-disclosure | C-21 | nothing: the connection load is measured only with a live session | absent (static run) |
340
+ | **C21** progressive-disclosure | C-21 | nothing: the connection load is measured only with a live session | could-not-judge (static run of an MCP server: not measured) / absent (not an MCP server) |
271
341
  | **C22** test-ratio-gate | C-22 | test/coverage ratios cited in `README.md`, `README.fr.md`, `CHANGELOG.md` and their passage identifier | absent (no ratio cited) / non-conforming / could-not-judge |
272
342
  | **C25** build-identity | C-25 | the `new McpServer(...)` / `new Server(...)` arguments and a `/health` route: a build-fed identity field beside `version` | absent (no construction) / present / non-conforming / could-not-judge |
273
- | **C26** subpackage-lockfile | C-26 | deployment configs (`railway.json`, `Dockerfile`, `fly.toml`, ...) and a frozen install of each targeted subpackage in isolation | absent (no deployment config, or no npm site) / present / non-conforming / could-not-judge |
343
+ | **C26** subpackage-lockfile | C-26 | deployment configs (`railway.json`, `Dockerfile`, `fly.toml`, ...) and a frozen install of each targeted subpackage in isolation | absent (no deployment config) / present / non-conforming / could-not-judge (also: every site skipped as not npm-managed, its lockfile not measured) |
274
344
  | **A2** declared-domains | A-2 | network and frame targets in the UI code against the `_meta.ui.csp` lists, and the single-file bundle | absent (no `ui://` resource) / present / non-conforming / could-not-judge |
275
- | **A7** consent-before-destructive | A-7 | the gate logic: event-origin approvals, `destructiveHint`-only skips, explicit confirmation requests | absent (no tool-call gate) / present / non-conforming / could-not-judge |
345
+ | **A7** consent-before-destructive | A-7 | the gate logic: event-origin approvals, `destructiveHint`-only skips, explicit confirmation requests | absent (not an App and no tool call) / present / non-conforming / could-not-judge (also: an App or a tool call with no confirmation, or a request whose method is an expression) |
276
346
  | **S12** list-pagination | S-12 | `nextCursor` in each hand-registered protocol list handler, and code that decodes a cursor | absent (no list method served) / present / non-conforming / could-not-judge |
277
347
  | **DServer2** naming | C-2 | tool names (snake_case, 64-character cap) and the `package.json` name (kebab-case) | present / non-conforming / could-not-judge |
278
348
  | **DServer6** secret-hygiene | C-6 | log calls referencing secrets, PII or internal detail, and raw error traces sent to the client | present / non-conforming / could-not-judge |
279
349
  | **DDebugOptIn** debug-opt-in | C-6 (debug half) | `.debug(...)` calls and the env/config gate around them | absent (no debug output) / present / non-conforming / could-not-judge |
280
350
  | **DServer8** ui-fallback | A-1 | each `content[]` emitting a `ui://` resource, and a sibling text/markdown entry | absent (no `ui://` emission) / present / non-conforming / could-not-judge |
281
- | **DServer14** oauth-resource-server | S-5 | the five-element OAuth 2.1 resource-server chain and the `@vantageos/cloud-identity` dependency and range | absent (no resource-server surface) / present / non-conforming / could-not-judge |
351
+ | **DServer14** oauth-resource-server | S-5 | the five-element OAuth 2.1 resource-server chain and the `@vantageos/cloud-identity` dependency and range | absent (no resource-server surface, out of S-5's scope: not an MCP server, or stdio only) / present / non-conforming (also: in scope with no surface) / could-not-judge (also: the scope unread — HTTP with no tenancy statement, or no transport wired) |
282
352
  | **DAppI18n** app-i18n | C-20 | `i18n/fr.json` keys against `i18n/en.json` | absent (no `i18n/`) / present / non-conforming / could-not-judge |
283
- | **DExt1** identifier | E-1 | the reverse-DNS `identifier` in `extension.json` and TS factories, and vendor host-key namespaces against the registry | absent (no identifier declared) / present / non-conforming / could-not-judge |
353
+ | **DExt1** identifier | E-1 | the reverse-DNS `identifier` in `extension.json` and TS factories, and vendor host-key namespaces against the registry | absent (not an extension: no manifest, no `defineExtension` call, no identifier) / present / non-conforming (including a `defineExtension` call with no `identifier`) / could-not-judge |
284
354
  | **DExt2** graceful-degradation | E-2 | `graceful_degradation` in `extension.json` and `gracefulDegradation` in `defineExtension` | absent (no flag found) / present / non-conforming / could-not-judge |
285
355
  | **DExt3** single-type | E-3 | the extension `type` in `extension.json` and `defineExtension`: exactly one known category | absent (no type declared) / present / non-conforming / could-not-judge |
286
356
  | **DExt4** lifecycle-hooks | E-4 | the manifest `lifecycle` hooks against their implementations (`hooks/` files, factory hooks) | absent (no hook declared) / present / non-conforming / could-not-judge |
287
- | **DExt5** bilingual | C-1 | `description_fr` and `README.fr.md` beside each `extension.json`, and per-tool `description_fr` | absent (no manifest, or an FR piece missing) / present / could-not-judge |
357
+ | **DExt5** bilingual | C-1 | `description_fr` and `README.fr.md` beside each `extension.json`, and per-tool `description_fr` | absent (no manifest) / present / non-conforming (an FR piece missing) / could-not-judge |
288
358
  | **DExt7** eval-coverage | C-5 | each extension's `evals/evals.json`: >=3 cases including an "extension absente" case | absent (no manifest) / present / non-conforming / could-not-judge |
289
- | **DExt8** semver+changelog | C-3 | each extension's `package.json` `version` against strict SemVer, and `CHANGELOG.md` beside it | absent (no manifest, or no `CHANGELOG.md`) / present / non-conforming / could-not-judge |
359
+ | **DExt8** semver+changelog | C-3 | each extension's `package.json` `version` against strict SemVer, and `CHANGELOG.md` beside it | absent (no manifest) / present / non-conforming (including no `CHANGELOG.md`) / could-not-judge |
290
360
  | **DExt9** hook-timeout | E-6 | each declared lifecycle hook's timeout guard (manifest `timeouts.<hook>` or in its implementation) | absent (no hook declared) / present / non-conforming / could-not-judge |
291
361
  | **S42** write-read-claims | S-42 | the verified claims each write tool forwards to its backend door against those of the read tools on the same table | absent (no backend door call) / present / non-conforming / could-not-judge |
292
362
  | **S44** closed-output | S-44 | every object of each tool's output schema closed to added fields (`.strict()`, `additionalProperties: false`, ...) | absent (no tool) / present / non-conforming / could-not-judge |
@@ -314,7 +384,7 @@ where the tree contradicts the rule, and otherwise `could-not-judge` naming the
314
384
  | **C32** host-key-additive | C-32 | `_meta` objects (followed through spreads and consts): `openai/outputTemplate` needs `ui.resourceUri`, `openai/visibility` needs `ui.visibility` | absent / non-conforming / could-not-judge (served `tools/list` owed) |
315
385
  | **C33** identity-tool | C-33 | on an authenticated server, the identity tool: no argument, `readOnlyHint: true`, an `outputSchema` that declares `id` (inline or a same-tree const) | absent / non-conforming / could-not-judge |
316
386
  | **S29**..**S34** | S-29..S-34 | the `events` capability and the three `events/*` handler literals; descriptors (`name`, bilingual description, non-empty `delivery`, `inputSchema`, `payloadSchema`); the `-32012`/`-32602`/`whsec_`, `-32015`/`verification`, five-header/`standardwebhooks`/262144-byte/410-413 evidence; `events.accessRecheckSeconds > 0` in the server manifest | absent (no events surface) / non-conforming / could-not-judge (dynamic half named) |
317
- | **S5** authz-elements (f)-(l) | S-5 (f)..(l) | PRM `resource` and its path-suffixed route, CIMD + `"none"`, `iss` flag, `/authorize` handler (auto-approval, organisation from a query parameter), jwt-bearer, OIDC discovery | absent / non-conforming / could-not-judge (sites exposed in `owedVerdict`; probes owed) |
387
+ | **S5** authz-elements (f)-(l) | S-5 (f)..(l) | PRM `resource` and its path-suffixed route, CIMD + `"none"`, `iss` flag, `/authorize` handler (auto-approval, organisation from a query parameter), jwt-bearer, OIDC discovery | absent (out of S-5's scope: not an MCP server, or stdio only) / non-conforming / could-not-judge (sites exposed in `owedVerdict`; probes owed; or the S-5 scope unread) |
318
388
  | **E7** middleware-events | E-7 | writes to `delivery`/`arguments`/`id`/`refreshBefore`/`cursor` and replacement of `ctx.output` inside an `events/*` branch of a hook | absent / present / non-conforming |
319
389
  | **E8** official-ext-declared | E-8 | `capabilities.extensions` as an object, each official key's MUST methods registered | absent / present / non-conforming / could-not-judge (unknown official extension) |
320
390
  | **E9** host-invoked-tools | E-9 | `openai/settings.readTool`, `openai/mentions.searchTool`: registered, `readOnlyHint: true`, `outputSchema`, no required input, `"app"` visibility, ResourceLink | absent / present / non-conforming |
@@ -372,7 +442,7 @@ an error message) it counts only as code or as a quoted property key.
372
442
  | **S45** origin-targets | S-45 | `mcp-server.json` `distribution.targets`, the public origin (manifest URL or `PUBLIC_BASE_URL`), the Streamable HTTP route, each declared host's verification path and where its value comes from | absent (no target declared) / present / non-conforming / could-not-judge (a development default alone) |
373
443
  | **S46** registration-redirects | S-46 | CIMD and DCR offered together, each declared host's redirect in the allow-list; served half: the registration and authorize endpoints | absent / present / non-conforming / could-not-judge |
374
444
  | **S47** webhook-delivery | S-47 | events served, the outbound call whose target is the subscriber callback, its Standard Webhooks signature headers, the callback verification | absent (no events) / present / non-conforming / could-not-judge |
375
- | **S48** per-member | S-48 | the request path of a force-installed member: no shared-credential fallback, a 401 challenge for a member without a credential | absent (no person signs in) / present / non-conforming / could-not-judge |
445
+ | **S48** per-member | S-48 | the request path of a force-installed member: no shared-credential fallback, a 401 challenge for a member without a credential | absent (not an MCP server) / present / non-conforming / could-not-judge (also: a server that signs no member in — force-installed is stated in no tree) |
376
446
  | **C34** plugin-families | C-34 | each Agent Plugins, Claude or Cursor plugin file, the script that writes it, and its `--check` drift refusal | absent (no plugin family) / present / non-conforming / could-not-judge |
377
447
  | **C35** listing-kit | C-35 | `listing/listing.json`: description, tools, test prompts and reviewer note against their sources; served half: titles and hints against the served `tools/list` | absent (not listed) / present / non-conforming / could-not-judge |
378
448
 
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.
@@ -393,6 +393,16 @@ interface Detector {
393
393
  * alongside `rule`: a rule id with no pin is unverifiable against a moving
394
394
  * doc. */
395
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;
396
406
  /** Static verdict from the source tree. REQUIRED — static is never optional. */
397
407
  run(tree: Tree): DetectorResult;
398
408
  /**
@@ -679,6 +689,131 @@ interface EventsReadyOptions {
679
689
  }
680
690
  declare function runEventsReady(opts: EventsReadyOptions): Promise<DetectorResult[]>;
681
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
+
682
817
  type RunMode = "static" | "dynamic" | "both";
683
818
  interface RunDoctorOptions {
684
819
  mode?: RunMode;
@@ -791,6 +926,14 @@ declare function renderOwedVerdicts(results: DetectorResult[]): string;
791
926
  * prose.
792
927
  */
793
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>;
794
937
  /**
795
938
  * The process exit code a run's results carry, three-way with precedence:
796
939
  * 1 — a VIOLATION: at least one detector is `non-conforming` (something IS
@@ -798,10 +941,12 @@ declare function renderJson(surface: string, results: DetectorResult[], skipped:
798
941
  * 2 — an ABSTENTION with zero violations: at least one `could-not-judge`
799
942
  * ("I did not look" must NOT reach a caller as a clean 0).
800
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.
801
946
  * The rendered table already draws this distinction; this only lets a machine
802
947
  * reading the exit code (CI, the foreign-bite probes) see what the table says.
803
948
  */
804
949
  declare function computeExitCode(results: DetectorResult[]): number;
805
950
 
806
- export { OWED_FILE_NAME, SubjectUnreadableError, computeExitCode, countOwedHumanVerdicts, endpointSecrets, evaluateGate, gateExitCode, introspectEndpoint, isLiveDetector, readCoverage, readOwedFile, redactSecrets, renderCoverage, renderGate, renderJson, renderOwedVerdicts, renderSkipped, renderTable, runDoctor, runDoctorAsync, runDoctorReport, runEventsReady };
807
- export type { Coverage, EventsReadyOptions, GateVerdict, 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 };