@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,102 @@
1
+ "use strict";
2
+ /**
3
+ * Intent Drift Orchestration
4
+ * ---------------------------
5
+ * Wraps the intent-governance module (`governance/intent/*`) into an
6
+ * orchestration surface consumable by verify.ts. Pattern matches the other
7
+ * orchestration modules:
8
+ *
9
+ * - Caller hands us inputs (projectRoot, diffFiles, options).
10
+ * - We load the contract, run drift detection, return a typed result.
11
+ * - We do NOT render, log, or emit JSON. Caller owns presentation.
12
+ * - On any internal error, we return a safe empty result. Drift detection
13
+ * is opt-in; a malformed contract must never break verification.
14
+ *
15
+ * Phase 1 INVARIANT: drift detection is ADVISORY by default. The detector
16
+ * only emits BLOCK-severity violations when `enforce: true` is passed
17
+ * explicitly. Callers wishing to enforce must read the contract's
18
+ * enforcement signal (a future schema field, or an environment opt-in).
19
+ *
20
+ * Intelligence classification: DETERMINISTIC (delegated to inner module).
21
+ */
22
+ Object.defineProperty(exports, "__esModule", { value: true });
23
+ exports.runIntentDriftOrchestration = runIntentDriftOrchestration;
24
+ const intent_1 = require("../../intent");
25
+ // ── Public API ───────────────────────────────────────────────────────────────
26
+ /**
27
+ * Run the intent-drift detection orchestration. Safe to call on every verify run.
28
+ *
29
+ * Cost model:
30
+ * - No contract → ~1ms (filesystem stat + early return).
31
+ * - Contract present → proportional to (diff size × layer count). For a typical
32
+ * 50-file diff against a 5-layer contract, well under 50ms.
33
+ */
34
+ function runIntentDriftOrchestration(input) {
35
+ let load;
36
+ try {
37
+ load = (0, intent_1.loadIntentContract)(input.projectRoot, input.contractPath);
38
+ }
39
+ catch (err) {
40
+ // Defensive: loadIntentContract is already non-throwing, but we guard
41
+ // against future regressions and unexpected runtime errors.
42
+ const msg = err instanceof Error ? err.message : String(err);
43
+ return {
44
+ contractPresent: false,
45
+ contractPath: input.contractPath ?? '<unresolved>',
46
+ contractErrors: [`unexpected error loading intent contract: ${msg}`],
47
+ contractWarnings: [],
48
+ enforced: false,
49
+ report: (0, intent_1.runDriftDetection)({
50
+ graph: intent_1.EMPTY_INTENT_GRAPH,
51
+ diffFiles: [],
52
+ }),
53
+ };
54
+ }
55
+ if (!load.exists || load.errors.length > 0) {
56
+ return {
57
+ contractPresent: load.exists,
58
+ contractPath: load.path,
59
+ contractErrors: load.errors,
60
+ contractWarnings: load.warnings,
61
+ enforced: false,
62
+ report: (0, intent_1.runDriftDetection)({
63
+ graph: intent_1.EMPTY_INTENT_GRAPH,
64
+ diffFiles: [],
65
+ }),
66
+ };
67
+ }
68
+ const enforce = input.enforce === true;
69
+ let report;
70
+ try {
71
+ report = (0, intent_1.runDriftDetection)({
72
+ graph: load.graph,
73
+ diffFiles: input.diffFiles,
74
+ enforce,
75
+ });
76
+ }
77
+ catch (err) {
78
+ // Defensive: runDriftDetection is pure but we wrap to satisfy the
79
+ // "drift detection must never break verification" guarantee.
80
+ const msg = err instanceof Error ? err.message : String(err);
81
+ return {
82
+ contractPresent: true,
83
+ contractPath: load.path,
84
+ contractErrors: [`unexpected error running drift detection: ${msg}`],
85
+ contractWarnings: load.warnings,
86
+ enforced: enforce,
87
+ report: (0, intent_1.runDriftDetection)({
88
+ graph: intent_1.EMPTY_INTENT_GRAPH,
89
+ diffFiles: [],
90
+ }),
91
+ };
92
+ }
93
+ return {
94
+ contractPresent: true,
95
+ contractPath: load.path,
96
+ contractErrors: load.errors,
97
+ contractWarnings: load.warnings,
98
+ enforced: enforce,
99
+ report,
100
+ };
101
+ }
102
+ //# sourceMappingURL=intent-drift-orchestration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"intent-drift-orchestration.js","sourceRoot":"","sources":["../../../../src/governance/pipeline/orchestration/intent-drift-orchestration.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;AA0DH,kEAsEC;AA9HD,yCAMsB;AAwCtB,gFAAgF;AAEhF;;;;;;;GAOG;AACH,SAAgB,2BAA2B,CACzC,KAAoC;IAEpC,IAAI,IAA8B,CAAC;IACnC,IAAI,CAAC;QACH,IAAI,GAAG,IAAA,2BAAkB,EAAC,KAAK,CAAC,WAAW,EAAE,KAAK,CAAC,YAAY,CAAC,CAAC;IACnE,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,sEAAsE;QACtE,4DAA4D;QAC5D,MAAM,GAAG,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAC7D,OAAO;YACL,eAAe,EAAE,KAAK;YACtB,YAAY,EAAE,KAAK,CAAC,YAAY,IAAI,cAAc;YAClD,cAAc,EAAE,CAAC,6CAA6C,GAAG,EAAE,CAAC;YACpE,gBAAgB,EAAE,EAAE;YACpB,QAAQ,EAAE,KAAK;YACf,MAAM,EAAE,IAAA,0BAAiB,EAAC;gBACxB,KAAK,EAAE,2BAAkB;gBACzB,SAAS,EAAE,EAAE;aACd,CAAC;SACH,CAAC;IACJ,CAAC;IAED,IAAI,CAAC,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC3C,OAAO;YACL,eAAe,EAAE,IAAI,C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AC"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Plan-Mode Structural Analysis Orchestration
3
+ * --------------------------------------------
4
+ * Extracts the inline structural-engine invocation previously at
5
+ * `commands/verify.ts:4416–4440`. Unlike `structuralAnalysisStage` which
6
+ * wraps `runStructuralOnDiffFiles`, the plan-mode invocation uses the
7
+ * lower-level `StructuralRuleEngine.analyze()` API that requires explicit
8
+ * file-content reads BEFORE analysis.
9
+ *
10
+ * SEMANTIC PRESERVATION:
11
+ * - file reads are isolated per-file with the same try/swallow pattern
12
+ * - the outer try/catch is preserved (engine failure must never abort
13
+ * verify; we return zero-violation defaults instead)
14
+ * - the returned shape matches the inline `let` updates exactly
15
+ *
16
+ * REPLAY:
17
+ * The order of file reads (the diffFiles iteration order) is preserved,
18
+ * and the StructuralRuleEngine output ordering is left untouched. The
19
+ * downstream canonical pipeline sorts by stable keys, so even if read
20
+ * order changed it would not affect replay checksums — but we preserve
21
+ * it as a defensive guarantee.
22
+ */
23
+ import { type StructuralViolation } from '../../../structural-rules';
24
+ import type { DiffFile } from '@neurcode-ai/diff-parser';
25
+ export interface PlanStructuralAnalysisInput {
26
+ projectRoot: string;
27
+ diffFiles: ReadonlyArray<DiffFile>;
28
+ }
29
+ export interface PlanStructuralAnalysisResult {
30
+ violations: StructuralViolation[];
31
+ rulesApplied: string[];
32
+ suppressedCount: number;
33
+ }
34
+ /**
35
+ * Run the plan-mode structural engine. Replaces the inline block.
36
+ * Returns a default zero-violation result on empty input or on engine fault
37
+ * (preserving the original "non-fatal: structural engine errors must never
38
+ * break verification" invariant).
39
+ */
40
+ export declare function runPlanStructuralAnalysis(input: PlanStructuralAnalysisInput): PlanStructuralAnalysisResult;
41
+ //# sourceMappingURL=plan-structural-analysis.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plan-structural-analysis.d.ts","sourceRoot":"","sources":["../../../../src/governance/pipeline/orchestration/plan-structural-analysis.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAIH,OAAO,EAAqC,KAAK,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AACxG,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAEzD,MAAM,WAAW,2BAA2B;IAC1C,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC;CACpC;AAED,MAAM,WAAW,4BAA4B;IAC3C,UAAU,EAAE,mBAAmB,EAAE,CAAC;IAClC,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;CACzB;AAQD;;;;;GAKG;AACH,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,2BAA2B,GACjC,4BAA4B,CA+B9B"}
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ /**
3
+ * Plan-Mode Structural Analysis Orchestration
4
+ * --------------------------------------------
5
+ * Extracts the inline structural-engine invocation previously at
6
+ * `commands/verify.ts:4416–4440`. Unlike `structuralAnalysisStage` which
7
+ * wraps `runStructuralOnDiffFiles`, the plan-mode invocation uses the
8
+ * lower-level `StructuralRuleEngine.analyze()` API that requires explicit
9
+ * file-content reads BEFORE analysis.
10
+ *
11
+ * SEMANTIC PRESERVATION:
12
+ * - file reads are isolated per-file with the same try/swallow pattern
13
+ * - the outer try/catch is preserved (engine failure must never abort
14
+ * verify; we return zero-violation defaults instead)
15
+ * - the returned shape matches the inline `let` updates exactly
16
+ *
17
+ * REPLAY:
18
+ * The order of file reads (the diffFiles iteration order) is preserved,
19
+ * and the StructuralRuleEngine output ordering is left untouched. The
20
+ * downstream canonical pipeline sorts by stable keys, so even if read
21
+ * order changed it would not affect replay checksums — but we preserve
22
+ * it as a defensive guarantee.
23
+ */
24
+ Object.defineProperty(exports, "__esModule", { value: true });
25
+ exports.runPlanStructuralAnalysis = runPlanStructuralAnalysis;
26
+ const fs_1 = require("fs");
27
+ const path_1 = require("path");
28
+ const structural_rules_1 = require("../../../structural-rules");
29
+ const EMPTY_RESULT = {
30
+ violations: [],
31
+ rulesApplied: [],
32
+ suppressedCount: 0,
33
+ };
34
+ /**
35
+ * Run the plan-mode structural engine. Replaces the inline block.
36
+ * Returns a default zero-violation result on empty input or on engine fault
37
+ * (preserving the original "non-fatal: structural engine errors must never
38
+ * break verification" invariant).
39
+ */
40
+ function runPlanStructuralAnalysis(input) {
41
+ if (input.diffFiles.length === 0) {
42
+ return { ...EMPTY_RESULT };
43
+ }
44
+ try {
45
+ const structuralEngine = (0, structural_rules_1.createDefaultStructuralRuleEngine)();
46
+ const filesToAnalyze = [];
47
+ for (const df of input.diffFiles) {
48
+ const absPath = (0, path_1.join)(input.projectRoot, df.path);
49
+ if ((0, fs_1.existsSync)(absPath)) {
50
+ try {
51
+ const sourceText = (0, fs_1.readFileSync)(absPath, 'utf-8');
52
+ filesToAnalyze.push({ filePath: df.path, sourceText });
53
+ }
54
+ catch {
55
+ // Skip unreadable files (preserved invariant).
56
+ }
57
+ }
58
+ }
59
+ if (filesToAnalyze.length === 0) {
60
+ return { ...EMPTY_RESULT };
61
+ }
62
+ const structuralResult = structuralEngine.analyze(filesToAnalyze);
63
+ return {
64
+ violations: structuralResult.violations,
65
+ rulesApplied: structuralResult.rulesApplied,
66
+ suppressedCount: structuralResult.suppressedCount,
67
+ };
68
+ }
69
+ catch {
70
+ // Non-fatal: structural engine errors must never break verification.
71
+ return { ...EMPTY_RESULT };
72
+ }
73
+ }
74
+ //# sourceMappingURL=plan-structural-analysis.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plan-structural-analysis.js","sourceRoot":"","sources":["../../../../src/governance/pipeline/orchestration/plan-structural-analysis.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;;AA8BH,8DAiCC;AA7DD,2BAA8C;AAC9C,+BAA4B;AAC5B,gEAAwG;AAcxG,MAAM,YAAY,GAAiC;IACjD,UAAU,EAAE,EAAE;IACd,YAAY,EAAE,EAAE;IAChB,eAAe,E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@@
1
+ /**
2
+ * Policy Evaluation Summaries Orchestration
3
+ * ------------------------------------------
4
+ * Extracts the duplicated policy-exception-summary + governance-summary
5
+ * shaping logic previously duplicated at:
6
+ * - `commands/verify.ts:2610–2709` (executePolicyOnlyMode)
7
+ * - `commands/verify.ts:4818–4889` (verifyCommand main flow)
8
+ *
9
+ * RESPONSIBILITIES (data-pure):
10
+ * - shape `policyExceptionsSummary` from exceptionDecision + resolution
11
+ * - shape `policyGovernanceSummary` from governance + audit status
12
+ * - apply audit-integrity violation to the effective violation list
13
+ * - apply shouldIgnore filtering to suppressed/blocked violation lists
14
+ * - compute `policyDecision` from effective violations
15
+ *
16
+ * EXPLICITLY NOT RESPONSIBLE FOR:
17
+ * - calling `applyPolicyExceptions` (caller owns that before invoking us)
18
+ * - calling `resolveEffectivePolicyExceptions` (caller owns that)
19
+ * - rendering (chalk, console.log)
20
+ * - emitting JSON or exiting
21
+ *
22
+ * SEMANTIC PRESERVATION:
23
+ * The output shapes are byte-identical to the prior inline implementations.
24
+ * Field order matches the inline construction so JSON serialization is stable.
25
+ *
26
+ * REPLAY INVARIANT:
27
+ * - `explainExceptionEligibilityReason` moved from verify.ts (private) to here
28
+ * - `resolvePolicyDecisionFromViolations` duplicated as a pure local helper to
29
+ * avoid circular import — semantics are identical
30
+ */
31
+ import type { PolicyExceptionDecision, PolicyExceptionEntry } from '../../../utils/policy-exceptions';
32
+ /** Narrowed shape from ResolvedPolicyExceptions (verify.ts internal interface). */
33
+ export interface PolicyExceptionResolutionSummary {
34
+ mode: 'local' | 'org' | 'org_fallback_local';
35
+ exceptions: PolicyExceptionEntry[];
36
+ localConfigured: number;
37
+ orgConfigured: number;
38
+ warning: string | null;
39
+ }
40
+ /** Narrowed from governance.exceptionApprovals (OrgGovernanceSettings). */
41
+ export interface ExceptionApprovalConfig {
42
+ required: boolean;
43
+ minApprovals: number;
44
+ disallowSelfApproval: boolean;
45
+ allowedApprovers: string[];
46
+ requireReason: boolean;
47
+ minReasonLength: number;
48
+ maxExpiryDays: number;
49
+ criticalRulePatterns: string[];
50
+ criticalMinApprovals: number;
51
+ }
52
+ /** Narrowed from governance.audit (OrgGovernanceSettings). */
53
+ export interface GovernanceAuditConfig {
54
+ requireIntegrity: boolean;
55
+ }
56
+ /** From PolicyAuditVerification. */
57
+ export interface AuditIntegrityData {
58
+ valid: boolean;
59
+ count: number;
60
+ lastHash: string | null;
61
+ issues: string[];
62
+ }
63
+ export interface PolicyEvaluationSummariesInput {
64
+ /** Result of applyPolicyExceptions — caller is responsible for this call. */
65
+ exceptionDecision: PolicyExceptionDecision;
66
+ /** Result of resolveEffectivePolicyExceptions. */
67
+ policyExceptionResolution: PolicyExceptionResolutionSummary;
68
+ /** Policy violations present BEFORE exception application. */
69
+ policyViolations: Array<{
70
+ file: string;
71
+ rule: string;
72
+ severity: string;
73
+ message?: string;
74
+ line?: number;
75
+ }>;
76
+ /** Governance exception-approval configuration. */
77
+ exceptionApprovals: ExceptionApprovalConfig;
78
+ /** Governance audit configuration. */
79
+ audit: GovernanceAuditConfig;
80
+ /** Audit integrity verification result. */
81
+ auditIntegrity: AuditIntegrityData;
82
+ /** Returns true for file paths to exclude from governance checks. */
83
+ shouldIgnore: (file: string) => boolean;
84
+ /**
85
+ * Canonical path token for the policy audit file entry.
86
+ * Callers use 'neurcode.policy.audit.log.jsonl'.
87
+ */
88
+ policyAuditFile: string;
89
+ }
90
+ export interface PolicyExceptionsSummary {
91
+ sourceMode: PolicyExceptionResolutionSummary['mode'];
92
+ sourceWarning: string | null;
93
+ localConfigured: number;
94
+ orgConfigured: number;
95
+ configured: number;
96
+ active: number;
97
+ usable: number;
98
+ matched: number;
99
+ suppressed: number;
100
+ blocked: number;
101
+ matchedExceptionIds: string[];
102
+ suppressedViolations: Array<{
103
+ file: string;
104
+ rule: string;
105
+ severity: string;
106
+ message: string | undefined;
107
+ exceptionId: string;
108
+ reason: string;
109
+ expiresAt: string;
110
+ startLine?: number;
111
+ }>;
112
+ blockedViolations: Array<{
113
+ file: string;
114
+ rule: string;
115
+ severity: string;
116
+ message: string | undefined;
117
+ startLine?: number;
118
+ }>;
119
+ }
120
+ export interface PolicyGovernanceSummary {
121
+ exceptionApprovals: ExceptionApprovalConfig;
122
+ audit: {
123
+ requireIntegrity: boolean;
124
+ valid: boolean;
125
+ issues: string[];
126
+ lastHash: string | null;
127
+ eventCount: number;
128
+ };
129
+ }
130
+ export interface PolicyEvaluationSummariesResult {
131
+ /** Shaped policy exceptions summary — ready for canonical payload. */
132
+ policyExceptionsSummary: PolicyExceptionsSummary;
133
+ /** Shaped governance audit summary — ready for canonical payload. */
134
+ policyGovernanceSummary: PolicyGovernanceSummary;
135
+ /**
136
+ * Effective policy violations after exception application and audit check:
137
+ * remaining + blocked + (optional audit violation).
138
+ */
139
+ effectivePolicyViolations: Array<{
140
+ file: string;
141
+ rule: string;
142
+ severity: string;
143
+ message?: string;
144
+ line?: number;
145
+ }>;
146
+ /** Formatted blocked violations (subset of effectivePolicyViolations). */
147
+ blockedPolicyViolationItems: Array<{
148
+ file: string;
149
+ rule: string;
150
+ severity: string;
151
+ message: string;
152
+ line?: number;
153
+ }>;
154
+ /** Policy decision derived from effectivePolicyViolations. */
155
+ policyDecision: 'allow' | 'warn' | 'block';
156
+ }
157
+ /**
158
+ * Build the shaped policy-exception and governance-audit summaries.
159
+ *
160
+ * Replaces the duplicated inline shaping regions in both
161
+ * `executePolicyOnlyMode` and the main `verifyCommand` flow.
162
+ * Does not emit JSON, does not log, does not exit.
163
+ */
164
+ export declare function buildPolicyEvaluationSummaries(input: PolicyEvaluationSummariesInput): PolicyEvaluationSummariesResult;
165
+ //# sourceMappingURL=policy-evaluation-summaries.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"policy-evaluation-summaries.d.ts","sourceRoot":"","sources":["../../../../src/governance/pipeline/orchestration/policy-evaluation-summaries.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,KAA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AC;CACJ;AAED,MAAM,WAAW,uBAAuB;IACtC,kBAAkB,EAAE,uBAAuB,CAAC;IAC5C,KAAK,EAAE;QACL,gBAAgB,EAAE,OAAO,CAAC;QAC1B,KAAK,EAAE,OAAO,CAAC;QACf,MAAM,EAAE,MAAM,EAAE,CAAC;QACjB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;QACxB,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC;CACH;AAED,MAAM,WAAW,+BAA+B;IAC9C,sEAAsE;IACtE,uBAAuB,EAAE,uBAAuB,CAAC;IACjD,qEAAqE;IACrE,uBAAuB,EAAE,uBAAuB,CAAC;IACjD;;;OAGG;IACH,yBAAyB,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACpH,0EAA0E;IAC1E,2BAA2B,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACrH,8DAA8D;IAC9D,cAAc,EAAE,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC;CAC5C;AAsDD;;;;;;GAMG;AACH,wBAAgB,8BAA8B,CAC5C,KAAK,EAAE,8BAA8B,GACpC,+BAA+B,CAsGjC"}
@@ -0,0 +1,160 @@
1
+ "use strict";
2
+ /**
3
+ * Policy Evaluation Summaries Orchestration
4
+ * ------------------------------------------
5
+ * Extracts the duplicated policy-exception-summary + governance-summary
6
+ * shaping logic previously duplicated at:
7
+ * - `commands/verify.ts:2610–2709` (executePolicyOnlyMode)
8
+ * - `commands/verify.ts:4818–4889` (verifyCommand main flow)
9
+ *
10
+ * RESPONSIBILITIES (data-pure):
11
+ * - shape `policyExceptionsSummary` from exceptionDecision + resolution
12
+ * - shape `policyGovernanceSummary` from governance + audit status
13
+ * - apply audit-integrity violation to the effective violation list
14
+ * - apply shouldIgnore filtering to suppressed/blocked violation lists
15
+ * - compute `policyDecision` from effective violations
16
+ *
17
+ * EXPLICITLY NOT RESPONSIBLE FOR:
18
+ * - calling `applyPolicyExceptions` (caller owns that before invoking us)
19
+ * - calling `resolveEffectivePolicyExceptions` (caller owns that)
20
+ * - rendering (chalk, console.log)
21
+ * - emitting JSON or exiting
22
+ *
23
+ * SEMANTIC PRESERVATION:
24
+ * The output shapes are byte-identical to the prior inline implementations.
25
+ * Field order matches the inline construction so JSON serialization is stable.
26
+ *
27
+ * REPLAY INVARIANT:
28
+ * - `explainExceptionEligibilityReason` moved from verify.ts (private) to here
29
+ * - `resolvePolicyDecisionFromViolations` duplicated as a pure local helper to
30
+ * avoid circular import — semantics are identical
31
+ */
32
+ Object.defineProperty(exports, "__esModule", { value: true });
33
+ exports.buildPolicyEvaluationSummaries = buildPolicyEvaluationSummaries;
34
+ // ── Private helpers ───────────────────────────────────────────────────────────
35
+ /**
36
+ * Maps an eligibility-reason code to a human-readable message.
37
+ * Moved from verify.ts:1940 (was private, only used in the regions being extracted).
38
+ */
39
+ function explainExceptionEligibilityReason(reason) {
40
+ switch (reason) {
41
+ case 'reason_required':
42
+ return 'exception reason does not meet governance minimum length';
43
+ case 'duration_exceeds_max':
44
+ return 'exception expiry window exceeds governance maximum duration';
45
+ case 'approval_required':
46
+ return 'exception exists but approvals are required';
47
+ case 'critical_approvals_required':
48
+ return 'critical rule exception requires additional independent approvals';
49
+ case 'insufficient_approvals':
50
+ return 'exception exists but approval threshold is not met';
51
+ case 'self_approval_only':
52
+ return 'exception only has requester self-approval';
53
+ case 'approver_not_allowed':
54
+ return 'exception approvals are from non-allowlisted approvers';
55
+ default:
56
+ return 'exception is inactive or expired';
57
+ }
58
+ }
59
+ /** Pure decision helper — identical semantics to verify.ts:1924. */
60
+ function policyDecisionFromViolations(violations) {
61
+ let hasWarn = false;
62
+ for (const v of violations) {
63
+ const sev = String(v.severity || '').toLowerCase();
64
+ if (sev === 'block')
65
+ return 'block';
66
+ if (sev === 'warn')
67
+ hasWarn = true;
68
+ }
69
+ return hasWarn ? 'warn' : 'allow';
70
+ }
71
+ // ── Public API ────────────────────────────────────────────────────────────────
72
+ /**
73
+ * Build the shaped policy-exception and governance-audit summaries.
74
+ *
75
+ * Replaces the duplicated inline shaping regions in both
76
+ * `executePolicyOnlyMode` and the main `verifyCommand` flow.
77
+ * Does not emit JSON, does not log, does not exit.
78
+ */
79
+ function buildPolicyEvaluationSummaries(input) {
80
+ const { exceptionDecision, policyExceptionResolution, policyViolations, exceptionApprovals, audit, auditIntegrity, shouldIgnore, policyAuditFile, } = input;
81
+ // ── Filter suppressed/blocked by shouldIgnore ─────────────────────────────
82
+ const suppressedViolations = exceptionDecision.suppressedViolations.filter((item) => !shouldIgnore(item.file));
83
+ const blockedPolicyViolationItems = exceptionDecision.blockedViolations
84
+ .filter((item) => !shouldIgnore(item.file))
85
+ .map((item) => ({
86
+ file: item.file,
87
+ rule: item.rule,
88
+ severity: 'block',
89
+ message: `Exception ${item.exceptionId} cannot be applied: ${explainExceptionEligibilityReason(item.eligibilityReason)}` +
90
+ (item.requiredApprovals > 0
91
+ ? ` (approvals ${item.effectiveApprovals}/${item.requiredApprovals}${item.critical ? ', critical rule gate' : ''})`
92
+ : ''),
93
+ ...(item.line != null ? { line: item.line } : {}),
94
+ }));
95
+ // ── Effective violations = remaining + blocked (after ignore filtering) ───
96
+ let effectivePolicyViolations = [
97
+ ...exceptionDecision.remainingViolations.filter((item) => !shouldIgnore(item.file)),
98
+ ...blockedPolicyViolationItems,
99
+ ];
100
+ // ── Audit integrity violation (additive when enforcement enabled) ─────────
101
+ if (audit.requireIntegrity && !auditIntegrity.valid) {
102
+ effectivePolicyViolations.push({
103
+ file: policyAuditFile,
104
+ rule: 'policy_audit_integrity',
105
+ severity: 'block',
106
+ message: `Policy audit chain is invalid: ${auditIntegrity.issues.join('; ') || 'unknown issue'}`,
107
+ });
108
+ }
109
+ const policyDecision = policyDecisionFromViolations(effectivePolicyViolations);
110
+ // ── policyExceptionsSummary (field order matches prior inline) ────────────
111
+ const policyExceptionsSummary = {
112
+ sourceMode: policyExceptionResolution.mode,
113
+ sourceWarning: policyExceptionResolution.warning,
114
+ localConfigured: policyExceptionResolution.localConfigured,
115
+ orgConfigured: policyExceptionResolution.orgConfigured,
116
+ configured: policyExceptionResolution.exceptions.length,
117
+ active: exceptionDecision.activeExceptions.length,
118
+ usable: exceptionDecision.usableExceptions.length,
119
+ matched: exceptionDecision.matchedExceptionIds.length,
120
+ suppressed: suppressedViolations.length,
121
+ blocked: blockedPolicyViolationItems.length,
122
+ matchedExceptionIds: exceptionDecision.matchedExceptionIds,
123
+ suppressedViolations: suppressedViolations.map((item) => ({
124
+ file: item.file,
125
+ rule: item.rule,
126
+ severity: item.severity,
127
+ message: item.message,
128
+ exceptionId: item.exceptionId,
129
+ reason: item.reason,
130
+ expiresAt: item.expiresAt,
131
+ ...(item.line != null ? { startLine: item.line } : {}),
132
+ })),
133
+ blockedViolations: blockedPolicyViolationItems.map((item) => ({
134
+ file: item.file,
135
+ rule: item.rule,
136
+ severity: item.severity,
137
+ message: item.message,
138
+ ...(item.line != null ? { startLine: item.line } : {}),
139
+ })),
140
+ };
141
+ // ── policyGovernanceSummary (field order matches prior inline) ────────────
142
+ const policyGovernanceSummary = {
143
+ exceptionApprovals,
144
+ audit: {
145
+ requireIntegrity: audit.requireIntegrity,
146
+ valid: auditIntegrity.valid,
147
+ issues: auditIntegrity.issues,
148
+ lastHash: auditIntegrity.lastHash,
149
+ eventCount: auditIntegrity.count,
150
+ },
151
+ };
152
+ return {
153
+ policyExceptionsSummary,
154
+ policyGovernanceSummary,
155
+ effectivePolicyViolations,
156
+ blockedPolicyViolationItems,
157
+ policyDecision,
158
+ };
159
+ }
160
+ //# sourceMappingURL=policy-evaluation-summaries.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"policy-evaluation-summaries.js","sourceRoot":"","sources":["../../../../src/governance/pipeline/orchestration/policy-evaluation-summaries.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;;AAsLH,wEAwGC;AAnKD,iFAAiF;AAEjF;;;GAGG;AACH,SAAS,iCAAiC,CACxC,MAQ0B;IAE1B,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,iBAAiB;YACpB,OAAO,0DAA0D,CAAC;QACpE,KAAK,sBAAsB;YACzB,OAAO,6DAA6D,CAAC;QACvE,KAAK,mBAAmB;YACtB,OAAO,6CAA6C,CAAC;QACvD,KAAK,6BAA6B;YAChC,OAAO,mEAAmE,CAAC;QAC7E,KAAK,wBAAwB;YAC3B,OAAO,oDAAoD,CAAC;QAC9D,KAAK,oBAAoB;YACvB,OAAO,4CAA4C,CAAC;QACtD,KAAK,sBAAsB;YACzB,OAAO,wDAAwD,CAAC;QAClE;YACE,OAAO,kCAAkC,CAAC;IAC9C,CAAC;AACH,CAAC;AAED,oEAAoE;AACpE,SAAS,4BAA4B,CACnC,UAAuC;IAEvC,IAAI,OAAO,GAAG,KAAK,CAAC;IACpB,KAAK,MAAM,CAAC,IAAI,UAAU,EAAE,CAAC;QAC3B,MAAM,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;QACnD,IAAI,GAAG,KAAK,OAAO;YAAE,OAAO,OAAO,CAAC;QACpC,IAAI,GAAG,KAAK,MAAM;YAAE,OAAO,GAAG,IAAI,CAAC;IACrC,CAAC;IACD,OAAO,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC;AACpC,CAAC;AAED,iFAAiF;AAEjF;;;;;;GAMG;AACH,SAAgB,8BAA8B,CAC5C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