@isaacriehm/cairn-core 0.4.2 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (211) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/align-undo/index.d.ts +6 -0
  3. package/dist/align-undo/index.js +6 -0
  4. package/dist/align-undo/index.js.map +1 -0
  5. package/dist/align-undo/log.d.ts +53 -0
  6. package/dist/align-undo/log.js +99 -0
  7. package/dist/align-undo/log.js.map +1 -0
  8. package/dist/align-undo/undo.d.ts +66 -0
  9. package/dist/align-undo/undo.js +187 -0
  10. package/dist/align-undo/undo.js.map +1 -0
  11. package/dist/attention/bulk-accept.js +1 -1
  12. package/dist/attention/bulk-accept.js.map +1 -1
  13. package/dist/attention/dedup.d.ts +2 -2
  14. package/dist/attention/dedup.js +16 -51
  15. package/dist/attention/dedup.js.map +1 -1
  16. package/dist/attention/index.d.ts +1 -0
  17. package/dist/attention/index.js +1 -0
  18. package/dist/attention/index.js.map +1 -1
  19. package/dist/attention/restore.js +1 -1
  20. package/dist/attention/restore.js.map +1 -1
  21. package/dist/attention/serve/api.d.ts +23 -0
  22. package/dist/attention/serve/api.js +344 -0
  23. package/dist/attention/serve/api.js.map +1 -0
  24. package/dist/attention/serve/index.d.ts +62 -0
  25. package/dist/attention/serve/index.js +205 -0
  26. package/dist/attention/serve/index.js.map +1 -0
  27. package/dist/decision-capture/id.d.ts +62 -25
  28. package/dist/decision-capture/id.js +78 -57
  29. package/dist/decision-capture/id.js.map +1 -1
  30. package/dist/decision-capture/index.d.ts +3 -3
  31. package/dist/decision-capture/index.js +3 -3
  32. package/dist/decision-capture/index.js.map +1 -1
  33. package/dist/drain/drain.d.ts +77 -0
  34. package/dist/drain/drain.js +464 -0
  35. package/dist/drain/drain.js.map +1 -0
  36. package/dist/drain/index.d.ts +5 -0
  37. package/dist/drain/index.js +5 -0
  38. package/dist/drain/index.js.map +1 -0
  39. package/dist/fix-align/index.d.ts +5 -0
  40. package/dist/fix-align/index.js +5 -0
  41. package/dist/fix-align/index.js.map +1 -0
  42. package/dist/fix-align/run.d.ts +99 -0
  43. package/dist/fix-align/run.js +258 -0
  44. package/dist/fix-align/run.js.map +1 -0
  45. package/dist/ground/alignment-pending.d.ts +28 -0
  46. package/dist/ground/alignment-pending.js +83 -0
  47. package/dist/ground/alignment-pending.js.map +1 -0
  48. package/dist/ground/anchor-map.d.ts +14 -0
  49. package/dist/ground/anchor-map.js +57 -0
  50. package/dist/ground/anchor-map.js.map +1 -0
  51. package/dist/ground/index.d.ts +9 -2
  52. package/dist/ground/index.js +8 -2
  53. package/dist/ground/index.js.map +1 -1
  54. package/dist/ground/paths.d.ts +21 -0
  55. package/dist/ground/paths.js +43 -0
  56. package/dist/ground/paths.js.map +1 -1
  57. package/dist/ground/schemas.d.ts +201 -0
  58. package/dist/ground/schemas.js +128 -3
  59. package/dist/ground/schemas.js.map +1 -1
  60. package/dist/ground/scope-index.js +2 -2
  61. package/dist/ground/scope-index.js.map +1 -1
  62. package/dist/ground/slug.d.ts +60 -0
  63. package/dist/ground/slug.js +103 -0
  64. package/dist/ground/slug.js.map +1 -0
  65. package/dist/ground/sot-bindings.d.ts +14 -0
  66. package/dist/ground/sot-bindings.js +80 -0
  67. package/dist/ground/sot-bindings.js.map +1 -0
  68. package/dist/ground/sot-cache.d.ts +18 -0
  69. package/dist/ground/sot-cache.js +63 -0
  70. package/dist/ground/sot-cache.js.map +1 -0
  71. package/dist/ground/topic-index.d.ts +20 -0
  72. package/dist/ground/topic-index.js +60 -0
  73. package/dist/ground/topic-index.js.map +1 -0
  74. package/dist/hooks/post-tool-use/citation-scanner.d.ts +1 -1
  75. package/dist/hooks/post-tool-use/citation-scanner.js +3 -3
  76. package/dist/hooks/post-tool-use/citation-scanner.js.map +1 -1
  77. package/dist/hooks/post-tool-use/copy-scanner.js +1 -1
  78. package/dist/hooks/post-tool-use/copy-scanner.js.map +1 -1
  79. package/dist/hooks/post-tool-use/index.d.ts +2 -0
  80. package/dist/hooks/post-tool-use/index.js +1 -0
  81. package/dist/hooks/post-tool-use/index.js.map +1 -1
  82. package/dist/hooks/post-tool-use/legend-builder.d.ts +1 -1
  83. package/dist/hooks/post-tool-use/legend-builder.js +2 -2
  84. package/dist/hooks/post-tool-use/legend-builder.js.map +1 -1
  85. package/dist/hooks/post-tool-use/sot-align.d.ts +166 -0
  86. package/dist/hooks/post-tool-use/sot-align.js +1311 -0
  87. package/dist/hooks/post-tool-use/sot-align.js.map +1 -0
  88. package/dist/hooks/pre-commit/index.d.ts +8 -0
  89. package/dist/hooks/pre-commit/index.js +8 -0
  90. package/dist/hooks/pre-commit/index.js.map +1 -0
  91. package/dist/hooks/pre-commit/sot-align-precommit.d.ts +60 -0
  92. package/dist/hooks/pre-commit/sot-align-precommit.js +221 -0
  93. package/dist/hooks/pre-commit/sot-align-precommit.js.map +1 -0
  94. package/dist/hooks/runners/session-start.js +41 -0
  95. package/dist/hooks/runners/session-start.js.map +1 -1
  96. package/dist/hooks/sot-align-common.d.ts +39 -0
  97. package/dist/hooks/sot-align-common.js +152 -0
  98. package/dist/hooks/sot-align-common.js.map +1 -0
  99. package/dist/index.d.ts +5 -0
  100. package/dist/index.js +5 -0
  101. package/dist/index.js.map +1 -1
  102. package/dist/init/index.d.ts +4 -2
  103. package/dist/init/index.js +2 -1
  104. package/dist/init/index.js.map +1 -1
  105. package/dist/init/ingest-docs.d.ts +30 -47
  106. package/dist/init/ingest-docs.js +113 -406
  107. package/dist/init/ingest-docs.js.map +1 -1
  108. package/dist/init/init.d.ts +8 -0
  109. package/dist/init/init.js +58 -29
  110. package/dist/init/init.js.map +1 -1
  111. package/dist/init/mapper-parallel.js +1 -1
  112. package/dist/init/mapper-parallel.js.map +1 -1
  113. package/dist/init/phases/5-brand.js +1 -1
  114. package/dist/init/phases/5-brand.js.map +1 -1
  115. package/dist/init/phases/5b-topic-index.d.ts +30 -0
  116. package/dist/init/phases/5b-topic-index.js +62 -0
  117. package/dist/init/phases/5b-topic-index.js.map +1 -0
  118. package/dist/init/phases/6-docs-ingest.d.ts +4 -5
  119. package/dist/init/phases/6-docs-ingest.js +5 -6
  120. package/dist/init/phases/6-docs-ingest.js.map +1 -1
  121. package/dist/init/phases/index.d.ts +2 -0
  122. package/dist/init/phases/index.js +1 -0
  123. package/dist/init/phases/index.js.map +1 -1
  124. package/dist/init/phases/parallel-678.d.ts +14 -17
  125. package/dist/init/phases/parallel-678.js +77 -98
  126. package/dist/init/phases/parallel-678.js.map +1 -1
  127. package/dist/init/phases/source-comments-output-io.d.ts +16 -10
  128. package/dist/init/phases/source-comments-output-io.js +7 -10
  129. package/dist/init/phases/source-comments-output-io.js.map +1 -1
  130. package/dist/init/phases/types.d.ts +1 -1
  131. package/dist/init/phases/types.js +1 -0
  132. package/dist/init/phases/types.js.map +1 -1
  133. package/dist/init/rules-merge/discover.d.ts +8 -3
  134. package/dist/init/rules-merge/discover.js +7 -3
  135. package/dist/init/rules-merge/discover.js.map +1 -1
  136. package/dist/init/rules-merge/ingest.d.ts +81 -28
  137. package/dist/init/rules-merge/ingest.js +456 -155
  138. package/dist/init/rules-merge/ingest.js.map +1 -1
  139. package/dist/init/sot-emit.d.ts +84 -0
  140. package/dist/init/sot-emit.js +218 -0
  141. package/dist/init/sot-emit.js.map +1 -0
  142. package/dist/init/source-comments/classify.d.ts +12 -10
  143. package/dist/init/source-comments/classify.js +13 -25
  144. package/dist/init/source-comments/classify.js.map +1 -1
  145. package/dist/init/source-comments/index.d.ts +1 -1
  146. package/dist/init/source-comments/index.js +1 -1
  147. package/dist/init/source-comments/index.js.map +1 -1
  148. package/dist/init/source-comments/ingest.d.ts +91 -67
  149. package/dist/init/source-comments/ingest.js +392 -349
  150. package/dist/init/source-comments/ingest.js.map +1 -1
  151. package/dist/init/topic-index/index.d.ts +36 -0
  152. package/dist/init/topic-index/index.js +46 -0
  153. package/dist/init/topic-index/index.js.map +1 -0
  154. package/dist/init/topic-index/judge.d.ts +20 -0
  155. package/dist/init/topic-index/judge.js +65 -0
  156. package/dist/init/topic-index/judge.js.map +1 -0
  157. package/dist/init/topic-index/resolve.d.ts +50 -0
  158. package/dist/init/topic-index/resolve.js +196 -0
  159. package/dist/init/topic-index/resolve.js.map +1 -0
  160. package/dist/init/topic-index/walk.d.ts +43 -0
  161. package/dist/init/topic-index/walk.js +293 -0
  162. package/dist/init/topic-index/walk.js.map +1 -0
  163. package/dist/mcp/history/summarizer.js +1 -1
  164. package/dist/mcp/history/summarizer.js.map +1 -1
  165. package/dist/mcp/schemas.d.ts +46 -9
  166. package/dist/mcp/schemas.js +48 -12
  167. package/dist/mcp/schemas.js.map +1 -1
  168. package/dist/mcp/tools/align-drain.d.ts +7 -0
  169. package/dist/mcp/tools/align-drain.js +26 -0
  170. package/dist/mcp/tools/align-drain.js.map +1 -0
  171. package/dist/mcp/tools/archive.js +1 -1
  172. package/dist/mcp/tools/archive.js.map +1 -1
  173. package/dist/mcp/tools/attention-restore.js +1 -1
  174. package/dist/mcp/tools/attention-restore.js.map +1 -1
  175. package/dist/mcp/tools/attention-serve.d.ts +23 -0
  176. package/dist/mcp/tools/attention-serve.js +78 -0
  177. package/dist/mcp/tools/attention-serve.js.map +1 -0
  178. package/dist/mcp/tools/attention-wait.d.ts +18 -0
  179. package/dist/mcp/tools/attention-wait.js +74 -0
  180. package/dist/mcp/tools/attention-wait.js.map +1 -0
  181. package/dist/mcp/tools/index.js +7 -0
  182. package/dist/mcp/tools/index.js.map +1 -1
  183. package/dist/mcp/tools/init-phases.js +4 -1
  184. package/dist/mcp/tools/init-phases.js.map +1 -1
  185. package/dist/mcp/tools/record-decision.js +14 -2
  186. package/dist/mcp/tools/record-decision.js.map +1 -1
  187. package/dist/mcp/tools/resolve-attention.d.ts +2 -2
  188. package/dist/mcp/tools/resolve-attention.js +830 -7
  189. package/dist/mcp/tools/resolve-attention.js.map +1 -1
  190. package/dist/status-line/event-queue.d.ts +40 -0
  191. package/dist/status-line/event-queue.js +195 -0
  192. package/dist/status-line/event-queue.js.map +1 -0
  193. package/dist/status-line/format.d.ts +1 -1
  194. package/dist/status-line/format.js +49 -6
  195. package/dist/status-line/format.js.map +1 -1
  196. package/dist/status-line/index.d.ts +41 -0
  197. package/dist/status-line/index.js +14 -0
  198. package/dist/status-line/index.js.map +1 -1
  199. package/dist/status-line/reader.js +23 -18
  200. package/dist/status-line/reader.js.map +1 -1
  201. package/dist/status-line/writer.d.ts +1 -1
  202. package/dist/status-line/writer.js +5 -0
  203. package/dist/status-line/writer.js.map +1 -1
  204. package/dist/text/jaccard.d.ts +19 -0
  205. package/dist/text/jaccard.js +68 -0
  206. package/dist/text/jaccard.js.map +1 -0
  207. package/package.json +1 -1
  208. package/templates/.cairn/git-hooks/pre-commit +16 -3
  209. package/templates/attention-ui/app.css +406 -0
  210. package/templates/attention-ui/app.js +384 -0
  211. package/templates/attention-ui/index.html +56 -0
@@ -0,0 +1,258 @@
1
+ /**
2
+ * Layer D — `cairn fix align` (plan §4.4).
3
+ *
4
+ * Operator-explicit full-repo Haiku-judge sweep over every prose
5
+ * block × every accepted DEC. Reuses the Layer A `alignFile` machinery
6
+ * per file with elevated caps so a single sweep can fully judge each
7
+ * file rather than deferring to staleness.
8
+ *
9
+ * Two phases:
10
+ *
11
+ * 1. Pre-flight (deterministic, free) — walk every staged source
12
+ * file, extract prose blocks, compute Tier 1 candidate counts +
13
+ * Haiku call estimate. Produces a cost preview the operator can
14
+ * eyeball before approving the spend.
15
+ *
16
+ * 2. Apply (calls Haiku) — invoke `alignFile` per file. Aggregate
17
+ * tier counts, pending, deferred, descriptive, Haiku spend.
18
+ *
19
+ * `--dry-run` exits after pre-flight. `--max-cost` aborts apply when
20
+ * the estimate exceeds the budget. `--no-creation` short-circuits the
21
+ * Tier 3 creation judge so a sweep only consolidates duplicates
22
+ * without proposing fresh DECs.
23
+ */
24
+ import { readdirSync, statSync } from "node:fs";
25
+ import { join, relative } from "node:path";
26
+ import { matchAnyGlob, readSotCache, } from "../ground/index.js";
27
+ import { alignFile } from "../hooks/post-tool-use/index.js";
28
+ import { TIER2_JACCARD_FLOOR, TOP_K_CANDIDATES, extractBlocks, isMarkdownPath, topKCandidates, } from "../hooks/sot-align-common.js";
29
+ import { logger } from "../logger.js";
30
+ import { tokenize } from "../text/jaccard.js";
31
+ const log = logger("fix-align");
32
+ /* -------------------------------------------------------------------------- */
33
+ /* Tunables */
34
+ /* -------------------------------------------------------------------------- */
35
+ const SWEEP_PASS1_CAP = 200;
36
+ const SWEEP_PASS2_CAP = 50;
37
+ const PASS2_FRACTION_ESTIMATE = 0.1; // ~10% of Pass-1 ambiguous → Pass-2
38
+ const TOKENS_PER_PASS1_CALL = 600; // empirical: Haiku dedup P1 ~600 tokens in/out
39
+ const TOKENS_PER_PASS2_CALL = 1_200;
40
+ const TOKENS_PER_CREATION_CALL = 800;
41
+ const DEFAULT_MAX_COST_TOKENS = 500_000;
42
+ const MIN_BLOCK_PROSE_LEN = 80;
43
+ const MIN_BLOCK_TOKEN_COUNT = 10;
44
+ const DEFAULT_EXCLUDES = [
45
+ ".cairn/**",
46
+ "node_modules/**",
47
+ "dist/**",
48
+ "build/**",
49
+ ".git/**",
50
+ ".vscode/**",
51
+ ".idea/**",
52
+ ];
53
+ /* -------------------------------------------------------------------------- */
54
+ /* Run */
55
+ /* -------------------------------------------------------------------------- */
56
+ export async function runFixAlign(args) {
57
+ const { repoRoot } = args;
58
+ const include = args.include ?? [];
59
+ const exclude = [...DEFAULT_EXCLUDES, ...(args.exclude ?? [])];
60
+ const maxCost = args.maxCost ?? DEFAULT_MAX_COST_TOKENS;
61
+ const skipCreation = args.skipCreation === true;
62
+ const pass1Cap = args.pass1Cap ?? SWEEP_PASS1_CAP;
63
+ const pass2Cap = args.pass2Cap ?? SWEEP_PASS2_CAP;
64
+ const filesVisited = listSourceFiles({ repoRoot, include, exclude });
65
+ const cache = readSotCache(repoRoot);
66
+ const cacheEntries = Object.values(cache.entries).filter((e) => e.tokens.length > 0);
67
+ const preflight = computePreflight({
68
+ repoRoot,
69
+ files: filesVisited,
70
+ cacheEntries,
71
+ skipCreation,
72
+ pass1Cap,
73
+ });
74
+ const result = {
75
+ preflight,
76
+ apply: null,
77
+ abortedOverBudget: false,
78
+ filesVisited,
79
+ };
80
+ if (args.dryRun === true)
81
+ return result;
82
+ if (preflight.estimatedTokens > maxCost) {
83
+ log.warn({ estimated: preflight.estimatedTokens, maxCost }, "fix-align estimate exceeds maxCost; aborting before Haiku spend");
84
+ result.abortedOverBudget = true;
85
+ return result;
86
+ }
87
+ const aggregate = {
88
+ filesAligned: 0,
89
+ blocksConsidered: 0,
90
+ tier1Aligned: 0,
91
+ tier2Aligned: 0,
92
+ decsCreated: 0,
93
+ invsCreated: 0,
94
+ augmentsDecs: 0,
95
+ augmentsInvs: 0,
96
+ pending: 0,
97
+ deferredToStaleness: 0,
98
+ descriptive: 0,
99
+ skipped: 0,
100
+ haikuPass1Calls: 0,
101
+ haikuPass2Calls: 0,
102
+ haikuCalls: 0,
103
+ };
104
+ for (const file of filesVisited) {
105
+ const alignArgs = {
106
+ repoRoot,
107
+ filePath: file,
108
+ sessionId: null,
109
+ pass1Cap,
110
+ pass2Cap,
111
+ skipCreation,
112
+ };
113
+ if (args.mocks?.mockDedupJudgePass1 !== undefined)
114
+ alignArgs.mockDedupJudgePass1 = args.mocks.mockDedupJudgePass1;
115
+ if (args.mocks?.mockDedupJudgePass2 !== undefined)
116
+ alignArgs.mockDedupJudgePass2 = args.mocks.mockDedupJudgePass2;
117
+ if (args.mocks?.mockDeltaExtract !== undefined)
118
+ alignArgs.mockDeltaExtract = args.mocks.mockDeltaExtract;
119
+ if (args.mocks?.mockDeltaClassify !== undefined)
120
+ alignArgs.mockDeltaClassify = args.mocks.mockDeltaClassify;
121
+ if (args.mocks?.mockCreationJudgePass1 !== undefined)
122
+ alignArgs.mockCreationJudgePass1 = args.mocks.mockCreationJudgePass1;
123
+ if (args.mocks?.mockCreationJudgePass2 !== undefined)
124
+ alignArgs.mockCreationJudgePass2 = args.mocks.mockCreationJudgePass2;
125
+ let fileResult;
126
+ try {
127
+ fileResult = await alignFile(alignArgs);
128
+ }
129
+ catch (err) {
130
+ log.warn({ file, err: String(err) }, "alignFile threw; continuing sweep");
131
+ continue;
132
+ }
133
+ aggregate.filesAligned += 1;
134
+ aggregate.blocksConsidered += fileResult.blocksConsidered;
135
+ aggregate.tier1Aligned += fileResult.tier1Aligned;
136
+ aggregate.tier2Aligned += fileResult.tier2Aligned;
137
+ aggregate.decsCreated += fileResult.decsCreated;
138
+ aggregate.invsCreated += fileResult.invsCreated;
139
+ aggregate.augmentsDecs += fileResult.augmentsDecs;
140
+ aggregate.augmentsInvs += fileResult.augmentsInvs;
141
+ aggregate.pending += fileResult.pending;
142
+ aggregate.deferredToStaleness += fileResult.deferredToStaleness;
143
+ aggregate.descriptive += fileResult.descriptive;
144
+ aggregate.skipped += fileResult.skipped;
145
+ aggregate.haikuPass1Calls += fileResult.haikuPass1Calls;
146
+ aggregate.haikuPass2Calls += fileResult.haikuPass2Calls;
147
+ aggregate.haikuCalls += fileResult.haikuCalls;
148
+ }
149
+ result.apply = aggregate;
150
+ return result;
151
+ }
152
+ function listSourceFiles(args) {
153
+ const out = [];
154
+ walk(args.repoRoot, args.repoRoot, out, args);
155
+ out.sort();
156
+ return out;
157
+ }
158
+ function walk(repoRoot, dir, out, args) {
159
+ let entries;
160
+ try {
161
+ entries = readdirSync(dir);
162
+ }
163
+ catch {
164
+ return;
165
+ }
166
+ for (const name of entries) {
167
+ if (name.startsWith(".") && name !== ".cairn") {
168
+ // Allow .cairn for the exclude check below; everything else
169
+ // hidden gets skipped (avoids walking node_modules-equivalents).
170
+ if (name === ".git" || name === ".vscode" || name === ".idea")
171
+ continue;
172
+ }
173
+ const abs = join(dir, name);
174
+ let s;
175
+ try {
176
+ s = statSync(abs);
177
+ }
178
+ catch {
179
+ continue;
180
+ }
181
+ const rel = relative(repoRoot, abs).split("\\").join("/");
182
+ if (s.isDirectory()) {
183
+ if (matchAnyGlob(`${rel}/`, args.exclude) || matchAnyGlob(rel, args.exclude))
184
+ continue;
185
+ walk(repoRoot, abs, out, args);
186
+ continue;
187
+ }
188
+ if (!s.isFile())
189
+ continue;
190
+ if (isMarkdownPath(rel))
191
+ continue;
192
+ if (matchAnyGlob(rel, args.exclude))
193
+ continue;
194
+ if (args.include.length > 0 && !matchAnyGlob(rel, args.include))
195
+ continue;
196
+ out.push(rel);
197
+ }
198
+ }
199
+ function computePreflight(args) {
200
+ const out = {
201
+ filesScanned: args.files.length,
202
+ blocksConsidered: 0,
203
+ shortBlocks: 0,
204
+ blocksWithTier1Candidates: 0,
205
+ blocksWithoutCandidates: 0,
206
+ estimatedPass1Calls: 0,
207
+ estimatedPass2Calls: 0,
208
+ estimatedCreationCalls: 0,
209
+ estimatedTokens: 0,
210
+ };
211
+ for (const file of args.files) {
212
+ let blocks;
213
+ try {
214
+ blocks = extractBlocks(args.repoRoot, file);
215
+ }
216
+ catch {
217
+ continue;
218
+ }
219
+ for (const block of blocks) {
220
+ out.blocksConsidered += 1;
221
+ if (block.prose.length < MIN_BLOCK_PROSE_LEN) {
222
+ out.shortBlocks += 1;
223
+ continue;
224
+ }
225
+ const blockTokens = tokenize(block.prose, { codeAware: true });
226
+ if (blockTokens.size < MIN_BLOCK_TOKEN_COUNT) {
227
+ out.shortBlocks += 1;
228
+ continue;
229
+ }
230
+ const candidates = topKCandidates(blockTokens, args.cacheEntries, TIER2_JACCARD_FLOOR, TOP_K_CANDIDATES);
231
+ if (candidates.length === 0) {
232
+ out.blocksWithoutCandidates += 1;
233
+ if (!args.skipCreation) {
234
+ // Tier 3 creation: ~1 P1 call + ~5% P2 escalation.
235
+ out.estimatedPass1Calls += 1;
236
+ out.estimatedPass2Calls += 0.05;
237
+ out.estimatedCreationCalls += 1;
238
+ }
239
+ continue;
240
+ }
241
+ out.blocksWithTier1Candidates += 1;
242
+ // Tier 2 dedup: at most pass1Cap P1 calls per block, but
243
+ // typically the first candidate matches → average ~1 P1 call.
244
+ const expectedP1 = Math.min(candidates.length, Math.max(1, args.pass1Cap));
245
+ const avgP1 = Math.min(expectedP1, 2); // empirical avg
246
+ out.estimatedPass1Calls += avgP1;
247
+ out.estimatedPass2Calls += avgP1 * PASS2_FRACTION_ESTIMATE;
248
+ }
249
+ }
250
+ out.estimatedPass1Calls = Math.ceil(out.estimatedPass1Calls);
251
+ out.estimatedPass2Calls = Math.ceil(out.estimatedPass2Calls);
252
+ out.estimatedTokens =
253
+ out.estimatedPass1Calls * TOKENS_PER_PASS1_CALL +
254
+ out.estimatedPass2Calls * TOKENS_PER_PASS2_CALL +
255
+ out.estimatedCreationCalls * TOKENS_PER_CREATION_CALL;
256
+ return out;
257
+ }
258
+ //# sourceMappingURL=run.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run.js","sourceRoot":"","sources":["../../src/fix-align/run.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAChD,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EACL,YAAY,EACZ,YAAY,GAEb,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,SAAS,EAA4C,MAAM,iCAAiC,CAAC;AACtG,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,aAAa,EACb,cAAc,EACd,cAAc,GACf,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAE9C,MAAM,GAAG,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC;AAEhC,gFAAgF;AAChF,gFAAgF;AAChF,gFAAgF;AAEhF,MAAM,eAAe,GAAG,GAAG,CAAC;AAC5B,MAAM,eAAe,GAAG,EAAE,CAAC;AAC3B,MAAM,uBAAuB,GAAG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CAAC;oBAC7B,GAAG,CAAC,mBAAmB,IAAI,IAAI,CAAC;oBAChC,GAAG,CAAC,sBAAsB,IAAI,CAAC,CAAC;gBAClC,CAAC;gBACD,SAAS;YACX,CAAC;YACD,GAAG,CAAC,yBAAyB,IAAI,CAAC,CAAC;YACnC,yDAAyD;YACzD,8DAA8D;YAC9D,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;YAC3E,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,CAAC,gBAAgB;YACvD,GAAG,CAAC,mBAAmB,IAAI,KAAK,CAAC;YACjC,GAAG,CAAC,mBAAmB,IAAI,KAAK,GAAG,uBAAuB,CAAC;QAC7D,CAAC;IACH,CAAC;IAED,GAAG,CAAC,mBAAmB,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;IAC7D,GAAG,CAAC,mBAAmB,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;IAC7D,GAAG,CAAC,eAAe;QACjB,GAAG,CAAC,mBAAmB,GAAG,qBAAqB;YAC/C,GAAG,CAAC,mBAAmB,GAAG,qBAAqB;YAC/C,GAAG,CAAC,sBAAsB,GAAG,wBAAwB,CAAC;IAExD,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Alignment-pending queue writer — used by Layer A (PostToolUse hook,
3
+ * pass-2-still-ambiguous + tier3-ambiguous paths) and Layer C
4
+ * (SessionStart drain, Haiku-judge-ambiguous path).
5
+ *
6
+ * The cairn-attention skill renders the file with side-by-side prose
7
+ * and an AskUserQuestion four-option pick. The filename is a content
8
+ * fingerprint slug so re-running with the same prose is idempotent.
9
+ */
10
+ import type { CommentBlock } from "../init/source-comments/index.js";
11
+ export type AlignmentPendingKind = "tier2-ambiguous" | "tier3-ambiguous";
12
+ export interface WriteAlignmentPendingArgs {
13
+ repoRoot: string;
14
+ block: CommentBlock;
15
+ kind: AlignmentPendingKind;
16
+ /** Existing entity id (Tier 2 paths only). */
17
+ existingId?: string;
18
+ /** Existing entity body (Tier 2 paths only). */
19
+ existingBody?: string;
20
+ /**
21
+ * Detector tag stamped into frontmatter — distinguishes Layer A
22
+ * (`layer-a-pass2-ambiguous`) from Layer C (`layer-c-drain-ambiguous`).
23
+ * Defaults to the Layer A detector for back-compat with the existing
24
+ * `tier3-ambiguous` smoke fixtures.
25
+ */
26
+ detector?: string;
27
+ }
28
+ export declare function writeAlignmentPending(args: WriteAlignmentPendingArgs): string;
@@ -0,0 +1,83 @@
1
+ /**
2
+ * Alignment-pending queue writer — used by Layer A (PostToolUse hook,
3
+ * pass-2-still-ambiguous + tier3-ambiguous paths) and Layer C
4
+ * (SessionStart drain, Haiku-judge-ambiguous path).
5
+ *
6
+ * The cairn-attention skill renders the file with side-by-side prose
7
+ * and an AskUserQuestion four-option pick. The filename is a content
8
+ * fingerprint slug so re-running with the same prose is idempotent.
9
+ */
10
+ import { existsSync, mkdirSync, writeFileSync } from "node:fs";
11
+ import { join } from "node:path";
12
+ import { stringify as stringifyYaml } from "yaml";
13
+ import { alignmentPendingDir } from "./paths.js";
14
+ import { topicSlug } from "./slug.js";
15
+ export function writeAlignmentPending(args) {
16
+ const { repoRoot, block, kind } = args;
17
+ const detector = args.detector ?? "layer-a-pass2-ambiguous";
18
+ const dir = alignmentPendingDir(repoRoot);
19
+ mkdirSync(dir, { recursive: true });
20
+ const slug = topicSlug(block.prose);
21
+ const filename = `${slug}.md`;
22
+ const abs = join(dir, filename);
23
+ if (existsSync(abs))
24
+ return `.cairn/ground/alignment-pending/${filename}`;
25
+ const now = new Date().toISOString();
26
+ const fm = {
27
+ slug,
28
+ kind,
29
+ source_file: block.file,
30
+ source_range: `${block.startLine}-${block.endLine}`,
31
+ start_line: block.startLine,
32
+ end_line: block.endLine,
33
+ start_offset: block.startOffset,
34
+ end_offset: block.endOffset,
35
+ lang: block.lang,
36
+ raw: block.raw,
37
+ detected_at: now,
38
+ detector,
39
+ severity: "soft",
40
+ };
41
+ if (args.existingId !== undefined)
42
+ fm["existing_id"] = args.existingId;
43
+ const lines = [];
44
+ lines.push("---");
45
+ lines.push(stringifyYaml(fm).trimEnd());
46
+ lines.push("---");
47
+ lines.push("");
48
+ lines.push(`# Alignment pending — ${slug} (${kind})`);
49
+ lines.push("");
50
+ lines.push(`## Block (just written at \`${block.file}:${block.startLine}-${block.endLine}\`)`);
51
+ lines.push("");
52
+ lines.push("```");
53
+ lines.push(block.prose.trim());
54
+ lines.push("```");
55
+ lines.push("");
56
+ if (args.existingId !== undefined && args.existingBody !== undefined) {
57
+ lines.push(`## Existing ${args.existingId}`);
58
+ lines.push("");
59
+ lines.push("```");
60
+ lines.push(args.existingBody.trim());
61
+ lines.push("```");
62
+ lines.push("");
63
+ }
64
+ lines.push("## How to resolve");
65
+ lines.push("");
66
+ if (kind === "tier2-ambiguous") {
67
+ lines.push("Pass 2 dedup judge returned ambiguous. cairn-attention will surface");
68
+ lines.push("a side-by-side render with `[a] same` / `[b] different` /");
69
+ lines.push("`[c] augments` / `[d] leave for later` choices via");
70
+ lines.push("`cairn_resolve_attention({ kind: \"alignment_pending\", ... })`.");
71
+ }
72
+ else {
73
+ lines.push("Pass 2 creation judge could not classify the block as");
74
+ lines.push("decision / constraint / descriptive. cairn-attention will");
75
+ lines.push("surface `[a] decision` / `[b] constraint` / `[c] descriptive` /");
76
+ lines.push("`[d] leave for later` via");
77
+ lines.push("`cairn_resolve_attention({ kind: \"alignment_pending\", ... })`.");
78
+ }
79
+ lines.push("");
80
+ writeFileSync(abs, lines.join("\n"), "utf8");
81
+ return `.cairn/ground/alignment-pending/${filename}`;
82
+ }
83
+ //# sourceMappingURL=alignment-pending.js.map
@@ -0,0 +1 @@
1
+ {"version":3,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→ location index for sot_kind=path
4
+ * DECs. Operator's docs stay pristine: no `<!-- cairn-anchor: … -->`
5
+ * comments are injected. When the operator renames a heading or moves a
6
+ * paragraph, the anchor-map updates and §DEC-<hash> tokens stay valid
7
+ * because they resolve through this map, not the literal heading slug.
8
+ */
9
+ export declare function emptyAnchorMap(): AnchorMap;
10
+ export declare function readAnchorMap(repoRoot: string): AnchorMap;
11
+ export declare function writeAnchorMap(repoRoot: string, map: AnchorMap): string;
12
+ export declare function setAnchor(map: AnchorMap, slug: string, entry: AnchorMapEntry): AnchorMap;
13
+ export declare function getAnchor(map: AnchorMap, slug: string): AnchorMapEntry | null;
14
+ export declare function deleteAnchor(map: AnchorMap, slug: string): AnchorMap;
@@ -0,0 +1,57 @@
1
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
2
+ import { dirname } from "node:path";
3
+ import { parse as parseYaml, stringify as stringifyYaml } from "yaml";
4
+ import { logger } from "../logger.js";
5
+ import { anchorMapPath } from "./paths.js";
6
+ import { AnchorMap } from "./schemas.js";
7
+ const log = logger("ground.anchor-map");
8
+ /**
9
+ * Anchor-map is the external slug → location index for sot_kind=path
10
+ * DECs. Operator's docs stay pristine: no `<!-- cairn-anchor: … -->`
11
+ * comments are injected. When the operator renames a heading or moves a
12
+ * paragraph, the anchor-map updates and §DEC-<hash> tokens stay valid
13
+ * because they resolve through this map, not the literal heading slug.
14
+ */
15
+ export function emptyAnchorMap() {
16
+ return { version: 1, generated: new Date().toISOString(), anchors: {} };
17
+ }
18
+ export function readAnchorMap(repoRoot) {
19
+ const path = anchorMapPath(repoRoot);
20
+ if (!existsSync(path))
21
+ return emptyAnchorMap();
22
+ try {
23
+ const raw = readFileSync(path, "utf8");
24
+ const parsed = AnchorMap.safeParse(parseYaml(raw));
25
+ if (!parsed.success) {
26
+ log.warn({ path, error: parsed.error.message }, "anchor-map invalid; treating as empty");
27
+ return emptyAnchorMap();
28
+ }
29
+ return parsed.data;
30
+ }
31
+ catch (err) {
32
+ log.warn({ path, err }, "anchor-map read failed; treating as empty");
33
+ return emptyAnchorMap();
34
+ }
35
+ }
36
+ export function writeAnchorMap(repoRoot, map) {
37
+ const path = anchorMapPath(repoRoot);
38
+ mkdirSync(dirname(path), { recursive: true });
39
+ const next = { ...map, generated: new Date().toISOString() };
40
+ writeFileSync(path, stringifyYaml(next), "utf8");
41
+ log.debug({ path, anchors: Object.keys(next.anchors).length }, "wrote anchor-map");
42
+ return path;
43
+ }
44
+ export function setAnchor(map, slug, entry) {
45
+ return { ...map, anchors: { ...map.anchors, [slug]: entry } };
46
+ }
47
+ export function getAnchor(map, slug) {
48
+ return map.anchors[slug] ?? null;
49
+ }
50
+ export function deleteAnchor(map, slug) {
51
+ if (map.anchors[slug] === undefined)
52
+ return map;
53
+ const anchors = { ...map.anchors };
54
+ delete anchors[slug];
55
+ return { ...map, anchors };
56
+ }
57
+ //# sourceMappingURL=anchor-map.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"anchor-map.js","sourceRoot":"","sources":["../../src/ground/anchor-map.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,SAAS,IAAI,aAAa,EAAE,MAAM,MAAM,CAAC;AACtE,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAuB,MAAM,cAAc,CAAC;AAE9D,MAAM,GAAG,GAAG,MAAM,CAAC,mBAAmB,CAAC,CAAC;AAExC;;;;;;GAMG;AAEH,MAAM,UAAU,cAAc;IAC5B,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,EAAE,OAAO,E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AAO,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE,kBAAkB,CAAC,CAAC;IACnF,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,GAAc,EAAE,IAAY,EAAE,KAAqB;IAC3E,OAAO,EAAE,GAAG,GAAG,EAAE,OAAO,EAAE,EAAE,GAAG,GAAG,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC;AAChE,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,GAAc,EAAE,IAAY;IACpD,OAAO,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC;AACnC,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,GAAc,EAAE,IAAY;IACvD,IAAI,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,SAAS;QAAE,OAAO,GAAG,CAAC;IAChD,MAAM,OAAO,GAAG,EAAE,GAAG,GAAG,CAAC,OAAO,EAAE,CAAC;IACnC,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC;IACrB,OAAO,EAAE,GAAG,GAAG,EAAE,OAAO,EAAE,CAAC;AAC7B,CAAC"}
@@ -1,4 +1,4 @@
1
- export { CANONICAL_GLOBS, CANONICAL_EXCLUDES, decisionsDir, decisionsLedgerPath, groundDir, invariantsDir, invariantsLedgerPath, manifestPath, qualityGradesPath, runsTerminalDir, stalenessCurrentPath, stalenessDir, stalenessLogPath, } from "./paths.js";
1
+ export { CANONICAL_GLOBS, CANONICAL_EXCLUDES, alignmentPendingDir, anchorMapPath, archivedConflictsDir, conflictsDir, decisionsDir, decisionsLedgerPath, groundDir, haikuCacheDir, invariantsDir, invariantsLedgerPath, manifestPath, qualityGradesPath, runsTerminalDir, sotBindingsPath, sotCachePath, sotRenderedCacheDir, layerADeferredLogPath, preCommitDeferredLogPath, stalenessCurrentPath, stalenessDir, stalenessLogPath, topicIndexPath, } from "./paths.js";
2
2
  export { matchGlob, matchAnyGlob, compileGlob } from "./glob.js";
3
3
  export { walkCanonical } from "./walk.js";
4
4
  export { parseFrontmatter, readFrontmatter, evaluateFreshness } from "./frontmatter.js";
@@ -9,8 +9,15 @@ export { buildDecisionsLedger, buildInvariantsLedger, writeDecisionsLedger, writ
9
9
  export type { LedgerOptions } from "./ledgers.js";
10
10
  export { recordDriftEvent, writeDriftSnapshot } from "./drift.js";
11
11
  export type { DriftSnapshot } from "./drift.js";
12
+ export { writeAlignmentPending } from "./alignment-pending.js";
13
+ export type { AlignmentPendingKind, WriteAlignmentPendingArgs, } from "./alignment-pending.js";
12
14
  export { buildQualityGrades, writeQualityGrades } from "./quality-grades.js";
13
15
  export type { QualityGradesOptions } from "./quality-grades.js";
14
16
  export { coerceDecisionIds, coerceInvariantIds, lookupScope, readScopeIndex, rebuildScopeIndex, rescanScopeIndex, scopeIndexPath, writeScopeIndex, } from "./scope-index.js";
15
17
  export type { RebuildScopeIndexOptions, RebuildScopeIndexResult, RescanScopeIndexResult, ScopeIndex, ScopeIndexEntry, } from "./scope-index.js";
16
- export { Audience, ProvenanceFrontmatter, ManifestEntry, Manifest, DecisionAssertion, DecisionFrontmatter, InvariantFrontmatter, DecisionLedgerEntry, InvariantLedgerEntry, QualityGrade, QualityGrades, DriftEvent, } from "./schemas.js";
18
+ export { AnchorMap, AnchorMapEntry, Audience, ProvenanceFrontmatter, ManifestEntry, Manifest, DecisionAssertion, DecisionFrontmatter, InvariantFrontmatter, DecisionLedgerEntry, InvariantLedgerEntry, QualityGrade, QualityGrades, DriftEvent, PreCommitDriftCandidate, PreCommitDriftLogEntry, SotBindings, SotCache, SotCacheEntry, SotKind, TopicIndex, TopicIndexEntry, } from "./schemas.js";
19
+ export { bindDec, decsForPath, emptySotBindings, pathForDec, readSotBindings, unbindDec, writeSotBindings, } from "./sot-bindings.js";
20
+ export { emptyTopicIndex, getTopic, readTopicIndex, setTopic, writeTopicIndex, } from "./topic-index.js";
21
+ export { deleteEntry as deleteSotCacheEntry, emptySotCache, entries as sotCacheEntries, getEntry as getSotCacheEntry, readSotCache, setEntry as setSotCacheEntry, writeSotCache, } from "./sot-cache.js";
22
+ export { deleteAnchor, emptyAnchorMap, getAnchor, readAnchorMap, setAnchor, writeAnchorMap, } from "./anchor-map.js";
23
+ export { bodyContentHash, deriveDecId, deriveInvId, deriveLedgerDecId, deriveLedgerInvId, normalizeBlock, topicSlug, } from "./slug.js";
@@ -1,11 +1,17 @@
1
- export { CANONICAL_GLOBS, CANONICAL_EXCLUDES, decisionsDir, decisionsLedgerPath, groundDir, invariantsDir, invariantsLedgerPath, manifestPath, qualityGradesPath, runsTerminalDir, stalenessCurrentPath, stalenessDir, stalenessLogPath, } from "./paths.js";
1
+ export { CANONICAL_GLOBS, CANONICAL_EXCLUDES, alignmentPendingDir, anchorMapPath, archivedConflictsDir, conflictsDir, decisionsDir, decisionsLedgerPath, groundDir, haikuCacheDir, invariantsDir, invariantsLedgerPath, manifestPath, qualityGradesPath, runsTerminalDir, sotBindingsPath, sotCachePath, sotRenderedCacheDir, layerADeferredLogPath, preCommitDeferredLogPath, stalenessCurrentPath, stalenessDir, stalenessLogPath, topicIndexPath, } from "./paths.js";
2
2
  export { matchGlob, matchAnyGlob, compileGlob } from "./glob.js";
3
3
  export { walkCanonical } from "./walk.js";
4
4
  export { parseFrontmatter, readFrontmatter, evaluateFreshness } from "./frontmatter.js";
5
5
  export { buildManifest, writeManifest } from "./manifest.js";
6
6
  export { buildDecisionsLedger, buildInvariantsLedger, writeDecisionsLedger, writeInvariantsLedger, } from "./ledgers.js";
7
7
  export { recordDriftEvent, writeDriftSnapshot } from "./drift.js";
8
+ export { writeAlignmentPending } from "./alignment-pending.js";
8
9
  export { buildQualityGrades, writeQualityGrades } from "./quality-grades.js";
9
10
  export { coerceDecisionIds, coerceInvariantIds, lookupScope, readScopeIndex, rebuildScopeIndex, rescanScopeIndex, scopeIndexPath, writeScopeIndex, } from "./scope-index.js";
10
- export { Audience, ProvenanceFrontmatter, ManifestEntry, Manifest, DecisionAssertion, DecisionFrontmatter, InvariantFrontmatter, DecisionLedgerEntry, InvariantLedgerEntry, QualityGrade, QualityGrades, DriftEvent, } from "./schemas.js";
11
+ export { AnchorMap, AnchorMapEntry, Audience, ProvenanceFrontmatter, ManifestEntry, Manifest, DecisionAssertion, DecisionFrontmatter, InvariantFrontmatter, DecisionLedgerEntry, InvariantLedgerEntry, QualityGrade, QualityGrades, DriftEvent, PreCommitDriftCandidate, PreCommitDriftLogEntry, SotBindings, SotCache, SotCacheEntry, SotKind, TopicIndex, TopicIndexEntry, } from "./schemas.js";
12
+ export { bindDec, decsForPath, emptySotBindings, pathForDec, readSotBindings, unbindDec, writeSotBindings, } from "./sot-bindings.js";
13
+ export { emptyTopicIndex, getTopic, readTopicIndex, setTopic, writeTopicIndex, } from "./topic-index.js";
14
+ export { deleteEntry as deleteSotCacheEntry, emptySotCache, entries as sotCacheEntries, getEntry as getSotCacheEntry, readSotCache, setEntry as setSotCacheEntry, writeSotCache, } from "./sot-cache.js";
15
+ export { deleteAnchor, emptyAnchorMap, getAnchor, readAnchorMap, setAnchor, writeAnchorMap, } from "./anchor-map.js";
16
+ export { bodyContentHash, deriveDecId, deriveInvId, deriveLedgerDecId, deriveLedgerInvId, normalizeBlock, topicSlug, } from "./slug.js";
11
17
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ground/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,YAAY,EACZ,mBAAmB,EACnB,SAAS,EACT,aAAa,EACb,oBAAoB,EACpB,YAAY,EACZ,iBAAiB,EACjB,eAAe,EACf,oBAAoB,EACpB,YAAY,EACZ,gBAAgB,GACjB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAExF,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE7D,OAAO,EACL,oBAAoB,EACpB,qBAAqB,EACrB,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAElE,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAE7E,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,WAAW,EACX,cAAc,EACd,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,EACd,eAAe,GAChB,MAAM,kBAAkB,CAAC;AAQ1B,OAAO,EACL,QAAQ,EACR,qBAAqB,EACrB,aAAa,EACb,QAAQ,EACR,iBAAiB,EACjB,mBAAmB,EACnB,oBAAoB,EACpB,mBAAmB,EACnB,oBAAoB,EACpB,YAAY,EACZ,aAAa,EACb,UAAU,GACX,MAAM,cAAc,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ground/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,mBAAmB,EACnB,aAAa,EACb,oBAAoB,EACpB,YAAY,EACZ,YAAY,EACZ,mBAAmB,EACnB,SAAS,EACT,aAAa,EACb,aAAa,EACb,oBAAoB,EACpB,YAAY,EACZ,iBAAiB,EACjB,eAAe,EACf,eAAe,EACf,YAAY,EACZ,mBAAmB,EACnB,qBAAqB,EACrB,wBAAwB,EACxB,oBAAoB,EACpB,YAAY,EACZ,gBAAgB,EAChB,cAAc,GACf,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACjE,OAAO,EAAE,aA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Y,EACZ,QAAQ,IAAI,gBAAgB,EAC5B,aAAa,GACd,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,YAAY,EACZ,cAAc,EACd,SAAS,EACT,aAAa,EACb,SAAS,EACT,cAAc,GACf,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,eAAe,EACf,WAAW,EACX,WAAW,EACX,iBAAiB,EACjB,iBAAiB,EACjB,cAAc,EACd,SAAS,GACV,MAAM,WAAW,CAAC"}
@@ -14,7 +14,28 @@ export declare function invariantsDir(repoRoot: string): string;
14
14
  export declare function decisionsLedgerPath(repoRoot: string): string;
15
15
  export declare function invariantsLedgerPath(repoRoot: string): string;
16
16
  export declare function qualityGradesPath(repoRoot: string): string;
17
+ export declare function topicIndexPath(repoRoot: string): string;
18
+ export declare function sotBindingsPath(repoRoot: string): string;
19
+ export declare function sotCachePath(repoRoot: string): string;
20
+ export declare function anchorMapPath(repoRoot: string): string;
21
+ export declare function conflictsDir(repoRoot: string): string;
22
+ export declare function archivedConflictsDir(repoRoot: string): string;
23
+ export declare function alignmentPendingDir(repoRoot: string): string;
24
+ export declare function sotRenderedCacheDir(repoRoot: string): string;
25
+ export declare function haikuCacheDir(repoRoot: string): string;
17
26
  export declare function stalenessDir(repoRoot: string): string;
18
27
  export declare function stalenessLogPath(repoRoot: string): string;
19
28
  export declare function stalenessCurrentPath(repoRoot: string): string;
29
+ /**
30
+ * Layer A live-hook deferred-block log. PostToolUse Write/Edit appends
31
+ * one rich record per block when the per-Write Haiku cap is exceeded
32
+ * or Pass-2-still-ambiguous fires. Drained by Layer C at SessionStart.
33
+ */
34
+ export declare function layerADeferredLogPath(repoRoot: string): string;
35
+ /**
36
+ * Layer B pre-commit-drift rich log. Git pre-commit hook appends one
37
+ * record per prose block discovered in staged content. Drained by
38
+ * Layer C at SessionStart.
39
+ */
40
+ export declare function preCommitDeferredLogPath(repoRoot: string): string;
20
41
  export declare function runsTerminalDir(repoRoot: string): string;
@@ -45,6 +45,33 @@ export function invariantsLedgerPath(repoRoot) {
45
45
  export function qualityGradesPath(repoRoot) {
46
46
  return join(groundDir(repoRoot), "quality-grades.yaml");
47
47
  }
48
+ export function topicIndexPath(repoRoot) {
49
+ return join(groundDir(repoRoot), "topic-index.yaml");
50
+ }
51
+ export function sotBindingsPath(repoRoot) {
52
+ return join(groundDir(repoRoot), "sot-bindings.yaml");
53
+ }
54
+ export function sotCachePath(repoRoot) {
55
+ return join(groundDir(repoRoot), "sot-cache.yaml");
56
+ }
57
+ export function anchorMapPath(repoRoot) {
58
+ return join(groundDir(repoRoot), "anchor-map.yaml");
59
+ }
60
+ export function conflictsDir(repoRoot) {
61
+ return join(groundDir(repoRoot), "conflicts");
62
+ }
63
+ export function archivedConflictsDir(repoRoot) {
64
+ return join(conflictsDir(repoRoot), "_archived");
65
+ }
66
+ export function alignmentPendingDir(repoRoot) {
67
+ return join(groundDir(repoRoot), "alignment-pending");
68
+ }
69
+ export function sotRenderedCacheDir(repoRoot) {
70
+ return join(repoRoot, ".cairn", "cache", "sot-rendered");
71
+ }
72
+ export function haikuCacheDir(repoRoot) {
73
+ return join(repoRoot, ".cairn", "cache", "haiku");
74
+ }
48
75
  export function stalenessDir(repoRoot) {
49
76
  return join(repoRoot, ".cairn", "staleness");
50
77
  }
@@ -54,6 +81,22 @@ export function stalenessLogPath(repoRoot) {
54
81
  export function stalenessCurrentPath(repoRoot) {
55
82
  return join(stalenessDir(repoRoot), "current.json");
56
83
  }
84
+ /**
85
+ * Layer A live-hook deferred-block log. PostToolUse Write/Edit appends
86
+ * one rich record per block when the per-Write Haiku cap is exceeded
87
+ * or Pass-2-still-ambiguous fires. Drained by Layer C at SessionStart.
88
+ */
89
+ export function layerADeferredLogPath(repoRoot) {
90
+ return join(stalenessDir(repoRoot), "layer-a-deferred.jsonl");
91
+ }
92
+ /**
93
+ * Layer B pre-commit-drift rich log. Git pre-commit hook appends one
94
+ * record per prose block discovered in staged content. Drained by
95
+ * Layer C at SessionStart.
96
+ */
97
+ export function preCommitDeferredLogPath(repoRoot) {
98
+ return join(stalenessDir(repoRoot), "pre-commit-deferred.jsonl");
99
+ }
57
100
  export function runsTerminalDir(repoRoot) {
58
101
  return join(repoRoot, ".cairn", "runs", "terminal");
59
102
  }
@@ -1 +1 @@
1
- {"version":3,"file":"paths.js","sourceRoot":"","sources":["../../src/ground/paths.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,WAAW;IACX,WAAW;IACX,wBAAwB;IACxB,wBAAwB;IACxB,uBAAuB;IACvB,cAAc;IACd,oBAAoB;IACpB,oBAAoB;IACpB,0BAA0B;CAC3B,CAAC;AAEF,8DAA8D;AAC9D,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,mCAAmC;IACnC,6BAA6B;IAC7B,+CAA+C;IAC/C,iDAAiD;IACjD,mCAAmC;CACpC,CAAC;AAEF,MAAM,UAAU,SAAS,CAAC,QAAgB;IACxC,OAAO,IAAI,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;AAC5C,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,QAAgB;IAC3C,OAAO,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,eAAe,CAAC,CAAC;AACpD,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,QAAgB;IAC3C,OAAO,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,WAAW,CAAC,CAAC;AAChD,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,QAAgB;IAC5C,OAAO,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,YAAY,CAAC,CAAC;AACjD,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,QAAgB;IAClD,OAAO,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,EAAE,uBAAuB,CAAC,CAAC;AAC/D,CAAC;AAED,MAAM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