@neurcode-ai/cli 0.10.1 → 0.14.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 (199) hide show
  1. package/.telemetry-bundle/dist/contracts.d.ts +1 -1
  2. package/README.md +74 -25
  3. package/dist/commands/governance.d.ts.map +1 -1
  4. package/dist/commands/governance.js +12 -0
  5. package/dist/commands/governance.js.map +1 -1
  6. package/dist/commands/home.d.ts +21 -0
  7. package/dist/commands/home.d.ts.map +1 -0
  8. package/dist/commands/home.js +253 -0
  9. package/dist/commands/home.js.map +1 -0
  10. package/dist/commands/login.js +1 -1
  11. package/dist/commands/login.js.map +1 -1
  12. package/dist/commands/quickstart.d.ts.map +1 -1
  13. package/dist/commands/quickstart.js +13 -11
  14. package/dist/commands/quickstart.js.map +1 -1
  15. package/dist/commands/remediate-export.d.ts.map +1 -1
  16. package/dist/commands/remediate-export.js +17 -2
  17. package/dist/commands/remediate-export.js.map +1 -1
  18. package/dist/commands/replay.d.ts.map +1 -1
  19. package/dist/commands/replay.js +36 -0
  20. package/dist/commands/replay.js.map +1 -1
  21. package/dist/commands/verify-output.d.ts.map +1 -1
  22. package/dist/commands/verify-output.js +88 -4
  23. package/dist/commands/verify-output.js.map +1 -1
  24. package/dist/commands/verify.d.ts +22 -1
  25. package/dist/commands/verify.d.ts.map +1 -1
  26. package/dist/commands/verify.js +467 -37
  27. package/dist/commands/verify.js.map +1 -1
  28. package/dist/daemon/server.d.ts.map +1 -1
  29. package/dist/daemon/server.js +4 -0
  30. package/dist/daemon/server.js.map +1 -1
  31. package/dist/governance/canonical-pipeline.d.ts.map +1 -1
  32. package/dist/governance/canonical-pipeline.js +29 -3
  33. package/dist/governance/canonical-pipeline.js.map +1 -1
  34. package/dist/governance/intent/drift-detector.d.ts +100 -0
  35. package/dist/governance/intent/drift-detector.d.ts.map +1 -0
  36. package/dist/governance/intent/drift-detector.js +275 -0
  37. package/dist/governance/intent/drift-detector.js.map +1 -0
  38. package/dist/governance/intent/glob-match.d.ts +43 -0
  39. package/dist/governance/intent/glob-match.d.ts.map +1 -0
  40. package/dist/governance/intent/glob-match.js +108 -0
  41. package/dist/governance/intent/glob-match.js.map +1 -0
  42. package/dist/governance/intent/import-graph.d.ts +56 -0
  43. package/dist/governance/intent/import-graph.d.ts.map +1 -0
  44. package/dist/governance/intent/import-graph.js +133 -0
  45. package/dist/governance/intent/import-graph.js.map +1 -0
  46. package/dist/governance/intent/index.d.ts +23 -0
  47. package/dist/governance/intent/index.d.ts.map +1 -0
  48. package/dist/governance/intent/index.js +48 -0
  49. package/dist/governance/intent/index.js.map +1 -0
  50. package/dist/governance/intent/intelligence-boundaries.d.ts +69 -0
  51. package/dist/governance/intent/intelligence-boundaries.d.ts.map +1 -0
  52. package/dist/governance/intent/intelligence-boundaries.js +163 -0
  53. package/dist/governance/intent/intelligence-boundaries.js.map +1 -0
  54. package/dist/governance/intent/intent-contract.d.ts +76 -0
  55. package/dist/governance/intent/intent-contract.d.ts.map +1 -0
  56. package/dist/governance/intent/intent-contract.js +397 -0
  57. package/dist/governance/intent/intent-contract.js.map +1 -0
  58. package/dist/governance/intent/intent-graph.d.ts +135 -0
  59. package/dist/governance/intent/intent-graph.d.ts.map +1 -0
  60. package/dist/governance/intent/intent-graph.js +67 -0
  61. package/dist/governance/intent/intent-graph.js.map +1 -0
  62. package/dist/governance/pipeline/computation-trace.d.ts +52 -0
  63. package/dist/governance/pipeline/computation-trace.d.ts.map +1 -0
  64. package/dist/governance/pipeline/computation-trace.js +79 -0
  65. package/dist/governance/pipeline/computation-trace.js.map +1 -0
  66. package/dist/governance/pipeline/envelope-assembly.d.ts +132 -0
  67. package/dist/governance/pipeline/envelope-assembly.d.ts.map +1 -0
  68. package/dist/governance/pipeline/envelope-assembly.js +140 -0
  69. package/dist/governance/pipeline/envelope-assembly.js.map +1 -0
  70. package/dist/governance/pipeline/fingerprint.d.ts +34 -0
  71. package/dist/governance/pipeline/fingerprint.d.ts.map +1 -0
  72. package/dist/governance/pipeline/fingerprint.js +78 -0
  73. package/dist/governance/pipeline/fingerprint.js.map +1 -0
  74. package/dist/governance/pipeline/helpers.d.ts +74 -0
  75. package/dist/governance/pipeline/helpers.d.ts.map +1 -0
  76. package/dist/governance/pipeline/helpers.js +112 -0
  77. package/dist/governance/pipeline/helpers.js.map +1 -0
  78. package/dist/governance/pipeline/index.d.ts +27 -0
  79. package/dist/governance/pipeline/index.d.ts.map +1 -0
  80. package/dist/governance/pipeline/index.js +63 -0
  81. package/dist/governance/pipeline/index.js.map +1 -0
  82. package/dist/governance/pipeline/lineage.d.ts +26 -0
  83. package/dist/governance/pipeline/lineage.d.ts.map +1 -0
  84. package/dist/governance/pipeline/lineage.js +51 -0
  85. package/dist/governance/pipeline/lineage.js.map +1 -0
  86. package/dist/governance/pipeline/orchestration/advisory-mode-contract.d.ts +15 -0
  87. package/dist/governance/pipeline/orchestration/advisory-mode-contract.d.ts.map +1 -0
  88. package/dist/governance/pipeline/orchestration/advisory-mode-contract.js +44 -0
  89. package/dist/governance/pipeline/orchestration/advisory-mode-contract.js.map +1 -0
  90. package/dist/governance/pipeline/orchestration/advisory-mode.d.ts +102 -0
  91. package/dist/governance/pipeline/orchestration/advisory-mode.d.ts.map +1 -0
  92. package/dist/governance/pipeline/orchestration/advisory-mode.js +170 -0
  93. package/dist/governance/pipeline/orchestration/advisory-mode.js.map +1 -0
  94. package/dist/governance/pipeline/orchestration/evidence-lifecycle.d.ts +133 -0
  95. package/dist/governance/pipeline/orchestration/evidence-lifecycle.d.ts.map +1 -0
  96. package/dist/governance/pipeline/orchestration/evidence-lifecycle.js +125 -0
  97. package/dist/governance/pipeline/orchestration/evidence-lifecycle.js.map +1 -0
  98. package/dist/governance/pipeline/orchestration/index.d.ts +16 -0
  99. package/dist/governance/pipeline/orchestration/index.d.ts.map +1 -0
  100. package/dist/governance/pipeline/orchestration/index.js +30 -0
  101. package/dist/governance/pipeline/orchestration/index.js.map +1 -0
  102. package/dist/governance/pipeline/orchestration/intent-drift-orchestration.d.ts +65 -0
  103. package/dist/governance/pipeline/orchestration/intent-drift-orchestration.d.ts.map +1 -0
  104. package/dist/governance/pipeline/orchestration/intent-drift-orchestration.js +102 -0
  105. package/dist/governance/pipeline/orchestration/intent-drift-orchestration.js.map +1 -0
  106. package/dist/governance/pipeline/orchestration/plan-structural-analysis.d.ts +41 -0
  107. package/dist/governance/pipeline/orchestration/plan-structural-analysis.d.ts.map +1 -0
  108. package/dist/governance/pipeline/orchestration/plan-structural-analysis.js +74 -0
  109. package/dist/governance/pipeline/orchestration/plan-structural-analysis.js.map +1 -0
  110. package/dist/governance/pipeline/orchestration/policy-evaluation-summaries.d.ts +165 -0
  111. package/dist/governance/pipeline/orchestration/policy-evaluation-summaries.d.ts.map +1 -0
  112. package/dist/governance/pipeline/orchestration/policy-evaluation-summaries.js +160 -0
  113. package/dist/governance/pipeline/orchestration/policy-evaluation-summaries.js.map +1 -0
  114. package/dist/governance/pipeline/orchestration/scope-guard-orchestration.d.ts +152 -0
  115. package/dist/governance/pipeline/orchestration/scope-guard-orchestration.d.ts.map +1 -0
  116. package/dist/governance/pipeline/orchestration/scope-guard-orchestration.js +188 -0
  117. package/dist/governance/pipeline/orchestration/scope-guard-orchestration.js.map +1 -0
  118. package/dist/governance/pipeline/runtime.d.ts +70 -0
  119. package/dist/governance/pipeline/runtime.d.ts.map +1 -0
  120. package/dist/governance/pipeline/runtime.js +223 -0
  121. package/dist/governance/pipeline/runtime.js.map +1 -0
  122. package/dist/governance/pipeline/shared-types.d.ts +7 -0
  123. package/dist/governance/pipeline/shared-types.d.ts.map +1 -0
  124. package/dist/governance/pipeline/shared-types.js +7 -0
  125. package/dist/governance/pipeline/shared-types.js.map +1 -0
  126. package/dist/governance/pipeline/stages/compiled-policy-stage.d.ts +28 -0
  127. package/dist/governance/pipeline/stages/compiled-policy-stage.d.ts.map +1 -0
  128. package/dist/governance/pipeline/stages/compiled-policy-stage.js +53 -0
  129. package/dist/governance/pipeline/stages/compiled-policy-stage.js.map +1 -0
  130. package/dist/governance/pipeline/stages/diff-normalization-stage.d.ts +63 -0
  131. package/dist/governance/pipeline/stages/diff-normalization-stage.d.ts.map +1 -0
  132. package/dist/governance/pipeline/stages/diff-normalization-stage.js +140 -0
  133. package/dist/governance/pipeline/stages/diff-normalization-stage.js.map +1 -0
  134. package/dist/governance/pipeline/stages/governance-synthesis-stage.d.ts +53 -0
  135. package/dist/governance/pipeline/stages/governance-synthesis-stage.d.ts.map +1 -0
  136. package/dist/governance/pipeline/stages/governance-synthesis-stage.js +129 -0
  137. package/dist/governance/pipeline/stages/governance-synthesis-stage.js.map +1 -0
  138. package/dist/governance/pipeline/stages/index.d.ts +29 -0
  139. package/dist/governance/pipeline/stages/index.d.ts.map +1 -0
  140. package/dist/governance/pipeline/stages/index.js +40 -0
  141. package/dist/governance/pipeline/stages/index.js.map +1 -0
  142. package/dist/governance/pipeline/stages/policy-lock-stage.d.ts +31 -0
  143. package/dist/governance/pipeline/stages/policy-lock-stage.d.ts.map +1 -0
  144. package/dist/governance/pipeline/stages/policy-lock-stage.js +71 -0
  145. package/dist/governance/pipeline/stages/policy-lock-stage.js.map +1 -0
  146. package/dist/governance/pipeline/stages/runtime-guard-stage.d.ts +29 -0
  147. package/dist/governance/pipeline/stages/runtime-guard-stage.d.ts.map +1 -0
  148. package/dist/governance/pipeline/stages/runtime-guard-stage.js +65 -0
  149. package/dist/governance/pipeline/stages/runtime-guard-stage.js.map +1 -0
  150. package/dist/governance/pipeline/stages/structural-analysis-stage.d.ts +24 -0
  151. package/dist/governance/pipeline/stages/structural-analysis-stage.d.ts.map +1 -0
  152. package/dist/governance/pipeline/stages/structural-analysis-stage.js +58 -0
  153. package/dist/governance/pipeline/stages/structural-analysis-stage.js.map +1 -0
  154. package/dist/governance/pipeline/summary.d.ts +14 -0
  155. package/dist/governance/pipeline/summary.d.ts.map +1 -0
  156. package/dist/governance/pipeline/summary.js +50 -0
  157. package/dist/governance/pipeline/summary.js.map +1 -0
  158. package/dist/governance/pipeline/types.d.ts +69 -0
  159. package/dist/governance/pipeline/types.d.ts.map +1 -0
  160. package/dist/governance/pipeline/types.js +30 -0
  161. package/dist/governance/pipeline/types.js.map +1 -0
  162. package/dist/index.js +44 -3
  163. package/dist/index.js.map +1 -1
  164. package/dist/utils/active-engineering-context.d.ts +16 -0
  165. package/dist/utils/active-engineering-context.d.ts.map +1 -1
  166. package/dist/utils/active-engineering-context.js +302 -0
  167. package/dist/utils/active-engineering-context.js.map +1 -1
  168. package/dist/utils/import-edge-classifier.d.ts +76 -0
  169. package/dist/utils/import-edge-classifier.d.ts.map +1 -0
  170. package/dist/utils/import-edge-classifier.js +308 -0
  171. package/dist/utils/import-edge-classifier.js.map +1 -0
  172. package/dist/utils/import-edge-extractor.d.ts +52 -0
  173. package/dist/utils/import-edge-extractor.d.ts.map +1 -0
  174. package/dist/utils/import-edge-extractor.js +223 -0
  175. package/dist/utils/import-edge-extractor.js.map +1 -0
  176. package/dist/utils/import-edge-governance.d.ts +37 -0
  177. package/dist/utils/import-edge-governance.d.ts.map +1 -0
  178. package/dist/utils/import-edge-governance.js +56 -0
  179. package/dist/utils/import-edge-governance.js.map +1 -0
  180. package/dist/utils/messages.d.ts.map +1 -1
  181. package/dist/utils/messages.js +19 -10
  182. package/dist/utils/messages.js.map +1 -1
  183. package/dist/utils/path-boundary-classifier.d.ts +42 -0
  184. package/dist/utils/path-boundary-classifier.d.ts.map +1 -0
  185. package/dist/utils/path-boundary-classifier.js +143 -0
  186. package/dist/utils/path-boundary-classifier.js.map +1 -0
  187. package/dist/utils/replay-html-report.d.ts +29 -0
  188. package/dist/utils/replay-html-report.d.ts.map +1 -0
  189. package/dist/utils/replay-html-report.js +309 -0
  190. package/dist/utils/replay-html-report.js.map +1 -0
  191. package/dist/utils/runtime-state.d.ts +44 -0
  192. package/dist/utils/runtime-state.d.ts.map +1 -0
  193. package/dist/utils/runtime-state.js +151 -0
  194. package/dist/utils/runtime-state.js.map +1 -0
  195. package/package.json +3 -3
  196. package/dist/utils/box.d.ts +0 -16
  197. package/dist/utils/box.d.ts.map +0 -1
  198. package/dist/utils/box.js +0 -85
  199. package/dist/utils/box.js.map +0 -1
@@ -0,0 +1,170 @@
1
+ "use strict";
2
+ /**
3
+ * Advisory-Mode Orchestration
4
+ * ---------------------------
5
+ * Extracts the no-plan / advisory-first branch previously inlined at
6
+ * `commands/verify.ts:4161–4321`.
7
+ *
8
+ * RESPONSIBILITIES (data-pure):
9
+ * - resolve auto-contract path when no change-contract is present
10
+ * - evaluate advisory signals (with runtime-pressure gating)
11
+ * - run structural rules (via the existing structural-analysis stage)
12
+ * - compute verdict / grade / score
13
+ * - assemble the advisory canonical payload
14
+ *
15
+ * EXPLICITLY NOT RESPONSIBLE FOR:
16
+ * - human-readable rendering (caller owns chalk + printFirstRunAdvisoryMessage)
17
+ * - emitting verify JSON (caller owns emitVerifyJson + emitCanonicalVerifyJson)
18
+ * - recording telemetry verdict (caller owns recordVerifyEvent)
19
+ * - calling exitWithEvidence (caller owns process termination)
20
+ *
21
+ * SEMANTIC PRESERVATION:
22
+ * The output `payload` is byte-equivalent to the prior inline literal at
23
+ * line ~4276 (the `emitVerifyJson({...})` call). Field order matches the
24
+ * inline implementation so JSON serialization is identical.
25
+ *
26
+ * REPLAY INVARIANT:
27
+ * - structural-analysis stage call is identical to the prior wire-in
28
+ * - advisory signals evaluation is identical to the prior call
29
+ * - structural-engine fault swallowing is preserved (try/swallow in compute)
30
+ */
31
+ Object.defineProperty(exports, "__esModule", { value: true });
32
+ exports.runAdvisoryMode = runAdvisoryMode;
33
+ const change_contract_1 = require("../../../utils/change-contract");
34
+ const advisory_signals_1 = require("../../../utils/advisory-signals");
35
+ const verify_runtime_stability_1 = require("../../../utils/verify-runtime-stability");
36
+ const advisory_mode_contract_1 = require("./advisory-mode-contract");
37
+ const helpers_1 = require("../helpers");
38
+ const stages_1 = require("../stages");
39
+ const structural_on_diff_1 = require("../../structural-on-diff");
40
+ const ADVISORY_MESSAGE = 'No plan linked yet. Ran advisory verification for quick first-run experience. ' +
41
+ 'Use `neurcode plan` and `neurcode contract import --auto-detect --write-change-contract` for full enforcement.';
42
+ /**
43
+ * Compute the advisory-mode result. Replaces the inline compute region.
44
+ *
45
+ * Does not emit JSON, does not log, does not exit.
46
+ */
47
+ async function runAdvisoryMode(input) {
48
+ const { options, projectRoot, diffFiles, summary, runtimeCtx, changeContractRead, changeContractSummary, strictArtifactMode, pipelineCtx } = input;
49
+ // ── Auto-contract generation ──────────────────────────────────────────
50
+ let autoContractPath = null;
51
+ let updatedChangeContractSummary = changeContractSummary;
52
+ if (!changeContractRead.contract && !strictArtifactMode) {
53
+ try {
54
+ const fallbackPlanId = `advisory_${Date.now()}`;
55
+ const advisoryContract = (0, advisory_mode_contract_1.buildMinimalAdvisoryContractFromDiff)(diffFiles, fallbackPlanId);
56
+ autoContractPath = (0, change_contract_1.writeChangeContract)(projectRoot, advisoryContract, options.changeContract);
57
+ updatedChangeContractSummary = {
58
+ path: autoContractPath,
59
+ exists: true,
60
+ enforced: false,
61
+ valid: true,
62
+ planId: advisoryContract.planId,
63
+ contractId: advisoryContract.contractId,
64
+ coverage: {
65
+ expectedFiles: advisoryContract.expectedFiles.length,
66
+ changedFiles: diffFiles.length,
67
+ outOfContractFiles: 0,
68
+ missingExpectedFiles: 0,
69
+ blockedFilesTouched: 0,
70
+ actionMismatches: 0,
71
+ expectedSymbols: advisoryContract.expectedSymbols?.length || 0,
72
+ changedSymbols: 0,
73
+ missingExpectedSymbols: 0,
74
+ blockedSymbolsTouched: 0,
75
+ symbolActionMismatches: 0,
76
+ symbolRenameMatches: 0,
77
+ toleratedUnexpectedFiles: 0,
78
+ toleratedMissingExpectedSymbols: 0,
79
+ },
80
+ signature: changeContractSummary.signature,
81
+ violations: [],
82
+ };
83
+ }
84
+ catch {
85
+ autoContractPath = null;
86
+ }
87
+ }
88
+ // ── Advisory signals ──────────────────────────────────────────────────
89
+ const advisorySignalsSkipped = (0, verify_runtime_stability_1.shouldSkipAdvisoryLayer)(runtimeCtx);
90
+ const advisorySignals = advisorySignalsSkipped
91
+ ? []
92
+ : (0, advisory_signals_1.evaluateAdvisorySignals)({ diffFiles, summary });
93
+ const advisoryWarnCount = advisorySignals.filter(s => s.severity === 'warn').length;
94
+ // ── Structural rules (advisory) ───────────────────────────────────────
95
+ let advisoryStructuralViolations = [];
96
+ let advisoryStructuralBlockingCount = 0;
97
+ try {
98
+ const structuralResult = await (0, helpers_1.runStageOrFallback)(stages_1.structuralAnalysisStage, { projectRoot, diffFiles }, pipelineCtx, () => (0, structural_on_diff_1.runStructuralOnDiffFiles)(projectRoot, diffFiles));
99
+ advisoryStructuralViolations = structuralResult.violations;
100
+ advisoryStructuralBlockingCount = structuralResult.violations.filter(v => v.severity === 'BLOCKING').length;
101
+ }
102
+ catch {
103
+ // Structural engine failure must never block advisory verify.
104
+ }
105
+ // ── Verdict / grade / score ──────────────────────────────────────────
106
+ const hasFlags = advisoryWarnCount > 0 || advisoryStructuralBlockingCount > 0;
107
+ const advisoryVerdict = hasFlags ? 'WARN' : 'PASS';
108
+ const advisoryGrade = hasFlags ? 'C' : 'B';
109
+ const advisoryScore = hasFlags ? 60 : 70;
110
+ // ── Build violations array (advisory shape) ──────────────────────────
111
+ const advisoryViolations = [
112
+ ...advisorySignals.map(item => ({
113
+ file: item.files[0] || '.',
114
+ rule: `advisory:${item.code.toLowerCase()}`,
115
+ severity: item.severity === 'warn' ? 'warn' : 'allow',
116
+ message: `${item.title}: ${item.detail}`,
117
+ })),
118
+ ...advisoryStructuralViolations.map(v => ({
119
+ file: v.filePath,
120
+ rule: `structural-advisory:${v.ruleId.toLowerCase()}`,
121
+ severity: 'warn',
122
+ message: `${v.ruleId} ${v.ruleName}: ${v.evidence.slice(0, 100)} (advisory — link plan to enforce)`,
123
+ })),
124
+ ];
125
+ // ── Canonical advisory payload assembly ──────────────────────────────
126
+ const payload = {
127
+ grade: advisoryGrade,
128
+ score: advisoryScore,
129
+ verdict: advisoryVerdict,
130
+ violations: advisoryViolations,
131
+ adherenceScore: advisoryScore,
132
+ bloatCount: 0,
133
+ bloatFiles: [],
134
+ plannedFilesModified: 0,
135
+ totalPlannedFiles: 0,
136
+ message: ADVISORY_MESSAGE,
137
+ scopeGuardPassed: true,
138
+ mode: 'advisory_missing_plan',
139
+ advisoryMode: true,
140
+ advisorySignals,
141
+ structuralViolations: advisoryStructuralViolations,
142
+ structuralBlockingCount: advisoryStructuralBlockingCount,
143
+ ...(advisoryStructuralBlockingCount > 0
144
+ ? {
145
+ structuralNote: `${advisoryStructuralBlockingCount} structural finding(s) surfaced in advisory mode. Link a plan to enforce.`,
146
+ }
147
+ : {}),
148
+ policyOnly: true,
149
+ policyOnlySource: 'fallback_missing_plan',
150
+ ...(autoContractPath
151
+ ? { changeContract: { ...updatedChangeContractSummary, path: autoContractPath } }
152
+ : { changeContract: changeContractSummary }),
153
+ };
154
+ return {
155
+ payload,
156
+ telemetry: {
157
+ verdict: advisoryVerdict,
158
+ detail: `advisory_missing_plan;signals=${advisorySignals.length};warn=${advisoryWarnCount}`,
159
+ files: diffFiles.map(f => f.path),
160
+ },
161
+ autoContractPath,
162
+ message: ADVISORY_MESSAGE,
163
+ updatedChangeContractSummary,
164
+ advisorySignals,
165
+ advisoryStructuralViolations,
166
+ advisoryStructuralBlockingCount,
167
+ advisorySignalsSkipped,
168
+ };
169
+ }
170
+ //# sourceMappingURL=advisory-mode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"advisory-mode.js","sourceRoot":"","sources":["../../../../src/governance/pipeline/orchestration/advisory-mode.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;;AAgFH,0CAyIC;AAvND,oEAAqE;AACrE,sEAA+F;AAC/F,sFAA6G;AAC7G,qEAAgF;AAChF,wCAAgD;AAChD,sCAAoD;AAKpD,iEAAoE;AA2DpE,MAAM,gBAAgB,GACpB,gFAAgF;IAChF,gHAAgH,CAAC;AA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aAAa;QAC7B,UAAU,EAAE,CAAC;QACb,UAAU,EAAE,EAAE;QACd,oBAAoB,EAAE,CAAC;QACvB,iBAAiB,EAAE,CAAC;QACpB,OAAO,EAAE,gBAAgB;QACzB,gBAAgB,EAAE,IAAI;QACtB,IAAI,EAAE,uBAAuB;QAC7B,YAAY,EAAE,IAAI;QAClB,eAAe;QACf,oBAAoB,EAAE,4BAA4B;QAClD,uBAAuB,EAAE,+BAA+B;QACxD,GAAG,CAAC,+BAA+B,GAAG,CAAC;YACrC,CAAC,CAAC;gBACE,cAAc,EAAE,GAAG,+BAA+B,2EAA2E;aAC9H;YACH,CAAC,CAAC,EAAE,CAAC;QACP,UAAU,EAAE,IAAI;QAChB,gBAAgB,EAAE,uBAAuB;QACzC,GAAG,CAAC,gBAAgB;YAClB,CAAC,CAAC,EAAE,cAAc,EAAE,EAAE,GAAG,4BAA4B,EAAE,IAAI,EAAE,gBAAgB,EAAE,EAAE;YACjF,CAAC,CAAC,EAAE,cAAc,EAAE,qBAAqB,EAAE,CAAC;KAC/C,CAAC;IAEF,OAAO;QACL,OAAO;QACP,SAAS,EAAE;YACT,OAAO,EAAE,eAAe;YACxB,MAAM,EAAE,iCAAiC,eAAe,CAAC,MAAM,SAAS,iBAAiB,EAAE;YAC3F,KAAK,EAAE,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;SAClC;QACD,gBAAgB;QAChB,OAAO,EAAE,gBAAgB;QACzB,4BAA4B;QAC5B,eAAe;QACf,4BAA4B;QAC5B,+BAA+B;QAC/B,sBAAsB;KACvB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,133 @@
1
+ /**
2
+ * Evidence Lifecycle Runtime
3
+ * --------------------------
4
+ * Extracts the closure-heavy evidence/finalize plumbing previously inlined at
5
+ * `commands/verify.ts:2816–2905`. The original implementation captured five
6
+ * pieces of mutable state via closure (`lastCanonicalOutput`,
7
+ * `lastEvidenceFallbackOutput`, `evidenceFinalizeAttempted`,
8
+ * `verifyStartedAtMs`, `lastProvenanceRunId`) and exposed three lambdas
9
+ * (`captureEvidencePayload`, `finalizeEvidence`, `exitWithEvidence`).
10
+ *
11
+ * This module replaces that pattern with a typed, explicit holder object so:
12
+ * - lifecycle state is replay-visible (not hidden inside a closure)
13
+ * - finalize idempotency is enforced at the type level
14
+ * - the caller decides termination policy (we DO NOT call process.exit here)
15
+ * - degraded persistence (write failure, missing payload) is explicit
16
+ *
17
+ * Semantic preservation:
18
+ * - finalize is called at most once (existing invariant)
19
+ * - write failure is swallowed and (in non-JSON mode) reported (existing)
20
+ * - calibration telemetry call (`appendVerifyCompletedFromCanonical`) is
21
+ * wrapped in try/catch (existing)
22
+ * - process.exit is INVOKED BY THE CALLER, not by this module
23
+ *
24
+ * Replay invariant:
25
+ * The evidence artifact written by `runEvidenceFinalize` is byte-identical
26
+ * to what the prior closure wrote, for any given lifecycle state. The
27
+ * transition `appendVerifyCompletedFromCanonical(...)` happens at the same
28
+ * point (after finalize, before exit) so telemetry semantics are preserved.
29
+ */
30
+ import type { VerificationEvidenceContext } from '../../../utils/verification-evidence';
31
+ /**
32
+ * Replay-visible lifecycle state. Replaces the four mutable `let`s previously
33
+ * declared at the top of `verifyCommand`.
34
+ *
35
+ * Mutated by `captureEvidencePayload`, `setProvenanceRunId`, and
36
+ * `runEvidenceFinalize` — never by external callers.
37
+ */
38
+ export interface EvidenceLifecycleState {
39
+ /** Last canonical (toCanonicalVerifyOutput-shaped) payload observed. */
40
+ lastCanonicalOutput: Record<string, unknown> | null;
41
+ /** Last raw verify payload observed (fallback used when canonical is null). */
42
+ lastEvidenceFallbackOutput: Record<string, unknown> | null;
43
+ /** True once finalize has been attempted (success OR failure); idempotent. */
44
+ finalizeAttempted: boolean;
45
+ /** Provenance run ID written during normal flow; null until set. */
46
+ lastProvenanceRunId: string | null;
47
+ }
48
+ /**
49
+ * Static configuration for the lifecycle. Captured once when verify starts.
50
+ */
51
+ export interface EvidenceLifecycleConfig {
52
+ enabled: boolean;
53
+ projectRoot: string;
54
+ startedAtMs: number;
55
+ ciMode: boolean;
56
+ deterministicMode: boolean;
57
+ evidenceDir?: string;
58
+ ciContext: VerificationEvidenceContext;
59
+ /** Runtime-metadata block embedded in the evidence artifact. */
60
+ runtimeMetadata: {
61
+ cliJsonContractVersion: string;
62
+ runtimeCompatibilityContractVersion: string;
63
+ componentVersion: string;
64
+ nodeVersion: string;
65
+ platform: string;
66
+ arch: string;
67
+ command: string;
68
+ };
69
+ /** JSON mode flag — controls whether finalize-failure prints to stderr. */
70
+ jsonMode: boolean;
71
+ /**
72
+ * Caller-supplied chalk-dimming logger for the success path. The original
73
+ * implementation used `chalk.dim` from `commands/verify.ts`; we delegate to
74
+ * the caller so this module stays chalk-free.
75
+ */
76
+ reportArtifactPath?: (path: string) => void;
77
+ /** Caller-supplied warning logger for finalize-failure (non-JSON mode). */
78
+ reportFinalizeFailure?: (message: string) => void;
79
+ /**
80
+ * Caller-supplied canonical-form transformer. The original verify.ts
81
+ * function `toCanonicalVerifyOutput` is passed in to avoid a circular
82
+ * dependency between this module and the command file. Required.
83
+ */
84
+ toCanonicalVerifyOutput: (payload: Record<string, unknown>) => Record<string, unknown>;
85
+ }
86
+ /**
87
+ * Create a fresh lifecycle state. Replaces the four `let` declarations at the
88
+ * top of `verifyCommand`.
89
+ */
90
+ export declare function createEvidenceLifecycleState(): EvidenceLifecycleState;
91
+ /**
92
+ * Record a verify payload into the lifecycle state. Computes the canonical
93
+ * representation eagerly so finalize can write either form. Replaces the
94
+ * `captureEvidencePayload` closure.
95
+ *
96
+ * Pure side-effect on the state object — no I/O.
97
+ */
98
+ export declare function captureEvidencePayload(state: EvidenceLifecycleState, config: Pick<EvidenceLifecycleConfig, 'toCanonicalVerifyOutput'>, payload: Record<string, unknown>): void;
99
+ /**
100
+ * Set the provenance run ID. Replaces the inline mutation `lastProvenanceRunId = ...`.
101
+ */
102
+ export declare function setProvenanceRunId(state: EvidenceLifecycleState, runId: string | null): void;
103
+ /**
104
+ * Result of finalizing the evidence lifecycle. Surfaced so the caller can
105
+ * print to stdout in non-JSON mode and trace the lifecycle in replay tools.
106
+ */
107
+ export interface EvidenceFinalizeResult {
108
+ attempted: boolean;
109
+ skipped: boolean;
110
+ /** Reason for skip when `skipped` is true. */
111
+ skipReason?: 'disabled' | 'already-attempted';
112
+ /** Path of the written evidence artifact when persistence succeeded. */
113
+ artifactPath: string | null;
114
+ /** Error message when persistence failed. */
115
+ error?: string;
116
+ }
117
+ /**
118
+ * Run the evidence-finalize lifecycle. Replaces the `finalizeEvidence` closure.
119
+ *
120
+ * Idempotent: subsequent calls return `{ attempted: true, skipped: true }`.
121
+ * Never throws — failures are surfaced via the returned `error` field and the
122
+ * configured warning logger.
123
+ */
124
+ export declare function runEvidenceFinalize(state: EvidenceLifecycleState, config: EvidenceLifecycleConfig, exitCode: number): EvidenceFinalizeResult;
125
+ /**
126
+ * Run the telemetry-calibration emission. Replaces the inline call
127
+ * `appendVerifyCompletedFromCanonical(projectRoot, lastCanonicalOutput,
128
+ * lastProvenanceRunId)` previously inside the `exitWithEvidence` closure.
129
+ *
130
+ * Never throws — calibration must not affect verify exit.
131
+ */
132
+ export declare function emitCalibrationTelemetry(state: EvidenceLifecycleState, config: Pick<EvidenceLifecycleConfig, 'projectRoot'>): void;
133
+ //# sourceMappingURL=evidence-lifecycle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"evidence-lifecycle.d.ts","sourceRoot":"","sources":["../../../../src/governance/pipeline/orchestration/evidence-lifecycle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,KAAK,EACV,2BAA2B,EAC5B,MAAM,sCAAsC,CAAC;AAM9C;;;;;;GAMG;AACH,MAAM,WAAW,sBAAsB;IACrC,wEAAwE;IACxE,mBAAmB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IACpD,+EAA+E;IAC/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E,yBAAyB,CAAC,EAChE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,IAAI,CAGN;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,sBAAsB,EAC7B,KAAK,EAAE,MAAM,GAAG,IAAI,GACnB,IAAI,CAEN;AAED;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACrC,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,8CAA8C;IAC9C,UAAU,CAAC,EAAE,UAAU,GAAG,mBAAmB,CAAC;IAC9C,wEAAwE;IACxE,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,6CAA6C;IAC7C,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,sBAAsB,EAC7B,MAAM,EAAE,uBAAuB,EAC/B,QAAQ,EAAE,MAAM,GACf,sBAAsB,CAiCxB;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,sBAAsB,EAC7B,MAAM,EAAE,IAAI,CAAC,uBAAuB,EAAE,aAAa,CAAC,GACnD,IAAI,CAUN"}
@@ -0,0 +1,125 @@
1
+ "use strict";
2
+ /**
3
+ * Evidence Lifecycle Runtime
4
+ * --------------------------
5
+ * Extracts the closure-heavy evidence/finalize plumbing previously inlined at
6
+ * `commands/verify.ts:2816–2905`. The original implementation captured five
7
+ * pieces of mutable state via closure (`lastCanonicalOutput`,
8
+ * `lastEvidenceFallbackOutput`, `evidenceFinalizeAttempted`,
9
+ * `verifyStartedAtMs`, `lastProvenanceRunId`) and exposed three lambdas
10
+ * (`captureEvidencePayload`, `finalizeEvidence`, `exitWithEvidence`).
11
+ *
12
+ * This module replaces that pattern with a typed, explicit holder object so:
13
+ * - lifecycle state is replay-visible (not hidden inside a closure)
14
+ * - finalize idempotency is enforced at the type level
15
+ * - the caller decides termination policy (we DO NOT call process.exit here)
16
+ * - degraded persistence (write failure, missing payload) is explicit
17
+ *
18
+ * Semantic preservation:
19
+ * - finalize is called at most once (existing invariant)
20
+ * - write failure is swallowed and (in non-JSON mode) reported (existing)
21
+ * - calibration telemetry call (`appendVerifyCompletedFromCanonical`) is
22
+ * wrapped in try/catch (existing)
23
+ * - process.exit is INVOKED BY THE CALLER, not by this module
24
+ *
25
+ * Replay invariant:
26
+ * The evidence artifact written by `runEvidenceFinalize` is byte-identical
27
+ * to what the prior closure wrote, for any given lifecycle state. The
28
+ * transition `appendVerifyCompletedFromCanonical(...)` happens at the same
29
+ * point (after finalize, before exit) so telemetry semantics are preserved.
30
+ */
31
+ Object.defineProperty(exports, "__esModule", { value: true });
32
+ exports.createEvidenceLifecycleState = createEvidenceLifecycleState;
33
+ exports.captureEvidencePayload = captureEvidencePayload;
34
+ exports.setProvenanceRunId = setProvenanceRunId;
35
+ exports.runEvidenceFinalize = runEvidenceFinalize;
36
+ exports.emitCalibrationTelemetry = emitCalibrationTelemetry;
37
+ const verification_evidence_1 = require("../../../utils/verification-evidence");
38
+ const telemetry_1 = require("@neurcode-ai/telemetry");
39
+ /**
40
+ * Create a fresh lifecycle state. Replaces the four `let` declarations at the
41
+ * top of `verifyCommand`.
42
+ */
43
+ function createEvidenceLifecycleState() {
44
+ return {
45
+ lastCanonicalOutput: null,
46
+ lastEvidenceFallbackOutput: null,
47
+ finalizeAttempted: false,
48
+ lastProvenanceRunId: null,
49
+ };
50
+ }
51
+ /**
52
+ * Record a verify payload into the lifecycle state. Computes the canonical
53
+ * representation eagerly so finalize can write either form. Replaces the
54
+ * `captureEvidencePayload` closure.
55
+ *
56
+ * Pure side-effect on the state object — no I/O.
57
+ */
58
+ function captureEvidencePayload(state, config, payload) {
59
+ state.lastEvidenceFallbackOutput = payload;
60
+ state.lastCanonicalOutput = config.toCanonicalVerifyOutput(payload);
61
+ }
62
+ /**
63
+ * Set the provenance run ID. Replaces the inline mutation `lastProvenanceRunId = ...`.
64
+ */
65
+ function setProvenanceRunId(state, runId) {
66
+ state.lastProvenanceRunId = runId;
67
+ }
68
+ /**
69
+ * Run the evidence-finalize lifecycle. Replaces the `finalizeEvidence` closure.
70
+ *
71
+ * Idempotent: subsequent calls return `{ attempted: true, skipped: true }`.
72
+ * Never throws — failures are surfaced via the returned `error` field and the
73
+ * configured warning logger.
74
+ */
75
+ function runEvidenceFinalize(state, config, exitCode) {
76
+ if (!config.enabled) {
77
+ return { attempted: false, skipped: true, skipReason: 'disabled', artifactPath: null };
78
+ }
79
+ if (state.finalizeAttempted) {
80
+ return { attempted: true, skipped: true, skipReason: 'already-attempted', artifactPath: null };
81
+ }
82
+ state.finalizeAttempted = true;
83
+ try {
84
+ const artifactPath = (0, verification_evidence_1.writeVerificationEvidence)({
85
+ enabled: config.enabled,
86
+ projectRoot: config.projectRoot,
87
+ startedAtMs: config.startedAtMs,
88
+ exitCode,
89
+ ciMode: config.ciMode,
90
+ deterministicMode: config.deterministicMode,
91
+ evidenceDir: config.evidenceDir,
92
+ canonicalOutput: state.lastCanonicalOutput,
93
+ fallbackOutput: state.lastEvidenceFallbackOutput,
94
+ ciContext: config.ciContext,
95
+ runtimeMetadata: config.runtimeMetadata,
96
+ });
97
+ if (artifactPath && !config.jsonMode && config.reportArtifactPath) {
98
+ config.reportArtifactPath(artifactPath);
99
+ }
100
+ return { attempted: true, skipped: false, artifactPath: artifactPath ?? null };
101
+ }
102
+ catch (error) {
103
+ const message = error instanceof Error ? error.message : String(error);
104
+ if (!config.jsonMode && config.reportFinalizeFailure) {
105
+ config.reportFinalizeFailure(message);
106
+ }
107
+ return { attempted: true, skipped: false, artifactPath: null, error: message };
108
+ }
109
+ }
110
+ /**
111
+ * Run the telemetry-calibration emission. Replaces the inline call
112
+ * `appendVerifyCompletedFromCanonical(projectRoot, lastCanonicalOutput,
113
+ * lastProvenanceRunId)` previously inside the `exitWithEvidence` closure.
114
+ *
115
+ * Never throws — calibration must not affect verify exit.
116
+ */
117
+ function emitCalibrationTelemetry(state, config) {
118
+ try {
119
+ (0, telemetry_1.appendVerifyCompletedFromCanonical)(config.projectRoot, state.lastCanonicalOutput, state.lastProvenanceRunId);
120
+ }
121
+ catch {
122
+ // calibration must never affect exit
123
+ }
124
+ }
125
+ //# sourceMappingURL=evidence-lifecycle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"evidence-lifecycle.js","sourceRoot":"","sources":["../../../../src/governance/pipeline/orchestration/evidence-lifecycle.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;;AAuEH,oEAOC;AASD,wDAOC;AAKD,gDAKC;AAwBD,kDAqCC;AASD,4DAaC;AAtLD,gFAE8C;AAC9C,sDAA4E;AA2D5E;;;GAGG;AACH,SAAgB,4BAA4B;IAC1C,OAAO;QACL,mBAAmB,EAAE,IAAI;QACzB,0BAA0B,EAAE,IAAI;QAChC,iBAAiB,EAAE,KAAK;QACxB,mBAAmB,EAAE,IAAI;KAC1B,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,sBAAsB,CACpC,KAA6B,EAC7B,MAAgE,EAChE,OAAgC;IAEhC,KAAK,CAAC,0BAA0B,GAAG,OAAO,CAAC;IAC3C,KAAK,CAAC,mBAAmB,GAAG,MAAM,CAAC,uBAAuB,CAAC,OAAO,CAA4B,CAAC;AACjG,CAAC;AAED;;GAEG;AACH,SAAgB,kBAAkB,CAChC,KAA6B,EAC7B,KAAoB;IAEpB,KAAK,CAAC,mBAAmB,GAAG,KAAK,CAAC;AACpC,CAAC;AAiBD;;;;;;GAMG;AACH,SAAgB,mBAAmB,CACjC,KAA6B,EAC7B,MAA+B,EAC/B,QAAgB;IAEhB,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACpB,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;IACzF,CA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AAO,CAAC,CAAC;QACxC,CAAC;QACD,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;IACjF,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,wBAAwB,CACtC,KAA6B,EAC7B,MAAoD;IAEpD,IAAI,CAAC;QACH,IAAA,8CAAkC,EAChC,MAAM,CAAC,WAAW,EAClB,KAAK,CAAC,mBAAmB,EACzB,KAAK,CAAC,mBAAmB,CAC1B,CAAC;IACJ,CAAC;IAAC,MAAM,CAAC;QACP,qCAAqC;IACvC,CAAC;AACH,CAAC"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Pipeline orchestration extractions — public re-exports.
3
+ *
4
+ * Each module in this directory is a typed, replay-aware extraction of an
5
+ * orchestration region previously inlined in `commands/verify.ts`. The goal
6
+ * is to reduce orchestration concentration in verify.ts while preserving
7
+ * byte-for-byte semantics (replay checksum, finding identity, JSON shape).
8
+ */
9
+ export { runAdvisoryMode, type AdvisoryChangeContractSummary, type AdvisoryModeInput, type AdvisoryModeResult, } from './advisory-mode';
10
+ export { buildMinimalAdvisoryContractFromDiff, } from './advisory-mode-contract';
11
+ export { captureEvidencePayload, createEvidenceLifecycleState, emitCalibrationTelemetry, runEvidenceFinalize, setProvenanceRunId, type EvidenceFinalizeResult, type EvidenceLifecycleConfig, type EvidenceLifecycleState, } from './evidence-lifecycle';
12
+ export { runPlanStructuralAnalysis, type PlanStructuralAnalysisInput, type PlanStructuralAnalysisResult, } from './plan-structural-analysis';
13
+ export { runScopeGuardOrchestration, type ScopeGuardOrchestrationInput, type ScopeGuardOrchestrationResult, type ScopeGuardPlanClient, type ScopeGuardLocalPlan, type ScopeGuardSigningParams, type SessionResolutionNote, } from './scope-guard-orchestration';
14
+ export { buildPolicyEvaluationSummaries, type PolicyEvaluationSummariesInput, type PolicyEvaluationSummariesResult, type PolicyExceptionsSummary, type PolicyGovernanceSummary, type PolicyExceptionResolutionSummary, type ExceptionApprovalConfig, type GovernanceAuditConfig, type AuditIntegrityData, } from './policy-evaluation-summaries';
15
+ export { runIntentDriftOrchestration, type IntentDriftOrchestrationInput, type IntentDriftOrchestrationResult, } from './intent-drift-orchestration';
16
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/governance/pipeline/orchestration/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EACL,eAAe,EACf,KAAK,6BAA6B,EAClC,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,GACxB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,oCAAoC,GACrC,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,sBAAsB,EACtB,4BAA4B,EAC5B,wBAAwB,EACxB,mBAAmB,EACnB,kBAAkB,EAClB,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,EAC5B,KAAK,sBAAsB,GAC5B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,yBAAyB,EACzB,KAAK,2BAA2B,EAChC,KAAK,4BAA4B,GAClC,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,0BAA0B,EAC1B,KAAK,4BAA4B,EACjC,KAAK,6BAA6B,EAClC,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,KAAK,uBAAuB,EAC5B,KAAK,qBAAqB,GAC3B,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,8BAA8B,EAC9B,KAAK,8BAA8B,EACnC,KAAK,+BAA+B,EACpC,KAAK,uBAAuB,EAC5B,KAAK,uBAAuB,EAC5B,KAAK,gCAAgC,EACrC,KAAK,uBAAuB,EAC5B,KAAK,qBAAqB,EAC1B,KAAK,kBAAkB,GACxB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,2BAA2B,EAC3B,KAAK,6BAA6B,EAClC,KAAK,8BAA8B,GACpC,MAAM,8BAA8B,CAAC"}
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ /**
3
+ * Pipeline orchestration extractions — public re-exports.
4
+ *
5
+ * Each module in this directory is a typed, replay-aware extraction of an
6
+ * orchestration region previously inlined in `commands/verify.ts`. The goal
7
+ * is to reduce orchestration concentration in verify.ts while preserving
8
+ * byte-for-byte semantics (replay checksum, finding identity, JSON shape).
9
+ */
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.runIntentDriftOrchestration = exports.buildPolicyEvaluationSummaries = exports.runScopeGuardOrchestration = exports.runPlanStructuralAnalysis = exports.setProvenanceRunId = exports.runEvidenceFinalize = exports.emitCalibrationTelemetry = exports.createEvidenceLifecycleState = exports.captureEvidencePayload = exports.buildMinimalAdvisoryContractFromDiff = exports.runAdvisoryMode = void 0;
12
+ var advisory_mode_1 = require("./advisory-mode");
13
+ Object.defineProperty(exports, "runAdvisoryMode", { enumerable: true, get: function () { return advisory_mode_1.runAdvisoryMode; } });
14
+ var advisory_mode_contract_1 = require("./advisory-mode-contract");
15
+ Object.defineProperty(exports, "buildMinimalAdvisoryContractFromDiff", { enumerable: true, get: function () { return advisory_mode_contract_1.buildMinimalAdvisoryContractFromDiff; } });
16
+ var evidence_lifecycle_1 = require("./evidence-lifecycle");
17
+ Object.defineProperty(exports, "captureEvidencePayload", { enumerable: true, get: function () { return evidence_lifecycle_1.captureEvidencePayload; } });
18
+ Object.defineProperty(exports, "createEvidenceLifecycleState", { enumerable: true, get: function () { return evidence_lifecycle_1.createEvidenceLifecycleState; } });
19
+ Object.defineProperty(exports, "emitCalibrationTelemetry", { enumerable: true, get: function () { return evidence_lifecycle_1.emitCalibrationTelemetry; } });
20
+ Object.defineProperty(exports, "runEvidenceFinalize", { enumerable: true, get: function () { return evidence_lifecycle_1.runEvidenceFinalize; } });
21
+ Object.defineProperty(exports, "setProvenanceRunId", { enumerable: true, get: function () { return evidence_lifecycle_1.setProvenanceRunId; } });
22
+ var plan_structural_analysis_1 = require("./plan-structural-analysis");
23
+ Object.defineProperty(exports, "runPlanStructuralAnalysis", { enumerable: true, get: function () { return plan_structural_analysis_1.runPlanStructuralAnalysis; } });
24
+ var scope_guard_orchestration_1 = require("./scope-guard-orchestration");
25
+ Object.defineProperty(exports, "runScopeGuardOrchestration", { enumerable: true, get: function () { return scope_guard_orchestration_1.runScopeGuardOrchestration; } });
26
+ var policy_evaluation_summaries_1 = require("./policy-evaluation-summaries");
27
+ Object.defineProperty(exports, "buildPolicyEvaluationSummaries", { enumerable: true, get: function () { return policy_evaluation_summaries_1.buildPolicyEvaluationSummaries; } });
28
+ var intent_drift_orchestration_1 = require("./intent-drift-orchestration");
29
+ Object.defineProperty(exports, "runIntentDriftOrchestration", { enumerable: true, get: function () { return intent_drift_orchestration_1.runIntentDriftOrchestration; } });
30
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/governance/pipeline/orchestration/index.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;AAEH,iDAKyB;AAJvB,gHAAA,eAAe,OAAA;AAKjB,mEAEkC;AADhC,8IAAA,oCAAoC,OAAA;AAEtC,2DAS8B;AAR5B,4HAAA,sBAAsB,OAAA;AACtB,kIAAA,4BAA4B,OAAA;AAC5B,8HAAA,wBAAwB,OAAA;AACxB,yHAAA,mBAAmB,OAAA;AACnB,wHAAA,kBAAkB,OAAA;AAKpB,uEAIoC;AAHlC,qIAAA,yBAAyB,OAAA;AAI3B,yEAQqC;AAPnC,uIAAA,0BAA0B,OAAA;AAQ5B,6EAUuC;AATrC,6IAAA,8BAA8B,OAAA;AAUhC,2EAIsC;AAHpC,yIAAA,2BAA2B,OAAA"}
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Intent Drift Orchestration
3
+ * ---------------------------
4
+ * Wraps the intent-governance module (`governance/intent/*`) into an
5
+ * orchestration surface consumable by verify.ts. Pattern matches the other
6
+ * orchestration modules:
7
+ *
8
+ * - Caller hands us inputs (projectRoot, diffFiles, options).
9
+ * - We load the contract, run drift detection, return a typed result.
10
+ * - We do NOT render, log, or emit JSON. Caller owns presentation.
11
+ * - On any internal error, we return a safe empty result. Drift detection
12
+ * is opt-in; a malformed contract must never break verification.
13
+ *
14
+ * Phase 1 INVARIANT: drift detection is ADVISORY by default. The detector
15
+ * only emits BLOCK-severity violations when `enforce: true` is passed
16
+ * explicitly. Callers wishing to enforce must read the contract's
17
+ * enforcement signal (a future schema field, or an environment opt-in).
18
+ *
19
+ * Intelligence classification: DETERMINISTIC (delegated to inner module).
20
+ */
21
+ import { type DriftReport } from '../../intent';
22
+ import type { DiffFile } from '@neurcode-ai/diff-parser';
23
+ export interface IntentDriftOrchestrationInput {
24
+ /** Absolute project root. */
25
+ projectRoot: string;
26
+ /** Parsed diff files for the current change. */
27
+ diffFiles: DiffFile[];
28
+ /** Optional contract path override (relative to projectRoot). */
29
+ contractPath?: string;
30
+ /**
31
+ * When true, forbidden-edge violations are emitted as `block` severity.
32
+ * Default is `false` — advisory-only, safe-by-default rollout.
33
+ * Tier-up to enforcement happens via NEURCODE_INTENT_ENFORCE=1 or a future
34
+ * contract field; callers compute this externally and pass it in.
35
+ */
36
+ enforce?: boolean;
37
+ }
38
+ export interface IntentDriftOrchestrationResult {
39
+ /**
40
+ * True when a contract file was found and parsed (regardless of contents).
41
+ * False when the project has no `.neurcode/intent.json` — drift detection
42
+ * is then skipped and `report` reflects an empty run.
43
+ */
44
+ contractPresent: boolean;
45
+ /** Absolute path of the contract we looked at. */
46
+ contractPath: string;
47
+ /** Validation errors encountered while loading the contract, if any. */
48
+ contractErrors: string[];
49
+ /** Soft warnings from the loader. */
50
+ contractWarnings: string[];
51
+ /** Whether enforcement was active for this run. */
52
+ enforced: boolean;
53
+ /** The drift report. Always present, even when no contract was found. */
54
+ report: DriftReport;
55
+ }
56
+ /**
57
+ * Run the intent-drift detection orchestration. Safe to call on every verify run.
58
+ *
59
+ * Cost model:
60
+ * - No contract → ~1ms (filesystem stat + early return).
61
+ * - Contract present → proportional to (diff size × layer count). For a typical
62
+ * 50-file diff against a 5-layer contract, well under 50ms.
63
+ */
64
+ export declare function runIntentDriftOrchestration(input: IntentDriftOrchestrationInput): IntentDriftOrchestrationResult;
65
+ //# sourceMappingURL=intent-drift-orchestration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"intent-drift-orchestration.d.ts","sourceRoot":"","sources":["../../../../src/governance/pipeline/orchestration/intent-drift-orchestration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAIL,KAAK,WAAW,EAEjB,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAIzD,MAAM,WAAW,6BAA6B;IAC5C,6BAA6B;IAC7B,WAAW,EAAE,MAAM,CAAC;IACpB,gDAAgD;IAChD,SAAS,EAAE,QAAQ,EAAE,CAAC;IACtB,iEAAiE;IACjE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,8BAA8B;IAC7C;;;;OAIG;IACH,eAAe,EAAE,OAAO,CAAC;IACzB,kDAAkD;IAClD,YAAY,EAAE,MAAM,CAAC;IACrB,wEAAwE;IACxE,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,qCAAqC;IACrC,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,mDAAmD;IACnD,QAAQ,EAAE,OAAO,CAAC;IAClB,yEAAyE;IACzE,MAAM,EAAE,WAAW,CAAC;CACrB;AAID;;;;;;;GAOG;AACH,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,6BAA6B,GACnC,8BAA8B,CAoEhC"}