@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.
- package/README.md +122 -226
- package/dist/cli/commands/agents.js +1 -32
- package/dist/cli/commands/benchmark.d.ts +2 -3
- package/dist/cli/commands/benchmark.js +1 -31
- package/dist/cli/commands/build-plan.js +26 -50
- package/dist/cli/commands/build.d.ts +2 -3
- package/dist/cli/commands/build.js +1 -31
- package/dist/cli/commands/graphs.js +177 -32
- package/dist/cli/commands/mcp.d.ts +1 -0
- package/dist/cli/commands/mcp.js +223 -126
- package/dist/cli/commands/project.js +10 -36
- package/dist/cli/commands/reset.d.ts +2 -3
- package/dist/cli/commands/reset.js +1 -22
- package/dist/cli/commands/runs.js +86 -33
- package/dist/cli/commands/status.js +3 -24
- package/dist/cli/commands/traces.js +1 -29
- package/dist/cli/commands/wizard.js +17 -29
- package/dist/cli/lib/http-client.d.ts +39 -0
- package/dist/cli/lib/http-client.js +73 -0
- package/dist/packages/build-plans/authoring/brief.d.ts +25 -4
- package/dist/packages/build-plans/authoring/build-plan-authoring.d.ts +42 -1
- package/dist/packages/build-plans/authoring/build-plan-authoring.js +470 -63
- package/dist/packages/build-plans/authoring/build-plan-edit-session.d.ts +9 -0
- package/dist/packages/build-plans/authoring/build-plan-edit-session.js +27 -10
- package/dist/packages/build-plans/authoring/build-plan-improvement.js +62 -8
- package/dist/packages/build-plans/authoring/lib/build-plan-edit-utils.d.ts +1 -0
- package/dist/packages/build-plans/package/build-plan-definitions.d.ts +0 -1
- package/dist/packages/build-plans/package/build-plan-definitions.js +5 -3
- package/dist/packages/build-plans/package/build-plan-stage-runner.d.ts +1 -0
- package/dist/packages/build-plans/package/build-plan-stage-runner.js +2 -1
- package/dist/packages/build-plans/package/builtin-build-plan.d.ts +2 -2
- package/dist/packages/build-plans/package/builtin-build-plan.js +3 -3
- package/dist/packages/build-plans/package/context-interface.d.ts +3 -0
- package/dist/packages/build-plans/package/context-interface.js +5 -5
- package/dist/packages/build-plans/package/interf-build-plan-package.js +22 -22
- package/dist/packages/build-plans/package/local-build-plans.d.ts +10 -5
- package/dist/packages/build-plans/package/local-build-plans.js +57 -32
- package/dist/packages/contracts/index.d.ts +4 -3
- package/dist/packages/contracts/index.js +2 -1
- package/dist/packages/contracts/lib/context-graph-layer.d.ts +161 -0
- package/dist/packages/contracts/lib/context-graph-layer.js +216 -0
- package/dist/packages/contracts/lib/project-paths.d.ts +7 -0
- package/dist/packages/contracts/lib/project-paths.js +9 -0
- package/dist/packages/contracts/lib/project-schema.d.ts +264 -1
- package/dist/packages/contracts/lib/project-schema.js +38 -13
- package/dist/packages/contracts/lib/schema.d.ts +556 -23
- package/dist/packages/contracts/lib/schema.js +279 -18
- package/dist/packages/contracts/utils/filesystem.d.ts +1 -0
- package/dist/packages/contracts/utils/filesystem.js +29 -1
- package/dist/packages/projects/lib/schema.d.ts +6 -8
- package/dist/packages/projects/lib/schema.js +3 -1
- package/dist/packages/projects/source-config.d.ts +0 -5
- package/dist/packages/projects/source-config.js +9 -22
- package/dist/packages/runtime/actions/fields.d.ts +4 -0
- package/dist/packages/runtime/actions/form-builders.js +79 -31
- package/dist/packages/runtime/actions/form-validators.js +9 -3
- package/dist/packages/runtime/actions/helpers.js +3 -3
- package/dist/packages/runtime/actions/registry.d.ts +1 -1
- package/dist/packages/runtime/actions/registry.js +1 -1
- package/dist/packages/runtime/actions/requests.d.ts +1 -1
- package/dist/packages/runtime/actions/requests.js +12 -6
- package/dist/packages/runtime/actions/schemas.d.ts +7 -0
- package/dist/packages/runtime/actions/schemas.js +1 -0
- package/dist/packages/runtime/agent-handoff.js +8 -7
- package/dist/packages/runtime/agents/lib/execution-profile.d.ts +14 -0
- package/dist/packages/runtime/agents/lib/execution-profile.js +23 -0
- package/dist/packages/runtime/agents/lib/execution.js +14 -8
- package/dist/packages/runtime/agents/lib/executors.d.ts +1 -0
- package/dist/packages/runtime/agents/lib/executors.js +11 -2
- package/dist/packages/runtime/agents/lib/logs.d.ts +10 -0
- package/dist/packages/runtime/agents/lib/logs.js +32 -8
- package/dist/packages/runtime/agents/lib/preflight.js +4 -1
- package/dist/packages/runtime/agents/lib/render.d.ts +18 -0
- package/dist/packages/runtime/agents/lib/render.js +44 -18
- package/dist/packages/runtime/agents/lib/shell-templates.js +105 -63
- package/dist/packages/runtime/agents/lib/shells.d.ts +29 -0
- package/dist/packages/runtime/agents/lib/shells.js +158 -32
- package/dist/packages/runtime/agents/lib/source-context-scan.d.ts +10 -0
- package/dist/packages/runtime/agents/lib/source-context-scan.js +388 -0
- package/dist/packages/runtime/agents/lib/status.js +1 -14
- package/dist/packages/runtime/agents/lib/string-utils.d.ts +16 -0
- package/dist/packages/runtime/agents/lib/string-utils.js +36 -0
- package/dist/packages/runtime/agents/lib/types.d.ts +1 -0
- package/dist/packages/runtime/agents/providers/codex.js +2 -0
- package/dist/packages/runtime/agents/role-executors.js +2 -1
- package/dist/packages/runtime/auth/session-store.js +11 -3
- package/dist/packages/runtime/benchmark-question-draft.d.ts +3 -0
- package/dist/packages/runtime/benchmark-question-draft.js +57 -28
- package/dist/packages/runtime/build/artifact-status.d.ts +1 -1
- package/dist/packages/runtime/build/artifact-status.js +1 -1
- package/dist/packages/runtime/build/build-evidence.d.ts +2 -1
- package/dist/packages/runtime/build/build-evidence.js +11 -5
- package/dist/packages/runtime/build/build-pipeline.js +89 -5
- package/dist/packages/runtime/build/build-stage-plan.js +3 -1
- package/dist/packages/runtime/build/build-stage-runner.js +169 -32
- package/dist/packages/runtime/build/build-target.d.ts +3 -0
- package/dist/packages/runtime/build/build-target.js +25 -1
- package/dist/packages/runtime/build/check-evaluator.d.ts +1 -1
- package/dist/packages/runtime/build/check-evaluator.js +655 -4
- package/dist/packages/runtime/build/context-graph-paths.d.ts +13 -0
- package/dist/packages/runtime/build/context-graph-paths.js +27 -0
- package/dist/packages/runtime/build/index.d.ts +2 -2
- package/dist/packages/runtime/build/index.js +2 -2
- package/dist/packages/runtime/build/inspect-map.d.ts +10 -0
- package/dist/packages/runtime/build/inspect-map.js +270 -0
- package/dist/packages/runtime/build/lib/schema.d.ts +246 -53
- package/dist/packages/runtime/build/lib/schema.js +173 -15
- package/dist/packages/runtime/build/native-entrypoint.d.ts +2 -0
- package/dist/packages/runtime/build/native-entrypoint.js +286 -0
- package/dist/packages/runtime/build/runtime-contracts.js +9 -3
- package/dist/packages/runtime/build/runtime-log-paths.d.ts +3 -0
- package/dist/packages/runtime/build/runtime-log-paths.js +16 -0
- package/dist/packages/runtime/build/runtime-prompt.js +6 -4
- package/dist/packages/runtime/build/runtime-runs.js +63 -10
- package/dist/packages/runtime/build/runtime-types.d.ts +4 -1
- package/dist/packages/runtime/build/runtime.d.ts +3 -1
- package/dist/packages/runtime/build/runtime.js +3 -1
- package/dist/packages/runtime/build/source-files.js +11 -2
- package/dist/packages/runtime/build/source-inventory.d.ts +1 -0
- package/dist/packages/runtime/build/source-inventory.js +246 -7
- package/dist/packages/runtime/build/source-manifest.d.ts +11 -0
- package/dist/packages/runtime/build/source-manifest.js +30 -2
- package/dist/packages/runtime/build/stage-evidence.js +80 -11
- package/dist/packages/runtime/build/stage-manifest.d.ts +45 -0
- package/dist/packages/runtime/build/stage-manifest.js +1125 -0
- package/dist/packages/runtime/build/stage-reuse.js +12 -0
- package/dist/packages/runtime/build/stage-session.d.ts +81 -0
- package/dist/packages/runtime/build/stage-session.js +308 -0
- package/dist/packages/runtime/build/state-io.js +10 -11
- package/dist/packages/runtime/build/state-view.js +1 -1
- package/dist/packages/runtime/build/state.d.ts +1 -1
- package/dist/packages/runtime/build/state.js +1 -1
- package/dist/packages/runtime/build/summary-coverage-index.d.ts +21 -0
- package/dist/packages/runtime/build/summary-coverage-index.js +189 -0
- package/dist/packages/runtime/build/traces.js +3 -3
- package/dist/packages/runtime/build/validate-context-graph.d.ts +1 -1
- package/dist/packages/runtime/build/validate-context-graph.js +5 -5
- package/dist/packages/runtime/build/validate.d.ts +1 -1
- package/dist/packages/runtime/build/validate.js +1 -1
- package/dist/packages/runtime/client.d.ts +3 -3
- package/dist/packages/runtime/client.js +8 -13
- package/dist/packages/runtime/context-checks.js +13 -0
- package/dist/packages/runtime/context-graph-scaffold.js +2 -1
- package/dist/packages/runtime/context-graph-semantic-graph.d.ts +9 -0
- package/dist/packages/runtime/context-graph-semantic-graph.js +416 -0
- package/dist/packages/runtime/execution/lib/schema.d.ts +34 -31
- package/dist/packages/runtime/index.d.ts +2 -2
- package/dist/packages/runtime/index.js +1 -1
- package/dist/packages/runtime/native-run-handlers.d.ts +38 -0
- package/dist/packages/runtime/native-run-handlers.js +52 -33
- package/dist/packages/runtime/plan-artifact-contract.js +1 -1
- package/dist/packages/runtime/project-source-state.d.ts +4 -4
- package/dist/packages/runtime/project-source-state.js +5 -2
- package/dist/packages/runtime/project-store.d.ts +5 -0
- package/dist/packages/runtime/project-store.js +30 -3
- package/dist/packages/runtime/requested-artifacts.js +1 -1
- package/dist/packages/runtime/run-observability.js +9 -4
- package/dist/packages/runtime/runtime-action-proposals.js +3 -3
- package/dist/packages/runtime/runtime-build-plans.js +47 -3
- package/dist/packages/runtime/runtime-build-runs.js +9 -16
- package/dist/packages/runtime/runtime-caches.d.ts +26 -0
- package/dist/packages/runtime/runtime-caches.js +47 -0
- package/dist/packages/runtime/runtime-jobs.js +6 -6
- package/dist/packages/runtime/runtime-project-mutations.js +1 -0
- package/dist/packages/runtime/runtime-project-reads.d.ts +4 -1
- package/dist/packages/runtime/runtime-project-reads.js +229 -36
- package/dist/packages/runtime/runtime-proposal-helpers.js +6 -6
- package/dist/packages/runtime/runtime-resource-builders.d.ts +4 -2
- package/dist/packages/runtime/runtime-resource-builders.js +16 -14
- package/dist/packages/runtime/runtime-status.d.ts +14 -0
- package/dist/packages/runtime/runtime-status.js +15 -0
- package/dist/packages/runtime/runtime-verify-runs.js +6 -5
- package/dist/packages/runtime/runtime.d.ts +439 -22
- package/dist/packages/runtime/runtime.js +16 -2
- package/dist/packages/runtime/schemas/actions.d.ts +24 -0
- package/dist/packages/runtime/schemas/agents.d.ts +28 -0
- package/dist/packages/runtime/schemas/agents.js +33 -0
- package/dist/packages/runtime/schemas/build-plans.d.ts +181 -8
- package/dist/packages/runtime/schemas/build-plans.js +36 -2
- package/dist/packages/runtime/schemas/context-graphs.d.ts +1522 -0
- package/dist/packages/runtime/schemas/context-graphs.js +110 -0
- package/dist/packages/runtime/schemas/files.d.ts +7 -347
- package/dist/packages/runtime/schemas/files.js +1 -24
- package/dist/packages/runtime/schemas/index.d.ts +1 -0
- package/dist/packages/runtime/schemas/index.js +1 -0
- package/dist/packages/runtime/schemas/jobs.js +4 -0
- package/dist/packages/runtime/schemas/projects.d.ts +48 -21
- package/dist/packages/runtime/schemas/projects.js +34 -10
- package/dist/packages/runtime/schemas/runs.d.ts +1009 -240
- package/dist/packages/runtime/schemas/runs.js +17 -0
- package/dist/packages/runtime/service/openapi.js +1 -0
- package/dist/packages/runtime/service/operations.d.ts +1666 -145
- package/dist/packages/runtime/service/operations.js +147 -17
- package/dist/packages/runtime/service/routes.d.ts +11 -3
- package/dist/packages/runtime/service/routes.js +11 -3
- package/dist/packages/runtime/service/server-app-boot.js +2 -2
- package/dist/packages/runtime/service/server-helpers.d.ts +11 -0
- package/dist/packages/runtime/service/server-helpers.js +19 -0
- package/dist/packages/runtime/service/server-routes-action-proposals.js +4 -2
- package/dist/packages/runtime/service/server-routes-agents.js +19 -85
- package/dist/packages/runtime/service/server-routes-build-plans.js +14 -11
- package/dist/packages/runtime/service/server-routes-project-context.js +102 -7
- package/dist/packages/runtime/service/server-routes-project-jobs.js +19 -12
- package/dist/packages/runtime/service/server-routes-project-runs.js +5 -2
- package/dist/packages/runtime/service/server-routes-projects.js +6 -2
- package/dist/packages/runtime/service/server-routes-runs.js +11 -4
- package/dist/packages/runtime/verify/lib/schema.js +12 -0
- package/dist/packages/runtime/verify/test-file-guard.d.ts +2 -0
- package/dist/packages/runtime/verify/test-file-guard.js +29 -0
- package/dist/packages/runtime/verify/verify-execution.d.ts +7 -0
- package/dist/packages/runtime/verify/verify-execution.js +109 -35
- package/dist/packages/runtime/verify/verify-paths.d.ts +1 -0
- package/dist/packages/runtime/verify/verify-paths.js +4 -0
- package/dist/packages/runtime/verify/verify-specs.js +49 -39
- package/dist/packages/runtime/wire-schemas.d.ts +1 -1
- package/dist/packages/runtime/wire-schemas.js +1 -1
- package/package.json +2 -8
- package/public-repo/CONTRIBUTING.md +10 -3
- package/public-repo/README.md +122 -226
- package/public-repo/build-plans/interf-default/README.md +15 -12
- package/public-repo/build-plans/interf-default/build/stages/entrypoint/SKILL.md +74 -0
- package/public-repo/build-plans/interf-default/build/stages/knowledge/SKILL.md +95 -0
- package/public-repo/build-plans/interf-default/build/stages/summarize/SKILL.md +38 -5
- package/public-repo/build-plans/interf-default/build-plan.json +27 -23
- package/public-repo/build-plans/interf-default/build-plan.schema.json +24 -20
- package/public-repo/build-plans/interf-default/use/query/SKILL.md +8 -7
- package/public-repo/openapi/local-service.openapi.json +11637 -4213
- package/public-repo/skills/interf/SKILL.md +174 -134
- package/dist/packages/runtime/build/runtime-paths.d.ts +0 -8
- package/dist/packages/runtime/build/runtime-paths.js +0 -26
- package/dist/packages/runtime/build/state-paths.d.ts +0 -7
- package/dist/packages/runtime/build/state-paths.js +0 -22
- package/public-repo/build-plans/interf-default/build/stages/shape/SKILL.md +0 -34
- 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;
|
|
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
|
-
? "
|
|
66
|
-
: `${sourceFiles - filesProcessed} Source file${sourceFiles - filesProcessed === 1 ? "" : "s"} lack accepted
|
|
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
|
|
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) => `
|
|
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] ?? "
|
|
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
|
|
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
|
|
275
|
-
return validateBuildStage(dirPath, "
|
|
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,
|
|
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,
|
|
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 {
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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 (
|
|
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 (
|
|
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 (
|
|
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 ===
|
|
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;
|