@rigour-labs/core 6.8.0 → 6.8.1

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 (326) hide show
  1. package/dist/inference/cloud-provider.js +12 -2
  2. package/package.json +11 -8
  3. package/dist/brief/briefing.test.d.ts +0 -1
  4. package/dist/brief/briefing.test.js +0 -107
  5. package/dist/context/automatic-index-cache.test.d.ts +0 -1
  6. package/dist/context/automatic-index-cache.test.js +0 -30
  7. package/dist/context/automatic-index.test.d.ts +0 -1
  8. package/dist/context/automatic-index.test.js +0 -45
  9. package/dist/context/cache-engine.test.d.ts +0 -1
  10. package/dist/context/cache-engine.test.js +0 -99
  11. package/dist/context/dependency-graph.test.d.ts +0 -1
  12. package/dist/context/dependency-graph.test.js +0 -13
  13. package/dist/context/index-status.test.d.ts +0 -1
  14. package/dist/context/index-status.test.js +0 -26
  15. package/dist/context.test.d.ts +0 -1
  16. package/dist/context.test.js +0 -228
  17. package/dist/deep/agent-review.test.d.ts +0 -1
  18. package/dist/deep/agent-review.test.js +0 -53
  19. package/dist/deep/code-context.test.d.ts +0 -1
  20. package/dist/deep/code-context.test.js +0 -48
  21. package/dist/deep/code-pass.test.d.ts +0 -1
  22. package/dist/deep/code-pass.test.js +0 -112
  23. package/dist/deep/code-review-prompt.test.d.ts +0 -1
  24. package/dist/deep/code-review-prompt.test.js +0 -20
  25. package/dist/deep/code-verifier.test.d.ts +0 -1
  26. package/dist/deep/code-verifier.test.js +0 -54
  27. package/dist/deep/diff-tests/calls.test.d.ts +0 -1
  28. package/dist/deep/diff-tests/calls.test.js +0 -33
  29. package/dist/deep/diff-tests/run.test.d.ts +0 -1
  30. package/dist/deep/diff-tests/run.test.js +0 -58
  31. package/dist/deep/fact-extractor.test.d.ts +0 -1
  32. package/dist/deep/fact-extractor.test.js +0 -581
  33. package/dist/deep/parse-findings.test.d.ts +0 -1
  34. package/dist/deep/parse-findings.test.js +0 -25
  35. package/dist/deep/pr-review.test.d.ts +0 -1
  36. package/dist/deep/pr-review.test.js +0 -80
  37. package/dist/deep/prompts.test.d.ts +0 -1
  38. package/dist/deep/prompts.test.js +0 -235
  39. package/dist/deep/reference-pack.test.d.ts +0 -1
  40. package/dist/deep/reference-pack.test.js +0 -46
  41. package/dist/deep/related-changes.test.d.ts +0 -1
  42. package/dist/deep/related-changes.test.js +0 -33
  43. package/dist/deep/review-context-export.test.d.ts +0 -1
  44. package/dist/deep/review-context-export.test.js +0 -32
  45. package/dist/deep/review-tools.test.d.ts +0 -1
  46. package/dist/deep/review-tools.test.js +0 -39
  47. package/dist/deep/risk.test.d.ts +0 -1
  48. package/dist/deep/risk.test.js +0 -101
  49. package/dist/deep/verifier.test.d.ts +0 -1
  50. package/dist/deep/verifier.test.js +0 -635
  51. package/dist/discovery.test.d.ts +0 -1
  52. package/dist/discovery.test.js +0 -93
  53. package/dist/environment.test.d.ts +0 -1
  54. package/dist/environment.test.js +0 -94
  55. package/dist/firewall/firewall.test.d.ts +0 -1
  56. package/dist/firewall/firewall.test.js +0 -117
  57. package/dist/firewall/trust-boundaries.test.d.ts +0 -1
  58. package/dist/firewall/trust-boundaries.test.js +0 -64
  59. package/dist/firewall/trusted-control.test.d.ts +0 -1
  60. package/dist/firewall/trusted-control.test.js +0 -188
  61. package/dist/gates/agent-team.test.d.ts +0 -1
  62. package/dist/gates/agent-team.test.js +0 -113
  63. package/dist/gates/ast.test.d.ts +0 -1
  64. package/dist/gates/ast.test.js +0 -112
  65. package/dist/gates/checkpoint.test.d.ts +0 -1
  66. package/dist/gates/checkpoint.test.js +0 -105
  67. package/dist/gates/content.test.d.ts +0 -1
  68. package/dist/gates/content.test.js +0 -73
  69. package/dist/gates/coverage.test.d.ts +0 -1
  70. package/dist/gates/coverage.test.js +0 -53
  71. package/dist/gates/dedupe-failures.test.d.ts +0 -1
  72. package/dist/gates/dedupe-failures.test.js +0 -12
  73. package/dist/gates/deep-analysis.test.d.ts +0 -1
  74. package/dist/gates/deep-analysis.test.js +0 -86
  75. package/dist/gates/deep-intent.test.d.ts +0 -1
  76. package/dist/gates/deep-intent.test.js +0 -51
  77. package/dist/gates/deep-timeout.test.d.ts +0 -1
  78. package/dist/gates/deep-timeout.test.js +0 -10
  79. package/dist/gates/deprecated-apis.test.d.ts +0 -1
  80. package/dist/gates/deprecated-apis.test.js +0 -318
  81. package/dist/gates/deprecated-dependencies.test.d.ts +0 -1
  82. package/dist/gates/deprecated-dependencies.test.js +0 -55
  83. package/dist/gates/frontend-secret-exposure.test.d.ts +0 -1
  84. package/dist/gates/frontend-secret-exposure.test.js +0 -148
  85. package/dist/gates/hallucinated-imports/framework-modules-nuxt.test.d.ts +0 -1
  86. package/dist/gates/hallucinated-imports/framework-modules-nuxt.test.js +0 -27
  87. package/dist/gates/hallucinated-imports/js-resolver-types.test.d.ts +0 -1
  88. package/dist/gates/hallucinated-imports/js-resolver-types.test.js +0 -14
  89. package/dist/gates/hallucinated-imports-sveltekit.test.d.ts +0 -1
  90. package/dist/gates/hallucinated-imports-sveltekit.test.js +0 -132
  91. package/dist/gates/hallucinated-imports.test.d.ts +0 -1
  92. package/dist/gates/hallucinated-imports.test.js +0 -1206
  93. package/dist/gates/js-style-context.test.d.ts +0 -1
  94. package/dist/gates/js-style-context.test.js +0 -35
  95. package/dist/gates/logic-drift.test.d.ts +0 -1
  96. package/dist/gates/logic-drift.test.js +0 -52
  97. package/dist/gates/phantom-apis.test.d.ts +0 -1
  98. package/dist/gates/phantom-apis.test.js +0 -396
  99. package/dist/gates/promise-safety.test.d.ts +0 -1
  100. package/dist/gates/promise-safety.test.js +0 -34
  101. package/dist/gates/runner.test.d.ts +0 -1
  102. package/dist/gates/runner.test.js +0 -77
  103. package/dist/gates/scoped-gates.test.d.ts +0 -1
  104. package/dist/gates/scoped-gates.test.js +0 -52
  105. package/dist/gates/security-patterns-owasp.test.d.ts +0 -1
  106. package/dist/gates/security-patterns-owasp.test.js +0 -186
  107. package/dist/gates/security-patterns.test.d.ts +0 -1
  108. package/dist/gates/security-patterns.test.js +0 -194
  109. package/dist/gates/semantic-bugs.test.d.ts +0 -1
  110. package/dist/gates/semantic-bugs.test.js +0 -76
  111. package/dist/gates/side-effect-analysis.test.d.ts +0 -1
  112. package/dist/gates/side-effect-analysis.test.js +0 -162
  113. package/dist/gates/style-drift.test.d.ts +0 -1
  114. package/dist/gates/style-drift.test.js +0 -26
  115. package/dist/gates/test-quality.test.d.ts +0 -1
  116. package/dist/gates/test-quality.test.js +0 -325
  117. package/dist/gates/trusted-reviews.test.d.ts +0 -1
  118. package/dist/gates/trusted-reviews.test.js +0 -16
  119. package/dist/gates/unindexed-reads/queries.test.d.ts +0 -1
  120. package/dist/gates/unindexed-reads/queries.test.js +0 -54
  121. package/dist/gates/unindexed-reads/schema.test.d.ts +0 -1
  122. package/dist/gates/unindexed-reads/schema.test.js +0 -81
  123. package/dist/gates/unindexed-reads/unindexed-reads.test.d.ts +0 -1
  124. package/dist/gates/unindexed-reads/unindexed-reads.test.js +0 -90
  125. package/dist/hooks/checker.test.d.ts +0 -1
  126. package/dist/hooks/checker.test.js +0 -159
  127. package/dist/hooks/dlp-confidence.test.d.ts +0 -1
  128. package/dist/hooks/dlp-confidence.test.js +0 -51
  129. package/dist/hooks/dlp-feedback.test.d.ts +0 -1
  130. package/dist/hooks/dlp-feedback.test.js +0 -131
  131. package/dist/hooks/input-validator.test.d.ts +0 -1
  132. package/dist/hooks/input-validator.test.js +0 -329
  133. package/dist/hooks/templates.test.d.ts +0 -1
  134. package/dist/hooks/templates.test.js +0 -27
  135. package/dist/inference/brain-placeholder.test.d.ts +0 -1
  136. package/dist/inference/brain-placeholder.test.js +0 -28
  137. package/dist/inference/cloud-provider.test.d.ts +0 -1
  138. package/dist/inference/cloud-provider.test.js +0 -139
  139. package/dist/inference/executable.test.d.ts +0 -1
  140. package/dist/inference/executable.test.js +0 -41
  141. package/dist/inference/http-download.test.d.ts +0 -1
  142. package/dist/inference/http-download.test.js +0 -109
  143. package/dist/inference/llama-engine-checksum.test.d.ts +0 -1
  144. package/dist/inference/llama-engine-checksum.test.js +0 -27
  145. package/dist/inference/llama-engine.test.d.ts +0 -1
  146. package/dist/inference/llama-engine.test.js +0 -51
  147. package/dist/inference/llama-process.test.d.ts +0 -1
  148. package/dist/inference/llama-process.test.js +0 -61
  149. package/dist/inference/local-model.test.d.ts +0 -1
  150. package/dist/inference/local-model.test.js +0 -23
  151. package/dist/inference/model-download.test.d.ts +0 -1
  152. package/dist/inference/model-download.test.js +0 -125
  153. package/dist/inference/model-manager.test.d.ts +0 -1
  154. package/dist/inference/model-manager.test.js +0 -24
  155. package/dist/inference/types.test.d.ts +0 -1
  156. package/dist/inference/types.test.js +0 -19
  157. package/dist/memory/recall.test.d.ts +0 -1
  158. package/dist/memory/recall.test.js +0 -36
  159. package/dist/pattern-index/indexer.test.d.ts +0 -6
  160. package/dist/pattern-index/indexer.test.js +0 -197
  161. package/dist/pattern-index/matcher.test.d.ts +0 -6
  162. package/dist/pattern-index/matcher.test.js +0 -238
  163. package/dist/pattern-index/pattern-reuse.test.d.ts +0 -1
  164. package/dist/pattern-index/pattern-reuse.test.js +0 -76
  165. package/dist/pattern-index/semantic-runtime.test.d.ts +0 -1
  166. package/dist/pattern-index/semantic-runtime.test.js +0 -31
  167. package/dist/pattern-index/staleness.test.d.ts +0 -6
  168. package/dist/pattern-index/staleness.test.js +0 -211
  169. package/dist/review/agent-fixes.test.d.ts +0 -1
  170. package/dist/review/agent-fixes.test.js +0 -32
  171. package/dist/review/backtest-init.test.d.ts +0 -1
  172. package/dist/review/backtest-init.test.js +0 -136
  173. package/dist/review/backtest-judges.test.d.ts +0 -1
  174. package/dist/review/backtest-judges.test.js +0 -32
  175. package/dist/review/backtest-last.test.d.ts +0 -1
  176. package/dist/review/backtest-last.test.js +0 -109
  177. package/dist/review/backtest.test.d.ts +0 -1
  178. package/dist/review/backtest.test.js +0 -183
  179. package/dist/review/baseline.test.d.ts +0 -1
  180. package/dist/review/baseline.test.js +0 -22
  181. package/dist/review/branch-checks.test.d.ts +0 -1
  182. package/dist/review/branch-checks.test.js +0 -48
  183. package/dist/review/check-outcomes.test.d.ts +0 -1
  184. package/dist/review/check-outcomes.test.js +0 -56
  185. package/dist/review/code-patterns.test.d.ts +0 -1
  186. package/dist/review/code-patterns.test.js +0 -142
  187. package/dist/review/dead-code.test.d.ts +0 -1
  188. package/dist/review/dead-code.test.js +0 -154
  189. package/dist/review/deep-runs.test.d.ts +0 -1
  190. package/dist/review/deep-runs.test.js +0 -23
  191. package/dist/review/effectiveness.test.d.ts +0 -1
  192. package/dist/review/effectiveness.test.js +0 -42
  193. package/dist/review/fix-scope.test.d.ts +0 -1
  194. package/dist/review/fix-scope.test.js +0 -104
  195. package/dist/review/generated-files.test.d.ts +0 -1
  196. package/dist/review/generated-files.test.js +0 -25
  197. package/dist/review/migration-order.test.d.ts +0 -1
  198. package/dist/review/migration-order.test.js +0 -62
  199. package/dist/review/quiet.test.d.ts +0 -1
  200. package/dist/review/quiet.test.js +0 -38
  201. package/dist/review/receipt.test.d.ts +0 -1
  202. package/dist/review/receipt.test.js +0 -60
  203. package/dist/review/review-task.test.d.ts +0 -1
  204. package/dist/review/review-task.test.js +0 -89
  205. package/dist/review/review.test.d.ts +0 -1
  206. package/dist/review/review.test.js +0 -203
  207. package/dist/review/reviewer/adapters.test.d.ts +0 -1
  208. package/dist/review/reviewer/adapters.test.js +0 -100
  209. package/dist/review/reviewer/api-judge.test.d.ts +0 -1
  210. package/dist/review/reviewer/api-judge.test.js +0 -108
  211. package/dist/review/reviewer/background.test.d.ts +0 -1
  212. package/dist/review/reviewer/background.test.js +0 -118
  213. package/dist/review/reviewer/context.test.d.ts +0 -1
  214. package/dist/review/reviewer/context.test.js +0 -45
  215. package/dist/review/reviewer/exec.test.d.ts +0 -1
  216. package/dist/review/reviewer/exec.test.js +0 -59
  217. package/dist/review/reviewer/inputs.test.d.ts +0 -1
  218. package/dist/review/reviewer/inputs.test.js +0 -52
  219. package/dist/review/reviewer/panel.test.d.ts +0 -1
  220. package/dist/review/reviewer/panel.test.js +0 -110
  221. package/dist/review/reviewer/record.test.d.ts +0 -1
  222. package/dist/review/reviewer/record.test.js +0 -40
  223. package/dist/review/reviewer/rule-writer.test.d.ts +0 -1
  224. package/dist/review/reviewer/rule-writer.test.js +0 -52
  225. package/dist/review/reviewer/settings.test.d.ts +0 -1
  226. package/dist/review/reviewer/settings.test.js +0 -57
  227. package/dist/review/reviewer/usage.test.d.ts +0 -1
  228. package/dist/review/reviewer/usage.test.js +0 -14
  229. package/dist/review/reviewer.test.d.ts +0 -1
  230. package/dist/review/reviewer.test.js +0 -792
  231. package/dist/review/stories.test.d.ts +0 -1
  232. package/dist/review/stories.test.js +0 -58
  233. package/dist/review/toolchain.test.d.ts +0 -1
  234. package/dist/review/toolchain.test.js +0 -108
  235. package/dist/review/typed/redundancy.test.d.ts +0 -1
  236. package/dist/review/typed/redundancy.test.js +0 -315
  237. package/dist/review/typed/schema-nullability.test.d.ts +0 -1
  238. package/dist/review/typed/schema-nullability.test.js +0 -63
  239. package/dist/review-learning/human-edits.test.d.ts +0 -1
  240. package/dist/review-learning/human-edits.test.js +0 -47
  241. package/dist/review-learning/repo-rules.test.d.ts +0 -1
  242. package/dist/review-learning/repo-rules.test.js +0 -93
  243. package/dist/review-learning/review-learning.test.d.ts +0 -1
  244. package/dist/review-learning/review-learning.test.js +0 -249
  245. package/dist/safety.test.d.ts +0 -1
  246. package/dist/safety.test.js +0 -42
  247. package/dist/semantic/benchmark.test.d.ts +0 -1
  248. package/dist/semantic/benchmark.test.js +0 -22
  249. package/dist/semantic/intent/intent.test.d.ts +0 -1
  250. package/dist/semantic/intent/intent.test.js +0 -46
  251. package/dist/semantic/learn/learn.test.d.ts +0 -1
  252. package/dist/semantic/learn/learn.test.js +0 -67
  253. package/dist/semantic/origins.test.d.ts +0 -1
  254. package/dist/semantic/origins.test.js +0 -77
  255. package/dist/semantic/project-facts.test.d.ts +0 -1
  256. package/dist/semantic/project-facts.test.js +0 -45
  257. package/dist/semantic/sites/call-sites.test.d.ts +0 -1
  258. package/dist/semantic/sites/call-sites.test.js +0 -46
  259. package/dist/services/adaptive-thresholds.test.d.ts +0 -1
  260. package/dist/services/adaptive-thresholds.test.js +0 -53
  261. package/dist/services/agent-history.test.d.ts +0 -1
  262. package/dist/services/agent-history.test.js +0 -69
  263. package/dist/services/context-scope-summary.test.d.ts +0 -1
  264. package/dist/services/context-scope-summary.test.js +0 -17
  265. package/dist/services/context-telemetry-service.test.d.ts +0 -1
  266. package/dist/services/context-telemetry-service.test.js +0 -182
  267. package/dist/services/cursor-usage-sync.test.d.ts +0 -1
  268. package/dist/services/cursor-usage-sync.test.js +0 -173
  269. package/dist/services/engineering-knowledge-graph.test.d.ts +0 -1
  270. package/dist/services/engineering-knowledge-graph.test.js +0 -76
  271. package/dist/services/model-pricing.test.d.ts +0 -1
  272. package/dist/services/model-pricing.test.js +0 -44
  273. package/dist/services/observed-savings.test.d.ts +0 -1
  274. package/dist/services/observed-savings.test.js +0 -37
  275. package/dist/services/score-history.test.d.ts +0 -1
  276. package/dist/services/score-history.test.js +0 -61
  277. package/dist/smoke.test.d.ts +0 -1
  278. package/dist/smoke.test.js +0 -17
  279. package/dist/storage/cache-cleanup.test.d.ts +0 -1
  280. package/dist/storage/cache-cleanup.test.js +0 -54
  281. package/dist/storage/context-telemetry.test.d.ts +0 -1
  282. package/dist/storage/context-telemetry.test.js +0 -80
  283. package/dist/storage/db.test.d.ts +0 -1
  284. package/dist/storage/db.test.js +0 -46
  285. package/dist/storage/fix-lessons.test.d.ts +0 -1
  286. package/dist/storage/fix-lessons.test.js +0 -61
  287. package/dist/storage/lessons.test.d.ts +0 -1
  288. package/dist/storage/lessons.test.js +0 -81
  289. package/dist/storage/local-encryption.test.d.ts +0 -1
  290. package/dist/storage/local-encryption.test.js +0 -34
  291. package/dist/storage/local-memory.test.d.ts +0 -1
  292. package/dist/storage/local-memory.test.js +0 -55
  293. package/dist/storage/share-memory.test.d.ts +0 -1
  294. package/dist/storage/share-memory.test.js +0 -34
  295. package/dist/storage/team-diagnostics.test.d.ts +0 -1
  296. package/dist/storage/team-diagnostics.test.js +0 -51
  297. package/dist/storage/team-scope.test.d.ts +0 -1
  298. package/dist/storage/team-scope.test.js +0 -22
  299. package/dist/storage/team-store.test.d.ts +0 -1
  300. package/dist/storage/team-store.test.js +0 -11
  301. package/dist/storage/team-sync-scope.test.d.ts +0 -1
  302. package/dist/storage/team-sync-scope.test.js +0 -100
  303. package/dist/storage/team-vector-store.test.d.ts +0 -1
  304. package/dist/storage/team-vector-store.test.js +0 -56
  305. package/dist/storage/telemetry-scope.test.d.ts +0 -1
  306. package/dist/storage/telemetry-scope.test.js +0 -38
  307. package/dist/task/thread.test.d.ts +0 -1
  308. package/dist/task/thread.test.js +0 -133
  309. package/dist/telemetry/telemetry.test.d.ts +0 -1
  310. package/dist/telemetry/telemetry.test.js +0 -64
  311. package/dist/types/index.test.d.ts +0 -1
  312. package/dist/types/index.test.js +0 -33
  313. package/dist/utils/command-line.test.d.ts +0 -1
  314. package/dist/utils/command-line.test.js +0 -8
  315. package/dist/utils/diff-removed.test.d.ts +0 -1
  316. package/dist/utils/diff-removed.test.js +0 -29
  317. package/dist/utils/diff.test.d.ts +0 -1
  318. package/dist/utils/diff.test.js +0 -38
  319. package/dist/utils/glob-paths.test.d.ts +0 -1
  320. package/dist/utils/glob-paths.test.js +0 -40
  321. package/dist/utils/profile.test.d.ts +0 -1
  322. package/dist/utils/profile.test.js +0 -68
  323. package/dist/utils/scanner.test.d.ts +0 -1
  324. package/dist/utils/scanner.test.js +0 -48
  325. package/dist/utils/scope.test.d.ts +0 -1
  326. package/dist/utils/scope.test.js +0 -38
@@ -107,7 +107,7 @@ export class CloudProvider {
107
107
  const response = await this.client.messages.create({
108
108
  model: this.modelName,
109
109
  max_tokens: options?.maxTokens || 4096,
110
- temperature: options?.temperature ?? 0.1,
110
+ ...claudeSampling(this.modelName, options?.temperature ?? 0.1),
111
111
  messages: cacheFirstPrompt(toAnthropicMessages(messages)),
112
112
  ...(tools.length ? { tools: tools.map(t => ({ name: t.name, description: t.description, input_schema: t.parameters })) } : {}),
113
113
  ...(tools.length && options?.toolChoice === 'none' ? { tool_choice: { type: 'none' } } : {}),
@@ -157,7 +157,7 @@ export class CloudProvider {
157
157
  const response = await this.client.messages.create({
158
158
  model: this.modelName,
159
159
  max_tokens: options?.maxTokens || 2048,
160
- temperature: options?.temperature || 0.1,
160
+ ...claudeSampling(this.modelName, options?.temperature ?? 0.1),
161
161
  messages: [
162
162
  { role: 'user', content: prompt }
163
163
  ],
@@ -203,6 +203,16 @@ export class CloudProvider {
203
203
  this.client = null;
204
204
  }
205
205
  }
206
+ /**
207
+ * Claude models that take no sampling parameters: Anthropic's model guide lists temperature, top_p and top_k as removed
208
+ * (a 400) on Fable, Mythos, Opus 5.5, Opus 5, Opus 4.8 and 4.7 and Sonnet 5, and non-default values as a 400 on Sonnet 5.5
209
+ * and Haiku 5.5; OpenRouter's model list marks temperature unsupported on them too. Older Claude models still take it.
210
+ */
211
+ const CLAUDE_WITHOUT_SAMPLING = /claude-(?:fable|mythos|opus-5|opus-4-[78]|sonnet-5|haiku-5)/;
212
+ /** The temperature to send a Claude model: none to one that rejects sampling parameters. */
213
+ function claudeSampling(model, temperature) {
214
+ return CLAUDE_WITHOUT_SAMPLING.test(model) ? {} : { temperature };
215
+ }
206
216
  /** The per-call timeout, honoured by both SDKs (their default is minutes, with retries). */
207
217
  function requestOptions(options) {
208
218
  return options?.timeout ? { timeout: options.timeout } : {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rigour-labs/core",
3
- "version": "6.8.0",
3
+ "version": "6.8.1",
4
4
  "description": "Rigour's review engine: deterministic gates on changed lines, rules and lessons learned from your team's fixes, and per-check precision from what you fix versus dismiss, across TypeScript, JavaScript, Python, Go, Ruby and C#.",
5
5
  "engines": {
6
6
  "node": ">=22.13"
@@ -30,7 +30,10 @@
30
30
  "type": "module",
31
31
  "files": [
32
32
  "dist",
33
- "README.md"
33
+ "README.md",
34
+ "!dist/**/*.test.js",
35
+ "!dist/**/*.test.d.ts",
36
+ "!dist/**/*.test.js.map"
34
37
  ],
35
38
  "main": "dist/index.js",
36
39
  "types": "dist/index.d.ts",
@@ -69,14 +72,14 @@
69
72
  "zod": "^3.22.4"
70
73
  },
71
74
  "optionalDependencies": {
72
- "@anthropic-ai/sdk": "^0.30.1",
75
+ "@anthropic-ai/sdk": "^0.132.1",
73
76
  "pg": "^8.16.3",
74
77
  "openai": "^5.23.2",
75
- "@rigour-labs/brain-darwin-x64": "6.8.0",
76
- "@rigour-labs/brain-darwin-arm64": "6.8.0",
77
- "@rigour-labs/brain-win-x64": "6.8.0",
78
- "@rigour-labs/brain-linux-x64": "6.8.0",
79
- "@rigour-labs/brain-linux-arm64": "6.8.0"
78
+ "@rigour-labs/brain-darwin-arm64": "6.8.1",
79
+ "@rigour-labs/brain-linux-arm64": "6.8.1",
80
+ "@rigour-labs/brain-darwin-x64": "6.8.1",
81
+ "@rigour-labs/brain-linux-x64": "6.8.1",
82
+ "@rigour-labs/brain-win-x64": "6.8.1"
80
83
  },
81
84
  "devDependencies": {
82
85
  "@types/fs-extra": "^11.0.4",
@@ -1 +0,0 @@
1
- export {};
@@ -1,107 +0,0 @@
1
- import { execFileSync } from 'child_process';
2
- import fs from 'fs';
3
- import os from 'os';
4
- import path from 'path';
5
- import { afterEach, beforeEach, describe, expect, it } from 'vitest';
6
- import { writeLessons } from '../review-learning/lessons.js';
7
- import { readThread } from '../task/thread.js';
8
- import { BRIEFING_MAX_ITEMS, briefFile, briefingText, briefTask, buildBriefing, buildFileBriefing, fileBriefingText } from './briefing.js';
9
- let repo;
10
- const git = (...args) => execFileSync('git', ['-C', repo, ...args], { encoding: 'utf8' }).trim();
11
- const write = (file, text) => {
12
- fs.mkdirSync(path.dirname(path.join(repo, file)), { recursive: true });
13
- fs.writeFileSync(path.join(repo, file), text);
14
- };
15
- const lesson = (id, state, file, text, symbols, pr) => ({
16
- id, text, file, symbols, state, evidence: [{ kind: 'outcome', pr, comment: 'c', author: 'senior', source: 'person' }],
17
- });
18
- beforeEach(() => {
19
- repo = fs.mkdtempSync(path.join(os.tmpdir(), 'brief-'));
20
- git('init', '-q', '-b', 'main');
21
- git('config', 'user.email', 't@example.com');
22
- git('config', 'user.name', 't');
23
- git('config', 'commit.gpgsign', 'false');
24
- write('AGENTS.md', [
25
- '- Every job in `src/jobs/` must take `withLock()` before its first read; a job that reads first double-sends.',
26
- '',
27
- 'Prefer `fetchWithTimeout()` over a bare call in `src/jobs/` when talking to partner APIs; a hung request blocks the queue.',
28
- '',
29
- ].join('\n'));
30
- write('services/billing/AGENTS.md', '- Every amount in `services/billing/` must be integer cents via `toCents()`; never a float.\n');
31
- write('src/jobs/retry.ts', 'export async function retryJob() {}\n');
32
- write('services/billing/charge.ts', 'export const charge = 1;\n');
33
- git('add', '-A');
34
- git('commit', '-qm', 'init');
35
- writeLessons(repo, [
36
- lesson('v1', 'verified', 'src/jobs/retry.ts', 'Bound the retry window at both ends: `updated_at` between since and until.', ['retryJob'], 12),
37
- lesson('c1', 'candidate', 'src/jobs/retry.ts', 'Log every retry at debug level in `retryJob`.', ['retryJob'], 13),
38
- lesson('r1', 'rejected', 'src/jobs/retry.ts', 'Wrap `retryJob` in a second try/catch.', ['retryJob'], 14),
39
- ]);
40
- });
41
- afterEach(() => fs.rmSync(repo, { recursive: true, force: true }));
42
- describe('the briefing', () => {
43
- it("gives the files' requirement rules first, then verified lessons, settled points, then guidance, each cited; never a candidate", () => {
44
- const briefing = buildBriefing(repo, { goal: 'retry the partner job with backoff', files: ['src/jobs/retry.ts'] });
45
- expect(briefing.items.map(i => [i.kind, i.requirement ?? false, i.cite])).toEqual([
46
- ['rule', true, 'AGENTS.md'],
47
- ['lesson', false, 'learned in PR #12'],
48
- ['settled', false, 'learned in PR #14'],
49
- ['rule', false, 'AGENTS.md'],
50
- ]);
51
- expect(briefing.items[1].text).toContain('Bound the retry window at both ends');
52
- expect(briefing.items.some(i => i.text.includes('debug level'))).toBe(false); // a candidate is not the team's yet
53
- // A team whose reviewer is shown candidates (review_lessons: all) is briefed with them too.
54
- expect(buildBriefing(repo, { goal: 'retry the partner job with backoff', files: ['src/jobs/retry.ts'], lessons: 'all' }).items.some(i => i.text.includes('debug level'))).toBe(true);
55
- expect(briefing.items.some(i => i.text.includes('integer cents'))).toBe(false); // billing's rule, not this task's folder
56
- // A rule that only shares words with the task, naming none of its paths or identifiers, is not briefed.
57
- write('AGENTS.md', fs.readFileSync(path.join(repo, 'AGENTS.md'), 'utf8') + '\nEvery partner retry job must log its backoff and the partner it retried for, always.\n');
58
- expect(buildBriefing(repo, { goal: 'retry the partner job with backoff', files: ['src/jobs/retry.ts'] }).items.some(i => i.text.includes('log its backoff'))).toBe(false);
59
- const text = briefingText(briefing);
60
- expect(text.split('\n')[1]).toMatch(/^1\. \[must\] Every job in `src\/jobs\/` must take `withLock\(\)`.* \(AGENTS\.md\)$/);
61
- expect(text).toContain('[settled] settled against, do not do or raise it: Wrap `retryJob` in a second try/catch. (learned in PR #14)');
62
- });
63
- it("serves a folder's own rules to a task in that folder, cited with the folder", () => {
64
- const briefing = buildBriefing(repo, { goal: 'charge in cents', files: ['services/billing/charge.ts'] });
65
- expect(briefing.items.map(i => i.cite)).toContain('services/billing/AGENTS.md, for services/billing/');
66
- });
67
- it('never gives more than ten items, and says nothing when nothing applies', () => {
68
- write('AGENTS.md', Array.from({ length: 30 }, (_, i) => `- Every job in \`src/jobs/\` must call \`step${i}()\` before \`retryJob\` reads.\n`).join('\n'));
69
- expect(buildBriefing(repo, { goal: 'retry job', files: ['src/jobs/retry.ts'], limit: 50 }).items).toHaveLength(BRIEFING_MAX_ITEMS);
70
- expect(buildBriefing(repo, { goal: 'retry job', files: ['src/jobs/retry.ts'], limit: 3 }).items).toHaveLength(3);
71
- const nothing = buildBriefing(repo, { goal: 'update the readme wording', files: ['README.md'] });
72
- expect(nothing.items).toEqual([]);
73
- expect(briefingText(nothing)).toBe('');
74
- });
75
- it("reads the task's likely files from the branch's own changes and the goal's words, and the goal from the branch when none is given", () => {
76
- git('checkout', '-qb', 'feat/retry-backoff');
77
- write('src/jobs/retry.ts', 'export async function retryJob() { return 1; }\n');
78
- git('commit', '-qam', 'work');
79
- const briefing = buildBriefing(repo);
80
- expect(briefing.goal).toBe('feat retry backoff');
81
- expect(briefing.files).toEqual(['src/jobs/retry.ts']);
82
- expect(buildBriefing(repo, { goal: 'charge the customer' }).files).toEqual(['src/jobs/retry.ts', 'services/billing/charge.ts']);
83
- });
84
- it("records what was briefed on the task's thread, by id", () => {
85
- git('checkout', '-qb', 'feat/retry');
86
- const briefing = briefTask(repo, { goal: 'retry', files: ['src/jobs/retry.ts'], session: 's1', agent: 'claude' });
87
- const [event] = readThread(repo).events;
88
- expect(event).toMatchObject({ kind: 'brief', session: 's1', agent: 'claude', items: briefing.items.length, ids: briefing.items.map(i => i.id), files: ['src/jobs/retry.ts'] });
89
- });
90
- });
91
- describe("a file's briefing, on the agent's first edit of it", () => {
92
- it("gives at most three items: the file's requirement rules, its lessons and settled points; never guidance or another file's", () => {
93
- const briefing = buildFileBriefing(repo, 'src/jobs/retry.ts');
94
- expect(briefing.items.map(i => [i.kind, i.cite])).toEqual([['rule', 'AGENTS.md'], ['lesson', 'learned in PR #12'], ['settled', 'learned in PR #14']]);
95
- expect(briefing.items.some(i => i.text.includes('fetchWithTimeout'))).toBe(false); // guidance waits for review
96
- expect(fileBriefingText(briefing).split('\n')[0]).toBe('Rigour, before you edit src/jobs/retry.ts: what this team asks of this file.');
97
- expect(buildFileBriefing(repo, 'services/billing/charge.ts').items.map(i => i.cite)).toEqual(['services/billing/AGENTS.md, for services/billing/']);
98
- expect(buildFileBriefing(repo, 'README.md').items).toEqual([]);
99
- expect(fileBriefingText(buildFileBriefing(repo, 'README.md'))).toBe('');
100
- expect(buildFileBriefing(repo, 'src/jobs/retry.ts', { lessons: 'all' }).items.length).toBe(3); // still three, with candidates in play
101
- });
102
- it('records the file it briefed on the thread', () => {
103
- git('checkout', '-qb', 'feat/retry');
104
- briefFile(repo, 'src/jobs/retry.ts', { session: 's9', agent: 'claude' });
105
- expect(readThread(repo).events[0]).toMatchObject({ kind: 'brief', file: 'src/jobs/retry.ts', session: 's9', items: 3, files: ['src/jobs/retry.ts'] });
106
- });
107
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,30 +0,0 @@
1
- import fs from 'fs';
2
- import os from 'os';
3
- import path from 'path';
4
- import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
5
- const writes = vi.hoisted(() => ({ count: 0 }));
6
- vi.mock('../storage/context-telemetry.js', async (importOriginal) => ({
7
- ...(await importOriginal()),
8
- setContextCacheRecord: async () => { writes.count++; },
9
- }));
10
- const { ensureAutomaticIndex, updateAutomaticIndexForFiles } = await import('./automatic-index.js');
11
- let cwd;
12
- beforeEach(() => {
13
- writes.count = 0;
14
- cwd = fs.mkdtempSync(path.join(os.tmpdir(), 'auto-index-'));
15
- fs.mkdirSync(path.join(cwd, 'src'));
16
- fs.writeFileSync(path.join(cwd, 'src/a.ts'), 'export function alpha() { return 1; }\n');
17
- fs.writeFileSync(path.join(cwd, 'src/b.ts'), 'export function beta() { return 2; }\n');
18
- });
19
- afterEach(() => fs.rmSync(cwd, { recursive: true, force: true }));
20
- describe('automatic indexing', () => {
21
- it('writes nothing to the context cache, however many edits it sees', async () => {
22
- await ensureAutomaticIndex(cwd, { backgroundSemantic: false });
23
- for (let edit = 0; edit < 5; edit++) {
24
- fs.writeFileSync(path.join(cwd, 'src/a.ts'), `export function alpha() { return ${edit}; }\n`);
25
- await updateAutomaticIndexForFiles(cwd, ['src/a.ts']);
26
- }
27
- expect(writes.count).toBe(0);
28
- expect(fs.existsSync(path.join(cwd, '.rigour', 'patterns.json'))).toBe(true);
29
- });
30
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,45 +0,0 @@
1
- import fs from 'fs-extra';
2
- import os from 'os';
3
- import path from 'path';
4
- import { afterEach, describe, expect, it } from 'vitest';
5
- import { ensureAutomaticIndex, mergeSemanticEmbeddings, updateAutomaticIndexForFiles } from './automatic-index.js';
6
- describe('automatic incremental index', () => {
7
- const cwd = path.join(os.tmpdir(), `rigour-auto-index-${process.pid}`);
8
- afterEach(() => fs.remove(cwd));
9
- it('builds once and refreshes only changed files and their dependents', async () => {
10
- await fs.outputFile(path.join(cwd, 'src/value.ts'), 'export const value = 1;');
11
- await fs.outputFile(path.join(cwd, 'src/consumer.ts'), "import { value } from './value';\nexport const doubled = value * 2;");
12
- const baseline = await ensureAutomaticIndex(cwd, { backgroundSemantic: false });
13
- const untouched = baseline.files.find(file => file.path === 'src/consumer.ts')?.indexedAt;
14
- await fs.writeFile(path.join(cwd, 'src/value.ts'), 'export const value = 2;');
15
- const result = await updateAutomaticIndexForFiles(cwd, ['src/value.ts']);
16
- expect(result.affectedFiles.sort()).toEqual(['src/consumer.ts', 'src/value.ts']);
17
- expect(result.index.files.find(file => file.path === 'src/consumer.ts')?.indexedAt).not.toBe(untouched);
18
- });
19
- it('ignores changed-file paths outside the repository', async () => {
20
- await fs.outputFile(path.join(cwd, 'src/value.ts'), 'export const value = 1;');
21
- const baseline = await ensureAutomaticIndex(cwd, { backgroundSemantic: false });
22
- const result = await updateAutomaticIndexForFiles(cwd, [path.join(cwd, '..', 'outside.ts')]);
23
- expect(result.affectedFiles).toEqual([]);
24
- expect(result.index.patterns).toEqual(baseline.patterns);
25
- });
26
- it('merges background embeddings onto the latest structural snapshot', () => {
27
- const pattern = (id, file, embedding) => ({
28
- id, file, embedding, type: 'function', name: id, line: 1, endLine: 1,
29
- signature: '', description: '', keywords: [], hash: id, exported: true,
30
- usageCount: 0, indexedAt: '2026-09-10T00:00:00.000Z',
31
- });
32
- const makeIndex = (patterns) => ({
33
- version: '1.0.0', lastUpdated: '2026-09-10T00:00:00.000Z', rootDir: cwd,
34
- patterns,
35
- files: patterns.map(entry => ({ path: entry.file, hash: entry.hash, patternCount: 1, indexedAt: entry.indexedAt })),
36
- stats: { totalPatterns: patterns.length, totalFiles: patterns.length, byType: { function: patterns.length }, indexDurationMs: 1 },
37
- });
38
- const latest = makeIndex([pattern('changed', 'src/changed.ts'), pattern('new', 'src/new.ts')]);
39
- const enriched = makeIndex([pattern('changed', 'src/old.ts', [0.1, 0.2]), pattern('deleted', 'src/deleted.ts', [0.3])]);
40
- const merged = mergeSemanticEmbeddings(latest, enriched);
41
- expect(merged.patterns.map(entry => entry.id)).toEqual(['changed', 'new']);
42
- expect(merged.patterns[0].file).toBe('src/changed.ts');
43
- expect(merged.patterns[0].embedding).toEqual([0.1, 0.2]);
44
- });
45
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,99 +0,0 @@
1
- import { describe, it, expect, beforeEach, vi } from 'vitest';
2
- import path from 'path';
3
- import os from 'os';
4
- import fs from 'fs-extra';
5
- vi.mock('./db.js', () => ({
6
- isSQLiteAvailable: () => false,
7
- openDatabase: async () => null,
8
- DB_PATH: '/tmp/rigour-test.db',
9
- RIGOUR_DIR: '/tmp/.rigour',
10
- }));
11
- import { getSemanticQueryCache, setSemanticQueryCache, findRelatedSemanticQueryCache, queryTokenOverlap, distinctiveTokenAgreement, filterExistingEditScope, getTaskCheckpointCache, setTaskCheckpointCache, hashContent, normalizeQuery } from './cache-engine.js';
12
- describe('Context cache engine', () => {
13
- const testCwd = path.join(os.tmpdir(), `rigour-cache-test-${Date.now()}`);
14
- beforeEach(async () => {
15
- await fs.ensureDir(testCwd);
16
- });
17
- it('should calculate consistent SHA-256 hashes', () => {
18
- const hash1 = hashContent('const x = 1;');
19
- const hash2 = hashContent('const x = 1;');
20
- const hash3 = hashContent('const x = 2;');
21
- expect(hash1).toBe(hash2);
22
- expect(hash1).not.toBe(hash3);
23
- expect(hash1.length).toBe(16);
24
- });
25
- it('should normalize intent queries correctly', () => {
26
- expect(normalizeQuery(' Add priority to task!! ')).toBe('add priority to task');
27
- expect(normalizeQuery('Task SHOULD Support Priority.')).toBe('task should support priority');
28
- });
29
- it('Layer 3: should store and retrieve semantic query scope', async () => {
30
- const entry = {
31
- query: 'task priority persistence',
32
- resolvedOwner: 'task-team',
33
- editScope: ['services/task.ts'],
34
- validationScope: ['npm test'],
35
- evidence: ['AST match'],
36
- commitSha: 'commit-99',
37
- confidence: 0.95
38
- };
39
- await setSemanticQueryCache('add priority to task', 'commit-99', entry, testCwd);
40
- const retrieved = await getSemanticQueryCache('add priority to task', 'commit-99', testCwd);
41
- expect(retrieved).not.toBeNull();
42
- expect(retrieved?.resolvedOwner).toBe('task-team');
43
- expect(retrieved?.editScope).toContain('services/task.ts');
44
- });
45
- it('Layer 4: should store and retrieve subagent task checkpoint packet', async () => {
46
- const packet = {
47
- taskId: 'CTP-142',
48
- agentId: 'CTP-142-task',
49
- phase: 'implementation',
50
- component: 'services/task',
51
- changedFiles: ['services/task.ts'],
52
- decisions: ['Added priority field'],
53
- validation: ['npm test passed'],
54
- remainingWork: ['Add integration test'],
55
- risks: ['Migration needed']
56
- };
57
- await setTaskCheckpointCache(packet, 126000, testCwd);
58
- const retrieved = await getTaskCheckpointCache('CTP-142', 'CTP-142-task', 'implementation', testCwd);
59
- expect(retrieved).not.toBeNull();
60
- expect(retrieved?.taskId).toBe('CTP-142');
61
- expect(retrieved?.decisions).toContain('Added priority field');
62
- });
63
- it('Layer 3: finds related semantic queries at same commit for partial reuse', async () => {
64
- expect(queryTokenOverlap('task priority persistence service', 'task priority persistence service layer')).toBeGreaterThan(0.7);
65
- expect(distinctiveTokenAgreement('task service', 'payment service')).toBeLessThan(0.67);
66
- await setSemanticQueryCache('task priority persistence service', 'commit-rel', {
67
- query: 'task priority persistence service',
68
- resolvedOwner: 'task-team',
69
- editScope: ['services/task.ts'],
70
- validationScope: ['npm test'],
71
- evidence: ['related'],
72
- commitSha: 'commit-rel',
73
- confidence: 0.9,
74
- }, testCwd);
75
- const related = await findRelatedSemanticQueryCache('task priority persistence service layer', 'commit-rel', testCwd);
76
- expect(related).not.toBeNull();
77
- expect(related?.entry.editScope).toContain('services/task.ts');
78
- // Same generic stem, different distinctive noun → reject
79
- await setSemanticQueryCache('payment service billing', 'commit-rel', {
80
- query: 'payment service billing',
81
- resolvedOwner: 'pay',
82
- editScope: ['services/pay.ts'],
83
- validationScope: [],
84
- evidence: [],
85
- commitSha: 'commit-rel',
86
- confidence: 0.9,
87
- }, testCwd);
88
- const crossDomain = await findRelatedSemanticQueryCache('task service billing', 'commit-rel', testCwd);
89
- expect(crossDomain).toBeNull();
90
- const otherCommit = await findRelatedSemanticQueryCache('task priority persistence service layer', 'commit-other', testCwd);
91
- expect(otherCommit).toBeNull();
92
- });
93
- it('filters missing edit-scope files for quality', async () => {
94
- await fs.writeFile(path.join(testCwd, 'alive.ts'), 'export const ok = 1;\n');
95
- const result = await filterExistingEditScope(['alive.ts', 'gone.ts'], testCwd);
96
- expect(result.valid).toEqual(['alive.ts']);
97
- expect(result.missing).toEqual(['gone.ts']);
98
- });
99
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,13 +0,0 @@
1
- import { describe, expect, it } from 'vitest';
2
- import { affectedDependents } from './dependency-graph.js';
3
- describe('affectedDependents', () => {
4
- it('includes direct and transitive consumers', () => {
5
- const affected = affectedDependents({
6
- version: 1,
7
- generatedAt: '2026-09-10T00:00:00Z',
8
- nodes: ['a.ts', 'b.ts', 'c.ts'],
9
- edges: [{ from: 'b.ts', to: 'a.ts' }, { from: 'c.ts', to: 'b.ts' }],
10
- }, ['a.ts']);
11
- expect(new Set(affected)).toEqual(new Set(['a.ts', 'b.ts', 'c.ts']));
12
- });
13
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,26 +0,0 @@
1
- import fs from 'fs';
2
- import os from 'os';
3
- import path from 'path';
4
- import { afterEach, beforeEach, describe, expect, it } from 'vitest';
5
- import { getAutomaticIndexStatus, recordIndexChoice } from './automatic-index.js';
6
- let cwd;
7
- beforeEach(() => { cwd = fs.mkdtempSync(path.join(os.tmpdir(), 'index-status-')); });
8
- afterEach(() => fs.rmSync(cwd, { recursive: true, force: true }));
9
- const index = (embedded) => ({
10
- version: '1.0.0', lastUpdated: '', rootDir: cwd, files: [],
11
- patterns: [{ id: 'a', type: 'function', name: 'a', file: 'a.ts', line: 1, endLine: 1, signature: '', description: '', keywords: [], hash: 'a', exported: true, usageCount: 0, indexedAt: '', ...(embedded ? { embedding: [0.1] } : {}) }],
12
- stats: { totalPatterns: 1, totalFiles: 1, byType: {}, indexDurationMs: 0 },
13
- });
14
- describe('semantic index status', () => {
15
- it('treats no status yet as warming, not as an opt-out', async () => {
16
- expect((await getAutomaticIndexStatus(cwd)).semantic).toBe('warming');
17
- });
18
- it('records what an explicit index chose, so automatic indexing and Studio agree', async () => {
19
- await recordIndexChoice(cwd, index(false), false);
20
- expect((await getAutomaticIndexStatus(cwd)).semantic).toBe('disabled');
21
- await recordIndexChoice(cwd, index(true), true);
22
- expect((await getAutomaticIndexStatus(cwd)).semantic).toBe('ready');
23
- await recordIndexChoice(cwd, index(false), true);
24
- expect((await getAutomaticIndexStatus(cwd)).semantic).toBe('degraded');
25
- });
26
- });
@@ -1 +0,0 @@
1
- export {};