@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
|
@@ -4,9 +4,10 @@ import { basename, dirname, join, relative, sep as pathSep } from "node:path";
|
|
|
4
4
|
import { CHART_APPROXIMATION_NOTES } from "./chart-guidance.js";
|
|
5
5
|
import { buildCompiledSourceFiles } from "../../compile/source-files.js";
|
|
6
6
|
import { METHOD_PACKAGE_DIR } from "../../../project/interf-detect.js";
|
|
7
|
-
import {
|
|
7
|
+
import { CHECK_KINDS, } from "../../../contracts/lib/schema.js";
|
|
8
|
+
import { CONTEXT_INTERFACE_FILE as METHOD_SCHEMA_FILE, contextInterfaceArtifactAbsolutePath as compiledArtifactAbsolutePath, listContextInterfaceArtifacts, readContextInterface as readCompiledSchemaFile, resolveContextInterfacePath as resolveMethodSchemaPath, } from "../../../methods/package/context-interface.js";
|
|
8
9
|
import { stageExecutionShellsRoot, methodImprovementLoopRoot, methodPackagePathForCompiled, compiledInterfConfigPath, compiledRuntimeRoot, compiledRuntimeSourceSnapshotPath, compiledRuntimeStageInputsPath, } from "../../compile/compiled-paths.js";
|
|
9
|
-
import {
|
|
10
|
+
import { ensureCompiledArtifactTargets } from "../../compile/compiled-schema.js";
|
|
10
11
|
import { listFilesRecursive } from "../../../contracts/utils/filesystem.js";
|
|
11
12
|
import { resolveMethodImprovementReviewSourcePaths } from "../../../methods/package/method-review-paths.js";
|
|
12
13
|
const LOCAL_SKILL_ROOTS = [
|
|
@@ -26,18 +27,18 @@ export function writeNativeAgentSurface(rootPath, agentsContent, skillName, skil
|
|
|
26
27
|
function compiledQuerySkillSourcePath(compiledPath) {
|
|
27
28
|
return join(methodPackagePathForCompiled(compiledPath), "use", "query", "SKILL.md");
|
|
28
29
|
}
|
|
29
|
-
function
|
|
30
|
+
function compiledArtifactSummaryLines(compiledPath) {
|
|
30
31
|
const schema = readCompiledSchemaFile(methodPackagePathForCompiled(compiledPath));
|
|
31
32
|
if (!schema)
|
|
32
33
|
return ["- No Method schema is available yet."];
|
|
33
|
-
return schema
|
|
34
|
-
.filter((
|
|
35
|
-
.map((
|
|
34
|
+
return listContextInterfaceArtifacts(schema)
|
|
35
|
+
.filter((artifact) => artifact.kind !== "runtime")
|
|
36
|
+
.map((artifact) => `- \`${artifact.id}\` -> \`${artifact.path}\` (${artifact.role} ${artifact.kind})`);
|
|
36
37
|
}
|
|
37
38
|
export function renderCompiledAgents(compiledPath, name, methodId, about, options = {}) {
|
|
38
39
|
const methodOriginSelected = options.methodOriginSelected ?? methodId;
|
|
39
40
|
const methodLocalDraft = options.methodLocalDraft === true;
|
|
40
|
-
const
|
|
41
|
+
const artifactLines = compiledArtifactSummaryLines(compiledPath);
|
|
41
42
|
return [
|
|
42
43
|
`# ${name}`,
|
|
43
44
|
"",
|
|
@@ -53,7 +54,7 @@ export function renderCompiledAgents(compiledPath, name, methodId, about, option
|
|
|
53
54
|
"## How to use this portable context",
|
|
54
55
|
"",
|
|
55
56
|
"1. Use the local native `interf-query` skill that Interf generated for this portable context.",
|
|
56
|
-
"2. Let the Method docs and declared
|
|
57
|
+
"2. Let the Method docs and declared Artifacts guide retrieval instead of assuming a fixed note layout.",
|
|
57
58
|
"3. Use `.interf/runtime/source-snapshot.json` when you need to inspect the source references behind the output.",
|
|
58
59
|
"",
|
|
59
60
|
"## How this portable context works",
|
|
@@ -72,8 +73,8 @@ export function renderCompiledAgents(compiledPath, name, methodId, about, option
|
|
|
72
73
|
"- `.interf/method/compile/stages/` defines stage-specific docs that Interf projects into native execution shells for automated runs.",
|
|
73
74
|
"- Native local query skills are generated under local agent skill directories such as `.claude/skills/` and `.codex/skills/`.",
|
|
74
75
|
"- `.interf/runtime/source-snapshot.json` records the source files assigned to the latest runtime snapshot.",
|
|
75
|
-
`- Method
|
|
76
|
-
...
|
|
76
|
+
`- Method Artifacts are declared in \`.interf/method/${METHOD_SCHEMA_FILE}\`.`,
|
|
77
|
+
...artifactLines,
|
|
77
78
|
"- `.interf/runtime/` holds runtime artifacts written by Interf.",
|
|
78
79
|
"- `.interf/tests/` mirrors the latest saved readiness-check run and keeps detailed target runs plus preserved sandboxes.",
|
|
79
80
|
"- `.interf/tests/targets/` holds detailed source-files and compiled target runs plus preserved test sandboxes.",
|
|
@@ -110,12 +111,12 @@ export function renderCompiledQuerySkill() {
|
|
|
110
111
|
"",
|
|
111
112
|
"Default loop:",
|
|
112
113
|
"1. Read `.interf/method/README.md` and this file first.",
|
|
113
|
-
`2. Use the Method
|
|
114
|
+
`2. Use the Method Artifacts declared in \`.interf/method/${METHOD_SCHEMA_FILE}\` before consulting source references.`,
|
|
114
115
|
"3. Use `.interf/runtime/source-snapshot.json` for direct quotes, verification, exact lookups, and cases where the portable context is missing the needed evidence or is ambiguous.",
|
|
115
116
|
"",
|
|
116
117
|
"Answering rule:",
|
|
117
118
|
"- do not modify source files while answering",
|
|
118
|
-
"- treat the Method as the portable-context contract and use its
|
|
119
|
+
"- treat the Method as the portable-context contract and use its Artifacts as the working retrieval surface",
|
|
119
120
|
"- say explicitly when an answer depends on approximation, bounded inference, or a source re-check",
|
|
120
121
|
"- use source references to confirm source page, metric family, provenance, or exact wording when the portable context is missing the needed evidence or is ambiguous",
|
|
121
122
|
"- do not invent navigation or note structure beyond what this Method declares",
|
|
@@ -142,7 +143,7 @@ function renderSourceFilesTestAgents() {
|
|
|
142
143
|
"## Rules",
|
|
143
144
|
"",
|
|
144
145
|
"- Answer only from source files listed in `runtime/source-files.json`.",
|
|
145
|
-
"- There is no portable context here, so do not assume any portable-context
|
|
146
|
+
"- There is no portable context here, so do not assume any portable-context Artifacts exist.",
|
|
146
147
|
"- Do not treat hidden runtime files or test artifacts as evidence.",
|
|
147
148
|
...chartNotes,
|
|
148
149
|
"- Write the requested answer and trace files, then stop.",
|
|
@@ -181,24 +182,24 @@ function readCompiledQuerySkillSource(compiledPath) {
|
|
|
181
182
|
function stageShellMethodRoot(shellRoot) {
|
|
182
183
|
return join(shellRoot, METHOD_PACKAGE_DIR);
|
|
183
184
|
}
|
|
184
|
-
function
|
|
185
|
-
return join(shellRoot, "inputs",
|
|
185
|
+
function shellInputArtifactPath(shellRoot, artifactId) {
|
|
186
|
+
return join(shellRoot, "inputs", artifactId);
|
|
186
187
|
}
|
|
187
|
-
function
|
|
188
|
-
return join(shellRoot, "outputs",
|
|
188
|
+
function shellOutputArtifactPath(shellRoot, artifactId) {
|
|
189
|
+
return join(shellRoot, "outputs", artifactId);
|
|
189
190
|
}
|
|
190
|
-
function
|
|
191
|
+
function shellArtifactAliasMountPath(shellRoot, artifact, mountKind) {
|
|
191
192
|
const mountRoot = mountKind === "inputs"
|
|
192
|
-
?
|
|
193
|
-
:
|
|
194
|
-
return
|
|
195
|
-
? join(mountRoot, basename(
|
|
193
|
+
? shellInputArtifactPath(shellRoot, artifact.id)
|
|
194
|
+
: shellOutputArtifactPath(shellRoot, artifact.id);
|
|
195
|
+
return artifact.kind === "file"
|
|
196
|
+
? join(mountRoot, basename(artifact.path))
|
|
196
197
|
: mountRoot;
|
|
197
198
|
}
|
|
198
|
-
function
|
|
199
|
-
return
|
|
200
|
-
? `${mountKind}/${
|
|
201
|
-
: `${mountKind}/${
|
|
199
|
+
function describeShellArtifactAliasMountPath(artifact, mountKind) {
|
|
200
|
+
return artifact.kind === "file"
|
|
201
|
+
? `${mountKind}/${artifact.id}/${basename(artifact.path)}`
|
|
202
|
+
: `${mountKind}/${artifact.id}`;
|
|
202
203
|
}
|
|
203
204
|
function shellRuntimePath(shellRoot, relativePath) {
|
|
204
205
|
return join(shellRoot, "runtime", relativePath);
|
|
@@ -240,15 +241,15 @@ function loadCompiledSchema(compiledPath) {
|
|
|
240
241
|
}
|
|
241
242
|
return schema;
|
|
242
243
|
}
|
|
243
|
-
function
|
|
244
|
-
return new Map(schema.
|
|
244
|
+
function artifactMap(schema) {
|
|
245
|
+
return new Map(listContextInterfaceArtifacts(schema).map((artifact) => [artifact.id, artifact]));
|
|
245
246
|
}
|
|
246
|
-
function
|
|
247
|
-
const
|
|
248
|
-
if (!
|
|
249
|
-
throw new Error(`Missing Method schema
|
|
247
|
+
function artifactOrThrow(artifacts, artifactId) {
|
|
248
|
+
const artifact = artifacts.get(artifactId);
|
|
249
|
+
if (!artifact) {
|
|
250
|
+
throw new Error(`Missing Method schema Artifact "${artifactId}" for stage shell projection.`);
|
|
250
251
|
}
|
|
251
|
-
return
|
|
252
|
+
return artifact;
|
|
252
253
|
}
|
|
253
254
|
function normalizeArtifactRelativePath(path) {
|
|
254
255
|
return path
|
|
@@ -263,28 +264,29 @@ function relativePathEqualsOrWithin(basePath, candidatePath) {
|
|
|
263
264
|
return false;
|
|
264
265
|
return candidate === base || candidate.startsWith(`${base}/`);
|
|
265
266
|
}
|
|
266
|
-
function
|
|
267
|
-
|
|
267
|
+
function stageWriteArtifactSet(schema, stage) {
|
|
268
|
+
const artifacts = listContextInterfaceArtifacts(schema);
|
|
269
|
+
return new Set(stage.writes.filter((artifactId) => artifacts.some((artifact) => artifact.id === artifactId)));
|
|
268
270
|
}
|
|
269
|
-
function
|
|
270
|
-
const materialized =
|
|
271
|
-
for (const
|
|
272
|
-
if (
|
|
273
|
-
materialized.add(
|
|
271
|
+
function stageMaterializedArtifactSet(schema, stage, writeArtifacts = []) {
|
|
272
|
+
const materialized = stageWriteArtifactSet(schema, stage);
|
|
273
|
+
for (const artifact of listContextInterfaceArtifacts(schema)) {
|
|
274
|
+
if (artifact.kind === "runtime" && stage.reads.includes(artifact.id)) {
|
|
275
|
+
materialized.add(artifact.id);
|
|
274
276
|
}
|
|
275
277
|
}
|
|
276
278
|
for (const artifactPath of writeArtifacts) {
|
|
277
279
|
const normalizedArtifactPath = normalizeArtifactRelativePath(artifactPath);
|
|
278
280
|
if (normalizedArtifactPath.length === 0)
|
|
279
281
|
continue;
|
|
280
|
-
const owner = schema.
|
|
282
|
+
const owner = listContextInterfaceArtifacts(schema).find((artifact) => relativePathEqualsOrWithin(artifact.path, normalizedArtifactPath));
|
|
281
283
|
if (owner) {
|
|
282
284
|
materialized.add(owner.id);
|
|
283
285
|
}
|
|
284
286
|
}
|
|
285
287
|
return materialized;
|
|
286
288
|
}
|
|
287
|
-
function ensureShellLocalProjection(sourcePath, targetPath,
|
|
289
|
+
function ensureShellLocalProjection(sourcePath, targetPath, artifact) {
|
|
288
290
|
if (existsSync(sourcePath)) {
|
|
289
291
|
copyResolvedTree({
|
|
290
292
|
sourcePath,
|
|
@@ -293,7 +295,7 @@ function ensureShellLocalProjection(sourcePath, targetPath, zone) {
|
|
|
293
295
|
});
|
|
294
296
|
return;
|
|
295
297
|
}
|
|
296
|
-
if (
|
|
298
|
+
if (artifact.kind === "file") {
|
|
297
299
|
mkdirSync(dirname(targetPath), { recursive: true });
|
|
298
300
|
return;
|
|
299
301
|
}
|
|
@@ -303,7 +305,7 @@ function ensureCompiledExecutionSurface(compiledPath) {
|
|
|
303
305
|
mkdirSync(compiledRuntimeRoot(compiledPath), { recursive: true });
|
|
304
306
|
mkdirSync(methodPackagePathForCompiled(compiledPath), { recursive: true });
|
|
305
307
|
const schema = loadCompiledSchema(compiledPath);
|
|
306
|
-
|
|
308
|
+
ensureCompiledArtifactTargets(compiledPath, schema);
|
|
307
309
|
return schema;
|
|
308
310
|
}
|
|
309
311
|
function readStageMethodDoc(compiledPath, stage) {
|
|
@@ -332,12 +334,12 @@ function renderStageExecutionAgents(compiledName, methodId, stage) {
|
|
|
332
334
|
"",
|
|
333
335
|
"## Shell ABI",
|
|
334
336
|
"",
|
|
335
|
-
"- `inputs/<
|
|
336
|
-
"- `outputs/<
|
|
337
|
-
"- For file
|
|
337
|
+
"- `inputs/<artifact-id>/` = read mounts for the current stage.",
|
|
338
|
+
"- `outputs/<artifact-id>/` = write mounts for the current stage.",
|
|
339
|
+
"- For file Artifacts, `runtime/paths.json` points to the exact file path inside those mount roots.",
|
|
338
340
|
"- `runtime/source-snapshot.json` = source references captured for this run.",
|
|
339
341
|
"- `runtime/stage-inputs.json` = exact source references assigned to this stage.",
|
|
340
|
-
"- declared
|
|
342
|
+
"- declared Artifact paths are also projected at the shell root so Method-relative contract paths stay valid.",
|
|
341
343
|
"- `runtime/` = stage contract and machine-readable path map for this shell.",
|
|
342
344
|
"- `method/` = Method metadata, `method.schema.json`, and docs for the current stage only.",
|
|
343
345
|
"",
|
|
@@ -348,9 +350,9 @@ function renderStageExecutionAgents(compiledName, methodId, stage) {
|
|
|
348
350
|
"- This shell has its own AGENTS/CLAUDE/native skills. It does not inherit the portable-context query shell.",
|
|
349
351
|
"- The portable context root itself is not linked into this shell.",
|
|
350
352
|
"- Do not switch into query mode or act like a user-facing assistant.",
|
|
351
|
-
"- Do not modify files under `inputs/` unless the same
|
|
353
|
+
"- Do not modify files under `inputs/` unless the same Artifact is also mounted under `outputs/`.",
|
|
352
354
|
"",
|
|
353
|
-
"## Current Stage
|
|
355
|
+
"## Current Stage Artifacts",
|
|
354
356
|
"",
|
|
355
357
|
`- reads: ${stage.reads.join(", ")}`,
|
|
356
358
|
`- writes: ${stage.writes.join(", ")}`,
|
|
@@ -359,7 +361,7 @@ function renderStageExecutionAgents(compiledName, methodId, stage) {
|
|
|
359
361
|
"",
|
|
360
362
|
"- complete the current stage",
|
|
361
363
|
"- honor the deterministic contract",
|
|
362
|
-
"- write outputs through the declared
|
|
364
|
+
"- write outputs through the declared Artifact mounts",
|
|
363
365
|
"- stop when the stage is complete",
|
|
364
366
|
"",
|
|
365
367
|
].join("\n");
|
|
@@ -378,7 +380,7 @@ function renderStageExecutionSkill(stage, stageMethodDoc) {
|
|
|
378
380
|
"This local native skill exists for automated Interf stage execution.",
|
|
379
381
|
"Read `runtime/stage-contract.json` first.",
|
|
380
382
|
"Then read `runtime/source-snapshot.json`, `runtime/stage-inputs.json`, and `runtime/paths.json`.",
|
|
381
|
-
"Use the assigned source references and the mounted `inputs/` and `outputs/`
|
|
383
|
+
"Use the assigned source references and the mounted `inputs/` and `outputs/` Artifacts for this stage.",
|
|
382
384
|
"Do not switch into manual query mode.",
|
|
383
385
|
"",
|
|
384
386
|
"## Current Stage",
|
|
@@ -440,33 +442,33 @@ function projectMethodMetadata(compiledPath, shellRoot, stage) {
|
|
|
440
442
|
linkPath(stageDocsPath, join(shellMethodRoot, "compile", "stages", stage.skillDir));
|
|
441
443
|
}
|
|
442
444
|
}
|
|
443
|
-
function
|
|
444
|
-
const
|
|
445
|
-
for (const
|
|
446
|
-
if (
|
|
445
|
+
function projectCompiledSchemaArtifacts(compiledPath, shellRoot, schema, artifactIds, materializedArtifactIds) {
|
|
446
|
+
const allowedArtifactIds = artifactIds ? new Set(artifactIds) : null;
|
|
447
|
+
for (const artifact of listContextInterfaceArtifacts(schema)) {
|
|
448
|
+
if (allowedArtifactIds && !allowedArtifactIds.has(artifact.id))
|
|
447
449
|
continue;
|
|
448
|
-
const sourcePath =
|
|
449
|
-
const targetPath = join(shellRoot,
|
|
450
|
-
if (
|
|
451
|
-
ensureShellLocalProjection(sourcePath, targetPath,
|
|
450
|
+
const sourcePath = compiledArtifactAbsolutePath(compiledPath, artifact);
|
|
451
|
+
const targetPath = join(shellRoot, artifact.path);
|
|
452
|
+
if (materializedArtifactIds?.has(artifact.id)) {
|
|
453
|
+
ensureShellLocalProjection(sourcePath, targetPath, artifact);
|
|
452
454
|
continue;
|
|
453
455
|
}
|
|
454
456
|
linkPath(sourcePath, targetPath);
|
|
455
457
|
}
|
|
456
458
|
}
|
|
457
|
-
function
|
|
458
|
-
const
|
|
459
|
-
const mountFor = (
|
|
460
|
-
const
|
|
459
|
+
function buildStageArtifactMounts(compiledPath, shellRoot, stage, schema) {
|
|
460
|
+
const artifacts = artifactMap(schema);
|
|
461
|
+
const mountFor = (artifactId) => {
|
|
462
|
+
const artifact = artifactOrThrow(artifacts, artifactId);
|
|
461
463
|
return {
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
shell_root_path:
|
|
465
|
-
input_mount_path: stage.reads.includes(
|
|
466
|
-
?
|
|
464
|
+
artifact_id: artifact.id,
|
|
465
|
+
artifact_path: artifact.path,
|
|
466
|
+
shell_root_path: artifact.path,
|
|
467
|
+
input_mount_path: stage.reads.includes(artifactId)
|
|
468
|
+
? describeShellArtifactAliasMountPath(artifact, "inputs")
|
|
467
469
|
: null,
|
|
468
|
-
output_mount_path: stage.writes.includes(
|
|
469
|
-
?
|
|
470
|
+
output_mount_path: stage.writes.includes(artifactId)
|
|
471
|
+
? describeShellArtifactAliasMountPath(artifact, "outputs")
|
|
470
472
|
: null,
|
|
471
473
|
};
|
|
472
474
|
};
|
|
@@ -475,16 +477,16 @@ function buildStageZoneMounts(compiledPath, shellRoot, stage, schema) {
|
|
|
475
477
|
writes: stage.writes.map(mountFor),
|
|
476
478
|
};
|
|
477
479
|
}
|
|
478
|
-
function
|
|
479
|
-
const
|
|
480
|
-
for (const
|
|
481
|
-
const
|
|
482
|
-
const targetPath = join(shellRoot,
|
|
483
|
-
if (stage.reads.includes(
|
|
484
|
-
linkRelativePath(targetPath,
|
|
480
|
+
function projectStageArtifactMountAliases(shellRoot, stage, schema) {
|
|
481
|
+
const artifacts = artifactMap(schema);
|
|
482
|
+
for (const artifactId of new Set([...stage.reads, ...stage.writes])) {
|
|
483
|
+
const artifact = artifactOrThrow(artifacts, artifactId);
|
|
484
|
+
const targetPath = join(shellRoot, artifact.path);
|
|
485
|
+
if (stage.reads.includes(artifactId)) {
|
|
486
|
+
linkRelativePath(targetPath, shellArtifactAliasMountPath(shellRoot, artifact, "inputs"));
|
|
485
487
|
}
|
|
486
|
-
if (stage.writes.includes(
|
|
487
|
-
linkRelativePath(targetPath,
|
|
488
|
+
if (stage.writes.includes(artifactId)) {
|
|
489
|
+
linkRelativePath(targetPath, shellArtifactAliasMountPath(shellRoot, artifact, "outputs"));
|
|
488
490
|
}
|
|
489
491
|
}
|
|
490
492
|
}
|
|
@@ -501,46 +503,46 @@ function writeExecutionShellPathsFile(shellRoot, methodId, stage, mounts) {
|
|
|
501
503
|
}
|
|
502
504
|
export function syncStageExecutionShellWrites(compiledPath, shellRoot, stage, writeArtifacts = []) {
|
|
503
505
|
const schema = ensureCompiledExecutionSurface(compiledPath);
|
|
504
|
-
const
|
|
505
|
-
const
|
|
506
|
-
.map((
|
|
507
|
-
for (const
|
|
508
|
-
const
|
|
509
|
-
const outputAliasPath =
|
|
510
|
-
const
|
|
506
|
+
const artifacts = artifactMap(schema);
|
|
507
|
+
const stageWriteArtifacts = Array.from(stageWriteArtifactSet(schema, stage))
|
|
508
|
+
.map((artifactId) => artifactOrThrow(artifacts, artifactId));
|
|
509
|
+
for (const artifact of stageWriteArtifacts) {
|
|
510
|
+
const canonicalShellArtifactPath = join(shellRoot, artifact.path);
|
|
511
|
+
const outputAliasPath = shellArtifactAliasMountPath(shellRoot, artifact, "outputs");
|
|
512
|
+
const shellArtifactPath = artifact.kind === "file" &&
|
|
511
513
|
existsSync(outputAliasPath) &&
|
|
512
514
|
!lstatSync(outputAliasPath).isSymbolicLink()
|
|
513
515
|
? outputAliasPath
|
|
514
|
-
:
|
|
515
|
-
if (!existsSync(
|
|
516
|
+
: canonicalShellArtifactPath;
|
|
517
|
+
if (!existsSync(shellArtifactPath))
|
|
516
518
|
continue;
|
|
517
|
-
const
|
|
518
|
-
if (
|
|
519
|
+
const shellArtifactStat = lstatSync(shellArtifactPath);
|
|
520
|
+
if (shellArtifactStat.isSymbolicLink())
|
|
519
521
|
continue;
|
|
520
|
-
const
|
|
521
|
-
if (
|
|
522
|
-
const
|
|
523
|
-
const
|
|
524
|
-
? listFilesRecursive(
|
|
522
|
+
const compiledArtifactPath = compiledArtifactAbsolutePath(compiledPath, artifact);
|
|
523
|
+
if (shellArtifactStat.isDirectory()) {
|
|
524
|
+
const shellArtifactFiles = listFilesRecursive(shellArtifactPath);
|
|
525
|
+
const compiledArtifactFiles = existsSync(compiledArtifactPath)
|
|
526
|
+
? listFilesRecursive(compiledArtifactPath)
|
|
525
527
|
: [];
|
|
526
|
-
if (
|
|
528
|
+
if (shellArtifactFiles.length === 0 && compiledArtifactFiles.length > 0) {
|
|
527
529
|
continue;
|
|
528
530
|
}
|
|
529
|
-
rmSync(
|
|
530
|
-
mkdirSync(dirname(
|
|
531
|
-
cpSync(
|
|
531
|
+
rmSync(compiledArtifactPath, { recursive: true, force: true });
|
|
532
|
+
mkdirSync(dirname(compiledArtifactPath), { recursive: true });
|
|
533
|
+
cpSync(shellArtifactPath, compiledArtifactPath, {
|
|
532
534
|
recursive: true,
|
|
533
535
|
force: true,
|
|
534
536
|
});
|
|
535
537
|
continue;
|
|
536
538
|
}
|
|
537
|
-
mkdirSync(dirname(
|
|
538
|
-
copyFileSync(
|
|
539
|
+
mkdirSync(dirname(compiledArtifactPath), { recursive: true });
|
|
540
|
+
copyFileSync(shellArtifactPath, compiledArtifactPath);
|
|
539
541
|
}
|
|
540
542
|
for (const artifactPath of writeArtifacts) {
|
|
541
543
|
const normalizedArtifactPath = normalizeArtifactRelativePath(artifactPath);
|
|
542
544
|
if (normalizedArtifactPath.length === 0 ||
|
|
543
|
-
|
|
545
|
+
stageWriteArtifacts.some((artifact) => relativePathEqualsOrWithin(artifact.path, normalizedArtifactPath))) {
|
|
544
546
|
continue;
|
|
545
547
|
}
|
|
546
548
|
const shellArtifactPath = join(shellRoot, normalizedArtifactPath);
|
|
@@ -747,9 +749,8 @@ function renderMethodAuthoringAgents(options) {
|
|
|
747
749
|
"- Edit only files under `method/`.",
|
|
748
750
|
"- Do not edit source artifacts.",
|
|
749
751
|
"- Keep the Method package valid for the current compiler API and `method.schema.json`.",
|
|
750
|
-
"- Use kebab-case ids everywhere: stage ids, skill_dir values,
|
|
751
|
-
"-
|
|
752
|
-
"- For file output zones that replace scaffold files, add `artifacts_must_not_contain` entries that reject `Not yet compiled.` placeholder text; its keys must be artifact paths like `home.md`, not zone ids like `home`.",
|
|
752
|
+
"- Use kebab-case ids everywhere: stage ids, skill_dir values, Artifact ids, reads/writes values, and package ids. Never use underscores.",
|
|
753
|
+
"- Put deterministic validation on Artifact `checks[]`; do not add stage `acceptance` blocks.",
|
|
753
754
|
"- Prefer direct file-reading and search tools over shell commands for routine file inspection.",
|
|
754
755
|
"- Do not use shell helpers like `cat`, `sed`, `ls`, or `find` when a native read/search tool can inspect the same files.",
|
|
755
756
|
"",
|
|
@@ -757,7 +758,8 @@ function renderMethodAuthoringAgents(options) {
|
|
|
757
758
|
"",
|
|
758
759
|
"- produce one standalone Method package tuned to the source data, desired outputs, and checks in this task",
|
|
759
760
|
"- replace the neutral scaffold topology with the stage graph this agent work needs",
|
|
760
|
-
"- define
|
|
761
|
+
"- define Artifacts and checks so Interf can show whether the data is ready",
|
|
762
|
+
"- satisfy every `artifact_requirements[]` entry from `runtime/authoring-context.json` when entries are present",
|
|
761
763
|
"- preserve deterministic stage and context-interface contracts",
|
|
762
764
|
"- stop once the Method edits are complete",
|
|
763
765
|
"",
|
|
@@ -779,10 +781,12 @@ function renderMethodAuthoringSkill() {
|
|
|
779
781
|
"Rules:",
|
|
780
782
|
"- edit only `method/`",
|
|
781
783
|
`- keep \`method.json\`, \`${METHOD_SCHEMA_FILE}\`, and any changed stage docs aligned`,
|
|
782
|
-
"-
|
|
783
|
-
"-
|
|
784
|
+
"- put deterministic validation on Artifact `checks[]`; do not add stage `acceptance` blocks",
|
|
785
|
+
"- use only CheckKind values listed in `runtime/authoring-context.json`; do not invent aliases",
|
|
786
|
+
"- keep Artifact checks and the producing stage docs aligned",
|
|
787
|
+
"- satisfy every `artifact_requirements[]` entry from `runtime/authoring-context.json` when entries are present",
|
|
784
788
|
"- design the stage graph from the source data and preparation-and-evidence brief",
|
|
785
|
-
"- use kebab-case ids everywhere: stage ids, skill_dir values,
|
|
789
|
+
"- use kebab-case ids everywhere: stage ids, skill_dir values, Artifact ids, reads/writes values, and package ids; never use underscores",
|
|
786
790
|
"- replace the placeholder `prepare` stage unless that exact stage is truly the final method",
|
|
787
791
|
"- keep the package standalone; do not introduce runtime inheritance or hidden source-package assumptions",
|
|
788
792
|
"- do not introduce wikilinks unless the Method also creates the target note by exact basename or explicit relative path",
|
|
@@ -790,7 +794,7 @@ function renderMethodAuthoringSkill() {
|
|
|
790
794
|
"- prefer conservative routing changes over speculative note sprawl",
|
|
791
795
|
"- prefer direct file-reading and search tools over shell commands for routine file inspection",
|
|
792
796
|
"- do not use shell helpers like `cat`, `sed`, `ls`, or `find` when a native read/search tool can inspect the same files",
|
|
793
|
-
"- do not hardcode readiness-check answers into Method docs",
|
|
797
|
+
"- do not hardcode readiness-check answers into reusable Method docs",
|
|
794
798
|
"- do not edit source artifacts",
|
|
795
799
|
"",
|
|
796
800
|
].join("\n");
|
|
@@ -812,6 +816,8 @@ export function createMethodAuthoringShell(options) {
|
|
|
812
816
|
method_label: options.label,
|
|
813
817
|
...(options.referenceMethodId ? { reference_method_id: options.referenceMethodId } : {}),
|
|
814
818
|
task_prompt: options.taskPrompt,
|
|
819
|
+
allowed_check_kinds: CHECK_KINDS,
|
|
820
|
+
artifact_requirements: options.artifactRequirements ?? [],
|
|
815
821
|
preparation: {
|
|
816
822
|
source_folder_path: options.sourceFolderPath,
|
|
817
823
|
checks: {
|
|
@@ -866,7 +872,7 @@ function renderMethodImprovementAgents(compiledName, methodId, loopIndex) {
|
|
|
866
872
|
"- Do not edit checks, test specs, source files, or generated context outputs.",
|
|
867
873
|
"- Review context outputs under `artifacts/compiled-view/` and test/runtime evidence under `artifacts/`.",
|
|
868
874
|
"- Keep the Method package valid for the current compiler API and `method.schema.json`.",
|
|
869
|
-
"-
|
|
875
|
+
"- Put deterministic validation on Artifact `checks[]`; do not add stage `acceptance` blocks.",
|
|
870
876
|
"",
|
|
871
877
|
"## Goal",
|
|
872
878
|
"",
|
|
@@ -916,15 +922,15 @@ function renderMethodImprovementSkill(methodId, loopIndex, improvementDoc) {
|
|
|
916
922
|
function projectCompiledReviewArtifactsSnapshot(compiledPath, shellRoot, schema) {
|
|
917
923
|
const compiledViewRoot = join(shellRoot, "artifacts", "compiled-view");
|
|
918
924
|
mkdirSync(compiledViewRoot, { recursive: true });
|
|
919
|
-
for (const
|
|
920
|
-
if (
|
|
925
|
+
for (const artifact of listContextInterfaceArtifacts(schema)) {
|
|
926
|
+
if (artifact.kind === "runtime" || artifact.path === "source-files")
|
|
921
927
|
continue;
|
|
922
|
-
const sourcePath =
|
|
928
|
+
const sourcePath = compiledArtifactAbsolutePath(compiledPath, artifact);
|
|
923
929
|
if (!existsSync(sourcePath))
|
|
924
930
|
continue;
|
|
925
931
|
copyResolvedTree({
|
|
926
932
|
sourcePath,
|
|
927
|
-
targetPath: join(compiledViewRoot,
|
|
933
|
+
targetPath: join(compiledViewRoot, artifact.path),
|
|
928
934
|
shellType: "method-improvement",
|
|
929
935
|
});
|
|
930
936
|
}
|
|
@@ -970,21 +976,22 @@ export function projectSourceFilesTestQueryShell(rootPath) {
|
|
|
970
976
|
}
|
|
971
977
|
export function createStageExecutionShell(compiledPath, compiledName, methodId, stage, writeArtifacts = []) {
|
|
972
978
|
const schema = ensureCompiledExecutionSurface(compiledPath);
|
|
973
|
-
const
|
|
979
|
+
const materializedArtifacts = stageMaterializedArtifactSet(schema, stage, writeArtifacts);
|
|
974
980
|
const shellsRoot = stageExecutionShellsRoot(compiledPath);
|
|
975
981
|
const shellRoot = join(shellsRoot, `${stage.id}-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`);
|
|
976
982
|
mkdirSync(shellRoot, { recursive: true });
|
|
977
983
|
mkdirSync(join(shellRoot, "runtime"), { recursive: true });
|
|
984
|
+
mkdirSync(join(shellRoot, ".interf", "runtime"), { recursive: true });
|
|
978
985
|
mkdirSync(join(shellRoot, "inputs"), { recursive: true });
|
|
979
986
|
mkdirSync(join(shellRoot, "outputs"), { recursive: true });
|
|
980
987
|
linkPath(compiledInterfConfigPath(compiledPath), join(shellRoot, "interf.json"));
|
|
981
988
|
linkPath(join(compiledRuntimeRoot(compiledPath), "stage-contract.json"), shellRuntimePath(shellRoot, "stage-contract.json"));
|
|
982
989
|
linkIfExists(compiledRuntimeSourceSnapshotPath(compiledPath), shellRuntimePath(shellRoot, "source-snapshot.json"));
|
|
983
990
|
linkIfExists(compiledRuntimeStageInputsPath(compiledPath, stage.id), shellRuntimePath(shellRoot, "stage-inputs.json"));
|
|
984
|
-
|
|
991
|
+
projectCompiledSchemaArtifacts(compiledPath, shellRoot, schema, new Set([...stage.reads, ...stage.writes]), materializedArtifacts);
|
|
985
992
|
projectMethodMetadata(compiledPath, shellRoot, stage);
|
|
986
|
-
|
|
987
|
-
writeExecutionShellPathsFile(shellRoot, methodId, stage,
|
|
993
|
+
projectStageArtifactMountAliases(shellRoot, stage, schema);
|
|
994
|
+
writeExecutionShellPathsFile(shellRoot, methodId, stage, buildStageArtifactMounts(compiledPath, shellRoot, stage, schema));
|
|
988
995
|
const agentsContent = renderStageExecutionAgents(compiledName, methodId, stage);
|
|
989
996
|
writeNativeAgentSurface(shellRoot, agentsContent, "interf-stage", renderStageExecutionSkill(stage, readStageMethodDoc(compiledPath, stage)));
|
|
990
997
|
return {
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 0.17 — interface seams for the future cloud variant.
|
|
3
|
+
*
|
|
4
|
+
* These types document the injection points a cloud variant of the
|
|
5
|
+
* engine slots into without forking. The local binary keeps its
|
|
6
|
+
* in-process implementations (private `Map` fields on the runtime,
|
|
7
|
+
* the per-instance bearer-token check in `server.ts`); cloud variants
|
|
8
|
+
* provide their own implementations and pass them through
|
|
9
|
+
* `startLocalService` / `LocalServiceRuntimeOptions`.
|
|
10
|
+
*
|
|
11
|
+
* Each seam below is paired with a `TODO(cloud)` marker at the
|
|
12
|
+
* concrete call site so the cloud variant has a clear "wire this
|
|
13
|
+
* through" landing pad. Local default behavior is unchanged in 0.17.
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* **B4.1 — `IdempotencyStore` (E-1 in the 0.16 architecture audit).**
|
|
17
|
+
*
|
|
18
|
+
* Backs the `POST /v1/compile-runs` idempotency-key dedupe cache. The
|
|
19
|
+
* in-process `Map` cache works for one local engine; multi-replica
|
|
20
|
+
* cloud needs a shared store (Redis-shaped) so a retry that lands on
|
|
21
|
+
* a different replica hits the same dedupe entry.
|
|
22
|
+
*
|
|
23
|
+
* Local default: in-memory map on the runtime.
|
|
24
|
+
*
|
|
25
|
+
* Cloud injection: wrap a Redis client (or equivalent shared store).
|
|
26
|
+
*/
|
|
27
|
+
export interface IdempotencyStore {
|
|
28
|
+
get(scope: string, key: string): {
|
|
29
|
+
runId: string;
|
|
30
|
+
expiresAt: number;
|
|
31
|
+
} | null;
|
|
32
|
+
set(scope: string, key: string, value: {
|
|
33
|
+
runId: string;
|
|
34
|
+
expiresAt: number;
|
|
35
|
+
}): void;
|
|
36
|
+
delete(scope: string, key: string): void;
|
|
37
|
+
prune(now: number): void;
|
|
38
|
+
size(): number;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* **B4.2 — `RunLeaseStore` (I-1 in the 0.16 architecture audit).**
|
|
42
|
+
*
|
|
43
|
+
* Tracks active compile runs so the engine can cancel them and reject
|
|
44
|
+
* concurrent run starts on the same preparation. The local default uses
|
|
45
|
+
* the runtime's `activeCompileRuns` map; multi-replica cloud needs a
|
|
46
|
+
* shared lease store with heartbeat so a replica can take over a run
|
|
47
|
+
* whose owning replica died.
|
|
48
|
+
*
|
|
49
|
+
* Local default: in-memory map on the runtime.
|
|
50
|
+
*
|
|
51
|
+
* Cloud injection: shared lease store with heartbeat (Redis lease,
|
|
52
|
+
* Cassandra LWT, etc.) plus a `listActive()` heartbeat scan.
|
|
53
|
+
*/
|
|
54
|
+
export interface RunLeaseStore {
|
|
55
|
+
acquire(runId: string, lease: RunLeaseEntry): void;
|
|
56
|
+
release(runId: string): void;
|
|
57
|
+
get(runId: string): RunLeaseEntry | null;
|
|
58
|
+
markCancelled(runId: string): void;
|
|
59
|
+
listActive(): Iterable<{
|
|
60
|
+
runId: string;
|
|
61
|
+
lease: RunLeaseEntry;
|
|
62
|
+
}>;
|
|
63
|
+
}
|
|
64
|
+
export interface RunLeaseEntry {
|
|
65
|
+
prepDataDir: string;
|
|
66
|
+
preparation: string;
|
|
67
|
+
cancelled: boolean;
|
|
68
|
+
cancelledAt?: string;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* **B4.3 — `tokenValidator` (S-2 in the 0.16 architecture audit).**
|
|
72
|
+
*
|
|
73
|
+
* Local default: every accepted token is treated equivalently — the
|
|
74
|
+
* engine carries a single bearer token at startup, and any request
|
|
75
|
+
* presenting that token is authorized. Cloud needs a per-account
|
|
76
|
+
* token issuer + validator so the engine can attach an `account_id`
|
|
77
|
+
* to billing events (Phase F) and scope writes per-account.
|
|
78
|
+
*
|
|
79
|
+
* Local default: configured bearer or `null` (loopback).
|
|
80
|
+
*
|
|
81
|
+
* Cloud injection: validate against a token-issuer service, return
|
|
82
|
+
* the `account_id` so downstream code can attach it to runs and
|
|
83
|
+
* billing events.
|
|
84
|
+
*/
|
|
85
|
+
export type TokenValidator = (token: string) => TokenValidation | Promise<TokenValidation>;
|
|
86
|
+
export interface TokenValidation {
|
|
87
|
+
ok: boolean;
|
|
88
|
+
account_id: string | null;
|
|
89
|
+
reason?: string;
|
|
90
|
+
}
|
|
91
|
+
export declare class InMemoryIdempotencyStore implements IdempotencyStore {
|
|
92
|
+
private buckets;
|
|
93
|
+
get(scope: string, key: string): {
|
|
94
|
+
runId: string;
|
|
95
|
+
expiresAt: number;
|
|
96
|
+
} | null;
|
|
97
|
+
set(scope: string, key: string, value: {
|
|
98
|
+
runId: string;
|
|
99
|
+
expiresAt: number;
|
|
100
|
+
}): void;
|
|
101
|
+
delete(scope: string, key: string): void;
|
|
102
|
+
prune(now: number): void;
|
|
103
|
+
size(): number;
|
|
104
|
+
}
|
|
105
|
+
export declare class InMemoryRunLeaseStore implements RunLeaseStore {
|
|
106
|
+
private leases;
|
|
107
|
+
acquire(runId: string, lease: RunLeaseEntry): void;
|
|
108
|
+
release(runId: string): void;
|
|
109
|
+
get(runId: string): RunLeaseEntry | null;
|
|
110
|
+
markCancelled(runId: string): void;
|
|
111
|
+
listActive(): Iterable<{
|
|
112
|
+
runId: string;
|
|
113
|
+
lease: RunLeaseEntry;
|
|
114
|
+
}>;
|
|
115
|
+
}
|