@gate-forge/core 0.7.1 → 0.9.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 (141) hide show
  1. package/dist/classifier/bind.d.ts +2 -0
  2. package/dist/classifier/bind.d.ts.map +1 -1
  3. package/dist/classifier/bind.js +8 -0
  4. package/dist/classifier/bind.js.map +1 -1
  5. package/dist/classifier/classify.d.ts +2 -0
  6. package/dist/classifier/classify.d.ts.map +1 -1
  7. package/dist/classifier/classify.js +127 -2
  8. package/dist/classifier/classify.js.map +1 -1
  9. package/dist/classifier/index.d.ts +2 -2
  10. package/dist/classifier/index.d.ts.map +1 -1
  11. package/dist/classifier/index.js +1 -1
  12. package/dist/classifier/index.js.map +1 -1
  13. package/dist/classifier/schema.d.ts +54 -0
  14. package/dist/classifier/schema.d.ts.map +1 -1
  15. package/dist/classifier/schema.js +17 -0
  16. package/dist/classifier/schema.js.map +1 -1
  17. package/dist/config/index.d.ts +186 -0
  18. package/dist/config/index.d.ts.map +1 -1
  19. package/dist/config/index.js +327 -1
  20. package/dist/config/index.js.map +1 -1
  21. package/dist/graph/schema.d.ts +34 -0
  22. package/dist/graph/schema.d.ts.map +1 -1
  23. package/dist/index.d.ts +80 -10
  24. package/dist/index.d.ts.map +1 -1
  25. package/dist/index.js +58 -6
  26. package/dist/index.js.map +1 -1
  27. package/dist/mapping/resolve.d.ts +32 -1
  28. package/dist/mapping/resolve.d.ts.map +1 -1
  29. package/dist/mapping/resolve.js +297 -65
  30. package/dist/mapping/resolve.js.map +1 -1
  31. package/dist/policy/evaluate.d.ts +30 -0
  32. package/dist/policy/evaluate.d.ts.map +1 -1
  33. package/dist/policy/evaluate.js +22 -12
  34. package/dist/policy/evaluate.js.map +1 -1
  35. package/dist/quarantine/index.d.ts +82 -0
  36. package/dist/quarantine/index.d.ts.map +1 -0
  37. package/dist/quarantine/index.js +194 -0
  38. package/dist/quarantine/index.js.map +1 -0
  39. package/dist/receipt/index.d.ts +65 -1
  40. package/dist/receipt/index.d.ts.map +1 -1
  41. package/dist/receipt/index.js +115 -1
  42. package/dist/receipt/index.js.map +1 -1
  43. package/dist/report/human-message.d.ts +33 -0
  44. package/dist/report/human-message.d.ts.map +1 -0
  45. package/dist/report/human-message.js +33 -0
  46. package/dist/report/human-message.js.map +1 -0
  47. package/dist/report/index.d.ts +183 -9
  48. package/dist/report/index.d.ts.map +1 -1
  49. package/dist/report/index.js +317 -23
  50. package/dist/report/index.js.map +1 -1
  51. package/dist/schemas/adoption.d.ts +2 -0
  52. package/dist/schemas/adoption.d.ts.map +1 -1
  53. package/dist/schemas/adoption.js +6 -0
  54. package/dist/schemas/adoption.js.map +1 -1
  55. package/dist/schemas/behavior-catalog.d.ts +12 -0
  56. package/dist/schemas/behavior-catalog.d.ts.map +1 -1
  57. package/dist/schemas/behavior-evidence.d.ts +40 -0
  58. package/dist/schemas/behavior-evidence.d.ts.map +1 -1
  59. package/dist/schemas/behavior-evidence.js +9 -0
  60. package/dist/schemas/behavior-evidence.js.map +1 -1
  61. package/dist/schemas/behavior-policy.d.ts +26 -0
  62. package/dist/schemas/behavior-policy.d.ts.map +1 -1
  63. package/dist/schemas/behavior-policy.js +37 -1
  64. package/dist/schemas/behavior-policy.js.map +1 -1
  65. package/dist/schemas/execution-result.d.ts +17 -5
  66. package/dist/schemas/execution-result.d.ts.map +1 -1
  67. package/dist/schemas/execution-result.js +57 -2
  68. package/dist/schemas/execution-result.js.map +1 -1
  69. package/dist/schemas/gate-receipt.d.ts +25 -2
  70. package/dist/schemas/gate-receipt.d.ts.map +1 -1
  71. package/dist/schemas/gate-receipt.js +181 -2
  72. package/dist/schemas/gate-receipt.js.map +1 -1
  73. package/dist/schemas/index.d.ts +2 -0
  74. package/dist/schemas/index.d.ts.map +1 -1
  75. package/dist/schemas/index.js +2 -0
  76. package/dist/schemas/index.js.map +1 -1
  77. package/dist/schemas/policy.d.ts +19 -0
  78. package/dist/schemas/policy.d.ts.map +1 -1
  79. package/dist/schemas/policy.js +36 -0
  80. package/dist/schemas/policy.js.map +1 -1
  81. package/dist/schemas/quarantine.d.ts +25 -0
  82. package/dist/schemas/quarantine.d.ts.map +1 -0
  83. package/dist/schemas/quarantine.js +34 -0
  84. package/dist/schemas/quarantine.js.map +1 -0
  85. package/dist/schemas/queue-observer.d.ts +195 -0
  86. package/dist/schemas/queue-observer.d.ts.map +1 -0
  87. package/dist/schemas/queue-observer.js +190 -0
  88. package/dist/schemas/queue-observer.js.map +1 -0
  89. package/dist/schemas/run-record.d.ts +57 -0
  90. package/dist/schemas/run-record.d.ts.map +1 -0
  91. package/dist/schemas/run-record.js +108 -0
  92. package/dist/schemas/run-record.js.map +1 -0
  93. package/dist/schemas/runtime-config.d.ts +67 -0
  94. package/dist/schemas/runtime-config.d.ts.map +1 -1
  95. package/dist/schemas/runtime-config.js +75 -1
  96. package/dist/schemas/runtime-config.js.map +1 -1
  97. package/dist/schemas/signature-profile.d.ts +99 -0
  98. package/dist/schemas/signature-profile.d.ts.map +1 -0
  99. package/dist/schemas/signature-profile.js +197 -0
  100. package/dist/schemas/signature-profile.js.map +1 -0
  101. package/dist/schemas/test-map.d.ts +4 -0
  102. package/dist/schemas/test-map.d.ts.map +1 -1
  103. package/dist/schemas/test-map.js +12 -0
  104. package/dist/schemas/test-map.js.map +1 -1
  105. package/dist/schemas/verdict.d.ts +19 -4
  106. package/dist/schemas/verdict.d.ts.map +1 -1
  107. package/dist/schemas/verdict.js +42 -5
  108. package/dist/schemas/verdict.js.map +1 -1
  109. package/dist/strictness.d.ts +102 -0
  110. package/dist/strictness.d.ts.map +1 -0
  111. package/dist/strictness.js +92 -0
  112. package/dist/strictness.js.map +1 -0
  113. package/dist/supervision/index.js +6 -6
  114. package/dist/supervision/index.js.map +1 -1
  115. package/dist/twin-paths.d.ts +125 -0
  116. package/dist/twin-paths.d.ts.map +1 -0
  117. package/dist/twin-paths.js +233 -0
  118. package/dist/twin-paths.js.map +1 -0
  119. package/dist/verdict/behavior.d.ts.map +1 -1
  120. package/dist/verdict/behavior.js +284 -10
  121. package/dist/verdict/behavior.js.map +1 -1
  122. package/dist/verdict/cause.d.ts.map +1 -1
  123. package/dist/verdict/cause.js +18 -0
  124. package/dist/verdict/cause.js.map +1 -1
  125. package/dist/verdict/evaluate.d.ts +62 -0
  126. package/dist/verdict/evaluate.d.ts.map +1 -1
  127. package/dist/verdict/evaluate.js +300 -13
  128. package/dist/verdict/evaluate.js.map +1 -1
  129. package/dist/verdict/index.d.ts +3 -3
  130. package/dist/verdict/index.d.ts.map +1 -1
  131. package/dist/verdict/index.js +3 -3
  132. package/dist/verdict/index.js.map +1 -1
  133. package/dist/verdict/pack-verifiers.d.ts +17 -3
  134. package/dist/verdict/pack-verifiers.d.ts.map +1 -1
  135. package/dist/verdict/pack-verifiers.js +47 -8
  136. package/dist/verdict/pack-verifiers.js.map +1 -1
  137. package/dist/verdict/registry.d.ts +19 -0
  138. package/dist/verdict/registry.d.ts.map +1 -1
  139. package/dist/verdict/registry.js +21 -0
  140. package/dist/verdict/registry.js.map +1 -1
  141. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"evaluate.d.ts","sourceRoot":"","sources":["../../src/policy/evaluate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAsC,KAAK,YAAY,EAAiB,MAAM,sBAAsB,CAAC;AAG5G,OAAO,EAAiC,KAAK,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACtF,OAAO,EAAe,KAAK,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAmD,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGzG,4DAA4D;AAC5D,eAAO,MAAM,oBAAoB,UAAU,CAAC;AAE5C;;;;;;;GAOG;AACH,eAAO,MAAM,2BAA2B,iBAAiB,CAAC;AAK1D;;;;GAIG;AACH,qBAAa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;;;;;;;;;;kBAM9B,CAAC;AAEL,uCAAuC;AACvC,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAEpE,sEAAsE;AACtE,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAcrC,CAAC;AAEL,+CAA+C;AAC/C,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAC;AAElF;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,YAAY,EACtB,SAAS,EAAE;IACT,MAAM,EAAE,OAAO,CAAC;IAChB,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,OAAO,CAAC;IAChB,MAAM,EAAE,OAAO,CAAC;IAChB,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC;CAC3D,GACA,OAAO,CAaT;AAED,MAAM,WAAW,qBAAqB;IACpC,6CAA6C;IAC7C,KAAK,EAAE,aAAa,CAAC;IACrB,iEAAiE;IACjE,QAAQ,EAAE,UAAU,CAAC;IACrB,qEAAqE;IACrE,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC;IACjB;;;OAGG;IACH,aAAa,CAAC,EAAE,aAAa,EAAE,CAAC;CACjC;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,GAAG,sBAAsB,CAwErF"}
@@ -209,14 +209,13 @@ export function evaluatePolicies(input) {
209
209
  resourceId: resource.id,
210
210
  name: resource.name,
211
211
  detail: `resource '${resource.id ?? resource.name}' has no effective classification ` +
212
- '(the classifier blocked it definitionally); run ' +
213
- `'gateforge explain ${resource.id ?? resource.name}' for the typed ` +
214
- 'reason and its in-code resolution',
212
+ '(the classifier blocked it definitionally)',
215
213
  location: resource.location,
214
+ nextAction: 'gateforge classify --json',
216
215
  });
217
216
  continue;
218
217
  }
219
- generateObligations(resource, policyFile.policies, obligations, obligationIds);
218
+ generateObligations(resource, policyFile.policies, obligations, obligationIds, policyFile.options?.['http.endpoint.requireObservation'] === 'all');
220
219
  }
221
220
  for (const entry of input.graph.unresolved) {
222
221
  blocking.push({
@@ -264,13 +263,13 @@ export function evaluatePolicies(input) {
264
263
  * policy's required contract that the lifecycle allows, deduplicated
265
264
  * by obligation id (first matching policy owns the id).
266
265
  */
267
- function generateObligations(resource, policies, obligations, obligationIds) {
266
+ function generateObligations(resource, policies, obligations, obligationIds, observationScopeAll) {
268
267
  const classification = resource.classification;
269
268
  if (classification === null || resource.id === null)
270
269
  return;
271
270
  const exposure = classification.exposure;
272
271
  for (const policy of policies) {
273
- if (!policyMatches(policy, resource, exposure))
272
+ if (!policyMatches(policy, resource, exposure, observationScopeAll))
274
273
  continue;
275
274
  for (const contract of policy.require) {
276
275
  if (contract.startsWith(CRUD_CONTRACT_PREFIX) ||
@@ -301,7 +300,7 @@ function generateObligations(resource, policies, obligations, obligationIds) {
301
300
  }
302
301
  }
303
302
  }
304
- function policyMatches(policy, resource, exposure) {
303
+ function policyMatches(policy, resource, exposure, observationScopeAll) {
305
304
  const when = policy.when;
306
305
  if (when.kind !== undefined && when.kind !== resource.kind)
307
306
  return false;
@@ -321,14 +320,25 @@ function policyMatches(policy, resource, exposure) {
321
320
  }
322
321
  }
323
322
  if (when.consumed !== undefined) {
323
+ // Plan Phase 4c (E60): the pinned
324
+ // `http.endpoint.requireObservation: all` option widens ONLY the
325
+ // `consumed: true` matcher of an endpoint-scoped policy to the
326
+ // whole discovered route inventory, so a new route no UI calls
327
+ // owes the observation contracts too (blocking
328
+ // TEST_MAPPING_MISSING until mapped or baselined). A `consumed:
329
+ // false` policy and every non-endpoint resource are untouched —
330
+ // the option narrows nothing and adds no contract.
331
+ const observationScopeWidened = observationScopeAll && when.kind === HTTP_ENDPOINT_RESOURCE_KIND && when.consumed === true;
324
332
  // Endpoint consumption match: `true` requires the attribute to be
325
333
  // EXACTLY true; `false` matches everything else (including absent —
326
334
  // non-endpoint resources are "not consumed", never match-excluded).
327
- if (when.consumed === true && resource.attributes['frontendConsumed'] !== true) {
328
- return false;
329
- }
330
- if (when.consumed === false && resource.attributes['frontendConsumed'] === true) {
331
- return false;
335
+ if (!observationScopeWidened) {
336
+ if (when.consumed === true && resource.attributes['frontendConsumed'] !== true) {
337
+ return false;
338
+ }
339
+ if (when.consumed === false && resource.attributes['frontendConsumed'] === true) {
340
+ return false;
341
+ }
332
342
  }
333
343
  }
334
344
  return true;
@@ -1 +1 @@
1
- {"version":3,"file":"evaluate.js","sourceRoot":"","sources":["../../src/policy/evaluate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAoC,MAAM,sBAAsB,CAAC;AAC5G,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAmB,MAAM,0BAA0B,CAAC;AAC7E,OAAO,EAAE,gBAAgB,EAAgC,MAAM,sBAAsB,CAAC;AACtF,OAAO,EAAE,WAAW,EAAc,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,2BAA2B,EAA0C,MAAM,oBAAoB,CAAC;AACzG,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,4DAA4D;AAC5D,MAAM,CAAC,MAAM,oBAAoB,GAAG,OAAO,CAAC;AAE5C;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,cAAc,CAAC;AAE1D,+DAA+D;AAC/D,MAAM,eAAe,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,QA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AE,CAAC,CAAC,CAAC;AACrE,CAAC;AAED,SAAS,YAAY,CAAC,QAAyB;IAC7C,OAAO,CAAC,GAAG,QAAQ,CAAC,CAAC,IAAI,CACvB,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CACP,cAAc,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC;QAC9B,cAAc,CAAC,CAAC,CAAC,UAAU,IAAI,EAAE,EAAE,CAAC,CAAC,UAAU,IAAI,EAAE,CAAC;QACtD,cAAc,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC;QAC1C,cAAc,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,CACrC,CAAC;AACJ,CAAC;AAED,SAAS,UAAU,CAAC,MAAyB;IAC3C,OAAO,CAAC,GAAG,MAAM,CAAC,CAAC,IAAI,CACrB,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CACP,cAAc,CAAC,CAAC,CAAC,KAAK,CAAC,YAAY,EAAE,CAAC,CAAC,KAAK,CAAC,YAAY,CAAC;QAC1D,cAAc,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CACjD,CAAC;AACJ,CAAC"}
@@ -0,0 +1,82 @@
1
+ import { type Quarantine } from '../schemas/quarantine.js';
2
+ /** Maximum quarantine lifetime in days: a quarantine always expires. */
3
+ export declare const QUARANTINE_MAX_DAYS = 14;
4
+ /** The documented ceiling in milliseconds. */
5
+ export declare const QUARANTINE_MAX_DURATION_MS: number;
6
+ /** Repo-relative quarantine directory. */
7
+ export declare const QUARANTINE_DIR = ".gateforge/quarantine";
8
+ /** One fail-closed quarantine-loading problem (file-scoped, actionable). */
9
+ export interface QuarantineProblem {
10
+ /** Quarantine file the problem was found in (basename). */
11
+ file: string;
12
+ /** Single-cause human explanation. */
13
+ detail: string;
14
+ }
15
+ /** Error raised for any fail-closed quarantine configuration problem. */
16
+ export declare class GateforgeQuarantineError extends Error {
17
+ /** Every problem found, file-scoped, in deterministic order. */
18
+ readonly problems: readonly QuarantineProblem[];
19
+ constructor(problems: readonly QuarantineProblem[]);
20
+ }
21
+ /** One loaded quarantine with its file and expiry state. */
22
+ export interface LoadedQuarantine {
23
+ /** Basename of the file the record came from. */
24
+ file: string;
25
+ /** The schema-valid quarantine document. */
26
+ quarantine: Quarantine;
27
+ }
28
+ /** Result of loading a quarantine directory against the injected clock. */
29
+ export interface QuarantineLoadResult {
30
+ /** Unexpired quarantines — the required set minus these tests. */
31
+ active: LoadedQuarantine[];
32
+ /** Quarantines expired at the injected `now` — each one blocks. */
33
+ expired: LoadedQuarantine[];
34
+ }
35
+ /** Options for {@link loadQuarantines}. */
36
+ export interface QuarantineLoadOptions {
37
+ /** Injected clock instant (Date or ISO-8601) expiry is judged against. */
38
+ now: Date | string;
39
+ /** Maximum allowed lifetime; defaults to the documented 14 days. */
40
+ maxDurationMs?: number;
41
+ }
42
+ /**
43
+ * Loads and validates every `*.yml` quarantine file in `dir` (sorted by
44
+ * filename for determinism). A missing directory yields an empty result
45
+ * — most repositories have no quarantines. Any problem (unparsable
46
+ * YAML, missing mandatory field, duplicate test key, over-long duration)
47
+ * fails closed with {@link GateforgeQuarantineError}.
48
+ *
49
+ * Args:
50
+ * dir: the quarantine directory (`.gateforge/quarantine`).
51
+ * options: injected clock and optional maximum duration.
52
+ *
53
+ * Returns:
54
+ * QuarantineLoadResult: active and expired partitions, both sorted by
55
+ * test key.
56
+ *
57
+ * @throws GateforgeQuarantineError when any file fails closed.
58
+ */
59
+ export declare function loadQuarantines(dir: string, options: QuarantineLoadOptions): QuarantineLoadResult;
60
+ /**
61
+ * Serializes one quarantine document in the stable on-disk form
62
+ * (block YAML, trailing newline).
63
+ *
64
+ * Args:
65
+ * quarantine: the schema-valid document.
66
+ *
67
+ * Returns:
68
+ * string: the file content.
69
+ */
70
+ export declare function serializeQuarantine(quarantine: Quarantine): string;
71
+ /**
72
+ * Writes one quarantine document, creating parent directories as needed.
73
+ * Fail-closed: a write failure surfaces as a {@link GateforgeQuarantineError}.
74
+ *
75
+ * Args:
76
+ * path: destination file path.
77
+ * quarantine: the schema-valid document to write.
78
+ *
79
+ * @throws GateforgeQuarantineError when the file cannot be written.
80
+ */
81
+ export declare function writeQuarantine(path: string, quarantine: Quarantine): void;
82
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/quarantine/index.ts"],"names":[],"mappings":"AA0BA,OAAO,EAAoB,KAAK,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAG7E,wEAAwE;AACxE,eAAO,MAAM,mBAAmB,KAAK,CAAC;AAEtC,8CAA8C;AAC9C,eAAO,MAAM,0BAA0B,QAAmC,CAAC;AAE3E,0CAA0C;AAC1C,eAAO,MAAM,cAAc,0BAA0B,CAAC;AAEtD,4EAA4E;AAC5E,MAAM,WAAW,iBAAiB;IAChC,2DAA2D;IAC3D,IAAI,EAAE,MAAM,CAAC;IACb,sCAAsC;IACtC,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,yEAAyE;AACzE,qBAAa,wBAAyB,SAAQ,KAAK;IACjD,gEAAgE;IAChE,QAAQ,CAAC,QAAQ,EAAE,SAAS,iBAAiB,EAAE,CAAC;gBAEpC,QAAQ,EAAE,SAAS,iBAAiB,EAAE;CAQnD;AAED,4DAA4D;AAC5D,MAAM,WAAW,gBAAgB;IAC/B,iDAAiD;IACjD,IAAI,EAAE,MAAM,CAAC;IACb,4CAA4C;IAC5C,UAAU,EAAE,UAAU,CAAC;CACxB;AAED,2EAA2E;AAC3E,MAAM,WAAW,oBAAoB;IACnC,kEAAkE;IAClE,MAAM,EAAE,gBAAgB,EAAE,CAAC;IAC3B,mEAAmE;IACnE,OAAO,EAAE,gBAAgB,EAAE,CAAC;CAC7B;AAED,2CAA2C;AAC3C,MAAM,WAAW,qBAAqB;IACpC,0EAA0E;IAC1E,GAAG,EAAE,IAAI,GAAG,MAAM,CAAC;IACnB,oEAAoE;IACpE,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAwBD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,eAAe,CAC7B,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,qBAAqB,GAC7B,oBAAoB,CAoEtB;AAED;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,UAAU,GAAG,MAAM,CAUlE;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,GAAG,IAAI,CAY1E"}
@@ -0,0 +1,194 @@
1
+ /**
2
+ * Flaky-test quarantine loading.
3
+ *
4
+ * Owner-approved, always-expiring files in `.gateforge/quarantine/*.yml`
5
+ * that remove ONE test from the required set. The same trust pattern as
6
+ * waivers, with one difference in force: a quarantined test never
7
+ * FORGIVES anything — it never blocks and its evidence is never used,
8
+ * so an obligation only it covered stays `missing`.
9
+ *
10
+ * Fail-closed rules:
11
+ * - ALL FOUR attribution fields (testKey, owner, approver, reason) plus
12
+ * the expiry are mandatory; a file missing any of them is a
13
+ * configuration error, never a partially-applied exception.
14
+ * - Expiry is judged against the INJECTED clock, never the wall clock
15
+ * (invariant 7).
16
+ * - A maximum duration is enforced: a quarantine may never outlive the
17
+ * documented ceiling, so a "temporary" escape hatch cannot become
18
+ * permanent by hand-editing the expiry.
19
+ * - Two quarantines on the same test key are ambiguous → error.
20
+ *
21
+ * Loading is synchronous, matching the waivers loader.
22
+ */
23
+ import { existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync } from 'node:fs';
24
+ import { basename, dirname, join } from 'node:path';
25
+ import { parse as parseYaml, stringify as stringifyYaml } from 'yaml';
26
+ import { compareStrings } from '../graph/util.js';
27
+ import { QuarantineSchema } from '../schemas/quarantine.js';
28
+ import { parseInstant } from '../verdict/index.js';
29
+ /** Maximum quarantine lifetime in days: a quarantine always expires. */
30
+ export const QUARANTINE_MAX_DAYS = 14;
31
+ /** The documented ceiling in milliseconds. */
32
+ export const QUARANTINE_MAX_DURATION_MS = QUARANTINE_MAX_DAYS * 86_400_000;
33
+ /** Repo-relative quarantine directory. */
34
+ export const QUARANTINE_DIR = '.gateforge/quarantine';
35
+ /** Error raised for any fail-closed quarantine configuration problem. */
36
+ export class GateforgeQuarantineError extends Error {
37
+ /** Every problem found, file-scoped, in deterministic order. */
38
+ problems;
39
+ constructor(problems) {
40
+ const rendered = problems.map((problem) => ` ${problem.file}: ${problem.detail}`).join('\n');
41
+ super(`quarantine configuration failed closed with ${problems.length} problem(s):\n${rendered}`);
42
+ this.name = 'GateforgeQuarantineError';
43
+ this.problems = problems;
44
+ }
45
+ }
46
+ /**
47
+ * Parses one quarantine document (fail-closed: an empty or non-mapping
48
+ * document is a problem, never an empty quarantine).
49
+ *
50
+ * Args:
51
+ * text: the raw file content.
52
+ *
53
+ * Returns:
54
+ * unknown: the parsed YAML mapping.
55
+ *
56
+ * @throws Error when the bytes are unparsable or not a mapping.
57
+ */
58
+ function parseYamlDocument(text) {
59
+ const parsed = parseYaml(text);
60
+ if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {
61
+ throw new Error('quarantine document must be a mapping with schemaVersion, testKey, owner, approver, reason, expiresAt');
62
+ }
63
+ return parsed;
64
+ }
65
+ /**
66
+ * Loads and validates every `*.yml` quarantine file in `dir` (sorted by
67
+ * filename for determinism). A missing directory yields an empty result
68
+ * — most repositories have no quarantines. Any problem (unparsable
69
+ * YAML, missing mandatory field, duplicate test key, over-long duration)
70
+ * fails closed with {@link GateforgeQuarantineError}.
71
+ *
72
+ * Args:
73
+ * dir: the quarantine directory (`.gateforge/quarantine`).
74
+ * options: injected clock and optional maximum duration.
75
+ *
76
+ * Returns:
77
+ * QuarantineLoadResult: active and expired partitions, both sorted by
78
+ * test key.
79
+ *
80
+ * @throws GateforgeQuarantineError when any file fails closed.
81
+ */
82
+ export function loadQuarantines(dir, options) {
83
+ const now = parseInstant(options.now);
84
+ const maxDurationMs = options.maxDurationMs ?? QUARANTINE_MAX_DURATION_MS;
85
+ if (!existsSync(dir))
86
+ return { active: [], expired: [] };
87
+ const files = readdirSync(dir, { withFileTypes: true })
88
+ .filter((entry) => entry.isFile() && entry.name.endsWith('.yml'))
89
+ .map((entry) => entry.name)
90
+ .sort(compareStrings);
91
+ const problems = [];
92
+ const parsed = [];
93
+ for (const file of files) {
94
+ let document;
95
+ try {
96
+ document = parseYamlDocument(readFileSync(join(dir, file), 'utf8'));
97
+ }
98
+ catch (error) {
99
+ problems.push({
100
+ file,
101
+ detail: `not parsable YAML: ${error instanceof Error ? error.message : String(error)}`,
102
+ });
103
+ continue;
104
+ }
105
+ const result = QuarantineSchema.safeParse(document);
106
+ if (!result.success) {
107
+ for (const issue of result.error.issues) {
108
+ problems.push({ file, detail: `${issue.path.join('.') || '<quarantine>'}: ${issue.message}` });
109
+ }
110
+ continue;
111
+ }
112
+ const duration = Date.parse(result.data.expiresAt) - now.getTime();
113
+ if (duration > maxDurationMs) {
114
+ problems.push({
115
+ file,
116
+ detail: `expiresAt '${result.data.expiresAt}' exceeds the maximum quarantine duration ` +
117
+ `(${String(Math.round(maxDurationMs / 86_400_000))} days from now)`,
118
+ });
119
+ continue;
120
+ }
121
+ parsed.push({ file, quarantine: result.data });
122
+ }
123
+ const byTestKey = new Map();
124
+ for (const entry of parsed) {
125
+ const firstFile = byTestKey.get(entry.quarantine.testKey);
126
+ if (firstFile !== undefined) {
127
+ problems.push({
128
+ file: entry.file,
129
+ detail: `test key '${entry.quarantine.testKey}' is already quarantined by '${firstFile}' — ` +
130
+ 'one quarantine per test, never two overlapping exceptions',
131
+ });
132
+ continue;
133
+ }
134
+ byTestKey.set(entry.quarantine.testKey, entry.file);
135
+ }
136
+ if (problems.length > 0)
137
+ throw new GateforgeQuarantineError(problems);
138
+ const active = [];
139
+ const expired = [];
140
+ for (const entry of parsed) {
141
+ if (now.getTime() >= Date.parse(entry.quarantine.expiresAt))
142
+ expired.push(entry);
143
+ else
144
+ active.push(entry);
145
+ }
146
+ const byTest = (a, b) => compareStrings(a.quarantine.testKey, b.quarantine.testKey);
147
+ return { active: [...active].sort(byTest), expired: [...expired].sort(byTest) };
148
+ }
149
+ /**
150
+ * Serializes one quarantine document in the stable on-disk form
151
+ * (block YAML, trailing newline).
152
+ *
153
+ * Args:
154
+ * quarantine: the schema-valid document.
155
+ *
156
+ * Returns:
157
+ * string: the file content.
158
+ */
159
+ export function serializeQuarantine(quarantine) {
160
+ const body = stringifyYaml({
161
+ schemaVersion: quarantine.schemaVersion,
162
+ testKey: quarantine.testKey,
163
+ owner: quarantine.owner,
164
+ approver: quarantine.approver,
165
+ reason: quarantine.reason,
166
+ expiresAt: quarantine.expiresAt,
167
+ });
168
+ return `${body.endsWith('\n') ? body : `${body}\n`}`;
169
+ }
170
+ /**
171
+ * Writes one quarantine document, creating parent directories as needed.
172
+ * Fail-closed: a write failure surfaces as a {@link GateforgeQuarantineError}.
173
+ *
174
+ * Args:
175
+ * path: destination file path.
176
+ * quarantine: the schema-valid document to write.
177
+ *
178
+ * @throws GateforgeQuarantineError when the file cannot be written.
179
+ */
180
+ export function writeQuarantine(path, quarantine) {
181
+ try {
182
+ mkdirSync(dirname(path), { recursive: true });
183
+ writeFileSync(path, serializeQuarantine(quarantine), 'utf8');
184
+ }
185
+ catch (error) {
186
+ throw new GateforgeQuarantineError([
187
+ {
188
+ file: basename(path),
189
+ detail: `could not be written: ${error instanceof Error ? error.message : String(error)}`,
190
+ },
191
+ ]);
192
+ }
193
+ }
194
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/quarantine/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,YAAY,EAAE,aAAa,EAA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B,KAAK,EAAE,UAAU,CAAC,KAAK;QACvB,QAAQ,EAAE,UAAU,CAAC,QAAQ;QAC7B,MAAM,EAAE,UAAU,CAAC,MAAM;QACzB,SAAS,EAAE,UAAU,CAAC,SAAS;KAChC,CAAC,CAAC;IACH,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,EAAE,CAAC;AACvD,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,eAAe,CAAC,IAAY,EAAE,UAAsB;IAClE,IAAI,CAAC;QACH,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAC9C,aAAa,CAAC,IAAI,EAAE,mBAAmB,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC,CAAC;IAC/D,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,wBAAwB,CAAC;YACjC;gBACE,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC;gBACpB,MAAM,EAAE,yBAAyB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;aAC1F;SACF,CAAC,CAAC;IACL,CAAC;AACH,CAAC"}
@@ -1,6 +1,8 @@
1
1
  import { type JsonValue } from '../canonical-json.js';
2
- import { type GateReceipt } from '../schemas/gate-receipt.js';
3
2
  import { EMPTY_BEHAVIOR_CATALOG_DIGEST } from '../policy/behavior.js';
3
+ import { type GateReceipt } from '../schemas/gate-receipt.js';
4
+ import type { ExecutedOutcome } from '../schemas/execution-result.js';
5
+ import { type RunRecord, type RunRecordBody } from '../schemas/run-record.js';
4
6
  /** Domain tag binding receipt MACs to the gate-receipt envelope format. */
5
7
  export declare const RECEIPT_DOMAIN = "gateforge.receipt.v2";
6
8
  /** The only receipt envelope version this code produces or honors. */
@@ -63,6 +65,68 @@ export { EMPTY_BEHAVIOR_CATALOG_DIGEST };
63
65
  * TypeError: when the verifier key is empty.
64
66
  */
65
67
  export declare function gateReceiptMac(verifierKey: string, body: GateReceiptBody): string;
68
+ /**
69
+ * Digest over a run's per-test outcomes, in the sealed order. A run
70
+ * record binds it so the record can never claim a cleaner run than the
71
+ * execution result it names, and a consumer recomputes it from that
72
+ * execution result when it recomputes the re-seal.
73
+ *
74
+ * Args:
75
+ * outcomes: the sealed execution result's per-test outcomes.
76
+ *
77
+ * Returns:
78
+ * string: 64-char lowercase hex digest.
79
+ */
80
+ export declare function testOutcomesDigestOf(outcomes: readonly ExecutedOutcome[]): string;
81
+ /** Domain tag binding run-record MACs to the run-record envelope format. */
82
+ export declare const RUN_RECORD_DOMAIN = "gateforge.run-record.v1";
83
+ /** The only run-record envelope version this code produces or honors. */
84
+ export declare const RUN_RECORD_VERSION = 1;
85
+ /**
86
+ * Computes the run-record MAC: HMAC-SHA256 over the GF-canonical JSON
87
+ * of `{domain: 'gateforge.run-record.v1', ...body}` keyed by the same
88
+ * witness verifier key a receipt uses. The distinct domain tag makes
89
+ * cross-format acceptance impossible in both directions: a run record
90
+ * can never verify as a gate receipt, and a receipt MAC can never
91
+ * verify as a run record.
92
+ *
93
+ * Args:
94
+ * verifierKey: the witness verifier secret (non-empty).
95
+ * body: the unsigned run-record body.
96
+ *
97
+ * Returns:
98
+ * string: 64-char lowercase hex HMAC.
99
+ *
100
+ * Throws:
101
+ * TypeError: when the verifier key is empty.
102
+ */
103
+ export declare function runRecordMac(verifierKey: string, body: RunRecordBody): string;
104
+ /** Typed reasons a run-record candidate failed verification (fail closed). */
105
+ export type RunRecordRejection = 'missing' | 'malformed' | 'mac-fail' | 'not-whole-suite';
106
+ /** The verification outcome: a validated run record or a typed rejection. */
107
+ export type RunRecordVerification = {
108
+ ok: true;
109
+ record: RunRecord;
110
+ } | {
111
+ ok: false;
112
+ rejection: RunRecordRejection;
113
+ detail: string;
114
+ };
115
+ /**
116
+ * Verifies a run-record candidate end to end (fail closed): the strict
117
+ * schema first, then the MAC under the given verifier key. A run record
118
+ * authenticates EXACTLY this much and no more — it carries no gate
119
+ * verdict, so there is nothing here to grade, compare against a policy
120
+ * pin, or accept as proof for a blocked gate.
121
+ *
122
+ * Args:
123
+ * verifierKey: the witness verifier secret the record must carry a MAC for.
124
+ * candidate: the parsed run-state document.
125
+ *
126
+ * Returns:
127
+ * RunRecordVerification: the validated record or the typed rejection.
128
+ */
129
+ export declare function verifyRunRecord(verifierKey: string, candidate: unknown): RunRecordVerification;
66
130
  /** Typed reasons a receipt candidate failed verification (fail closed). */
67
131
  export type ReceiptRejection = 'missing' | 'malformed' | 'mac-fail' | 'input-digest-mismatch' | 'policy-digest-mismatch' | 'selection-digest-mismatch' | 'catalog-digest-mismatch' | 'execution-digest-mismatch' | 'attestation-digest-mismatch' | 'tree-mismatch' | 'behavior-digest-mismatch' | 'case-set-mismatch' | 'case-execution-mismatch' | 'engine-bundle-mismatch' | 'boundary-mismatch' | 'artifact-mismatch' | 'not-clean';
68
132
  /** The verification outcome: a validated receipt or a typed rejection. */
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/receipt/index.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAkC,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtF,OAAO,EAAqB,KAAK,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACjF,OAAO,EAAE,6BAA6B,EAAE,MAAM,uBAAuB,CAAC;AAEtE,2EAA2E;AAC3E,eAAO,MAAM,cAAc,yBAAyB,CAAC;AAErD,sEAAsE;AACtE,eAAO,MAAM,eAAe,IAAI,CAAC;AAKjC,6DAA6D;AAC7D,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;AAEvD,gFAAgF;AAChF,eAAO,MAAM,8BAA8B,QAGzC,CAAC;AAEH,uEAAuE;AACvE,eAA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1C,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B"}
@@ -15,8 +15,9 @@
15
15
  */
16
16
  import { createHmac, timingSafeEqual } from 'node:crypto';
17
17
  import { canonicalJson, sha256Canonical } from '../canonical-json.js';
18
- import { GateReceiptSchema } from '../schemas/gate-receipt.js';
19
18
  import { EMPTY_BEHAVIOR_CATALOG_DIGEST } from '../policy/behavior.js';
19
+ import { GateReceiptSchema } from '../schemas/gate-receipt.js';
20
+ import { RunRecordSchema } from '../schemas/run-record.js';
20
21
  /** Domain tag binding receipt MACs to the gate-receipt envelope format. */
21
22
  export const RECEIPT_DOMAIN = 'gateforge.receipt.v2';
22
23
  /** The only receipt envelope version this code produces or honors. */
@@ -127,6 +128,119 @@ export function gateReceiptMac(verifierKey, body) {
127
128
  }))
128
129
  .digest('hex');
129
130
  }
131
+ /**
132
+ * Digest over a run's per-test outcomes, in the sealed order. A run
133
+ * record binds it so the record can never claim a cleaner run than the
134
+ * execution result it names, and a consumer recomputes it from that
135
+ * execution result when it recomputes the re-seal.
136
+ *
137
+ * Args:
138
+ * outcomes: the sealed execution result's per-test outcomes.
139
+ *
140
+ * Returns:
141
+ * string: 64-char lowercase hex digest.
142
+ */
143
+ export function testOutcomesDigestOf(outcomes) {
144
+ return sha256Canonical(outcomes);
145
+ }
146
+ /** Domain tag binding run-record MACs to the run-record envelope format. */
147
+ export const RUN_RECORD_DOMAIN = 'gateforge.run-record.v1';
148
+ /** The only run-record envelope version this code produces or honors. */
149
+ export const RUN_RECORD_VERSION = 1;
150
+ /**
151
+ * Computes the run-record MAC: HMAC-SHA256 over the GF-canonical JSON
152
+ * of `{domain: 'gateforge.run-record.v1', ...body}` keyed by the same
153
+ * witness verifier key a receipt uses. The distinct domain tag makes
154
+ * cross-format acceptance impossible in both directions: a run record
155
+ * can never verify as a gate receipt, and a receipt MAC can never
156
+ * verify as a run record.
157
+ *
158
+ * Args:
159
+ * verifierKey: the witness verifier secret (non-empty).
160
+ * body: the unsigned run-record body.
161
+ *
162
+ * Returns:
163
+ * string: 64-char lowercase hex HMAC.
164
+ *
165
+ * Throws:
166
+ * TypeError: when the verifier key is empty.
167
+ */
168
+ export function runRecordMac(verifierKey, body) {
169
+ if (typeof verifierKey !== 'string' || verifierKey.length === 0) {
170
+ throw new TypeError('runRecordMac: verifier key must be a non-empty string');
171
+ }
172
+ return createHmac('sha256', verifierKey)
173
+ .update(canonicalJson({
174
+ domain: RUN_RECORD_DOMAIN,
175
+ ...body,
176
+ }))
177
+ .digest('hex');
178
+ }
179
+ /**
180
+ * Verifies a run-record candidate end to end (fail closed): the strict
181
+ * schema first, then the MAC under the given verifier key. A run record
182
+ * authenticates EXACTLY this much and no more — it carries no gate
183
+ * verdict, so there is nothing here to grade, compare against a policy
184
+ * pin, or accept as proof for a blocked gate.
185
+ *
186
+ * Args:
187
+ * verifierKey: the witness verifier secret the record must carry a MAC for.
188
+ * candidate: the parsed run-state document.
189
+ *
190
+ * Returns:
191
+ * RunRecordVerification: the validated record or the typed rejection.
192
+ */
193
+ export function verifyRunRecord(verifierKey, candidate) {
194
+ if (candidate === undefined || candidate === null) {
195
+ return { ok: false, rejection: 'missing', detail: 'run record is missing' };
196
+ }
197
+ const parsed = RunRecordSchema.safeParse(candidate);
198
+ if (!parsed.success) {
199
+ const issue = parsed.error.issues[0];
200
+ const path = issue === undefined ? '' : ` at '${issue.path.map(String).join('.')}':`;
201
+ return {
202
+ ok: false,
203
+ rejection: 'malformed',
204
+ detail: `run record is malformed${path} ${issue?.message ?? 'unknown schema error'}`,
205
+ };
206
+ }
207
+ const record = parsed.data;
208
+ const { mac, ...body } = record;
209
+ if (typeof verifierKey !== 'string' || verifierKey.length === 0) {
210
+ return {
211
+ ok: false,
212
+ rejection: 'mac-fail',
213
+ detail: 'run record cannot verify without a verifier key (fail closed)',
214
+ };
215
+ }
216
+ if (!MAC_PATTERN.test(mac)) {
217
+ return { ok: false, rejection: 'mac-fail', detail: 'run record mac is malformed' };
218
+ }
219
+ let expectedMac;
220
+ let claimedMac;
221
+ try {
222
+ expectedMac = Buffer.from(runRecordMac(verifierKey, body), 'hex');
223
+ claimedMac = Buffer.from(mac, 'hex');
224
+ }
225
+ catch {
226
+ return { ok: false, rejection: 'mac-fail', detail: 'run record mac could not be recomputed' };
227
+ }
228
+ if (expectedMac.length !== claimedMac.length || !timingSafeEqual(expectedMac, claimedMac)) {
229
+ return {
230
+ ok: false,
231
+ rejection: 'mac-fail',
232
+ detail: 'run record signature fails; the record was forged or tampered with (fail closed)',
233
+ };
234
+ }
235
+ if (record.plannedTests === 0) {
236
+ return {
237
+ ok: false,
238
+ rejection: 'not-whole-suite',
239
+ detail: 'run record holds no planned test, so it proves no whole-suite run',
240
+ };
241
+ }
242
+ return { ok: true, record };
243
+ }
130
244
  /**
131
245
  * Verifies a receipt candidate end-to-end (fail closed):
132
246
  * 1. structural — the value must parse against the strict v1 schema;