@neurcode-ai/cli 0.9.64 → 0.9.66

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 (323) hide show
  1. package/LICENSE +201 -0
  2. package/dist/commands/bootstrap-policy.d.ts +29 -0
  3. package/dist/commands/bootstrap-policy.d.ts.map +1 -0
  4. package/dist/commands/bootstrap-policy.js +334 -0
  5. package/dist/commands/bootstrap-policy.js.map +1 -0
  6. package/dist/commands/brain.d.ts.map +1 -1
  7. package/dist/commands/brain.js +273 -0
  8. package/dist/commands/brain.js.map +1 -1
  9. package/dist/commands/doctor.d.ts.map +1 -1
  10. package/dist/commands/doctor.js +82 -0
  11. package/dist/commands/doctor.js.map +1 -1
  12. package/dist/commands/pilot-report.d.ts +9 -0
  13. package/dist/commands/pilot-report.d.ts.map +1 -0
  14. package/dist/commands/pilot-report.js +176 -0
  15. package/dist/commands/pilot-report.js.map +1 -0
  16. package/dist/commands/quickstart.d.ts +21 -0
  17. package/dist/commands/quickstart.d.ts.map +1 -0
  18. package/dist/commands/quickstart.js +178 -0
  19. package/dist/commands/quickstart.js.map +1 -0
  20. package/dist/commands/remediate-export.d.ts +31 -0
  21. package/dist/commands/remediate-export.d.ts.map +1 -0
  22. package/dist/commands/remediate-export.js +283 -0
  23. package/dist/commands/remediate-export.js.map +1 -0
  24. package/dist/commands/remediate-governance.d.ts +54 -0
  25. package/dist/commands/remediate-governance.d.ts.map +1 -0
  26. package/dist/commands/remediate-governance.js +375 -0
  27. package/dist/commands/remediate-governance.js.map +1 -0
  28. package/dist/commands/remediate.d.ts.map +1 -1
  29. package/dist/commands/remediate.js.map +1 -1
  30. package/dist/commands/replay.d.ts.map +1 -1
  31. package/dist/commands/replay.js +30 -0
  32. package/dist/commands/replay.js.map +1 -1
  33. package/dist/commands/verify.d.ts.map +1 -1
  34. package/dist/commands/verify.js +409 -30
  35. package/dist/commands/verify.js.map +1 -1
  36. package/dist/daemon/server.d.ts.map +1 -1
  37. package/dist/daemon/server.js +1078 -0
  38. package/dist/daemon/server.js.map +1 -1
  39. package/dist/explainability/DeterminismClassifier.d.ts +34 -0
  40. package/dist/explainability/DeterminismClassifier.d.ts.map +1 -0
  41. package/dist/explainability/DeterminismClassifier.js +104 -0
  42. package/dist/explainability/DeterminismClassifier.js.map +1 -0
  43. package/dist/explainability/ViolationFormatter.d.ts +32 -0
  44. package/dist/explainability/ViolationFormatter.d.ts.map +1 -0
  45. package/dist/explainability/ViolationFormatter.js +252 -0
  46. package/dist/explainability/ViolationFormatter.js.map +1 -0
  47. package/dist/explainability/index.d.ts +15 -0
  48. package/dist/explainability/index.d.ts.map +1 -0
  49. package/dist/explainability/index.js +94 -0
  50. package/dist/explainability/index.js.map +1 -0
  51. package/dist/explainability/types.d.ts +37 -0
  52. package/dist/explainability/types.d.ts.map +1 -0
  53. package/dist/explainability/types.js +3 -0
  54. package/dist/explainability/types.js.map +1 -0
  55. package/dist/governance/canonical-invariants.d.ts +88 -0
  56. package/dist/governance/canonical-invariants.d.ts.map +1 -0
  57. package/dist/governance/canonical-invariants.js +197 -0
  58. package/dist/governance/canonical-invariants.js.map +1 -0
  59. package/dist/governance/canonical-ordering.d.ts +76 -0
  60. package/dist/governance/canonical-ordering.d.ts.map +1 -0
  61. package/dist/governance/canonical-ordering.js +189 -0
  62. package/dist/governance/canonical-ordering.js.map +1 -0
  63. package/dist/governance/canonical-pipeline.d.ts +45 -0
  64. package/dist/governance/canonical-pipeline.d.ts.map +1 -0
  65. package/dist/governance/canonical-pipeline.js +616 -0
  66. package/dist/governance/canonical-pipeline.js.map +1 -0
  67. package/dist/governance/diff-line-provenance.d.ts +59 -0
  68. package/dist/governance/diff-line-provenance.d.ts.map +1 -0
  69. package/dist/governance/diff-line-provenance.js +118 -0
  70. package/dist/governance/diff-line-provenance.js.map +1 -0
  71. package/dist/governance/pilot-readiness.d.ts +34 -0
  72. package/dist/governance/pilot-readiness.d.ts.map +1 -0
  73. package/dist/governance/pilot-readiness.js +226 -0
  74. package/dist/governance/pilot-readiness.js.map +1 -0
  75. package/dist/governance/policy-parity-validator.d.ts +62 -0
  76. package/dist/governance/policy-parity-validator.d.ts.map +1 -0
  77. package/dist/governance/policy-parity-validator.js +137 -0
  78. package/dist/governance/policy-parity-validator.js.map +1 -0
  79. package/dist/governance/remediation-boundary.d.ts +55 -0
  80. package/dist/governance/remediation-boundary.d.ts.map +1 -0
  81. package/dist/governance/remediation-boundary.js +120 -0
  82. package/dist/governance/remediation-boundary.js.map +1 -0
  83. package/dist/governance/structural-cache.d.ts +103 -0
  84. package/dist/governance/structural-cache.d.ts.map +1 -0
  85. package/dist/governance/structural-cache.js +240 -0
  86. package/dist/governance/structural-cache.js.map +1 -0
  87. package/dist/governance/structural-on-diff.d.ts +33 -0
  88. package/dist/governance/structural-on-diff.d.ts.map +1 -0
  89. package/dist/governance/structural-on-diff.js +67 -0
  90. package/dist/governance/structural-on-diff.js.map +1 -0
  91. package/dist/governance/structural-policy-merge.d.ts +22 -0
  92. package/dist/governance/structural-policy-merge.d.ts.map +1 -0
  93. package/dist/governance/structural-policy-merge.js +32 -0
  94. package/dist/governance/structural-policy-merge.js.map +1 -0
  95. package/dist/governance/verify-runtime-guard.d.ts +99 -0
  96. package/dist/governance/verify-runtime-guard.d.ts.map +1 -0
  97. package/dist/governance/verify-runtime-guard.js +129 -0
  98. package/dist/governance/verify-runtime-guard.js.map +1 -0
  99. package/dist/index.js +107 -0
  100. package/dist/index.js.map +1 -1
  101. package/dist/integrations/review-compression/index.d.ts +50 -0
  102. package/dist/integrations/review-compression/index.d.ts.map +1 -0
  103. package/dist/integrations/review-compression/index.js +158 -0
  104. package/dist/integrations/review-compression/index.js.map +1 -0
  105. package/dist/intent-engine/domain-taxonomy.d.ts +42 -0
  106. package/dist/intent-engine/domain-taxonomy.d.ts.map +1 -0
  107. package/dist/intent-engine/domain-taxonomy.js +534 -0
  108. package/dist/intent-engine/domain-taxonomy.js.map +1 -0
  109. package/dist/intent-engine/index.d.ts +1 -0
  110. package/dist/intent-engine/index.d.ts.map +1 -1
  111. package/dist/intent-engine/index.js +6 -1
  112. package/dist/intent-engine/index.js.map +1 -1
  113. package/dist/intent-engine/parser.d.ts.map +1 -1
  114. package/dist/intent-engine/parser.js +47 -0
  115. package/dist/intent-engine/parser.js.map +1 -1
  116. package/dist/intent-engine/repo-classifier.d.ts +64 -0
  117. package/dist/intent-engine/repo-classifier.d.ts.map +1 -0
  118. package/dist/intent-engine/repo-classifier.js +178 -0
  119. package/dist/intent-engine/repo-classifier.js.map +1 -0
  120. package/dist/intent-engine/semantic-expander.d.ts +104 -0
  121. package/dist/intent-engine/semantic-expander.d.ts.map +1 -0
  122. package/dist/intent-engine/semantic-expander.js +480 -0
  123. package/dist/intent-engine/semantic-expander.js.map +1 -0
  124. package/dist/patch-engine/patterns.d.ts.map +1 -1
  125. package/dist/patch-engine/patterns.js +8 -4
  126. package/dist/patch-engine/patterns.js.map +1 -1
  127. package/dist/semantic/index.d.ts +14 -0
  128. package/dist/semantic/index.d.ts.map +1 -0
  129. package/dist/semantic/index.js +30 -0
  130. package/dist/semantic/index.js.map +1 -0
  131. package/dist/semantic/tfidf-engine.d.ts +81 -0
  132. package/dist/semantic/tfidf-engine.d.ts.map +1 -0
  133. package/dist/semantic/tfidf-engine.js +278 -0
  134. package/dist/semantic/tfidf-engine.js.map +1 -0
  135. package/dist/semantic/vector-store.d.ts +108 -0
  136. package/dist/semantic/vector-store.d.ts.map +1 -0
  137. package/dist/semantic/vector-store.js +321 -0
  138. package/dist/semantic/vector-store.js.map +1 -0
  139. package/dist/structural-rules/context-severity.d.ts +46 -0
  140. package/dist/structural-rules/context-severity.d.ts.map +1 -0
  141. package/dist/structural-rules/context-severity.js +115 -0
  142. package/dist/structural-rules/context-severity.js.map +1 -0
  143. package/dist/structural-rules/distributed/DS001-saga-rollback-absence.d.ts +11 -0
  144. package/dist/structural-rules/distributed/DS001-saga-rollback-absence.d.ts.map +1 -0
  145. package/dist/structural-rules/distributed/DS001-saga-rollback-absence.js +212 -0
  146. package/dist/structural-rules/distributed/DS001-saga-rollback-absence.js.map +1 -0
  147. package/dist/structural-rules/distributed/DS002-missing-correlation-id.d.ts +11 -0
  148. package/dist/structural-rules/distributed/DS002-missing-correlation-id.d.ts.map +1 -0
  149. package/dist/structural-rules/distributed/DS002-missing-correlation-id.js +213 -0
  150. package/dist/structural-rules/distributed/DS002-missing-correlation-id.js.map +1 -0
  151. package/dist/structural-rules/distributed/index.d.ts +3 -0
  152. package/dist/structural-rules/distributed/index.d.ts.map +1 -0
  153. package/dist/structural-rules/distributed/index.js +8 -0
  154. package/dist/structural-rules/distributed/index.js.map +1 -0
  155. package/dist/structural-rules/engine.d.ts +25 -0
  156. package/dist/structural-rules/engine.d.ts.map +1 -0
  157. package/dist/structural-rules/engine.js +90 -0
  158. package/dist/structural-rules/engine.js.map +1 -0
  159. package/dist/structural-rules/index.d.ts +45 -0
  160. package/dist/structural-rules/index.d.ts.map +1 -0
  161. package/dist/structural-rules/index.js +158 -0
  162. package/dist/structural-rules/index.js.map +1 -0
  163. package/dist/structural-rules/python/PY001-asyncio-task-without-cancel.d.ts +11 -0
  164. package/dist/structural-rules/python/PY001-asyncio-task-without-cancel.d.ts.map +1 -0
  165. package/dist/structural-rules/python/PY001-asyncio-task-without-cancel.js +66 -0
  166. package/dist/structural-rules/python/PY001-asyncio-task-without-cancel.js.map +1 -0
  167. package/dist/structural-rules/python/PY002-unbounded-dict-singleton.d.ts +11 -0
  168. package/dist/structural-rules/python/PY002-unbounded-dict-singleton.d.ts.map +1 -0
  169. package/dist/structural-rules/python/PY002-unbounded-dict-singleton.js +135 -0
  170. package/dist/structural-rules/python/PY002-unbounded-dict-singleton.js.map +1 -0
  171. package/dist/structural-rules/python/PY003-broad-except-clause.d.ts +32 -0
  172. package/dist/structural-rules/python/PY003-broad-except-clause.d.ts.map +1 -0
  173. package/dist/structural-rules/python/PY003-broad-except-clause.js +277 -0
  174. package/dist/structural-rules/python/PY003-broad-except-clause.js.map +1 -0
  175. package/dist/structural-rules/python/PY004-swallowed-async-exception.d.ts +11 -0
  176. package/dist/structural-rules/python/PY004-swallowed-async-exception.d.ts.map +1 -0
  177. package/dist/structural-rules/python/PY004-swallowed-async-exception.js +167 -0
  178. package/dist/structural-rules/python/PY004-swallowed-async-exception.js.map +1 -0
  179. package/dist/structural-rules/python/PY005-fastapi-without-pydantic.d.ts +11 -0
  180. package/dist/structural-rules/python/PY005-fastapi-without-pydantic.d.ts.map +1 -0
  181. package/dist/structural-rules/python/PY005-fastapi-without-pydantic.js +154 -0
  182. package/dist/structural-rules/python/PY005-fastapi-without-pydantic.js.map +1 -0
  183. package/dist/structural-rules/python/PY006-blocking-io-in-async.d.ts +11 -0
  184. package/dist/structural-rules/python/PY006-blocking-io-in-async.d.ts.map +1 -0
  185. package/dist/structural-rules/python/PY006-blocking-io-in-async.js +130 -0
  186. package/dist/structural-rules/python/PY006-blocking-io-in-async.js.map +1 -0
  187. package/dist/structural-rules/python/PY007-sqlalchemy-session-leak.d.ts +11 -0
  188. package/dist/structural-rules/python/PY007-sqlalchemy-session-leak.d.ts.map +1 -0
  189. package/dist/structural-rules/python/PY007-sqlalchemy-session-leak.js +93 -0
  190. package/dist/structural-rules/python/PY007-sqlalchemy-session-leak.js.map +1 -0
  191. package/dist/structural-rules/python/PY008-celery-task-without-retry.d.ts +11 -0
  192. package/dist/structural-rules/python/PY008-celery-task-without-retry.d.ts.map +1 -0
  193. package/dist/structural-rules/python/PY008-celery-task-without-retry.js +154 -0
  194. package/dist/structural-rules/python/PY008-celery-task-without-retry.js.map +1 -0
  195. package/dist/structural-rules/python/PY009-unsafe-pickle-deserialization.d.ts +11 -0
  196. package/dist/structural-rules/python/PY009-unsafe-pickle-deserialization.d.ts.map +1 -0
  197. package/dist/structural-rules/python/PY009-unsafe-pickle-deserialization.js +133 -0
  198. package/dist/structural-rules/python/PY009-unsafe-pickle-deserialization.js.map +1 -0
  199. package/dist/structural-rules/python/PY010-leaked-aiohttp-session.d.ts +11 -0
  200. package/dist/structural-rules/python/PY010-leaked-aiohttp-session.d.ts.map +1 -0
  201. package/dist/structural-rules/python/PY010-leaked-aiohttp-session.js +80 -0
  202. package/dist/structural-rules/python/PY010-leaked-aiohttp-session.js.map +1 -0
  203. package/dist/structural-rules/python/PY011-thread-lifecycle.d.ts +11 -0
  204. package/dist/structural-rules/python/PY011-thread-lifecycle.d.ts.map +1 -0
  205. package/dist/structural-rules/python/PY011-thread-lifecycle.js +97 -0
  206. package/dist/structural-rules/python/PY011-thread-lifecycle.js.map +1 -0
  207. package/dist/structural-rules/python/PY012-asyncio-run-misuse.d.ts +11 -0
  208. package/dist/structural-rules/python/PY012-asyncio-run-misuse.d.ts.map +1 -0
  209. package/dist/structural-rules/python/PY012-asyncio-run-misuse.js +83 -0
  210. package/dist/structural-rules/python/PY012-asyncio-run-misuse.js.map +1 -0
  211. package/dist/structural-rules/python/PY013-mutable-default-arg.d.ts +11 -0
  212. package/dist/structural-rules/python/PY013-mutable-default-arg.d.ts.map +1 -0
  213. package/dist/structural-rules/python/PY013-mutable-default-arg.js +73 -0
  214. package/dist/structural-rules/python/PY013-mutable-default-arg.js.map +1 -0
  215. package/dist/structural-rules/python/PY014-fixed-sleep-retry.d.ts +11 -0
  216. package/dist/structural-rules/python/PY014-fixed-sleep-retry.d.ts.map +1 -0
  217. package/dist/structural-rules/python/PY014-fixed-sleep-retry.js +115 -0
  218. package/dist/structural-rules/python/PY014-fixed-sleep-retry.js.map +1 -0
  219. package/dist/structural-rules/rules/SR001-swallowed-async-rejection.d.ts +11 -0
  220. package/dist/structural-rules/rules/SR001-swallowed-async-rejection.d.ts.map +1 -0
  221. package/dist/structural-rules/rules/SR001-swallowed-async-rejection.js +145 -0
  222. package/dist/structural-rules/rules/SR001-swallowed-async-rejection.js.map +1 -0
  223. package/dist/structural-rules/rules/SR002-unbounded-collection.d.ts +11 -0
  224. package/dist/structural-rules/rules/SR002-unbounded-collection.d.ts.map +1 -0
  225. package/dist/structural-rules/rules/SR002-unbounded-collection.js +196 -0
  226. package/dist/structural-rules/rules/SR002-unbounded-collection.js.map +1 -0
  227. package/dist/structural-rules/rules/SR003-timer-without-cleanup.d.ts +11 -0
  228. package/dist/structural-rules/rules/SR003-timer-without-cleanup.d.ts.map +1 -0
  229. package/dist/structural-rules/rules/SR003-timer-without-cleanup.js +148 -0
  230. package/dist/structural-rules/rules/SR003-timer-without-cleanup.js.map +1 -0
  231. package/dist/structural-rules/rules/SR004-request-boundary-no-validation.d.ts +11 -0
  232. package/dist/structural-rules/rules/SR004-request-boundary-no-validation.d.ts.map +1 -0
  233. package/dist/structural-rules/rules/SR004-request-boundary-no-validation.js +162 -0
  234. package/dist/structural-rules/rules/SR004-request-boundary-no-validation.js.map +1 -0
  235. package/dist/structural-rules/rules/SR005-halfopen-probe-gate.d.ts +11 -0
  236. package/dist/structural-rules/rules/SR005-halfopen-probe-gate.d.ts.map +1 -0
  237. package/dist/structural-rules/rules/SR005-halfopen-probe-gate.js +150 -0
  238. package/dist/structural-rules/rules/SR005-halfopen-probe-gate.js.map +1 -0
  239. package/dist/structural-rules/rules/SR006-fanout-error-sanitization.d.ts +11 -0
  240. package/dist/structural-rules/rules/SR006-fanout-error-sanitization.d.ts.map +1 -0
  241. package/dist/structural-rules/rules/SR006-fanout-error-sanitization.js +161 -0
  242. package/dist/structural-rules/rules/SR006-fanout-error-sanitization.js.map +1 -0
  243. package/dist/structural-rules/rules/SR007-cross-request-error.d.ts +11 -0
  244. package/dist/structural-rules/rules/SR007-cross-request-error.d.ts.map +1 -0
  245. package/dist/structural-rules/rules/SR007-cross-request-error.js +175 -0
  246. package/dist/structural-rules/rules/SR007-cross-request-error.js.map +1 -0
  247. package/dist/structural-rules/rules/SR008-background-task-orphan.d.ts +11 -0
  248. package/dist/structural-rules/rules/SR008-background-task-orphan.d.ts.map +1 -0
  249. package/dist/structural-rules/rules/SR008-background-task-orphan.js +176 -0
  250. package/dist/structural-rules/rules/SR008-background-task-orphan.js.map +1 -0
  251. package/dist/structural-rules/rules/SR009-missing-retry-backoff.d.ts +11 -0
  252. package/dist/structural-rules/rules/SR009-missing-retry-backoff.d.ts.map +1 -0
  253. package/dist/structural-rules/rules/SR009-missing-retry-backoff.js +168 -0
  254. package/dist/structural-rules/rules/SR009-missing-retry-backoff.js.map +1 -0
  255. package/dist/structural-rules/rules/SR010-retry-storm.d.ts +11 -0
  256. package/dist/structural-rules/rules/SR010-retry-storm.d.ts.map +1 -0
  257. package/dist/structural-rules/rules/SR010-retry-storm.js +181 -0
  258. package/dist/structural-rules/rules/SR010-retry-storm.js.map +1 -0
  259. package/dist/structural-rules/rules/SR011-event-listener-leak.d.ts +11 -0
  260. package/dist/structural-rules/rules/SR011-event-listener-leak.d.ts.map +1 -0
  261. package/dist/structural-rules/rules/SR011-event-listener-leak.js +208 -0
  262. package/dist/structural-rules/rules/SR011-event-listener-leak.js.map +1 -0
  263. package/dist/structural-rules/rules/SR012-promise-race-leak.d.ts +11 -0
  264. package/dist/structural-rules/rules/SR012-promise-race-leak.d.ts.map +1 -0
  265. package/dist/structural-rules/rules/SR012-promise-race-leak.js +191 -0
  266. package/dist/structural-rules/rules/SR012-promise-race-leak.js.map +1 -0
  267. package/dist/structural-rules/rules/SR013-missing-idempotency-key.d.ts +11 -0
  268. package/dist/structural-rules/rules/SR013-missing-idempotency-key.d.ts.map +1 -0
  269. package/dist/structural-rules/rules/SR013-missing-idempotency-key.js +219 -0
  270. package/dist/structural-rules/rules/SR013-missing-idempotency-key.js.map +1 -0
  271. package/dist/structural-rules/rules/SR014-mutable-closure-async.d.ts +11 -0
  272. package/dist/structural-rules/rules/SR014-mutable-closure-async.d.ts.map +1 -0
  273. package/dist/structural-rules/rules/SR014-mutable-closure-async.js +208 -0
  274. package/dist/structural-rules/rules/SR014-mutable-closure-async.js.map +1 -0
  275. package/dist/structural-rules/rules/SR015-dangling-abort-controller.d.ts +11 -0
  276. package/dist/structural-rules/rules/SR015-dangling-abort-controller.d.ts.map +1 -0
  277. package/dist/structural-rules/rules/SR015-dangling-abort-controller.js +190 -0
  278. package/dist/structural-rules/rules/SR015-dangling-abort-controller.js.map +1 -0
  279. package/dist/structural-rules/rules/SR016-unsafe-json-parse.d.ts +11 -0
  280. package/dist/structural-rules/rules/SR016-unsafe-json-parse.d.ts.map +1 -0
  281. package/dist/structural-rules/rules/SR016-unsafe-json-parse.js +187 -0
  282. package/dist/structural-rules/rules/SR016-unsafe-json-parse.js.map +1 -0
  283. package/dist/structural-rules/suppressions.d.ts +43 -0
  284. package/dist/structural-rules/suppressions.d.ts.map +1 -0
  285. package/dist/structural-rules/suppressions.js +115 -0
  286. package/dist/structural-rules/suppressions.js.map +1 -0
  287. package/dist/structural-rules/types.d.ts +55 -0
  288. package/dist/structural-rules/types.d.ts.map +1 -0
  289. package/dist/structural-rules/types.js +3 -0
  290. package/dist/structural-rules/types.js.map +1 -0
  291. package/dist/utils/brain-cache.d.ts +100 -0
  292. package/dist/utils/brain-cache.d.ts.map +1 -0
  293. package/dist/utils/brain-cache.js +346 -0
  294. package/dist/utils/brain-cache.js.map +1 -0
  295. package/dist/utils/governance-provenance.d.ts +95 -0
  296. package/dist/utils/governance-provenance.d.ts.map +1 -0
  297. package/dist/utils/governance-provenance.js +187 -0
  298. package/dist/utils/governance-provenance.js.map +1 -0
  299. package/dist/utils/pilot-metrics.d.ts +46 -0
  300. package/dist/utils/pilot-metrics.d.ts.map +1 -0
  301. package/dist/utils/pilot-metrics.js +240 -0
  302. package/dist/utils/pilot-metrics.js.map +1 -0
  303. package/dist/utils/replay-runtime.d.ts +34 -0
  304. package/dist/utils/replay-runtime.d.ts.map +1 -1
  305. package/dist/utils/replay-runtime.js +207 -0
  306. package/dist/utils/replay-runtime.js.map +1 -1
  307. package/dist/utils/verify-runtime-stability.d.ts +142 -0
  308. package/dist/utils/verify-runtime-stability.d.ts.map +1 -0
  309. package/dist/utils/verify-runtime-stability.js +230 -0
  310. package/dist/utils/verify-runtime-stability.js.map +1 -0
  311. package/dist/workspace/cross-repo-graph.d.ts +111 -0
  312. package/dist/workspace/cross-repo-graph.d.ts.map +1 -0
  313. package/dist/workspace/cross-repo-graph.js +450 -0
  314. package/dist/workspace/cross-repo-graph.js.map +1 -0
  315. package/dist/workspace/federated-context.d.ts +144 -0
  316. package/dist/workspace/federated-context.d.ts.map +1 -0
  317. package/dist/workspace/federated-context.js +347 -0
  318. package/dist/workspace/federated-context.js.map +1 -0
  319. package/dist/workspace/index.d.ts +38 -0
  320. package/dist/workspace/index.d.ts.map +1 -0
  321. package/dist/workspace/index.js +48 -0
  322. package/dist/workspace/index.js.map +1 -0
  323. package/package.json +9 -9
@@ -0,0 +1,230 @@
1
+ "use strict";
2
+ /**
3
+ * Verify Runtime Stability (Phase 4 — Verify Runtime Stability)
4
+ *
5
+ * Bounded execution guarantees for enterprise CI environments.
6
+ *
7
+ * Provides:
8
+ * 1. Hard execution timeouts with graceful partial-result preservation
9
+ * 2. Large repo detection and cache-build recommendations
10
+ * 3. Memory pressure tracking with layered degradation
11
+ * 4. Runtime transparency — every degraded mode is explicitly reported
12
+ *
13
+ * Layered degradation order (when memory or time pressure is detected):
14
+ * 1. Semantic layer first (LLM-assisted planning, intent expansion)
15
+ * 2. Advisory systems second (heuristic signals, advisory-only rules)
16
+ * 3. NEVER structural governance — AST-backed structural verification
17
+ * MUST remain operational even under full degradation
18
+ *
19
+ * Design constraints:
20
+ * - All timeouts are configurable via environment variables
21
+ * - Degradation is explicit and reported in verify output
22
+ * - Partial findings are always preserved (never silently dropped)
23
+ * - Structural governance is protected by construction
24
+ */
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.MEMORY_DEGRADE_ADVISORY_THRESHOLD = exports.MEMORY_DEGRADE_SEMANTIC_THRESHOLD = exports.LARGE_REPO_FILE_THRESHOLD = exports.CI_VERIFY_MAX_MS = exports.LOCAL_VERIFY_MAX_MS = void 0;
27
+ exports.createVerifyRuntimeContext = createVerifyRuntimeContext;
28
+ exports.isTimedOut = isTimedOut;
29
+ exports.elapsedMs = elapsedMs;
30
+ exports.remainingMs = remainingMs;
31
+ exports.isTimePressure = isTimePressure;
32
+ exports.getHeapUsedFraction = getHeapUsedFraction;
33
+ exports.applyMemoryPressureDegradation = applyMemoryPressureDegradation;
34
+ exports.estimateRepoFileCount = estimateRepoFileCount;
35
+ exports.applyLargeRepoProtection = applyLargeRepoProtection;
36
+ exports.shouldSkipSemanticLayer = shouldSkipSemanticLayer;
37
+ exports.shouldSkipAdvisoryLayer = shouldSkipAdvisoryLayer;
38
+ exports.buildVerifyRuntimeReport = buildVerifyRuntimeReport;
39
+ const child_process_1 = require("child_process");
40
+ // ── Constants ─────────────────────────────────────────────────────────────────
41
+ /** Local verify max wall-clock time (90s default) */
42
+ exports.LOCAL_VERIFY_MAX_MS = parseInt(process.env['NEURCODE_VERIFY_TIMEOUT_LOCAL'] ?? '', 10) || 90_000;
43
+ /** CI verify max wall-clock time (180s default) */
44
+ exports.CI_VERIFY_MAX_MS = parseInt(process.env['NEURCODE_VERIFY_TIMEOUT_CI'] ?? '', 10) || 180_000;
45
+ /** Repo size threshold for large-repo warning (10,000 files) */
46
+ exports.LARGE_REPO_FILE_THRESHOLD = parseInt(process.env['NEURCODE_LARGE_REPO_THRESHOLD'] ?? '', 10) || 10_000;
47
+ /** Heap usage fraction above which semantic layer is degraded (0.75 = 75%) */
48
+ exports.MEMORY_DEGRADE_SEMANTIC_THRESHOLD = 0.75;
49
+ /** Heap usage fraction above which advisory layer is degraded (0.90 = 90%) */
50
+ exports.MEMORY_DEGRADE_ADVISORY_THRESHOLD = 0.90;
51
+ // ── Runtime context ───────────────────────────────────────────────────────────
52
+ /**
53
+ * Create a new verify runtime context.
54
+ * Call once at the start of verify execution.
55
+ */
56
+ function createVerifyRuntimeContext(isCI) {
57
+ return {
58
+ isCI,
59
+ timeoutMs: isCI ? exports.CI_VERIFY_MAX_MS : exports.LOCAL_VERIFY_MAX_MS,
60
+ startedAt: Date.now(),
61
+ degradedLayers: new Set(),
62
+ degradationReasons: [],
63
+ skippedSubsystems: [],
64
+ largeRepoMode: false,
65
+ estimatedFileCount: null,
66
+ };
67
+ }
68
+ // ── Time pressure ─────────────────────────────────────────────────────────────
69
+ /**
70
+ * Check if the verify execution has exceeded its time budget.
71
+ *
72
+ * @returns true if timeout has been exceeded
73
+ */
74
+ function isTimedOut(ctx) {
75
+ return (Date.now() - ctx.startedAt) >= ctx.timeoutMs;
76
+ }
77
+ /**
78
+ * Get elapsed time in milliseconds since verify started.
79
+ */
80
+ function elapsedMs(ctx) {
81
+ return Date.now() - ctx.startedAt;
82
+ }
83
+ /**
84
+ * Get remaining time in milliseconds before timeout.
85
+ */
86
+ function remainingMs(ctx) {
87
+ return Math.max(0, ctx.timeoutMs - elapsedMs(ctx));
88
+ }
89
+ /**
90
+ * Check if remaining time is below a given threshold.
91
+ * Use to preemptively skip expensive operations.
92
+ *
93
+ * @param ctx Runtime context
94
+ * @param thresholdMs Time threshold in ms (default: 5000ms)
95
+ */
96
+ function isTimePressure(ctx, thresholdMs = 5_000) {
97
+ return remainingMs(ctx) < thresholdMs;
98
+ }
99
+ // ── Memory pressure ───────────────────────────────────────────────────────────
100
+ /**
101
+ * Get current heap usage as a fraction of heap limit.
102
+ * Returns 0 if measurement is unavailable.
103
+ */
104
+ function getHeapUsedFraction() {
105
+ try {
106
+ const mem = process.memoryUsage();
107
+ if (mem.heapTotal > 0) {
108
+ return mem.heapUsed / mem.heapTotal;
109
+ }
110
+ }
111
+ catch {
112
+ // Non-fatal
113
+ }
114
+ return 0;
115
+ }
116
+ /**
117
+ * Check memory pressure and apply layered degradation if needed.
118
+ *
119
+ * Degradation order:
120
+ * 1. 75% heap: degrade semantic layer (LLM intent expansion etc.)
121
+ * 2. 90% heap: degrade advisory layer (heuristic signals etc.)
122
+ * Structural governance is NEVER degraded by memory pressure.
123
+ *
124
+ * @param ctx Runtime context (mutated to record degradation)
125
+ */
126
+ function applyMemoryPressureDegradation(ctx) {
127
+ const fraction = getHeapUsedFraction();
128
+ if (fraction >= exports.MEMORY_DEGRADE_ADVISORY_THRESHOLD && !ctx.degradedLayers.has('advisory')) {
129
+ ctx.degradedLayers.add('advisory');
130
+ ctx.degradationReasons.push(`Heap usage at ${Math.round(fraction * 100)}% exceeded advisory threshold ` +
131
+ `(${Math.round(exports.MEMORY_DEGRADE_ADVISORY_THRESHOLD * 100)}%) — advisory layer degraded`);
132
+ ctx.skippedSubsystems.push('advisory-signals', 'heuristic-rules');
133
+ }
134
+ if (fraction >= exports.MEMORY_DEGRADE_SEMANTIC_THRESHOLD && !ctx.degradedLayers.has('semantic')) {
135
+ ctx.degradedLayers.add('semantic');
136
+ ctx.degradationReasons.push(`Heap usage at ${Math.round(fraction * 100)}% exceeded semantic threshold ` +
137
+ `(${Math.round(exports.MEMORY_DEGRADE_SEMANTIC_THRESHOLD * 100)}%) — semantic layer degraded`);
138
+ ctx.skippedSubsystems.push('intent-expansion', 'llm-planning');
139
+ }
140
+ }
141
+ // ── Large repo detection ──────────────────────────────────────────────────────
142
+ /**
143
+ * Estimate the number of tracked files in the git repository.
144
+ * Returns null if git is unavailable or the command fails.
145
+ */
146
+ function estimateRepoFileCount(projectRoot) {
147
+ try {
148
+ const output = (0, child_process_1.execSync)('git ls-files --cached | wc -l', {
149
+ cwd: projectRoot,
150
+ encoding: 'utf-8',
151
+ timeout: 5000,
152
+ stdio: ['ignore', 'pipe', 'ignore'],
153
+ });
154
+ const count = parseInt(output.trim(), 10);
155
+ return Number.isFinite(count) ? count : null;
156
+ }
157
+ catch {
158
+ return null;
159
+ }
160
+ }
161
+ /**
162
+ * Check if the repo qualifies as a large repo and apply appropriate guidance.
163
+ *
164
+ * If file count exceeds LARGE_REPO_FILE_THRESHOLD:
165
+ * - Sets ctx.largeRepoMode = true
166
+ * - Adds a cache-build recommendation to degradationReasons
167
+ * - Does NOT degrade structural governance
168
+ *
169
+ * @param ctx Runtime context (mutated)
170
+ * @param projectRoot Project root path
171
+ */
172
+ function applyLargeRepoProtection(ctx, projectRoot) {
173
+ const count = estimateRepoFileCount(projectRoot);
174
+ ctx.estimatedFileCount = count;
175
+ if (count !== null && count > exports.LARGE_REPO_FILE_THRESHOLD) {
176
+ ctx.largeRepoMode = true;
177
+ ctx.degradationReasons.push(`Large repo detected (${count.toLocaleString()} tracked files, threshold: ` +
178
+ `${exports.LARGE_REPO_FILE_THRESHOLD.toLocaleString()}). ` +
179
+ `Structural cache warm-up recommended: run \`neurcode cache build\` before CI. ` +
180
+ `Semantic state will NOT be rebuilt synchronously in CI mode.`);
181
+ if (ctx.isCI) {
182
+ ctx.skippedSubsystems.push('synchronous-semantic-state-rebuild');
183
+ }
184
+ }
185
+ }
186
+ // ── Degradation guards ────────────────────────────────────────────────────────
187
+ /**
188
+ * Return true if the semantic layer should be skipped.
189
+ * Call before any LLM-assisted or semantic expansion operations.
190
+ */
191
+ function shouldSkipSemanticLayer(ctx) {
192
+ return ctx.degradedLayers.has('semantic') || isTimePressure(ctx, 10_000);
193
+ }
194
+ /**
195
+ * Return true if the advisory layer should be skipped.
196
+ * Call before any heuristic or advisory-only operations.
197
+ */
198
+ function shouldSkipAdvisoryLayer(ctx) {
199
+ return ctx.degradedLayers.has('advisory') || isTimePressure(ctx, 3_000);
200
+ }
201
+ // ── Report generation ─────────────────────────────────────────────────────────
202
+ /**
203
+ * Build a runtime transparency report from the context.
204
+ * Include this in verify JSON output when --ci flag is set.
205
+ */
206
+ function buildVerifyRuntimeReport(ctx) {
207
+ const heapFraction = getHeapUsedFraction();
208
+ let memoryMb = 0;
209
+ try {
210
+ memoryMb = Math.round(process.memoryUsage().heapUsed / 1024 / 1024);
211
+ }
212
+ catch {
213
+ // Non-fatal
214
+ }
215
+ return {
216
+ degraded: ctx.degradedLayers.size > 0 || ctx.largeRepoMode,
217
+ degradedLayers: [...ctx.degradedLayers],
218
+ degradationReasons: [...ctx.degradationReasons],
219
+ skippedSubsystems: [...ctx.skippedSubsystems],
220
+ largeRepoMode: ctx.largeRepoMode,
221
+ estimatedFileCount: ctx.estimatedFileCount,
222
+ elapsedMs: elapsedMs(ctx),
223
+ timeoutMs: ctx.timeoutMs,
224
+ remainingMs: remainingMs(ctx),
225
+ memoryUsageMb: memoryMb,
226
+ heapUsedFraction: Math.round(heapFraction * 1000) / 1000,
227
+ structuralGovernanceOperational: true,
228
+ };
229
+ }
230
+ //# sourceMappingURL=verify-runtime-stability.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verify-runtime-stability.js","sourceRoot":"","sources":["../../src/utils/verify-runtime-stability.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;;;AAsEH,gEAWC;AASD,gCAEC;AAKD,8BAEC;AAKD,kCAEC;AASD,wCAEC;AAQD,kDAUC;AAYD,wEAoBC;AAQD,sDAaC;AAaD,4DAoBC;AAQD,0DAEC;AAMD,0DAEC;AAQD,4DAuBC;AA5QD,iDAAyC;AAIzC,iFAAiF;AAEjF,qDAAqD;AACxC,QAAA,mBAAmB,GAC9B,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,+BAA+B,CAAC,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,MAAM,CAAC;AAE7E,mDAAmD;AACtC,QAAA,gBAAgB,GAC3B,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,4BAA4B,CAAC,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,OAAO,CAAC;AAE3E,gEAAgE;AACnD,QAAA,yBAAyB,GACpC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,+BAA+B,CAAC,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,MAAM,CAAC;AAE7E,8EAA8E;AACjE,QAAA,iCAAiC,GAAG,IAAI,CAAC;AAEtD,8EAA8E;AACjE,QAAA,iCAAiC,GAAG,IAAI,CAAC;AAwCtD,iFAAiF;AAEjF;;;GAGG;AACH,SAAgB,0BAA0B,CAAC,IAAa;IACtD,OAAO;QACL,IAAI;QACJ,SAAS,EAAE,IAAI,CA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E,CAAC;AAED,iFAAiF;AAEjF;;;GAGG;AACH,SAAgB,wBAAwB,CAAC,GAAyB;IAChE,MAAM,YAAY,GAAG,mBAAmB,EAAE,CAAC;IAC3C,IAAI,QAAQ,GAAG,CAAC,CAAC;IACjB,IAAI,CAAC;QACH,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,QAAQ,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC;IACtE,CAAC;IAAC,MAAM,CAAC;QACP,YAAY;IACd,CAAC;IAED,OAAO;QACL,QAAQ,EAAE,GAAG,CAAC,cAAc,CAAC,IAAI,GAAG,CAAC,IAAI,GAAG,CAAC,aAAa;QAC1D,cAAc,EAAE,CAAC,GAAG,GAAG,CAAC,cAAc,CAAoB;QAC1D,kBAAkB,EAAE,CAAC,GAAG,GAAG,CAAC,kBAAkB,CAAC;QAC/C,iBAAiB,EAAE,CAAC,GAAG,GAAG,CAAC,iBAAiB,CAAC;QAC7C,aAAa,EAAE,GAAG,CAAC,aAAa;QAChC,kBAAkB,EAAE,GAAG,CAAC,kBAAkB;QAC1C,SAAS,EAAE,SAAS,CAAC,GAAG,CAAC;QACzB,SAAS,EAAE,GAAG,CAAC,SAAS;QACxB,WAAW,EAAE,WAAW,CAAC,GAAG,CAAC;QAC7B,aAAa,EAAE,QAAQ;QACvB,gBAAgB,EAAE,IAAI,CAAC,KAAK,CAAC,YAAY,GAAG,IAAI,CAAC,GAAG,IAAI;QACxD,+BAA+B,EAAE,IAAI;KACtC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,111 @@
1
+ /**
2
+ * Cross-Repo Dependency Graph
3
+ *
4
+ * Detects coupling between repositories that is INVISIBLE to single-repo graph analysis.
5
+ * This is the key gap for microservice architectures where:
6
+ * - Service A calls Service B over HTTP/gRPC
7
+ * - Service C publishes Kafka events that Service D consumes
8
+ * - All services share a contract package (@company/shared-types)
9
+ * - Environment variables encode service discovery (AUTH_SERVICE_URL)
10
+ *
11
+ * Each detected edge has:
12
+ * - A `via` classification (how the coupling manifests)
13
+ * - A `confidence` level (high = structural proof, low = pattern heuristic)
14
+ * - `evidence` lines that prove the coupling exists
15
+ *
16
+ * The graph is deterministic: same inputs → identical edges, same ordering.
17
+ * All regex patterns are pre-compiled and stateless.
18
+ */
19
+ import type { BrainRepositoryMap } from '@neurcode-ai/core';
20
+ import type { WorkspaceRepository } from '../utils/workspace-runtime';
21
+ export type CrossRepoEdgeVia = 'http-client' | 'grpc-client' | 'event-publish' | 'event-subscribe' | 'shared-contract' | 'env-service-url' | 'openapi-client' | 'db-shared-schema';
22
+ export type CrossRepoEdgeConfidence = 'high' | 'medium' | 'low';
23
+ export interface CrossRepoEdge {
24
+ /** Source: repo + file that creates the coupling */
25
+ fromRepo: string;
26
+ fromFile: string;
27
+ /** Target: resolved repo name (from workspace topology) */
28
+ toRepo: string;
29
+ /**
30
+ * toFile is set when we can pin the coupling to a specific file in the target repo
31
+ * (e.g., a shared contract file). Null when we only know the target service.
32
+ */
33
+ toFile: string | null;
34
+ /** Mechanism of the coupling */
35
+ via: CrossRepoEdgeVia;
36
+ /** How confident we are this is a real cross-repo dependency */
37
+ confidence: CrossRepoEdgeConfidence;
38
+ /**
39
+ * The actual code lines that prove this edge exists.
40
+ * Always populated — no evidence → no edge.
41
+ */
42
+ evidence: string[];
43
+ /**
44
+ * Human-readable explanation of what this coupling means for blast radius.
45
+ * Used in context packages and advisory reports.
46
+ */
47
+ impactSummary: string;
48
+ }
49
+ export interface CrossRepoBuildOptions {
50
+ /**
51
+ * Maximum number of files to scan per repo.
52
+ * Prevents runaway on massive monorepos. Default: 2000.
53
+ */
54
+ maxFilesPerRepo?: number;
55
+ /**
56
+ * Whether to follow symlinks during glob scan. Default: false.
57
+ */
58
+ followSymlinks?: boolean;
59
+ }
60
+ export interface CrossRepoGraph {
61
+ generatedAt: string;
62
+ repos: string[];
63
+ edges: CrossRepoEdge[];
64
+ stats: {
65
+ filesScanned: number;
66
+ edgesDetected: number;
67
+ byVia: Record<CrossRepoEdgeVia, number>;
68
+ byConfidence: Record<CrossRepoEdgeConfidence, number>;
69
+ };
70
+ }
71
+ export interface CrossRepoGraphBuilderInput {
72
+ /** All repos in the workspace topology */
73
+ repos: WorkspaceRepository[];
74
+ /**
75
+ * Pre-loaded brain maps keyed by repo name.
76
+ * Optional — if absent for a repo, we fall back to direct file scanning.
77
+ */
78
+ brainMaps?: Record<string, BrainRepositoryMap>;
79
+ options?: CrossRepoBuildOptions;
80
+ }
81
+ /**
82
+ * Build the cross-repo dependency graph for a workspace.
83
+ *
84
+ * This function:
85
+ * 1. Scans source files in each repo for cross-service coupling signals
86
+ * 2. Resolves each signal to a target repo using the workspace topology
87
+ * 3. Returns typed, evidence-backed edges with confidence scores
88
+ *
89
+ * Deterministic: same workspace config + same file contents → same graph.
90
+ */
91
+ export declare function buildCrossRepoGraph(input: CrossRepoGraphBuilderInput): CrossRepoGraph;
92
+ /**
93
+ * Get all repos that are directly affected when a change occurs in `repoName`.
94
+ * Returns repos that import from / depend on `repoName`.
95
+ */
96
+ export declare function getDownstreamRepos(graph: CrossRepoGraph, repoName: string): string[];
97
+ /**
98
+ * Get all repos that `repoName` directly depends on (calls/imports).
99
+ */
100
+ export declare function getUpstreamRepos(graph: CrossRepoGraph, repoName: string): string[];
101
+ /**
102
+ * Get all edges involving a specific file change in a specific repo.
103
+ * Used to find "what cross-repo coupling does this file touch?"
104
+ */
105
+ export declare function getEdgesForFile(graph: CrossRepoGraph, repoName: string, filePath: string): CrossRepoEdge[];
106
+ /**
107
+ * Get all edges that point TO a specific file in a repo.
108
+ * Used to find "who depends on this file?"
109
+ */
110
+ export declare function getEdgesPointingToFile(graph: CrossRepoGraph, repoName: string, filePath: string): CrossRepoEdge[];
111
+ //# sourceMappingURL=cross-repo-graph.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cross-repo-graph.d.ts","sourceRoot":"","sources":["../../src/workspace/cross-repo-graph.ts"],"names":[],"mappings":"A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