@interf/compiler 0.33.0 → 0.50.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 (234) hide show
  1. package/README.md +122 -226
  2. package/dist/cli/commands/agents.js +1 -32
  3. package/dist/cli/commands/benchmark.d.ts +2 -3
  4. package/dist/cli/commands/benchmark.js +1 -31
  5. package/dist/cli/commands/build-plan.js +26 -50
  6. package/dist/cli/commands/build.d.ts +2 -3
  7. package/dist/cli/commands/build.js +1 -31
  8. package/dist/cli/commands/graphs.js +177 -32
  9. package/dist/cli/commands/mcp.d.ts +1 -0
  10. package/dist/cli/commands/mcp.js +223 -126
  11. package/dist/cli/commands/project.js +10 -36
  12. package/dist/cli/commands/reset.d.ts +2 -3
  13. package/dist/cli/commands/reset.js +1 -22
  14. package/dist/cli/commands/runs.js +86 -33
  15. package/dist/cli/commands/status.js +3 -24
  16. package/dist/cli/commands/traces.js +1 -29
  17. package/dist/cli/commands/wizard.js +17 -29
  18. package/dist/cli/lib/http-client.d.ts +39 -0
  19. package/dist/cli/lib/http-client.js +73 -0
  20. package/dist/packages/build-plans/authoring/brief.d.ts +25 -4
  21. package/dist/packages/build-plans/authoring/build-plan-authoring.d.ts +42 -1
  22. package/dist/packages/build-plans/authoring/build-plan-authoring.js +470 -63
  23. package/dist/packages/build-plans/authoring/build-plan-edit-session.d.ts +9 -0
  24. package/dist/packages/build-plans/authoring/build-plan-edit-session.js +27 -10
  25. package/dist/packages/build-plans/authoring/build-plan-improvement.js +62 -8
  26. package/dist/packages/build-plans/authoring/lib/build-plan-edit-utils.d.ts +1 -0
  27. package/dist/packages/build-plans/package/build-plan-definitions.d.ts +0 -1
  28. package/dist/packages/build-plans/package/build-plan-definitions.js +5 -3
  29. package/dist/packages/build-plans/package/build-plan-stage-runner.d.ts +1 -0
  30. package/dist/packages/build-plans/package/build-plan-stage-runner.js +2 -1
  31. package/dist/packages/build-plans/package/builtin-build-plan.d.ts +2 -2
  32. package/dist/packages/build-plans/package/builtin-build-plan.js +3 -3
  33. package/dist/packages/build-plans/package/context-interface.d.ts +3 -0
  34. package/dist/packages/build-plans/package/context-interface.js +5 -5
  35. package/dist/packages/build-plans/package/interf-build-plan-package.js +22 -22
  36. package/dist/packages/build-plans/package/local-build-plans.d.ts +10 -5
  37. package/dist/packages/build-plans/package/local-build-plans.js +57 -32
  38. package/dist/packages/contracts/index.d.ts +4 -3
  39. package/dist/packages/contracts/index.js +2 -1
  40. package/dist/packages/contracts/lib/context-graph-layer.d.ts +161 -0
  41. package/dist/packages/contracts/lib/context-graph-layer.js +216 -0
  42. package/dist/packages/contracts/lib/project-paths.d.ts +7 -0
  43. package/dist/packages/contracts/lib/project-paths.js +9 -0
  44. package/dist/packages/contracts/lib/project-schema.d.ts +264 -1
  45. package/dist/packages/contracts/lib/project-schema.js +38 -13
  46. package/dist/packages/contracts/lib/schema.d.ts +556 -23
  47. package/dist/packages/contracts/lib/schema.js +279 -18
  48. package/dist/packages/contracts/utils/filesystem.d.ts +1 -0
  49. package/dist/packages/contracts/utils/filesystem.js +29 -1
  50. package/dist/packages/projects/lib/schema.d.ts +6 -8
  51. package/dist/packages/projects/lib/schema.js +3 -1
  52. package/dist/packages/projects/source-config.d.ts +0 -5
  53. package/dist/packages/projects/source-config.js +9 -22
  54. package/dist/packages/runtime/actions/fields.d.ts +4 -0
  55. package/dist/packages/runtime/actions/form-builders.js +79 -31
  56. package/dist/packages/runtime/actions/form-validators.js +9 -3
  57. package/dist/packages/runtime/actions/helpers.js +3 -3
  58. package/dist/packages/runtime/actions/registry.d.ts +1 -1
  59. package/dist/packages/runtime/actions/registry.js +1 -1
  60. package/dist/packages/runtime/actions/requests.d.ts +1 -1
  61. package/dist/packages/runtime/actions/requests.js +12 -6
  62. package/dist/packages/runtime/actions/schemas.d.ts +7 -0
  63. package/dist/packages/runtime/actions/schemas.js +1 -0
  64. package/dist/packages/runtime/agent-handoff.js +8 -7
  65. package/dist/packages/runtime/agents/lib/execution-profile.d.ts +14 -0
  66. package/dist/packages/runtime/agents/lib/execution-profile.js +23 -0
  67. package/dist/packages/runtime/agents/lib/execution.js +14 -8
  68. package/dist/packages/runtime/agents/lib/executors.d.ts +1 -0
  69. package/dist/packages/runtime/agents/lib/executors.js +11 -2
  70. package/dist/packages/runtime/agents/lib/logs.d.ts +10 -0
  71. package/dist/packages/runtime/agents/lib/logs.js +32 -8
  72. package/dist/packages/runtime/agents/lib/preflight.js +4 -1
  73. package/dist/packages/runtime/agents/lib/render.d.ts +18 -0
  74. package/dist/packages/runtime/agents/lib/render.js +44 -18
  75. package/dist/packages/runtime/agents/lib/shell-templates.js +105 -63
  76. package/dist/packages/runtime/agents/lib/shells.d.ts +29 -0
  77. package/dist/packages/runtime/agents/lib/shells.js +158 -32
  78. package/dist/packages/runtime/agents/lib/source-context-scan.d.ts +10 -0
  79. package/dist/packages/runtime/agents/lib/source-context-scan.js +388 -0
  80. package/dist/packages/runtime/agents/lib/status.js +1 -14
  81. package/dist/packages/runtime/agents/lib/string-utils.d.ts +16 -0
  82. package/dist/packages/runtime/agents/lib/string-utils.js +36 -0
  83. package/dist/packages/runtime/agents/lib/types.d.ts +1 -0
  84. package/dist/packages/runtime/agents/providers/codex.js +2 -0
  85. package/dist/packages/runtime/agents/role-executors.js +2 -1
  86. package/dist/packages/runtime/auth/session-store.js +11 -3
  87. package/dist/packages/runtime/benchmark-question-draft.d.ts +3 -0
  88. package/dist/packages/runtime/benchmark-question-draft.js +57 -28
  89. package/dist/packages/runtime/build/artifact-status.d.ts +1 -1
  90. package/dist/packages/runtime/build/artifact-status.js +1 -1
  91. package/dist/packages/runtime/build/build-evidence.d.ts +2 -1
  92. package/dist/packages/runtime/build/build-evidence.js +11 -5
  93. package/dist/packages/runtime/build/build-pipeline.js +89 -5
  94. package/dist/packages/runtime/build/build-stage-plan.js +3 -1
  95. package/dist/packages/runtime/build/build-stage-runner.js +169 -32
  96. package/dist/packages/runtime/build/build-target.d.ts +3 -0
  97. package/dist/packages/runtime/build/build-target.js +25 -1
  98. package/dist/packages/runtime/build/check-evaluator.d.ts +1 -1
  99. package/dist/packages/runtime/build/check-evaluator.js +655 -4
  100. package/dist/packages/runtime/build/context-graph-paths.d.ts +13 -0
  101. package/dist/packages/runtime/build/context-graph-paths.js +27 -0
  102. package/dist/packages/runtime/build/index.d.ts +2 -2
  103. package/dist/packages/runtime/build/index.js +2 -2
  104. package/dist/packages/runtime/build/inspect-map.d.ts +10 -0
  105. package/dist/packages/runtime/build/inspect-map.js +270 -0
  106. package/dist/packages/runtime/build/lib/schema.d.ts +246 -53
  107. package/dist/packages/runtime/build/lib/schema.js +173 -15
  108. package/dist/packages/runtime/build/native-entrypoint.d.ts +2 -0
  109. package/dist/packages/runtime/build/native-entrypoint.js +286 -0
  110. package/dist/packages/runtime/build/runtime-contracts.js +9 -3
  111. package/dist/packages/runtime/build/runtime-log-paths.d.ts +3 -0
  112. package/dist/packages/runtime/build/runtime-log-paths.js +16 -0
  113. package/dist/packages/runtime/build/runtime-prompt.js +6 -4
  114. package/dist/packages/runtime/build/runtime-runs.js +63 -10
  115. package/dist/packages/runtime/build/runtime-types.d.ts +4 -1
  116. package/dist/packages/runtime/build/runtime.d.ts +3 -1
  117. package/dist/packages/runtime/build/runtime.js +3 -1
  118. package/dist/packages/runtime/build/source-files.js +11 -2
  119. package/dist/packages/runtime/build/source-inventory.d.ts +1 -0
  120. package/dist/packages/runtime/build/source-inventory.js +246 -7
  121. package/dist/packages/runtime/build/source-manifest.d.ts +11 -0
  122. package/dist/packages/runtime/build/source-manifest.js +30 -2
  123. package/dist/packages/runtime/build/stage-evidence.js +80 -11
  124. package/dist/packages/runtime/build/stage-manifest.d.ts +45 -0
  125. package/dist/packages/runtime/build/stage-manifest.js +1125 -0
  126. package/dist/packages/runtime/build/stage-reuse.js +12 -0
  127. package/dist/packages/runtime/build/stage-session.d.ts +81 -0
  128. package/dist/packages/runtime/build/stage-session.js +308 -0
  129. package/dist/packages/runtime/build/state-io.js +10 -11
  130. package/dist/packages/runtime/build/state-view.js +1 -1
  131. package/dist/packages/runtime/build/state.d.ts +1 -1
  132. package/dist/packages/runtime/build/state.js +1 -1
  133. package/dist/packages/runtime/build/summary-coverage-index.d.ts +21 -0
  134. package/dist/packages/runtime/build/summary-coverage-index.js +189 -0
  135. package/dist/packages/runtime/build/traces.js +3 -3
  136. package/dist/packages/runtime/build/validate-context-graph.d.ts +1 -1
  137. package/dist/packages/runtime/build/validate-context-graph.js +5 -5
  138. package/dist/packages/runtime/build/validate.d.ts +1 -1
  139. package/dist/packages/runtime/build/validate.js +1 -1
  140. package/dist/packages/runtime/client.d.ts +3 -3
  141. package/dist/packages/runtime/client.js +8 -13
  142. package/dist/packages/runtime/context-checks.js +13 -0
  143. package/dist/packages/runtime/context-graph-scaffold.js +2 -1
  144. package/dist/packages/runtime/context-graph-semantic-graph.d.ts +9 -0
  145. package/dist/packages/runtime/context-graph-semantic-graph.js +416 -0
  146. package/dist/packages/runtime/execution/lib/schema.d.ts +34 -31
  147. package/dist/packages/runtime/index.d.ts +2 -2
  148. package/dist/packages/runtime/index.js +1 -1
  149. package/dist/packages/runtime/native-run-handlers.d.ts +38 -0
  150. package/dist/packages/runtime/native-run-handlers.js +52 -33
  151. package/dist/packages/runtime/plan-artifact-contract.js +1 -1
  152. package/dist/packages/runtime/project-source-state.d.ts +4 -4
  153. package/dist/packages/runtime/project-source-state.js +5 -2
  154. package/dist/packages/runtime/project-store.d.ts +5 -0
  155. package/dist/packages/runtime/project-store.js +30 -3
  156. package/dist/packages/runtime/requested-artifacts.js +1 -1
  157. package/dist/packages/runtime/run-observability.js +9 -4
  158. package/dist/packages/runtime/runtime-action-proposals.js +3 -3
  159. package/dist/packages/runtime/runtime-build-plans.js +47 -3
  160. package/dist/packages/runtime/runtime-build-runs.js +9 -16
  161. package/dist/packages/runtime/runtime-caches.d.ts +26 -0
  162. package/dist/packages/runtime/runtime-caches.js +47 -0
  163. package/dist/packages/runtime/runtime-jobs.js +6 -6
  164. package/dist/packages/runtime/runtime-project-mutations.js +1 -0
  165. package/dist/packages/runtime/runtime-project-reads.d.ts +4 -1
  166. package/dist/packages/runtime/runtime-project-reads.js +229 -36
  167. package/dist/packages/runtime/runtime-proposal-helpers.js +6 -6
  168. package/dist/packages/runtime/runtime-resource-builders.d.ts +4 -2
  169. package/dist/packages/runtime/runtime-resource-builders.js +16 -14
  170. package/dist/packages/runtime/runtime-status.d.ts +14 -0
  171. package/dist/packages/runtime/runtime-status.js +15 -0
  172. package/dist/packages/runtime/runtime-verify-runs.js +6 -5
  173. package/dist/packages/runtime/runtime.d.ts +439 -22
  174. package/dist/packages/runtime/runtime.js +16 -2
  175. package/dist/packages/runtime/schemas/actions.d.ts +24 -0
  176. package/dist/packages/runtime/schemas/agents.d.ts +28 -0
  177. package/dist/packages/runtime/schemas/agents.js +33 -0
  178. package/dist/packages/runtime/schemas/build-plans.d.ts +181 -8
  179. package/dist/packages/runtime/schemas/build-plans.js +36 -2
  180. package/dist/packages/runtime/schemas/context-graphs.d.ts +1522 -0
  181. package/dist/packages/runtime/schemas/context-graphs.js +110 -0
  182. package/dist/packages/runtime/schemas/files.d.ts +7 -347
  183. package/dist/packages/runtime/schemas/files.js +1 -24
  184. package/dist/packages/runtime/schemas/index.d.ts +1 -0
  185. package/dist/packages/runtime/schemas/index.js +1 -0
  186. package/dist/packages/runtime/schemas/jobs.js +4 -0
  187. package/dist/packages/runtime/schemas/projects.d.ts +48 -21
  188. package/dist/packages/runtime/schemas/projects.js +34 -10
  189. package/dist/packages/runtime/schemas/runs.d.ts +1009 -240
  190. package/dist/packages/runtime/schemas/runs.js +17 -0
  191. package/dist/packages/runtime/service/openapi.js +1 -0
  192. package/dist/packages/runtime/service/operations.d.ts +1666 -145
  193. package/dist/packages/runtime/service/operations.js +147 -17
  194. package/dist/packages/runtime/service/routes.d.ts +11 -3
  195. package/dist/packages/runtime/service/routes.js +11 -3
  196. package/dist/packages/runtime/service/server-app-boot.js +2 -2
  197. package/dist/packages/runtime/service/server-helpers.d.ts +11 -0
  198. package/dist/packages/runtime/service/server-helpers.js +19 -0
  199. package/dist/packages/runtime/service/server-routes-action-proposals.js +4 -2
  200. package/dist/packages/runtime/service/server-routes-agents.js +19 -85
  201. package/dist/packages/runtime/service/server-routes-build-plans.js +14 -11
  202. package/dist/packages/runtime/service/server-routes-project-context.js +102 -7
  203. package/dist/packages/runtime/service/server-routes-project-jobs.js +19 -12
  204. package/dist/packages/runtime/service/server-routes-project-runs.js +5 -2
  205. package/dist/packages/runtime/service/server-routes-projects.js +6 -2
  206. package/dist/packages/runtime/service/server-routes-runs.js +11 -4
  207. package/dist/packages/runtime/verify/lib/schema.js +12 -0
  208. package/dist/packages/runtime/verify/test-file-guard.d.ts +2 -0
  209. package/dist/packages/runtime/verify/test-file-guard.js +29 -0
  210. package/dist/packages/runtime/verify/verify-execution.d.ts +7 -0
  211. package/dist/packages/runtime/verify/verify-execution.js +109 -35
  212. package/dist/packages/runtime/verify/verify-paths.d.ts +1 -0
  213. package/dist/packages/runtime/verify/verify-paths.js +4 -0
  214. package/dist/packages/runtime/verify/verify-specs.js +49 -39
  215. package/dist/packages/runtime/wire-schemas.d.ts +1 -1
  216. package/dist/packages/runtime/wire-schemas.js +1 -1
  217. package/package.json +2 -8
  218. package/public-repo/CONTRIBUTING.md +10 -3
  219. package/public-repo/README.md +122 -226
  220. package/public-repo/build-plans/interf-default/README.md +15 -12
  221. package/public-repo/build-plans/interf-default/build/stages/entrypoint/SKILL.md +74 -0
  222. package/public-repo/build-plans/interf-default/build/stages/knowledge/SKILL.md +95 -0
  223. package/public-repo/build-plans/interf-default/build/stages/summarize/SKILL.md +38 -5
  224. package/public-repo/build-plans/interf-default/build-plan.json +27 -23
  225. package/public-repo/build-plans/interf-default/build-plan.schema.json +24 -20
  226. package/public-repo/build-plans/interf-default/use/query/SKILL.md +8 -7
  227. package/public-repo/openapi/local-service.openapi.json +11637 -4213
  228. package/public-repo/skills/interf/SKILL.md +174 -134
  229. package/dist/packages/runtime/build/runtime-paths.d.ts +0 -8
  230. package/dist/packages/runtime/build/runtime-paths.js +0 -26
  231. package/dist/packages/runtime/build/state-paths.d.ts +0 -7
  232. package/dist/packages/runtime/build/state-paths.js +0 -22
  233. package/public-repo/build-plans/interf-default/build/stages/shape/SKILL.md +0 -34
  234. package/public-repo/build-plans/interf-default/build/stages/structure/SKILL.md +0 -28
@@ -0,0 +1,189 @@
1
+ /**
2
+ * Deterministic NAVIGATION layer that GUARANTEES every summary note is reachable
3
+ * through the link web, independent of agent behavior.
4
+ *
5
+ * THE PROBLEM IT SOLVES
6
+ * The summarize stage produces one summary note per Source file. Knowledge and
7
+ * entrypoint stages are SUPPOSED to wikilink those summaries into the graph, but
8
+ * that relies on the stage agent doing it. When the agent skips a summary, that
9
+ * summary becomes a free-floating island: no note links it, it links no note,
10
+ * undirected degree 0. The `graph_notes_connected` readiness check then fails,
11
+ * and the rendered semantic graph shows the coverage layer as scattered dots.
12
+ *
13
+ * THE GUARANTEE
14
+ * After the stage agents run, the build calls `ensureSummaryCoverageIndex`. It
15
+ * is pure structure, deterministic, and idempotent. It writes a managed
16
+ * "Coverage index" block into `home.md` — the entrypoint spine — holding a
17
+ * `[[full/graph/path]]` wikilink to EVERY summary note the build produced,
18
+ * grouped by source folder. A full graph path resolves uniquely in the
19
+ * connectivity check's link resolver, so each summary gains a guaranteed
20
+ * INBOUND edge from `home.md`. `home.md` is itself part of the fixed skeleton
21
+ * and the graph spine, so it is never an island. Result: no summary can be a
22
+ * free-floating island, regardless of what the stage agent linked.
23
+ *
24
+ * WHY home.md (NOT a new note under summaries/)
25
+ * `home.md` is exactly what entrypoints are for: routing the reader into the
26
+ * content layers. The entrypoint SKILL already models a "Coverage" section in
27
+ * home that links every summary. Putting the index in the spine — rather than a
28
+ * new note inside `summaries/` — keeps the `summaries/` layer purely
29
+ * source-grounded summary notes (so the per-summary content contract,
30
+ * `frontmatter_required_keys` / `frontmatter_valid` / source-ref checks, still
31
+ * holds for every file there) while still guaranteeing connectivity.
32
+ *
33
+ * WHAT IT IS NOT
34
+ * This is a NAVIGATION layer: links only, exactly what `home.md` / entrypoints
35
+ * are for. It invents NO knowledge, NO claims, NO project-specific content, and
36
+ * hardcodes NOTHING about any Source. It only adds `[[wikilinks]]` from the
37
+ * entrypoint spine down to summaries the build already produced. It respects the
38
+ * fixed Context Graph skeleton: it edits only `home.md`, adds no new top-level
39
+ * folder, and creates no note inside the content layers.
40
+ *
41
+ * IDEMPOTENT / DETERMINISTIC
42
+ * Same graph in → same home block out. The block is regenerated from the current
43
+ * on-disk summary set every call (notes sorted, grouped deterministically) and is
44
+ * delimited by stable markers, so re-running REPLACES it in place rather than
45
+ * appending. Agent-authored home content outside the markers is preserved.
46
+ * Re-running on an already-finalized graph is a no-op on content.
47
+ *
48
+ * Best-effort: a failure to write must never fail a build (the stage outputs are
49
+ * already on disk). The connectivity check still runs after and is the source of
50
+ * truth on readiness.
51
+ */
52
+ import { existsSync, readFileSync } from "node:fs";
53
+ import { join, relative } from "node:path";
54
+ import { writeFileAtomic } from "./atomic-fs.js";
55
+ import { listFilesRecursive } from "../../contracts/utils/filesystem.js";
56
+ import { isOutputMarkdownFile } from "./validate.js";
57
+ import { HOME_SPINE_FILE } from "../../contracts/lib/context-graph-layer.js";
58
+ const SUMMARIES_LAYER_DIR = "summaries";
59
+ /** Stable delimiters around the managed coverage block in `home.md`. */
60
+ export const HOME_COVERAGE_BLOCK_BEGIN = "<!-- interf:coverage-index:begin -->";
61
+ export const HOME_COVERAGE_BLOCK_END = "<!-- interf:coverage-index:end -->";
62
+ /**
63
+ * Normalize a graph-relative file path to the link form the connectivity check
64
+ * resolves: forward slashes, no leading `./`, no trailing `.md`. Mirrors
65
+ * `normalizeGraphPath` in check-evaluator so the wikilinks this module emits are
66
+ * the exact tokens that check credits as web edges.
67
+ */
68
+ function toGraphPath(relativePath) {
69
+ return relativePath
70
+ .replaceAll("\\", "/")
71
+ .replace(/^\.\/+/, "")
72
+ .replace(/\.md$/i, "")
73
+ .replace(/\/+$/g, "");
74
+ }
75
+ /**
76
+ * Every summary note in the graph, as graph paths, deterministically sorted.
77
+ * Uses the same `isOutputMarkdownFile` filter the connectivity check and the
78
+ * semantic-graph builder use, so the spine links exactly the notes the check
79
+ * scores for connectivity.
80
+ */
81
+ function listSummaryNoteGraphPaths(contextGraphPath) {
82
+ const summariesDir = join(contextGraphPath, SUMMARIES_LAYER_DIR);
83
+ if (!existsSync(summariesDir))
84
+ return [];
85
+ return listFilesRecursive(summariesDir, isOutputMarkdownFile)
86
+ .map((file) => toGraphPath(relative(contextGraphPath, file)))
87
+ .sort((left, right) => left.localeCompare(right));
88
+ }
89
+ /**
90
+ * Group summary note graph paths by their source folder (the segment(s) between
91
+ * `summaries/` and the note leaf), purely for a navigable, grouped block.
92
+ * Grouping is cosmetic — connectivity is guaranteed by the per-note wikilink
93
+ * regardless of grouping — so a note directly under the layer falls into a single
94
+ * root group.
95
+ */
96
+ function groupBySourceFolder(graphPaths) {
97
+ const groups = new Map();
98
+ for (const graphPath of graphPaths) {
99
+ const withoutLayer = graphPath.replace(new RegExp(`^${SUMMARIES_LAYER_DIR}/`), "");
100
+ const lastSlash = withoutLayer.lastIndexOf("/");
101
+ const group = lastSlash >= 0 ? withoutLayer.slice(0, lastSlash) : SUMMARIES_LAYER_DIR;
102
+ const bucket = groups.get(group);
103
+ if (bucket)
104
+ bucket.push(graphPath);
105
+ else
106
+ groups.set(group, [graphPath]);
107
+ }
108
+ return groups;
109
+ }
110
+ /**
111
+ * Render the managed coverage block: a stable-delimited `## Coverage` section
112
+ * that wikilinks every summary by its full graph path, grouped by source folder.
113
+ * Deterministic for a given summary set.
114
+ */
115
+ function renderCoverageBlock(graphPaths) {
116
+ const lines = [
117
+ HOME_COVERAGE_BLOCK_BEGIN,
118
+ "## Coverage",
119
+ "",
120
+ "Every Source summary in this Context Graph, linked so the coverage layer stays",
121
+ "connected to this entrypoint. Navigation only — links, no new content.",
122
+ "",
123
+ ];
124
+ const groups = groupBySourceFolder(graphPaths);
125
+ const groupNames = [...groups.keys()].sort((left, right) => left.localeCompare(right));
126
+ for (const group of groupNames) {
127
+ lines.push(`### ${group}`, "");
128
+ for (const graphPath of groups.get(group) ?? []) {
129
+ lines.push(`- [[${graphPath}]]`);
130
+ }
131
+ lines.push("");
132
+ }
133
+ lines.push(HOME_COVERAGE_BLOCK_END);
134
+ return lines.join("\n");
135
+ }
136
+ /**
137
+ * Write or replace the managed coverage block in `home.md`. The block is
138
+ * delimited by stable markers and fully rewritten each call, so agent-authored
139
+ * spine content outside the markers is preserved and re-running is idempotent. If
140
+ * `home.md` does not exist yet, a minimal spine carrying the block is created —
141
+ * home is part of the fixed skeleton, so ensuring it exists is legitimate.
142
+ */
143
+ function writeCoverageBlockIntoHome(contextGraphPath, block) {
144
+ const homePath = join(contextGraphPath, HOME_SPINE_FILE);
145
+ if (!existsSync(homePath)) {
146
+ writeFileAtomic(homePath, `# Home\n\n${block}\n`);
147
+ return;
148
+ }
149
+ const current = readFileSync(homePath, "utf8");
150
+ const beginIndex = current.indexOf(HOME_COVERAGE_BLOCK_BEGIN);
151
+ const endIndex = current.indexOf(HOME_COVERAGE_BLOCK_END);
152
+ let next;
153
+ if (beginIndex >= 0 && endIndex > beginIndex) {
154
+ // Replace the existing managed block in place (idempotent).
155
+ const before = current.slice(0, beginIndex);
156
+ const after = current.slice(endIndex + HOME_COVERAGE_BLOCK_END.length);
157
+ next = `${before}${block}${after}`;
158
+ }
159
+ else {
160
+ // Append the managed block once, separated from existing spine content.
161
+ const trimmed = current.replace(/\s+$/g, "");
162
+ next = `${trimmed}\n\n${block}\n`;
163
+ }
164
+ if (next !== current)
165
+ writeFileAtomic(homePath, next);
166
+ }
167
+ /**
168
+ * Ensure `home.md` wikilinks every summary the build produced, via a managed,
169
+ * deterministic coverage block. Call this at build finalization, AFTER the stage
170
+ * agents have produced summaries, BEFORE the connectivity check runs. Guarantees
171
+ * every summary note has an inbound graph edge from the entrypoint spine
172
+ * regardless of agent behavior.
173
+ *
174
+ * Returns the count of linked summaries, or `null` when there is nothing to index
175
+ * (no `summaries/` layer). Never throws into the build: assembly is already
176
+ * complete; this is the connectivity floor laid on top.
177
+ */
178
+ export function ensureSummaryCoverageIndex(contextGraphPath) {
179
+ if (!existsSync(contextGraphPath))
180
+ return null;
181
+ const graphPaths = listSummaryNoteGraphPaths(contextGraphPath);
182
+ if (graphPaths.length === 0)
183
+ return null;
184
+ writeCoverageBlockIntoHome(contextGraphPath, renderCoverageBlock(graphPaths));
185
+ return {
186
+ summaries: graphPaths.length,
187
+ indexPath: HOME_SPINE_FILE,
188
+ };
189
+ }
@@ -25,7 +25,7 @@ export function buildTraces(input) {
25
25
  const generatedAt = input.generatedAt ?? new Date().toISOString();
26
26
  const sourceFiles = input.sourceFileCount;
27
27
  // Files-processed is evidence-backed. Source inventory gives the
28
- // denominator; Build evidence or accepted stage evidence must provide the
28
+ // denominator; accepted Stage Manifest coverage or supplemental diagnostics must provide the
29
29
  // observed value.
30
30
  const filesProcessed = clampObservedCount(input.filesProcessed, sourceFiles);
31
31
  const filesTotal = sourceFiles;
@@ -62,8 +62,8 @@ export function buildTraces(input) {
62
62
  total: sourceFiles,
63
63
  passed: filesProcessed >= sourceFiles,
64
64
  detail: filesProcessed >= sourceFiles
65
- ? "Build evidence covers every Source file."
66
- : `${sourceFiles - filesProcessed} Source file${sourceFiles - filesProcessed === 1 ? "" : "s"} lack accepted Build evidence.`,
65
+ ? "Accepted coverage records cover every Source file."
66
+ : `${sourceFiles - filesProcessed} Source file${sourceFiles - filesProcessed === 1 ? "" : "s"} lack accepted coverage records.`,
67
67
  });
68
68
  }
69
69
  if (pagesRead >= 0) {
@@ -23,5 +23,5 @@ export declare function validateContextGraphSetup(dirPath: string): ContextGraph
23
23
  export declare function validateBuildStage(dirPath: string, stageId: string): BuildStageValidation;
24
24
  export declare function validateContextGraph(dirPath: string): ContextGraphValidation;
25
25
  export declare function validateBuildSummarize(dirPath: string): BuildStageValidation;
26
- export declare function validateContextGraphStructure(dirPath: string): BuildStageValidation;
26
+ export declare function validateContextGraphKnowledge(dirPath: string): BuildStageValidation;
27
27
  export declare function validateBuildOutput(dirPath: string): ContextGraphValidation;
@@ -168,7 +168,7 @@ export function validateBuildStage(dirPath, stageId) {
168
168
  const artifacts = artifactsBuiltByStage(context.schema, buildPlanStage);
169
169
  const failures = artifactCheckFailures(dirPath, artifacts, artifactCounts);
170
170
  checks.artifact_diagnostics_ok = failures.length === 0;
171
- artifactErrors = failures.map((result) => `Artifact diagnostic "${result.check_id}" failed for ${result.kind}: ${result.summary}`);
171
+ artifactErrors = failures.map((result) => `Requested output diagnostic "${result.check_id}" failed for ${result.kind}: ${result.summary}`);
172
172
  }
173
173
  else {
174
174
  checks.artifact_diagnostics_ok = false;
@@ -190,7 +190,7 @@ export function validateBuildStage(dirPath, stageId) {
190
190
  ? required
191
191
  ? `Stage "${stageId}" checks passed.`
192
192
  : `Stage "${stageId}" is not required yet.`
193
- : `Stage "${stageId}" failed — ${errors[0] ?? "Artifact diagnostics not satisfied."}`;
193
+ : `Stage "${stageId}" failed — ${errors[0] ?? "stage output validation not satisfied."}`;
194
194
  return {
195
195
  ok,
196
196
  required,
@@ -257,7 +257,7 @@ export function validateContextGraph(dirPath) {
257
257
  stage: failedStage,
258
258
  summary: ok
259
259
  ? `Build Plan checks passed — ${completedStages}/${context.buildPlan.stages.length} stages satisfied.`
260
- : `Build Plan failed — ${errors[0] ?? "stage Artifact diagnostics not satisfied."}`,
260
+ : `Build Plan failed — ${errors[0] ?? "stage output validation not satisfied."}`,
261
261
  counts: {
262
262
  source_total: context.sourceTotal,
263
263
  stage_total: context.buildPlan.stages.length,
@@ -271,8 +271,8 @@ export function validateContextGraph(dirPath) {
271
271
  export function validateBuildSummarize(dirPath) {
272
272
  return validateBuildStage(dirPath, "summarize");
273
273
  }
274
- export function validateContextGraphStructure(dirPath) {
275
- return validateBuildStage(dirPath, "structure");
274
+ export function validateContextGraphKnowledge(dirPath) {
275
+ return validateBuildStage(dirPath, "knowledge");
276
276
  }
277
277
  export function validateBuildOutput(dirPath) {
278
278
  return validateContextGraph(dirPath);
@@ -17,5 +17,5 @@ export declare function isOutputMarkdownFile(filePath: string): boolean;
17
17
  export declare function safeReadText(filePath: string): string | null;
18
18
  export declare function extractSynthAbstract(frontmatter: Record<string, unknown>, body: string): string | null;
19
19
  export declare function countSynthAbstractWords(frontmatter: Record<string, unknown>, body: string): number;
20
- export { validateContextGraphSetup, validateBuildStage, validateContextGraph, validateBuildSummarize, validateContextGraphStructure, validateBuildOutput, } from "./validate-context-graph.js";
20
+ export { validateContextGraphSetup, validateBuildStage, validateContextGraph, validateBuildSummarize, validateContextGraphKnowledge, validateBuildOutput, } from "./validate-context-graph.js";
21
21
  export type { ContextGraphValidationSummary, BuildStageValidation, ContextGraphValidation, } from "./validate-context-graph.js";
@@ -256,4 +256,4 @@ function addFrontmatterLinkTarget(targets, value) {
256
256
  }
257
257
  }
258
258
  }
259
- export { validateContextGraphSetup, validateBuildStage, validateContextGraph, validateBuildSummarize, validateContextGraphStructure, validateBuildOutput, } from "./validate-context-graph.js";
259
+ export { validateContextGraphSetup, validateBuildStage, validateContextGraph, validateBuildSummarize, validateContextGraphKnowledge, validateBuildOutput, } from "./validate-context-graph.js";
@@ -35,7 +35,7 @@ export declare function findLocalService(options?: {
35
35
  }): Promise<LocalServiceConnection | null>;
36
36
  export declare function submitBuildRunToLocalService(options: {
37
37
  projectId: string;
38
- request: BuildRunCreateRequest;
38
+ request: Omit<BuildRunCreateRequest, "project">;
39
39
  idempotencyKey?: string;
40
40
  }): Promise<{
41
41
  serviceUrl: string;
@@ -43,14 +43,14 @@ export declare function submitBuildRunToLocalService(options: {
43
43
  } | null>;
44
44
  export declare function submitVerifyRunToLocalService(options: {
45
45
  projectId: string;
46
- request: VerifyRunCreateRequest;
46
+ request: Omit<VerifyRunCreateRequest, "project">;
47
47
  }): Promise<{
48
48
  serviceUrl: string;
49
49
  resource: VerifyRunResource;
50
50
  } | null>;
51
51
  export declare function submitResetToLocalService(options: {
52
52
  projectId: string;
53
- request: ResetRequest;
53
+ request: Omit<ResetRequest, "project">;
54
54
  }): Promise<{
55
55
  serviceUrl: string;
56
56
  result: ResetResult;
@@ -1,6 +1,7 @@
1
- import { BuildRunCreateRequestSchema, BuildRunListResponseSchema, BuildRunResourceSchema, RunObservabilityResourceSchema, ActionProposalApprovalRequestSchema, ActionProposalCreateRequestSchema, ActionProposalResourceSchema, LocalJobRunResourceSchema, LocalServiceHealthSchema, BenchmarkQuestionDraftCreateRequestSchema, BenchmarkQuestionDraftResultSchema, ResetRequestSchema, ResetResultSchema, VerifyRunCreateRequestSchema, VerifyRunResourceSchema, BuildPlanAuthoringCreateRequestSchema, BuildPlanAuthoringResultSchema, } from "./schemas/index.js";
1
+ import { BuildRunListResponseSchema, BuildRunResourceSchema, RunObservabilityResourceSchema, ActionProposalApprovalRequestSchema, ActionProposalCreateRequestSchema, ActionProposalResourceSchema, LocalJobRunResourceSchema, LocalServiceHealthSchema, BenchmarkQuestionDraftCreateRequestSchema, BenchmarkQuestionDraftResultSchema, ResetResultSchema, ProjectBuildRunCreateRequestSchema, ProjectResetRequestSchema, ProjectVerifyRunCreateRequestSchema, VerifyRunResourceSchema, BuildPlanAuthoringCreateRequestSchema, BuildPlanAuthoringResultSchema, } from "./schemas/index.js";
2
2
  import { LOCAL_SERVICE_ROUTES, buildLocalServiceUrl, projectSubresourcePath, } from "./service/routes.js";
3
3
  import { INTERF_AUTH_TOKEN_ENV, readActiveConnection } from "./connection-config.js";
4
+ import { isTerminalStatus } from "./runtime-status.js";
4
5
  async function connectOrNull(options = {}) {
5
6
  const conn = readActiveConnection({
6
7
  urlOverride: options.url ?? null,
@@ -86,7 +87,7 @@ export async function submitBuildRunToLocalService(options) {
86
87
  const connection = await connectOrNull();
87
88
  if (!connection)
88
89
  return null;
89
- const request = BuildRunCreateRequestSchema.parse(options.request);
90
+ const request = ProjectBuildRunCreateRequestSchema.parse(options.request);
90
91
  const headers = {
91
92
  ...authHeaders(connection.authToken),
92
93
  ...(options.idempotencyKey ? { "x-interf-idempotency-key": options.idempotencyKey } : {}),
@@ -106,7 +107,7 @@ export async function submitVerifyRunToLocalService(options) {
106
107
  const connection = await connectOrNull();
107
108
  if (!connection)
108
109
  return null;
109
- const request = VerifyRunCreateRequestSchema.parse(options.request);
110
+ const request = ProjectVerifyRunCreateRequestSchema.parse(options.request);
110
111
  const url = `${connection.serviceUrl}${projectSubresourcePath(options.projectId, "verifyRuns")}`;
111
112
  const resource = VerifyRunResourceSchema.parse(await fetchJson(url, {
112
113
  method: "POST",
@@ -122,7 +123,7 @@ export async function submitResetToLocalService(options) {
122
123
  const connection = await connectOrNull();
123
124
  if (!connection)
124
125
  return null;
125
- const request = ResetRequestSchema.parse(options.request);
126
+ const request = ProjectResetRequestSchema.parse(options.request);
126
127
  const url = `${connection.serviceUrl}${projectSubresourcePath(options.projectId, "reset")}`;
127
128
  const result = ResetResultSchema.parse(await fetchJson(url, {
128
129
  method: "POST",
@@ -179,12 +180,6 @@ export async function approveActionProposalInLocalService(options) {
179
180
  });
180
181
  return decided ?? proposal;
181
182
  }
182
- function isTerminalJobStatus(status) {
183
- return status === "succeeded" || status === "failed" || status === "cancelled";
184
- }
185
- function isTerminalRunStatus(status) {
186
- return status === "succeeded" || status === "failed" || status === "cancelled";
187
- }
188
183
  export async function getLocalBuildRun(options) {
189
184
  const headers = authHeaders(options.authToken ?? resolveLocalServiceAuthToken());
190
185
  const runValue = await fetchJson(`${options.serviceUrl}/v1/runs/${encodeURIComponent(options.runId)}`, {
@@ -244,7 +239,7 @@ export async function waitForLocalBuildRun(options) {
244
239
  authToken: options.authToken ?? null,
245
240
  });
246
241
  options.onUpdate?.(resource);
247
- if (isTerminalRunStatus(resource.run.status))
242
+ if (isTerminalStatus(resource.run.status))
248
243
  return resource;
249
244
  await new Promise((resolveWait) => setTimeout(resolveWait, delay));
250
245
  if (explicit === undefined) {
@@ -270,7 +265,7 @@ export async function waitForLocalVerifyRun(options) {
270
265
  authToken: options.authToken ?? null,
271
266
  });
272
267
  options.onUpdate?.(resource);
273
- if (isTerminalRunStatus(resource.status))
268
+ if (isTerminalStatus(resource.status))
274
269
  return resource;
275
270
  await new Promise((resolveWait) => setTimeout(resolveWait, delay));
276
271
  if (explicit === undefined) {
@@ -295,7 +290,7 @@ export async function waitForLocalJobRun(options) {
295
290
  authToken: options.authToken ?? null,
296
291
  });
297
292
  options.onUpdate?.(job);
298
- if (isTerminalJobStatus(job.status))
293
+ if (isTerminalStatus(job.status))
299
294
  return job;
300
295
  if (options.timeoutMs && Date.now() - startedAt > options.timeoutMs) {
301
296
  throw new Error(`Timed out waiting for local job ${options.runId}.`);
@@ -1,3 +1,16 @@
1
+ // COMPAT — legacy Context Check derivation, scheduled for removal once the
2
+ // Graph Manifest readiness rollup is the only path readers consume.
3
+ //
4
+ // The new product spine is primary_metrics + readiness in GraphManifest
5
+ // (see internal/plans/stage-manifest-context-graph-execution-plan-2026-05-27.md
6
+ // Phase 7). This module still runs because:
7
+ // 1. runtime-build-runs writes context_checks into the immutable Run record
8
+ // so old Run records remain consistent.
9
+ // 2. runtime-project-reads exposes a fallback "context-checks" gate when no
10
+ // GraphManifest exists yet (pre-refactor builds).
11
+ // Removal path: once all live instances have at least one GraphManifest-backed
12
+ // Build, drop the writes in runtime-build-runs and the fallback gate in
13
+ // runtime-project-reads, then delete this file. Do not add new callers.
1
14
  import { ContextCheckSchema, } from "../contracts/lib/schema.js";
2
15
  import { slugify } from "../contracts/utils/naming.js";
3
16
  function boundedContextCheckId(value, fallback) {
@@ -79,7 +79,7 @@ export function ensureContextGraphScaffoldAt(options) {
79
79
  assertContextGraphContainer(projectDataDir);
80
80
  mkdirSync(contextGraphPath, { recursive: true });
81
81
  mkdirSync(testRootForContextGraph(contextGraphPath), { recursive: true });
82
- if (buildPlanId === "interf-default") {
82
+ if (buildPlanId === DEFAULT_BUILD_PLAN_ID) {
83
83
  seedLocalDefaultBuildPlan({ projectDataDir });
84
84
  }
85
85
  const selectedBuildPlan = getBuildPlan(buildPlanId, { projectDataDir });
@@ -111,6 +111,7 @@ export function createContextGraph(name, projectDataDir, buildPlanId = DEFAULT_B
111
111
  saveContextGraphInterfConfig(contextGraphPath, {
112
112
  type: "context-graph",
113
113
  name,
114
+ intent: savedProject?.intent ?? "",
114
115
  build_plan: selectedBuildPlan.id,
115
116
  build_plan_origin: {
116
117
  selected: selectedBuildPlan.id,
@@ -0,0 +1,9 @@
1
+ import { type ContextGraphSemanticGraph } from "./schemas/index.js";
2
+ import type { SourceManifest } from "../contracts/lib/schema.js";
3
+ export declare function buildContextGraphSemanticGraph(options: {
4
+ contextGraphPath: string;
5
+ projectId: string;
6
+ generatedAt?: string;
7
+ sourceManifest?: SourceManifest | null;
8
+ entrypointPath?: string | null;
9
+ }): ContextGraphSemanticGraph;