@staix/agent-research 0.3.0 → 0.4.1
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/CHANGELOG.md +70 -0
- package/README.md +93 -22
- package/package.json +4 -1
- package/src/cli-output.ts +446 -0
- package/src/cli.ts +208 -66
- package/src/commands-table.ts +213 -93
- package/src/commands.ts +86 -17
- package/src/exp/artifacts.ts +20 -2
- package/src/exp/attempts.ts +26 -9
- package/src/exp/calibrate.ts +125 -0
- package/src/exp/executor.ts +130 -21
- package/src/exp/final.ts +12 -3
- package/src/exp/idea-report.ts +97 -0
- package/src/exp/ideas.ts +90 -6
- package/src/exp/investigate.ts +25 -22
- package/src/exp/metrics.ts +3 -5
- package/src/exp/protocol.ts +28 -3
- package/src/exp/reuse-admission.ts +3 -1
- package/src/exp/reuse-runtime.ts +5 -1
- package/src/exp/screen.ts +83 -0
- package/src/exp/selection.ts +110 -4
- package/src/exp/snapshot.ts +28 -8
- package/src/exp/stages.ts +3 -1
- package/src/harness/transitions.ts +37 -5
- package/src/manifest.ts +13 -5
- package/src/mcp-tools.ts +67 -14
- package/src/memory/archive.ts +8 -3
- package/src/paper/build.ts +39 -25
- package/src/paper/check.ts +46 -15
- package/src/paper/dependencies.ts +47 -0
- package/src/paper/document.ts +19 -0
- package/src/paper/figures.ts +152 -0
- package/src/paper/hygiene.ts +16 -5
- package/src/paper/plan.ts +71 -29
- package/src/paper/point-evidence.ts +27 -12
- package/src/paper/render.ts +113 -0
- package/src/paper/renderer.ts +128 -0
- package/src/paper/review.ts +41 -5
- package/src/plan/definition.ts +6 -1
- package/src/playbook.ts +21 -11
- package/src/provenance.ts +4 -3
- package/src/study-export.ts +7 -4
- package/src/study.ts +9 -4
- package/src/ui/plugin.ts +3 -1
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { readCard } from "../lit/cards.ts";
|
|
2
|
-
import { ATTEMPT_BYTES, validateAttemptRecord } from "../exp/attempts.ts";
|
|
2
|
+
import { ATTEMPT_BYTES, validateAttemptRecord, type Attempt } from "../exp/attempts.ts";
|
|
3
3
|
import { lstatSync, opendirSync } from "node:fs";
|
|
4
4
|
import { join } from "node:path";
|
|
5
|
-
import { openStudy, readTextBounded } from "../study.ts";
|
|
5
|
+
import { openStudy, plain, readTextBounded } from "../study.ts";
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
interface EvidenceArtifact { sha256: string; bytes: number; retained?: { attemptId: string; stage: string; sha256: string } }
|
|
8
|
+
export interface PointEvidenceResolution { resolved: boolean; reason?: string; code?: "run-limit"; artifacts?: EvidenceArtifact[] }
|
|
8
9
|
/** Only typed local failure classes may become advice; never propagate a source's free-text error. */
|
|
9
10
|
export function pointEvidenceAdvice(resolution: PointEvidenceResolution): string {
|
|
10
11
|
return resolution.code === "run-limit" ? "more than 4096 run directories; archive the study before checking point evidence" : "restore the referenced card or attempt record, or revise the point evidence";
|
|
@@ -15,10 +16,10 @@ function physicalDirectory(file: string): boolean {
|
|
|
15
16
|
catch (error) { if ((error as NodeJS.ErrnoException).code === "ENOENT") return false; throw error; }
|
|
16
17
|
}
|
|
17
18
|
/** Read only the addressed payload; unrelated attempts never enter point planning or checking. */
|
|
18
|
-
function existingAttempt(dir: string, wanted: string):
|
|
19
|
+
function existingAttempt(dir: string, wanted: string): Attempt | undefined {
|
|
19
20
|
const {study} = openStudy(dir), runs = join(dir, "runs");
|
|
20
|
-
if (study.mode !== "experiment" || !physicalDirectory(runs)) return
|
|
21
|
-
const directory = opendirSync(runs); let count = 0, found
|
|
21
|
+
if (study.mode !== "experiment" || !physicalDirectory(runs)) return undefined;
|
|
22
|
+
const directory = opendirSync(runs); let count = 0, found: Attempt | undefined;
|
|
22
23
|
try {
|
|
23
24
|
for (let entry = directory.readSync(); entry; entry = directory.readSync()) {
|
|
24
25
|
if (++count > 4096) throw new PointEvidenceBound("point evidence: more than 4096 run directories; archive the study before checking point evidence");
|
|
@@ -30,18 +31,31 @@ function existingAttempt(dir: string, wanted: string): boolean {
|
|
|
30
31
|
try {
|
|
31
32
|
const stat = lstatSync(file);
|
|
32
33
|
if (!stat.isFile() || stat.isSymbolicLink()) throw new Error("unsafe attempt record");
|
|
33
|
-
if (found) return
|
|
34
|
+
if (found) return undefined; // The address has no run component; duplicate matches are ambiguous.
|
|
34
35
|
raw = readTextBounded(file, ATTEMPT_BYTES, {noFollow: true});
|
|
35
36
|
}
|
|
36
37
|
catch (error) { if ((error as NodeJS.ErrnoException).code === "ENOENT") continue; throw error; }
|
|
37
|
-
|
|
38
|
-
found
|
|
38
|
+
found = validateAttemptRecord(JSON.parse(raw), entry.name, wanted);
|
|
39
|
+
if (found.studyId !== study.id) return undefined;
|
|
39
40
|
}
|
|
40
41
|
return found;
|
|
41
42
|
} finally { directory.closeSync(); }
|
|
42
43
|
}
|
|
44
|
+
function attemptArtifacts(attempt: Attempt): EvidenceArtifact[] {
|
|
45
|
+
const files = (raw: unknown, retained?: EvidenceArtifact["retained"]): EvidenceArtifact[] => {
|
|
46
|
+
if (!Array.isArray(raw)) return [];
|
|
47
|
+
return raw.flatMap(output => plain(output) && typeof output.sha256 === "string" && /^[a-f0-9]{64}$/.test(output.sha256)
|
|
48
|
+
&& typeof output.bytes === "number" && Number.isSafeInteger(output.bytes) && output.bytes >= 0
|
|
49
|
+
? [{sha256: output.sha256, bytes: output.bytes, ...(retained ? {retained} : {})}] : []);
|
|
50
|
+
};
|
|
51
|
+
if (!attempt.pipeline) return files(attempt.outputs);
|
|
52
|
+
return [
|
|
53
|
+
...files(attempt.stages.evaluator?.evidence?.outputs),
|
|
54
|
+
...attempt.pipeline.completed.flatMap(stage => files(stage.record.evidence?.outputs, stage.ref)),
|
|
55
|
+
];
|
|
56
|
+
}
|
|
43
57
|
/** Existence and record integrity only, never support, correctness or a successful outcome. */
|
|
44
|
-
export function resolvePointEvidence(dir: string, reference: string): PointEvidenceResolution {
|
|
58
|
+
export function resolvePointEvidence(dir: string, reference: string, includeArtifacts = false): PointEvidenceResolution {
|
|
45
59
|
if (typeof reference !== "string" || Buffer.byteLength(reference) > 4096 || reference.includes("\0")) return {resolved: false, reason: "invalid local evidence address; use card:<paper-id> or attempt:<16-hex-id>"};
|
|
46
60
|
try {
|
|
47
61
|
if (reference.startsWith("card:")) {
|
|
@@ -52,8 +66,9 @@ export function resolvePointEvidence(dir: string, reference: string): PointEvide
|
|
|
52
66
|
if (reference.startsWith("attempt:")) {
|
|
53
67
|
const id = reference.slice(8);
|
|
54
68
|
if (!/^[a-f0-9]{16}$/.test(id)) return {resolved: false, reason: "attempt address is invalid; select an id from ares attempt list"};
|
|
55
|
-
|
|
56
|
-
return {resolved:
|
|
69
|
+
const attempt = existingAttempt(dir, id);
|
|
70
|
+
if (!attempt) return {resolved: false, reason: "attempt is missing, ambiguous or belongs to another source; select a current-study record from ares attempt list"};
|
|
71
|
+
return {resolved: true, ...(includeArtifacts ? {artifacts: attemptArtifacts(attempt)} : {})};
|
|
57
72
|
}
|
|
58
73
|
} catch (error) {
|
|
59
74
|
if (error instanceof PointEvidenceBound) return {resolved: false, code: "run-limit", reason: error.message};
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { paperDocument, paperEventFor, type PaperDocument } from "./document.ts";
|
|
2
|
+
import { existsSync, lstatSync } from "node:fs";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { commit, hashFileBounded, openStudy, plain, readBytesBounded, readLedger, sha256, type Actor } from "../study.ts";
|
|
5
|
+
import { readCurrentBuild } from "./build.ts";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* External render receipts (#162). ares records what was rendered from which build; it never runs a renderer and
|
|
9
|
+
* never judges whether the rendering is faithful. `renderReceipt: 1` is renderer-agnostic.
|
|
10
|
+
*/
|
|
11
|
+
export const RENDER_RECEIPT_VERSION = 1;
|
|
12
|
+
export const PAPER_RENDER_BYTES = 64 * 1024 * 1024, RENDER_RECEIPT_BYTES = 64 * 1024, RENDER_OUTPUTS = 16;
|
|
13
|
+
const HEX64 = /^[a-f0-9]{64}$/, NAME = /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;
|
|
14
|
+
const renderFolder = (doc: PaperDocument) => doc === "slides" ? "slides.render" : "render";
|
|
15
|
+
export function paperRenderDir(dir: string, doc: PaperDocument = "manuscript") { return join(dir, "paper", "build", renderFolder(doc)); }
|
|
16
|
+
const receiptPath = (dir: string, doc: PaperDocument) => join(paperRenderDir(dir, doc), "receipt.json");
|
|
17
|
+
|
|
18
|
+
export interface RenderReceipt { v: 1; tool: string; version: string; environment: string; evidenceSha256: string; manuscriptSha256: string; template: string; outputs: { name: string; sha256: string; pages: number }[] }
|
|
19
|
+
function bad(detail: string): never { throw new Error(`paper render: receipt ${detail}; pass a renderReceipt v1 JSON with tool, version, environment, evidenceSha256, manuscriptSha256, template and outputs`); }
|
|
20
|
+
function identity(value: unknown, what: string): string {
|
|
21
|
+
if (typeof value !== "string" || !value.trim() || value.length > 256 || /[\u0000-\u001f]/.test(value)) bad(`${what} must be 1..256 characters without control characters`);
|
|
22
|
+
return value;
|
|
23
|
+
}
|
|
24
|
+
/** Unknown fields stay in the stored bytes; only a newer or unknown version is refused, leaving every file unchanged. */
|
|
25
|
+
export function validateRenderReceipt(raw: unknown): RenderReceipt {
|
|
26
|
+
if (!plain(raw)) bad("is not a JSON object");
|
|
27
|
+
if (raw.v !== RENDER_RECEIPT_VERSION) throw new Error(`paper render: unsupported receipt version ${JSON.stringify(raw.v)?.slice(0, 20)}; use an ares version that supports it; nothing was recorded`);
|
|
28
|
+
for (const key of ["evidenceSha256", "manuscriptSha256"] as const) if (typeof raw[key] !== "string" || !HEX64.test(raw[key] as string)) bad(`${key} must be a lowercase SHA-256`);
|
|
29
|
+
if (!Array.isArray(raw.outputs) || raw.outputs.length < 1 || raw.outputs.length > RENDER_OUTPUTS) bad(`outputs must list 1..${RENDER_OUTPUTS} files`);
|
|
30
|
+
const names = new Set<string>();
|
|
31
|
+
const outputs = raw.outputs.map((item: unknown) => {
|
|
32
|
+
if (!plain(item) || typeof item.name !== "string" || !NAME.test(item.name) || item.name === "receipt.json") bad("output name must be a plain file name other than receipt.json");
|
|
33
|
+
if (typeof item.sha256 !== "string" || !HEX64.test(item.sha256)) bad("output sha256 must be a lowercase SHA-256");
|
|
34
|
+
if (typeof item.pages !== "number" || !Number.isSafeInteger(item.pages) || item.pages < 0) bad("output pages must be a nonnegative integer");
|
|
35
|
+
if (names.has(item.name)) bad(`output ${item.name} is listed twice`);
|
|
36
|
+
names.add(item.name);
|
|
37
|
+
return { name: item.name, sha256: item.sha256, pages: item.pages };
|
|
38
|
+
});
|
|
39
|
+
return { v: 1, tool: identity(raw.tool, "tool"), version: identity(raw.version, "version"), environment: identity(raw.environment, "environment"), evidenceSha256: raw.evidenceSha256 as string, manuscriptSha256: raw.manuscriptSha256 as string, template: identity(raw.template, "template"), outputs };
|
|
40
|
+
}
|
|
41
|
+
function parseReceipt(bytes: Buffer): RenderReceipt {
|
|
42
|
+
let raw: unknown;
|
|
43
|
+
try { raw = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(bytes)); } catch { bad("is not valid UTF-8 JSON"); }
|
|
44
|
+
return validateRenderReceipt(raw);
|
|
45
|
+
}
|
|
46
|
+
/** The reserved derived path must be real directories, so a stored file never lands outside the study. */
|
|
47
|
+
function assertReservedPath(dir: string, doc: PaperDocument): void {
|
|
48
|
+
for (const part of [join(dir, "paper"), join(dir, "paper", "build"), paperRenderDir(dir, doc)]) {
|
|
49
|
+
if (!existsSync(part)) continue;
|
|
50
|
+
const info = lstatSync(part);
|
|
51
|
+
if (info.isSymbolicLink() || !info.isDirectory()) throw new Error(`paper render: paper/build/${renderFolder(doc)} must be a real directory without symbolic links; restore it before recording`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** Caller holds the study lock. Every check precedes the single file-and-receipt commit. */
|
|
56
|
+
export function recordPaperRender(dirArg: string, file: string, receiptFile: string, actor: Actor, doc: PaperDocument = "manuscript") {
|
|
57
|
+
paperDocument(doc);
|
|
58
|
+
const { dir } = openStudy(dirArg);
|
|
59
|
+
let receiptBytes: Buffer, output: Buffer;
|
|
60
|
+
try { receiptBytes = readBytesBounded(receiptFile, RENDER_RECEIPT_BYTES, { noFollow: true }); }
|
|
61
|
+
catch { throw new Error(`paper render: receipt is missing, a symbolic link, not a regular file or larger than ${RENDER_RECEIPT_BYTES} bytes; pass the renderer's receipt JSON file`); }
|
|
62
|
+
const receipt = parseReceipt(receiptBytes);
|
|
63
|
+
try { output = readBytesBounded(file, PAPER_RENDER_BYTES, { noFollow: true }); }
|
|
64
|
+
catch { throw new Error(`paper render: file is missing, a symbolic link, not a regular file or larger than ${PAPER_RENDER_BYTES} bytes; pass the rendered document itself`); }
|
|
65
|
+
const current = readCurrentBuild(dir, doc), outputSha256 = sha256(output);
|
|
66
|
+
if (receipt.evidenceSha256 !== current.evidenceSha256) throw new Error(`paper render: receipt evidenceSha256 does not match the current paper/build/${doc === "slides" ? "slides.evidence.json" : "evidence.json"}; render the current build and retry`);
|
|
67
|
+
if (receipt.manuscriptSha256 !== current.manuscriptSha256) throw new Error("paper render: receipt manuscriptSha256 does not match the current rendered manuscript; render the current build and retry");
|
|
68
|
+
const entry = receipt.outputs.find(item => item.sha256 === outputSha256);
|
|
69
|
+
if (!entry) throw new Error("paper render: the file's SHA-256 matches no output in the receipt; pass the file the receipt describes");
|
|
70
|
+
assertReservedPath(dir, doc);
|
|
71
|
+
const receiptSha256 = sha256(receiptBytes), stored = join(paperRenderDir(dir, doc), entry.name);
|
|
72
|
+
const last = readLedger(dir).findLast(event => paperEventFor(event, "paper.rendered", doc));
|
|
73
|
+
const same = last?.data.receiptSha256 === receiptSha256 && last.data.outputSha256 === outputSha256 && last.data.name === entry.name && stillStored(dir, entry.name, outputSha256, receiptSha256, doc);
|
|
74
|
+
const result = { evidenceSha256: current.evidenceSha256, outputSha256, bytes: output.length, name: entry.name, receiptSha256, path: `paper/build/${renderFolder(doc)}/${entry.name}` };
|
|
75
|
+
if (same) return { ...result, changed: false };
|
|
76
|
+
commit(dir, [[stored, output, PAPER_RENDER_BYTES], [receiptPath(dir, doc), receiptBytes, RENDER_RECEIPT_BYTES]], [{ actor, type: "paper.rendered", data: {
|
|
77
|
+
...(doc === "slides" ? { doc } : {}), evidenceSha256: current.evidenceSha256, manuscriptSha256: current.manuscriptSha256, outputSha256, bytes: output.length, name: entry.name, receiptSha256,
|
|
78
|
+
renderer: { tool: receipt.tool, version: receipt.version, environment: receipt.environment }, template: receipt.template,
|
|
79
|
+
} }]);
|
|
80
|
+
return { ...result, changed: true };
|
|
81
|
+
}
|
|
82
|
+
function stillStored(dir: string, name: string, outputSha256: string, receiptSha256: string, doc: PaperDocument): boolean {
|
|
83
|
+
try {
|
|
84
|
+
return hashFileBounded(join(paperRenderDir(dir, doc), name), PAPER_RENDER_BYTES, { noFollow: true }).sha256 === outputSha256
|
|
85
|
+
&& sha256(readBytesBounded(receiptPath(dir, doc), RENDER_RECEIPT_BYTES, { noFollow: true })) === receiptSha256;
|
|
86
|
+
} catch { return false; }
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export interface RenderStatus {
|
|
90
|
+
current: boolean;
|
|
91
|
+
reason: string | null;
|
|
92
|
+
render: { evidenceSha256: string; outputSha256: string; bytes: number; name: string; path: string; receiptSha256: string; renderer: unknown; template: unknown; at: string } | null;
|
|
93
|
+
}
|
|
94
|
+
/** Read-only. A rebuild with a new evidence hash makes the last render stale without deleting it. */
|
|
95
|
+
export function showPaperRender(dirArg: string, doc: PaperDocument = "manuscript"): RenderStatus {
|
|
96
|
+
paperDocument(doc);
|
|
97
|
+
const { dir } = openStudy(dirArg), last = readLedger(dir).findLast(event => paperEventFor(event, "paper.rendered", doc));
|
|
98
|
+
if (!last) return { current: false, reason: "no render recorded; run ares paper render record after rendering the current build", render: null };
|
|
99
|
+
const data = last.data, name = typeof data.name === "string" && NAME.test(data.name) ? data.name : undefined;
|
|
100
|
+
if (!name || typeof data.evidenceSha256 !== "string" || typeof data.outputSha256 !== "string" || typeof data.receiptSha256 !== "string") return { current: false, reason: "the last paper.rendered event is malformed; record the render again", render: null };
|
|
101
|
+
const render = { evidenceSha256: data.evidenceSha256, outputSha256: data.outputSha256, bytes: typeof data.bytes === "number" ? data.bytes : 0, name, path: `paper/build/${renderFolder(doc)}/${name}`, receiptSha256: data.receiptSha256, renderer: data.renderer ?? null, template: data.template ?? null, at: last.at };
|
|
102
|
+
let build: ReturnType<typeof readCurrentBuild>;
|
|
103
|
+
try { build = readCurrentBuild(dir, doc); }
|
|
104
|
+
catch { return { current: false, reason: `no current paper build; run ares paper build${doc === "slides" ? " --doc slides" : ""}, render it and record the render`, render }; }
|
|
105
|
+
if (build.evidenceSha256 !== data.evidenceSha256 || build.manuscriptSha256 !== data.manuscriptSha256) return { current: false, reason: "the recorded render belongs to an earlier build; render the current build and record it", render };
|
|
106
|
+
if (!stillStored(dir, name, data.outputSha256, data.receiptSha256, doc)) return { current: false, reason: "the stored render or receipt changed or is missing; record the render again", render };
|
|
107
|
+
return { current: true, reason: null, render };
|
|
108
|
+
}
|
|
109
|
+
/** Never throws: summaries for review show and archive preview. */
|
|
110
|
+
export function renderSummary(dir: string): { current: boolean; reason: string | null } {
|
|
111
|
+
try { const status = showPaperRender(dir); return { current: status.current, reason: status.reason }; }
|
|
112
|
+
catch (error) { return { current: false, reason: error instanceof Error ? error.message : "render status unavailable" }; }
|
|
113
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { accessSync, chmodSync, constants, existsSync, lstatSync, mkdirSync, mkdtempSync, rmSync, statSync } from "node:fs";
|
|
2
|
+
import { tmpdir } from "node:os";
|
|
3
|
+
import { delimiter, dirname, isAbsolute, join, resolve } from "node:path";
|
|
4
|
+
import { openStudy, plain, readTextBounded, writeAtomic, type Actor } from "../study.ts";
|
|
5
|
+
import { spawnRunner, type ProcessRunner } from "../exp/executor.ts";
|
|
6
|
+
import { readCurrentBuild } from "./build.ts";
|
|
7
|
+
import { recordPaperRender, RENDER_RECEIPT_BYTES, validateRenderReceipt } from "./render.ts";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Machine-local renderer for the `paper.render` plan step (#163). The command lives under the user's family home,
|
|
11
|
+
* keyed by study id, and is never read from plan.json or any committed study file: a committed plan must not choose
|
|
12
|
+
* a command the controller runs.
|
|
13
|
+
*/
|
|
14
|
+
export const RENDERER_CONFIG_VERSION = 1, RENDERER_CONFIG_BYTES = 64 * 1024, RENDERER_ARGS = 64, RENDERER_ARG_BYTES = 4096;
|
|
15
|
+
export const RENDERER_TIMEOUT_DEFAULT_S = 600, RENDERER_TIMEOUT_MAX_S = 86_400;
|
|
16
|
+
/** Placeholders a template may use: the study directory and a fresh output directory outside the manuscript sources. */
|
|
17
|
+
export const RENDERER_PLACEHOLDERS = ["{study}", "{out}"] as const;
|
|
18
|
+
export interface RendererConfig { v: 1; studyId: string; command: string[]; timeoutS: number }
|
|
19
|
+
const SET_HINT = "ares renderer set <dir> --command '[\"tool\",\"arg\",\"{study}\",\"{out}\"]'";
|
|
20
|
+
|
|
21
|
+
function fail(message: string): never { throw new Error(`renderer: ${message}`); }
|
|
22
|
+
function configPath(home: string, studyId: string) {
|
|
23
|
+
if (!isAbsolute(home) || home.includes("\0")) fail("family home must be an absolute path; correct AGENTHUB_HOME or HOME");
|
|
24
|
+
if (!/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/.test(studyId)) fail("study id is not a plain token; restore study.json");
|
|
25
|
+
const base = resolve(home), dir = join(base, "research", "renderers");
|
|
26
|
+
return { base, dir, file: join(dir, `${studyId}.json`) };
|
|
27
|
+
}
|
|
28
|
+
/** The mutable home paths must be this user's real directories and file, never links. */
|
|
29
|
+
function guard(home: string, file: string): void {
|
|
30
|
+
const uid = process.getuid!(), { base } = configPath(home, "x");
|
|
31
|
+
for (let current = file; ; current = dirname(current)) {
|
|
32
|
+
let info;
|
|
33
|
+
try { info = lstatSync(current); } catch (error) { if ((error as NodeJS.ErrnoException).code === "ENOENT") { if (current === dirname(current)) break; continue; } throw error; }
|
|
34
|
+
if (info.isSymbolicLink()) fail("links are refused in renderer configuration paths; restore a real directory under the family home");
|
|
35
|
+
if (current === file ? !info.isFile() : !info.isDirectory()) fail("renderer configuration path has the wrong file type; restore it under the family home");
|
|
36
|
+
if (info.uid !== uid && (current.startsWith(base) || info.uid !== 0)) fail("renderer configuration path is owned by another user");
|
|
37
|
+
if (current === dirname(current) || current === base) break;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
export function validateRendererConfig(raw: unknown, studyId: string): RendererConfig {
|
|
41
|
+
if (!plain(raw)) fail("configuration must be an object");
|
|
42
|
+
const extra = Object.keys(raw).find(key => !["v", "studyId", "command", "timeoutS"].includes(key));
|
|
43
|
+
if (extra !== undefined) fail(`unknown field ${JSON.stringify(extra).slice(0, 40)}; use v, command and timeoutS`);
|
|
44
|
+
if (raw.v !== RENDERER_CONFIG_VERSION) fail("unsupported configuration version; keep the file unchanged and use a compatible ares version");
|
|
45
|
+
if (raw.studyId !== undefined && raw.studyId !== studyId) fail("configuration belongs to another study; run ares renderer set for this study");
|
|
46
|
+
if (!Array.isArray(raw.command) || raw.command.length < 1 || raw.command.length > RENDERER_ARGS) fail(`command must be a JSON array of 1..${RENDERER_ARGS} arguments; run ${SET_HINT}`);
|
|
47
|
+
const command = raw.command.map((arg: unknown, index: number) => {
|
|
48
|
+
if (typeof arg !== "string" || !arg || arg.includes("\0") || Buffer.byteLength(arg) > RENDERER_ARG_BYTES) fail(`command[${index}] must be a nonempty string of at most ${RENDERER_ARG_BYTES} bytes without NUL`);
|
|
49
|
+
return arg;
|
|
50
|
+
});
|
|
51
|
+
if (RENDERER_PLACEHOLDERS.some(placeholder => command[0]!.includes(placeholder))) fail("command[0] is the program and cannot contain a placeholder");
|
|
52
|
+
const timeoutS = raw.timeoutS ?? RENDERER_TIMEOUT_DEFAULT_S;
|
|
53
|
+
if (typeof timeoutS !== "number" || !Number.isSafeInteger(timeoutS) || timeoutS < 1 || timeoutS > RENDERER_TIMEOUT_MAX_S) fail(`timeoutS must be an integer from 1 to ${RENDERER_TIMEOUT_MAX_S}`);
|
|
54
|
+
return { v: 1, studyId, command, timeoutS };
|
|
55
|
+
}
|
|
56
|
+
export function readRenderer(home: string, dirArg: string): RendererConfig | undefined {
|
|
57
|
+
const { study } = openStudy(dirArg), { file } = configPath(home, study.id);
|
|
58
|
+
guard(home, file);
|
|
59
|
+
if (!existsSync(file)) return undefined;
|
|
60
|
+
let raw: unknown;
|
|
61
|
+
try { raw = JSON.parse(readTextBounded(file, RENDERER_CONFIG_BYTES, { noFollow: true, uid: process.getuid!() })); }
|
|
62
|
+
catch { fail(`configuration is unreadable, invalid JSON or larger than ${RENDERER_CONFIG_BYTES} bytes; run ${SET_HINT} again`); }
|
|
63
|
+
return validateRendererConfig(raw, study.id);
|
|
64
|
+
}
|
|
65
|
+
/** Writes only the machine-local file under the family home; the study and its ledger are unchanged. */
|
|
66
|
+
export function setRenderer(home: string, dirArg: string, raw: { command: unknown; timeoutS?: unknown }) {
|
|
67
|
+
const { study } = openStudy(dirArg), config = validateRendererConfig({ v: 1, ...raw }, study.id), { dir, file } = configPath(home, study.id);
|
|
68
|
+
guard(home, file);
|
|
69
|
+
mkdirSync(dir, { recursive: true, mode: 0o700 }); chmodSync(dir, 0o700); guard(home, file);
|
|
70
|
+
const text = JSON.stringify(config, null, 2) + "\n";
|
|
71
|
+
writeAtomic(file, text, RENDERER_CONFIG_BYTES, 0o600);
|
|
72
|
+
return { ...config, path: file };
|
|
73
|
+
}
|
|
74
|
+
export function showRenderer(home: string, dirArg: string) {
|
|
75
|
+
const config = readRenderer(home, dirArg);
|
|
76
|
+
return config ? { configured: true, command: config.command, timeoutS: config.timeoutS } : { configured: false, reason: `no renderer configured on this machine; run ${SET_HINT}` };
|
|
77
|
+
}
|
|
78
|
+
/** Follows links (Homebrew and /usr/local/bin entries are symlinks) and requires an executable regular file. */
|
|
79
|
+
function executable(path: string): boolean {
|
|
80
|
+
try { return statSync(path).isFile() && (accessSync(path, constants.X_OK), true); } catch { return false; }
|
|
81
|
+
}
|
|
82
|
+
function onPath(program: string, env: NodeJS.ProcessEnv): boolean {
|
|
83
|
+
if (program.includes("/")) return executable(resolve(program));
|
|
84
|
+
return (env.PATH ?? "").split(delimiter).filter(Boolean).some(dir => executable(join(dir, program)));
|
|
85
|
+
}
|
|
86
|
+
/** Read-only; runs nothing. */
|
|
87
|
+
export function checkRenderer(home: string, dirArg: string, env: NodeJS.ProcessEnv) {
|
|
88
|
+
const checks: { name: string; state: "ok" | "failed" | "skipped"; detail: string }[] = [];
|
|
89
|
+
let config: RendererConfig | undefined;
|
|
90
|
+
try {
|
|
91
|
+
config = readRenderer(home, dirArg);
|
|
92
|
+
checks.push(config ? { name: "Renderer configuration", state: "ok", detail: `${config.command.length} arguments, ${config.timeoutS} s timeout` } : { name: "Renderer configuration", state: "failed", detail: `Configure the renderer with ${SET_HINT}` });
|
|
93
|
+
} catch (error) { checks.push({ name: "Renderer configuration", state: "failed", detail: error instanceof Error ? error.message : "unreadable" }); }
|
|
94
|
+
if (config) checks.push(onPath(config.command[0]!, env) ? { name: "Renderer program", state: "ok", detail: config.command[0]! } : { name: "Renderer program", state: "failed", detail: `${config.command[0]} was not found on PATH` });
|
|
95
|
+
else checks.push({ name: "Renderer program", state: "skipped", detail: "Renderer unconfigured" });
|
|
96
|
+
if (existsSync(join(openStudy(dirArg).dir, "renderer.json"))) checks.push({ name: "Committed renderer", state: "failed", detail: "renderer.json in the study is refused; remove it and use ares renderer set" });
|
|
97
|
+
return { ok: checks.every(row => row.state === "ok"), checks };
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export interface RenderStepOptions { home: string; actor: Actor; runner?: ProcessRunner; env?: NodeJS.ProcessEnv }
|
|
101
|
+
/**
|
|
102
|
+
* The `paper.render` step: requires a current build, runs the machine-local renderer with a bounded wall time and
|
|
103
|
+
* records its receipt through the render-record path. Every failure throws before a study write; the temporary output
|
|
104
|
+
* directory is outside the study and is always removed.
|
|
105
|
+
*/
|
|
106
|
+
export async function runRenderStep(dirArg: string, options: RenderStepOptions, record: (file: string, receipt: string) => Promise<ReturnType<typeof recordPaperRender>>) {
|
|
107
|
+
const { dir } = openStudy(dirArg);
|
|
108
|
+
if (existsSync(join(dir, "renderer.json"))) fail("a committed renderer.json in the study is refused; remove it and configure the renderer with ares renderer set");
|
|
109
|
+
const build = readCurrentBuild(dir), config = readRenderer(options.home, dir);
|
|
110
|
+
if (!config) fail(`no renderer configured on this machine; run ${SET_HINT}`);
|
|
111
|
+
const out = mkdtempSync(join(tmpdir(), "ares-render-"));
|
|
112
|
+
try {
|
|
113
|
+
const args = config.command.slice(1).map(arg => arg.replaceAll("{study}", dir).replaceAll("{out}", out));
|
|
114
|
+
let result;
|
|
115
|
+
try { result = await (options.runner ?? spawnRunner)({ command: config.command[0]!, args, cwd: dir, timeoutMs: config.timeoutS * 1000, ...(options.env ? { env: options.env } : {}) }); }
|
|
116
|
+
catch { fail(`${config.command[0]} could not be started; run ares renderer check`); }
|
|
117
|
+
if (result.timedOut) fail(`timed out after ${config.timeoutS} s; nothing was recorded; raise --timeout-s or fix the renderer`);
|
|
118
|
+
if (result.exitCode !== 0) fail(`exited with status ${result.exitCode}; nothing was recorded; run the renderer by hand to see its output`);
|
|
119
|
+
const receipt = join(out, "receipt.json");
|
|
120
|
+
let parsed;
|
|
121
|
+
try { parsed = validateRenderReceipt(JSON.parse(readTextBounded(receipt, RENDER_RECEIPT_BYTES, { noFollow: true }))); }
|
|
122
|
+
catch (error) { fail(`receipt missing or invalid in the output directory (${error instanceof Error ? error.message.slice(0, 200) : "unreadable"}); nothing was recorded`); }
|
|
123
|
+
if (parsed.evidenceSha256 !== build.evidenceSha256 || parsed.manuscriptSha256 !== build.manuscriptSha256) fail("receipt does not match the current build; nothing was recorded; rebuild and rerun the step");
|
|
124
|
+
const output = parsed.outputs[0]!;
|
|
125
|
+
const recorded = await record(join(out, output.name), receipt);
|
|
126
|
+
return { sha256: recorded.outputSha256, evidenceSha256: recorded.evidenceSha256, changed: recorded.changed };
|
|
127
|
+
} finally { rmSync(out, { recursive: true, force: true }); }
|
|
128
|
+
}
|
package/src/paper/review.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { requireCopilotAccept, CopilotAcceptError } from "../copilot.ts";
|
|
2
2
|
import { boundedText, commit, onlyKeys, openStudy, plain, readLedger, sha256, type Actor, type LedgerEvent } from "../study.ts";
|
|
3
3
|
import { readCurrentBuild } from "./build.ts";
|
|
4
|
+
import { renderSummary } from "./render.ts";
|
|
4
5
|
import { checkPaper } from "./check.ts";
|
|
5
|
-
import { DEFAULT_PAPER_SETTINGS, readPaperSettings, readReviewSettings, type SurveyChecklistMode } from "./hygiene.ts";
|
|
6
|
+
import { DEFAULT_PAPER_SETTINGS, readPaperSettings, readReviewSettings, type ReadbackMode, type SurveyChecklistMode } from "./hygiene.ts";
|
|
7
|
+
import { readPaperPlan } from "./plan.ts";
|
|
8
|
+
export const READBACK_CLAIMS = 8, READBACK_CLAIM_CHARS = 500;
|
|
6
9
|
export const REVIEW_KINDS = ["contradiction", "unsupported-claim", "number", "citation", "method", "clarity", "other"] as const;
|
|
7
10
|
export const REPAIR_SCOPES = ["edit", "paragraph", "section"] as const;
|
|
8
11
|
export type RepairScope = typeof REPAIR_SCOPES[number];
|
|
@@ -22,11 +25,14 @@ const SURVEY_KEYS: SurveyKey[] = SURVEY_CHECKLIST.map(item => item.key);
|
|
|
22
25
|
export function reviewChecklist() { return { survey: SURVEY_CHECKLIST.map(item => ({ ...item })) }; }
|
|
23
26
|
/** Unset means show for survey studies and off for experiment studies. */
|
|
24
27
|
export function surveyChecklistMode(dir: string, mode: string): SurveyChecklistMode { return readReviewSettings(dir).surveyChecklist ?? (mode === "survey" ? "show" : "off"); }
|
|
28
|
+
/** Unset means show for every study mode. */
|
|
29
|
+
export function readbackMode(dir: string): ReadbackMode { return readReviewSettings(dir).readback ?? "show"; }
|
|
25
30
|
export interface ReviewFinding { id: string; kind: typeof REVIEW_KINDS[number]; location: string; text: string; blocking: boolean; repair?: RepairScope; section?: string }
|
|
26
31
|
export interface ReviewReport {
|
|
27
32
|
v: 1; reviewer: { id: string; modelFamily: string }; buildSha256: string;
|
|
28
33
|
checklist: { negativeResults: boolean; denominators: boolean; limitations: boolean; reproducibility: boolean; survey?: SurveyAnswers };
|
|
29
34
|
findings: ReviewFinding[];
|
|
35
|
+
readback?: { claims: string[] };
|
|
30
36
|
}
|
|
31
37
|
export interface ReviewPointFindings {
|
|
32
38
|
point: string; open: number; blocking: number;
|
|
@@ -49,7 +55,7 @@ function object(raw: unknown, keys: string[], field: string, strict: boolean): R
|
|
|
49
55
|
}
|
|
50
56
|
export function validateReview(raw: unknown, strict = true): ReviewReport {
|
|
51
57
|
try {
|
|
52
|
-
const value = object(raw, ["v", "reviewer", "buildSha256", "checklist", "findings"], "report", strict);
|
|
58
|
+
const value = object(raw, ["v", "reviewer", "buildSha256", "checklist", "findings", "readback"], "report", strict);
|
|
53
59
|
if (value.v !== 1) throw new Error("review: unsupported report version; use an ares version that supports this report, keeping the original bytes unchanged");
|
|
54
60
|
const reviewer = object(value.reviewer, ["id", "modelFamily"], "reviewer", strict), checklist = object(value.checklist, ["negativeResults", "denominators", "limitations", "reproducibility", "survey"], "checklist", strict);
|
|
55
61
|
const buildSha256 = text(value.buildSha256, "buildSha256", 64);
|
|
@@ -61,6 +67,18 @@ export function validateReview(raw: unknown, strict = true): ReviewReport {
|
|
|
61
67
|
for (const key of SURVEY_KEYS) if (typeof block[key] !== "boolean") bad(`checklist.survey.${key} must be a boolean; run ares review checklist for the six questions`);
|
|
62
68
|
survey = Object.fromEntries(SURVEY_KEYS.map(key => [key, block[key] as boolean])) as SurveyAnswers;
|
|
63
69
|
}
|
|
70
|
+
let readback: { claims: string[] } | undefined;
|
|
71
|
+
if (value.readback !== undefined) {
|
|
72
|
+
const block = object(value.readback, ["claims"], "readback", strict);
|
|
73
|
+
if (!Array.isArray(block.claims) || block.claims.length < 1 || block.claims.length > READBACK_CLAIMS) bad(`readback.claims must hold 1 to ${READBACK_CLAIMS} claims`);
|
|
74
|
+
readback = { claims: block.claims.map((claim, index) => {
|
|
75
|
+
if (typeof claim !== "string" || !claim.trim()) bad(`readback.claims[${index}] must be nonblank text`);
|
|
76
|
+
if (/[\r\n\u2028\u2029]/.test(claim)) bad(`readback.claims[${index}] must be a single line`);
|
|
77
|
+
const trimmed = claim.trim();
|
|
78
|
+
if ([...trimmed].length > READBACK_CLAIM_CHARS) bad(`readback.claims[${index}] exceeds ${READBACK_CLAIM_CHARS} characters`);
|
|
79
|
+
return trimmed;
|
|
80
|
+
}) };
|
|
81
|
+
}
|
|
64
82
|
if (!Array.isArray(value.findings) || value.findings.length > 200) bad("findings must be an array of at most 200 entries");
|
|
65
83
|
const ids = new Set<string>();
|
|
66
84
|
const findings = value.findings.map((raw, index) => {
|
|
@@ -73,7 +91,7 @@ export function validateReview(raw: unknown, strict = true): ReviewReport {
|
|
|
73
91
|
return { id, kind: finding.kind as typeof REVIEW_KINDS[number], location: text(finding.location, `finding ${id}.location`), text: text(finding.text, `finding ${id}.text`), blocking: finding.kind === "contradiction" || finding.blocking,
|
|
74
92
|
...(finding.repair !== undefined ? { repair: finding.repair as RepairScope } : {}), ...(finding.section !== undefined ? { section: text(finding.section, `finding ${id}.section`, 256).trim() } : {}) };
|
|
75
93
|
});
|
|
76
|
-
return { v: 1, reviewer: { id: text(reviewer.id, "reviewer.id", 128), modelFamily: text(reviewer.modelFamily, "reviewer.modelFamily", 128).trim().toLowerCase() }, buildSha256, checklist: { negativeResults: checklist.negativeResults as boolean, denominators: checklist.denominators as boolean, limitations: checklist.limitations as boolean, reproducibility: checklist.reproducibility as boolean, ...(survey ? { survey } : {}) }, findings };
|
|
94
|
+
return { v: 1, reviewer: { id: text(reviewer.id, "reviewer.id", 128), modelFamily: text(reviewer.modelFamily, "reviewer.modelFamily", 128).trim().toLowerCase() }, buildSha256, checklist: { negativeResults: checklist.negativeResults as boolean, denominators: checklist.denominators as boolean, limitations: checklist.limitations as boolean, reproducibility: checklist.reproducibility as boolean, ...(survey ? { survey } : {}) }, findings, ...(readback ? { readback } : {}) };
|
|
77
95
|
} catch (error) {
|
|
78
96
|
const message = error instanceof Error ? error.message : "invalid report";
|
|
79
97
|
if (message.includes("; inspect ares review show") || message.includes("supports this report")) throw error;
|
|
@@ -101,6 +119,7 @@ export function addReview(dirArg: string, raw: unknown, actor: Actor) {
|
|
|
101
119
|
requireCopilotAccept(dir, "paper");
|
|
102
120
|
const report = validateReview(raw), current = readCurrentBuild(dir), events = readLedger(dir), rows = foldReviews(events);
|
|
103
121
|
if (!report.checklist.survey && surveyChecklistMode(dir, study.mode) === "require") bad("checklist.survey is required by study.toml [review] surveyChecklist = \"require\"; add the six survey answers listed by ares review checklist (false answers are allowed)");
|
|
122
|
+
if (!report.readback && readbackMode(dir) === "require") bad("readback is required by study.toml [review] readback = \"require\"; add readback.claims with 1 to 8 single-line claims the manuscript makes");
|
|
104
123
|
if (report.buildSha256 !== current.evidenceSha256) bad("stale buildSha256; use the evidenceSha256 from the current ares paper build output");
|
|
105
124
|
if (rows.filter(row => row.report.buildSha256 === report.buildSha256).length >= 100) bad("100 reviews already recorded for this build; resolve existing findings or build a revised manuscript");
|
|
106
125
|
const id = sha256(JSON.stringify([report, events.length])).slice(0, 16);
|
|
@@ -152,8 +171,13 @@ export function reviewReadiness(dirArg: string) {
|
|
|
152
171
|
if (families.length < 2) unmet.push({ code: "model-families", message: "fewer than two distinct model families reviewed the current evidence hash; add current-build reviews from two families" });
|
|
153
172
|
const openBlocking = reviews.flatMap(row => row.report.findings.filter(f => f.blocking && !row.resolutions[f.id]).map(f => ({ reviewId: row.id, findingId: f.id, kind: f.kind, location: f.location, text: f.text })));
|
|
154
173
|
if (openBlocking.length) unmet.push({ code: "blocking-findings", message: `open blocking findings: ${openBlocking.map(f => `${f.reviewId}/${f.findingId} (${f.kind})`).join(", ")}; resolve each with a reason using ares review resolve` });
|
|
155
|
-
const rounds = roundsView(dir, rows, buildSha256), survey = surveyView(dir, study.mode, reviews), points = pointView(reviews);
|
|
156
|
-
|
|
174
|
+
const rounds = roundsView(dir, rows, buildSha256), survey = surveyView(dir, study.mode, reviews), points = pointView(reviews), readbacks = readbackView(dir, reviews);
|
|
175
|
+
// Render status is informational unless study.toml [paper] requireRender = true (#162).
|
|
176
|
+
const render = renderSummary(dir);
|
|
177
|
+
let requireRender = false;
|
|
178
|
+
try { requireRender = readPaperSettings(dir).requireRender === true; } catch { /* roundsView already reports unreadable settings */ }
|
|
179
|
+
if (requireRender && !render.current) unmet.push({ code: "render", message: `requireRender is set and ${render.reason ?? "no current render"}` });
|
|
180
|
+
return { ready: unmet.length === 0, buildSha256: buildSha256 ?? null, ...(current ? { manuscriptSha256: current.manuscriptSha256 } : {}), check: check ?? null, reviews, families, openBlocking, ...points, checklists: reviews.map(row => { const { survey: answers, ...rest } = row.report.checklist; return { reviewId: row.id, ...rest, ...(survey.surveyChecklist === "off" || answers === undefined ? {} : { survey: answers }) }; }), claims: "unavailable (STAIxBWLB/agent-hub#931)", render, unmet, ...rounds, ...survey, readback: readbacks.readback, readbacks: readbacks.readbacks, ...(readbacks.planClaims ? { planClaims: readbacks.planClaims } : {}), info: [...rounds.info, ...survey.info, ...readbacks.info] };
|
|
157
181
|
}
|
|
158
182
|
/** Exact location metadata only: no paper-plan lookup, support judgment or readiness change. */
|
|
159
183
|
function pointView(reviews: ReviewRecord[]): { openByPoint?: ReviewPointFindings[] } {
|
|
@@ -173,6 +197,18 @@ function pointView(reviews: ReviewRecord[]): { openByPoint?: ReviewPointFindings
|
|
|
173
197
|
point, open: findings.length, blocking: findings.filter(finding => finding.blocking).length, findings,
|
|
174
198
|
})) };
|
|
175
199
|
}
|
|
200
|
+
/** Display only: ares never compares read-backs with plan claims, and neither enters unmet. */
|
|
201
|
+
function readbackView(dir: string, reviews: ReviewRecord[]): { readback: ReadbackMode; readbacks: { reviewId: string; reviewer: string; modelFamily: string; claims: string[] }[]; planClaims?: { point: string; claim: string }[]; info: { code: string; message: string }[] } {
|
|
202
|
+
let mode: ReadbackMode = "show";
|
|
203
|
+
const info: { code: string; message: string }[] = [];
|
|
204
|
+
try { mode = readbackMode(dir); }
|
|
205
|
+
catch (error) { info.push({ code: "review-readback-settings", message: `${error instanceof Error ? error.message : "study.toml unreadable"}; read-back display defaults to show` }); }
|
|
206
|
+
if (mode === "off") return { readback: mode, readbacks: [], info };
|
|
207
|
+
let planClaims: { point: string; claim: string }[] | undefined;
|
|
208
|
+
try { const claims = (readPaperPlan(dir)?.sections ?? []).flatMap(section => (section.points ?? []).map(point => ({ point: point.id, claim: point.claim }))); if (claims.length) planClaims = claims; }
|
|
209
|
+
catch { /* paper check reports an invalid plan */ }
|
|
210
|
+
return { readback: mode, readbacks: reviews.flatMap(row => row.report.readback ? [{ reviewId: row.id, reviewer: row.report.reviewer.id, modelFamily: row.report.reviewer.modelFamily, claims: row.report.readback.claims }] : []), ...(planClaims ? { planClaims } : {}), info };
|
|
211
|
+
}
|
|
176
212
|
/** Display only: answers, including false ones, never enter unmet. Off hides the block and the projection; require is enforced at review add. */
|
|
177
213
|
function surveyView(dir: string, studyMode: string, reviews: ReviewRecord[]) {
|
|
178
214
|
let mode: SurveyChecklistMode, info: { code: string; message: string }[] = [];
|
package/src/plan/definition.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { validateIntent } from "../lit/queries.ts";
|
|
|
6
6
|
import { boundedText, commit, onlyKeys, plain, readJsonFile, sha256, type Actor } from "../study.ts";
|
|
7
7
|
|
|
8
8
|
export const PLAN_BYTES = 65_536, PLAN_ID_BYTES = 128;
|
|
9
|
-
export const STEP_COMMANDS = ["lit.search", "lit.verify", "lit.bib", "cite.check", "attempt.run", "investigate.close", "ablate.close", "final.close", "paper.build", "watch.run"] as const;
|
|
9
|
+
export const STEP_COMMANDS = ["lit.search", "lit.verify", "lit.bib", "cite.check", "attempt.run", "investigate.close", "ablate.close", "final.close", "paper.build", "paper.render", "watch.run"] as const;
|
|
10
10
|
export type StepCommand = typeof STEP_COMMANDS[number];
|
|
11
11
|
export type StepArgs = Record<string, string | number | boolean | string[]>;
|
|
12
12
|
type BaseNode = { id: string; needs: string[]; phase?: Phase };
|
|
@@ -30,6 +30,11 @@ function references(raw: unknown, name: string): string[] {
|
|
|
30
30
|
function stepArgs(raw: unknown, command: StepCommand, id: string): StepArgs {
|
|
31
31
|
const where = `plan step ${id} (${command})`;
|
|
32
32
|
if (!plain(raw)) throw new Error(`${where}.args: object required`);
|
|
33
|
+
// paper.render takes no arguments: the renderer command is machine-local and never comes from plan.json (#163).
|
|
34
|
+
if (command === "paper.render") {
|
|
35
|
+
if (Object.keys(raw).length) throw new Error(`${where}.args: paper.render takes no arguments; configure the renderer with ares renderer set and run ares plan set again`);
|
|
36
|
+
return {};
|
|
37
|
+
}
|
|
33
38
|
const spec = COMMANDS.find(c => c.name === command.replace(".", " "))!;
|
|
34
39
|
const args: StepArgs = {};
|
|
35
40
|
for (const [key, value] of Object.entries(raw)) {
|