@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,108 @@
1
+ "use strict";
2
+ /**
3
+ * Bounded deterministic glob matcher for intent governance.
4
+ *
5
+ * Why a local implementation:
6
+ * - Zero filesystem access. Pattern-vs-string only.
7
+ * - Replay determinism: identical (pattern, path) → identical boolean, forever.
8
+ * - No dependency on `glob`, `minimatch`, or `micromatch` (which have version drift,
9
+ * locale-sensitive behaviour, and historical bugs around `**` semantics).
10
+ *
11
+ * Supported syntax (intentionally minimal):
12
+ * `**` — match any number of path segments (including zero)
13
+ * `*` — match any sequence of chars except `/`
14
+ * `?` — match exactly one char except `/`
15
+ * Literal characters match themselves. No brace expansion, no character classes,
16
+ * no negation (negation is expressed at the contract layer, not the glob layer).
17
+ *
18
+ * Paths are normalised to forward slashes before matching. Leading `./` is stripped.
19
+ *
20
+ * Intelligence classification: DETERMINISTIC.
21
+ */
22
+ Object.defineProperty(exports, "__esModule", { value: true });
23
+ exports.normalizePathForGlob = normalizePathForGlob;
24
+ exports.compileGlob = compileGlob;
25
+ exports.matchesGlob = matchesGlob;
26
+ exports.matchesAnyGlob = matchesAnyGlob;
27
+ exports.firstMatchingGlob = firstMatchingGlob;
28
+ const ESCAPE_RE = /[.+^${}()|[\]\\]/g;
29
+ /** Normalise a file path for matching: forward slashes, no leading `./`. */
30
+ function normalizePathForGlob(path) {
31
+ let p = path.replace(/\\/g, '/');
32
+ if (p.startsWith('./'))
33
+ p = p.slice(2);
34
+ return p;
35
+ }
36
+ /**
37
+ * Compile a glob into a deterministic RegExp.
38
+ * The regex is anchored: it matches the full path, not a substring.
39
+ */
40
+ function compileGlob(pattern) {
41
+ const normalized = normalizePathForGlob(pattern);
42
+ let i = 0;
43
+ let out = '^';
44
+ while (i < normalized.length) {
45
+ const c = normalized[i];
46
+ // `**` — any number of segments (zero or more)
47
+ if (c === '*' && normalized[i + 1] === '*') {
48
+ // `**/` or `/**` collapses to "anything (including empty)" without trailing slash artifacts
49
+ if (normalized[i + 2] === '/') {
50
+ out += '(?:.*/)?';
51
+ i += 3;
52
+ continue;
53
+ }
54
+ out += '.*';
55
+ i += 2;
56
+ continue;
57
+ }
58
+ // `*` — any chars except `/`
59
+ if (c === '*') {
60
+ out += '[^/]*';
61
+ i += 1;
62
+ continue;
63
+ }
64
+ // `?` — one char except `/`
65
+ if (c === '?') {
66
+ out += '[^/]';
67
+ i += 1;
68
+ continue;
69
+ }
70
+ // literal
71
+ out += c.replace(ESCAPE_RE, '\\$&');
72
+ i += 1;
73
+ }
74
+ out += '$';
75
+ return new RegExp(out);
76
+ }
77
+ /**
78
+ * Test whether `path` matches `pattern`. Both are normalised before comparison.
79
+ * Pure function — same inputs always produce the same output.
80
+ */
81
+ function matchesGlob(pattern, path) {
82
+ return compileGlob(pattern).test(normalizePathForGlob(path));
83
+ }
84
+ /**
85
+ * Return true if `path` matches any pattern in `patterns`.
86
+ * Useful for layer membership checks where multiple globs are OR'd together.
87
+ */
88
+ function matchesAnyGlob(patterns, path) {
89
+ const normalised = normalizePathForGlob(path);
90
+ for (const pattern of patterns) {
91
+ if (compileGlob(pattern).test(normalised))
92
+ return true;
93
+ }
94
+ return false;
95
+ }
96
+ /**
97
+ * Return the first pattern in `patterns` that matches `path`, or `null` if none match.
98
+ * Order matters — caller is responsible for arranging patterns in priority order.
99
+ */
100
+ function firstMatchingGlob(patterns, path) {
101
+ const normalised = normalizePathForGlob(path);
102
+ for (const pattern of patterns) {
103
+ if (compileGlob(pattern).test(normalised))
104
+ return pattern;
105
+ }
106
+ return null;
107
+ }
108
+ //# sourceMappingURL=glob-match.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"glob-match.js","sourceRoot":"","sources":["../../../src/governance/intent/glob-match.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;AAKH,oDAIC;AAMD,kCAwCC;A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AI,CAAC,CAAC;YACP,SAAS;QACX,CAAC;QAED,UAAU;QACV,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;QACpC,CAAC,IAAI,CAAC,CAAC;IACT,CAAC;IACD,GAAG,IAAI,GAAG,CAAC;IACX,OAAO,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC;AACzB,CAAC;AAED;;;GAGG;AACH,SAAgB,WAAW,CAAC,OAAe,EAAE,IAAY;IACvD,OAAO,WAAW,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC,CAAC;AAC/D,CAAC;AAED;;;GAGG;AACH,SAAgB,cAAc,CAAC,QAA+B,EAAE,IAAY;IAC1E,MAAM,UAAU,GAAG,oBAAoB,CAAC,IAAI,CAAC,CAAC;IAC9C,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC/B,IAAI,WAAW,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC;YAAE,OAAO,IAAI,CAAC;IACzD,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;GAGG;AACH,SAAgB,iBAAiB,CAC/B,QAA+B,EAC/B,IAAY;IAEZ,MAAM,UAAU,GAAG,oBAAoB,CAAC,IAAI,CAAC,CAAC;IAC9C,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC/B,IAAI,WAAW,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC;YAAE,OAAO,OAAO,CAAC;IAC5D,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Import Graph Extraction — bounded, deterministic, diff-scoped.
3
+ *
4
+ * Extracts import edges (file → imported specifier) from the **added** lines of
5
+ * a parsed diff. This is intentionally narrow:
6
+ *
7
+ * - **Bounded scope**: only files in the diff, only added lines.
8
+ * We never re-parse the entire project. This keeps drift detection fast
9
+ * and proportional to the size of the change, not the size of the codebase.
10
+ *
11
+ * - **Regex-based parsing**: not AST. For governance signals on imports
12
+ * specifically, ECMAScript `import`/`require` statements are unambiguous
13
+ * enough that regex matches what an AST would catch. False positives in
14
+ * pathological edge cases (e.g. import strings inside template literals)
15
+ * are acceptable — drift findings are advisory in Phase 1.
16
+ *
17
+ * - **TS/JS/Python first**: matchers for ESM imports, CJS requires, and
18
+ * Python `from X import` / `import X`. Other languages can be added as
19
+ * additional matcher entries.
20
+ *
21
+ * Intelligence classification: DETERMINISTIC.
22
+ */
23
+ import type { DiffFile } from '@neurcode-ai/diff-parser';
24
+ /**
25
+ * One extracted import edge: a file imports a specifier on a specific line.
26
+ *
27
+ * `specifier` is the literal string from the source (e.g. `"./auth/login"`,
28
+ * `"@neurcode-ai/diff-parser"`, `"sqlalchemy.orm"`). Resolution to a layer is
29
+ * the next phase's job — this module produces raw, faithful edges.
30
+ */
31
+ export interface ImportEdge {
32
+ /** Source file (project-relative). */
33
+ fromFile: string;
34
+ /** Raw imported specifier. */
35
+ specifier: string;
36
+ /** 1-based line number (best-effort, from the diff hunk). */
37
+ line: number;
38
+ /** Original matched text — used in drift reports as evidence. */
39
+ rawStatement: string;
40
+ /** Which matcher produced this edge. Aids debuggability. */
41
+ matcherId: string;
42
+ }
43
+ /**
44
+ * Extract all import edges from the added lines of the diff.
45
+ *
46
+ * Pure function — same `diffFiles` produces the same `ImportEdge[]` every time,
47
+ * with deterministic ordering (files in input order; lines in hunk order;
48
+ * matchers in declaration order).
49
+ */
50
+ export declare function extractImportEdgesFromDiff(diffFiles: DiffFile[]): ImportEdge[];
51
+ /**
52
+ * Group edges by source file. Used by the drift detector to iterate
53
+ * file-by-file when classifying layers.
54
+ */
55
+ export declare function groupImportEdgesByFile(edges: ImportEdge[]): Map<string, ImportEdge[]>;
56
+ //# sourceMappingURL=import-graph.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"import-graph.d.ts","sourceRoot":"","sources":["../../../src/governance/intent/import-graph.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAIzD;;;;;;GAMG;AACH,MAAM,WAAW,UAAU;IACzB,sCAAsC;IACtC,QAAQ,EAAE,MAAM,CAAC;IACjB,8BAA8B;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,6DAA6D;IAC7D,IAAI,EAAE,MAAM,CAAC;IACb,iEAAiE;IACjE,YAAY,EAAE,MAAM,CAAC;IACrB,4DAA4D;IAC5D,SAAS,EAAE,MAAM,CAAC;CACnB;AAoDD;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CAAC,SAAS,EAAE,QAAQ,EAAE,GAAG,UAAU,EAAE,CAsB9E;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,UAAU,EAAE,GAAG,GAAG,CAAC,MAAM,EAAE,UAAU,EAAE,CAAC,CAWrF"}
@@ -0,0 +1,133 @@
1
+ "use strict";
2
+ /**
3
+ * Import Graph Extraction — bounded, deterministic, diff-scoped.
4
+ *
5
+ * Extracts import edges (file → imported specifier) from the **added** lines of
6
+ * a parsed diff. This is intentionally narrow:
7
+ *
8
+ * - **Bounded scope**: only files in the diff, only added lines.
9
+ * We never re-parse the entire project. This keeps drift detection fast
10
+ * and proportional to the size of the change, not the size of the codebase.
11
+ *
12
+ * - **Regex-based parsing**: not AST. For governance signals on imports
13
+ * specifically, ECMAScript `import`/`require` statements are unambiguous
14
+ * enough that regex matches what an AST would catch. False positives in
15
+ * pathological edge cases (e.g. import strings inside template literals)
16
+ * are acceptable — drift findings are advisory in Phase 1.
17
+ *
18
+ * - **TS/JS/Python first**: matchers for ESM imports, CJS requires, and
19
+ * Python `from X import` / `import X`. Other languages can be added as
20
+ * additional matcher entries.
21
+ *
22
+ * Intelligence classification: DETERMINISTIC.
23
+ */
24
+ Object.defineProperty(exports, "__esModule", { value: true });
25
+ exports.extractImportEdgesFromDiff = extractImportEdgesFromDiff;
26
+ exports.groupImportEdgesByFile = groupImportEdgesByFile;
27
+ /**
28
+ * The matcher set. Order is irrelevant — every matcher is run against every
29
+ * added line. A single line could in theory match multiple matchers; in
30
+ * practice the regexes are disjoint.
31
+ */
32
+ const IMPORT_MATCHERS = [
33
+ // ESM: `import X from "..."`, `import "..."`, `import { X } from "..."`
34
+ {
35
+ id: 'esm-import-from',
36
+ pattern: /\bimport\s+[^'"]*?from\s+['"]([^'"]+)['"]/,
37
+ },
38
+ {
39
+ id: 'esm-import-side-effect',
40
+ pattern: /\bimport\s+['"]([^'"]+)['"]/,
41
+ },
42
+ // ESM: dynamic `import("...")`
43
+ {
44
+ id: 'esm-import-dynamic',
45
+ pattern: /\bimport\s*\(\s*['"]([^'"]+)['"]\s*\)/,
46
+ },
47
+ // CJS: `require("...")`
48
+ {
49
+ id: 'cjs-require',
50
+ pattern: /\brequire\s*\(\s*['"]([^'"]+)['"]\s*\)/,
51
+ },
52
+ // Python: `from foo.bar import baz`
53
+ {
54
+ id: 'py-from-import',
55
+ pattern: /^\s*from\s+([\w.]+)\s+import\s+/,
56
+ },
57
+ // Python: `import foo.bar`
58
+ {
59
+ id: 'py-import',
60
+ pattern: /^\s*import\s+([\w.]+)(?:\s+as\s+\w+)?\s*$/,
61
+ },
62
+ ];
63
+ // ── Public API ───────────────────────────────────────────────────────────────
64
+ /**
65
+ * Extract all import edges from the added lines of the diff.
66
+ *
67
+ * Pure function — same `diffFiles` produces the same `ImportEdge[]` every time,
68
+ * with deterministic ordering (files in input order; lines in hunk order;
69
+ * matchers in declaration order).
70
+ */
71
+ function extractImportEdgesFromDiff(diffFiles) {
72
+ const edges = [];
73
+ for (const file of diffFiles) {
74
+ if (!file.hunks)
75
+ continue;
76
+ for (const hunk of file.hunks) {
77
+ if (!hunk.lines)
78
+ continue;
79
+ // newStart is the line number of the first line in the new file
80
+ let currentLine = hunk.newStart ?? 1;
81
+ for (const line of hunk.lines) {
82
+ if (line.type === 'added') {
83
+ collectMatchesFromLine(file.path, line.content ?? '', currentLine, edges);
84
+ currentLine += 1;
85
+ }
86
+ else if (line.type === 'context') {
87
+ currentLine += 1;
88
+ }
89
+ // 'removed' lines do not advance newStart counter
90
+ }
91
+ }
92
+ }
93
+ return edges;
94
+ }
95
+ /**
96
+ * Group edges by source file. Used by the drift detector to iterate
97
+ * file-by-file when classifying layers.
98
+ */
99
+ function groupImportEdgesByFile(edges) {
100
+ const grouped = new Map();
101
+ for (const edge of edges) {
102
+ const existing = grouped.get(edge.fromFile);
103
+ if (existing) {
104
+ existing.push(edge);
105
+ }
106
+ else {
107
+ grouped.set(edge.fromFile, [edge]);
108
+ }
109
+ }
110
+ return grouped;
111
+ }
112
+ // ── Internal ─────────────────────────────────────────────────────────────────
113
+ function collectMatchesFromLine(fromFile, rawContent, line, out) {
114
+ // Diff hunks may include a leading "+" in some representations; the
115
+ // @neurcode-ai/diff-parser strips it but we guard defensively.
116
+ const content = rawContent.startsWith('+') ? rawContent.slice(1) : rawContent;
117
+ for (const matcher of IMPORT_MATCHERS) {
118
+ const match = matcher.pattern.exec(content);
119
+ if (!match)
120
+ continue;
121
+ const specifier = match[1];
122
+ if (!specifier)
123
+ continue;
124
+ out.push({
125
+ fromFile,
126
+ specifier,
127
+ line,
128
+ rawStatement: content.trim(),
129
+ matcherId: matcher.id,
130
+ });
131
+ }
132
+ }
133
+ //# sourceMappingURL=import-graph.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"import-graph.js","sourceRoot":"","sources":["../../../src/governance/intent/import-graph.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;;AAmFH,gEAsBC;AAMD,wDAWC;AArFD;;;;GAIG;AACH,MAAM,eAAe,GAAoB;IACvC,wEAAwE;IACxE;QACE,EAAE,EAAE,iBAAiB;QACrB,OAAO,EAAE,2CAA2C;KACrD;IACD;QACE,EAAE,EAAE,wBAAwB;QAC5B,OAAO,EAAE,6B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ent.json`) → typed IntentGraph
6
+ * - Deterministic import-graph extraction from a diff
7
+ * - Deterministic architectural drift detection (layer rules)
8
+ * - Explicit intelligence-boundary classification
9
+ *
10
+ * What this module is NOT:
11
+ * - A graph database
12
+ * - An AI-driven architecture inferrer
13
+ * - A replacement for change-contract or the intent-engine (NL coverage)
14
+ *
15
+ * See individual modules for the principles each surface adheres to.
16
+ */
17
+ export { EMPTY_INTENT_GRAPH, INTENT_GRAPH_SCHEMA_VERSION, isEmptyIntentGraph, intentGraphHasEnforcement, type IntentEdge, type IntentGraph, type IntentLayer, type IntentModule, type IntentTrustBoundary, } from './intent-graph';
18
+ export { INTENT_CONTRACT_FILENAME, INTENT_CONTRACT_RELATIVE_PATH, buildIntentGraphFromRaw, loadIntentContract, resolveIntentContractPath, type IntentContractLoadResult, } from './intent-contract';
19
+ export { compileGlob, firstMatchingGlob, matchesAnyGlob, matchesGlob, normalizePathForGlob, } from './glob-match';
20
+ export { extractImportEdgesFromDiff, groupImportEdgesByFile, type ImportEdge, } from './import-graph';
21
+ export { intentGraphIsEnforceable, runDriftDetection, type ClassifiedFile, type DriftDetectorInput, type DriftReport, type DriftViolation, } from './drift-detector';
22
+ export { activeIntelligenceClasses, getIntelligenceClassificationMap, hasNonDeterministicSurface, PHASE_1_SURFACES, type IntelligenceClass, type IntelligenceSurface, } from './intelligence-boundaries';
23
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/governance/intent/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EACL,kBAAkB,EAClB,2BAA2B,EAC3B,kBAAkB,EAClB,yBAAyB,EACzB,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,mBAAmB,GACzB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,wBAAwB,EACxB,6BAA6B,EAC7B,uBAAuB,EACvB,kBAAkB,EAClB,yBAAyB,EACzB,KAAK,wBAAwB,GAC9B,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,WAAW,EACX,iBAAiB,EACjB,cAAc,EACd,WAAW,EACX,oBAAoB,GACrB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,0BAA0B,EAC1B,sBAAsB,EACtB,KAAK,UAAU,GAChB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,wBAAwB,EACxB,iBAAiB,EACjB,KAAK,cAAc,EACnB,KAAK,kBAAkB,EACvB,KAAK,WAAW,EAChB,KAAK,cAAc,GACpB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,yBAAyB,EACzB,gCAAgC,EAChC,0BAA0B,EAC1B,gBAAgB,EAChB,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,GACzB,MAAM,2BAA2B,CAAC"}
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ /**
3
+ * Intent-Aware Governance — public surface.
4
+ *
5
+ * Phase 1 capabilities:
6
+ * - Declarative intent contract (`.neurcode/intent.json`) → typed IntentGraph
7
+ * - Deterministic import-graph extraction from a diff
8
+ * - Deterministic architectural drift detection (layer rules)
9
+ * - Explicit intelligence-boundary classification
10
+ *
11
+ * What this module is NOT:
12
+ * - A graph database
13
+ * - An AI-driven architecture inferrer
14
+ * - A replacement for change-contract or the intent-engine (NL coverage)
15
+ *
16
+ * See individual modules for the principles each surface adheres to.
17
+ */
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports.PHASE_1_SURFACES = exports.hasNonDeterministicSurface = exports.getIntelligenceClassificationMap = exports.activeIntelligenceClasses = exports.runDriftDetection = exports.intentGraphIsEnforceable = exports.groupImportEdgesByFile = exports.extractImportEdgesFromDiff = exports.normalizePathForGlob = exports.matchesGlob = exports.matchesAnyGlob = exports.firstMatchingGlob = exports.compileGlob = exports.resolveIntentContractPath = exports.loadIntentContract = exports.buildIntentGraphFromRaw = exports.INTENT_CONTRACT_RELATIVE_PATH = exports.INTENT_CONTRACT_FILENAME = exports.intentGraphHasEnforcement = exports.isEmptyIntentGraph = exports.INTENT_GRAPH_SCHEMA_VERSION = exports.EMPTY_INTENT_GRAPH = void 0;
20
+ var intent_graph_1 = require("./intent-graph");
21
+ Object.defineProperty(exports, "EMPTY_INTENT_GRAPH", { enumerable: true, get: function () { return intent_graph_1.EMPTY_INTENT_GRAPH; } });
22
+ Object.defineProperty(exports, "INTENT_GRAPH_SCHEMA_VERSION", { enumerable: true, get: function () { return intent_graph_1.INTENT_GRAPH_SCHEMA_VERSION; } });
23
+ Object.defineProperty(exports, "isEmptyIntentGraph", { enumerable: true, get: function () { return intent_graph_1.isEmptyIntentGraph; } });
24
+ Object.defineProperty(exports, "intentGraphHasEnforcement", { enumerable: true, get: function () { return intent_graph_1.intentGraphHasEnforcement; } });
25
+ var intent_contract_1 = require("./intent-contract");
26
+ Object.defineProperty(exports, "INTENT_CONTRACT_FILENAME", { enumerable: true, get: function () { return intent_contract_1.INTENT_CONTRACT_FILENAME; } });
27
+ Object.defineProperty(exports, "INTENT_CONTRACT_RELATIVE_PATH", { enumerable: true, get: function () { return intent_contract_1.INTENT_CONTRACT_RELATIVE_PATH; } });
28
+ Object.defineProperty(exports, "buildIntentGraphFromRaw", { enumerable: true, get: function () { return intent_contract_1.buildIntentGraphFromRaw; } });
29
+ Object.defineProperty(exports, "loadIntentContract", { enumerable: true, get: function () { return intent_contract_1.loadIntentContract; } });
30
+ Object.defineProperty(exports, "resolveIntentContractPath", { enumerable: true, get: function () { return intent_contract_1.resolveIntentContractPath; } });
31
+ var glob_match_1 = require("./glob-match");
32
+ Object.defineProperty(exports, "compileGlob", { enumerable: true, get: function () { return glob_match_1.compileGlob; } });
33
+ Object.defineProperty(exports, "firstMatchingGlob", { enumerable: true, get: function () { return glob_match_1.firstMatchingGlob; } });
34
+ Object.defineProperty(exports, "matchesAnyGlob", { enumerable: true, get: function () { return glob_match_1.matchesAnyGlob; } });
35
+ Object.defineProperty(exports, "matchesGlob", { enumerable: true, get: function () { return glob_match_1.matchesGlob; } });
36
+ Object.defineProperty(exports, "normalizePathForGlob", { enumerable: true, get: function () { return glob_match_1.normalizePathForGlob; } });
37
+ var import_graph_1 = require("./import-graph");
38
+ Object.defineProperty(exports, "extractImportEdgesFromDiff", { enumerable: true, get: function () { return import_graph_1.extractImportEdgesFromDiff; } });
39
+ Object.defineProperty(exports, "groupImportEdgesByFile", { enumerable: true, get: function () { return import_graph_1.groupImportEdgesByFile; } });
40
+ var drift_detector_1 = require("./drift-detector");
41
+ Object.defineProperty(exports, "intentGraphIsEnforceable", { enumerable: true, get: function () { return drift_detector_1.intentGraphIsEnforceable; } });
42
+ Object.defineProperty(exports, "runDriftDetection", { enumerable: true, get: function () { return drift_detector_1.runDriftDetection; } });
43
+ var intelligence_boundaries_1 = require("./intelligence-boundaries");
44
+ Object.defineProperty(exports, "activeIntelligenceClasses", { enumerable: true, get: function () { return intelligence_boundaries_1.activeIntelligenceClasses; } });
45
+ Object.defineProperty(exports, "getIntelligenceClassificationMap", { enumerable: true, get: function () { return intelligence_boundaries_1.getIntelligenceClassificationMap; } });
46
+ Object.defineProperty(exports, "hasNonDeterministicSurface", { enumerable: true, get: function () { return intelligence_boundaries_1.hasNonDeterministicSurface; } });
47
+ Object.defineProperty(exports, "PHASE_1_SURFACES", { enumerable: true, get: function () { return intelligence_boundaries_1.PHASE_1_SURFACES; } });
48
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/governance/intent/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;AAEH,+CAUwB;AATtB,kHAAA,kBAAkB,OAAA;AAClB,2HAAA,2BAA2B,OAAA;AAC3B,kHAAA,kBAAkB,OAAA;AAClB,yHAAA,yBAAyB,OAAA;AAQ3B,qDAO2B;AANzB,2HAAA,wBAAwB,OAAA;AACxB,gIAAA,6BAA6B,OAAA;AAC7B,0HAAA,uBAAuB,OAAA;AACvB,qHAAA,kBAAkB,OAAA;AAClB,4HAAA,yBAAyB,OAAA;AAI3B,2CAMsB;AALpB,yGAAA,WAAW,OAAA;AACX,+GAAA,iBAAiB,OAAA;AACjB,4GAAA,cAAc,OAAA;AACd,yGAAA,WAAW,OAAA;AACX,kHAAA,oBAAoB,OAAA;AAGtB,+CAIwB;AAHtB,0HAAA,0BAA0B,OAAA;AAC1B,sHAAA,sBAAsB,OAAA;AAIxB,mDAO0B;AANxB,0HAAA,wBAAwB,OAAA;AACxB,mHAAA,iBAAiB,OAAA;AAOnB,qEAOmC;AANjC,oIAAA,yBAAyB,OAAA;AACzB,2IAAA,gCAAgC,OAAA;AAChC,qIAAA,0BAA0B,OAAA;AAC1B,2HAAA,gBAAgB,OAAA"}
@@ -0,0 +1,69 @@
1
+ /**
2
+ * Intelligence Boundaries — explicit classification of every governance-intelligence
3
+ * surface in the intent module.
4
+ *
5
+ * NEURCODE'S NON-NEGOTIABLE PRINCIPLE:
6
+ *
7
+ * Governance findings must be **explainable**, **deterministic-first**, and
8
+ * **bounded**. A finding's source must be inspectable. AI augmentation, when
9
+ * it exists, must be optional, advisory, and clearly labelled. Opaque AI
10
+ * governance theater is BANNED.
11
+ *
12
+ * This file enumerates every function/surface in `governance/intent/*` and
13
+ * assigns one of four classifications:
14
+ *
15
+ * - `deterministic` : Same input → same output, no randomness, no I/O,
16
+ * no probabilistic models. Findings are direct
17
+ * consequences of declared rules.
18
+ *
19
+ * - `heuristic` : Pattern-based reasoning with bounded confidence.
20
+ * May have false positives/negatives. Used for
21
+ * fallback classification, never for blocking decisions.
22
+ *
23
+ * - `ai_augmented` : Uses an LLM or external model. Output is advisory-only.
24
+ * Must include the model output AND the deterministic
25
+ * findings side-by-side so reviewers can compare.
26
+ *
27
+ * - `banned` : Forbidden patterns. Used as a guard against accidental
28
+ * introduction of opaque AI paths.
29
+ *
30
+ * Phase 1 INVARIANT: Every surface in the intent module is `deterministic` or
31
+ * `banned`. There are NO heuristic or AI-augmented surfaces yet. Future phases
32
+ * may introduce them, but only with explicit board-review and a corresponding
33
+ * entry here.
34
+ *
35
+ * Testing: `intent-governance.test.ts` enforces that the classification map is
36
+ * complete and contains no AI-augmented entries in Phase 1.
37
+ */
38
+ export type IntelligenceClass = 'deterministic' | 'heuristic' | 'ai_augmented' | 'banned';
39
+ export interface IntelligenceSurface {
40
+ /** Module path + exported symbol, e.g. `governance/intent/drift-detector#runDriftDetection`. */
41
+ surface: string;
42
+ classification: IntelligenceClass;
43
+ /** Brief justification, shown in audit reports. */
44
+ rationale: string;
45
+ }
46
+ /**
47
+ * The canonical Phase 1 classification map. This is the SOURCE OF TRUTH for
48
+ * how every intent-module surface is classified. Tests assert that:
49
+ * - No surface is `ai_augmented` in Phase 1.
50
+ * - Every public export of the intent module appears here.
51
+ * - No `banned` patterns are reachable from the public API.
52
+ */
53
+ export declare const PHASE_1_SURFACES: IntelligenceSurface[];
54
+ /**
55
+ * Returns the classification map. Use this in audit/replay payloads to record
56
+ * which intelligence classes were active for this verify run.
57
+ */
58
+ export declare function getIntelligenceClassificationMap(): IntelligenceSurface[];
59
+ /**
60
+ * Returns the unique set of classifications present in the map.
61
+ * Useful for assertions like "this build has no AI-augmented surfaces".
62
+ */
63
+ export declare function activeIntelligenceClasses(): IntelligenceClass[];
64
+ /**
65
+ * Returns true if any surface is classified as `ai_augmented` or `heuristic`.
66
+ * In Phase 1 this MUST return false. The CI test asserts this invariant.
67
+ */
68
+ export declare function hasNonDeterministicSurface(): boolean;
69
+ //# sourceMappingURL=intelligence-boundaries.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"intelligence-boundaries.d.ts","sourceRoot":"","sources":["../../../src/governance/intent/intelligence-boundaries.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAIH,MAAM,MAAM,iBAAiB,GACzB,eAAe,GACf,WAAW,GACX,cAAc,GACd,QAAQ,CAAC;AAEb,MAAM,WAAW,mBAAmB;IAClC,gGAAgG;IAChG,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,iBAAiB,CAAC;IAClC,mDAAmD;IACnD,SAAS,EAAE,MAAM,CAAC;CACnB;AAID;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,EAAE,mBAAmB,EAsFjD,CAAC;AAIF;;;GAGG;AACH,wBAAgB,gCAAgC,IAAI,mBAAmB,EAAE,CAGxE;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,IAAI,iBAAiB,EAAE,CAI/D;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,IAAI,OAAO,CAOpD"}
@@ -0,0 +1,163 @@
1
+ "use strict";
2
+ /**
3
+ * Intelligence Boundaries — explicit classification of every governance-intelligence
4
+ * surface in the intent module.
5
+ *
6
+ * NEURCODE'S NON-NEGOTIABLE PRINCIPLE:
7
+ *
8
+ * Governance findings must be **explainable**, **deterministic-first**, and
9
+ * **bounded**. A finding's source must be inspectable. AI augmentation, when
10
+ * it exists, must be optional, advisory, and clearly labelled. Opaque AI
11
+ * governance theater is BANNED.
12
+ *
13
+ * This file enumerates every function/surface in `governance/intent/*` and
14
+ * assigns one of four classifications:
15
+ *
16
+ * - `deterministic` : Same input → same output, no randomness, no I/O,
17
+ * no probabilistic models. Findings are direct
18
+ * consequences of declared rules.
19
+ *
20
+ * - `heuristic` : Pattern-based reasoning with bounded confidence.
21
+ * May have false positives/negatives. Used for
22
+ * fallback classification, never for blocking decisions.
23
+ *
24
+ * - `ai_augmented` : Uses an LLM or external model. Output is advisory-only.
25
+ * Must include the model output AND the deterministic
26
+ * findings side-by-side so reviewers can compare.
27
+ *
28
+ * - `banned` : Forbidden patterns. Used as a guard against accidental
29
+ * introduction of opaque AI paths.
30
+ *
31
+ * Phase 1 INVARIANT: Every surface in the intent module is `deterministic` or
32
+ * `banned`. There are NO heuristic or AI-augmented surfaces yet. Future phases
33
+ * may introduce them, but only with explicit board-review and a corresponding
34
+ * entry here.
35
+ *
36
+ * Testing: `intent-governance.test.ts` enforces that the classification map is
37
+ * complete and contains no AI-augmented entries in Phase 1.
38
+ */
39
+ Object.defineProperty(exports, "__esModule", { value: true });
40
+ exports.PHASE_1_SURFACES = void 0;
41
+ exports.getIntelligenceClassificationMap = getIntelligenceClassificationMap;
42
+ exports.activeIntelligenceClasses = activeIntelligenceClasses;
43
+ exports.hasNonDeterministicSurface = hasNonDeterministicSurface;
44
+ // ── Phase 1 surface map ──────────────────────────────────────────────────────
45
+ /**
46
+ * The canonical Phase 1 classification map. This is the SOURCE OF TRUTH for
47
+ * how every intent-module surface is classified. Tests assert that:
48
+ * - No surface is `ai_augmented` in Phase 1.
49
+ * - Every public export of the intent module appears here.
50
+ * - No `banned` patterns are reachable from the public API.
51
+ */
52
+ exports.PHASE_1_SURFACES = [
53
+ // intent-graph.ts
54
+ {
55
+ surface: 'governance/intent/intent-graph#IntentGraph',
56
+ classification: 'deterministic',
57
+ rationale: 'Pure TypeScript type. Carries no runtime behaviour.',
58
+ },
59
+ {
60
+ surface: 'governance/intent/intent-graph#isEmptyIntentGraph',
61
+ classification: 'deterministic',
62
+ rationale: 'Pure predicate over graph shape.',
63
+ },
64
+ {
65
+ surface: 'governance/intent/intent-graph#intentGraphHasEnforcement',
66
+ classification: 'deterministic',
67
+ rationale: 'Pure predicate over graph shape.',
68
+ },
69
+ // intent-contract.ts
70
+ {
71
+ surface: 'governance/intent/intent-contract#loadIntentContract',
72
+ classification: 'deterministic',
73
+ rationale: 'Reads a JSON file from disk. Same file bytes → same graph. ' +
74
+ 'No network, no clock, no randomness. Filesystem read is the only I/O.',
75
+ },
76
+ {
77
+ surface: 'governance/intent/intent-contract#buildIntentGraphFromRaw',
78
+ classification: 'deterministic',
79
+ rationale: 'Pure parser/validator. No I/O.',
80
+ },
81
+ {
82
+ surface: 'governance/intent/intent-contract#resolveIntentContractPath',
83
+ classification: 'deterministic',
84
+ rationale: 'Path arithmetic only.',
85
+ },
86
+ // glob-match.ts
87
+ {
88
+ surface: 'governance/intent/glob-match#compileGlob',
89
+ classification: 'deterministic',
90
+ rationale: 'Pure pattern compilation to RegExp.',
91
+ },
92
+ {
93
+ surface: 'governance/intent/glob-match#matchesGlob',
94
+ classification: 'deterministic',
95
+ rationale: 'Pure regex test.',
96
+ },
97
+ {
98
+ surface: 'governance/intent/glob-match#matchesAnyGlob',
99
+ classification: 'deterministic',
100
+ rationale: 'Pure regex test over an array.',
101
+ },
102
+ {
103
+ surface: 'governance/intent/glob-match#firstMatchingGlob',
104
+ classification: 'deterministic',
105
+ rationale: 'Pure regex test; returns first matching pattern.',
106
+ },
107
+ // import-graph.ts
108
+ {
109
+ surface: 'governance/intent/import-graph#extractImportEdgesFromDiff',
110
+ classification: 'deterministic',
111
+ rationale: 'Regex-based extraction from the added lines of a parsed diff. Output is a ' +
112
+ 'pure function of the input diff. No project-level AST, no filesystem access.',
113
+ },
114
+ {
115
+ surface: 'governance/intent/import-graph#groupImportEdgesByFile',
116
+ classification: 'deterministic',
117
+ rationale: 'Pure grouping of edges by `fromFile`.',
118
+ },
119
+ // drift-detector.ts
120
+ {
121
+ surface: 'governance/intent/drift-detector#runDriftDetection',
122
+ classification: 'deterministic',
123
+ rationale: 'Pure function of (graph, diffFiles). Same inputs → same DriftReport, ' +
124
+ 'including identical violation ordering (sorted by file/line/specifier).',
125
+ },
126
+ {
127
+ surface: 'governance/intent/drift-detector#intentGraphIsEnforceable',
128
+ classification: 'deterministic',
129
+ rationale: 'Pure predicate.',
130
+ },
131
+ ];
132
+ // ── Public predicates ────────────────────────────────────────────────────────
133
+ /**
134
+ * Returns the classification map. Use this in audit/replay payloads to record
135
+ * which intelligence classes were active for this verify run.
136
+ */
137
+ function getIntelligenceClassificationMap() {
138
+ // Return a shallow copy so callers cannot mutate the canonical map.
139
+ return exports.PHASE_1_SURFACES.slice();
140
+ }
141
+ /**
142
+ * Returns the unique set of classifications present in the map.
143
+ * Useful for assertions like "this build has no AI-augmented surfaces".
144
+ */
145
+ function activeIntelligenceClasses() {
146
+ const set = new Set();
147
+ for (const s of exports.PHASE_1_SURFACES)
148
+ set.add(s.classification);
149
+ return [...set].sort();
150
+ }
151
+ /**
152
+ * Returns true if any surface is classified as `ai_augmented` or `heuristic`.
153
+ * In Phase 1 this MUST return false. The CI test asserts this invariant.
154
+ */
155
+ function hasNonDeterministicSurface() {
156
+ for (const s of exports.PHASE_1_SURFACES) {
157
+ if (s.classification === 'ai_augmented' || s.classification === 'heuristic') {
158
+ return true;
159
+ }
160
+ }
161
+ return false;
162
+ }
163
+ //# sourceMappingURL=intelligence-boundaries.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"intelligence-boundaries.js","sourceRoot":"","sources":["../../../src/governance/intent/intelligence-boundaries.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;;;AAyHH,4EAGC;AAMD,8DAIC;AAMD,gEAOC;AAjID,gFAAgF;AAEhF;;;;;;GAMG;AACU,QAAA,gBAAgB,GAA0B;IACrD,kBAAkB;IAClB;QACE,OAAO,EAAE,4CAA4C;QACrD,cAAc,EAAE,eAAe;QAC/B,SAAS,EAAE,qDAAqD;KACjE;IACD;QACE,OAAO,EAAE,mDAAmD;QAC5D,cAAc,EAAE,eAAe;QAC/B,SAAS,EAAE,kCAAkC;KAC9C;IACD;QACE,OAAO,EAAE,0DAA0D;QACnE,cAAc,EAAE,eAAe;QAC/B,SAAS,EAAE,kCAAkC;KAC9C;IAED,qBAAqB;IACrB;QACE,OAAO,EAAE,sDAAsD;QAC/D,cAAc,EAAE,eAAe;QAC/B,SAAS,EACP,6DAA6D;YAC7D,uEAAuE;KAC1E;IACD;QACE,OAAO,EAAE,2DAA2D;QACpE,cAAc,EAAE,eAAe;QAC/B,SAAS,EAAE,gCAAgC;KAC5C;IACD;QACE,OAAO,EAAE,6DAA6D;QACtE,cAAc,EAAE,eAAe;QAC/B,SAAS,EAAE,uBAAuB;KACnC;IAED,gBAAgB;I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