@neurcode-ai/cli 0.10.1 → 0.12.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 (171) hide show
  1. package/.telemetry-bundle/dist/contracts.d.ts +1 -1
  2. package/README.md +74 -25
  3. package/dist/commands/remediate-export.js +1 -1
  4. package/dist/commands/replay.d.ts.map +1 -1
  5. package/dist/commands/replay.js +36 -0
  6. package/dist/commands/replay.js.map +1 -1
  7. package/dist/commands/verify-output.d.ts.map +1 -1
  8. package/dist/commands/verify-output.js +66 -4
  9. package/dist/commands/verify-output.js.map +1 -1
  10. package/dist/commands/verify.d.ts +22 -1
  11. package/dist/commands/verify.d.ts.map +1 -1
  12. package/dist/commands/verify.js +446 -34
  13. package/dist/commands/verify.js.map +1 -1
  14. package/dist/daemon/server.d.ts.map +1 -1
  15. package/dist/daemon/server.js +4 -0
  16. package/dist/daemon/server.js.map +1 -1
  17. package/dist/governance/intent/drift-detector.d.ts +100 -0
  18. package/dist/governance/intent/drift-detector.d.ts.map +1 -0
  19. package/dist/governance/intent/drift-detector.js +275 -0
  20. package/dist/governance/intent/drift-detector.js.map +1 -0
  21. package/dist/governance/intent/glob-match.d.ts +43 -0
  22. package/dist/governance/intent/glob-match.d.ts.map +1 -0
  23. package/dist/governance/intent/glob-match.js +108 -0
  24. package/dist/governance/intent/glob-match.js.map +1 -0
  25. package/dist/governance/intent/import-graph.d.ts +56 -0
  26. package/dist/governance/intent/import-graph.d.ts.map +1 -0
  27. package/dist/governance/intent/import-graph.js +133 -0
  28. package/dist/governance/intent/import-graph.js.map +1 -0
  29. package/dist/governance/intent/index.d.ts +23 -0
  30. package/dist/governance/intent/index.d.ts.map +1 -0
  31. package/dist/governance/intent/index.js +48 -0
  32. package/dist/governance/intent/index.js.map +1 -0
  33. package/dist/governance/intent/intelligence-boundaries.d.ts +69 -0
  34. package/dist/governance/intent/intelligence-boundaries.d.ts.map +1 -0
  35. package/dist/governance/intent/intelligence-boundaries.js +163 -0
  36. package/dist/governance/intent/intelligence-boundaries.js.map +1 -0
  37. package/dist/governance/intent/intent-contract.d.ts +76 -0
  38. package/dist/governance/intent/intent-contract.d.ts.map +1 -0
  39. package/dist/governance/intent/intent-contract.js +397 -0
  40. package/dist/governance/intent/intent-contract.js.map +1 -0
  41. package/dist/governance/intent/intent-graph.d.ts +135 -0
  42. package/dist/governance/intent/intent-graph.d.ts.map +1 -0
  43. package/dist/governance/intent/intent-graph.js +67 -0
  44. package/dist/governance/intent/intent-graph.js.map +1 -0
  45. package/dist/governance/pipeline/computation-trace.d.ts +52 -0
  46. package/dist/governance/pipeline/computation-trace.d.ts.map +1 -0
  47. package/dist/governance/pipeline/computation-trace.js +79 -0
  48. package/dist/governance/pipeline/computation-trace.js.map +1 -0
  49. package/dist/governance/pipeline/envelope-assembly.d.ts +132 -0
  50. package/dist/governance/pipeline/envelope-assembly.d.ts.map +1 -0
  51. package/dist/governance/pipeline/envelope-assembly.js +140 -0
  52. package/dist/governance/pipeline/envelope-assembly.js.map +1 -0
  53. package/dist/governance/pipeline/fingerprint.d.ts +34 -0
  54. package/dist/governance/pipeline/fingerprint.d.ts.map +1 -0
  55. package/dist/governance/pipeline/fingerprint.js +78 -0
  56. package/dist/governance/pipeline/fingerprint.js.map +1 -0
  57. package/dist/governance/pipeline/helpers.d.ts +74 -0
  58. package/dist/governance/pipeline/helpers.d.ts.map +1 -0
  59. package/dist/governance/pipeline/helpers.js +112 -0
  60. package/dist/governance/pipeline/helpers.js.map +1 -0
  61. package/dist/governance/pipeline/index.d.ts +27 -0
  62. package/dist/governance/pipeline/index.d.ts.map +1 -0
  63. package/dist/governance/pipeline/index.js +63 -0
  64. package/dist/governance/pipeline/index.js.map +1 -0
  65. package/dist/governance/pipeline/lineage.d.ts +26 -0
  66. package/dist/governance/pipeline/lineage.d.ts.map +1 -0
  67. package/dist/governance/pipeline/lineage.js +51 -0
  68. package/dist/governance/pipeline/lineage.js.map +1 -0
  69. package/dist/governance/pipeline/orchestration/advisory-mode-contract.d.ts +15 -0
  70. package/dist/governance/pipeline/orchestration/advisory-mode-contract.d.ts.map +1 -0
  71. package/dist/governance/pipeline/orchestration/advisory-mode-contract.js +44 -0
  72. package/dist/governance/pipeline/orchestration/advisory-mode-contract.js.map +1 -0
  73. package/dist/governance/pipeline/orchestration/advisory-mode.d.ts +102 -0
  74. package/dist/governance/pipeline/orchestration/advisory-mode.d.ts.map +1 -0
  75. package/dist/governance/pipeline/orchestration/advisory-mode.js +170 -0
  76. package/dist/governance/pipeline/orchestration/advisory-mode.js.map +1 -0
  77. package/dist/governance/pipeline/orchestration/evidence-lifecycle.d.ts +133 -0
  78. package/dist/governance/pipeline/orchestration/evidence-lifecycle.d.ts.map +1 -0
  79. package/dist/governance/pipeline/orchestration/evidence-lifecycle.js +125 -0
  80. package/dist/governance/pipeline/orchestration/evidence-lifecycle.js.map +1 -0
  81. package/dist/governance/pipeline/orchestration/index.d.ts +16 -0
  82. package/dist/governance/pipeline/orchestration/index.d.ts.map +1 -0
  83. package/dist/governance/pipeline/orchestration/index.js +30 -0
  84. package/dist/governance/pipeline/orchestration/index.js.map +1 -0
  85. package/dist/governance/pipeline/orchestration/intent-drift-orchestration.d.ts +65 -0
  86. package/dist/governance/pipeline/orchestration/intent-drift-orchestration.d.ts.map +1 -0
  87. package/dist/governance/pipeline/orchestration/intent-drift-orchestration.js +102 -0
  88. package/dist/governance/pipeline/orchestration/intent-drift-orchestration.js.map +1 -0
  89. package/dist/governance/pipeline/orchestration/plan-structural-analysis.d.ts +41 -0
  90. package/dist/governance/pipeline/orchestration/plan-structural-analysis.d.ts.map +1 -0
  91. package/dist/governance/pipeline/orchestration/plan-structural-analysis.js +74 -0
  92. package/dist/governance/pipeline/orchestration/plan-structural-analysis.js.map +1 -0
  93. package/dist/governance/pipeline/orchestration/policy-evaluation-summaries.d.ts +165 -0
  94. package/dist/governance/pipeline/orchestration/policy-evaluation-summaries.d.ts.map +1 -0
  95. package/dist/governance/pipeline/orchestration/policy-evaluation-summaries.js +160 -0
  96. package/dist/governance/pipeline/orchestration/policy-evaluation-summaries.js.map +1 -0
  97. package/dist/governance/pipeline/orchestration/scope-guard-orchestration.d.ts +152 -0
  98. package/dist/governance/pipeline/orchestration/scope-guard-orchestration.d.ts.map +1 -0
  99. package/dist/governance/pipeline/orchestration/scope-guard-orchestration.js +188 -0
  100. package/dist/governance/pipeline/orchestration/scope-guard-orchestration.js.map +1 -0
  101. package/dist/governance/pipeline/runtime.d.ts +70 -0
  102. package/dist/governance/pipeline/runtime.d.ts.map +1 -0
  103. package/dist/governance/pipeline/runtime.js +223 -0
  104. package/dist/governance/pipeline/runtime.js.map +1 -0
  105. package/dist/governance/pipeline/shared-types.d.ts +7 -0
  106. package/dist/governance/pipeline/shared-types.d.ts.map +1 -0
  107. package/dist/governance/pipeline/shared-types.js +7 -0
  108. package/dist/governance/pipeline/shared-types.js.map +1 -0
  109. package/dist/governance/pipeline/stages/compiled-policy-stage.d.ts +28 -0
  110. package/dist/governance/pipeline/stages/compiled-policy-stage.d.ts.map +1 -0
  111. package/dist/governance/pipeline/stages/compiled-policy-stage.js +53 -0
  112. package/dist/governance/pipeline/stages/compiled-policy-stage.js.map +1 -0
  113. package/dist/governance/pipeline/stages/diff-normalization-stage.d.ts +63 -0
  114. package/dist/governance/pipeline/stages/diff-normalization-stage.d.ts.map +1 -0
  115. package/dist/governance/pipeline/stages/diff-normalization-stage.js +140 -0
  116. package/dist/governance/pipeline/stages/diff-normalization-stage.js.map +1 -0
  117. package/dist/governance/pipeline/stages/governance-synthesis-stage.d.ts +53 -0
  118. package/dist/governance/pipeline/stages/governance-synthesis-stage.d.ts.map +1 -0
  119. package/dist/governance/pipeline/stages/governance-synthesis-stage.js +129 -0
  120. package/dist/governance/pipeline/stages/governance-synthesis-stage.js.map +1 -0
  121. package/dist/governance/pipeline/stages/index.d.ts +29 -0
  122. package/dist/governance/pipeline/stages/index.d.ts.map +1 -0
  123. package/dist/governance/pipeline/stages/index.js +40 -0
  124. package/dist/governance/pipeline/stages/index.js.map +1 -0
  125. package/dist/governance/pipeline/stages/policy-lock-stage.d.ts +31 -0
  126. package/dist/governance/pipeline/stages/policy-lock-stage.d.ts.map +1 -0
  127. package/dist/governance/pipeline/stages/policy-lock-stage.js +71 -0
  128. package/dist/governance/pipeline/stages/policy-lock-stage.js.map +1 -0
  129. package/dist/governance/pipeline/stages/runtime-guard-stage.d.ts +29 -0
  130. package/dist/governance/pipeline/stages/runtime-guard-stage.d.ts.map +1 -0
  131. package/dist/governance/pipeline/stages/runtime-guard-stage.js +65 -0
  132. package/dist/governance/pipeline/stages/runtime-guard-stage.js.map +1 -0
  133. package/dist/governance/pipeline/stages/structural-analysis-stage.d.ts +24 -0
  134. package/dist/governance/pipeline/stages/structural-analysis-stage.d.ts.map +1 -0
  135. package/dist/governance/pipeline/stages/structural-analysis-stage.js +58 -0
  136. package/dist/governance/pipeline/stages/structural-analysis-stage.js.map +1 -0
  137. package/dist/governance/pipeline/summary.d.ts +14 -0
  138. package/dist/governance/pipeline/summary.d.ts.map +1 -0
  139. package/dist/governance/pipeline/summary.js +50 -0
  140. package/dist/governance/pipeline/summary.js.map +1 -0
  141. package/dist/governance/pipeline/types.d.ts +69 -0
  142. package/dist/governance/pipeline/types.d.ts.map +1 -0
  143. package/dist/governance/pipeline/types.js +30 -0
  144. package/dist/governance/pipeline/types.js.map +1 -0
  145. package/dist/index.js +29 -0
  146. package/dist/index.js.map +1 -1
  147. package/dist/utils/active-engineering-context.d.ts +16 -0
  148. package/dist/utils/active-engineering-context.d.ts.map +1 -1
  149. package/dist/utils/active-engineering-context.js +302 -0
  150. package/dist/utils/active-engineering-context.js.map +1 -1
  151. package/dist/utils/import-edge-classifier.d.ts +76 -0
  152. package/dist/utils/import-edge-classifier.d.ts.map +1 -0
  153. package/dist/utils/import-edge-classifier.js +308 -0
  154. package/dist/utils/import-edge-classifier.js.map +1 -0
  155. package/dist/utils/import-edge-extractor.d.ts +52 -0
  156. package/dist/utils/import-edge-extractor.d.ts.map +1 -0
  157. package/dist/utils/import-edge-extractor.js +223 -0
  158. package/dist/utils/import-edge-extractor.js.map +1 -0
  159. package/dist/utils/import-edge-governance.d.ts +37 -0
  160. package/dist/utils/import-edge-governance.d.ts.map +1 -0
  161. package/dist/utils/import-edge-governance.js +56 -0
  162. package/dist/utils/import-edge-governance.js.map +1 -0
  163. package/dist/utils/path-boundary-classifier.d.ts +42 -0
  164. package/dist/utils/path-boundary-classifier.d.ts.map +1 -0
  165. package/dist/utils/path-boundary-classifier.js +143 -0
  166. package/dist/utils/path-boundary-classifier.js.map +1 -0
  167. package/dist/utils/replay-html-report.d.ts +29 -0
  168. package/dist/utils/replay-html-report.d.ts.map +1 -0
  169. package/dist/utils/replay-html-report.js +309 -0
  170. package/dist/utils/replay-html-report.js.map +1 -0
  171. package/package.json +2 -2
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Governance computation trace surface.
3
+ *
4
+ * Produces a compact, human-readable summary of HOW a verify run computed
5
+ * its governance verdict. The trace is derived entirely from the pipeline
6
+ * ledger — no re-computation, no re-inspection. Pure observability.
7
+ *
8
+ * Audience:
9
+ * - dashboards rendering an explainability column
10
+ * - audit / replay reviewers who want a one-screen narrative
11
+ * - operators triaging degraded or failed governance runs
12
+ *
13
+ * Constraints:
14
+ * - Deterministic given the same ledger.
15
+ * - No PII or excerpts — only stage IDs, statuses, fingerprints.
16
+ * - Bounded length: at most one line per stage plus a header.
17
+ */
18
+ import type { GovernanceStageId, GovernanceStageResult, GovernanceStageStatus } from '@neurcode-ai/contracts';
19
+ export interface GovernanceComputationTrace {
20
+ /** One-line summary suitable for a dashboard header. */
21
+ headline: string;
22
+ /** Detail rows; one per stage, in canonical execution order. */
23
+ rows: GovernanceComputationTraceRow[];
24
+ /** Stage IDs of stages that did not reach 'succeeded'. */
25
+ notableStages: GovernanceStageId[];
26
+ }
27
+ export interface GovernanceComputationTraceRow {
28
+ stageId: GovernanceStageId;
29
+ status: GovernanceStageStatus;
30
+ determinism: string;
31
+ durationMs: number;
32
+ outputFingerprintShort: string | null;
33
+ dependsOn: GovernanceStageId[];
34
+ failureCategory?: string;
35
+ }
36
+ /**
37
+ * Build a deterministic computation trace from a pipeline ledger.
38
+ *
39
+ * The trace renders the same way for the same ledger across runs and
40
+ * machines. Wall-clock durations are reported but never used in headlines
41
+ * (they would non-determinize the trace).
42
+ */
43
+ export declare function buildComputationTrace(ledger: readonly GovernanceStageResult[]): GovernanceComputationTrace;
44
+ /**
45
+ * Render a computation trace as a deterministic multi-line text block.
46
+ *
47
+ * Output format is stable across runs given the same ledger (durations are
48
+ * truncated to integer milliseconds; nothing else is wall-clock-dependent).
49
+ * Suitable for embedding in --explain output or in CI logs.
50
+ */
51
+ export declare function renderComputationTrace(trace: GovernanceComputationTrace): string;
52
+ //# sourceMappingURL=computation-trace.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"computation-trace.d.ts","sourceRoot":"","sources":["../../../src/governance/pipeline/computation-trace.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EACV,iBAAiB,EACjB,qBAAqB,EACrB,qBAAqB,EACtB,MAAM,wBAAwB,CAAC;AAEhC,MAAM,WAAW,0BAA0B;IACzC,wDAAwD;IACxD,QAAQ,EAAE,MAAM,CAAC;IACjB,gEAAgE;IAChE,IAAI,EAAE,6BAA6B,EAAE,CAAC;IACtC,0DAA0D;IAC1D,aAAa,EAAE,iBAAiB,EAAE,CAAC;CACpC;AAED,MAAM,WAAW,6BAA6B;IAC5C,OAAO,EAAE,iBAAiB,CAAC;IAC3B,MAAM,EAAE,qBAAqB,CAAC;IAC9B,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,sBAAsB,EAAE,MAAM,GAAG,IAAI,CAAC;IACtC,SAAS,EAAE,iBAAiB,EAAE,CAAC;IAC/B,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,SAAS,qBAAqB,EAAE,GACvC,0BAA0B,CAgC5B;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,0BAA0B,GAChC,MAAM,CAaR"}
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ /**
3
+ * Governance computation trace surface.
4
+ *
5
+ * Produces a compact, human-readable summary of HOW a verify run computed
6
+ * its governance verdict. The trace is derived entirely from the pipeline
7
+ * ledger — no re-computation, no re-inspection. Pure observability.
8
+ *
9
+ * Audience:
10
+ * - dashboards rendering an explainability column
11
+ * - audit / replay reviewers who want a one-screen narrative
12
+ * - operators triaging degraded or failed governance runs
13
+ *
14
+ * Constraints:
15
+ * - Deterministic given the same ledger.
16
+ * - No PII or excerpts — only stage IDs, statuses, fingerprints.
17
+ * - Bounded length: at most one line per stage plus a header.
18
+ */
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ exports.buildComputationTrace = buildComputationTrace;
21
+ exports.renderComputationTrace = renderComputationTrace;
22
+ /**
23
+ * Build a deterministic computation trace from a pipeline ledger.
24
+ *
25
+ * The trace renders the same way for the same ledger across runs and
26
+ * machines. Wall-clock durations are reported but never used in headlines
27
+ * (they would non-determinize the trace).
28
+ */
29
+ function buildComputationTrace(ledger) {
30
+ const rows = ledger.map((entry) => ({
31
+ stageId: entry.stageId,
32
+ status: entry.status,
33
+ determinism: entry.replay.determinism,
34
+ durationMs: entry.metrics.durationMs,
35
+ outputFingerprintShort: entry.replay.outputFingerprint
36
+ ? entry.replay.outputFingerprint.slice(0, 12)
37
+ : null,
38
+ dependsOn: [...entry.replay.dependsOn],
39
+ failureCategory: entry.failure?.category,
40
+ }));
41
+ const notableStages = ledger
42
+ .filter((e) => e.status !== 'succeeded')
43
+ .map((e) => e.stageId);
44
+ const succeededCount = ledger.filter((e) => e.status === 'succeeded').length;
45
+ const totalCount = ledger.length;
46
+ let headline;
47
+ if (totalCount === 0) {
48
+ headline = 'governance pipeline: no stages executed';
49
+ }
50
+ else if (notableStages.length === 0) {
51
+ headline = `governance pipeline: ${totalCount} stage(s) succeeded`;
52
+ }
53
+ else {
54
+ headline =
55
+ `governance pipeline: ${succeededCount}/${totalCount} succeeded; ` +
56
+ `${notableStages.length} stage(s) did not succeed`;
57
+ }
58
+ return { headline, rows, notableStages };
59
+ }
60
+ /**
61
+ * Render a computation trace as a deterministic multi-line text block.
62
+ *
63
+ * Output format is stable across runs given the same ledger (durations are
64
+ * truncated to integer milliseconds; nothing else is wall-clock-dependent).
65
+ * Suitable for embedding in --explain output or in CI logs.
66
+ */
67
+ function renderComputationTrace(trace) {
68
+ const lines = [];
69
+ lines.push(trace.headline);
70
+ for (const row of trace.rows) {
71
+ const fp = row.outputFingerprintShort ?? '-';
72
+ const deps = row.dependsOn.length > 0 ? ` ← [${row.dependsOn.join(', ')}]` : '';
73
+ const failure = row.failureCategory ? ` (failure: ${row.failureCategory})` : '';
74
+ lines.push(` • ${row.stageId.padEnd(28)} ${row.status.padEnd(10)} ` +
75
+ `${row.determinism.padEnd(28)} fp=${fp}${deps}${failure}`);
76
+ }
77
+ return lines.join('\n');
78
+ }
79
+ //# sourceMappingURL=computation-trace.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"computation-trace.js","sourceRoot":"","sources":["../../../src/governance/pipeline/computation-trace.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;GAgBG;;AAkCH,sDAkCC;AASD,wDAeC;AAjED;;;;;;GAMG;AACH,SAAgB,qBAAqB,CACnC,MAAwC;IAExC,MAAM,IAAI,GAAoC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QACnE,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,WAAW,EAAE,KAAK,CAAC,MAAM,CAAC,WAAW;QACrC,UAAU,EAAE,KAAK,CAAC,OAAO,CAAC,UAAU;QACpC,s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,QAAQ,CAAC,CAAC;IAC3B,KAAK,MAAM,GAAG,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC;QAC7B,MAAM,EAAE,GAAG,GAAG,CAAC,sBAAsB,IAAI,GAAG,CAAC;QAC7C,MAAM,IAAI,GAAG,GAAG,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;QAChF,MAAM,OAAO,GAAG,GAAG,CAAC,eAAe,CAAC,CAAC,CAAC,cAAc,GAAG,CAAC,eAAe,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;QAChF,KAAK,CAAC,IAAI,CACR,OAAO,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,GAAG;YACzD,GAAG,GAAG,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,IAAI,GAAG,OAAO,EAAE,CAC1D,CAAC;IACJ,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
@@ -0,0 +1,132 @@
1
+ /**
2
+ * Shared canonical-payload assembly.
3
+ *
4
+ * Both `verifyCommand` and `executePolicyOnlyMode` build a "canonical payload"
5
+ * — the dict that becomes the verify JSON output (and, via
6
+ * `synthesizeGovernance`, the canonical governance envelope).
7
+ *
8
+ * The two orchestrators previously inlined this assembly with mostly-identical
9
+ * fields and small mode-specific differences. This module extracts the
10
+ * shared core into a single helper that takes a typed input describing the
11
+ * mode-specific extras.
12
+ *
13
+ * Replay invariant:
14
+ * The resulting payload, after `synthesizeGovernance`, MUST produce the same
15
+ * `replayChecksum` it did under the prior inline implementation, for any
16
+ * given input. The fields that contribute to the checksum (canonical sorted
17
+ * findings) flow through `payload.structuralViolations` and the various
18
+ * issue arrays — exactly as before.
19
+ *
20
+ * What this module does NOT do:
21
+ * - It does not emit JSON.
22
+ * - It does not call `synthesizeGovernance` (caller does that).
23
+ * - It does not finalize evidence (caller does that).
24
+ * - It does not record telemetry (caller does that).
25
+ * - It is not a generic builder pattern; it is a typed extraction of a
26
+ * duplicated literal-object construction.
27
+ */
28
+ import type { StructuralViolation } from '../../structural-rules/types';
29
+ import type { PolicyOnlySource } from './shared-types';
30
+ /**
31
+ * Minimal "governance payload" surface — the parts of the canonical payload
32
+ * that are produced by the governance evaluator and threaded into both modes.
33
+ * Caller passes in an opaque object; we spread it.
34
+ */
35
+ export type GovernancePayloadFragment = Record<string, unknown>;
36
+ /**
37
+ * Policy-pack fragment — present when an installed pack contributed rules.
38
+ */
39
+ export interface PolicyPackFragment {
40
+ id: string;
41
+ name: string;
42
+ version: string;
43
+ ruleCount: number;
44
+ }
45
+ export interface PolicyLockSummaryFragment {
46
+ enforced: boolean;
47
+ matched: boolean;
48
+ path: string;
49
+ mismatches: ReadonlyArray<unknown>;
50
+ }
51
+ export interface PolicyOnlyCanonicalPayloadInput {
52
+ grade: string;
53
+ score: number;
54
+ verdict: string;
55
+ message: string;
56
+ violations: ReadonlyArray<unknown>;
57
+ structuralViolations: ReadonlyArray<StructuralViolation>;
58
+ structuralRulesApplied: ReadonlyArray<string>;
59
+ structuralSuppressedCount: number;
60
+ source: PolicyOnlySource;
61
+ replayChecksum: string;
62
+ governancePayload: GovernancePayloadFragment;
63
+ policyLock: PolicyLockSummaryFragment;
64
+ policyExceptions: unknown;
65
+ policyGovernance: unknown;
66
+ policyPack?: PolicyPackFragment | null;
67
+ }
68
+ /**
69
+ * Assemble the policy-only canonical payload. Replaces the inline literal
70
+ * previously at `commands/verify.ts:2685–2724`.
71
+ *
72
+ * Field order is preserved byte-for-byte from the prior implementation so
73
+ * `JSON.stringify` output (and therefore stdout writes, evidence captures,
74
+ * and any string-equality fixtures) remains identical.
75
+ */
76
+ export declare function buildPolicyOnlyCanonicalPayload(input: PolicyOnlyCanonicalPayloadInput): Record<string, unknown>;
77
+ /**
78
+ * AI-debt summary fragment — pass-through; consumed by buildAiDebtReportViolations
79
+ * in the caller. The verify.ts payload includes this as an explicit `aiDebt` key.
80
+ */
81
+ export type AiDebtSummaryFragment = unknown;
82
+ /** Change-contract summary fragment — pass-through. */
83
+ export type ChangeContractSummaryFragment = unknown;
84
+ /** Compiled policy metadata fragment — pass-through. */
85
+ export type CompiledPolicyMetadataFragment = Record<string, unknown> | null;
86
+ /** Runtime guard summary fragment — pass-through. */
87
+ export interface RuntimeGuardSummaryFragment {
88
+ required: boolean;
89
+ [key: string]: unknown;
90
+ }
91
+ /** Intent proof summary fragment — pass-through. */
92
+ export type IntentProofSummaryFragment = unknown;
93
+ /** Policy decision fragment — pass-through, only emitted when violations exist. */
94
+ export type PolicyDecisionFragment = unknown;
95
+ export interface VerifyCanonicalPayloadInput {
96
+ grade: string;
97
+ score: number;
98
+ verdict: string;
99
+ message: string;
100
+ violations: ReadonlyArray<unknown>;
101
+ scopeGuardPassed: boolean;
102
+ bloatCount: number;
103
+ bloatFiles: ReadonlyArray<string>;
104
+ plannedFilesModified: number;
105
+ totalPlannedFiles: number;
106
+ verificationSource: string;
107
+ structuralViolations: ReadonlyArray<StructuralViolation>;
108
+ structuralRulesApplied: ReadonlyArray<string>;
109
+ structuralSuppressedCount: number;
110
+ aiDebt: AiDebtSummaryFragment;
111
+ changeContract: ChangeContractSummaryFragment;
112
+ compiledPolicyMetadata: CompiledPolicyMetadataFragment;
113
+ governancePayload: GovernancePayloadFragment | undefined;
114
+ policyLock: PolicyLockSummaryFragment;
115
+ policyExceptions: unknown;
116
+ policyGovernance: unknown;
117
+ intentProof: IntentProofSummaryFragment;
118
+ runtimeGuard?: RuntimeGuardSummaryFragment | null;
119
+ policyDecision?: PolicyDecisionFragment;
120
+ policyPack?: PolicyPackFragment | null;
121
+ }
122
+ /**
123
+ * Assemble the main-flow (plan_enforced) canonical payload. Twin of
124
+ * `buildPolicyOnlyCanonicalPayload` for the verifyCommand main path.
125
+ * Replaces the inline literal previously at `commands/verify.ts:5542–5585`.
126
+ *
127
+ * Field order MUST be preserved byte-for-byte from the prior inline
128
+ * implementation. Replay consumers (audit dashboards, action JSON parsers)
129
+ * may depend on JSON serialization order.
130
+ */
131
+ export declare function buildVerifyCanonicalPayload(input: VerifyCanonicalPayloadInput): Record<string, unknown>;
132
+ //# sourceMappingURL=envelope-assembly.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"envelope-assembly.d.ts","sourceRoot":"","sources":["../../../src/governance/pipeline/envelope-assembly.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEvD;;;;GAIG;AACH,MAAM,MAAM,yBAAyB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEhE;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,yBAAyB;IACxC,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC;CACpC;AAED,MAAM,WAAW,+BAA+B;IAE9C,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAEhB,UAAU,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC;IACnC,oBAAoB,EAAE,aAAa,CAAC,mBAAmB,CAAC,CAAC;IACzD,s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C,oBAAoB,EAAE,MAAM,CAAC;IAC7B,iBAAiB,EAAE,MAAM,CAAC;IAE1B,kBAAkB,EAAE,MAAM,CAAC;IAE3B,oBAAoB,EAAE,aAAa,CAAC,mBAAmB,CAAC,CAAC;IACzD,sBAAsB,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAC9C,yBAAyB,EAAE,MAAM,CAAC;IAElC,MAAM,EAAE,qBAAqB,CAAC;IAC9B,cAAc,EAAE,6BAA6B,CAAC;IAC9C,sBAAsB,EAAE,8BAA8B,CAAC;IACvD,iBAAiB,EAAE,yBAAyB,GAAG,SAAS,CAAC;IACzD,UAAU,EAAE,yBAAyB,CAAC;IACtC,gBAAgB,EAAE,OAAO,CAAC;IAC1B,gBAAgB,EAAE,OAAO,CAAC;IAC1B,WAAW,EAAE,0BAA0B,CAAC;IACxC,YAAY,CAAC,EAAE,2BAA2B,GAAG,IAAI,CAAC;IAClD,cAAc,CAAC,EAAE,sBAAsB,CAAC;IACxC,UAAU,CAAC,EAAE,kBAAkB,GAAG,IAAI,CAAC;CACxC;AAED;;;;;;;;GAQG;AACH,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,2BAA2B,GACjC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAgDzB"}
@@ -0,0 +1,140 @@
1
+ "use strict";
2
+ /**
3
+ * Shared canonical-payload assembly.
4
+ *
5
+ * Both `verifyCommand` and `executePolicyOnlyMode` build a "canonical payload"
6
+ * — the dict that becomes the verify JSON output (and, via
7
+ * `synthesizeGovernance`, the canonical governance envelope).
8
+ *
9
+ * The two orchestrators previously inlined this assembly with mostly-identical
10
+ * fields and small mode-specific differences. This module extracts the
11
+ * shared core into a single helper that takes a typed input describing the
12
+ * mode-specific extras.
13
+ *
14
+ * Replay invariant:
15
+ * The resulting payload, after `synthesizeGovernance`, MUST produce the same
16
+ * `replayChecksum` it did under the prior inline implementation, for any
17
+ * given input. The fields that contribute to the checksum (canonical sorted
18
+ * findings) flow through `payload.structuralViolations` and the various
19
+ * issue arrays — exactly as before.
20
+ *
21
+ * What this module does NOT do:
22
+ * - It does not emit JSON.
23
+ * - It does not call `synthesizeGovernance` (caller does that).
24
+ * - It does not finalize evidence (caller does that).
25
+ * - It does not record telemetry (caller does that).
26
+ * - It is not a generic builder pattern; it is a typed extraction of a
27
+ * duplicated literal-object construction.
28
+ */
29
+ Object.defineProperty(exports, "__esModule", { value: true });
30
+ exports.buildPolicyOnlyCanonicalPayload = buildPolicyOnlyCanonicalPayload;
31
+ exports.buildVerifyCanonicalPayload = buildVerifyCanonicalPayload;
32
+ /**
33
+ * Assemble the policy-only canonical payload. Replaces the inline literal
34
+ * previously at `commands/verify.ts:2685–2724`.
35
+ *
36
+ * Field order is preserved byte-for-byte from the prior implementation so
37
+ * `JSON.stringify` output (and therefore stdout writes, evidence captures,
38
+ * and any string-equality fixtures) remains identical.
39
+ */
40
+ function buildPolicyOnlyCanonicalPayload(input) {
41
+ return {
42
+ grade: input.grade,
43
+ score: input.score,
44
+ verdict: input.verdict,
45
+ violations: input.violations,
46
+ message: input.message,
47
+ scopeGuardPassed: true, // N/A in policy-only mode
48
+ bloatCount: 0,
49
+ bloatFiles: [],
50
+ plannedFilesModified: 0,
51
+ totalPlannedFiles: 0,
52
+ adherenceScore: input.score,
53
+ structuralViolations: input.structuralViolations,
54
+ structuralRulesApplied: input.structuralRulesApplied,
55
+ structuralSuppressedCount: input.structuralSuppressedCount,
56
+ mode: 'policy_only',
57
+ policyOnly: true,
58
+ policyOnlySource: input.source,
59
+ replayChecksum: input.replayChecksum,
60
+ replayMode: 'local-structural',
61
+ ...input.governancePayload,
62
+ policyLock: {
63
+ enforced: input.policyLock.enforced,
64
+ matched: input.policyLock.matched,
65
+ path: input.policyLock.path,
66
+ mismatches: input.policyLock.mismatches,
67
+ },
68
+ policyExceptions: input.policyExceptions,
69
+ policyGovernance: input.policyGovernance,
70
+ ...(input.policyPack
71
+ ? {
72
+ policyPack: {
73
+ id: input.policyPack.id,
74
+ name: input.policyPack.name,
75
+ version: input.policyPack.version,
76
+ ruleCount: input.policyPack.ruleCount,
77
+ },
78
+ }
79
+ : {}),
80
+ };
81
+ }
82
+ /**
83
+ * Assemble the main-flow (plan_enforced) canonical payload. Twin of
84
+ * `buildPolicyOnlyCanonicalPayload` for the verifyCommand main path.
85
+ * Replaces the inline literal previously at `commands/verify.ts:5542–5585`.
86
+ *
87
+ * Field order MUST be preserved byte-for-byte from the prior inline
88
+ * implementation. Replay consumers (audit dashboards, action JSON parsers)
89
+ * may depend on JSON serialization order.
90
+ */
91
+ function buildVerifyCanonicalPayload(input) {
92
+ const payload = {
93
+ grade: input.grade,
94
+ score: input.score,
95
+ verdict: input.verdict,
96
+ violations: input.violations,
97
+ message: input.message,
98
+ adherenceScore: input.score,
99
+ scopeGuardPassed: input.scopeGuardPassed,
100
+ bloatCount: input.bloatCount,
101
+ bloatFiles: input.bloatFiles,
102
+ plannedFilesModified: input.plannedFilesModified,
103
+ totalPlannedFiles: input.totalPlannedFiles,
104
+ verificationSource: input.verificationSource,
105
+ structuralViolations: input.structuralViolations,
106
+ structuralRulesApplied: input.structuralRulesApplied,
107
+ structuralSuppressedCount: input.structuralSuppressedCount,
108
+ mode: 'plan_enforced',
109
+ policyOnly: false,
110
+ aiDebt: input.aiDebt,
111
+ changeContract: input.changeContract,
112
+ ...(input.compiledPolicyMetadata ? { policyCompilation: input.compiledPolicyMetadata } : {}),
113
+ ...(input.governancePayload || {}),
114
+ policyLock: {
115
+ enforced: input.policyLock.enforced,
116
+ matched: input.policyLock.matched,
117
+ path: input.policyLock.path,
118
+ mismatches: input.policyLock.mismatches,
119
+ },
120
+ policyExceptions: input.policyExceptions,
121
+ policyGovernance: input.policyGovernance,
122
+ intentProof: input.intentProof,
123
+ ...(input.runtimeGuard && input.runtimeGuard.required
124
+ ? { runtimeGuard: input.runtimeGuard }
125
+ : {}),
126
+ ...(input.policyDecision !== undefined ? { policyDecision: input.policyDecision } : {}),
127
+ ...(input.policyPack
128
+ ? {
129
+ policyPack: {
130
+ id: input.policyPack.id,
131
+ name: input.policyPack.name,
132
+ version: input.policyPack.version,
133
+ ruleCount: input.policyPack.ruleCount,
134
+ },
135
+ }
136
+ : {}),
137
+ };
138
+ return payload;
139
+ }
140
+ //# sourceMappingURL=envelope-assembly.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"envelope-assembly.js","sourceRoot":"","sources":["../../../src/governance/pipeline/envelope-assembly.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;;AA4DH,0EA2CC;AA0ED,kEAkDC;AA/KD;;;;;;;GAOG;AACH,SAAgB,+BAA+B,CAC7C,KAAsC;IAEtC,OAAO;QACL,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,UAAU,EAAE,KAAK,CAAC,UAAU;QAC5B,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,gBAAgB,EAAE,IAAI,EAAE,0BAA0B;QAClD,UAAU,EAAE,CAAC;QACb,UAAU,EAAE,EAAE;QACd,oBAAoB,EAAE,CAAC;QACvB,iBAAiB,EAAE,CAAC;QACpB,cAAc,EAAE,KAAK,CAAC,KAAK;QAC3B,oBAAoB,EAAE,KAAK,CAAC,oBAAoB;QAChD,sBAAsB,EAAE,KAAK,CAAC,sBAAsB;QACpD,yBAAyB,EAAE,KAAK,CAAC,yBAAyB;QAC1D,IAAI,EAAE,aAAa;QACnB,UAAU,EAAE,IAAI;QAChB,gBAAgB,EAAE,KAAK,CAAC,MAAM;QAC9B,cAAc,EAAE,KAAK,CAAC,cAAc;QACpC,UAAU,EAAE,kBAAkB;QAC9B,GAAG,KAAK,CAAC,iBAAiB;QAC1B,UAAU,EAAE;YACV,QAAQ,EAAE,KAAK,CAAC,UAAU,CAAC,QAAQ;YACnC,OAAO,EAAE,KAAK,CAAC,UAAU,CAAC,OAAO;YACjC,IAAI,E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B,CAAC"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Deterministic stage fingerprinting.
3
+ *
4
+ * A stage fingerprint is a SHA-256 over the stable identifiers of the stage's
5
+ * input or output. It MUST be:
6
+ * - Independent of wall-clock time, run IDs, and process state
7
+ * - Stable across operating systems and Node versions
8
+ * - Computed only from canonical fields (no excerpts, no PII)
9
+ *
10
+ * Callers should provide a `signal` object containing the minimum stable
11
+ * descriptors. Anything not present in the signal is ignored by the fingerprint.
12
+ */
13
+ /**
14
+ * Compute a deterministic SHA-256 fingerprint from a stage signal object.
15
+ *
16
+ * The signal is serialized via stable key ordering so logically identical inputs
17
+ * always produce the same hash, regardless of source object key insertion order.
18
+ *
19
+ * @param signal An object containing stable, PII-free identifiers.
20
+ * @returns 64-char hex SHA-256 digest, or undefined when signal is empty.
21
+ */
22
+ export declare function fingerprintStageSignal(signal: unknown): string | undefined;
23
+ /**
24
+ * Deterministic JSON serialization with sorted object keys.
25
+ *
26
+ * Mirrors the contract of `@neurcode-ai/telemetry`'s `stableStringify` to avoid
27
+ * a cross-package dependency at this layer. Identical implementation invariants:
28
+ * - Objects: keys sorted lexicographically
29
+ * - Arrays: order preserved
30
+ * - Numbers: NaN/Infinity become null (JSON-compatible)
31
+ * - Functions / undefined values: omitted
32
+ */
33
+ export declare function stableStringify(value: unknown): string;
34
+ //# sourceMappingURL=fingerprint.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fingerprint.d.ts","sourceRoot":"","sources":["../../../src/governance/pipeline/fingerprint.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAS1E;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAEtD"}
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ /**
3
+ * Deterministic stage fingerprinting.
4
+ *
5
+ * A stage fingerprint is a SHA-256 over the stable identifiers of the stage's
6
+ * input or output. It MUST be:
7
+ * - Independent of wall-clock time, run IDs, and process state
8
+ * - Stable across operating systems and Node versions
9
+ * - Computed only from canonical fields (no excerpts, no PII)
10
+ *
11
+ * Callers should provide a `signal` object containing the minimum stable
12
+ * descriptors. Anything not present in the signal is ignored by the fingerprint.
13
+ */
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.fingerprintStageSignal = fingerprintStageSignal;
16
+ exports.stableStringify = stableStringify;
17
+ const crypto_1 = require("crypto");
18
+ /**
19
+ * Compute a deterministic SHA-256 fingerprint from a stage signal object.
20
+ *
21
+ * The signal is serialized via stable key ordering so logically identical inputs
22
+ * always produce the same hash, regardless of source object key insertion order.
23
+ *
24
+ * @param signal An object containing stable, PII-free identifiers.
25
+ * @returns 64-char hex SHA-256 digest, or undefined when signal is empty.
26
+ */
27
+ function fingerprintStageSignal(signal) {
28
+ if (signal === null || signal === undefined) {
29
+ return undefined;
30
+ }
31
+ const stable = stableStringify(signal);
32
+ if (!stable || stable === '{}' || stable === '[]') {
33
+ return undefined;
34
+ }
35
+ return (0, crypto_1.createHash)('sha256').update(stable, 'utf-8').digest('hex');
36
+ }
37
+ /**
38
+ * Deterministic JSON serialization with sorted object keys.
39
+ *
40
+ * Mirrors the contract of `@neurcode-ai/telemetry`'s `stableStringify` to avoid
41
+ * a cross-package dependency at this layer. Identical implementation invariants:
42
+ * - Objects: keys sorted lexicographically
43
+ * - Arrays: order preserved
44
+ * - Numbers: NaN/Infinity become null (JSON-compatible)
45
+ * - Functions / undefined values: omitted
46
+ */
47
+ function stableStringify(value) {
48
+ return JSON.stringify(canonicalize(value));
49
+ }
50
+ function canonicalize(value) {
51
+ if (value === null || value === undefined) {
52
+ return null;
53
+ }
54
+ if (typeof value === 'number') {
55
+ return Number.isFinite(value) ? value : null;
56
+ }
57
+ if (typeof value === 'string' || typeof value === 'boolean') {
58
+ return value;
59
+ }
60
+ if (Array.isArray(value)) {
61
+ return value.map(canonicalize);
62
+ }
63
+ if (typeof value === 'object') {
64
+ const obj = value;
65
+ const keys = Object.keys(obj).sort();
66
+ const out = {};
67
+ for (const k of keys) {
68
+ const v = obj[k];
69
+ if (v === undefined || typeof v === 'function')
70
+ continue;
71
+ out[k] = canonicalize(v);
72
+ }
73
+ return out;
74
+ }
75
+ // bigint, symbol, etc. — drop
76
+ return null;
77
+ }
78
+ //# sourceMappingURL=fingerprint.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fingerprint.js","sourceRoot":"","sources":["../../../src/governance/pipeline/fingerprint.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;AAaH,wDASC;AAYD,0CAEC;AAlCD,mCAAoC;AAEpC;;;;;;;;GAQG;AACH,SAAgB,sBAAsB,CAAC,MAAe;IACpD,IAAI,MAAM,KAAK,IAAI,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QAC5C,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,MAAM,MAAM,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;IACvC,IAAI,CAAC,MAAM,IAAI,MAAM,KAAK,IAAI,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;QAClD,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,OAAO,IAAA,mBAAU,EAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACpE,CAAC;AAED;;;;;;;;;GASG;AACH,SAAgB,eAAe,CAAC,KAAc;IAC5C,OAAO,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC;AAC7C,CAAC;AAED,SAAS,YAAY,CAAC,KAAc;IAClC,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QAC1C,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;IAC/C,CAAC;IACD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,SAAS,EAAE,CAAC;QAC5D,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,KAAK,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IACjC,CAAC;IACD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,MAAM,GAAG,GAAG,KAAgC,CAAC;QAC7C,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;QACrC,MAAM,GAAG,GAA4B,EAAE,CAAC;QACxC,KAAK,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC;YACrB,MAAM,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;YACjB,IAAI,CAAC,KAAK,SAAS,IAAI,OAAO,CAAC,KAAK,UAAU;gBAAE,SAAS;YACzD,GAAG,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC;QAC3B,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC;IACD,8BAA8B;IAC9B,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Pipeline execution helpers.
3
+ *
4
+ * Compresses the repetitive verify.ts wire-in pattern:
5
+ *
6
+ * const stageResult = await runStage(stage, input, ctx);
7
+ * const value = stageResult.output ?? fallback(...);
8
+ *
9
+ * into a single named helper, while preserving:
10
+ * - the underlying determinism of the wrapped function
11
+ * - the staged-pipeline ledger receipt
12
+ * - the byte-for-byte fallback semantics on isolated stage failure
13
+ *
14
+ * These are explicitly NOT a generic workflow engine. They are minimal,
15
+ * typed helpers for the four governance-pipeline wire-in patterns we
16
+ * encountered in verify.ts.
17
+ *
18
+ * - runStageOrFallback — "stage failed, compute the same thing without staging"
19
+ * - runStageWithDegradedFallback — "stage succeeded but output was null; fall back"
20
+ * - stageReceiptOrCompute — "you only want a value; the receipt is bookkeeping"
21
+ * - getLastStageOutput — "read the most recent ledger entry for a stage"
22
+ *
23
+ * Replay invariant: when the stage succeeds, the helper returns the stage's
24
+ * output; the fallback is only used when the stage failed or produced null.
25
+ * The fallback MUST be byte-equivalent to the stage's execute body — that
26
+ * way semantics are preserved regardless of which branch ran.
27
+ */
28
+ import type { GovernanceStageId, GovernanceStageResult } from '@neurcode-ai/contracts';
29
+ import type { GovernancePipelineContext, GovernancePipelineStage } from './types';
30
+ /**
31
+ * Run a stage and unwrap its output. If the stage failed or returned null,
32
+ * invoke the supplied fallback synchronously and use that value instead.
33
+ *
34
+ * The ledger always receives a receipt regardless of outcome — the fallback
35
+ * does not produce its own receipt (that would double-count).
36
+ */
37
+ export declare function runStageOrFallback<TIn, TOut>(stage: GovernancePipelineStage<TIn, TOut>, input: TIn, ctx: GovernancePipelineContext, fallback: () => TOut): Promise<TOut>;
38
+ /**
39
+ * Same as `runStageOrFallback`, but the fallback may be async (e.g. when it
40
+ * has to re-read from disk or call out to a sibling helper).
41
+ */
42
+ export declare function runStageOrAsyncFallback<TIn, TOut>(stage: GovernancePipelineStage<TIn, TOut>, input: TIn, ctx: GovernancePipelineContext, fallback: () => Promise<TOut>): Promise<TOut>;
43
+ /**
44
+ * Run a stage and return both the unwrapped output AND the full receipt.
45
+ * Useful when the caller needs to consult the receipt (e.g. for failure
46
+ * surfacing) but doesn't want to write the unwrap boilerplate.
47
+ */
48
+ export declare function runStageWithReceipt<TIn, TOut>(stage: GovernancePipelineStage<TIn, TOut>, input: TIn, ctx: GovernancePipelineContext, fallback: () => TOut): Promise<{
49
+ value: TOut;
50
+ result: GovernanceStageResult<TOut>;
51
+ }>;
52
+ /**
53
+ * If a stage has already run and produced output, return that. Otherwise run
54
+ * the supplied compute function (and DO NOT append a ledger entry — this is
55
+ * "look up or compute"). Used when verify.ts has already invoked a stage
56
+ * elsewhere and a later code path needs the same value without re-emitting.
57
+ */
58
+ export declare function stageReceiptOrCompute<T>(ctx: GovernancePipelineContext, stageId: GovernanceStageId, compute: () => T): T;
59
+ /**
60
+ * Convenience: did a given stage record any non-success status in the ledger?
61
+ *
62
+ * Returns true when the stage ran and its status is `degraded` or `failed`.
63
+ * Returns false when the stage succeeded OR has not yet run.
64
+ */
65
+ export declare function stageDegradedOrFailed(ctx: GovernancePipelineContext, stageId: GovernanceStageId): boolean;
66
+ /**
67
+ * Convenience: enumerate all stages in the ledger that are NOT 'succeeded'.
68
+ * Used by computation-trace explainability helpers.
69
+ */
70
+ export declare function enumerateNonSuccessStages(ctx: GovernancePipelineContext): Array<{
71
+ stageId: GovernanceStageId;
72
+ status: 'skipped' | 'degraded' | 'failed';
73
+ }>;
74
+ //# sourceMappingURL=helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/governance/pipeline/helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,KAAK,EACV,iBAAiB,EACjB,qBAAqB,EACtB,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EACV,yBAAyB,EACzB,uBAAuB,EACxB,MAAM,SAAS,CAAC;AAGjB;;;;;;GAMG;AACH,wBAAsB,kBAAkB,CAAC,GAAG,EAAE,IAAI,EAChD,KAAK,EAAE,uBAAuB,CAAC,GAAG,EAAE,IAAI,CAAC,EACzC,KAAK,EAAE,GAAG,EACV,GAAG,EAAE,yBAAyB,EAC9B,QAAQ,EAAE,MAAM,IAAI,GACnB,OAAO,CAAC,IAAI,CAAC,CAMf;AAED;;;GAGG;AACH,wBAAsB,uBAAuB,CAAC,GAAG,EAAE,IAAI,EACrD,KAAK,EAAE,uBAAuB,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