@isaacriehm/cairn-core 0.8.0 → 0.9.2

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 (143) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/attention/bulk-accept.d.ts +0 -2
  3. package/dist/attention/bulk-accept.js +0 -3
  4. package/dist/attention/bulk-accept.js.map +1 -1
  5. package/dist/attention/scoring.d.ts +1 -3
  6. package/dist/attention/scoring.js +1 -12
  7. package/dist/attention/scoring.js.map +1 -1
  8. package/dist/claude/cache.js +1 -0
  9. package/dist/claude/cache.js.map +1 -1
  10. package/dist/claude/runner.js +25 -1
  11. package/dist/claude/runner.js.map +1 -1
  12. package/dist/claude/types.d.ts +8 -0
  13. package/dist/hooks/runners/payload.d.ts +10 -0
  14. package/dist/hooks/runners/payload.js +13 -0
  15. package/dist/hooks/runners/payload.js.map +1 -1
  16. package/dist/hooks/runners/session-end.js +2 -4
  17. package/dist/hooks/runners/session-end.js.map +1 -1
  18. package/dist/hooks/runners/session-start.js +48 -4
  19. package/dist/hooks/runners/session-start.js.map +1 -1
  20. package/dist/init/brand-derive.js +6 -1
  21. package/dist/init/brand-derive.js.map +1 -1
  22. package/dist/init/brand-setup.d.ts +12 -1
  23. package/dist/init/brand-setup.js +36 -1
  24. package/dist/init/brand-setup.js.map +1 -1
  25. package/dist/init/curator/corpus.d.ts +92 -0
  26. package/dist/init/curator/corpus.js +171 -0
  27. package/dist/init/curator/corpus.js.map +1 -0
  28. package/dist/init/curator/emit.d.ts +42 -0
  29. package/dist/init/curator/emit.js +230 -0
  30. package/dist/init/curator/emit.js.map +1 -0
  31. package/dist/init/curator/index.d.ts +1 -0
  32. package/dist/init/curator/index.js +2 -0
  33. package/dist/init/curator/index.js.map +1 -0
  34. package/dist/init/curator/regex-prefilter.d.ts +54 -0
  35. package/dist/init/curator/regex-prefilter.js +185 -0
  36. package/dist/init/curator/regex-prefilter.js.map +1 -0
  37. package/dist/init/curator/validate.d.ts +46 -0
  38. package/dist/init/curator/validate.js +100 -0
  39. package/dist/init/curator/validate.js.map +1 -0
  40. package/dist/init/curator/walker.d.ts +36 -0
  41. package/dist/init/curator/walker.js +380 -0
  42. package/dist/init/curator/walker.js.map +1 -0
  43. package/dist/init/eta-calibration.d.ts +39 -0
  44. package/dist/init/eta-calibration.js +143 -0
  45. package/dist/init/eta-calibration.js.map +1 -0
  46. package/dist/init/index.d.ts +3 -2
  47. package/dist/init/index.js +2 -1
  48. package/dist/init/index.js.map +1 -1
  49. package/dist/init/init.js +4 -20
  50. package/dist/init/init.js.map +1 -1
  51. package/dist/init/mapper-merge.d.ts +4 -6
  52. package/dist/init/mapper-merge.js +11 -34
  53. package/dist/init/mapper-merge.js.map +1 -1
  54. package/dist/init/mapper-parallel.d.ts +0 -1
  55. package/dist/init/mapper-parallel.js +7 -6
  56. package/dist/init/mapper-parallel.js.map +1 -1
  57. package/dist/init/mapper-prompts.d.ts +1 -4
  58. package/dist/init/mapper-prompts.js +2 -6
  59. package/dist/init/mapper-prompts.js.map +1 -1
  60. package/dist/init/mapper.d.ts +8 -7
  61. package/dist/init/mapper.js +23 -15
  62. package/dist/init/mapper.js.map +1 -1
  63. package/dist/init/overlay.js +0 -1
  64. package/dist/init/overlay.js.map +1 -1
  65. package/dist/init/phases/10-rules-merge.d.ts +7 -2
  66. package/dist/init/phases/10-rules-merge.js +18 -45
  67. package/dist/init/phases/10-rules-merge.js.map +1 -1
  68. package/dist/init/phases/13-multidev.d.ts +5 -1
  69. package/dist/init/phases/13-multidev.js +23 -2
  70. package/dist/init/phases/13-multidev.js.map +1 -1
  71. package/dist/init/phases/4-seed.js +1 -2
  72. package/dist/init/phases/4-seed.js.map +1 -1
  73. package/dist/init/phases/5-preflight.d.ts +42 -0
  74. package/dist/init/phases/5-preflight.js +244 -0
  75. package/dist/init/phases/5-preflight.js.map +1 -0
  76. package/dist/init/phases/7-topic-index.d.ts +6 -0
  77. package/dist/init/phases/7-topic-index.js +13 -0
  78. package/dist/init/phases/7-topic-index.js.map +1 -1
  79. package/dist/init/phases/8-docs-ingest.d.ts +6 -5
  80. package/dist/init/phases/8-docs-ingest.js +17 -56
  81. package/dist/init/phases/8-docs-ingest.js.map +1 -1
  82. package/dist/init/phases/9a-walker.d.ts +15 -0
  83. package/dist/init/phases/9a-walker.js +63 -0
  84. package/dist/init/phases/9a-walker.js.map +1 -0
  85. package/dist/init/phases/9b-curate.d.ts +19 -0
  86. package/dist/init/phases/9b-curate.js +79 -0
  87. package/dist/init/phases/9b-curate.js.map +1 -0
  88. package/dist/init/phases/9c-emit.d.ts +13 -0
  89. package/dist/init/phases/9c-emit.js +57 -0
  90. package/dist/init/phases/9c-emit.js.map +1 -0
  91. package/dist/init/phases/index.d.ts +6 -5
  92. package/dist/init/phases/index.js +4 -4
  93. package/dist/init/phases/index.js.map +1 -1
  94. package/dist/init/phases/mapper-output-io.d.ts +5 -5
  95. package/dist/init/phases/mapper-output-io.js +5 -5
  96. package/dist/init/phases/orchestrator.js +1 -1
  97. package/dist/init/phases/state-io.js +1 -1
  98. package/dist/init/phases/types.d.ts +79 -13
  99. package/dist/init/phases/types.js +4 -2
  100. package/dist/init/phases/types.js.map +1 -1
  101. package/dist/init/source-comments/ingest.d.ts +0 -2
  102. package/dist/init/source-comments/ingest.js.map +1 -1
  103. package/dist/init/source-comments/walker.js +2 -2
  104. package/dist/init/topic-index/index.d.ts +8 -0
  105. package/dist/init/topic-index/index.js +10 -2
  106. package/dist/init/topic-index/index.js.map +1 -1
  107. package/dist/init/topic-index/judge.d.ts +15 -0
  108. package/dist/init/topic-index/judge.js +15 -1
  109. package/dist/init/topic-index/judge.js.map +1 -1
  110. package/dist/init/topic-index/resolve.js +41 -14
  111. package/dist/init/topic-index/resolve.js.map +1 -1
  112. package/dist/init/walker.d.ts +1 -1
  113. package/dist/init/walker.js +1 -1
  114. package/dist/init/workflow-block.d.ts +5 -6
  115. package/dist/init/workflow-block.js +5 -9
  116. package/dist/init/workflow-block.js.map +1 -1
  117. package/dist/mcp/tools/bulk-accept-attention.d.ts +1 -1
  118. package/dist/mcp/tools/bulk-accept-attention.js +4 -6
  119. package/dist/mcp/tools/bulk-accept-attention.js.map +1 -1
  120. package/dist/mcp/tools/init-phases.d.ts +7 -6
  121. package/dist/mcp/tools/init-phases.js +34 -59
  122. package/dist/mcp/tools/init-phases.js.map +1 -1
  123. package/dist/session-start/build.js +47 -5
  124. package/dist/session-start/build.js.map +1 -1
  125. package/package.json +2 -2
  126. package/templates/.cairn/config/trust-policy.yaml +0 -3
  127. package/templates/.cairn/config/workflow.md +0 -1
  128. package/templates/.cairn/ground/canonical-map/topics.yaml +0 -12
  129. package/dist/init/phases/5-pilot.d.ts +0 -10
  130. package/dist/init/phases/5-pilot.js +0 -108
  131. package/dist/init/phases/5-pilot.js.map +0 -1
  132. package/dist/init/phases/9-source-comments.d.ts +0 -6
  133. package/dist/init/phases/9-source-comments.js +0 -67
  134. package/dist/init/phases/9-source-comments.js.map +0 -1
  135. package/dist/init/phases/parallel-8910.d.ts +0 -27
  136. package/dist/init/phases/parallel-8910.js +0 -197
  137. package/dist/init/phases/parallel-8910.js.map +0 -1
  138. package/dist/init/phases/source-comments-output-io.d.ts +0 -89
  139. package/dist/init/phases/source-comments-output-io.js +0 -81
  140. package/dist/init/phases/source-comments-output-io.js.map +0 -1
  141. package/templates/.cairn/ground/capabilities/mcp-tools.yaml +0 -29
  142. package/templates/.cairn/ground/capabilities/skills.yaml +0 -25
  143. package/templates/.cairn/ground/capabilities/snippets.yaml +0 -29
@@ -0,0 +1,244 @@
1
+ /**
2
+ * Phase 5-preflight — count the units the long Haiku phases will
3
+ * process (markdown paragraphs, essay-class comment blocks, rule
4
+ * sections, jaccard pair estimate), then compute an aggregate ETA
5
+ * by multiplying counts against the per-machine calibration cache.
6
+ *
7
+ * No operator input. Always advances. Output is consumed by the
8
+ * cairn-adopt skill which renders a single banner immediately after
9
+ * this phase so the operator sees an honest pre-commit estimate
10
+ * before the long phases (7-topic-index → 10-rules-merge) start.
11
+ *
12
+ * Pilot scoping is gone — adoption always covers the whole repo.
13
+ * The operator can narrow surface area post-adoption via
14
+ * `cairn scope` if desired.
15
+ */
16
+ import { existsSync, readFileSync, statSync } from "node:fs";
17
+ import { extname, join } from "node:path";
18
+ import { walkFs } from "@isaacriehm/cairn-state";
19
+ import { walkSourceComments } from "../source-comments/walker.js";
20
+ import { discoverRuleSources } from "../rules-merge/discover.js";
21
+ import { parseRuleSections } from "../rules-merge/parse-sections.js";
22
+ import { readCalibration } from "../eta-calibration.js";
23
+ import { advancePhase, isSelfAdoptState } from "./orchestrator.js";
24
+ /** Hard upper bound on jaccard pair-judge calls (matches phase 7 cap). */
25
+ const JACCARD_PAIR_CAP = 200;
26
+ /** Skip dirs for the markdown walk — match the source walker's set. */
27
+ const DOC_SKIP_DIRS = new Set([
28
+ ".git",
29
+ "node_modules",
30
+ "dist",
31
+ "build",
32
+ "target",
33
+ "out",
34
+ "vendor",
35
+ ".venv",
36
+ ".direnv",
37
+ ".cache",
38
+ "coverage",
39
+ ".next",
40
+ ".turbo",
41
+ ".cairn",
42
+ ".archive",
43
+ ]);
44
+ export async function runPhase5Preflight(state) {
45
+ if (isSelfAdoptState(state)) {
46
+ const skipped = {
47
+ units: emptyUnits(),
48
+ eta: zeroEta(),
49
+ bannerLines: ["Self-adopt mode — long phases skipped, no ETA estimate."],
50
+ skipped: "self-adopt",
51
+ };
52
+ const next = {
53
+ ...state,
54
+ outputs: { ...state.outputs, "5-preflight": skipped },
55
+ };
56
+ return {
57
+ status: "complete",
58
+ nextPhase: "6-brand",
59
+ state: advancePhase(next),
60
+ };
61
+ }
62
+ const units = countUnits(state.repoRoot);
63
+ const eta = estimateEta(units);
64
+ const bannerLines = renderBanner(units, eta);
65
+ const out = { units, eta, bannerLines };
66
+ const next = {
67
+ ...state,
68
+ outputs: { ...state.outputs, "5-preflight": out },
69
+ };
70
+ return {
71
+ status: "complete",
72
+ nextPhase: "6-brand",
73
+ state: advancePhase(next),
74
+ };
75
+ }
76
+ function emptyUnits() {
77
+ return {
78
+ docFiles: 0,
79
+ docParagraphs: 0,
80
+ sourceFiles: 0,
81
+ essayBlocks: 0,
82
+ ruleH2Sections: 0,
83
+ jaccardPairsEstimate: 0,
84
+ };
85
+ }
86
+ function zeroEta() {
87
+ return {
88
+ perPhaseSeconds: {
89
+ "7-topic-index": 0,
90
+ "8-docs-ingest": 0,
91
+ "9-source-comments": 0,
92
+ "10-rules-merge": 0,
93
+ },
94
+ totalSeconds: 0,
95
+ totalSecondsHigh: 0,
96
+ };
97
+ }
98
+ function countUnits(repoRoot) {
99
+ const docs = countDocs(repoRoot);
100
+ const source = walkSourceComments({ repoRoot });
101
+ const rules = countRuleH2(repoRoot);
102
+ // Conservative jaccard pair estimate — phase 7 caps at 200 and the
103
+ // hit rate on monorepos saturates quickly. Below 50 paragraphs, every
104
+ // pair counts; above, assume the cap.
105
+ const jaccardPairsEstimate = docs.paragraphs <= 50
106
+ ? (docs.paragraphs * (docs.paragraphs - 1)) / 2
107
+ : JACCARD_PAIR_CAP;
108
+ return {
109
+ docFiles: docs.files,
110
+ docParagraphs: docs.paragraphs,
111
+ sourceFiles: source.fileCountByLang
112
+ ? Object.values(source.fileCountByLang).reduce((a, b) => a + b, 0)
113
+ : source.files.length,
114
+ essayBlocks: source.blocks.length,
115
+ ruleH2Sections: rules,
116
+ jaccardPairsEstimate: Math.min(JACCARD_PAIR_CAP, Math.round(jaccardPairsEstimate)),
117
+ };
118
+ }
119
+ function countDocs(repoRoot) {
120
+ let files = 0;
121
+ let paragraphs = 0;
122
+ // Repo-root markdown (README.md, CHANGELOG.md, AGENTS.md, etc.).
123
+ for (const name of safeReaddir(repoRoot)) {
124
+ if (!isMarkdown(name))
125
+ continue;
126
+ const abs = join(repoRoot, name);
127
+ const counts = countMarkdownFile(abs);
128
+ if (counts !== null) {
129
+ files += 1;
130
+ paragraphs += counts.paragraphs;
131
+ }
132
+ }
133
+ // docs/ subtree.
134
+ const docsDir = join(repoRoot, "docs");
135
+ if (existsSync(docsDir)) {
136
+ walkFs({
137
+ dir: docsDir,
138
+ repoRoot,
139
+ onDir: (_rel, _abs, ent) => {
140
+ if (DOC_SKIP_DIRS.has(ent.name))
141
+ return false;
142
+ return true;
143
+ },
144
+ onFile: (_rel, abs, ent) => {
145
+ if (!isMarkdown(ent.name))
146
+ return;
147
+ const counts = countMarkdownFile(abs);
148
+ if (counts !== null) {
149
+ files += 1;
150
+ paragraphs += counts.paragraphs;
151
+ }
152
+ },
153
+ });
154
+ }
155
+ return { files, paragraphs };
156
+ }
157
+ function isMarkdown(name) {
158
+ const ext = extname(name).toLowerCase();
159
+ return ext === ".md" || ext === ".mdx";
160
+ }
161
+ function safeReaddir(dir) {
162
+ try {
163
+ const ents = require("node:fs").readdirSync(dir);
164
+ return ents;
165
+ }
166
+ catch {
167
+ return [];
168
+ }
169
+ }
170
+ function countMarkdownFile(absPath) {
171
+ try {
172
+ const stat = statSync(absPath);
173
+ // Skip giant files — phase 8 skips them too in practice (over a few
174
+ // MB the embedding cost dominates and the operator usually wants
175
+ // them excluded).
176
+ if (stat.size > 2 * 1024 * 1024)
177
+ return null;
178
+ const body = readFileSync(absPath, "utf8");
179
+ // Paragraph = run of non-empty lines, separated by blank line(s).
180
+ const paragraphs = body
181
+ .split(/\n\s*\n/)
182
+ .map((p) => p.trim())
183
+ .filter((p) => p.length > 0).length;
184
+ return { paragraphs };
185
+ }
186
+ catch {
187
+ return null;
188
+ }
189
+ }
190
+ function countRuleH2(repoRoot) {
191
+ const sources = discoverRuleSources(repoRoot);
192
+ let total = 0;
193
+ for (const src of sources) {
194
+ try {
195
+ const body = readFileSync(src.absPath, "utf8");
196
+ const sections = parseRuleSections(body);
197
+ // Phase 10 issues one Haiku call per H2 (level 2). H3 sections
198
+ // ride along inside their parent H2's classification, so they
199
+ // don't add to the call count.
200
+ total += sections.filter((s) => s.level === 2).length;
201
+ }
202
+ catch {
203
+ // Unreadable rule file — skip silently; phase 10 will surface it.
204
+ }
205
+ }
206
+ return total;
207
+ }
208
+ function estimateEta(units) {
209
+ const cal = readCalibration();
210
+ const perPhaseSeconds = {
211
+ "7-topic-index": units.jaccardPairsEstimate * cal.phases["7-topic-index"].secondsPerUnit,
212
+ "8-docs-ingest": units.docParagraphs * cal.phases["8-docs-ingest"].secondsPerUnit,
213
+ "9-source-comments": units.essayBlocks * cal.phases["9-source-comments"].secondsPerUnit,
214
+ "10-rules-merge": units.ruleH2Sections * cal.phases["10-rules-merge"].secondsPerUnit,
215
+ };
216
+ const totalSeconds = perPhaseSeconds["7-topic-index"] +
217
+ perPhaseSeconds["8-docs-ingest"] +
218
+ perPhaseSeconds["9-source-comments"] +
219
+ perPhaseSeconds["10-rules-merge"];
220
+ return {
221
+ perPhaseSeconds,
222
+ totalSeconds,
223
+ totalSecondsHigh: totalSeconds * 1.5,
224
+ };
225
+ }
226
+ function renderBanner(units, eta) {
227
+ const totalLow = formatDuration(eta.totalSeconds);
228
+ const totalHigh = formatDuration(eta.totalSecondsHigh);
229
+ const lines = [];
230
+ lines.push(`Indexing whole repo (${units.sourceFiles} source files, ${units.essayBlocks} essay-class comments, ${units.docFiles} docs / ${units.docParagraphs} paragraphs, ${units.ruleH2Sections} rule sections).`);
231
+ lines.push(`Estimated time: ${totalLow}–${totalHigh}. Live ETA on statusline. /exit safe — SessionStart resumes.`);
232
+ return lines;
233
+ }
234
+ function formatDuration(seconds) {
235
+ if (seconds < 60)
236
+ return `${Math.max(1, Math.round(seconds))}s`;
237
+ const mins = Math.round(seconds / 60);
238
+ if (mins < 60)
239
+ return `${mins}m`;
240
+ const hours = Math.floor(mins / 60);
241
+ const remMins = mins % 60;
242
+ return remMins === 0 ? `${hours}h` : `${hours}h${remMins}m`;
243
+ }
244
+ //# sourceMappingURL=5-preflight.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"5-preflight.js","sourceRoot":"","sources":["../../../src/init/phases/5-preflight.ts"],"names":[],"mappings":"AAAA;;;;;;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AAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,cAAc,CAAC,OAAe;IACrC,IAAI,OAAO,GAAG,EAAE;QAAE,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC;IAChE,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,EAAE,CAAC,CAAC;IACtC,IAAI,IAAI,GAAG,EAAE;QAAE,OAAO,GAAG,IAAI,GAAG,CAAC;IACjC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,EAAE,CAAC,CAAC;IACpC,MAAM,OAAO,GAAG,IAAI,GAAG,EAAE,CAAC;IAC1B,OAAO,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,CAAC,CAAC,GAAG,KAAK,IAAI,OAAO,GAAG,CAAC;AAC9D,CAAC"}
@@ -13,6 +13,12 @@ export interface TopicIndexPhaseOutput {
13
13
  verbatim_collisions: number;
14
14
  semantic_collisions: number;
15
15
  judge_calls: number;
16
+ /** Subset of `judge_calls` served from the on-disk Claude cache (no plan-quota burn). */
17
+ judge_calls_cached: number;
18
+ /** Subset of `judge_calls` that spawned a fresh `claude --print` subprocess. */
19
+ judge_calls_fresh: number;
20
+ /** Judge calls that threw (cache write skipped, breaker counter incremented). */
21
+ judge_calls_errors: number;
16
22
  unresolved_ambiguous: number;
17
23
  topic_count: number;
18
24
  topic_index_path: string;
@@ -9,17 +9,30 @@
9
9
  */
10
10
  import { logger } from "../../logger.js";
11
11
  import { buildTopicIndex } from "../topic-index/index.js";
12
+ import { recordSample } from "../eta-calibration.js";
12
13
  import { advancePhase } from "./orchestrator.js";
13
14
  const log = logger("init.phases.7-topic-index");
14
15
  export async function runPhase7TopicIndex(state) {
16
+ const startedAt = performance.now();
15
17
  try {
16
18
  const result = await buildTopicIndex({ repoRoot: state.repoRoot });
19
+ const durationMs = Math.round(performance.now() - startedAt);
20
+ if (result.judgeCalls > 0) {
21
+ recordSample({
22
+ phase: "7-topic-index",
23
+ units: result.judgeCalls,
24
+ durationMs,
25
+ });
26
+ }
17
27
  const topicCount = Object.keys(result.topicIndex.topics).length;
18
28
  const out = {
19
29
  block_count: result.blockCount,
20
30
  verbatim_collisions: result.verbatimCollisions,
21
31
  semantic_collisions: result.semanticCollisions,
22
32
  judge_calls: result.judgeCalls,
33
+ judge_calls_cached: result.judgeCached,
34
+ judge_calls_fresh: result.judgeFresh,
35
+ judge_calls_errors: result.judgeErrors,
23
36
  unresolved_ambiguous: result.unresolvedAmbiguous,
24
37
  topic_count: topicCount,
25
38
  topic_index_path: result.topicIndexPath,
@@ -1 +1 @@
1
- {"version":3,"file":"7-topic-index.js","sourceRoot":"","sources":["../../../src/init/phases/7-topic-index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGjD,MAAM,GAAG,GAAG,MAAM,CAAC,2BAA2B,CAAC,CAAC;AAahD,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,KAAiB;IACzD,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,eAAe,CAAC,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC;QACnE,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC;QAChE,MAAM,GAAG,GAA0B;YACjC,WAAW,EAAE,MAAM,CAAC,UAAU;YAC9B,mBAAmB,EAAE,MAAM,CAAC,kBAAkB;YAC9C,mBAAmB,EAAE,MAAM,CAAC,kBAAkB;YAC9C,WAAW,EAAE,MAAM,CAAC,UAAU;YAC9B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AAG,CAAC,IAAI,CAAC,GAAG,EAAE,kBAAkB,CAAC,CAAC;QAClC,OAAO;YACL,MAAM,EAAE,UAAU;YAClB,SAAS,EAAE,eAAe;YAC1B,KAAK,EAAE,YAAY,CAAC,IAAI,CAAC;SAC1B,CAAC;IACJ,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,OAAO,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACjE,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,EAAE,gBAAgB,CAAC,CAAC;QACpC,OAAO;YACL,MAAM,EAAE,OAAO;YACf,KAAK,EAAE;gBACL,IAAI,EAAE,oBAAoB;gBAC1B,OAAO,EAAE,iCAAiC,OAAO,EAAE;aACpD;YACD,KAAK;SACN,CAAC;IACJ,CAAC;AACH,CAAC"}
@@ -1,10 +1,11 @@
1
1
  /**
2
- * Phase 8-docs-ingest — staged docs ingestion.
2
+ * Phase 8-docs-ingest — collapsed to a no-op in v0.9.0.
3
3
  *
4
- * Wraps `runDocsIngestion`; no operator input. The skill driver
5
- * surfaces the resulting `decsWritten.length` (drafts in `_inbox/`) in
6
- * the post-init summary so the operator sees how many docs-source
7
- * decision drafts landed for triage.
4
+ * The unified curator pipeline (Phase 9a/9b/9c) now subsumes docs
5
+ * ingestion alongside source comments and rule-file sections. This
6
+ * runner stays registered so resumes from old `init-state.json` files
7
+ * still flow through the state machine — it stamps a marker output
8
+ * and advances to `9a-walker`.
8
9
  */
9
10
  import type { PhaseResult, PhaseState } from "./types.js";
10
11
  export declare function runPhase8DocsIngest(state: PhaseState): Promise<PhaseResult>;
@@ -1,62 +1,23 @@
1
1
  /**
2
- * Phase 8-docs-ingest — staged docs ingestion.
2
+ * Phase 8-docs-ingest — collapsed to a no-op in v0.9.0.
3
3
  *
4
- * Wraps `runDocsIngestion`; no operator input. The skill driver
5
- * surfaces the resulting `decsWritten.length` (drafts in `_inbox/`) in
6
- * the post-init summary so the operator sees how many docs-source
7
- * decision drafts landed for triage.
4
+ * The unified curator pipeline (Phase 9a/9b/9c) now subsumes docs
5
+ * ingestion alongside source comments and rule-file sections. This
6
+ * runner stays registered so resumes from old `init-state.json` files
7
+ * still flow through the state machine — it stamps a marker output
8
+ * and advances to `9a-walker`.
8
9
  */
9
- import { runDocsIngestion } from "../ingest-docs.js";
10
- import { clearProgress, writeProgress } from "../progress.js";
11
- import { advancePhase, isSelfAdoptState } from "./orchestrator.js";
10
+ import { advancePhase } from "./orchestrator.js";
12
11
  export async function runPhase8DocsIngest(state) {
13
- if (isSelfAdoptState(state)) {
14
- const skipped = { skipped: "self-adopt" };
15
- const next = {
16
- ...state,
17
- outputs: { ...state.outputs, "8-docs-ingest": skipped },
18
- };
19
- return {
20
- status: "complete",
21
- nextPhase: "9-source-comments",
22
- state: advancePhase(next),
23
- };
24
- }
25
- const startedAt = Date.now();
26
- try {
27
- const result = await runDocsIngestion({
28
- repoRoot: state.repoRoot,
29
- onChunkProgress: (row) => {
30
- writeProgress(state.repoRoot, {
31
- phase: `8-docs-ingest:${row.stage}`,
32
- batch: row.entriesDone,
33
- total: row.totalEntries,
34
- startedAt,
35
- });
36
- },
37
- });
38
- clearProgress(state.repoRoot);
39
- const next = {
40
- ...state,
41
- outputs: { ...state.outputs, "8-docs-ingest": result },
42
- };
43
- return {
44
- status: "complete",
45
- nextPhase: "9-source-comments",
46
- state: advancePhase(next),
47
- };
48
- }
49
- catch (err) {
50
- clearProgress(state.repoRoot);
51
- return {
52
- status: "error",
53
- error: {
54
- code: "docs-ingest-failed",
55
- message: "Docs ingestion pipeline failed",
56
- detail: err instanceof Error ? err.stack ?? err.message : String(err),
57
- },
58
- state,
59
- };
60
- }
12
+ const out = { skipped: "merged-into-9-curator" };
13
+ const next = {
14
+ ...state,
15
+ outputs: { ...state.outputs, "8-docs-ingest": out },
16
+ };
17
+ return {
18
+ status: "complete",
19
+ nextPhase: "9a-walker",
20
+ state: advancePhase(next),
21
+ };
61
22
  }
62
23
  //# sourceMappingURL=8-docs-ingest.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"8-docs-ingest.js","sourceRoot":"","sources":["../../../src/init/phases/8-docs-ingest.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,gBAAgB,EAAwB,MAAM,mBAAmB,CAAC;AAC3E,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAGnE,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,KAAiB;IACzD,IAAI,gBAAgB,CAAC,KAAK,CAAC,EAAE,CAAC;QAC5B,MAAM,OAAO,GAAoB,EAAE,OAAO,EAAE,YAAqB,EAAE,CAAC;QACpE,MAAM,IAAI,GAAe;YACvB,GAAG,KAAK;YACR,OAAO,EAAE,EAAE,GAAG,KAAK,CAAC,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE;SACxD,CAAC;QACF,OAAO;YACL,MAAM,EAAE,UAAU;YAClB,SAAS,EAAE,mBAAmB;YAC9B,KAAK,EAAE,YAAY,CAAC,IAAI,CAAC;SAC1B,CAAC;IACJ,CAAC;IACD,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAC7B,IAAI,CAAC;QACH,MAAM,MAAM,GAAoB,MAAM,gBAAgB,CAAC;YACrD,QAAQ,EAAE,KAAK,CAAC,QAAQ;YACxB,eAAe,EAAE,CAAC,GAAG,EAAE,EAAE;gBACvB,aAAa,CAAC,KAAK,CAAC,QAAQ,EAAE;oBAC5B,KAAK,EAAE,iBAAiB,GAAG,CAAC,KAAK,EAAE;oBACnC,KAAK,EAAE,GAAG,CAAC,WAAW;oBACtB,KAAK,EAAE,GAAG,CAAC,YAAY;oBACvB,SAAS;iBACV,CAAC,CAAC;YACL,CAAC;SACF,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
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Phase 9a-walker — unified curator corpus walker (v0.9.0).
3
+ *
4
+ * Stub. Real implementation in a follow-up commit walks source
5
+ * comments + doc paragraphs + rule sections, applies the regex
6
+ * pre-filter from `curator/regex-prefilter.ts`, packs surviving
7
+ * records into shards capped at 120k input tokens, and writes
8
+ * `corpus.jsonl` + `shards.json` to `.cairn/init/curator/`.
9
+ *
10
+ * The cairn-adopt skill reads `shards.json` after this phase
11
+ * completes and dispatches `cairn:curator-map` subagents in parallel
12
+ * rounds of 4.
13
+ */
14
+ import type { PhaseResult, PhaseState } from "./types.js";
15
+ export declare function runPhase9aWalker(state: PhaseState): Promise<PhaseResult>;
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Phase 9a-walker — unified curator corpus walker (v0.9.0).
3
+ *
4
+ * Stub. Real implementation in a follow-up commit walks source
5
+ * comments + doc paragraphs + rule sections, applies the regex
6
+ * pre-filter from `curator/regex-prefilter.ts`, packs surviving
7
+ * records into shards capped at 120k input tokens, and writes
8
+ * `corpus.jsonl` + `shards.json` to `.cairn/init/curator/`.
9
+ *
10
+ * The cairn-adopt skill reads `shards.json` after this phase
11
+ * completes and dispatches `cairn:curator-map` subagents in parallel
12
+ * rounds of 4.
13
+ */
14
+ import { advancePhase, isSelfAdoptState } from "./orchestrator.js";
15
+ export async function runPhase9aWalker(state) {
16
+ if (isSelfAdoptState(state)) {
17
+ const skipped = { skipped: "self-adopt" };
18
+ const next = {
19
+ ...state,
20
+ outputs: { ...state.outputs, "9a-walker": skipped },
21
+ };
22
+ return {
23
+ status: "complete",
24
+ nextPhase: "9b-curate",
25
+ state: advancePhase(next),
26
+ };
27
+ }
28
+ // Real walker plugged in by `runCuratorWalker`.
29
+ try {
30
+ const { runCuratorWalker } = await import("../curator/walker.js");
31
+ const walker = await runCuratorWalker({ repoRoot: state.repoRoot });
32
+ const out = {
33
+ corpus_path: walker.corpus_path,
34
+ shards_path: walker.shards_path,
35
+ records_total: walker.records_total,
36
+ records_by_kind: walker.records_by_kind,
37
+ dropped: walker.dropped,
38
+ shards: walker.shards,
39
+ total_input_tokens_estimate: walker.total_input_tokens_estimate,
40
+ };
41
+ const next = {
42
+ ...state,
43
+ outputs: { ...state.outputs, "9a-walker": out },
44
+ };
45
+ return {
46
+ status: "complete",
47
+ nextPhase: "9b-curate",
48
+ state: advancePhase(next),
49
+ };
50
+ }
51
+ catch (err) {
52
+ return {
53
+ status: "error",
54
+ error: {
55
+ code: "9a-walker-failed",
56
+ message: "Curator walker failed",
57
+ detail: err instanceof Error ? err.stack ?? err.message : String(err),
58
+ },
59
+ state,
60
+ };
61
+ }
62
+ }
63
+ //# sourceMappingURL=9a-walker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"9a-walker.js","sourceRoot":"","sources":["../../../src/init/phases/9a-walker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAGnE,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,KAAiB;IACtD,IAAI,gBAAgB,CAAC,KAAK,CAAC,EAAE,CAAC;QAC5B,MAAM,OAAO,GAAiB,EAAE,OAAO,EAAE,YAAY,EAAE,CAAC;QACxD,MAAM,IAAI,GAAe;YACvB,GAAG,KAAK;YACR,OAAO,EAAE,EAAE,GAAG,KAAK,CAAC,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE;SACpD,CAAC;QACF,OAAO;YACL,MAAM,EAAE,UAAU;YAClB,SAAS,EAAE,WAAW;YACtB,KAAK,EAAE,YAAY,CAAC,IAAI,CAAC;SAC1B,CAAC;IACJ,CAAC;IACD,gDAAgD;IAChD,IAAI,CAAC;QACH,MAAM,EAAE,gBAAgB,EAAE,GAAG,MAAM,MAAM,CAAC,sBAAsB,CAAC,CAAC;QAClE,MAAM,MAAM,GAAG,MAAM,gBAAgB,CAAC,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC;QACpE,MAAM,GAAG,GAAiB;YACxB,WAAW,EAAE,MAAM,CAAC,WAAW;YAC/B,WAAW,EAAE,MAAM,CAAC,WAAW;YAC/B,aAAa,EAAE,MAAM,CAAC,aAAa;YACnC,eAAe,EAAE,MAAM,CAAC,eAAe;YACvC,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,2BAA2B,EAAE,MAAM,CAAC,2BAA2B;SAChE,CAAC;QACF,MAAM,IAAI,GAAe;YACvB,GAAG,KAAK;YACR,OAAO,EAAE,EAAE,GAAG,KAAK,CAAC,OAAO,EAAE,WAAW,EAAE,GAAG,EAAE;SAChD,CAAC;QACF,OAAO;YACL,MAAM,EAAE,UAAU;YAClB,SAAS,EAAE,WAAW;YACtB,KAAK,EAAE,YAAY,CAAC,IAAI,CAAC;SAC1B,CAAC;IACJ,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO;YACL,MAAM,EAAE,OAAO;YACf,KAAK,EAAE;gBACL,IAAI,EAAE,kBAAkB;gBACxB,OAAO,EAAE,uBAAuB;gBAChC,MAAM,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;aACtE;YACD,KAAK;SACN,CAAC;IACJ,CAAC;AACH,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Phase 9b-curate — skill-driven map+reduce dispatch (v0.9.0).
3
+ *
4
+ * The actual map+reduce work runs in the cairn-adopt skill. The skill
5
+ * reads `shards.json` from Phase 9a, spawns `cairn:curator-map`
6
+ * subagents per shard in parallel rounds of 4, then spawns one
7
+ * `cairn:curator-reduce` subagent over the aggregated candidates,
8
+ * writing the final synthesized entries to
9
+ * `.cairn/init/curator/final.jsonl`.
10
+ *
11
+ * This MCP runner is the state-machine bookkeeper for that work — it
12
+ * confirms `final.jsonl` exists, counts entries, advances to 9c-emit.
13
+ * If the skill calls this runner before writing `final.jsonl`, the
14
+ * runner errors so the operator sees a clear "skill orchestration
15
+ * skipped" signal rather than 9c-emit silently emitting zero entries.
16
+ */
17
+ import type { PhaseResult, PhaseState } from "./types.js";
18
+ export declare const CURATOR_FINAL_PATH: string;
19
+ export declare function runPhase9bCurate(state: PhaseState): Promise<PhaseResult>;
@@ -0,0 +1,79 @@
1
+ /**
2
+ * Phase 9b-curate — skill-driven map+reduce dispatch (v0.9.0).
3
+ *
4
+ * The actual map+reduce work runs in the cairn-adopt skill. The skill
5
+ * reads `shards.json` from Phase 9a, spawns `cairn:curator-map`
6
+ * subagents per shard in parallel rounds of 4, then spawns one
7
+ * `cairn:curator-reduce` subagent over the aggregated candidates,
8
+ * writing the final synthesized entries to
9
+ * `.cairn/init/curator/final.jsonl`.
10
+ *
11
+ * This MCP runner is the state-machine bookkeeper for that work — it
12
+ * confirms `final.jsonl` exists, counts entries, advances to 9c-emit.
13
+ * If the skill calls this runner before writing `final.jsonl`, the
14
+ * runner errors so the operator sees a clear "skill orchestration
15
+ * skipped" signal rather than 9c-emit silently emitting zero entries.
16
+ */
17
+ import { existsSync, readFileSync } from "node:fs";
18
+ import { join } from "node:path";
19
+ import { advancePhase, isSelfAdoptState } from "./orchestrator.js";
20
+ export const CURATOR_FINAL_PATH = join(".cairn", "init", "curator", "final.jsonl");
21
+ export async function runPhase9bCurate(state) {
22
+ if (isSelfAdoptState(state)) {
23
+ const skipped = { skipped: "self-adopt" };
24
+ const next = {
25
+ ...state,
26
+ outputs: { ...state.outputs, "9b-curate": skipped },
27
+ };
28
+ return {
29
+ status: "complete",
30
+ nextPhase: "9c-emit",
31
+ state: advancePhase(next),
32
+ };
33
+ }
34
+ const finalAbs = join(state.repoRoot, CURATOR_FINAL_PATH);
35
+ if (!existsSync(finalAbs)) {
36
+ return {
37
+ status: "error",
38
+ error: {
39
+ code: "9b-curate-missing-final",
40
+ message: "Curator skill orchestration did not write final.jsonl. The cairn-adopt skill must dispatch curator-map + curator-reduce subagents before invoking 9b-curate.",
41
+ detail: `Expected file at ${CURATOR_FINAL_PATH}`,
42
+ },
43
+ state,
44
+ };
45
+ }
46
+ let entries = 0;
47
+ try {
48
+ const text = readFileSync(finalAbs, "utf8");
49
+ for (const line of text.split("\n")) {
50
+ if (line.trim().length > 0)
51
+ entries += 1;
52
+ }
53
+ }
54
+ catch (err) {
55
+ return {
56
+ status: "error",
57
+ error: {
58
+ code: "9b-curate-read-failed",
59
+ message: "Failed to read curator final.jsonl",
60
+ detail: err instanceof Error ? err.stack ?? err.message : String(err),
61
+ },
62
+ state,
63
+ };
64
+ }
65
+ const out = {
66
+ final_path: CURATOR_FINAL_PATH,
67
+ final_entries: entries,
68
+ };
69
+ const next = {
70
+ ...state,
71
+ outputs: { ...state.outputs, "9b-curate": out },
72
+ };
73
+ return {
74
+ status: "complete",
75
+ nextPhase: "9c-emit",
76
+ state: advancePhase(next),
77
+ };
78
+ }
79
+ //# sourceMappingURL=9b-curate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"9b-curate.js","sourceRoot":"","sources":["../../../src/init/phases/9b-curate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAGnE,MAAM,CAAC,MAAM,kBAAkB,GAAG,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,aAAa,CAAC,CAAC;AAEnF,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,KAAiB;IACtD,IAAI,gBAAgB,CAAC,KAAK,CAAC,EAAE,CAAC;QAC5B,MAAM,OAAO,GAAiB,EAAE,OAAO,EAAE,YAAY,EAAE,CAAC;QACxD,MAA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B,UAAU,EAAE,kBAAkB;QAC9B,aAAa,EAAE,OAAO;KACvB,CAAC;IACF,MAAM,IAAI,GAAe;QACvB,GAAG,KAAK;QACR,OAAO,EAAE,EAAE,GAAG,KAAK,CAAC,OAAO,EAAE,WAAW,EAAE,GAAG,EAAE;KAChD,CAAC;IACF,OAAO;QACL,MAAM,EAAE,UAAU;QAClB,SAAS,EAAE,SAAS;QACpB,KAAK,EAAE,YAAY,CAAC,IAAI,CAAC;KAC1B,CAAC;AACJ,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Phase 9c-emit — deterministic curator emit (v0.9.0).
3
+ *
4
+ * Reads `.cairn/init/curator/final.jsonl`, validates each entry via
5
+ * the strict validators in `curator/validate.ts`, and writes
6
+ * surviving entries directly to `.cairn/ground/decisions/<id>.md`
7
+ * (DEC) or `.cairn/ground/invariants/<id>.md` (INV) with
8
+ * `status: accepted` / `status: active`. Invalid entries drop
9
+ * silently with a counter — operator's "auto-accept" directive in
10
+ * the curator plan means the bar is hard, not deferred to inbox.
11
+ */
12
+ import type { PhaseResult, PhaseState } from "./types.js";
13
+ export declare function runPhase9cEmit(state: PhaseState): Promise<PhaseResult>;