@neurcode-ai/cli 0.9.63 → 0.9.65

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 (308) hide show
  1. package/LICENSE +201 -0
  2. package/dist/commands/brain.d.ts.map +1 -1
  3. package/dist/commands/brain.js +273 -0
  4. package/dist/commands/brain.js.map +1 -1
  5. package/dist/commands/control-plane.js +7 -7
  6. package/dist/commands/control-plane.js.map +1 -1
  7. package/dist/commands/fix.d.ts.map +1 -1
  8. package/dist/commands/fix.js +108 -1
  9. package/dist/commands/fix.js.map +1 -1
  10. package/dist/commands/patch-apply.d.ts +2 -0
  11. package/dist/commands/patch-apply.d.ts.map +1 -1
  12. package/dist/commands/patch-apply.js +331 -19
  13. package/dist/commands/patch-apply.js.map +1 -1
  14. package/dist/commands/pilot-report.d.ts +9 -0
  15. package/dist/commands/pilot-report.d.ts.map +1 -0
  16. package/dist/commands/pilot-report.js +176 -0
  17. package/dist/commands/pilot-report.js.map +1 -0
  18. package/dist/commands/remediate-governance.d.ts +54 -0
  19. package/dist/commands/remediate-governance.d.ts.map +1 -0
  20. package/dist/commands/remediate-governance.js +375 -0
  21. package/dist/commands/remediate-governance.js.map +1 -0
  22. package/dist/commands/remediate.d.ts.map +1 -1
  23. package/dist/commands/remediate.js.map +1 -1
  24. package/dist/commands/replay.d.ts.map +1 -1
  25. package/dist/commands/replay.js +35 -5
  26. package/dist/commands/replay.js.map +1 -1
  27. package/dist/commands/verify.d.ts.map +1 -1
  28. package/dist/commands/verify.js +336 -25
  29. package/dist/commands/verify.js.map +1 -1
  30. package/dist/commands/workspace.js +7 -7
  31. package/dist/commands/workspace.js.map +1 -1
  32. package/dist/daemon/server.d.ts +2 -2
  33. package/dist/daemon/server.d.ts.map +1 -1
  34. package/dist/daemon/server.js +2113 -32
  35. package/dist/daemon/server.js.map +1 -1
  36. package/dist/explainability/DeterminismClassifier.d.ts +34 -0
  37. package/dist/explainability/DeterminismClassifier.d.ts.map +1 -0
  38. package/dist/explainability/DeterminismClassifier.js +104 -0
  39. package/dist/explainability/DeterminismClassifier.js.map +1 -0
  40. package/dist/explainability/ViolationFormatter.d.ts +32 -0
  41. package/dist/explainability/ViolationFormatter.d.ts.map +1 -0
  42. package/dist/explainability/ViolationFormatter.js +252 -0
  43. package/dist/explainability/ViolationFormatter.js.map +1 -0
  44. package/dist/explainability/index.d.ts +15 -0
  45. package/dist/explainability/index.d.ts.map +1 -0
  46. package/dist/explainability/index.js +94 -0
  47. package/dist/explainability/index.js.map +1 -0
  48. package/dist/explainability/types.d.ts +37 -0
  49. package/dist/explainability/types.d.ts.map +1 -0
  50. package/dist/explainability/types.js +3 -0
  51. package/dist/explainability/types.js.map +1 -0
  52. package/dist/governance/canonical-pipeline.d.ts +38 -0
  53. package/dist/governance/canonical-pipeline.d.ts.map +1 -0
  54. package/dist/governance/canonical-pipeline.js +448 -0
  55. package/dist/governance/canonical-pipeline.js.map +1 -0
  56. package/dist/governance/structural-on-diff.d.ts +13 -0
  57. package/dist/governance/structural-on-diff.d.ts.map +1 -0
  58. package/dist/governance/structural-on-diff.js +35 -0
  59. package/dist/governance/structural-on-diff.js.map +1 -0
  60. package/dist/governance/structural-policy-merge.d.ts +14 -0
  61. package/dist/governance/structural-policy-merge.d.ts.map +1 -0
  62. package/dist/governance/structural-policy-merge.js +25 -0
  63. package/dist/governance/structural-policy-merge.js.map +1 -0
  64. package/dist/index.js +86 -4
  65. package/dist/index.js.map +1 -1
  66. package/dist/integrations/review-compression/index.d.ts +50 -0
  67. package/dist/integrations/review-compression/index.d.ts.map +1 -0
  68. package/dist/integrations/review-compression/index.js +158 -0
  69. package/dist/integrations/review-compression/index.js.map +1 -0
  70. package/dist/intent-engine/domain-taxonomy.d.ts +42 -0
  71. package/dist/intent-engine/domain-taxonomy.d.ts.map +1 -0
  72. package/dist/intent-engine/domain-taxonomy.js +534 -0
  73. package/dist/intent-engine/domain-taxonomy.js.map +1 -0
  74. package/dist/intent-engine/index.d.ts +1 -0
  75. package/dist/intent-engine/index.d.ts.map +1 -1
  76. package/dist/intent-engine/index.js +6 -1
  77. package/dist/intent-engine/index.js.map +1 -1
  78. package/dist/intent-engine/matcher.d.ts.map +1 -1
  79. package/dist/intent-engine/matcher.js +2 -0
  80. package/dist/intent-engine/matcher.js.map +1 -1
  81. package/dist/intent-engine/parser.d.ts.map +1 -1
  82. package/dist/intent-engine/parser.js +47 -0
  83. package/dist/intent-engine/parser.js.map +1 -1
  84. package/dist/intent-engine/semantic-expander.d.ts +104 -0
  85. package/dist/intent-engine/semantic-expander.d.ts.map +1 -0
  86. package/dist/intent-engine/semantic-expander.js +480 -0
  87. package/dist/intent-engine/semantic-expander.js.map +1 -0
  88. package/dist/patch-engine/diff.d.ts +1 -1
  89. package/dist/patch-engine/diff.js +1 -1
  90. package/dist/patch-engine/generator.d.ts +9 -0
  91. package/dist/patch-engine/generator.d.ts.map +1 -1
  92. package/dist/patch-engine/generator.js +375 -17
  93. package/dist/patch-engine/generator.js.map +1 -1
  94. package/dist/patch-engine/index.d.ts +25 -25
  95. package/dist/patch-engine/index.d.ts.map +1 -1
  96. package/dist/patch-engine/index.js +134 -87
  97. package/dist/patch-engine/index.js.map +1 -1
  98. package/dist/patch-engine/patterns.d.ts +1 -1
  99. package/dist/patch-engine/patterns.d.ts.map +1 -1
  100. package/dist/patch-engine/patterns.js +282 -41
  101. package/dist/patch-engine/patterns.js.map +1 -1
  102. package/dist/patch-engine/rollback.d.ts +31 -0
  103. package/dist/patch-engine/rollback.d.ts.map +1 -0
  104. package/dist/patch-engine/rollback.js +275 -0
  105. package/dist/patch-engine/rollback.js.map +1 -0
  106. package/dist/patch-engine/safety.d.ts +28 -0
  107. package/dist/patch-engine/safety.d.ts.map +1 -0
  108. package/dist/patch-engine/safety.js +122 -0
  109. package/dist/patch-engine/safety.js.map +1 -0
  110. package/dist/patch-engine/transaction.d.ts +52 -0
  111. package/dist/patch-engine/transaction.d.ts.map +1 -0
  112. package/dist/patch-engine/transaction.js +93 -0
  113. package/dist/patch-engine/transaction.js.map +1 -0
  114. package/dist/semantic/index.d.ts +14 -0
  115. package/dist/semantic/index.d.ts.map +1 -0
  116. package/dist/semantic/index.js +30 -0
  117. package/dist/semantic/index.js.map +1 -0
  118. package/dist/semantic/tfidf-engine.d.ts +81 -0
  119. package/dist/semantic/tfidf-engine.d.ts.map +1 -0
  120. package/dist/semantic/tfidf-engine.js +278 -0
  121. package/dist/semantic/tfidf-engine.js.map +1 -0
  122. package/dist/semantic/vector-store.d.ts +108 -0
  123. package/dist/semantic/vector-store.d.ts.map +1 -0
  124. package/dist/semantic/vector-store.js +321 -0
  125. package/dist/semantic/vector-store.js.map +1 -0
  126. package/dist/structural-rules/context-severity.d.ts +46 -0
  127. package/dist/structural-rules/context-severity.d.ts.map +1 -0
  128. package/dist/structural-rules/context-severity.js +115 -0
  129. package/dist/structural-rules/context-severity.js.map +1 -0
  130. package/dist/structural-rules/distributed/DS001-saga-rollback-absence.d.ts +11 -0
  131. package/dist/structural-rules/distributed/DS001-saga-rollback-absence.d.ts.map +1 -0
  132. package/dist/structural-rules/distributed/DS001-saga-rollback-absence.js +212 -0
  133. package/dist/structural-rules/distributed/DS001-saga-rollback-absence.js.map +1 -0
  134. package/dist/structural-rules/distributed/DS002-missing-correlation-id.d.ts +11 -0
  135. package/dist/structural-rules/distributed/DS002-missing-correlation-id.d.ts.map +1 -0
  136. package/dist/structural-rules/distributed/DS002-missing-correlation-id.js +213 -0
  137. package/dist/structural-rules/distributed/DS002-missing-correlation-id.js.map +1 -0
  138. package/dist/structural-rules/distributed/index.d.ts +3 -0
  139. package/dist/structural-rules/distributed/index.d.ts.map +1 -0
  140. package/dist/structural-rules/distributed/index.js +8 -0
  141. package/dist/structural-rules/distributed/index.js.map +1 -0
  142. package/dist/structural-rules/engine.d.ts +25 -0
  143. package/dist/structural-rules/engine.d.ts.map +1 -0
  144. package/dist/structural-rules/engine.js +90 -0
  145. package/dist/structural-rules/engine.js.map +1 -0
  146. package/dist/structural-rules/index.d.ts +41 -0
  147. package/dist/structural-rules/index.d.ts.map +1 -0
  148. package/dist/structural-rules/index.js +141 -0
  149. package/dist/structural-rules/index.js.map +1 -0
  150. package/dist/structural-rules/python/PY001-asyncio-task-without-cancel.d.ts +11 -0
  151. package/dist/structural-rules/python/PY001-asyncio-task-without-cancel.d.ts.map +1 -0
  152. package/dist/structural-rules/python/PY001-asyncio-task-without-cancel.js +66 -0
  153. package/dist/structural-rules/python/PY001-asyncio-task-without-cancel.js.map +1 -0
  154. package/dist/structural-rules/python/PY002-unbounded-dict-singleton.d.ts +11 -0
  155. package/dist/structural-rules/python/PY002-unbounded-dict-singleton.d.ts.map +1 -0
  156. package/dist/structural-rules/python/PY002-unbounded-dict-singleton.js +135 -0
  157. package/dist/structural-rules/python/PY002-unbounded-dict-singleton.js.map +1 -0
  158. package/dist/structural-rules/python/PY003-broad-except-clause.d.ts +11 -0
  159. package/dist/structural-rules/python/PY003-broad-except-clause.d.ts.map +1 -0
  160. package/dist/structural-rules/python/PY003-broad-except-clause.js +86 -0
  161. package/dist/structural-rules/python/PY003-broad-except-clause.js.map +1 -0
  162. package/dist/structural-rules/python/PY004-swallowed-async-exception.d.ts +11 -0
  163. package/dist/structural-rules/python/PY004-swallowed-async-exception.d.ts.map +1 -0
  164. package/dist/structural-rules/python/PY004-swallowed-async-exception.js +167 -0
  165. package/dist/structural-rules/python/PY004-swallowed-async-exception.js.map +1 -0
  166. package/dist/structural-rules/python/PY005-fastapi-without-pydantic.d.ts +11 -0
  167. package/dist/structural-rules/python/PY005-fastapi-without-pydantic.d.ts.map +1 -0
  168. package/dist/structural-rules/python/PY005-fastapi-without-pydantic.js +154 -0
  169. package/dist/structural-rules/python/PY005-fastapi-without-pydantic.js.map +1 -0
  170. package/dist/structural-rules/python/PY006-blocking-io-in-async.d.ts +11 -0
  171. package/dist/structural-rules/python/PY006-blocking-io-in-async.d.ts.map +1 -0
  172. package/dist/structural-rules/python/PY006-blocking-io-in-async.js +130 -0
  173. package/dist/structural-rules/python/PY006-blocking-io-in-async.js.map +1 -0
  174. package/dist/structural-rules/python/PY007-sqlalchemy-session-leak.d.ts +11 -0
  175. package/dist/structural-rules/python/PY007-sqlalchemy-session-leak.d.ts.map +1 -0
  176. package/dist/structural-rules/python/PY007-sqlalchemy-session-leak.js +93 -0
  177. package/dist/structural-rules/python/PY007-sqlalchemy-session-leak.js.map +1 -0
  178. package/dist/structural-rules/python/PY008-celery-task-without-retry.d.ts +11 -0
  179. package/dist/structural-rules/python/PY008-celery-task-without-retry.d.ts.map +1 -0
  180. package/dist/structural-rules/python/PY008-celery-task-without-retry.js +154 -0
  181. package/dist/structural-rules/python/PY008-celery-task-without-retry.js.map +1 -0
  182. package/dist/structural-rules/python/PY009-unsafe-pickle-deserialization.d.ts +11 -0
  183. package/dist/structural-rules/python/PY009-unsafe-pickle-deserialization.d.ts.map +1 -0
  184. package/dist/structural-rules/python/PY009-unsafe-pickle-deserialization.js +133 -0
  185. package/dist/structural-rules/python/PY009-unsafe-pickle-deserialization.js.map +1 -0
  186. package/dist/structural-rules/python/PY010-leaked-aiohttp-session.d.ts +11 -0
  187. package/dist/structural-rules/python/PY010-leaked-aiohttp-session.d.ts.map +1 -0
  188. package/dist/structural-rules/python/PY010-leaked-aiohttp-session.js +80 -0
  189. package/dist/structural-rules/python/PY010-leaked-aiohttp-session.js.map +1 -0
  190. package/dist/structural-rules/rules/SR001-swallowed-async-rejection.d.ts +11 -0
  191. package/dist/structural-rules/rules/SR001-swallowed-async-rejection.d.ts.map +1 -0
  192. package/dist/structural-rules/rules/SR001-swallowed-async-rejection.js +145 -0
  193. package/dist/structural-rules/rules/SR001-swallowed-async-rejection.js.map +1 -0
  194. package/dist/structural-rules/rules/SR002-unbounded-collection.d.ts +11 -0
  195. package/dist/structural-rules/rules/SR002-unbounded-collection.d.ts.map +1 -0
  196. package/dist/structural-rules/rules/SR002-unbounded-collection.js +196 -0
  197. package/dist/structural-rules/rules/SR002-unbounded-collection.js.map +1 -0
  198. package/dist/structural-rules/rules/SR003-timer-without-cleanup.d.ts +11 -0
  199. package/dist/structural-rules/rules/SR003-timer-without-cleanup.d.ts.map +1 -0
  200. package/dist/structural-rules/rules/SR003-timer-without-cleanup.js +148 -0
  201. package/dist/structural-rules/rules/SR003-timer-without-cleanup.js.map +1 -0
  202. package/dist/structural-rules/rules/SR004-request-boundary-no-validation.d.ts +11 -0
  203. package/dist/structural-rules/rules/SR004-request-boundary-no-validation.d.ts.map +1 -0
  204. package/dist/structural-rules/rules/SR004-request-boundary-no-validation.js +162 -0
  205. package/dist/structural-rules/rules/SR004-request-boundary-no-validation.js.map +1 -0
  206. package/dist/structural-rules/rules/SR005-halfopen-probe-gate.d.ts +11 -0
  207. package/dist/structural-rules/rules/SR005-halfopen-probe-gate.d.ts.map +1 -0
  208. package/dist/structural-rules/rules/SR005-halfopen-probe-gate.js +150 -0
  209. package/dist/structural-rules/rules/SR005-halfopen-probe-gate.js.map +1 -0
  210. package/dist/structural-rules/rules/SR006-fanout-error-sanitization.d.ts +11 -0
  211. package/dist/structural-rules/rules/SR006-fanout-error-sanitization.d.ts.map +1 -0
  212. package/dist/structural-rules/rules/SR006-fanout-error-sanitization.js +161 -0
  213. package/dist/structural-rules/rules/SR006-fanout-error-sanitization.js.map +1 -0
  214. package/dist/structural-rules/rules/SR007-cross-request-error.d.ts +11 -0
  215. package/dist/structural-rules/rules/SR007-cross-request-error.d.ts.map +1 -0
  216. package/dist/structural-rules/rules/SR007-cross-request-error.js +175 -0
  217. package/dist/structural-rules/rules/SR007-cross-request-error.js.map +1 -0
  218. package/dist/structural-rules/rules/SR008-background-task-orphan.d.ts +11 -0
  219. package/dist/structural-rules/rules/SR008-background-task-orphan.d.ts.map +1 -0
  220. package/dist/structural-rules/rules/SR008-background-task-orphan.js +176 -0
  221. package/dist/structural-rules/rules/SR008-background-task-orphan.js.map +1 -0
  222. package/dist/structural-rules/rules/SR009-missing-retry-backoff.d.ts +11 -0
  223. package/dist/structural-rules/rules/SR009-missing-retry-backoff.d.ts.map +1 -0
  224. package/dist/structural-rules/rules/SR009-missing-retry-backoff.js +168 -0
  225. package/dist/structural-rules/rules/SR009-missing-retry-backoff.js.map +1 -0
  226. package/dist/structural-rules/rules/SR010-retry-storm.d.ts +11 -0
  227. package/dist/structural-rules/rules/SR010-retry-storm.d.ts.map +1 -0
  228. package/dist/structural-rules/rules/SR010-retry-storm.js +181 -0
  229. package/dist/structural-rules/rules/SR010-retry-storm.js.map +1 -0
  230. package/dist/structural-rules/rules/SR011-event-listener-leak.d.ts +11 -0
  231. package/dist/structural-rules/rules/SR011-event-listener-leak.d.ts.map +1 -0
  232. package/dist/structural-rules/rules/SR011-event-listener-leak.js +208 -0
  233. package/dist/structural-rules/rules/SR011-event-listener-leak.js.map +1 -0
  234. package/dist/structural-rules/rules/SR012-promise-race-leak.d.ts +11 -0
  235. package/dist/structural-rules/rules/SR012-promise-race-leak.d.ts.map +1 -0
  236. package/dist/structural-rules/rules/SR012-promise-race-leak.js +191 -0
  237. package/dist/structural-rules/rules/SR012-promise-race-leak.js.map +1 -0
  238. package/dist/structural-rules/rules/SR013-missing-idempotency-key.d.ts +11 -0
  239. package/dist/structural-rules/rules/SR013-missing-idempotency-key.d.ts.map +1 -0
  240. package/dist/structural-rules/rules/SR013-missing-idempotency-key.js +219 -0
  241. package/dist/structural-rules/rules/SR013-missing-idempotency-key.js.map +1 -0
  242. package/dist/structural-rules/rules/SR014-mutable-closure-async.d.ts +11 -0
  243. package/dist/structural-rules/rules/SR014-mutable-closure-async.d.ts.map +1 -0
  244. package/dist/structural-rules/rules/SR014-mutable-closure-async.js +208 -0
  245. package/dist/structural-rules/rules/SR014-mutable-closure-async.js.map +1 -0
  246. package/dist/structural-rules/rules/SR015-dangling-abort-controller.d.ts +11 -0
  247. package/dist/structural-rules/rules/SR015-dangling-abort-controller.d.ts.map +1 -0
  248. package/dist/structural-rules/rules/SR015-dangling-abort-controller.js +190 -0
  249. package/dist/structural-rules/rules/SR015-dangling-abort-controller.js.map +1 -0
  250. package/dist/structural-rules/rules/SR016-unsafe-json-parse.d.ts +11 -0
  251. package/dist/structural-rules/rules/SR016-unsafe-json-parse.d.ts.map +1 -0
  252. package/dist/structural-rules/rules/SR016-unsafe-json-parse.js +187 -0
  253. package/dist/structural-rules/rules/SR016-unsafe-json-parse.js.map +1 -0
  254. package/dist/structural-rules/suppressions.d.ts +43 -0
  255. package/dist/structural-rules/suppressions.d.ts.map +1 -0
  256. package/dist/structural-rules/suppressions.js +115 -0
  257. package/dist/structural-rules/suppressions.js.map +1 -0
  258. package/dist/structural-rules/types.d.ts +43 -0
  259. package/dist/structural-rules/types.d.ts.map +1 -0
  260. package/dist/structural-rules/types.js +3 -0
  261. package/dist/structural-rules/types.js.map +1 -0
  262. package/dist/utils/advisory-signals.d.ts +5 -0
  263. package/dist/utils/advisory-signals.d.ts.map +1 -1
  264. package/dist/utils/advisory-signals.js +50 -12
  265. package/dist/utils/advisory-signals.js.map +1 -1
  266. package/dist/utils/ai-debt-budget.d.ts.map +1 -1
  267. package/dist/utils/ai-debt-budget.js +5 -2
  268. package/dist/utils/ai-debt-budget.js.map +1 -1
  269. package/dist/utils/brain-cache.d.ts +100 -0
  270. package/dist/utils/brain-cache.d.ts.map +1 -0
  271. package/dist/utils/brain-cache.js +346 -0
  272. package/dist/utils/brain-cache.js.map +1 -0
  273. package/dist/utils/cli-json.d.ts.map +1 -1
  274. package/dist/utils/cli-json.js +80 -12
  275. package/dist/utils/cli-json.js.map +1 -1
  276. package/dist/utils/execution-bus.d.ts +10 -0
  277. package/dist/utils/execution-bus.d.ts.map +1 -1
  278. package/dist/utils/execution-bus.js +16 -0
  279. package/dist/utils/execution-bus.js.map +1 -1
  280. package/dist/utils/governance-provenance.d.ts +95 -0
  281. package/dist/utils/governance-provenance.d.ts.map +1 -0
  282. package/dist/utils/governance-provenance.js +187 -0
  283. package/dist/utils/governance-provenance.js.map +1 -0
  284. package/dist/utils/pilot-metrics.d.ts +46 -0
  285. package/dist/utils/pilot-metrics.d.ts.map +1 -0
  286. package/dist/utils/pilot-metrics.js +240 -0
  287. package/dist/utils/pilot-metrics.js.map +1 -0
  288. package/dist/utils/policy-compiler.d.ts +6 -0
  289. package/dist/utils/policy-compiler.d.ts.map +1 -1
  290. package/dist/utils/policy-compiler.js +20 -0
  291. package/dist/utils/policy-compiler.js.map +1 -1
  292. package/dist/utils/replay-runtime.d.ts +34 -0
  293. package/dist/utils/replay-runtime.d.ts.map +1 -1
  294. package/dist/utils/replay-runtime.js +207 -0
  295. package/dist/utils/replay-runtime.js.map +1 -1
  296. package/dist/workspace/cross-repo-graph.d.ts +111 -0
  297. package/dist/workspace/cross-repo-graph.d.ts.map +1 -0
  298. package/dist/workspace/cross-repo-graph.js +450 -0
  299. package/dist/workspace/cross-repo-graph.js.map +1 -0
  300. package/dist/workspace/federated-context.d.ts +144 -0
  301. package/dist/workspace/federated-context.d.ts.map +1 -0
  302. package/dist/workspace/federated-context.js +347 -0
  303. package/dist/workspace/federated-context.js.map +1 -0
  304. package/dist/workspace/index.d.ts +38 -0
  305. package/dist/workspace/index.d.ts.map +1 -0
  306. package/dist/workspace/index.js +48 -0
  307. package/dist/workspace/index.js.map +1 -0
  308. package/package.json +10 -10
@@ -0,0 +1,190 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.SR015DanglingAbortController = void 0;
37
+ const ts = __importStar(require("typescript"));
38
+ function getLineAndCol(sf, pos) {
39
+ const lc = sf.getLineAndCharacterOfPosition(pos);
40
+ return { line: lc.line + 1, column: lc.character + 1 };
41
+ }
42
+ function getEvidenceLines(sourceText, line, extra = 1) {
43
+ const lines = sourceText.split('\n');
44
+ return lines.slice(line - 1, Math.min(line - 1 + extra, lines.length)).map(l => l.slice(0, 120)).join('\n');
45
+ }
46
+ /**
47
+ * Collect `new AbortController()` variable names in a function body block,
48
+ * returning a map from variable name -> VariableDeclaration node.
49
+ */
50
+ function collectAbortControllerVars(block) {
51
+ const controllers = new Map();
52
+ function visit(node) {
53
+ if (ts.isVariableDeclaration(node) &&
54
+ ts.isIdentifier(node.name) &&
55
+ node.initializer &&
56
+ ts.isNewExpression(node.initializer) &&
57
+ ts.isIdentifier(node.initializer.expression) &&
58
+ node.initializer.expression.text === 'AbortController') {
59
+ controllers.set(node.name.text, node);
60
+ }
61
+ ts.forEachChild(node, visit);
62
+ }
63
+ ts.forEachChild(block, visit);
64
+ return controllers;
65
+ }
66
+ /**
67
+ * Check if varName.abort() is called anywhere within the given node subtree.
68
+ */
69
+ function hasAbortCall(node, varName) {
70
+ let found = false;
71
+ function visit(n) {
72
+ if (found)
73
+ return;
74
+ if (ts.isCallExpression(n) &&
75
+ ts.isPropertyAccessExpression(n.expression) &&
76
+ ts.isIdentifier(n.expression.expression) &&
77
+ n.expression.expression.text === varName &&
78
+ n.expression.name.text === 'abort') {
79
+ found = true;
80
+ return;
81
+ }
82
+ ts.forEachChild(n, visit);
83
+ }
84
+ visit(node);
85
+ return found;
86
+ }
87
+ /**
88
+ * Check if the controller variable is passed to another function as an argument
89
+ * (meaning the caller manages lifecycle).
90
+ */
91
+ function isPassedAsArgument(block, varName) {
92
+ let passed = false;
93
+ function visit(node) {
94
+ if (passed)
95
+ return;
96
+ if (ts.isCallExpression(node)) {
97
+ for (const arg of node.arguments) {
98
+ if (ts.isIdentifier(arg) && arg.text === varName) {
99
+ passed = true;
100
+ return;
101
+ }
102
+ // Also covers spread: func(...args) — skip for simplicity
103
+ }
104
+ }
105
+ ts.forEachChild(node, visit);
106
+ }
107
+ ts.forEachChild(block, visit);
108
+ return passed;
109
+ }
110
+ class SR015DanglingAbortController {
111
+ id = 'SR015';
112
+ name = 'Dangling AbortController (abort() never called)';
113
+ policyRef = 'SR015';
114
+ severity = 'ADVISORY';
115
+ languages = ['typescript', 'javascript'];
116
+ description = '`new AbortController()` created in a function but `.abort()` never called — ' +
117
+ 'signal listeners are never released, preventing GC of the associated closure.';
118
+ check(filePath, sourceText) {
119
+ try {
120
+ const violations = [];
121
+ const ext = filePath.endsWith('.tsx')
122
+ ? ts.ScriptKind.TSX
123
+ : filePath.endsWith('.jsx')
124
+ ? ts.ScriptKind.JSX
125
+ : filePath.endsWith('.js')
126
+ ? ts.ScriptKind.JS
127
+ : ts.ScriptKind.TS;
128
+ const sf = ts.createSourceFile(filePath, sourceText, ts.ScriptTarget.Latest, true, ext);
129
+ const visit = (node) => {
130
+ const isFuncLike = ts.isFunctionDeclaration(node) ||
131
+ ts.isFunctionExpression(node) ||
132
+ ts.isArrowFunction(node) ||
133
+ ts.isMethodDeclaration(node) ||
134
+ ts.isConstructorDeclaration(node);
135
+ if (isFuncLike && ts.isFunctionLike(node) && node.body && ts.isBlock(node.body)) {
136
+ const block = node.body;
137
+ const controllers = collectAbortControllerVars(block);
138
+ for (const [varName, decl] of controllers) {
139
+ // Exclude: controller passed as argument to another function (caller manages lifecycle)
140
+ if (isPassedAsArgument(block, varName)) {
141
+ continue;
142
+ }
143
+ // Check: is .abort() called anywhere in this function body?
144
+ if (!hasAbortCall(block, varName)) {
145
+ // Also check the enclosing class for abort calls (dispose/cleanup methods)
146
+ let foundInClass = false;
147
+ let classNode = node.parent;
148
+ while (classNode) {
149
+ if (ts.isClassDeclaration(classNode) || ts.isClassExpression(classNode)) {
150
+ foundInClass = hasAbortCall(classNode, varName);
151
+ break;
152
+ }
153
+ classNode = classNode.parent;
154
+ }
155
+ if (!foundInClass) {
156
+ const { line, column } = getLineAndCol(sf, decl.getStart(sf));
157
+ const evidence = getEvidenceLines(sourceText, line, 2);
158
+ violations.push({
159
+ ruleId: this.id,
160
+ ruleName: this.name,
161
+ policyRef: this.policyRef,
162
+ severity: this.severity,
163
+ filePath,
164
+ line,
165
+ column,
166
+ evidence,
167
+ operationalRisk: 'AbortController instances that are never aborted do not release the associated signal ' +
168
+ 'listeners, which hold references to the operation and its closure — preventing GC.',
169
+ remediation: 'Ensure every AbortController has a corresponding `.abort()` call in finally blocks, ' +
170
+ 'dispose methods, or signal listeners.',
171
+ determinism: 'heuristic-advisory',
172
+ confidence: 0.75,
173
+ language: filePath.match(/\.(js|jsx)$/) ? 'javascript' : 'typescript',
174
+ });
175
+ }
176
+ }
177
+ }
178
+ }
179
+ ts.forEachChild(node, visit);
180
+ };
181
+ ts.forEachChild(sf, visit);
182
+ return violations;
183
+ }
184
+ catch {
185
+ return [];
186
+ }
187
+ }
188
+ }
189
+ exports.SR015DanglingAbortController = SR015DanglingAbortController;
190
+ //# sourceMappingURL=SR015-dangling-abort-controller.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SR015-dangling-abort-controller.js","sourceRoot":"","sources":["../../../src/structural-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M,EAAE,GAAG,aAAa,CAAC,EAAE,EAAE,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;gCAC9D,MAAM,QAAQ,GAAG,gBAAgB,CAAC,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;gCACvD,UAAU,CAAC,IAAI,CAAC;oCACd,MAAM,EAAE,IAAI,CAAC,EAAE;oCACf,QAAQ,EAAE,IAAI,CAAC,IAAI;oCACnB,SAAS,EAAE,IAAI,CAAC,SAAS;oCACzB,QAAQ,EAAE,IAAI,CAAC,QAAQ;oCACvB,QAAQ;oCACR,IAAI;oCACJ,MAAM;oCACN,QAAQ;oCACR,eAAe,EACb,wFAAwF;wCACxF,oFAAoF;oCACtF,WAAW,EACT,sFAAsF;wCACtF,uCAAuC;oCACzC,WAAW,EAAE,oBAAoB;oCACjC,UAAU,EAAE,IAAI;oCAChB,QAAQ,EAAE,QAAQ,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,YAAY;iCACtE,CAAC,CAAC;4BACL,CAAC;wBACH,CAAC;oBACH,CAAC;gBACH,CAAC;gBAED,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;YAC/B,CAAC,CAAC;YAEF,EAAE,CAAC,YAAY,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;YAC3B,OAAO,UAAU,CAAC;QACpB,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,EAAE,CAAC;QACZ,CAAC;IACH,CAAC;CACF;AA1FD,oEA0FC"}
@@ -0,0 +1,11 @@
1
+ import { StructuralRule, StructuralViolation, RuleLanguage } from '../types';
2
+ export declare class SR016UnsafeJSONParse implements StructuralRule {
3
+ id: string;
4
+ name: string;
5
+ policyRef: string;
6
+ severity: "BLOCKING";
7
+ languages: RuleLanguage[];
8
+ description: string;
9
+ check(filePath: string, sourceText: string): StructuralViolation[];
10
+ }
11
+ //# sourceMappingURL=SR016-unsafe-json-parse.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SR016-unsafe-json-parse.d.ts","sourceRoot":"","sources":["../../../src/structural-rules/rules/SR016-unsafe-json-parse.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AA2F7E,qBAAa,oBAAqB,YAAW,cAAc;IACzD,EAAE,SAAW;IACb,IAAI,SAAsC;IAC1C,SAAS,SAAW;IACpB,QAAQ,EAAG,UAAU,CAAU;IAC/B,SAAS,EAAE,YAAY,EAAE,CAAgC;IACzD,WAAW,SAEuE;IAElF,KAAK,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,mBAAmB,EAAE;CAuEnE"}
@@ -0,0 +1,187 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.SR016UnsafeJSONParse = void 0;
37
+ const ts = __importStar(require("typescript"));
38
+ function getLineAndCol(sf, pos) {
39
+ const lc = sf.getLineAndCharacterOfPosition(pos);
40
+ return { line: lc.line + 1, column: lc.character + 1 };
41
+ }
42
+ function getEvidenceLines(sourceText, line, extra = 1) {
43
+ const lines = sourceText.split('\n');
44
+ return lines.slice(line - 1, Math.min(line - 1 + extra, lines.length)).map(l => l.slice(0, 120)).join('\n');
45
+ }
46
+ function isTestFile(filePath) {
47
+ return filePath.includes('.test.') || filePath.includes('.spec.');
48
+ }
49
+ /**
50
+ * Walk up the AST from a node to find the nearest try/catch statement.
51
+ * Returns true if a try block is found before reaching the function boundary.
52
+ */
53
+ function isWrappedInTryCatch(node) {
54
+ let current = node.parent;
55
+ while (current) {
56
+ // Stop at function boundaries — the try/catch must be within the same function
57
+ if (ts.isFunctionDeclaration(current) ||
58
+ ts.isFunctionExpression(current) ||
59
+ ts.isArrowFunction(current) ||
60
+ ts.isMethodDeclaration(current) ||
61
+ ts.isConstructorDeclaration(current) ||
62
+ ts.isGetAccessorDeclaration(current) ||
63
+ ts.isSetAccessorDeclaration(current)) {
64
+ return false;
65
+ }
66
+ if (ts.isTryStatement(current)) {
67
+ // The node must be inside the try block (not the catch/finally)
68
+ if (isDescendantOf(node, current.tryBlock)) {
69
+ return true;
70
+ }
71
+ }
72
+ current = current.parent;
73
+ }
74
+ return false;
75
+ }
76
+ /** Returns true if `node` is a descendant of `ancestor`. */
77
+ function isDescendantOf(node, ancestor) {
78
+ let current = node.parent;
79
+ while (current) {
80
+ if (current === ancestor)
81
+ return true;
82
+ current = current.parent;
83
+ }
84
+ return false;
85
+ }
86
+ /**
87
+ * Check if the JSON.parse call is inside a catch block.
88
+ * Error-handling context — acceptable to not double-wrap.
89
+ */
90
+ function isInsideCatchClause(node) {
91
+ let current = node.parent;
92
+ while (current) {
93
+ if (ts.isCatchClause(current))
94
+ return true;
95
+ // Stop at function boundaries
96
+ if (ts.isFunctionDeclaration(current) ||
97
+ ts.isFunctionExpression(current) ||
98
+ ts.isArrowFunction(current) ||
99
+ ts.isMethodDeclaration(current)) {
100
+ return false;
101
+ }
102
+ current = current.parent;
103
+ }
104
+ return false;
105
+ }
106
+ /**
107
+ * Check if the argument to JSON.parse is a string literal (compile-time safe).
108
+ */
109
+ function isStringLiteralArg(callNode) {
110
+ if (callNode.arguments.length === 0)
111
+ return false;
112
+ const firstArg = callNode.arguments[0];
113
+ return ts.isStringLiteral(firstArg) || ts.isNoSubstitutionTemplateLiteral(firstArg);
114
+ }
115
+ class SR016UnsafeJSONParse {
116
+ id = 'SR016';
117
+ name = 'Unsafe JSON.parse (no try/catch)';
118
+ policyRef = 'SR016';
119
+ severity = 'BLOCKING';
120
+ languages = ['typescript', 'javascript'];
121
+ description = 'JSON.parse() calls not wrapped in a try/catch — SyntaxError on malformed input crashes the ' +
122
+ 'handler and, in Node.js, kills all in-flight requests sharing the event loop.';
123
+ check(filePath, sourceText) {
124
+ try {
125
+ if (isTestFile(filePath))
126
+ return [];
127
+ const violations = [];
128
+ const ext = filePath.endsWith('.tsx')
129
+ ? ts.ScriptKind.TSX
130
+ : filePath.endsWith('.jsx')
131
+ ? ts.ScriptKind.JSX
132
+ : filePath.endsWith('.js')
133
+ ? ts.ScriptKind.JS
134
+ : ts.ScriptKind.TS;
135
+ const sf = ts.createSourceFile(filePath, sourceText, ts.ScriptTarget.Latest, true, ext);
136
+ const visit = (node) => {
137
+ // Looking for: JSON.parse(...)
138
+ if (ts.isCallExpression(node) &&
139
+ ts.isPropertyAccessExpression(node.expression) &&
140
+ ts.isIdentifier(node.expression.expression) &&
141
+ node.expression.expression.text === 'JSON' &&
142
+ node.expression.name.text === 'parse') {
143
+ // Exclude: argument is a string literal (compile-time safe)
144
+ if (isStringLiteralArg(node)) {
145
+ ts.forEachChild(node, visit);
146
+ return;
147
+ }
148
+ // Exclude: inside a catch clause (already error-handling context)
149
+ if (isInsideCatchClause(node)) {
150
+ ts.forEachChild(node, visit);
151
+ return;
152
+ }
153
+ // Flag if not wrapped in try/catch
154
+ if (!isWrappedInTryCatch(node)) {
155
+ const { line, column } = getLineAndCol(sf, node.expression.name.getStart(sf));
156
+ const evidence = getEvidenceLines(sourceText, line, 2);
157
+ violations.push({
158
+ ruleId: this.id,
159
+ ruleName: this.name,
160
+ policyRef: this.policyRef,
161
+ severity: this.severity,
162
+ filePath,
163
+ line,
164
+ column,
165
+ evidence,
166
+ operationalRisk: 'A single malformed JSON payload in a webhook, event stream, or IPC message crashes the ' +
167
+ 'handler. In a shared event loop (Node.js), this kills all in-flight requests.',
168
+ remediation: 'Wrap in try/catch: `try { const data = JSON.parse(raw); } catch (e) { ' +
169
+ "throw new TRPCError({ code: 'BAD_REQUEST', message: 'Invalid JSON payload' }); }`",
170
+ determinism: 'deterministic-structural',
171
+ confidence: 0.90,
172
+ language: filePath.match(/\.(js|jsx)$/) ? 'javascript' : 'typescript',
173
+ });
174
+ }
175
+ }
176
+ ts.forEachChild(node, visit);
177
+ };
178
+ ts.forEachChild(sf, visit);
179
+ return violations;
180
+ }
181
+ catch {
182
+ return [];
183
+ }
184
+ }
185
+ }
186
+ exports.SR016UnsafeJSONParse = SR016UnsafeJSONParse;
187
+ //# sourceMappingURL=SR016-unsafe-json-parse.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SR016-unsafe-json-parse.js","sourceRoot":"","sources":["../../../src/structural-rules/rules/SR016-unsafe-json-parse.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAiC;AAGjC,SAAS,aAAa,CAAC,EAAiB,EAAE,GAAW;IACnD,MAAM,EAAE,GAAG,EAAE,CAAC,6BAA6B,CAAC,GAAG,CAAC,CAAC;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E,QAAQ,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,YAAY;yBACtE,CAAC,CAAC;oBACL,CAAC;gBACH,CAAC;gBAED,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;YAC/B,CAAC,CAAC;YAEF,EAAE,CAAC,YAAY,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;YAC3B,OAAO,UAAU,CAAC;QACpB,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,EAAE,CAAC;QACZ,CAAC;IACH,CAAC;CACF;AAjFD,oDAiFC"}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Inline suppression annotations for structural rules.
3
+ *
4
+ * Supported formats:
5
+ * // neurcode-ignore: SR003
6
+ * // neurcode-ignore: SR003, SR007
7
+ * // neurcode-ignore-next-line: SR003
8
+ * // neurcode-ignore-file: SR003
9
+ * // neurcode-ignore-file: SR003 — reason: timer is cleaned up in test teardown
10
+ *
11
+ * Every suppression is preserved in the audit trail as a SuppressedViolation.
12
+ * Suppressions never silently drop findings — they reclassify them as suppressed.
13
+ */
14
+ import type { StructuralViolation } from './types';
15
+ export interface SuppressionDirective {
16
+ type: 'line' | 'next-line' | 'file';
17
+ ruleIds: string[];
18
+ line: number;
19
+ reason: string | null;
20
+ raw: string;
21
+ }
22
+ export interface SuppressedViolation {
23
+ violation: StructuralViolation;
24
+ directive: SuppressionDirective;
25
+ suppressedAt: string;
26
+ }
27
+ /**
28
+ * Parse all neurcode-ignore directives from source text.
29
+ * Returns directives sorted by line number.
30
+ */
31
+ export declare function parseSuppressionDirectives(sourceText: string): SuppressionDirective[];
32
+ /**
33
+ * Apply suppression directives to a set of violations.
34
+ *
35
+ * Returns:
36
+ * - active: violations NOT suppressed (to be reported normally)
37
+ * - suppressed: violations that matched a directive (audit trail)
38
+ */
39
+ export declare function applySuppressions(violations: StructuralViolation[], directives: SuppressionDirective[], _filePath: string): {
40
+ active: StructuralViolation[];
41
+ suppressed: SuppressedViolation[];
42
+ };
43
+ //# sourceMappingURL=suppressions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"suppressions.d.ts","sourceRoot":"","sources":["../../src/structural-rules/suppressions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAEnD,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAK,MAAM,GAAG,WAAW,GAAG,MAAM,CAAC;IACvC,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,IAAI,EAAK,MAAM,CAAC;IAChB,MAAM,EAAG,MAAM,GAAG,IAAI,CAAC;IACvB,GAAG,EAAM,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,mBAAmB;IAClC,SAAS,EAAK,mBAAmB,CAAC;IAClC,SAAS,EAAK,oBAAoB,CAAC;IACnC,YAAY,EAAE,MAAM,CAAC;CACtB;AASD;;;GAGG;AACH,wBAAgB,0BAA0B,CAAC,UAAU,EAAE,MAAM,GAAG,oBAAoB,EAAE,CA4CrF;AAUD;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,mBAAmB,EAAE,EACjC,UAAU,EAAE,oBAAoB,EAAE,EAClC,SAAS,EAAE,MAAM,GAChB;IAAE,MAAM,EAAE,mBAAmB,EAAE,CAAC;IAAC,UAAU,EAAE,mBAAmB,EAAE,CAAA;CAAE,CAwCtE"}
@@ -0,0 +1,115 @@
1
+ "use strict";
2
+ /**
3
+ * Inline suppression annotations for structural rules.
4
+ *
5
+ * Supported formats:
6
+ * // neurcode-ignore: SR003
7
+ * // neurcode-ignore: SR003, SR007
8
+ * // neurcode-ignore-next-line: SR003
9
+ * // neurcode-ignore-file: SR003
10
+ * // neurcode-ignore-file: SR003 — reason: timer is cleaned up in test teardown
11
+ *
12
+ * Every suppression is preserved in the audit trail as a SuppressedViolation.
13
+ * Suppressions never silently drop findings — they reclassify them as suppressed.
14
+ */
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.parseSuppressionDirectives = parseSuppressionDirectives;
17
+ exports.applySuppressions = applySuppressions;
18
+ // Matches: // neurcode-ignore[-next-line|-file][: SR001, SR002] [— reason: ...]
19
+ // Group 1: variant suffix ('-next-line', '-file', or empty)
20
+ // Group 2: rule list (may be absent)
21
+ // Group 3: reason text (may be absent)
22
+ const DIRECTIVE_RE = /\/\/\s*neurcode-ignore(-next-line|-file)?(?:\s*:\s*([^—\n]+?))?(?:\s*[—–-]\s*reason:\s*(.+?))?[\s]*$/;
23
+ /**
24
+ * Parse all neurcode-ignore directives from source text.
25
+ * Returns directives sorted by line number.
26
+ */
27
+ function parseSuppressionDirectives(sourceText) {
28
+ const lines = sourceText.split('\n');
29
+ const directives = [];
30
+ for (let i = 0; i < lines.length; i++) {
31
+ const lineText = lines[i];
32
+ const lineNumber = i + 1; // 1-based
33
+ // Quick bail — must contain the marker
34
+ if (!lineText.includes('neurcode-ignore'))
35
+ continue;
36
+ const match = DIRECTIVE_RE.exec(lineText);
37
+ if (!match)
38
+ continue;
39
+ const variantSuffix = match[1] ?? ''; // '-next-line', '-file', or ''
40
+ const ruleListRaw = match[2] ?? '';
41
+ const reasonRaw = match[3] ?? '';
42
+ let type;
43
+ if (variantSuffix === '-next-line') {
44
+ type = 'next-line';
45
+ }
46
+ else if (variantSuffix === '-file') {
47
+ type = 'file';
48
+ }
49
+ else {
50
+ type = 'line';
51
+ }
52
+ // Parse comma-separated rule IDs, stripping whitespace
53
+ const ruleIds = ruleListRaw
54
+ .split(',')
55
+ .map(r => r.trim())
56
+ .filter(r => r.length > 0);
57
+ const reason = reasonRaw.trim() || null;
58
+ // Capture the original comment text (trimmed)
59
+ const raw = lineText.replace(/^.*?\/\//, '//').trim();
60
+ directives.push({ type, ruleIds, line: lineNumber, reason, raw });
61
+ }
62
+ // Stable sort by line number (already in order, but be explicit)
63
+ directives.sort((a, b) => a.line - b.line);
64
+ return directives;
65
+ }
66
+ /**
67
+ * Return true if the directive covers the given ruleId.
68
+ * An empty ruleIds list means "suppress everything".
69
+ */
70
+ function directiveMatchesRule(directive, ruleId) {
71
+ return directive.ruleIds.length === 0 || directive.ruleIds.includes(ruleId);
72
+ }
73
+ /**
74
+ * Apply suppression directives to a set of violations.
75
+ *
76
+ * Returns:
77
+ * - active: violations NOT suppressed (to be reported normally)
78
+ * - suppressed: violations that matched a directive (audit trail)
79
+ */
80
+ function applySuppressions(violations, directives, _filePath) {
81
+ const active = [];
82
+ const suppressed = [];
83
+ const now = new Date().toISOString();
84
+ for (const violation of violations) {
85
+ let matchedDirective = null;
86
+ for (const directive of directives) {
87
+ if (!directiveMatchesRule(directive, violation.ruleId))
88
+ continue;
89
+ if (directive.type === 'file') {
90
+ matchedDirective = directive;
91
+ break;
92
+ }
93
+ if (directive.type === 'line' && directive.line === violation.line) {
94
+ matchedDirective = directive;
95
+ break;
96
+ }
97
+ if (directive.type === 'next-line' && directive.line + 1 === violation.line) {
98
+ matchedDirective = directive;
99
+ break;
100
+ }
101
+ }
102
+ if (matchedDirective) {
103
+ suppressed.push({
104
+ violation,
105
+ directive: matchedDirective,
106
+ suppressedAt: now,
107
+ });
108
+ }
109
+ else {
110
+ active.push(violation);
111
+ }
112
+ }
113
+ return { active, suppressed };
114
+ }
115
+ //# sourceMappingURL=suppressions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"suppressions.js","sourceRoot":"","sources":["../../src/structural-rules/suppressions.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;GAYG;;AA6BH,gEA4CC;AAiBD,8CA4CC;AApHD,gFAAgF;AAChF,4DAA4D;AAC5D,qCAAqC;AACrC,uCAAuC;AACvC,MAAM,YAAY,GAChB,sGAAsG,CAAC;AAEzG;;;GAGG;AACH,SAAgB,0BAA0B,CAAC,UAAkB;IAC3D,MAAM,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACrC,MAAM,UAAU,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BAAgB,GAAG,SAAS,CAAC;gBAC7B,MAAM;YACR,CAAC;YAED,IAAI,SAAS,CAAC,IAAI,KAAK,WAAW,IAAI,SAAS,CAAC,IAAI,GAAG,CAAC,KAAK,SAAS,CAAC,IAAI,EAAE,CAAC;gBAC5E,gBAAgB,GAAG,SAAS,CAAC;gBAC7B,MAAM;YACR,CAAC;QACH,CAAC;QAED,IAAI,gBAAgB,EAAE,CAAC;YACrB,UAAU,CAAC,IAAI,CAAC;gBACd,SAAS;gBACT,SAAS,EAAE,gBAAgB;gBAC3B,YAAY,EAAE,GAAG;aAClB,CAAC,CAAC;QACL,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACzB,CAAC;IACH,CAAC;IAED,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC;AAChC,CAAC"}
@@ -0,0 +1,43 @@
1
+ import type { SuppressedViolation } from './suppressions';
2
+ import type { SeverityAdjustment } from './context-severity';
3
+ export type { SuppressedViolation } from './suppressions';
4
+ export type { SeverityAdjustment } from './context-severity';
5
+ export type DeterminismLevel = 'deterministic-structural' | 'deterministic-semantic' | 'heuristic-advisory' | 'llm-assisted-planning';
6
+ export type RuleSeverity = 'BLOCKING' | 'ADVISORY';
7
+ export type RuleLanguage = 'typescript' | 'python' | 'javascript';
8
+ export interface StructuralViolation {
9
+ ruleId: string;
10
+ ruleName: string;
11
+ policyRef: string;
12
+ severity: RuleSeverity;
13
+ filePath: string;
14
+ line: number;
15
+ column: number;
16
+ evidence: string;
17
+ operationalRisk: string;
18
+ remediation: string;
19
+ determinism: DeterminismLevel;
20
+ confidence: number;
21
+ language: RuleLanguage;
22
+ }
23
+ export interface StructuralRuleResult {
24
+ violations: StructuralViolation[];
25
+ filesAnalyzed: number;
26
+ analysisMs: number;
27
+ rulesApplied: string[];
28
+ skippedFiles: string[];
29
+ suppressedCount: number;
30
+ suppressedViolations: SuppressedViolation[];
31
+ severityAdjustments: SeverityAdjustment[];
32
+ }
33
+ export interface StructuralRule {
34
+ id: string;
35
+ name: string;
36
+ policyRef: string;
37
+ severity: RuleSeverity;
38
+ languages: RuleLanguage[];
39
+ description: string;
40
+ /** Check a single file's source text. Returns violations found. */
41
+ check(filePath: string, sourceText: string): StructuralViolation[];
42
+ }
43
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/structural-rules/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAE7D,YAAY,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAC1D,YAAY,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAE7D,MAAM,MAAM,gBAAgB,GACxB,0BAA0B,GAC1B,wBAAwB,GACxB,oBAAoB,GACpB,uBAAuB,CAAC;AAE5B,MAAM,MAAM,YAAY,GAAG,UAAU,GAAG,UAAU,CAAC;AACnD,MAAM,MAAM,YAAY,GAAG,YAAY,GAAG,QAAQ,GAAG,YAAY,CAAC;AAElE,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAY,MAAM,CAAC;IACzB,QAAQ,EAAU,MAAM,CAAC;IACzB,SAAS,EAAS,MAAM,CAAC;IACzB,QAAQ,EAAU,YAAY,CAAC;IAC/B,QAAQ,EAAU,MAAM,CAAC;IACzB,IAAI,EAAc,MAAM,CAAC;IACzB,MAAM,EAAY,MAAM,CAAC;IACzB,QAAQ,EAAU,MAAM,CAAC;IACzB,eAAe,EAAG,MAAM,CAAC;IACzB,WAAW,EAAO,MAAM,CAAC;IACzB,WAAW,EAAO,gBAAgB,CAAC;IACnC,UAAU,EAAQ,MAAM,CAAC;IACzB,QAAQ,EAAU,YAAY,CAAC;CAChC;AAED,MAAM,WAAW,oBAAoB;IACnC,UAAU,EAAY,mBAAmB,EAAE,CAAC;IAC5C,aAAa,EAAS,MAAM,CAAC;IAC7B,UAAU,EAAY,MAAM,CAAC;IAC7B,YAAY,EAAU,MAAM,EAAE,CAAC;IAC/B,YAAY,EAAU,MAAM,EAAE,CAAC;IAC/B,eAAe,EAAO,MAAM,CAAC;IAC7B,oBAAoB,EAAE,mBAAmB,EAAE,CAAC;IAC5C,mBAAmB,EAAG,kBAAkB,EAAE,CAAC;CAC5C;AAED,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAS,MAAM,CAAC;IAClB,IAAI,EAAO,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAG,YAAY,CAAC;IACxB,SAAS,EAAE,YAAY,EAAE,CAAC;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,mEAAmE;IACnE,KAAK,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,mBAAmB,EAAE,CAAC;CACpE"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/structural-rules/types.ts"],"names":[],"mappings":""}
@@ -6,6 +6,11 @@ export interface AdvisorySignal {
6
6
  title: string;
7
7
  detail: string;
8
8
  files: string[];
9
+ advisoryOnly: true;
10
+ confidence: 'low' | 'medium';
11
+ evidence: string[];
12
+ uncertainty: string;
13
+ structuralCoverageGap: string;
9
14
  }
10
15
  interface AdvisoryInput {
11
16
  diffFiles: DiffFile[];