@isaacriehm/cairn-core 0.6.0 → 0.7.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 (431) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/align-undo/undo.js +2 -2
  3. package/dist/align-undo/undo.js.map +1 -1
  4. package/dist/attention/bulk-accept.js +104 -55
  5. package/dist/attention/bulk-accept.js.map +1 -1
  6. package/dist/attention/dedup.js +23 -10
  7. package/dist/attention/dedup.js.map +1 -1
  8. package/dist/attention/restore.js +2 -2
  9. package/dist/attention/restore.js.map +1 -1
  10. package/dist/attention/scoring.js +1 -1
  11. package/dist/attention/scoring.js.map +1 -1
  12. package/dist/attention/serve/api.d.ts +1 -0
  13. package/dist/attention/serve/api.js +130 -77
  14. package/dist/attention/serve/api.js.map +1 -1
  15. package/dist/attention/serve/index.d.ts +1 -0
  16. package/dist/attention/serve/index.js +21 -7
  17. package/dist/attention/serve/index.js.map +1 -1
  18. package/dist/attention/source-strip.js +41 -46
  19. package/dist/attention/source-strip.js.map +1 -1
  20. package/dist/claude/cache.d.ts +10 -19
  21. package/dist/claude/cache.js +0 -0
  22. package/dist/claude/cache.js.map +1 -1
  23. package/dist/claude/runner.d.ts +4 -6
  24. package/dist/claude/runner.js +242 -203
  25. package/dist/claude/runner.js.map +1 -1
  26. package/dist/claude/types.d.ts +5 -5
  27. package/dist/context/handoff-builder.d.ts +28 -4
  28. package/dist/context/handoff-builder.js +75 -157
  29. package/dist/context/handoff-builder.js.map +1 -1
  30. package/dist/context/spec-delta.js +61 -9
  31. package/dist/context/spec-delta.js.map +1 -1
  32. package/dist/context/task-summary.js +5 -1
  33. package/dist/context/task-summary.js.map +1 -1
  34. package/dist/decision-capture/id.js +1 -1
  35. package/dist/decision-capture/id.js.map +1 -1
  36. package/dist/doctor/index.d.ts +9 -11
  37. package/dist/doctor/index.js +118 -175
  38. package/dist/doctor/index.js.map +1 -1
  39. package/dist/drain/drain.d.ts +1 -1
  40. package/dist/drain/drain.js +16 -16
  41. package/dist/drain/drain.js.map +1 -1
  42. package/dist/drain/index.d.ts +1 -1
  43. package/dist/drain/index.js +1 -1
  44. package/dist/events/reader.d.ts +9 -10
  45. package/dist/events/reader.js +46 -57
  46. package/dist/events/reader.js.map +1 -1
  47. package/dist/events/writer.js +1 -1
  48. package/dist/events/writer.js.map +1 -1
  49. package/dist/fix-align/index.d.ts +1 -1
  50. package/dist/fix-align/index.js +1 -1
  51. package/dist/fix-align/run.d.ts +1 -1
  52. package/dist/fix-align/run.js +4 -3
  53. package/dist/fix-align/run.js.map +1 -1
  54. package/dist/fix-align/sentinel.d.ts +1 -2
  55. package/dist/fix-align/sentinel.js +3 -4
  56. package/dist/fix-align/sentinel.js.map +1 -1
  57. package/dist/gc/apply.js +1 -1
  58. package/dist/gc/apply.js.map +1 -1
  59. package/dist/gc/attested-commits.d.ts +19 -0
  60. package/dist/gc/attested-commits.js +48 -0
  61. package/dist/gc/attested-commits.js.map +1 -0
  62. package/dist/gc/canary.d.ts +11 -21
  63. package/dist/gc/canary.js +18 -24
  64. package/dist/gc/canary.js.map +1 -1
  65. package/dist/gc/citation-integrity.d.ts +11 -14
  66. package/dist/gc/citation-integrity.js +124 -125
  67. package/dist/gc/citation-integrity.js.map +1 -1
  68. package/dist/gc/classify.d.ts +1 -1
  69. package/dist/gc/classify.js +2 -2
  70. package/dist/gc/classify.js.map +1 -1
  71. package/dist/gc/completion-integrity.d.ts +6 -7
  72. package/dist/gc/completion-integrity.js +45 -53
  73. package/dist/gc/completion-integrity.js.map +1 -1
  74. package/dist/gc/doc-gardening.js +1 -9
  75. package/dist/gc/doc-gardening.js.map +1 -1
  76. package/dist/gc/frontmatter.js +2 -2
  77. package/dist/gc/frontmatter.js.map +1 -1
  78. package/dist/gc/index.d.ts +7 -6
  79. package/dist/gc/index.js +3 -2
  80. package/dist/gc/index.js.map +1 -1
  81. package/dist/gc/quality-update.d.ts +6 -10
  82. package/dist/gc/quality-update.js +12 -15
  83. package/dist/gc/quality-update.js.map +1 -1
  84. package/dist/gc/scope-coverage.js +1 -1
  85. package/dist/gc/scope-coverage.js.map +1 -1
  86. package/dist/gc/stub-hits.d.ts +7 -25
  87. package/dist/gc/stub-hits.js +14 -40
  88. package/dist/gc/stub-hits.js.map +1 -1
  89. package/dist/gc/sweep.js +15 -6
  90. package/dist/gc/sweep.js.map +1 -1
  91. package/dist/gc/types.d.ts +5 -5
  92. package/dist/gc/types.js +2 -2
  93. package/dist/gc/walk-source.js +8 -28
  94. package/dist/gc/walk-source.js.map +1 -1
  95. package/dist/hooks/defer.d.ts +9 -20
  96. package/dist/hooks/defer.js +10 -27
  97. package/dist/hooks/defer.js.map +1 -1
  98. package/dist/hooks/post-tool-use/allowlist-reader.d.ts +2 -1
  99. package/dist/hooks/post-tool-use/allowlist-reader.js +49 -34
  100. package/dist/hooks/post-tool-use/allowlist-reader.js.map +1 -1
  101. package/dist/hooks/post-tool-use/index.d.ts +3 -4
  102. package/dist/hooks/post-tool-use/index.js +3 -3
  103. package/dist/hooks/post-tool-use/index.js.map +1 -1
  104. package/dist/hooks/post-tool-use/legend-builder.d.ts +11 -2
  105. package/dist/hooks/post-tool-use/legend-builder.js +27 -2
  106. package/dist/hooks/post-tool-use/legend-builder.js.map +1 -1
  107. package/dist/hooks/post-tool-use/post-write.d.ts +8 -0
  108. package/dist/hooks/post-tool-use/post-write.js +112 -0
  109. package/dist/hooks/post-tool-use/post-write.js.map +1 -0
  110. package/dist/hooks/post-tool-use/read-enricher.d.ts +10 -5
  111. package/dist/hooks/post-tool-use/read-enricher.js +114 -149
  112. package/dist/hooks/post-tool-use/read-enricher.js.map +1 -1
  113. package/dist/hooks/post-tool-use/sot-align.d.ts +12 -0
  114. package/dist/hooks/post-tool-use/sot-align.js +73 -49
  115. package/dist/hooks/post-tool-use/sot-align.js.map +1 -1
  116. package/dist/hooks/post-tool-use/write-guardian.d.ts +40 -8
  117. package/dist/hooks/post-tool-use/write-guardian.js +202 -254
  118. package/dist/hooks/post-tool-use/write-guardian.js.map +1 -1
  119. package/dist/hooks/pre-commit/sot-align-precommit.js +2 -2
  120. package/dist/hooks/pre-commit/sot-align-precommit.js.map +1 -1
  121. package/dist/hooks/runners/index.d.ts +2 -2
  122. package/dist/hooks/runners/index.js +1 -1
  123. package/dist/hooks/runners/index.js.map +1 -1
  124. package/dist/hooks/runners/payload.d.ts +34 -19
  125. package/dist/hooks/runners/payload.js +47 -44
  126. package/dist/hooks/runners/payload.js.map +1 -1
  127. package/dist/hooks/runners/session-end.js +12 -11
  128. package/dist/hooks/runners/session-end.js.map +1 -1
  129. package/dist/hooks/runners/session-start.d.ts +4 -2
  130. package/dist/hooks/runners/session-start.js +88 -261
  131. package/dist/hooks/runners/session-start.js.map +1 -1
  132. package/dist/hooks/runners/stop.js +27 -8
  133. package/dist/hooks/runners/stop.js.map +1 -1
  134. package/dist/hooks/runners/user-prompt-submit.js +7 -1
  135. package/dist/hooks/runners/user-prompt-submit.js.map +1 -1
  136. package/dist/hooks/sot-align-common.d.ts +1 -2
  137. package/dist/hooks/sot-align-common.js +2 -2
  138. package/dist/hooks/sot-align-common.js.map +1 -1
  139. package/dist/index.d.ts +1 -1
  140. package/dist/index.js +12 -3
  141. package/dist/index.js.map +1 -1
  142. package/dist/init/baseline-audit.d.ts +14 -58
  143. package/dist/init/baseline-audit.js +92 -320
  144. package/dist/init/baseline-audit.js.map +1 -1
  145. package/dist/init/brand-derive.d.ts +11 -15
  146. package/dist/init/brand-derive.js +21 -46
  147. package/dist/init/brand-derive.js.map +1 -1
  148. package/dist/init/brand-setup.d.ts +1 -1
  149. package/dist/init/brand-setup.js +1 -1
  150. package/dist/init/detect.d.ts +25 -6
  151. package/dist/init/detect.js +107 -136
  152. package/dist/init/detect.js.map +1 -1
  153. package/dist/init/index.d.ts +4 -4
  154. package/dist/init/index.js +2 -2
  155. package/dist/init/index.js.map +1 -1
  156. package/dist/init/ingest-docs.d.ts +83 -23
  157. package/dist/init/ingest-docs.js +648 -136
  158. package/dist/init/ingest-docs.js.map +1 -1
  159. package/dist/init/init.d.ts +29 -20
  160. package/dist/init/init.js +132 -290
  161. package/dist/init/init.js.map +1 -1
  162. package/dist/init/mapper-merge.js +1 -1
  163. package/dist/init/mapper-merge.js.map +1 -1
  164. package/dist/init/mapper-parallel.d.ts +1 -1
  165. package/dist/init/mapper-parallel.js +10 -1
  166. package/dist/init/mapper-parallel.js.map +1 -1
  167. package/dist/init/mapper.js +1 -1
  168. package/dist/init/mapper.js.map +1 -1
  169. package/dist/init/multi-dev/install.d.ts +5 -5
  170. package/dist/init/multi-dev/install.js +4 -4
  171. package/dist/init/overlay.js +1 -0
  172. package/dist/init/overlay.js.map +1 -1
  173. package/dist/init/phases/1-detect.js +1 -1
  174. package/dist/init/phases/1-detect.js.map +1 -1
  175. package/dist/init/phases/{7c-rules-merge.d.ts → 10-rules-merge.d.ts} +2 -2
  176. package/dist/init/phases/{7c-rules-merge.js → 10-rules-merge.js} +6 -12
  177. package/dist/init/phases/10-rules-merge.js.map +1 -0
  178. package/dist/init/phases/11-baseline.d.ts +7 -0
  179. package/dist/init/phases/{8-baseline.js → 11-baseline.js} +5 -9
  180. package/dist/init/phases/11-baseline.js.map +1 -0
  181. package/dist/init/phases/12-strip.d.ts +10 -0
  182. package/dist/init/phases/{10-strip.js → 12-strip.js} +10 -14
  183. package/dist/init/phases/12-strip.js.map +1 -0
  184. package/dist/init/phases/{12-multidev.d.ts → 13-multidev.d.ts} +2 -2
  185. package/dist/init/phases/{12-multidev.js → 13-multidev.js} +4 -4
  186. package/dist/init/phases/{12-multidev.js.map → 13-multidev.js.map} +1 -1
  187. package/dist/init/phases/3-mapper.d.ts +1 -1
  188. package/dist/init/phases/3-mapper.js +2 -2
  189. package/dist/init/phases/3-mapper.js.map +1 -1
  190. package/dist/init/phases/{3b-seed.d.ts → 4-seed.d.ts} +2 -2
  191. package/dist/init/phases/{3b-seed.js → 4-seed.js} +7 -7
  192. package/dist/init/phases/4-seed.js.map +1 -0
  193. package/dist/init/phases/{4-pilot.d.ts → 5-pilot.d.ts} +2 -2
  194. package/dist/init/phases/{4-pilot.js → 5-pilot.js} +9 -9
  195. package/dist/init/phases/{4-pilot.js.map → 5-pilot.js.map} +1 -1
  196. package/dist/init/phases/{5-brand.d.ts → 6-brand.d.ts} +2 -7
  197. package/dist/init/phases/{5-brand.js → 6-brand.js} +6 -14
  198. package/dist/init/phases/6-brand.js.map +1 -0
  199. package/dist/init/phases/{5b-topic-index.d.ts → 7-topic-index.d.ts} +2 -11
  200. package/dist/init/phases/{5b-topic-index.js → 7-topic-index.js} +9 -18
  201. package/dist/init/phases/7-topic-index.js.map +1 -0
  202. package/dist/init/phases/8-docs-ingest.d.ts +10 -0
  203. package/dist/init/phases/{6-docs-ingest.js → 8-docs-ingest.js} +12 -14
  204. package/dist/init/phases/8-docs-ingest.js.map +1 -0
  205. package/dist/init/phases/9-source-comments.d.ts +6 -0
  206. package/dist/init/phases/{7b-source-comments.js → 9-source-comments.js} +7 -26
  207. package/dist/init/phases/9-source-comments.js.map +1 -0
  208. package/dist/init/phases/index.d.ts +12 -12
  209. package/dist/init/phases/index.js +11 -11
  210. package/dist/init/phases/index.js.map +1 -1
  211. package/dist/init/phases/{parallel-678.d.ts → parallel-8910.d.ts} +7 -8
  212. package/dist/init/phases/{parallel-678.js → parallel-8910.js} +34 -46
  213. package/dist/init/phases/parallel-8910.js.map +1 -0
  214. package/dist/init/phases/source-comments-output-io.d.ts +3 -3
  215. package/dist/init/phases/source-comments-output-io.js +3 -3
  216. package/dist/init/phases/types.d.ts +1 -1
  217. package/dist/init/phases/types.js +10 -10
  218. package/dist/init/phases/types.js.map +1 -1
  219. package/dist/init/rules-merge/discover.d.ts +2 -2
  220. package/dist/init/rules-merge/discover.js +28 -43
  221. package/dist/init/rules-merge/discover.js.map +1 -1
  222. package/dist/init/rules-merge/ingest.d.ts +6 -6
  223. package/dist/init/rules-merge/ingest.js +9 -10
  224. package/dist/init/rules-merge/ingest.js.map +1 -1
  225. package/dist/init/rules-merge/keep-markers.d.ts +1 -1
  226. package/dist/init/rules-merge/keep-markers.js +1 -1
  227. package/dist/init/rules-merge/regenerate.d.ts +3 -3
  228. package/dist/init/rules-merge/regenerate.js +3 -3
  229. package/dist/init/seed.js +17 -24
  230. package/dist/init/seed.js.map +1 -1
  231. package/dist/init/sot-emit.d.ts +48 -8
  232. package/dist/init/sot-emit.js +88 -10
  233. package/dist/init/sot-emit.js.map +1 -1
  234. package/dist/init/source-comments/classify.d.ts +2 -2
  235. package/dist/init/source-comments/classify.js +9 -1
  236. package/dist/init/source-comments/classify.js.map +1 -1
  237. package/dist/init/source-comments/index.d.ts +1 -1
  238. package/dist/init/source-comments/index.js.map +1 -1
  239. package/dist/init/source-comments/ingest.d.ts +2 -2
  240. package/dist/init/source-comments/ingest.js +110 -12
  241. package/dist/init/source-comments/ingest.js.map +1 -1
  242. package/dist/init/source-comments/strip-replace.js +3 -2
  243. package/dist/init/source-comments/strip-replace.js.map +1 -1
  244. package/dist/init/source-comments/walker.d.ts +3 -26
  245. package/dist/init/source-comments/walker.js +18 -30
  246. package/dist/init/source-comments/walker.js.map +1 -1
  247. package/dist/init/topic-index/index.d.ts +15 -1
  248. package/dist/init/topic-index/index.js +84 -5
  249. package/dist/init/topic-index/index.js.map +1 -1
  250. package/dist/init/topic-index/judge.d.ts +5 -9
  251. package/dist/init/topic-index/judge.js +25 -17
  252. package/dist/init/topic-index/judge.js.map +1 -1
  253. package/dist/init/topic-index/resolve.d.ts +23 -3
  254. package/dist/init/topic-index/resolve.js +102 -16
  255. package/dist/init/topic-index/resolve.js.map +1 -1
  256. package/dist/init/topic-index/walk.d.ts +36 -4
  257. package/dist/init/topic-index/walk.js +78 -12
  258. package/dist/init/topic-index/walk.js.map +1 -1
  259. package/dist/lock.js +4 -1
  260. package/dist/lock.js.map +1 -1
  261. package/dist/logger.js +3 -0
  262. package/dist/logger.js.map +1 -1
  263. package/dist/mcp/history/summarizer.js +6 -1
  264. package/dist/mcp/history/summarizer.js.map +1 -1
  265. package/dist/mcp/history/walker.js +1 -1
  266. package/dist/mcp/history/walker.js.map +1 -1
  267. package/dist/mcp/path-allowlist.js +1 -1
  268. package/dist/mcp/path-allowlist.js.map +1 -1
  269. package/dist/mcp/schemas.d.ts +47 -21
  270. package/dist/mcp/schemas.js +38 -9
  271. package/dist/mcp/schemas.js.map +1 -1
  272. package/dist/mcp/server.js +10 -0
  273. package/dist/mcp/server.js.map +1 -1
  274. package/dist/mcp/tools/archive.js +1 -1
  275. package/dist/mcp/tools/archive.js.map +1 -1
  276. package/dist/mcp/tools/attention-wait.js +12 -2
  277. package/dist/mcp/tools/attention-wait.js.map +1 -1
  278. package/dist/mcp/tools/bulk-accept-attention.js +29 -30
  279. package/dist/mcp/tools/bulk-accept-attention.js.map +1 -1
  280. package/dist/mcp/tools/canonical-for-topic.js +37 -15
  281. package/dist/mcp/tools/canonical-for-topic.js.map +1 -1
  282. package/dist/mcp/tools/decision-get.js +2 -2
  283. package/dist/mcp/tools/decision-get.js.map +1 -1
  284. package/dist/mcp/tools/decisions-for-symbol.js +2 -2
  285. package/dist/mcp/tools/decisions-for-symbol.js.map +1 -1
  286. package/dist/mcp/tools/get-full.js +1 -1
  287. package/dist/mcp/tools/get-full.js.map +1 -1
  288. package/dist/mcp/tools/ground-get.js +1 -1
  289. package/dist/mcp/tools/ground-get.js.map +1 -1
  290. package/dist/mcp/tools/in-scope.d.ts +8 -0
  291. package/dist/mcp/tools/in-scope.js +125 -0
  292. package/dist/mcp/tools/in-scope.js.map +1 -0
  293. package/dist/mcp/tools/index.js +11 -6
  294. package/dist/mcp/tools/index.js.map +1 -1
  295. package/dist/mcp/tools/init-phases.d.ts +3 -2
  296. package/dist/mcp/tools/init-phases.js +125 -124
  297. package/dist/mcp/tools/init-phases.js.map +1 -1
  298. package/dist/mcp/tools/invariant-get.js +2 -2
  299. package/dist/mcp/tools/invariant-get.js.map +1 -1
  300. package/dist/mcp/tools/record-decision.d.ts +4 -3
  301. package/dist/mcp/tools/record-decision.js +111 -36
  302. package/dist/mcp/tools/record-decision.js.map +1 -1
  303. package/dist/mcp/tools/reject-candidate.d.ts +24 -0
  304. package/dist/mcp/tools/reject-candidate.js +71 -0
  305. package/dist/mcp/tools/reject-candidate.js.map +1 -0
  306. package/dist/mcp/tools/resolve-attention.d.ts +5 -18
  307. package/dist/mcp/tools/resolve-attention.js +58 -158
  308. package/dist/mcp/tools/resolve-attention.js.map +1 -1
  309. package/dist/mcp/tools/search-candidates.d.ts +20 -0
  310. package/dist/mcp/tools/search-candidates.js +93 -0
  311. package/dist/mcp/tools/search-candidates.js.map +1 -0
  312. package/dist/mcp/tools/search.js +5 -4
  313. package/dist/mcp/tools/search.js.map +1 -1
  314. package/dist/mcp/tools/supersedes-chain.js +2 -2
  315. package/dist/mcp/tools/supersedes-chain.js.map +1 -1
  316. package/dist/mcp/tools/task-create.d.ts +1 -0
  317. package/dist/mcp/tools/task-create.js +2 -0
  318. package/dist/mcp/tools/task-create.js.map +1 -1
  319. package/dist/mcp/tools/timeline.js +1 -1
  320. package/dist/mcp/tools/timeline.js.map +1 -1
  321. package/dist/mcp/tools/types.d.ts +1 -0
  322. package/dist/mcp/tools/types.js +9 -1
  323. package/dist/mcp/tools/types.js.map +1 -1
  324. package/dist/sensors/attestation.d.ts +1 -1
  325. package/dist/sensors/attestation.js +2 -2
  326. package/dist/sensors/attestation.js.map +1 -1
  327. package/dist/sensors/catalog.d.ts +26 -28
  328. package/dist/sensors/catalog.js +79 -81
  329. package/dist/sensors/catalog.js.map +1 -1
  330. package/dist/sensors/decisions.d.ts +1 -1
  331. package/dist/sensors/decisions.js +15 -14
  332. package/dist/sensors/decisions.js.map +1 -1
  333. package/dist/sensors/diff.js +46 -22
  334. package/dist/sensors/diff.js.map +1 -1
  335. package/dist/sensors/runner.d.ts +2 -2
  336. package/dist/sensors/runner.js +3 -3
  337. package/dist/sensors/shell.d.ts +4 -0
  338. package/dist/sensors/shell.js +16 -0
  339. package/dist/sensors/shell.js.map +1 -0
  340. package/dist/sensors/structural.d.ts +3 -2
  341. package/dist/sensors/structural.js +3 -11
  342. package/dist/sensors/structural.js.map +1 -1
  343. package/dist/sensors/stub-catalog.d.ts +2 -1
  344. package/dist/sensors/stub-catalog.js +2 -9
  345. package/dist/sensors/stub-catalog.js.map +1 -1
  346. package/dist/sensors/types.d.ts +3 -4
  347. package/dist/sensors/types.js +1 -2
  348. package/dist/sensors/types.js.map +1 -1
  349. package/dist/session-start/build.js +1 -1
  350. package/dist/session-start/build.js.map +1 -1
  351. package/dist/status-line/event-queue.js +1 -1
  352. package/dist/status-line/index.d.ts +1 -1
  353. package/package.json +3 -2
  354. package/templates/.cairn/config/sensors.yaml +8 -8
  355. package/templates/attention-ui/app.js +101 -39
  356. package/dist/fs.d.ts +0 -5
  357. package/dist/fs.js +0 -11
  358. package/dist/fs.js.map +0 -1
  359. package/dist/ground/alignment-pending.d.ts +0 -28
  360. package/dist/ground/alignment-pending.js +0 -83
  361. package/dist/ground/alignment-pending.js.map +0 -1
  362. package/dist/ground/anchor-map.d.ts +0 -14
  363. package/dist/ground/anchor-map.js +0 -56
  364. package/dist/ground/anchor-map.js.map +0 -1
  365. package/dist/ground/drift.d.ts +0 -8
  366. package/dist/ground/drift.js +0 -23
  367. package/dist/ground/drift.js.map +0 -1
  368. package/dist/ground/frontmatter.d.ts +0 -32
  369. package/dist/ground/frontmatter.js +0 -77
  370. package/dist/ground/frontmatter.js.map +0 -1
  371. package/dist/ground/glob.d.ts +0 -10
  372. package/dist/ground/glob.js +0 -46
  373. package/dist/ground/glob.js.map +0 -1
  374. package/dist/ground/index.d.ts +0 -23
  375. package/dist/ground/index.js +0 -17
  376. package/dist/ground/index.js.map +0 -1
  377. package/dist/ground/ledgers.d.ts +0 -14
  378. package/dist/ground/ledgers.js +0 -105
  379. package/dist/ground/ledgers.js.map +0 -1
  380. package/dist/ground/manifest.d.ts +0 -10
  381. package/dist/ground/manifest.js +0 -84
  382. package/dist/ground/manifest.js.map +0 -1
  383. package/dist/ground/paths.d.ts +0 -41
  384. package/dist/ground/paths.js +0 -103
  385. package/dist/ground/paths.js.map +0 -1
  386. package/dist/ground/quality-grades.d.ts +0 -11
  387. package/dist/ground/quality-grades.js +0 -100
  388. package/dist/ground/quality-grades.js.map +0 -1
  389. package/dist/ground/schemas.d.ts +0 -502
  390. package/dist/ground/schemas.js +0 -318
  391. package/dist/ground/schemas.js.map +0 -1
  392. package/dist/ground/scope-index.d.ts +0 -96
  393. package/dist/ground/scope-index.js +0 -290
  394. package/dist/ground/scope-index.js.map +0 -1
  395. package/dist/ground/slug.d.ts +0 -60
  396. package/dist/ground/slug.js +0 -103
  397. package/dist/ground/slug.js.map +0 -1
  398. package/dist/ground/sot-bindings.d.ts +0 -14
  399. package/dist/ground/sot-bindings.js +0 -79
  400. package/dist/ground/sot-bindings.js.map +0 -1
  401. package/dist/ground/sot-cache.d.ts +0 -18
  402. package/dist/ground/sot-cache.js +0 -62
  403. package/dist/ground/sot-cache.js.map +0 -1
  404. package/dist/ground/topic-index.d.ts +0 -27
  405. package/dist/ground/topic-index.js +0 -82
  406. package/dist/ground/topic-index.js.map +0 -1
  407. package/dist/ground/walk.d.ts +0 -7
  408. package/dist/ground/walk.js +0 -53
  409. package/dist/ground/walk.js.map +0 -1
  410. package/dist/hooks/post-tool-use/ledger-cache.d.ts +0 -40
  411. package/dist/hooks/post-tool-use/ledger-cache.js +0 -290
  412. package/dist/hooks/post-tool-use/ledger-cache.js.map +0 -1
  413. package/dist/init/phases/10-strip.d.ts +0 -11
  414. package/dist/init/phases/10-strip.js.map +0 -1
  415. package/dist/init/phases/3b-seed.js.map +0 -1
  416. package/dist/init/phases/5-brand.js.map +0 -1
  417. package/dist/init/phases/5b-topic-index.js.map +0 -1
  418. package/dist/init/phases/6-docs-ingest.d.ts +0 -10
  419. package/dist/init/phases/6-docs-ingest.js.map +0 -1
  420. package/dist/init/phases/7b-source-comments.d.ts +0 -15
  421. package/dist/init/phases/7b-source-comments.js.map +0 -1
  422. package/dist/init/phases/7c-rules-merge.js.map +0 -1
  423. package/dist/init/phases/8-baseline.d.ts +0 -10
  424. package/dist/init/phases/8-baseline.js.map +0 -1
  425. package/dist/init/phases/parallel-678.js.map +0 -1
  426. package/dist/mcp/tools/decisions-in-scope.d.ts +0 -7
  427. package/dist/mcp/tools/decisions-in-scope.js +0 -66
  428. package/dist/mcp/tools/decisions-in-scope.js.map +0 -1
  429. package/dist/mcp/tools/invariants-in-scope.d.ts +0 -7
  430. package/dist/mcp/tools/invariants-in-scope.js +0 -81
  431. package/dist/mcp/tools/invariants-in-scope.js.map +0 -1
@@ -1,290 +0,0 @@
1
- /**
2
- * Scope index — forward map from every file path in the repo to the decisions
3
- * and invariants that apply to that file.
4
- *
5
- * Built at init by the Tier-2 mapper LLM, maintained by the GC sweep + the
6
- * MCP record-decision tool when scope edits land. Read by the read-enricher
7
- * / write-guardian hooks (via cached accessor in
8
- * `hooks/post-tool-use/ledger-cache.ts`) and by the GC scope-coverage pass.
9
- *
10
- * Spec: docs/FILESYSTEM_LAYOUT.md §2.1.
11
- */
12
- import { execFileSync } from "node:child_process";
13
- import { existsSync, readFileSync } from "node:fs";
14
- import { join } from "node:path";
15
- import { writeFileSafe } from "../fs.js";
16
- import { parse as parseYaml, stringify as stringifyYaml } from "yaml";
17
- import { logger } from "../logger.js";
18
- const DEC_ID_RE = /\bDEC-[0-9a-f]{7,}\b/;
19
- const INV_ID_RE = /\bINV-[0-9a-f]{7,}\b/;
20
- /**
21
- * Mapper LLMs occasionally emit ledger-entry PROSE ("HTTP layer is the only
22
- * public surface…") into `decisions[]` / `invariants[]` instead of bare IDs,
23
- * because the user prompt lists them as `${id} — ${title}` and the JSON-mode
24
- * schema only constrains the type to `string`. This coercer extracts the
25
- * first ID-shaped token from each string and silently drops anything that
26
- * doesn't match — IDs only, deduplicated, order preserved.
27
- */
28
- export function coerceDecisionIds(raw) {
29
- return coerceIds(raw, DEC_ID_RE);
30
- }
31
- export function coerceInvariantIds(raw) {
32
- return coerceIds(raw, INV_ID_RE);
33
- }
34
- function coerceIds(raw, re) {
35
- const out = [];
36
- const seen = new Set();
37
- for (const s of raw) {
38
- if (typeof s !== "string")
39
- continue;
40
- const m = s.match(re);
41
- if (m === null)
42
- continue;
43
- if (seen.has(m[0]))
44
- continue;
45
- seen.add(m[0]);
46
- out.push(m[0]);
47
- }
48
- return out;
49
- }
50
- export function scopeIndexPath(repoRoot) {
51
- return join(repoRoot, ".cairn", "ground", "scope-index.yaml");
52
- }
53
- export function readScopeIndex(repoRoot) {
54
- const path = scopeIndexPath(repoRoot);
55
- if (!existsSync(path))
56
- return null;
57
- let parsed;
58
- try {
59
- parsed = parseYaml(readFileSync(path, "utf8"));
60
- }
61
- catch {
62
- return null;
63
- }
64
- if (typeof parsed !== "object" || parsed === null)
65
- return null;
66
- const generated = typeof parsed["generated"] === "string"
67
- ? parsed["generated"]
68
- : new Date().toISOString();
69
- const filesRaw = parsed["files"];
70
- const files = {};
71
- if (typeof filesRaw === "object" && filesRaw !== null) {
72
- for (const [k, v] of Object.entries(filesRaw)) {
73
- if (typeof v !== "object" || v === null)
74
- continue;
75
- const e = v;
76
- const decisions = Array.isArray(e["decisions"])
77
- ? e["decisions"].filter((x) => typeof x === "string")
78
- : [];
79
- const invariants = Array.isArray(e["invariants"])
80
- ? e["invariants"].filter((x) => typeof x === "string")
81
- : [];
82
- const entry = { decisions, invariants };
83
- if (e["unscoped"] === true)
84
- entry.unscoped = true;
85
- files[k] = entry;
86
- }
87
- }
88
- return { generated, files };
89
- }
90
- export function lookupScope(index, repoRelativePath) {
91
- const entry = index.files[repoRelativePath];
92
- if (entry === undefined)
93
- return null;
94
- return entry;
95
- }
96
- export function writeScopeIndex(repoRoot, index) {
97
- const path = scopeIndexPath(repoRoot);
98
- writeFileSafe(path, stringifyYaml(index));
99
- }
100
- const log = logger("ground.scope-index");
101
- /* -------------------------------------------------------------------------- */
102
- /* Deterministic citation rescan */
103
- /* -------------------------------------------------------------------------- */
104
- const CITATION_RE = /§(?:INV|DEC)-\d{4,}/g;
105
- const RESCAN_SOURCE_EXT_RE = /\.(?:ts|tsx|cts|mts|js|jsx|cjs|mjs|py|rb|go|rs|java|kt|swift|c|cc|cpp|h|hpp|cs|php|sql|sh|bash)$/i;
106
- const RESCAN_SKIP_DIR_RE = /(?:^|\/)(?:node_modules|dist|build|out|\.next|\.turbo|\.cache|coverage|\.cairn|\.archive|\.git)(?:\/|$)/;
107
- /**
108
- * Deterministic regex sweep — walk every git-tracked source file, parse
109
- * `§INV-NNNN` / `§DEC-NNNN` cite tokens, and sync the scope-index so the
110
- * in-scope tools never lag behind source-cite reality. No LLM, no
111
- * incremental tracking complexity. Cheap enough to run on every
112
- * SessionStart (~100ms on 50k files).
113
- *
114
- * Honors `unscoped: true` entries — never touches them. Skips files with
115
- * no citations and no prior entry to avoid polluting the index. When a
116
- * file's cite set differs from its scope-index entry (added, removed, or
117
- * stale ids), the entry is rewritten with the deterministically-sorted
118
- * current set.
119
- */
120
- export function rescanScopeIndex(repoRoot) {
121
- const sourceFiles = listGitTrackedSourceFiles(repoRoot);
122
- const existing = readScopeIndex(repoRoot) ?? {
123
- generated: new Date().toISOString(),
124
- files: {},
125
- };
126
- let entriesAdded = 0;
127
- let entriesUpdated = 0;
128
- let entriesUnchanged = 0;
129
- let dirty = false;
130
- for (const rel of sourceFiles) {
131
- const prior = existing.files[rel];
132
- if (prior?.unscoped === true)
133
- continue;
134
- const found = scanFileCitations(join(repoRoot, rel));
135
- if (found === null)
136
- continue;
137
- if (found.decisions.length === 0 &&
138
- found.invariants.length === 0 &&
139
- prior === undefined) {
140
- continue;
141
- }
142
- if (prior === undefined) {
143
- existing.files[rel] = {
144
- decisions: found.decisions,
145
- invariants: found.invariants,
146
- };
147
- entriesAdded += 1;
148
- dirty = true;
149
- continue;
150
- }
151
- const sameDecs = prior.decisions.length === found.decisions.length &&
152
- prior.decisions.every((d, i) => d === found.decisions[i]);
153
- const sameInvs = prior.invariants.length === found.invariants.length &&
154
- prior.invariants.every((v, i) => v === found.invariants[i]);
155
- if (sameDecs && sameInvs) {
156
- entriesUnchanged += 1;
157
- continue;
158
- }
159
- existing.files[rel] = {
160
- decisions: found.decisions,
161
- invariants: found.invariants,
162
- };
163
- entriesUpdated += 1;
164
- dirty = true;
165
- }
166
- if (dirty) {
167
- writeScopeIndex(repoRoot, {
168
- generated: new Date().toISOString(),
169
- files: existing.files,
170
- });
171
- }
172
- return {
173
- filesScanned: sourceFiles.length,
174
- entriesAdded,
175
- entriesUpdated,
176
- entriesUnchanged,
177
- dirty,
178
- };
179
- }
180
- function scanFileCitations(absPath) {
181
- let body;
182
- try {
183
- body = readFileSync(absPath, "utf8");
184
- }
185
- catch {
186
- return null;
187
- }
188
- return parseCitations(body);
189
- }
190
- function parseCitations(body) {
191
- const decs = new Set();
192
- const invs = new Set();
193
- for (const m of body.matchAll(CITATION_RE)) {
194
- const tok = m[0].slice(1);
195
- if (tok.startsWith("DEC-"))
196
- decs.add(tok);
197
- else if (tok.startsWith("INV-"))
198
- invs.add(tok);
199
- }
200
- return {
201
- decisions: [...decs].sort(),
202
- invariants: [...invs].sort(),
203
- };
204
- }
205
- /**
206
- * Single-file scope-index sync from in-memory content. Called by the
207
- * PostToolUse(Write/Edit) hook so an agent's writes don't leave the
208
- * scope-index stale until the next SessionStart rescan. Same regex
209
- * parser as `rescanScopeIndex`, but bounded to one file — O(1) cost,
210
- * no walker.
211
- *
212
- * Honors `unscoped: true` entries (skips them). Honors the same skip
213
- * rule the rescan does: file with no citations and no prior entry is
214
- * a no-op so we don't pollute the index with empty rows.
215
- */
216
- export function syncFileScopeFromContent(repoRoot, repoRelPath, content) {
217
- const found = parseCitations(content);
218
- const existing = readScopeIndex(repoRoot) ?? {
219
- generated: new Date().toISOString(),
220
- files: {},
221
- };
222
- const prior = existing.files[repoRelPath];
223
- if (prior?.unscoped === true)
224
- return { dirty: false };
225
- if (found.decisions.length === 0 &&
226
- found.invariants.length === 0 &&
227
- prior === undefined) {
228
- return { dirty: false };
229
- }
230
- if (prior !== undefined) {
231
- const sameDecs = prior.decisions.length === found.decisions.length &&
232
- prior.decisions.every((d, i) => d === found.decisions[i]);
233
- const sameInvs = prior.invariants.length === found.invariants.length &&
234
- prior.invariants.every((v, i) => v === found.invariants[i]);
235
- if (sameDecs && sameInvs)
236
- return { dirty: false };
237
- }
238
- existing.files[repoRelPath] = {
239
- decisions: found.decisions,
240
- invariants: found.invariants,
241
- };
242
- writeScopeIndex(repoRoot, {
243
- generated: new Date().toISOString(),
244
- files: existing.files,
245
- });
246
- return { dirty: true };
247
- }
248
- function listGitTrackedSourceFiles(repoRoot) {
249
- let out;
250
- try {
251
- out = execFileSync("git", ["ls-files", "--cached", "--others", "--exclude-standard", "-z"], { cwd: repoRoot, maxBuffer: 100 * 1024 * 1024 }).toString("utf8");
252
- }
253
- catch {
254
- return [];
255
- }
256
- const acc = [];
257
- for (const path of out.split("\0")) {
258
- if (path.length === 0)
259
- continue;
260
- if (RESCAN_SKIP_DIR_RE.test(path))
261
- continue;
262
- if (!RESCAN_SOURCE_EXT_RE.test(path))
263
- continue;
264
- acc.push(path);
265
- }
266
- return acc;
267
- }
268
- /**
269
- * `cairn scope rebuild` — full deterministic resync of `.cairn/ground/
270
- * scope-index.yaml` from current source-cite reality. Used to be a
271
- * Sonnet call (`runMapper`-style) that re-classified files via the
272
- * Tier-2 mapper, but classification was always the wrong abstraction
273
- * — bare-symbol citations in source are the canonical source of truth,
274
- * `rescanScopeIndex` parses them deterministically, and the result
275
- * matches what the read-enricher legend actually shows.
276
- *
277
- * No LLM. No tokens. No mapper. Just a regex sweep over git-tracked
278
- * source files and an atomic write.
279
- */
280
- export async function rebuildScopeIndex(opts) {
281
- log.info({ repo_root: opts.repoRoot }, "scope rebuild — deterministic rescan");
282
- const startedAt = Date.now();
283
- const result = rescanScopeIndex(opts.repoRoot);
284
- return {
285
- path: scopeIndexPath(opts.repoRoot),
286
- filesClassified: result.entriesAdded + result.entriesUpdated + result.entriesUnchanged,
287
- durationMs: Date.now() - startedAt,
288
- };
289
- }
290
- //# sourceMappingURL=scope-index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"scope-index.js","sourceRoot":"","sources":["../../src/ground/scope-index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,SAAS,IAAI,aAAa,EAAE,MAAM,MAAM,CAAC;AAWtE,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAStC,MAAM,SAAS,GAAG,sBAAsB,CAAC;AACzC,MAAM,SAAS,GAAG,sBAAsB,CAAC;AAEzC;;;;;;;GAOG;AACH,MAAM,UAAU,iBAAiB,CAAC,GAAuB;IACvD,OAAO,SAAS,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;AACnC,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,GAAuB;IACxD,OAAO,SAAS,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;AACnC,CAAC;AAED,SAAS,SAAS,CAAC,GAAuB,EAAE,EAAU;IACpD,MAAM,GAAG,GAAa,EAAE,CAAC;IACzB,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAC/B,KAAK,MAAM,CAAC,IAAI,GAAG,EAAE,CAAC;QACpB,IAAI,OAAO,CAAC,KAAK,QAAQ;YAAE,SAAS;QACpC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACtB,IAAI,CAAC,KAAK,IAAI;YAAE,SAAS;QACzB,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC,CA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AAC,gBAAgB;QACvE,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS;KACnC,CAAC;AACJ,CAAC"}
@@ -1,60 +0,0 @@
1
- /**
2
- * Normalize a prose block: strip markdown ornaments + collapse whitespace.
3
- * Output is the canonical form fed into both content-fingerprint slug
4
- * generation and content-hash calculation. Identical normalized output
5
- * → identical slug, even if the source markdown formatting differs.
6
- */
7
- export declare function normalizeBlock(input: string): string;
8
- /**
9
- * Compute the 12-char content-fingerprint slug for a prose block. Uses
10
- * sha256 over the normalized body, hex-encoded, sliced to 12 chars.
11
- *
12
- * 12 chars → 48 bits, ~280 trillion buckets. Birthday collision becomes
13
- * meaningful around 16 million distinct topics; real repos are nowhere
14
- * close to that.
15
- */
16
- export declare function topicSlug(input: string): string;
17
- /**
18
- * Compute the full sha256 hex of a prose body (no normalization). Used
19
- * for sot_content_hash drift detection — the hash must change when the
20
- * operator edits the source paragraph by even one character so the
21
- * doc-drift sensor can fire.
22
- */
23
- export declare function bodyContentHash(body: string): string;
24
- /**
25
- * Derive a stable DEC id from canonical inputs. Plan §3.2.1: id =
26
- * "DEC-" + sha256(JSON.stringify({sot_path, title, capture_source})).slice(0, 7).
27
- *
28
- * Body is intentionally NOT in the hash input — doc-drift refresh
29
- * updates body but keeps the id stable so every §DEC-<hash> token in
30
- * source files survives the refresh.
31
- */
32
- export declare function deriveDecId(input: {
33
- sot_path: string;
34
- title: string;
35
- capture_source: string;
36
- }): string;
37
- export declare function deriveInvId(input: {
38
- sot_path: string;
39
- title: string;
40
- capture_source: string;
41
- }): string;
42
- /**
43
- * Ledger-DEC id derivation for source-comment captures (plan §5.3). The
44
- * generic `deriveDecId` keys on `(sot_path, title, capture_source)`, which
45
- * collapses for ledger entries because every source-comment DEC shares the
46
- * literal `sot_path: "ledger"`. Title alone is not unique — two essay
47
- * comments starting with the same line would collide. Source location is
48
- * stable post-strip-replace, so `(source_file, source_offset, capture_source)`
49
- * is the per-fact unique input.
50
- */
51
- export declare function deriveLedgerDecId(input: {
52
- source_file: string;
53
- source_offset: number;
54
- capture_source: string;
55
- }): string;
56
- export declare function deriveLedgerInvId(input: {
57
- source_file: string;
58
- source_offset: number;
59
- capture_source: string;
60
- }): string;
@@ -1,103 +0,0 @@
1
- import { createHash } from "node:crypto";
2
- /**
3
- * Content-fingerprint helpers shared by topic-index, anchor-map, sot-cache,
4
- * and the Layer A alignment hook.
5
- *
6
- * The content slug is sha256-derived from the normalized prose body so two
7
- * identical blocks (in any source) produce the same slug. Different content
8
- * → different slug, regardless of leading words. This avoids the "we use
9
- * postgres for X" vs "we use postgres for Y" collision that a leading-word
10
- * slugger would suffer.
11
- */
12
- const NORMALIZE_PATTERNS = [
13
- { pattern: /```[\s\S]*?```/g, replacement: " " },
14
- { pattern: /`[^`]+`/g, replacement: " " },
15
- { pattern: /\[([^\]]+)\]\([^)]*\)/g, replacement: "$1" },
16
- { pattern: /^#{1,6}\s+/gm, replacement: "" },
17
- { pattern: /^[\s>*\-+]+/gm, replacement: "" },
18
- { pattern: /\s+/g, replacement: " " },
19
- ];
20
- /**
21
- * Normalize a prose block: strip markdown ornaments + collapse whitespace.
22
- * Output is the canonical form fed into both content-fingerprint slug
23
- * generation and content-hash calculation. Identical normalized output
24
- * → identical slug, even if the source markdown formatting differs.
25
- */
26
- export function normalizeBlock(input) {
27
- let s = input;
28
- for (const { pattern, replacement } of NORMALIZE_PATTERNS) {
29
- s = s.replace(pattern, replacement);
30
- }
31
- return s.trim().toLowerCase();
32
- }
33
- /**
34
- * Compute the 12-char content-fingerprint slug for a prose block. Uses
35
- * sha256 over the normalized body, hex-encoded, sliced to 12 chars.
36
- *
37
- * 12 chars → 48 bits, ~280 trillion buckets. Birthday collision becomes
38
- * meaningful around 16 million distinct topics; real repos are nowhere
39
- * close to that.
40
- */
41
- export function topicSlug(input) {
42
- const normalized = normalizeBlock(input);
43
- return createHash("sha256").update(normalized, "utf8").digest("hex").slice(0, 12);
44
- }
45
- /**
46
- * Compute the full sha256 hex of a prose body (no normalization). Used
47
- * for sot_content_hash drift detection — the hash must change when the
48
- * operator edits the source paragraph by even one character so the
49
- * doc-drift sensor can fire.
50
- */
51
- export function bodyContentHash(body) {
52
- return createHash("sha256").update(body, "utf8").digest("hex");
53
- }
54
- /**
55
- * Derive a stable DEC id from canonical inputs. Plan §3.2.1: id =
56
- * "DEC-" + sha256(JSON.stringify({sot_path, title, capture_source})).slice(0, 7).
57
- *
58
- * Body is intentionally NOT in the hash input — doc-drift refresh
59
- * updates body but keeps the id stable so every §DEC-<hash> token in
60
- * source files survives the refresh.
61
- */
62
- export function deriveDecId(input) {
63
- const json = JSON.stringify({
64
- sot_path: input.sot_path,
65
- title: input.title,
66
- capture_source: input.capture_source,
67
- });
68
- return `DEC-${createHash("sha256").update(json, "utf8").digest("hex").slice(0, 7)}`;
69
- }
70
- export function deriveInvId(input) {
71
- const json = JSON.stringify({
72
- sot_path: input.sot_path,
73
- title: input.title,
74
- capture_source: input.capture_source,
75
- });
76
- return `INV-${createHash("sha256").update(json, "utf8").digest("hex").slice(0, 7)}`;
77
- }
78
- /**
79
- * Ledger-DEC id derivation for source-comment captures (plan §5.3). The
80
- * generic `deriveDecId` keys on `(sot_path, title, capture_source)`, which
81
- * collapses for ledger entries because every source-comment DEC shares the
82
- * literal `sot_path: "ledger"`. Title alone is not unique — two essay
83
- * comments starting with the same line would collide. Source location is
84
- * stable post-strip-replace, so `(source_file, source_offset, capture_source)`
85
- * is the per-fact unique input.
86
- */
87
- export function deriveLedgerDecId(input) {
88
- const json = JSON.stringify({
89
- source_file: input.source_file,
90
- source_offset: input.source_offset,
91
- capture_source: input.capture_source,
92
- });
93
- return `DEC-${createHash("sha256").update(json, "utf8").digest("hex").slice(0, 7)}`;
94
- }
95
- export function deriveLedgerInvId(input) {
96
- const json = JSON.stringify({
97
- source_file: input.source_file,
98
- source_offset: input.source_offset,
99
- capture_source: input.capture_source,
100
- });
101
- return `INV-${createHash("sha256").update(json, "utf8").digest("hex").slice(0, 7)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,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;AACtF,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,KAIjC;IACC,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC;QAC1B,WAAW,EAAE,KAAK,CAAC,WAAW;QAC9B,aAAa,EAAE,KAAK,CAAC,aAAa;QAClC,cAAc,EAAE,KAAK,CAAC,cAAc;KACrC,CAAC,CAAC;IACH,OAAO,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;AACtF,CAAC"}
@@ -1,14 +0,0 @@
1
- import { SotBindings } from "./schemas.js";
2
- /**
3
- * Sot-bindings is the lookup table that lens + sensors + the alignment
4
- * hook all consult to resolve a §DEC-<hash> token to its canonical
5
- * source. The forward index is one DEC → one path. The reverse index is
6
- * one path → many DECs (supersedes chains share their sot_path).
7
- */
8
- export declare function emptySotBindings(): SotBindings;
9
- export declare function readSotBindings(repoRoot: string): SotBindings;
10
- export declare function writeSotBindings(repoRoot: string, bindings: SotBindings): string;
11
- export declare function bindDec(bindings: SotBindings, decId: string, sotPath: string): SotBindings;
12
- export declare function unbindDec(bindings: SotBindings, decId: string): SotBindings;
13
- export declare function decsForPath(bindings: SotBindings, sotPath: string): string[];
14
- export declare function pathForDec(bindings: SotBindings, decId: string): string | null;
@@ -1,79 +0,0 @@
1
- import { existsSync, readFileSync } from "node:fs";
2
- import { writeFileSafe } from "../fs.js";
3
- import { parse as parseYaml, stringify as stringifyYaml } from "yaml";
4
- import { logger } from "../logger.js";
5
- import { sotBindingsPath } from "./paths.js";
6
- import { SotBindings } from "./schemas.js";
7
- const log = logger("ground.sot-bindings");
8
- /**
9
- * Sot-bindings is the lookup table that lens + sensors + the alignment
10
- * hook all consult to resolve a §DEC-<hash> token to its canonical
11
- * source. The forward index is one DEC → one path. The reverse index is
12
- * one path → many DECs (supersedes chains share their sot_path).
13
- */
14
- export function emptySotBindings() {
15
- return {
16
- version: 1,
17
- generated: new Date().toISOString(),
18
- forward: {},
19
- reverse: {},
20
- };
21
- }
22
- export function readSotBindings(repoRoot) {
23
- const path = sotBindingsPath(repoRoot);
24
- if (!existsSync(path))
25
- return emptySotBindings();
26
- try {
27
- const raw = readFileSync(path, "utf8");
28
- const parsed = SotBindings.safeParse(parseYaml(raw));
29
- if (!parsed.success) {
30
- log.warn({ path, error: parsed.error.message }, "sot-bindings invalid; treating as empty");
31
- return emptySotBindings();
32
- }
33
- return parsed.data;
34
- }
35
- catch (err) {
36
- log.warn({ path, err }, "sot-bindings read failed; treating as empty");
37
- return emptySotBindings();
38
- }
39
- }
40
- export function writeSotBindings(repoRoot, bindings) {
41
- const path = sotBindingsPath(repoRoot);
42
- const next = { ...bindings, generated: new Date().toISOString() };
43
- writeFileSafe(path, stringifyYaml(next));
44
- log.debug({ path, decs: Object.keys(next.forward).length }, "wrote sot-bindings");
45
- return path;
46
- }
47
- export function bindDec(bindings, decId, sotPath) {
48
- const forward = { ...bindings.forward, [decId]: sotPath };
49
- const reverse = { ...bindings.reverse };
50
- const existing = reverse[sotPath] ?? [];
51
- if (!existing.includes(decId)) {
52
- reverse[sotPath] = [...existing, decId];
53
- }
54
- return { ...bindings, forward, reverse };
55
- }
56
- export function unbindDec(bindings, decId) {
57
- const sotPath = bindings.forward[decId];
58
- if (sotPath === undefined)
59
- return bindings;
60
- const forward = { ...bindings.forward };
61
- delete forward[decId];
62
- const reverse = { ...bindings.reverse };
63
- const list = reverse[sotPath] ?? [];
64
- const filtered = list.filter((id) => id !== decId);
65
- if (filtered.length === 0) {
66
- delete reverse[sotPath];
67
- }
68
- else {
69
- reverse[sotPath] = filtered;
70
- }
71
- return { ...bindings, forward, reverse };
72
- }
73
- export function decsForPath(bindings, sotPath) {
74
- return bindings.reverse[sotPath] ?? [];
75
- }
76
- export function pathForDec(bindings, decId) {
77
- return bindings.forward[decId] ?? null;
78
- }
79
- //# sourceMappingURL=sot-bindings.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sot-bindings.js","sourceRoot":"","sources":["../../src/ground/sot-bindings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,SAAS,IAAI,aAAa,EAAE,MAAM,MAAM,CAAC;AACtE,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C,MAAM,GAAG,GAAG,MAAM,CAAC,qBAAqB,CAAC,CAAC;AAE1C;;;;;GAKG;AAEH,MAAM,UAAU,gBAAgB;IAC9B,OAAO;QACL,OAAO,EAAE,CAAC;QACV,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QACnC,OAAO,EAAE,EAAE;QACX,OAAO,EAAE,EAAE;KACZ,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,QAAgB;IAC9C,MAAM,IAAI,GAAG,eAAe,CAAC,QAAQ,CAAC,CAAC;IACvC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;QAAE,OAAO,gBAAgB,EAAE,CAAC;IACjD,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QACvC,MAAM,MAAM,GAAG,WAAW,CAAC,SAAS,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC;QACrD,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YACpB,GAAG,CAAC,IA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Entry } from "./schemas.js";
2
- /**
3
- * Sot-cache holds pre-tokenized DEC body content for the Layer A Jaccard
4
- * pre-filter. Rebuilt at SessionStart, incremental on PostToolUse Write
5
- * events that touch a DEC body or sot-path file. Mtime-keyed so a stale
6
- * entry is detected without re-tokenizing every body on every Write.
7
- */
8
- export declare function emptySotCache(): SotCache;
9
- export declare function readSotCache(repoRoot: string): SotCache;
10
- export declare function writeSotCache(repoRoot: string, cache: SotCache): string;
11
- export declare function setEntry(cache: SotCache, decId: string, entry: SotCacheEntry): SotCache;
12
- export declare function getEntry(cache: SotCache, decId: string): SotCacheEntry | null;
13
- export declare function deleteEntry(cache: SotCache, decId: string): SotCache;
14
- /**
15
- * Iterate all entries. Layer A's pre-filter pass calls this on each
16
- * Write to compute Jaccard against every cached DEC body.
17
- */
18
- export declare function entries(cache: SotCache): SotCacheEntry[];
@@ -1,62 +0,0 @@
1
- import { existsSync, readFileSync } from "node:fs";
2
- import { writeFileSafe } from "../fs.js";
3
- import { parse as parseYaml, stringify as stringifyYaml } from "yaml";
4
- import { logger } from "../logger.js";
5
- import { sotCachePath } from "./paths.js";
6
- import { SotCache } from "./schemas.js";
7
- const log = logger("ground.sot-cache");
8
- /**
9
- * Sot-cache holds pre-tokenized DEC body content for the Layer A Jaccard
10
- * pre-filter. Rebuilt at SessionStart, incremental on PostToolUse Write
11
- * events that touch a DEC body or sot-path file. Mtime-keyed so a stale
12
- * entry is detected without re-tokenizing every body on every Write.
13
- */
14
- export function emptySotCache() {
15
- return { version: 1, generated: new Date().toISOString(), entries: {} };
16
- }
17
- export function readSotCache(repoRoot) {
18
- const path = sotCachePath(repoRoot);
19
- if (!existsSync(path))
20
- return emptySotCache();
21
- try {
22
- const raw = readFileSync(path, "utf8");
23
- const parsed = SotCache.safeParse(parseYaml(raw));
24
- if (!parsed.success) {
25
- log.warn({ path, error: parsed.error.message }, "sot-cache invalid; treating as empty");
26
- return emptySotCache();
27
- }
28
- return parsed.data;
29
- }
30
- catch (err) {
31
- log.warn({ path, err }, "sot-cache read failed; treating as empty");
32
- return emptySotCache();
33
- }
34
- }
35
- export function writeSotCache(repoRoot, cache) {
36
- const path = sotCachePath(repoRoot);
37
- const next = { ...cache, generated: new Date().toISOString() };
38
- writeFileSafe(path, stringifyYaml(next));
39
- log.debug({ path, entries: Object.keys(next.entries).length }, "wrote sot-cache");
40
- return path;
41
- }
42
- export function setEntry(cache, decId, entry) {
43
- return { ...cache, entries: { ...cache.entries, [decId]: entry } };
44
- }
45
- export function getEntry(cache, decId) {
46
- return cache.entries[decId] ?? null;
47
- }
48
- export function deleteEntry(cache, decId) {
49
- if (cache.entries[decId] === undefined)
50
- return cache;
51
- const entries = { ...cache.entries };
52
- delete entries[decId];
53
- return { ...cache, entries };
54
- }
55
- /**
56
- * Iterate all entries. Layer A's pre-filter pass calls this on each
57
- * Write to compute Jaccard against every cached DEC body.
58
- */
59
- export function entries(cache) {
60
- return Object.values(cache.entries);
61
- }
62
- //# sourceMappingURL=sot-cache.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sot-cache.js","sourceRoot":"","sources":["../../src/ground/sot-cache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,SAAS,IAAI,aAAa,EAAE,MAAM,MAAM,CAAC;AACtE,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAsB,MAAM,cAAc,CAAC;AAE5D,MAAM,GAAG,GAAG,MAAM,CAAC,kBAAkB,CAAC,CAAC;AAEvC;;;;;GAKG;AAEH,MAAM,UAAU,aAAa;IAC3B,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAA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