@interf/compiler 0.16.0 → 0.18.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/LICENSE.md +1 -0
- package/README.md +10 -7
- package/TRADEMARKS.md +4 -4
- package/builtin-methods/interf-default/README.md +6 -7
- package/builtin-methods/interf-default/method.json +7 -68
- package/builtin-methods/interf-default/method.schema.json +52 -50
- package/dist/cli/commands/prep.js +58 -2
- package/dist/cli/commands/verify.d.ts +2 -0
- package/dist/cli/commands/verify.js +17 -8
- package/dist/cli/commands/wizard.js +122 -14
- package/dist/compiler-ui/404.html +1 -1
- package/dist/compiler-ui/__next.__PAGE__.txt +2 -2
- package/dist/compiler-ui/__next._full.txt +3 -3
- package/dist/compiler-ui/__next._head.txt +1 -1
- package/dist/compiler-ui/__next._index.txt +2 -2
- package/dist/compiler-ui/__next._tree.txt +2 -2
- package/dist/compiler-ui/_next/static/chunks/{13awzu4tooflw.css → 0_c_tvh-cukjz.css} +1 -1
- package/dist/compiler-ui/_next/static/chunks/{0jipmpez3_ehh.js → 0f_geuwdesg_c.js} +42 -17
- package/dist/compiler-ui/_not-found/__next._full.txt +2 -2
- package/dist/compiler-ui/_not-found/__next._head.txt +1 -1
- package/dist/compiler-ui/_not-found/__next._index.txt +2 -2
- package/dist/compiler-ui/_not-found/__next._not-found.__PAGE__.txt +1 -1
- package/dist/compiler-ui/_not-found/__next._not-found.txt +1 -1
- package/dist/compiler-ui/_not-found/__next._tree.txt +2 -2
- package/dist/compiler-ui/_not-found.html +1 -1
- package/dist/compiler-ui/_not-found.txt +2 -2
- package/dist/compiler-ui/index.html +1 -1
- package/dist/compiler-ui/index.txt +3 -3
- package/dist/packages/contracts/index.d.ts +2 -2
- package/dist/packages/contracts/index.js +1 -1
- package/dist/packages/contracts/lib/schema.d.ts +271 -72
- package/dist/packages/contracts/lib/schema.js +243 -83
- package/dist/packages/engine/action-definitions.js +1 -1
- package/dist/packages/engine/agents/lib/shells.d.ts +12 -4
- package/dist/packages/engine/agents/lib/shells.js +127 -120
- package/dist/packages/engine/cloud-seams.d.ts +115 -0
- package/dist/packages/engine/cloud-seams.js +84 -0
- package/dist/packages/engine/compile/artifact-counts.d.ts +1 -1
- package/dist/packages/engine/compile/artifact-counts.js +3 -3
- package/dist/packages/engine/compile/artifact-status.d.ts +41 -0
- package/dist/packages/engine/compile/artifact-status.js +166 -0
- package/dist/packages/engine/compile/billing-events.d.ts +89 -0
- package/dist/packages/engine/compile/billing-events.js +74 -0
- package/dist/packages/engine/compile/check-evaluator.d.ts +66 -0
- package/dist/packages/engine/compile/check-evaluator.js +298 -0
- package/dist/packages/engine/compile/compiled-schema.d.ts +7 -17
- package/dist/packages/engine/compile/compiled-schema.js +55 -70
- package/dist/packages/engine/compile/compiled-stage-plan.d.ts +1 -0
- package/dist/packages/engine/compile/compiled-stage-plan.js +32 -15
- package/dist/packages/engine/compile/compiled-stage-runner.js +1 -1
- package/dist/packages/engine/compile/index.d.ts +0 -1
- package/dist/packages/engine/compile/index.js +0 -1
- package/dist/packages/engine/compile/lib/schema.d.ts +111 -92
- package/dist/packages/engine/compile/lib/schema.js +35 -39
- package/dist/packages/engine/compile/method-primitives.d.ts +2 -2
- package/dist/packages/engine/compile/method-primitives.js +1 -1
- package/dist/packages/engine/compile/reset.js +4 -4
- package/dist/packages/engine/compile/runtime-contracts.js +2 -1
- package/dist/packages/engine/compile/runtime-prompt.js +3 -2
- package/dist/packages/engine/compile/runtime-reconcile.js +35 -35
- package/dist/packages/engine/compile/runtime-runs.js +0 -1
- package/dist/packages/engine/compile/runtime-types.d.ts +7 -8
- package/dist/packages/engine/compile/runtime.d.ts +1 -2
- package/dist/packages/engine/compile/runtime.js +0 -1
- package/dist/packages/engine/compile/state-health.js +6 -6
- package/dist/packages/engine/compile/state-view.js +7 -6
- package/dist/packages/engine/compile/validate-compiled.js +61 -30
- package/dist/packages/engine/compile/validate.js +26 -24
- package/dist/packages/engine/execution/lib/schema.d.ts +79 -33
- package/dist/packages/engine/execution/lib/schema.js +13 -5
- package/dist/packages/engine/index.d.ts +2 -2
- package/dist/packages/engine/index.js +1 -1
- package/dist/packages/engine/lib/schema.d.ts +551 -242
- package/dist/packages/engine/lib/schema.js +53 -17
- package/dist/packages/engine/native-run-handlers.js +15 -7
- package/dist/packages/engine/preparation-store.d.ts +6 -0
- package/dist/packages/engine/preparation-store.js +8 -0
- package/dist/packages/engine/routes.d.ts +6 -0
- package/dist/packages/engine/routes.js +6 -0
- package/dist/packages/engine/run-observability.js +1 -2
- package/dist/packages/engine/runtime-event-applier.js +7 -0
- package/dist/packages/engine/runtime-proposal-helpers.js +1 -1
- package/dist/packages/engine/runtime-resource-builders.d.ts +6 -6
- package/dist/packages/engine/runtime-resource-builders.js +5 -4
- package/dist/packages/engine/runtime.d.ts +67 -7
- package/dist/packages/engine/runtime.js +159 -29
- package/dist/packages/engine/server.d.ts +25 -0
- package/dist/packages/engine/server.js +62 -3
- package/dist/packages/engine/verify/index.d.ts +10 -10
- package/dist/packages/engine/verify/index.js +8 -8
- package/dist/packages/engine/verify/readiness-check-run.d.ts +27 -4
- package/dist/packages/engine/verify/readiness-check-run.js +92 -24
- package/dist/packages/engine/verify/{test-execution.d.ts → verify-execution.d.ts} +2 -2
- package/dist/packages/engine/verify/{test-execution.js → verify-execution.js} +2 -2
- package/dist/packages/engine/verify/{test-paths.d.ts → verify-paths.d.ts} +1 -1
- package/dist/packages/engine/verify/{test-sandbox.d.ts → verify-sandbox.d.ts} +1 -1
- package/dist/packages/engine/verify/{test-specs.d.ts → verify-specs.d.ts} +1 -1
- package/dist/packages/engine/verify/{test-specs.js → verify-specs.js} +1 -1
- package/dist/packages/engine/verify/{test-targets.d.ts → verify-targets.d.ts} +1 -1
- package/dist/packages/engine/verify/{test.d.ts → verify.d.ts} +4 -4
- package/dist/packages/engine/verify/{test.js → verify.js} +3 -3
- package/dist/packages/engine/wire-schemas.d.ts +545 -0
- package/dist/packages/engine/wire-schemas.js +59 -0
- package/dist/packages/methods/authoring/method-authoring.d.ts +2 -0
- package/dist/packages/methods/authoring/method-authoring.js +99 -18
- package/dist/packages/methods/authoring/method-edit-session.js +5 -5
- package/dist/packages/methods/authoring/method-improvement.js +1 -1
- package/dist/packages/methods/package/builtin-compiled-method.d.ts +12 -12
- package/dist/packages/methods/package/builtin-compiled-method.js +25 -22
- package/dist/packages/methods/package/context-interface.d.ts +39 -26
- package/dist/packages/methods/package/context-interface.js +48 -39
- package/dist/packages/methods/package/interf-method-package.js +28 -47
- package/dist/packages/methods/package/local-methods.d.ts +3 -4
- package/dist/packages/methods/package/local-methods.js +34 -62
- package/dist/packages/methods/package/method-definitions.d.ts +4 -6
- package/dist/packages/methods/package/method-definitions.js +0 -4
- package/dist/packages/methods/package/method-helpers.d.ts +0 -2
- package/dist/packages/methods/package/method-helpers.js +0 -4
- package/dist/packages/project/interf-scaffold.js +12 -12
- package/dist/packages/project/source-config.js +2 -1
- package/package.json +6 -16
- package/dist/packages/engine/compile/runtime-acceptance.d.ts +0 -9
- package/dist/packages/engine/compile/runtime-acceptance.js +0 -265
- /package/dist/compiler-ui/_next/static/{a3UiUF0DiMEbfWy_0gihg → 6qyE1u9m_oBUkvAhhoCmO}/_buildManifest.js +0 -0
- /package/dist/compiler-ui/_next/static/{a3UiUF0DiMEbfWy_0gihg → 6qyE1u9m_oBUkvAhhoCmO}/_clientMiddlewareManifest.js +0 -0
- /package/dist/compiler-ui/_next/static/{a3UiUF0DiMEbfWy_0gihg → 6qyE1u9m_oBUkvAhhoCmO}/_ssgManifest.js +0 -0
- /package/dist/packages/engine/verify/{test-paths.js → verify-paths.js} +0 -0
- /package/dist/packages/engine/verify/{test-profile-presets.d.ts → verify-profile-presets.d.ts} +0 -0
- /package/dist/packages/engine/verify/{test-profile-presets.js → verify-profile-presets.js} +0 -0
- /package/dist/packages/engine/verify/{test-sandbox.js → verify-sandbox.js} +0 -0
- /package/dist/packages/engine/verify/{test-targets.js → verify-targets.js} +0 -0
- /package/dist/packages/engine/verify/{test-types.d.ts → verify-types.d.ts} +0 -0
- /package/dist/packages/engine/verify/{test-types.js → verify-types.js} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { existsSync, readFileSync, statSync, writeFileSync, } from "node:fs";
|
|
2
2
|
import { extname, join, relative } from "node:path";
|
|
3
3
|
import { listFilesRecursive } from "../../contracts/utils/filesystem.js";
|
|
4
|
-
import {
|
|
4
|
+
import { compiledArtifactAbsolutePath, findCompiledSchemaArtifact, readCompiledSchemaFile, } from "./compiled-schema.js";
|
|
5
5
|
import { parseJsonFrontmatter } from "../../contracts/utils/parse.js";
|
|
6
6
|
import { loadRuntimeRun } from "./runtime.js";
|
|
7
7
|
import { initCompiledState, loadState, refreshCompiledArtifacts, saveState, } from "./state.js";
|
|
@@ -38,8 +38,8 @@ function anyPathUpdatedSince(absolutePath, sinceMs) {
|
|
|
38
38
|
}
|
|
39
39
|
return false;
|
|
40
40
|
}
|
|
41
|
-
function
|
|
42
|
-
const absolutePath =
|
|
41
|
+
function artifactCount(dirPath, artifactPath, kind) {
|
|
42
|
+
const absolutePath = compiledArtifactAbsolutePath(dirPath, { path: artifactPath });
|
|
43
43
|
if (!existsSync(absolutePath))
|
|
44
44
|
return 0;
|
|
45
45
|
if (kind === "file")
|
|
@@ -52,11 +52,11 @@ function summaryAbstract(content) {
|
|
|
52
52
|
return null;
|
|
53
53
|
return extractSynthAbstract(parsed.frontmatter, parsed.body);
|
|
54
54
|
}
|
|
55
|
-
function listZoneArtifacts(dirPath,
|
|
56
|
-
const absolutePath =
|
|
57
|
-
if (!existsSync(absolutePath) ||
|
|
55
|
+
function listZoneArtifacts(dirPath, artifact) {
|
|
56
|
+
const absolutePath = compiledArtifactAbsolutePath(dirPath, artifact);
|
|
57
|
+
if (!existsSync(absolutePath) || artifact.kind === "runtime")
|
|
58
58
|
return [];
|
|
59
|
-
if (
|
|
59
|
+
if (artifact.kind === "file") {
|
|
60
60
|
try {
|
|
61
61
|
return statSync(absolutePath).isFile() ? [absolutePath] : [];
|
|
62
62
|
}
|
|
@@ -68,8 +68,8 @@ function listZoneArtifacts(dirPath, zone) {
|
|
|
68
68
|
}
|
|
69
69
|
function buildInventoryMetadata(options) {
|
|
70
70
|
const metadata = {
|
|
71
|
-
|
|
72
|
-
|
|
71
|
+
artifact_id: options.artifactId,
|
|
72
|
+
artifact_kind: options.artifactKind,
|
|
73
73
|
file_extension: extname(options.filePath).toLowerCase() || null,
|
|
74
74
|
};
|
|
75
75
|
if (!options.parsedFrontmatter) {
|
|
@@ -98,16 +98,16 @@ function buildStageInventoryEntries(dirPath, stage) {
|
|
|
98
98
|
const schema = readCompiledSchemaFile(methodPackagePathForCompiled(dirPath));
|
|
99
99
|
if (!schema)
|
|
100
100
|
return [];
|
|
101
|
-
const
|
|
102
|
-
.map((
|
|
103
|
-
.filter((
|
|
104
|
-
const
|
|
105
|
-
.map((
|
|
106
|
-
.filter((
|
|
107
|
-
if (
|
|
101
|
+
const readableInputArtifacts = stage.reads
|
|
102
|
+
.map((artifactId) => findCompiledSchemaArtifact(schema, artifactId))
|
|
103
|
+
.filter((artifact) => artifact !== null && artifact.kind !== "runtime");
|
|
104
|
+
const outputArtifacts = stage.writes
|
|
105
|
+
.map((artifactId) => findCompiledSchemaArtifact(schema, artifactId))
|
|
106
|
+
.filter((artifact) => artifact !== null && artifact.kind !== "runtime");
|
|
107
|
+
if (outputArtifacts.length === 0)
|
|
108
108
|
return [];
|
|
109
109
|
const entries = [];
|
|
110
|
-
for (const outputZone of
|
|
110
|
+
for (const outputZone of outputArtifacts) {
|
|
111
111
|
for (const filePath of listZoneArtifacts(dirPath, outputZone)) {
|
|
112
112
|
const relativeOutputPath = relative(dirPath, filePath).replaceAll("\\", "/");
|
|
113
113
|
const parsed = isOutputMarkdownFile(filePath)
|
|
@@ -116,36 +116,36 @@ function buildStageInventoryEntries(dirPath, stage) {
|
|
|
116
116
|
const sourcePath = typeof parsed?.frontmatter.source === "string"
|
|
117
117
|
? parsed.frontmatter.source.trim()
|
|
118
118
|
: "";
|
|
119
|
-
const
|
|
120
|
-
? parsed.frontmatter.
|
|
119
|
+
const sourceArtifactId = typeof parsed?.frontmatter.source_artifact === "string"
|
|
120
|
+
? parsed.frontmatter.source_artifact.trim()
|
|
121
121
|
: "";
|
|
122
|
-
const inputZone =
|
|
123
|
-
?
|
|
124
|
-
:
|
|
125
|
-
?
|
|
122
|
+
const inputZone = sourceArtifactId.length > 0
|
|
123
|
+
? readableInputArtifacts.find((artifact) => artifact.id === sourceArtifactId) ?? null
|
|
124
|
+
: readableInputArtifacts.length === 1
|
|
125
|
+
? readableInputArtifacts[0]
|
|
126
126
|
: null;
|
|
127
127
|
entries.push({
|
|
128
128
|
...(inputZone && sourcePath.length > 0
|
|
129
129
|
? {
|
|
130
|
-
|
|
130
|
+
input_artifact: inputZone.id,
|
|
131
131
|
input_path: sourcePath,
|
|
132
132
|
}
|
|
133
133
|
: {}),
|
|
134
|
-
|
|
134
|
+
output_artifact: outputZone.id,
|
|
135
135
|
output_path: relativeOutputPath,
|
|
136
136
|
...(typeof parsed?.frontmatter.state === "string"
|
|
137
137
|
? { state: parsed.frontmatter.state }
|
|
138
138
|
: {}),
|
|
139
139
|
metadata: buildInventoryMetadata({
|
|
140
|
-
|
|
141
|
-
|
|
140
|
+
artifactId: outputZone.id,
|
|
141
|
+
artifactKind: outputZone.kind,
|
|
142
142
|
filePath,
|
|
143
143
|
parsedFrontmatter: parsed,
|
|
144
144
|
}),
|
|
145
145
|
});
|
|
146
146
|
}
|
|
147
147
|
}
|
|
148
|
-
return entries.sort((left, right) => `${left.
|
|
148
|
+
return entries.sort((left, right) => `${left.output_artifact}:${left.output_path}`.localeCompare(`${right.output_artifact}:${right.output_path}`));
|
|
149
149
|
}
|
|
150
150
|
function writeStageInventory(dirPath, stageId, entries) {
|
|
151
151
|
writeFileSync(join(compiledRuntimeRoot(dirPath), "inventory.json"), JSON.stringify(compiledInventoryFromEntries(entries, stageId), null, 2) + "\n");
|
|
@@ -160,12 +160,12 @@ export function reconcileCompiledStageRun(dirPath, stage) {
|
|
|
160
160
|
const schema = readCompiledSchemaFile(methodPackagePathForCompiled(dirPath));
|
|
161
161
|
if (!schema)
|
|
162
162
|
return false;
|
|
163
|
-
const
|
|
164
|
-
.map((
|
|
165
|
-
.filter((
|
|
166
|
-
if (
|
|
163
|
+
const writeArtifacts = stage.writes
|
|
164
|
+
.map((artifactId) => findCompiledSchemaArtifact(schema, artifactId))
|
|
165
|
+
.filter((artifact) => artifact !== null);
|
|
166
|
+
if (writeArtifacts.length === 0)
|
|
167
167
|
return false;
|
|
168
|
-
if (!
|
|
168
|
+
if (!writeArtifacts.some((artifact) => anyPathUpdatedSince(compiledArtifactAbsolutePath(dirPath, artifact), startedAtMs))) {
|
|
169
169
|
return false;
|
|
170
170
|
}
|
|
171
171
|
writeStageInventory(dirPath, stage.id, buildStageInventoryEntries(dirPath, stage));
|
|
@@ -183,8 +183,8 @@ export function reconcileCompiledStageRun(dirPath, stage) {
|
|
|
183
183
|
started_at: loadRuntimeRun(dirPath)?.started_at ?? now,
|
|
184
184
|
finished_at: now,
|
|
185
185
|
counts: activeRunCounts(dirPath),
|
|
186
|
-
|
|
187
|
-
artifacts:
|
|
186
|
+
artifact_counts: Object.fromEntries(writeArtifacts.map((artifact) => [artifact.id, artifactCount(dirPath, artifact.path, artifact.kind)])),
|
|
187
|
+
artifacts: writeArtifacts.map((artifact) => artifact.kind === "file" ? artifact.path : `${artifact.path}/`),
|
|
188
188
|
summary: loadRuntimeRun(dirPath)?.summary ?? null,
|
|
189
189
|
run_id: loadRuntimeRun(dirPath)?.run_id ?? null,
|
|
190
190
|
};
|
|
@@ -129,7 +129,6 @@ function startRuntimeRun(options) {
|
|
|
129
129
|
executor: buildRuntimeExecutorInfo(options.executor),
|
|
130
130
|
instructions: options.contract.instructions,
|
|
131
131
|
counts: options.contract.counts,
|
|
132
|
-
...(options.contract.acceptance ? { acceptance: options.contract.acceptance } : {}),
|
|
133
132
|
artifacts: options.contract.artifacts,
|
|
134
133
|
policies: options.contract.policies,
|
|
135
134
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type MethodExecutor } from "../agents/lib/executors.js";
|
|
2
|
-
import { type RuntimeRun, type
|
|
3
|
-
import type { MethodId, RuntimeContractType, RuntimeStage } from "../../contracts/lib/schema.js";
|
|
2
|
+
import { type RuntimeRun, type RuntimeStageContract, type RuntimeStageInstructions } from "./lib/schema.js";
|
|
3
|
+
import type { Check, MethodId, RuntimeContractType, RuntimeStage } from "../../contracts/lib/schema.js";
|
|
4
4
|
export type RuntimeRunStatus = "running" | "succeeded" | "failed";
|
|
5
5
|
export type RuntimeStageContractDraft = Omit<RuntimeStageContract, "kind" | "version" | "generated_at" | "run_id" | "target_type" | "target_name" | "method" | "stage" | "stage_label" | "contract_type" | "executor">;
|
|
6
6
|
export interface RuntimeStageExecutionOptions {
|
|
@@ -19,11 +19,6 @@ export interface RuntimeStageExecutionOptions {
|
|
|
19
19
|
completionCheck?: (() => boolean) | null;
|
|
20
20
|
onStatus?: (line: string) => void;
|
|
21
21
|
}
|
|
22
|
-
export interface RuntimeStageAcceptanceValidation {
|
|
23
|
-
ok: boolean;
|
|
24
|
-
summary: string;
|
|
25
|
-
failures: string[];
|
|
26
|
-
}
|
|
27
22
|
export interface RuntimeStageContractOptions {
|
|
28
23
|
compiledName: string;
|
|
29
24
|
stageId: string;
|
|
@@ -32,10 +27,14 @@ export interface RuntimeStageContractOptions {
|
|
|
32
27
|
extraReadArtifacts?: string[];
|
|
33
28
|
stageReadArtifacts: string[];
|
|
34
29
|
stageWriteArtifacts: string[];
|
|
30
|
+
stageWriteContracts?: Array<{
|
|
31
|
+
artifact_id: string;
|
|
32
|
+
path: string;
|
|
33
|
+
checks: Check[];
|
|
34
|
+
}>;
|
|
35
35
|
methodNotes?: string[];
|
|
36
36
|
localSkillDocs?: string[];
|
|
37
37
|
instructions: RuntimeStageInstructions;
|
|
38
|
-
acceptance?: RuntimeStageAcceptance;
|
|
39
38
|
}
|
|
40
39
|
export interface RuntimeRunPatch extends Partial<Pick<RuntimeRun, "counts" | "summary" | "status" | "error" | "exit_code" | "finished_at">> {
|
|
41
40
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
export type { RuntimeRunPatch, RuntimeRunStatus,
|
|
1
|
+
export type { RuntimeRunPatch, RuntimeRunStatus, RuntimeStageContractDraft, RuntimeStageExecutionOptions, RuntimeStageContractOptions, } from "./runtime-types.js";
|
|
2
2
|
export { archivedStageContractPath, eventLogPath, logsDirPath, promptLogPath, runHistoryPath, runPath, stageContractPath, statusLogPath, } from "./runtime-paths.js";
|
|
3
|
-
export { validateStageContractAcceptance } from "./runtime-acceptance.js";
|
|
4
3
|
export { buildStagePrompt } from "./runtime-prompt.js";
|
|
5
4
|
export { buildRuntimeStageContract, } from "./runtime-contracts.js";
|
|
6
5
|
export { beginRuntimeRun, loadRuntimeRun, markRuntimeRunFailedAfterValidation, markRuntimeRunSucceededAfterValidation, runExecutorStage, saveRuntimeRun, updateRuntimeRun, writeStageContract, } from "./runtime-runs.js";
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export { archivedStageContractPath, eventLogPath, logsDirPath, promptLogPath, runHistoryPath, runPath, stageContractPath, statusLogPath, } from "./runtime-paths.js";
|
|
2
|
-
export { validateStageContractAcceptance } from "./runtime-acceptance.js";
|
|
3
2
|
export { buildStagePrompt } from "./runtime-prompt.js";
|
|
4
3
|
export { buildRuntimeStageContract, } from "./runtime-contracts.js";
|
|
5
4
|
export { beginRuntimeRun, loadRuntimeRun, markRuntimeRunFailedAfterValidation, markRuntimeRunSucceededAfterValidation, runExecutorStage, saveRuntimeRun, updateRuntimeRun, writeStageContract, } from "./runtime-runs.js";
|
|
@@ -4,10 +4,10 @@ import { discoverSourceFiles } from "./discovery.js";
|
|
|
4
4
|
import { loadRuntimeRun } from "./runtime.js";
|
|
5
5
|
import { loadState } from "./state-io.js";
|
|
6
6
|
import { validateCompiled, validateCompiledStage, validateCompiledMethod, } from "./validate.js";
|
|
7
|
-
import { readCompiledSchemaFile } from "./compiled-schema.js";
|
|
7
|
+
import { listCompiledSchemaArtifacts, readCompiledSchemaFile } from "./compiled-schema.js";
|
|
8
8
|
import { methodPackagePathForCompiled } from "./compiled-paths.js";
|
|
9
9
|
import { getActiveCompiledMethod, resolveRequiredCompiledMethodFromConfig } from "../../methods/package/method-definitions.js";
|
|
10
|
-
import {
|
|
10
|
+
import { countCompiledArtifactsAtPath } from "./artifact-counts.js";
|
|
11
11
|
export function computeCompiledHealth(dirPath) {
|
|
12
12
|
const now = new Date().toISOString();
|
|
13
13
|
const config = readInterfConfig(dirPath);
|
|
@@ -37,9 +37,9 @@ export function computeCompiledHealth(dirPath) {
|
|
|
37
37
|
const firstFailed = stageResults.find((entry) => !entry.validation.ok) ?? null;
|
|
38
38
|
const methodValidation = validateCompiledMethod(dirPath);
|
|
39
39
|
const schema = readCompiledSchemaFile(methodPackagePathForCompiled(dirPath));
|
|
40
|
-
const
|
|
41
|
-
`
|
|
42
|
-
|
|
40
|
+
const artifactMetrics = Object.fromEntries((schema ? listCompiledSchemaArtifacts(schema) : []).map((artifact) => [
|
|
41
|
+
`artifact_${artifact.id}`,
|
|
42
|
+
countCompiledArtifactsAtPath(dirPath, artifact.path, artifact.kind),
|
|
43
43
|
]));
|
|
44
44
|
let status = "idle";
|
|
45
45
|
let stage = "idle";
|
|
@@ -98,7 +98,7 @@ export function computeCompiledHealth(dirPath) {
|
|
|
98
98
|
completed_stages: completedStages,
|
|
99
99
|
warnings: state?.warning_count ?? 0,
|
|
100
100
|
errors: (state?.error_count ?? 0) + errors,
|
|
101
|
-
...
|
|
101
|
+
...artifactMetrics,
|
|
102
102
|
},
|
|
103
103
|
checks,
|
|
104
104
|
};
|
|
@@ -2,7 +2,7 @@ import { basename } from "node:path";
|
|
|
2
2
|
import { readInterfConfig, resolveSourceFolderPath } from "../../project/interf-detect.js";
|
|
3
3
|
import { loadCompiledSourceSnapshot, loadCompiledViewSpec, saveCompiledViewSpec, } from "./state-io.js";
|
|
4
4
|
import { methodPackagePathForCompiled } from "./compiled-paths.js";
|
|
5
|
-
import { readCompiledSchemaFile } from "./compiled-schema.js";
|
|
5
|
+
import { listCompiledSchemaArtifacts, readCompiledSchemaFile } from "./compiled-schema.js";
|
|
6
6
|
import { getActiveCompiledMethod, resolveRequiredCompiledMethodFromConfig } from "../../methods/package/method-definitions.js";
|
|
7
7
|
import { writeCompiledSourceFiles, writeCompiledSourceSnapshot, } from "./source-files.js";
|
|
8
8
|
export function ensureCompiledViewSpec(dirPath) {
|
|
@@ -63,10 +63,11 @@ function buildDefaultCompiledViewSpec(dirPath, compiledName, generatedAt) {
|
|
|
63
63
|
resolveRequiredCompiledMethodFromConfig(config, `.interf/interf.json for ${dirPath}`);
|
|
64
64
|
const method = getActiveCompiledMethod(dirPath);
|
|
65
65
|
const schema = readCompiledSchemaFile(methodPackagePathForCompiled(dirPath));
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
.
|
|
69
|
-
|
|
66
|
+
const schemaArtifacts = schema ? listCompiledSchemaArtifacts(schema) : [];
|
|
67
|
+
const outputDocumentPaths = schemaArtifacts
|
|
68
|
+
.filter((artifact) => artifact.role === "output" && artifact.kind !== "runtime")
|
|
69
|
+
.map((artifact) => artifact.path);
|
|
70
|
+
const defaultNote = schemaArtifacts.find((artifact) => artifact.role === "output" && artifact.kind === "file")?.path ?? null;
|
|
70
71
|
return {
|
|
71
72
|
kind: "compiled-view-spec",
|
|
72
73
|
version: 2,
|
|
@@ -85,7 +86,7 @@ function buildDefaultCompiledViewSpec(dirPath, compiledName, generatedAt) {
|
|
|
85
86
|
{ id: "status", type: "status", title: "Compile Status", path: ".interf/runtime/health.json" },
|
|
86
87
|
{ id: "cards", type: "cards", title: "Key Metrics", path: ".interf/runtime/health.json" },
|
|
87
88
|
...(outputDocumentPaths.length > 0
|
|
88
|
-
? [{ id: "outputs", type: "documents", title: "Output
|
|
89
|
+
? [{ id: "outputs", type: "documents", title: "Output Artifacts", paths: outputDocumentPaths }]
|
|
89
90
|
: []),
|
|
90
91
|
{ id: "method", type: "documents", title: "Method Docs", paths: ["method/README.md", ...method.stages.map((stage) => `method/compile/stages/${stage.skillDir}`)] },
|
|
91
92
|
],
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { existsSync } from "node:fs";
|
|
2
2
|
import { discoverSourceFiles } from "./discovery.js";
|
|
3
|
-
import { METHOD_SCHEMA_FILE,
|
|
3
|
+
import { METHOD_SCHEMA_FILE, findCompiledSchemaArtifact, readCompiledSchemaFile, methodSchemaExists, } from "./compiled-schema.js";
|
|
4
4
|
import { resolveSourceFolderPath } from "../../project/interf-detect.js";
|
|
5
5
|
import { compiledInterfConfigPath, methodPackagePathForCompiled } from "./compiled-paths.js";
|
|
6
6
|
import { readCompiledConfig } from "./validate.js";
|
|
7
7
|
import { loadState } from "./state.js";
|
|
8
|
-
import { validateResolvedStageAcceptance, stageRecordFromState } from "./runtime-acceptance.js";
|
|
9
8
|
import { getActiveCompiledMethod, resolveRequiredCompiledMethodFromConfig, } from "../../methods/package/method-definitions.js";
|
|
10
|
-
import {
|
|
9
|
+
import { countCompiledArtifactsAtPath } from "./artifact-counts.js";
|
|
10
|
+
import { evaluateChecks } from "./check-evaluator.js";
|
|
11
11
|
function methodSchemaPresent(dirPath) {
|
|
12
12
|
return methodSchemaExists(methodPackagePathForCompiled(dirPath));
|
|
13
13
|
}
|
|
@@ -45,23 +45,57 @@ function readMethodContext(dirPath) {
|
|
|
45
45
|
function stageRequired(sourceTotal, writeCounts, stageRecordPresent) {
|
|
46
46
|
return sourceTotal > 0 || writeCounts > 0 || stageRecordPresent;
|
|
47
47
|
}
|
|
48
|
-
function
|
|
49
|
-
const
|
|
48
|
+
function artifactWriteCount(compiledPath, schema, stage) {
|
|
49
|
+
const artifactCounts = {};
|
|
50
50
|
let total = 0;
|
|
51
|
-
for (const
|
|
52
|
-
const
|
|
53
|
-
if (!
|
|
51
|
+
for (const artifactId of stage.writes) {
|
|
52
|
+
const artifact = findCompiledSchemaArtifact(schema, artifactId);
|
|
53
|
+
if (!artifact)
|
|
54
54
|
continue;
|
|
55
|
-
const count =
|
|
56
|
-
|
|
55
|
+
const count = countCompiledArtifactsAtPath(compiledPath, artifact.path, artifact.kind);
|
|
56
|
+
artifactCounts[artifactId] = count;
|
|
57
57
|
total += count;
|
|
58
58
|
}
|
|
59
|
-
return { total,
|
|
59
|
+
return { total, artifactCounts };
|
|
60
60
|
}
|
|
61
|
-
function
|
|
61
|
+
function stageRecordFromState(state, stageId) {
|
|
62
|
+
const stages = state?.stages;
|
|
63
|
+
if (!stages || typeof stages !== "object")
|
|
64
|
+
return null;
|
|
65
|
+
const stage = stages[stageId];
|
|
66
|
+
if (!stage || typeof stage !== "object" || Array.isArray(stage))
|
|
67
|
+
return null;
|
|
68
|
+
return stage;
|
|
69
|
+
}
|
|
70
|
+
function artifactsBuiltByStage(schema, stage) {
|
|
71
|
+
return (schema.artifacts ?? []).filter((artifact) => {
|
|
72
|
+
if (artifact.built_by_stages.includes(stage.id))
|
|
73
|
+
return true;
|
|
74
|
+
if (stage.writes.includes(artifact.id))
|
|
75
|
+
return true;
|
|
76
|
+
return artifact.shape.kind === "path" && (stage.writes.includes(artifact.id) || stage.writes.includes(artifact.shape.path));
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
function artifactCheckFailures(compiledPath, artifacts, counts) {
|
|
80
|
+
const failures = [];
|
|
81
|
+
for (const artifact of artifacts) {
|
|
82
|
+
const checks = artifact.checks ?? [];
|
|
83
|
+
if (checks.length === 0)
|
|
84
|
+
continue;
|
|
85
|
+
const targetPath = artifact.shape.kind === "path" ? artifact.shape.path : undefined;
|
|
86
|
+
const result = evaluateChecks(checks, {
|
|
87
|
+
rootPath: compiledPath,
|
|
88
|
+
targetPath,
|
|
89
|
+
counts,
|
|
90
|
+
});
|
|
91
|
+
failures.push(...result.failures);
|
|
92
|
+
}
|
|
93
|
+
return failures;
|
|
94
|
+
}
|
|
95
|
+
function mergeValidationCounts(sourceTotal, stageRecord, artifactCounts) {
|
|
62
96
|
const merged = {
|
|
63
97
|
source_total: sourceTotal,
|
|
64
|
-
...
|
|
98
|
+
...artifactCounts,
|
|
65
99
|
};
|
|
66
100
|
const stageCounts = stageRecord?.counts;
|
|
67
101
|
if (stageCounts && typeof stageCounts === "object" && !Array.isArray(stageCounts)) {
|
|
@@ -121,22 +155,19 @@ export function validateCompiledStage(dirPath, stageId) {
|
|
|
121
155
|
checks.stage_finished = Boolean(stageRecord?.finished_at);
|
|
122
156
|
checks.stage_succeeded = stageRecord?.status === "succeeded";
|
|
123
157
|
const writeCounts = methodStage && context.schema
|
|
124
|
-
?
|
|
125
|
-
: { total: 0,
|
|
126
|
-
const
|
|
158
|
+
? artifactWriteCount(dirPath, context.schema, methodStage)
|
|
159
|
+
: { total: 0, artifactCounts: {} };
|
|
160
|
+
const artifactCounts = mergeValidationCounts(context.sourceTotal, stageRecord, writeCounts.artifactCounts);
|
|
127
161
|
const required = stageRequired(context.sourceTotal, writeCounts.total, checks.stage_record_present);
|
|
128
|
-
let
|
|
162
|
+
let artifactErrors = [];
|
|
129
163
|
if (methodStage && context.schema) {
|
|
130
|
-
const
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
});
|
|
135
|
-
checks.acceptance_ok = acceptanceValidation.ok;
|
|
136
|
-
acceptanceErrors = acceptanceValidation.failures;
|
|
164
|
+
const artifacts = artifactsBuiltByStage(context.schema, methodStage);
|
|
165
|
+
const failures = artifactCheckFailures(dirPath, artifacts, artifactCounts);
|
|
166
|
+
checks.artifact_checks_ok = failures.length === 0;
|
|
167
|
+
artifactErrors = failures.map((proof) => `Artifact check "${proof.check_id}" failed for ${proof.kind}: ${proof.summary}`);
|
|
137
168
|
}
|
|
138
169
|
else {
|
|
139
|
-
checks.
|
|
170
|
+
checks.artifact_checks_ok = false;
|
|
140
171
|
}
|
|
141
172
|
if (required && checks.stage_record_present && !checks.stage_finished) {
|
|
142
173
|
errors.push(`Stage "${stageId}" has no finished_at proof in runtime state.`);
|
|
@@ -145,23 +176,23 @@ export function validateCompiledStage(dirPath, stageId) {
|
|
|
145
176
|
errors.push(`Stage "${stageId}" is not marked succeeded in runtime state.`);
|
|
146
177
|
}
|
|
147
178
|
if (required) {
|
|
148
|
-
errors.push(...
|
|
179
|
+
errors.push(...artifactErrors);
|
|
149
180
|
}
|
|
150
181
|
const ok = required ? errors.length === 0 : errors.length === 0;
|
|
151
182
|
const summary = !required
|
|
152
183
|
? `Stage "${stageId}" is not required yet.`
|
|
153
184
|
: ok
|
|
154
185
|
? `Stage "${stageId}" verified.`
|
|
155
|
-
: `Stage "${stageId}" failed — ${errors[0] ?? "
|
|
186
|
+
: `Stage "${stageId}" failed — ${errors[0] ?? "artifact checks not satisfied."}`;
|
|
156
187
|
return {
|
|
157
188
|
ok,
|
|
158
189
|
required,
|
|
159
190
|
stage: stageId,
|
|
160
191
|
summary,
|
|
161
192
|
counts: {
|
|
162
|
-
...
|
|
193
|
+
...artifactCounts,
|
|
163
194
|
write_artifacts: writeCounts.total,
|
|
164
|
-
|
|
195
|
+
declared_write_artifacts: methodStage?.writes.length ?? 0,
|
|
165
196
|
},
|
|
166
197
|
checks,
|
|
167
198
|
errors,
|
|
@@ -213,7 +244,7 @@ export function validateCompiledMethod(dirPath) {
|
|
|
213
244
|
stage: failedStage,
|
|
214
245
|
summary: ok
|
|
215
246
|
? `Compiled Method verified — ${completedStages}/${context.method.stages.length} stages satisfied.`
|
|
216
|
-
: `Compiled Method failed — ${errors[0] ?? "stage
|
|
247
|
+
: `Compiled Method failed — ${errors[0] ?? "stage artifact checks not satisfied."}`,
|
|
217
248
|
counts: {
|
|
218
249
|
source_total: context.sourceTotal,
|
|
219
250
|
stage_total: context.method.stages.length,
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { existsSync, readFileSync, statSync, } from "node:fs";
|
|
2
2
|
import { basename, dirname, extname, join, resolve } from "node:path";
|
|
3
|
-
import { readCompiledSchemaFile } from "./compiled-schema.js";
|
|
4
|
-
import { compiledKnowledgeRootPath } from "./compiled-schema.js";
|
|
3
|
+
import { listCompiledSchemaArtifacts, readCompiledSchemaFile } from "./compiled-schema.js";
|
|
5
4
|
import { methodPackagePathForCompiled } from "./compiled-paths.js";
|
|
6
5
|
import { listFilesRecursive } from "../../contracts/utils/filesystem.js";
|
|
7
6
|
import { readInterfConfig } from "../../project/interf-detect.js";
|
|
@@ -53,8 +52,8 @@ export function validateSynthFiles(files, options) {
|
|
|
53
52
|
};
|
|
54
53
|
}
|
|
55
54
|
export function countBrokenWikilinks(compiledRoot, noteIndexRoots, linkScanRoots) {
|
|
56
|
-
const
|
|
57
|
-
const
|
|
55
|
+
const artifactPathById = compiledArtifactDirectoryPaths(compiledRoot);
|
|
56
|
+
const directoryLeafParents = compiledDirectoryLeafParents(artifactPathById);
|
|
58
57
|
const noteIndex = new Set();
|
|
59
58
|
for (const filePath of dedupeFiles(noteIndexRoots)) {
|
|
60
59
|
for (const target of collectWikilinkTargets(filePath)) {
|
|
@@ -75,15 +74,15 @@ export function countBrokenWikilinks(compiledRoot, noteIndexRoots, linkScanRoots
|
|
|
75
74
|
if (!target)
|
|
76
75
|
continue;
|
|
77
76
|
if (target.includes("/")) {
|
|
78
|
-
if (!wikilinkPathExists(compiledRoot, target,
|
|
77
|
+
if (!wikilinkPathExists(compiledRoot, target, artifactPathById, directoryLeafParents, filePath)) {
|
|
79
78
|
brokenLinks += 1;
|
|
80
79
|
}
|
|
81
80
|
continue;
|
|
82
81
|
}
|
|
83
82
|
if (!noteIndex.has(target.toLowerCase()) &&
|
|
84
83
|
!noteIndex.has(noteName(target).toLowerCase()) &&
|
|
85
|
-
!wikilinkPathExists(compiledRoot, target,
|
|
86
|
-
!wikilinkPathExists(compiledRoot, noteName(target),
|
|
84
|
+
!wikilinkPathExists(compiledRoot, target, artifactPathById, directoryLeafParents, filePath) &&
|
|
85
|
+
!wikilinkPathExists(compiledRoot, noteName(target), artifactPathById, directoryLeafParents, filePath)) {
|
|
87
86
|
brokenLinks += 1;
|
|
88
87
|
}
|
|
89
88
|
}
|
|
@@ -172,22 +171,25 @@ function countWords(text) {
|
|
|
172
171
|
function noteName(filePath) {
|
|
173
172
|
return basename(filePath, extname(filePath));
|
|
174
173
|
}
|
|
175
|
-
function wikilinkPathExists(compiledRoot, target,
|
|
176
|
-
return linkPathCandidates(compiledRoot, target,
|
|
174
|
+
function wikilinkPathExists(compiledRoot, target, artifactPathById, directoryLeafParents, sourceFilePath) {
|
|
175
|
+
return linkPathCandidates(compiledRoot, target, artifactPathById, directoryLeafParents, sourceFilePath)
|
|
177
176
|
.some((candidate) => existsSync(candidate));
|
|
178
177
|
}
|
|
179
|
-
function linkPathCandidates(compiledRoot, target,
|
|
178
|
+
function linkPathCandidates(compiledRoot, target, artifactPathById, directoryLeafParents, sourceFilePath) {
|
|
180
179
|
const candidates = new Set();
|
|
181
180
|
addPathCandidate(candidates, join(compiledRoot, target));
|
|
182
181
|
if (sourceFilePath && (target.startsWith("./") || target.startsWith("../"))) {
|
|
183
182
|
addPathCandidateIfInside(candidates, compiledRoot, resolve(dirname(sourceFilePath), target));
|
|
184
183
|
}
|
|
185
184
|
const [firstSegment] = target.split("/");
|
|
186
|
-
if (firstSegment
|
|
187
|
-
|
|
185
|
+
if (firstSegment) {
|
|
186
|
+
const parentPath = directoryLeafParents.get(firstSegment);
|
|
187
|
+
if (parentPath) {
|
|
188
|
+
addPathCandidate(candidates, join(compiledRoot, parentPath, target));
|
|
189
|
+
}
|
|
188
190
|
}
|
|
189
191
|
if (firstSegment) {
|
|
190
|
-
const normalizedPrefix =
|
|
192
|
+
const normalizedPrefix = artifactPathById.get(firstSegment);
|
|
191
193
|
if (normalizedPrefix) {
|
|
192
194
|
const remainder = target.slice(firstSegment.length).replace(/^\/+/, "");
|
|
193
195
|
addPathCandidate(candidates, join(compiledRoot, normalizedPrefix, remainder));
|
|
@@ -206,24 +208,24 @@ function addPathCandidateIfInside(candidates, compiledRoot, absolutePath) {
|
|
|
206
208
|
return;
|
|
207
209
|
addPathCandidate(candidates, candidate);
|
|
208
210
|
}
|
|
209
|
-
function
|
|
211
|
+
function compiledArtifactDirectoryPaths(compiledRoot) {
|
|
210
212
|
const methodRoot = methodPackagePathForCompiled(compiledRoot);
|
|
211
213
|
const schema = readCompiledSchemaFile(methodRoot);
|
|
212
214
|
if (!schema)
|
|
213
215
|
return new Map();
|
|
214
|
-
return new Map(schema
|
|
215
|
-
.filter((
|
|
216
|
-
.map((
|
|
216
|
+
return new Map(listCompiledSchemaArtifacts(schema)
|
|
217
|
+
.filter((artifact) => artifact.kind === "directory")
|
|
218
|
+
.map((artifact) => [artifact.id, artifact.path]));
|
|
217
219
|
}
|
|
218
|
-
function
|
|
219
|
-
const
|
|
220
|
-
for (const
|
|
221
|
-
const [root, leaf, ...rest] =
|
|
222
|
-
if (root
|
|
220
|
+
function compiledDirectoryLeafParents(artifactPathById) {
|
|
221
|
+
const parents = new Map();
|
|
222
|
+
for (const artifactPath of artifactPathById.values()) {
|
|
223
|
+
const [root, leaf, ...rest] = artifactPath.split("/");
|
|
224
|
+
if (!root || !leaf || rest.length > 0)
|
|
223
225
|
continue;
|
|
224
|
-
|
|
226
|
+
parents.set(leaf, root);
|
|
225
227
|
}
|
|
226
|
-
return
|
|
228
|
+
return parents;
|
|
227
229
|
}
|
|
228
230
|
function collectWikilinkTargets(filePath) {
|
|
229
231
|
const targets = new Set();
|