@gate-forge/core 0.13.10 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/dist/config/index.d.ts +62 -6
  2. package/dist/config/index.d.ts.map +1 -1
  3. package/dist/config/index.js +79 -0
  4. package/dist/config/index.js.map +1 -1
  5. package/dist/index.d.ts +14 -2
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +14 -2
  8. package/dist/index.js.map +1 -1
  9. package/dist/policy/evaluate.d.ts +16 -0
  10. package/dist/policy/evaluate.d.ts.map +1 -1
  11. package/dist/policy/evaluate.js +21 -2
  12. package/dist/policy/evaluate.js.map +1 -1
  13. package/dist/report/index.d.ts +54 -1
  14. package/dist/report/index.d.ts.map +1 -1
  15. package/dist/report/index.js +25 -20
  16. package/dist/report/index.js.map +1 -1
  17. package/dist/schemas/behavior-evidence.d.ts +2 -2
  18. package/dist/schemas/behavior-policy.d.ts +7 -0
  19. package/dist/schemas/behavior-policy.d.ts.map +1 -1
  20. package/dist/schemas/behavior-policy.js +7 -0
  21. package/dist/schemas/behavior-policy.js.map +1 -1
  22. package/dist/schemas/business-rules.d.ts +3 -3
  23. package/dist/schemas/classification-policy.d.ts +1 -1
  24. package/dist/schemas/execution-result.d.ts +2 -0
  25. package/dist/schemas/execution-result.d.ts.map +1 -1
  26. package/dist/schemas/execution-result.js +4 -0
  27. package/dist/schemas/execution-result.js.map +1 -1
  28. package/dist/schemas/gate-receipt.d.ts +2 -2
  29. package/dist/schemas/queue-observer.d.ts +4 -4
  30. package/dist/schemas/runner-adapter.d.ts +7 -0
  31. package/dist/schemas/runner-adapter.d.ts.map +1 -1
  32. package/dist/schemas/test-catalog.d.ts +12 -12
  33. package/dist/schemas/test-map.d.ts +4 -4
  34. package/dist/schemas/verdict.d.ts +5 -0
  35. package/dist/schemas/verdict.d.ts.map +1 -1
  36. package/dist/schemas/verdict.js +22 -0
  37. package/dist/schemas/verdict.js.map +1 -1
  38. package/dist/strictness.d.ts +1 -1
  39. package/dist/test-identity.d.ts +21 -0
  40. package/dist/test-identity.d.ts.map +1 -0
  41. package/dist/test-identity.js +57 -0
  42. package/dist/test-identity.js.map +1 -0
  43. package/dist/verdict/http-coverage.d.ts +183 -0
  44. package/dist/verdict/http-coverage.d.ts.map +1 -0
  45. package/dist/verdict/http-coverage.js +400 -0
  46. package/dist/verdict/http-coverage.js.map +1 -0
  47. package/dist/verdict/http-ledger.d.ts +71 -0
  48. package/dist/verdict/http-ledger.d.ts.map +1 -0
  49. package/dist/verdict/http-ledger.js +172 -0
  50. package/dist/verdict/http-ledger.js.map +1 -0
  51. package/dist/verdict/index.d.ts +15 -1
  52. package/dist/verdict/index.d.ts.map +1 -1
  53. package/dist/verdict/index.js +15 -1
  54. package/dist/verdict/index.js.map +1 -1
  55. package/dist/verdict/pack-verifiers.d.ts +66 -11
  56. package/dist/verdict/pack-verifiers.d.ts.map +1 -1
  57. package/dist/verdict/pack-verifiers.js +137 -29
  58. package/dist/verdict/pack-verifiers.js.map +1 -1
  59. package/package.json +1 -1
@@ -0,0 +1,183 @@
1
+ import type { Location } from '../schemas/common.js';
2
+ import type { BlockingEntry } from '../policy/evaluate.js';
3
+ import type { HttpLedger, HttpLedgerRow } from './http-ledger.js';
4
+ /** A witnessed call that matches no route in the run's inventory. */
5
+ export declare const HTTP_CALL_UNMATCHED = "HTTP_CALL_UNMATCHED";
6
+ /** A witnessed response proves the app answered, but not that inventory is complete. */
7
+ export declare const HTTP_ROUTE_NOT_INVENTORIED = "HTTP_ROUTE_NOT_INVENTORIED";
8
+ /** A witnessed call that matches several routes at equal specificity. */
9
+ export declare const HTTP_CALL_AMBIGUOUS = "HTTP_CALL_AMBIGUOUS";
10
+ /** A static call site whose URL the join could not compute. */
11
+ export declare const HTTP_CALL_UNRESOLVED = "HTTP_CALL_UNRESOLVED";
12
+ /** Every typed call-finding code this module mints. */
13
+ export type HttpCallFindingCode = typeof HTTP_CALL_UNMATCHED | typeof HTTP_CALL_AMBIGUOUS | typeof HTTP_CALL_UNRESOLVED | typeof HTTP_ROUTE_NOT_INVENTORIED;
14
+ /** Which channel the call findings block on (owner-declared). */
15
+ export type HttpCallFindingsMode = 'report' | 'block';
16
+ /** One route of the served/used denominator, as the graph states it. */
17
+ export interface HttpCoverageRoute {
18
+ /** The `http.endpoint` graph resource id. */
19
+ resourceId: string;
20
+ /** The static join: a frontend call resolved onto this route. */
21
+ consumed: boolean;
22
+ /** The joined static call sites, `file:line:col`. */
23
+ callSites: readonly string[];
24
+ /**
25
+ * Proofs that this route's router is mounted on the scanned app (plan
26
+ * finding 13). Empty means "no mount proof"; it is read as "proven
27
+ * unmounted" only when {@link HttpCoverageInput.mountProvenanceEmitted}
28
+ * says the detector emitted the fact at all.
29
+ */
30
+ mountProvenances: readonly string[];
31
+ }
32
+ /** The minimum a verdict must say for the proven/missing counts. */
33
+ export interface HttpCoverageVerdict {
34
+ resourceId: string;
35
+ contract: string;
36
+ verdict: string;
37
+ }
38
+ /** One unresolved static entry, as the graph carries it. */
39
+ export interface HttpCoverageUnresolved {
40
+ code: string;
41
+ detail: string;
42
+ location: Location;
43
+ }
44
+ /** Everything the rules read. */
45
+ export interface HttpCoverageInput {
46
+ /** The run's route table, one entry per `http.endpoint` resource. */
47
+ routes: readonly HttpCoverageRoute[];
48
+ /**
49
+ * Whether this run's detector emitted mount provenance anywhere. Until
50
+ * a detector proves it (plan finding 13), NO route is subtracted from
51
+ * `served`: an absent proof is unknown served-ness, never proof of an
52
+ * unmounted router, and a summary line reading "0 served" would be a
53
+ * wrong report, not a conservative one.
54
+ */
55
+ mountProvenanceEmitted?: boolean;
56
+ /** The run's exchange ledger; null/absent for a run without exchanges. */
57
+ ledger?: HttpLedger | null;
58
+ /** The run's graded obligations (this run's scoped verdicts). */
59
+ verdicts?: readonly HttpCoverageVerdict[];
60
+ /** The graph's unresolved entries (R4's only source). */
61
+ unresolvedCallSites?: readonly HttpCoverageUnresolved[];
62
+ /** The owner's channel declaration; it never changes WHAT is found. */
63
+ mode?: HttpCallFindingsMode;
64
+ }
65
+ /** One typed finding about a call the product makes. */
66
+ export interface HttpCallFinding {
67
+ code: HttpCallFindingCode;
68
+ /** The route the call belongs to, when it belongs to one. */
69
+ resourceId: string | null;
70
+ /** The source location, when the call has one (R4 always does). */
71
+ location: Location | null;
72
+ /** A readable name for the call. It is not the identity; see `fingerprint`. */
73
+ key: string;
74
+ /**
75
+ * The identity the adoption receipt records (0.14 WP5 D1): a sha256 over
76
+ * the call's identity, never its status or line. Equal fingerprints are
77
+ * one debt.
78
+ */
79
+ fingerprint: string;
80
+ detail: string;
81
+ }
82
+ /** One used route whose two transport obligations are not both satisfied. */
83
+ export interface HttpMissingRoute {
84
+ resourceId: string;
85
+ /** The witnessing tests whose exchange matched this route. */
86
+ ledgerCallers: readonly string[];
87
+ /** The static call sites joined onto this route. */
88
+ callSites: readonly string[];
89
+ }
90
+ /** The one summary line's numbers (plan §4.5). */
91
+ export interface HttpCoverageSummary {
92
+ /** Route-table size excluding endpoints with empty `mountProvenances`. */
93
+ served: number;
94
+ /** Served routes a witnessed exchange matched OR a static call joined. */
95
+ used: number;
96
+ /** Used routes whose two transport obligations are both satisfied. */
97
+ proven: number;
98
+ /** Used routes that are not proven. */
99
+ missing: number;
100
+ /** Ledger rows the one resolver could not place on any route. */
101
+ unmatched: number;
102
+ /** Ledger rows the one resolver placed on several equal candidates. */
103
+ ambiguous: number;
104
+ /** Route inventory availability for safe unmatched-call adjudication. */
105
+ inventory?: 'complete' | 'incomplete' | 'unavailable';
106
+ }
107
+ /** What R1-R5 produced. */
108
+ export interface HttpCoverageResult {
109
+ summary: HttpCoverageSummary;
110
+ findings: HttpCallFinding[];
111
+ missingRoutes: HttpMissingRoute[];
112
+ }
113
+ /**
114
+ * Applies R1-R5 to one run.
115
+ *
116
+ * Args:
117
+ * input: the route table, the ledger, the graded obligations, the
118
+ * graph's unresolved entries and the owner's channel declaration.
119
+ *
120
+ * Returns:
121
+ * HttpCoverageResult: the summary line's numbers, the typed findings
122
+ * (identical in both modes) and the used-but-unproven routes with
123
+ * their callers.
124
+ */
125
+ export declare function evaluateHttpCoverage(input: HttpCoverageInput): HttpCoverageResult;
126
+ /**
127
+ * Projects the call findings onto the report's existing finding channel
128
+ * (`kind: 'finding'`, typed cause, the shared next action), so text, json
129
+ * and SARIF render them like every other finding.
130
+ *
131
+ * The CHANNEL is the caller's decision (the owner's `http.callFindings`):
132
+ * this function only shapes the entries.
133
+ *
134
+ * Args:
135
+ * findings: the run's call findings.
136
+ *
137
+ * Returns:
138
+ * BlockingEntry[]: one entry per finding, deterministically ordered.
139
+ */
140
+ export declare function httpCallFindingEntries(findings: readonly HttpCallFinding[]): BlockingEntry[];
141
+ /**
142
+ * Splits graded call findings into the blocking set and the advisory
143
+ * channel. Inventory gaps are always advisory; unresolved static call
144
+ * sites always block; other call findings follow `http.callFindings`.
145
+ *
146
+ * Args:
147
+ * findings: the run's NEW call findings (post-adoption filter).
148
+ * mode: the owner's `http.callFindings` declaration.
149
+ *
150
+ * Returns:
151
+ * blocking and advisories: disjoint entry lists in finding order.
152
+ */
153
+ export declare function channelHttpCallFindings(findings: readonly HttpCallFinding[], mode: HttpCallFindingsMode): {
154
+ blocking: BlockingEntry[];
155
+ advisories: BlockingEntry[];
156
+ };
157
+ /**
158
+ * Whether an adopted baseline may forgive this call-finding entry.
159
+ * Unresolved static call sites never shrink — only `scan.httpClients`
160
+ * clears them.
161
+ *
162
+ * Args:
163
+ * entry: one projected call finding.
164
+ *
165
+ * Returns:
166
+ * boolean: false when adoption must not forgive the entry.
167
+ */
168
+ export declare function httpCallFindingAdoptionForgivable(entry: BlockingEntry): boolean;
169
+ /**
170
+ * Projects the witness's body-shape findings (0.14 WP4) onto the finding
171
+ * channel: one entry per mismatched or refused exchange, in ledger order.
172
+ * `ok` and `unchecked` rows are not findings. The CHANNEL is the caller's
173
+ * decision (`http.responseShape: report` surfaces them as advisories; the
174
+ * `block` setting fails through the body obligation instead).
175
+ *
176
+ * Args:
177
+ * rows: the run's ledger rows.
178
+ *
179
+ * Returns:
180
+ * BlockingEntry[]: one entry per mismatch or refusal.
181
+ */
182
+ export declare function httpResponseShapeEntries(rows: readonly HttpLedgerRow[]): BlockingEntry[];
183
+ //# sourceMappingURL=http-coverage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-coverage.d.ts","sourceRoot":"","sources":["../../src/verdict/http-coverage.ts"],"names":[],"mappings":"AAmCA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAGlE,qEAAqE;AACrE,eAAO,MAAM,mBAAmB,wBAAwB,CAAC;AACzD,wFAAwF;AACxF,eAAO,MAAM,0BAA0B,+BAA+B,CAAC;AAEvE,yEAAyE;AACzE,eAAO,MAAM,mBAAmB,wBAAwB,CAAC;AAEzD,+DAA+D;AAC/D,eAAO,MAAM,oBAAoB,yBAAyB,CAAC;AAW3D,uDAAuD;AACvD,MAAM,MAAM,mBAAmB,GAC3B,OAAO,mBAAmB,GAC1B,OAAO,mBAAmB,GAC1B,OAAO,oBAAoB,GAC3B,OAAO,0BAA0B,CAAC;AAEtC,iEAAiE;AACjE,MAAM,MAAM,oBAAoB,GAAG,QAAQ,GAAG,OAAO,CAAC;AAEtD,wEAAwE;AACxE,MAAM,WAAW,iBAAiB;IAChC,6CAA6C;IAC7C,UAAU,EAAE,MAAM,CAAC;IACnB,iEAAiE;IACjE,QAAQ,EAAE,OAAO,CAAC;IAClB,qDAAqD;IACrD,SAAS,EAAE,SAAS,MAAM,EAAE,CAAC;IAC7B;;;;;OAKG;IACH,gBAAgB,EAAE,SAAS,MAAM,EAAE,CAAC;CACrC;AAED,oEAAoE;AACpE,MAAM,WAAW,mBAAmB;IAClC,UAAU,E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IACf,0EAA0E;IAC1E,IAAI,EAAE,MAAM,CAAC;IACb,sEAAsE;IACtE,MAAM,EAAE,MAAM,CAAC;IACf,uCAAuC;IACvC,OAAO,EAAE,MAAM,CAAC;IAChB,iEAAiE;IACjE,SAAS,EAAE,MAAM,CAAC;IAClB,uEAAuE;IACvE,SAAS,EAAE,MAAM,CAAC;IAClB,yEAAyE;IACzE,SAAS,CAAC,EAAE,UAAU,GAAG,YAAY,GAAG,aAAa,CAAC;CACvD;AAED,2BAA2B;AAC3B,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,mBAAmB,CAAC;IAC7B,QAAQ,EAAE,eAAe,EAAE,CAAC;IAC5B,aAAa,EAAE,gBAAgB,EAAE,CAAC;CACnC;AAwND;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,iBAAiB,GAAG,kBAAkB,CAuCjF;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,SAAS,eAAe,EAAE,GAAG,aAAa,EAAE,CAa5F;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,SAAS,eAAe,EAAE,EACpC,IAAI,EAAE,oBAAoB,GACzB;IAAE,QAAQ,EAAE,aAAa,EAAE,CAAC;IAAC,UAAU,EAAE,aAAa,EAAE,CAAA;CAAE,CAiB5D;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,iCAAiC,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAE/E;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,SAAS,aAAa,EAAE,GAAG,aAAa,EAAE,CAexF"}
@@ -0,0 +1,400 @@
1
+ /**
2
+ * The HTTP call rules R1-R5 (0.14 WP3, plan §4.3) over the exchange
3
+ * ledger.
4
+ *
5
+ * One primitive, three questions the gate could not answer before:
6
+ * - R1 USED: a route a witnessed exchange matched OR a static call site
7
+ * joined. Used routes already owe `http:request-observed` +
8
+ * `http:response-status-ok`: those obligations are generated PRE-RUN by
9
+ * the policy engine from the same `frontendConsumed` join
10
+ * (`policy/evaluate.ts`), so this module never invents an obligation —
11
+ * it reports who is used and who has not been proven yet.
12
+ * - R2: a `nomatch` call is an app defect only with status 404/405
13
+ * (`HTTP_CALL_UNMATCHED`); any other status becomes the report-only
14
+ * `HTTP_ROUTE_NOT_INVENTORIED` advisory because the app answered.
15
+ * - R3: a witnessed call matching several routes equally is
16
+ * `HTTP_CALL_AMBIGUOUS`.
17
+ * - R4: a static call site the join could not resolve, with its
18
+ * `file:line` — `HTTP_CALL_UNRESOLVED`. It reads the unresolved
19
+ * call-site facts the graph ALREADY carries (`FRONTEND_CALL_TARGET_UNRESOLVED`);
20
+ * it never scans anything itself.
21
+ * - R5: served-but-never-used is a COUNT, never a finding: the visible
22
+ * denominator, so an untested route cannot hide behind a green gate.
23
+ *
24
+ * `served` excludes endpoints whose router is never proven mounted
25
+ * (plan finding 13: an unmounted router is not a served route).
26
+ *
27
+ * NOTHING here changes a verdict: the rules add findings and one
28
+ * summary. Witnessed call findings (`HTTP_CALL_UNMATCHED` /
29
+ * `HTTP_CALL_AMBIGUOUS`) block on the owner's `http.callFindings`
30
+ * channel; `HTTP_CALL_UNRESOLVED` always blocks — the only escape is
31
+ * declaring the wrapper in `scan.httpClients` so the join resolves.
32
+ */
33
+ import { compareStrings } from '../graph/util.js';
34
+ import { sha256Canonical } from '../canonical-json.js';
35
+ import { CAUSE_NEXT_ACTIONS } from '../schemas/verdict.js';
36
+ import { HTTP_REQUEST_OBSERVED, HTTP_RESPONSE_STATUS_OK } from '../schemas/behavior-policy.js';
37
+ /** A witnessed call that matches no route in the run's inventory. */
38
+ export const HTTP_CALL_UNMATCHED = 'HTTP_CALL_UNMATCHED';
39
+ /** A witnessed response proves the app answered, but not that inventory is complete. */
40
+ export const HTTP_ROUTE_NOT_INVENTORIED = 'HTTP_ROUTE_NOT_INVENTORIED';
41
+ /** A witnessed call that matches several routes at equal specificity. */
42
+ export const HTTP_CALL_AMBIGUOUS = 'HTTP_CALL_AMBIGUOUS';
43
+ /** A static call site whose URL the join could not compute. */
44
+ export const HTTP_CALL_UNRESOLVED = 'HTTP_CALL_UNRESOLVED';
45
+ /**
46
+ * The static-scanner code for exactly "a frontend call whose target
47
+ * cannot be resolved statically". Read from the graph's unresolved
48
+ * entries; the constant is restated here because core cannot depend on
49
+ * `@gate-forge/http-contract` (same lockstep rule as
50
+ * `HTTP_OBSERVATION_UNTRUSTED` in pack-verifiers).
51
+ */
52
+ const FRONTEND_CALL_TARGET_UNRESOLVED = 'FRONTEND_CALL_TARGET_UNRESOLVED';
53
+ /** The two contracts R1's routes owe; both satisfied ⇒ proven. */
54
+ const TRANSPORT_CONTRACTS = [HTTP_REQUEST_OBSERVED, HTTP_RESPONSE_STATUS_OK];
55
+ /**
56
+ * Whether one route counts as served. An endpoint is only subtracted
57
+ * from the denominator when the detector emitted mount provenance at all
58
+ * and THIS route carries none of it (plan finding 13's `unmounted`).
59
+ *
60
+ * Args:
61
+ * route: one route of the table.
62
+ * mountProvenanceEmitted: whether the run carries mount proofs.
63
+ *
64
+ * Returns:
65
+ * boolean: true when the route is in the served denominator.
66
+ */
67
+ function isServed(route, mountProvenanceEmitted) {
68
+ return !mountProvenanceEmitted || route.mountProvenances.length > 0;
69
+ }
70
+ /**
71
+ * Collects the callers of every used route: the witnessing tests whose
72
+ * ledger row matched it, plus its joined static call sites.
73
+ *
74
+ * Args:
75
+ * routes: the run's route table.
76
+ * ledger: the run's exchange ledger (null when there is none).
77
+ * mountProvenanceEmitted: whether the run carries mount proofs.
78
+ *
79
+ * Returns:
80
+ * Map<string, HttpMissingRoute>: one entry per served route with at
81
+ * least one caller (a matched ledger row or a static join).
82
+ */
83
+ function usedRoutes(routes, ledger, mountProvenanceEmitted) {
84
+ const used = new Map();
85
+ const serve = (route, callers) => {
86
+ const entry = used.get(route.resourceId);
87
+ const ledgerCallers = [...new Set([...(entry?.ledgerCallers ?? []), ...callers])].sort(compareStrings);
88
+ const callSites = [...new Set([...(entry?.callSites ?? []), ...route.callSites])].sort(compareStrings);
89
+ used.set(route.resourceId, { resourceId: route.resourceId, ledgerCallers, callSites });
90
+ };
91
+ for (const route of routes) {
92
+ if (!isServed(route, mountProvenanceEmitted))
93
+ continue;
94
+ if (route.consumed)
95
+ serve(route, []);
96
+ }
97
+ for (const entry of ledger?.rows ?? []) {
98
+ if (entry.kind !== 'api' || entry.resolution !== 'match' || entry.route === null)
99
+ continue;
100
+ const route = routes.find((candidate) => candidate.resourceId === entry.route);
101
+ // A row matched by the resolver can only name a route of the same
102
+ // inventory; an id the table does not carry is never invented here.
103
+ if (route === undefined || !isServed(route, mountProvenanceEmitted))
104
+ continue;
105
+ serve(route, [entry.testId]);
106
+ }
107
+ return used;
108
+ }
109
+ /** The domain tag separating call-finding identities from every other hash. */
110
+ const HTTP_CALL_FINGERPRINT_DOMAIN = 'gateforge.http-call-finding.v1';
111
+ /** A path segment that is an id: all digits, a UUID, or a 16+ char hex run. */
112
+ const ID_SEGMENT = /^(?:\d+|[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}|[0-9a-f]{16,})$/i;
113
+ /**
114
+ * The shape of a call's path (0.14 WP5 D1): the query and fragment are
115
+ * dropped and every id segment collapses to `:id`, so `/items/42` and
116
+ * `/items/97` are one call shape.
117
+ *
118
+ * Args:
119
+ * path: the raw path the witness recorded.
120
+ *
121
+ * Returns:
122
+ * string: the path shape.
123
+ */
124
+ function pathShape(path) {
125
+ const bare = path.split(/[?#]/)[0] ?? '';
126
+ return bare.split('/').map((segment) => (ID_SEGMENT.test(segment) ? ':id' : segment)).join('/');
127
+ }
128
+ /**
129
+ * Reads one ledger row's placement into a finding, or null when the
130
+ * placement is not a defect (a match, or an inventory that could not be
131
+ * attributed — `incomplete` stays unknown, never a finding).
132
+ *
133
+ * Repeated identical calls collapse into ONE finding listing every
134
+ * observed status: one bug is one finding, not a wall of duplicates.
135
+ *
136
+ * Args:
137
+ * rows: the ledger rows sharing one (test, method, path).
138
+ * code: the finding code to mint.
139
+ *
140
+ * Returns:
141
+ * HttpCallFinding | null: the finding, or null when nothing is wrong.
142
+ */
143
+ function rowFinding(rows, code) {
144
+ const first = rows[0];
145
+ if (first === undefined)
146
+ return null;
147
+ const statuses = [...new Set(rows.map((entry) => String(entry.status)))].sort(compareStrings);
148
+ const call = `'${first.method} ${first.path}'`;
149
+ const shape = pathShape(first.path);
150
+ const identity = {
151
+ domain: HTTP_CALL_FINGERPRINT_DOMAIN,
152
+ code,
153
+ method: first.method,
154
+ pathShape: shape,
155
+ testId: first.testId,
156
+ };
157
+ const named = {
158
+ key: `${code} ${first.method} ${shape} (test ${first.testId})`,
159
+ fingerprint: sha256Canonical(identity),
160
+ };
161
+ if (code === HTTP_CALL_UNMATCHED || code === HTTP_ROUTE_NOT_INVENTORIED) {
162
+ return {
163
+ code,
164
+ resourceId: null,
165
+ location: null,
166
+ ...named,
167
+ detail: code === HTTP_CALL_UNMATCHED
168
+ ? `test '${first.testId}' called ${call} which matched no route in the run's inventory (HTTP ${statuses.join(', ')})`
169
+ : `the app served ${first.method} ${first.path} (HTTP ${statuses.join(', ')}) but the route inventory has no such route — the inventory is incomplete; check the detector for this framework`,
170
+ };
171
+ }
172
+ const candidates = [
173
+ ...new Set(rows.flatMap((entry) => entry.candidates ?? [])),
174
+ ].sort(compareStrings);
175
+ return {
176
+ code,
177
+ resourceId: null,
178
+ location: null,
179
+ ...named,
180
+ detail: `test '${first.testId}' called ${call} which matches ${String(candidates.length)} routes at ` +
181
+ `equal specificity (${candidates.join('; ')})`,
182
+ };
183
+ }
184
+ /**
185
+ * The call findings, in a deterministic order: by code, then resource,
186
+ * then detail.
187
+ *
188
+ * Args:
189
+ * ledger: the run's exchange ledger.
190
+ * unresolved: the graph's unresolved entries.
191
+ *
192
+ * Returns:
193
+ * HttpCallFinding[]: the run's call findings.
194
+ */
195
+ function callFindings(ledger, unresolved) {
196
+ const findings = [];
197
+ const grouped = new Map();
198
+ for (const entry of ledger?.rows ?? []) {
199
+ if (entry.kind !== 'api' || (entry.resolution !== 'nomatch' && entry.resolution !== 'ambiguous'))
200
+ continue;
201
+ const code = entry.resolution === 'ambiguous'
202
+ ? HTTP_CALL_AMBIGUOUS
203
+ : entry.status === 404 || entry.status === 405
204
+ ? HTTP_CALL_UNMATCHED
205
+ : HTTP_ROUTE_NOT_INVENTORIED;
206
+ const key = `${code}\u0000${entry.testId}\u0000${entry.method}\u0000${pathShape(entry.path)}`;
207
+ const bucket = grouped.get(key);
208
+ if (bucket === undefined)
209
+ grouped.set(key, [entry]);
210
+ else
211
+ bucket.push(entry);
212
+ }
213
+ for (const [key, rows] of grouped) {
214
+ const code = key.slice(0, key.indexOf('\u0000'));
215
+ const finding = rowFinding(rows, code);
216
+ if (finding !== null)
217
+ findings.push(finding);
218
+ }
219
+ for (const entry of unresolved) {
220
+ if (entry.code !== FRONTEND_CALL_TARGET_UNRESOLVED)
221
+ continue;
222
+ const identity = {
223
+ domain: HTTP_CALL_FINGERPRINT_DOMAIN,
224
+ code: HTTP_CALL_UNRESOLVED,
225
+ file: entry.location.file,
226
+ detail: entry.detail,
227
+ };
228
+ findings.push({
229
+ code: HTTP_CALL_UNRESOLVED,
230
+ resourceId: null,
231
+ location: entry.location,
232
+ key: `${HTTP_CALL_UNRESOLVED} ${entry.location.file}: ${entry.detail}`,
233
+ fingerprint: sha256Canonical(identity),
234
+ detail: `${entry.code}: ${entry.detail} — ${entry.location.file}:${String(entry.location.line)}`,
235
+ });
236
+ }
237
+ findings.sort((left, right) => compareStrings(left.code, right.code) ||
238
+ compareStrings(left.resourceId ?? '', right.resourceId ?? '') ||
239
+ compareStrings(left.detail, right.detail));
240
+ // Equal identities are one debt: a repeated call counts once.
241
+ const unique = new Map();
242
+ for (const finding of findings) {
243
+ if (!unique.has(finding.fingerprint))
244
+ unique.set(finding.fingerprint, finding);
245
+ }
246
+ return [...unique.values()];
247
+ }
248
+ /**
249
+ * Applies R1-R5 to one run.
250
+ *
251
+ * Args:
252
+ * input: the route table, the ledger, the graded obligations, the
253
+ * graph's unresolved entries and the owner's channel declaration.
254
+ *
255
+ * Returns:
256
+ * HttpCoverageResult: the summary line's numbers, the typed findings
257
+ * (identical in both modes) and the used-but-unproven routes with
258
+ * their callers.
259
+ */
260
+ export function evaluateHttpCoverage(input) {
261
+ const routes = [...input.routes].sort((left, right) => compareStrings(left.resourceId, right.resourceId));
262
+ const ledger = input.ledger ?? null;
263
+ const mountProvenanceEmitted = input.mountProvenanceEmitted === true;
264
+ const used = usedRoutes(routes, ledger, mountProvenanceEmitted);
265
+ const verdicts = input.verdicts ?? [];
266
+ const proven = new Set();
267
+ for (const [resourceId] of used) {
268
+ const states = TRANSPORT_CONTRACTS.map((contract) => verdicts.find((entry) => entry.resourceId === resourceId && entry.contract === contract)?.verdict);
269
+ // A waiver is a recorded forgiveness, not proof: only two
270
+ // `satisfied` verdicts prove the route.
271
+ if (states.every((state) => state === 'satisfied'))
272
+ proven.add(resourceId);
273
+ }
274
+ const missingRoutes = [...used.values()]
275
+ .filter((entry) => !proven.has(entry.resourceId))
276
+ .sort((left, right) => compareStrings(left.resourceId, right.resourceId));
277
+ const rows = ledger?.rows ?? [];
278
+ return {
279
+ summary: {
280
+ served: routes.filter((route) => isServed(route, mountProvenanceEmitted)).length,
281
+ used: used.size,
282
+ proven: proven.size,
283
+ missing: missingRoutes.length,
284
+ unmatched: rows.filter((entry) => entry.kind === 'api' &&
285
+ entry.resolution === 'nomatch' &&
286
+ (entry.status === 404 || entry.status === 405)).length,
287
+ ambiguous: rows.filter((entry) => entry.kind === 'api' && entry.resolution === 'ambiguous').length,
288
+ ...((ledger?.summary.inventory ?? (routes.length === 0 ? 'unavailable' : 'complete')) === 'complete'
289
+ ? {}
290
+ : { inventory: ledger?.summary.inventory ?? 'unavailable' }),
291
+ },
292
+ findings: callFindings(ledger, input.unresolvedCallSites ?? []),
293
+ missingRoutes,
294
+ };
295
+ }
296
+ /**
297
+ * Projects the call findings onto the report's existing finding channel
298
+ * (`kind: 'finding'`, typed cause, the shared next action), so text, json
299
+ * and SARIF render them like every other finding.
300
+ *
301
+ * The CHANNEL is the caller's decision (the owner's `http.callFindings`):
302
+ * this function only shapes the entries.
303
+ *
304
+ * Args:
305
+ * findings: the run's call findings.
306
+ *
307
+ * Returns:
308
+ * BlockingEntry[]: one entry per finding, deterministically ordered.
309
+ */
310
+ export function httpCallFindingEntries(findings) {
311
+ return findings.map((finding) => {
312
+ const inventoryGap = finding.code === HTTP_ROUTE_NOT_INVENTORIED;
313
+ return {
314
+ kind: 'finding',
315
+ resourceId: finding.resourceId,
316
+ name: null,
317
+ detail: `${finding.code}: ${finding.detail}`,
318
+ location: finding.location,
319
+ cause: inventoryGap ? null : finding.code,
320
+ nextAction: inventoryGap ? null : CAUSE_NEXT_ACTIONS[finding.code],
321
+ };
322
+ });
323
+ }
324
+ /**
325
+ * Splits graded call findings into the blocking set and the advisory
326
+ * channel. Inventory gaps are always advisory; unresolved static call
327
+ * sites always block; other call findings follow `http.callFindings`.
328
+ *
329
+ * Args:
330
+ * findings: the run's NEW call findings (post-adoption filter).
331
+ * mode: the owner's `http.callFindings` declaration.
332
+ *
333
+ * Returns:
334
+ * blocking and advisories: disjoint entry lists in finding order.
335
+ */
336
+ export function channelHttpCallFindings(findings, mode) {
337
+ const entries = httpCallFindingEntries(findings);
338
+ const blocking = [];
339
+ const advisories = [];
340
+ for (let index = 0; index < findings.length; index++) {
341
+ const finding = findings[index];
342
+ const entry = entries[index];
343
+ if (finding === undefined || entry === undefined)
344
+ continue;
345
+ if (finding.code === HTTP_ROUTE_NOT_INVENTORIED) {
346
+ advisories.push(entry);
347
+ }
348
+ else if (finding.code === HTTP_CALL_UNRESOLVED || mode === 'block') {
349
+ blocking.push(entry);
350
+ }
351
+ else {
352
+ advisories.push(entry);
353
+ }
354
+ }
355
+ return { blocking, advisories };
356
+ }
357
+ /**
358
+ * Whether an adopted baseline may forgive this call-finding entry.
359
+ * Unresolved static call sites never shrink — only `scan.httpClients`
360
+ * clears them.
361
+ *
362
+ * Args:
363
+ * entry: one projected call finding.
364
+ *
365
+ * Returns:
366
+ * boolean: false when adoption must not forgive the entry.
367
+ */
368
+ export function httpCallFindingAdoptionForgivable(entry) {
369
+ return entry.cause !== HTTP_CALL_UNRESOLVED;
370
+ }
371
+ /**
372
+ * Projects the witness's body-shape findings (0.14 WP4) onto the finding
373
+ * channel: one entry per mismatched or refused exchange, in ledger order.
374
+ * `ok` and `unchecked` rows are not findings. The CHANNEL is the caller's
375
+ * decision (`http.responseShape: report` surfaces them as advisories; the
376
+ * `block` setting fails through the body obligation instead).
377
+ *
378
+ * Args:
379
+ * rows: the run's ledger rows.
380
+ *
381
+ * Returns:
382
+ * BlockingEntry[]: one entry per mismatch or refusal.
383
+ */
384
+ export function httpResponseShapeEntries(rows) {
385
+ return rows
386
+ .filter((row) => row.kind === 'api' && (row.shape === 'mismatch' || row.shape === 'refused'))
387
+ .map((row) => {
388
+ const cause = row.shape === 'mismatch' ? 'HTTP_RESPONSE_SHAPE_MISMATCH' : 'HTTP_BODY_TOO_LARGE';
389
+ return {
390
+ kind: 'finding',
391
+ resourceId: row.route,
392
+ name: null,
393
+ detail: `${cause}: ${row.testId} ${row.method} ${row.path} (status ${row.status}): ${row.shapeDetail ?? ''}`,
394
+ location: null,
395
+ cause,
396
+ nextAction: CAUSE_NEXT_ACTIONS[cause],
397
+ };
398
+ });
399
+ }
400
+ //# sourceMappingURL=http-coverage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-coverage.js","sourceRoot":"","sources":["../../src/verdict/http-coverage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,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