@staix/agent-research 0.2.1 → 0.3.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/CHANGELOG.md +107 -0
- package/README.md +255 -24
- package/package.json +2 -2
- package/src/cli.ts +117 -10
- package/src/commands-table.ts +39 -8
- package/src/commands.ts +192 -32
- package/src/exp/attempts.ts +500 -65
- package/src/exp/executor.ts +235 -12
- package/src/exp/final.ts +1 -1
- package/src/exp/logs.ts +25 -12
- package/src/exp/metrics.ts +6 -5
- package/src/exp/pipeline.ts +92 -0
- package/src/exp/protocol.ts +85 -18
- package/src/exp/retention-script.ts +649 -0
- package/src/exp/retention.ts +70 -0
- package/src/exp/reuse-admission.ts +63 -0
- package/src/exp/reuse-contract.ts +48 -0
- package/src/exp/reuse-runtime.ts +87 -0
- package/src/exp/reuse.ts +87 -0
- package/src/exp/selection.ts +1 -1
- package/src/exp/snapshot.ts +3 -3
- package/src/exp/stages.ts +117 -0
- package/src/harness/experience-source.ts +34 -0
- package/src/harness/experience.ts +206 -0
- package/src/harness/hub-guidance.ts +140 -0
- package/src/harness/hub-reference.ts +18 -0
- package/src/harness/lesson-candidates.ts +162 -0
- package/src/harness/limits.ts +2 -0
- package/src/harness/privacy.ts +4 -0
- package/src/harness/receipts.ts +84 -0
- package/src/harness/rounds.ts +198 -0
- package/src/harness/transitions.ts +152 -0
- package/src/lit/candidates.ts +13 -5
- package/src/lit/cards.ts +55 -4
- package/src/lit/flow.ts +82 -0
- package/src/lit/queries.ts +62 -0
- package/src/manifest.ts +13 -6
- package/src/mcp-tools.ts +123 -25
- package/src/mcp.ts +4 -0
- package/src/memory/amem-show.ts +135 -0
- package/src/memory/amem.ts +3 -0
- package/src/memory/archive.ts +17 -8
- package/src/memory/evidence-local.ts +77 -0
- package/src/memory/evidence.ts +39 -0
- package/src/memory/lessons.ts +4 -2
- package/src/memory/skill-check.ts +56 -0
- package/src/memory/skill-format.ts +77 -0
- package/src/memory/skills.ts +72 -26
- package/src/memory/source-budget.ts +11 -0
- package/src/memory/vault-cards.ts +226 -0
- package/src/paper/build.ts +16 -7
- package/src/paper/check.ts +37 -10
- package/src/paper/headings.ts +39 -0
- package/src/paper/hygiene.ts +153 -0
- package/src/paper/placeholders.ts +16 -1
- package/src/paper/plan.ts +170 -0
- package/src/paper/point-evidence.ts +63 -0
- package/src/paper/points.ts +83 -0
- package/src/paper/review.ts +102 -9
- package/src/paper/scopes.ts +51 -0
- package/src/plan/definition.ts +5 -1
- package/src/plan/hub.ts +6 -0
- package/src/plan/state.ts +5 -0
- package/src/playbook.ts +35 -20
- package/src/privacy.ts +9 -0
- package/src/provenance.ts +679 -0
- package/src/scope.ts +24 -3
- package/src/study-export.ts +55 -27
- package/src/study.ts +54 -14
- package/src/ui/panel.css +4 -0
- package/src/ui/panel.js +263 -6
- package/src/ui/plugin.ts +68 -10
package/src/ui/panel.js
CHANGED
|
@@ -19,7 +19,7 @@ export default (host) => {
|
|
|
19
19
|
const at = (value) => typeof value === "string" ? value.replace("T", " ").replace(/\.\d+Z$/, " UTC") : "Time unavailable";
|
|
20
20
|
const go = (target, extra = {}) => host.navigate(host.tool, target, extra);
|
|
21
21
|
const tone = (state) => ["accepted", "approved", "qualified", "succeeded", "ready"].includes(state) ? "ok"
|
|
22
|
-
: ["failed", "unknown", "unavailable"].includes(state) ? "err"
|
|
22
|
+
: ["failed", "unknown", "unavailable", "corrupt", "missing"].includes(state) ? "err"
|
|
23
23
|
: ["pending", "proposed", "not_qualified", "rejected"].includes(state) ? "warn" : "neutral";
|
|
24
24
|
const decisionNotice = () => ui.notice("Each decision opens a preview. Nothing is written until you confirm.", "neutral");
|
|
25
25
|
const perform = async (input) => {
|
|
@@ -74,7 +74,8 @@ export default (host) => {
|
|
|
74
74
|
if (value.available === false) return h("section", { class: "ares-card" }, h("h3", { text: "Attempts unavailable" }),
|
|
75
75
|
ui.notice(line(value.reason) || "Attempt records could not be read. Inspect the study records and refresh.", "err"));
|
|
76
76
|
return h("section", { class: "ares-card" }, h("h3", { text: `Attempts: ${number(value.total)}` }),
|
|
77
|
-
ui.rows(Object.entries(byStatus), ([state, count]) => ui.row({ title: state, sub: number(count), chip: { text: state, tone: tone(state) } })) ?? ui.empty("No attempt status details")
|
|
77
|
+
ui.rows(Object.entries(byStatus), ([state, count]) => ui.row({ title: state, sub: number(count), chip: { text: state, tone: tone(state) } })) ?? ui.empty("No attempt status details"),
|
|
78
|
+
value.reuse ? h("p", {class: "ares-sub", text: `Reuse-controlled attempts: ${number(value.reuse.attempts)} | executed stages: ${number(value.reuse.executedStages)} | reused stages: ${number(value.reuse.reusedStages)} | fresh evaluations: ${number(value.reuse.freshEvaluations)} | independent samples: ${number(value.reuse.independentSamples)}`}) : null);
|
|
78
79
|
};
|
|
79
80
|
const studies = (snapshot) => {
|
|
80
81
|
const list = rows(snapshot.studies);
|
|
@@ -91,6 +92,24 @@ export default (host) => {
|
|
|
91
92
|
...(typeof study.dir === "string" ? { onOpen: () => go("study", { study: study.dir }) } : {}) });
|
|
92
93
|
}) ?? ui.empty("No registered studies", "Register one with ares console add <dir>. Ares does not scan the disk for studies.")];
|
|
93
94
|
};
|
|
95
|
+
const skillRef = (value) => {
|
|
96
|
+
if (typeof value === "string") return value;
|
|
97
|
+
const ref = record(value), fields = ["v", "tool", "projectKey", "kind", "id", "revision", "sha256"];
|
|
98
|
+
return JSON.stringify(Object.fromEntries(fields.filter(key => ref[key] !== undefined).map(key => [key, ref[key]])));
|
|
99
|
+
};
|
|
100
|
+
const skillList = (values, render = (value) => text(value)) => h("div", {},
|
|
101
|
+
rows(values).length ? h("ul", {class: "ares-list"}, ...rows(values).slice(0, 64).map(value => h("li", {text: render(value)}))) : h("p", {text: "None recorded"}),
|
|
102
|
+
rows(values).length > 64 ? ui.notice(`${rows(values).length - 64} more entries; display incomplete.`, "warn") : null);
|
|
103
|
+
const skillInspections = (values, caption) => h("div", {}, rows(values).length ? ui.table({caption,
|
|
104
|
+
columns: [{key: "ref", label: "Typed reference"}, {key: "state", label: "Recorded availability"}, {key: "integrity", label: "Integrity"}, {key: "outcome", label: "Recorded outcome"}, {key: "success", label: "Recorded success"}, {key: "support", label: "Support"}, {key: "digest", label: "Digest"}, {key: "versions", label: "Source versions"}, {key: "observed", label: "Observed time"}],
|
|
105
|
+
rows: rows(values).slice(0, 64).map(value => {
|
|
106
|
+
const item = record(value), version = record(item.sourceVersion);
|
|
107
|
+
return {ref: skillRef(item.ref), state: text(item.state), integrity: text(item.integrity), outcome: text(record(item.outcome).status),
|
|
108
|
+
success: typeof record(item.outcome).success === "boolean" ? String(item.outcome.success) : "Unavailable",
|
|
109
|
+
support: text(item.support), digest: text(item.digest, "not recorded"),
|
|
110
|
+
versions: JSON.stringify(Object.fromEntries(["reference", "native", "ledger", "amem"].filter(key => version[key] !== undefined).map(key => [key, version[key]]))), observed: at(item.observedAt)};
|
|
111
|
+
})}) : ui.empty("No stored inspection receipts"),
|
|
112
|
+
rows(values).length > 64 ? ui.notice(`${rows(values).length - 64} more receipts; display incomplete.`, "warn") : null);
|
|
94
113
|
const skillRows = (skills, study) => ui.rows(rows(skills), (skill) => ui.detail({
|
|
95
114
|
kind: "Skill proposal", title: text(skill.name), state: { text: text(skill.state), tone: tone(skill.state) }, summary: text(skill.summary, ""),
|
|
96
115
|
actions: skill.state === "proposed" && typeof skill.name === "string" && typeof study === "string" ? [
|
|
@@ -98,15 +117,30 @@ export default (host) => {
|
|
|
98
117
|
ui.button("Reject...", () => askDecision(`Reject ${skill.name}`, { action: "skill.reject", study, name: skill.name }), { tone: "danger" }),
|
|
99
118
|
ui.button("Withdraw...", () => askDecision(`Withdraw ${skill.name}`, { action: "skill.withdraw", study, name: skill.name }), { tone: "danger" }),
|
|
100
119
|
] : [],
|
|
101
|
-
sections: [{
|
|
102
|
-
|
|
103
|
-
|
|
120
|
+
sections: [{title: "Evidence status", body: h("div", {},
|
|
121
|
+
ui.notice(skill.skillProposal === 1 ? "Legacy v1 evidence: legacy-unresolved. Create a new v2 proposal for evidence-backed checks." : "V2 evidence: inspection-required. Stored receipts are not a current privacy check.", "warn"),
|
|
122
|
+
h("p", {text: `Run explicitly: ares skill check ${text(study, "<dir>")} ${text(skill.name, "<name>")}`}),
|
|
123
|
+
h("p", {text: "Acceptance reruns evidence and counterevidence under the study lock. Negative/no-winner outcomes are not success; source integrity is not support. Support remains reviewer-judgment."}))},
|
|
124
|
+
{title: "Applicability", body: h("p", {text: text(skill.applicability, "not recorded")})},
|
|
125
|
+
{title: "Limitations", body: skillList(skill.limitations)},
|
|
126
|
+
{title: "Steps", body: skillList(skill.steps)},
|
|
127
|
+
{title: "Evidence", body: skillList(skill.evidence, skillRef)},
|
|
128
|
+
{title: "Counterevidence", body: skillList(skill.counterevidence, skillRef)},
|
|
129
|
+
{title: "Proposal inspection receipts", body: skillInspections(skill.inspections, "Stored proposal inspections")},
|
|
130
|
+
...(skill.decision ? [{title: "Recorded decision", body: h("div", {},
|
|
131
|
+
h("p", {text: `${text(skill.decision.action)}: ${text(skill.decision.reason)}`}),
|
|
132
|
+
h("p", {text: `Actor: ${text(record(skill.decision.actor).kind)} ${text(record(skill.decision.actor).id, "")} | ${at(skill.decision.at)}`}),
|
|
133
|
+
h("p", {text: `Evidence fingerprint: ${text(skill.decision.evidenceFingerprint, "not recorded")}`}),
|
|
134
|
+
h("p", {text: `PR reference supplied (not verified as merged): ${text(skill.decision.pr, "not recorded")}`}))},
|
|
135
|
+
{title: "Decision inspection receipts", body: skillInspections(skill.decision.inspections, "Stored decision inspections")}] : [])],
|
|
104
136
|
footer: typeof skill.sha256 === "string" ? [skill.sha256] : [],
|
|
105
137
|
})) ?? ui.empty("No skill proposals");
|
|
106
138
|
const studyView = (snapshot) => {
|
|
107
139
|
const study = snapshot.study;
|
|
108
140
|
if (!study) return [toolbar("Study", true), ui.notice(text(snapshot.error, "Choose a registered study from the studies panel."), "warn")];
|
|
109
141
|
const sections = [toolbar(text(study.question, "Study"), true), decisionNotice()];
|
|
142
|
+
if (typeof study.dir === "string") sections.push(h("div", { class: "ares-bar" },
|
|
143
|
+
ui.button("Lineage", () => go("lineage", { study: study.dir })), ui.button("Compare", () => go("compare", { study: study.dir })), ui.button("Harness", () => go("harness", {study: study.dir}))));
|
|
110
144
|
if (study.available === false) return [...sections, ui.notice(text(study.reason, "Study unavailable; its registration is retained."), "err"), h("p", { class: "ares-sub", text: text(study.dir, "") })];
|
|
111
145
|
sections.push(h("div", { class: "ares-bar" }, ui.chip(text(study.mode), "neutral"), ui.chip(autonomyLabel(study.autonomy), "neutral")),
|
|
112
146
|
h("p", { class: "ares-sub", text: text(study.dir, "") }), gateRows(study.gates, study.dir), attemptRows(study.attempts));
|
|
@@ -145,10 +179,233 @@ export default (host) => {
|
|
|
145
179
|
ui.rows(errors, ([name, reason]) => ui.row({ title: name, sub: String(reason) }))));
|
|
146
180
|
return sections;
|
|
147
181
|
};
|
|
182
|
+
const rootParams = () => Object.fromEntries(["rootKind", "rootId", "rootRevision", "rootSha256"].filter(key => typeof params[key] === "string").map(key => [key, params[key]]));
|
|
183
|
+
const referenceLabel = (value) => {
|
|
184
|
+
const ref = record(value);
|
|
185
|
+
return `${text(ref.kind)}: ${text(ref.id)}${typeof ref.revision === "string" ? ` | revision ${ref.revision}` : ""}${typeof ref.sha256 === "string" ? ` | sha256 ${ref.sha256}` : ""}`;
|
|
186
|
+
};
|
|
187
|
+
const trace = (study, value) => {
|
|
188
|
+
const ref = record(value);
|
|
189
|
+
if (typeof study !== "string" || typeof ref.kind !== "string" || typeof ref.id !== "string") return;
|
|
190
|
+
go("lineage", { study, rootKind: ref.kind, rootId: ref.id,
|
|
191
|
+
...(typeof ref.revision === "string" ? { rootRevision: ref.revision } : {}), ...(typeof ref.sha256 === "string" ? { rootSha256: ref.sha256 } : {}) });
|
|
192
|
+
};
|
|
193
|
+
const proofLabel = (value) => {
|
|
194
|
+
const proof = record(value);
|
|
195
|
+
return `${text(proof.file)} | sha256 ${text(proof.sha256)}${typeof proof.ledgerIndex === "number" ? ` | ledger index ${proof.ledgerIndex}` : ""}${typeof proof.recordType === "string" ? ` | ${proof.recordType}` : ""}${typeof proof.nativeId === "string" ? ` | native id ${proof.nativeId}` : ""}`;
|
|
196
|
+
};
|
|
197
|
+
const chooseStudy = (snapshot, target) => ui.rows(rows(snapshot.studies).slice(0, 200), study => ui.row({
|
|
198
|
+
title: text(study.question, text(study.id, text(study.dir, "Registered study"))), sub: text(study.dir, ""),
|
|
199
|
+
...(typeof study.dir === "string" ? { onOpen: () => go(target, { study: study.dir }) } : {}),
|
|
200
|
+
})) ?? ui.empty("No registered studies", "Register a study with ares console add <dir>.");
|
|
201
|
+
const readHeader = (title, snapshot) => {
|
|
202
|
+
const study = record(snapshot.study), sections = [toolbar(title, true)];
|
|
203
|
+
if (typeof study.dir === "string") sections.push(h("div", { class: "ares-bar" },
|
|
204
|
+
ui.button("Study detail", () => go("study", { study: study.dir })),
|
|
205
|
+
ui.button("Full lineage", () => go("lineage", { study: study.dir })), ui.button("Compare", () => go("compare", { study: study.dir }))));
|
|
206
|
+
if (snapshot.error) sections.push(ui.notice(String(snapshot.error), "err"));
|
|
207
|
+
return sections;
|
|
208
|
+
};
|
|
209
|
+
const moreNotice = (count, command) => count > 0 ? ui.notice(`${count} more; inspect with ares lineage ${command} <dir> --json`, "warn") : null;
|
|
210
|
+
const reasonRows = (value, command = "compare") => {
|
|
211
|
+
const values = rows(value), shown = values.slice(0, 64);
|
|
212
|
+
return h("div", {}, ui.rows(shown, reason => ui.row({ title: String(reason) })), moreNotice(values.length - shown.length, command));
|
|
213
|
+
};
|
|
214
|
+
const readNotices = (value, command = "show") => {
|
|
215
|
+
const data = record(value), notices = [];
|
|
216
|
+
if (data.status === "changed") notices.push(ui.notice(command === "compare" ? "Sources changed or a write is in progress; retry the comparison." : "Sources or the root selection changed. Restart from the first page before continuing.", "warn"));
|
|
217
|
+
else if (data.status === "capped" || data.truncated === true) notices.push(ui.notice(data.status === "capped" ? command === "compare" ? "Traversal capped: this is a partial comparison, not complete evidence." : "Traversal capped: this is a partial graph, not complete provenance." : "This page is partial. Continue to read the remaining source-proven records.", "warn"));
|
|
218
|
+
if (data.status === "unavailable") notices.push(ui.notice("Some source records are unavailable or corrupt. Retained receipts do not establish current readable results.", "warn"));
|
|
219
|
+
const issues = rows(data.issues), critical = issue => /capped|changed/.test(text(issue.code, "")) || issue.code === "comparison-selection-unavailable";
|
|
220
|
+
const important = issues.filter(critical), shown = [...important, ...issues.filter(issue => !critical(issue)).slice(0, Math.max(0, 64 - important.length))];
|
|
221
|
+
notices.push(...shown.map(issue => ui.notice(`${text(issue.code, "Source issue")}: ${text(issue.message, "Inspect and restore the source record.")}`, "warn")));
|
|
222
|
+
const omitted = moreNotice(issues.length - shown.length, command); if (omitted) notices.push(omitted);
|
|
223
|
+
return notices;
|
|
224
|
+
};
|
|
225
|
+
const lineageView = (snapshot) => {
|
|
226
|
+
const sections = readHeader("Execution lineage", snapshot), study = record(snapshot.study), page = snapshot.lineage;
|
|
227
|
+
if (!study.dir) return [...sections, chooseStudy(snapshot, "lineage")];
|
|
228
|
+
if (!page) return [...sections, ui.empty("Lineage unavailable", "Choose a registered study or refresh after restoring its source records.")];
|
|
229
|
+
sections.push(...readNotices(page), h("p", { class: "ares-sub ares-identifiers", text: `Source sha256: ${text(page.sourceSha256)} | ledger bytes: ${number(page.ledgerPosition)} | nodes: ${number(page.totals?.nodes)} | edges: ${number(page.totals?.edges)}` }));
|
|
230
|
+
if (typeof params.rootKind === "string" && typeof params.rootId === "string") sections.push(h("p", { class: "ares-sub ares-identifiers", text: `Root ${params.rootKind}: ${params.rootId}` }));
|
|
231
|
+
if (page.status === "changed") sections.push(ui.button("Restart lineage", () => go("lineage", { study: study.dir, ...rootParams() })));
|
|
232
|
+
sections.push(h("section", { class: "ares-card ares-identifiers" }, h("h3", { text: "Source nodes" }),
|
|
233
|
+
ui.rows(rows(page.nodes).slice(0, 100), node => ui.row({ title: referenceLabel(node.ref), sub: proofLabel(node.proof),
|
|
234
|
+
chip: { text: `${text(node.state)} / ${text(node.availability)}`, tone: tone(node.state === "current" ? node.availability : node.state) }, onOpen: () => trace(study.dir, node.ref) })) ?? ui.empty("No source nodes on this page")));
|
|
235
|
+
sections.push(h("section", { class: "ares-card ares-identifiers" }, h("h3", { text: "Recorded relationships" }),
|
|
236
|
+
ui.table({ caption: "Source-proven edges", columns: [{ key: "from", label: "From" }, { key: "relation", label: "Relation" }, { key: "to", label: "To" }, { key: "proof", label: "Source proof" }],
|
|
237
|
+
rows: rows(page.edges).slice(0, 200).map(edge => ({ from: referenceLabel(edge.from), relation: text(edge.relation), to: referenceLabel(edge.to), proof: proofLabel(edge.proof) })) })));
|
|
238
|
+
sections.push(ui.notice("Current and historical receipts describe their source state. Missing/corrupt sources stay explicit; not-read artifacts show digests only, never output bodies.", "neutral"));
|
|
239
|
+
if (typeof page.nextCursor === "string") sections.push(ui.button("Next lineage page", () => go("lineage", { study: study.dir, ...rootParams(), graphCursor: page.nextCursor })));
|
|
240
|
+
return sections;
|
|
241
|
+
};
|
|
242
|
+
const compareView = (snapshot) => {
|
|
243
|
+
const sections = readHeader("Compare execution records", snapshot), study = record(snapshot.study);
|
|
244
|
+
if (!study.dir) return [...sections, chooseStudy(snapshot, "compare")];
|
|
245
|
+
const errors = h("div", { "aria-live": "polite" });
|
|
246
|
+
sections.push(ui.notice("Read-only comparison. Select exactly one list of existing records; this creates no winner, action or result receipt.", "neutral"),
|
|
247
|
+
ui.form([{ name: "attempts", label: "Attempt ids (comma-separated, at most eight)", value: typeof params.attempts === "string" ? params.attempts : "" }, { name: "candidates", label: "Candidate commits (comma-separated, at most eight)", value: typeof params.candidates === "string" ? params.candidates : "" }], { label: "Compare records", primary: true }, values => {
|
|
248
|
+
const attempts = text(values.attempts, "").trim(), candidates = text(values.candidates, "").trim();
|
|
249
|
+
const selected = attempts || candidates, ids = selected.split(",").map(id => id.trim()), pattern = attempts ? /^[a-f0-9]{16}$/ : /^[a-f0-9]{40}$/;
|
|
250
|
+
if (!!attempts === !!candidates || ids.length < 1 || ids.length > 8 || new Set(ids).size !== ids.length || ids.some(id => !pattern.test(id))) {
|
|
251
|
+
errors.replaceChildren(ui.notice("Enter exactly one list: one to eight distinct 16-hex attempt ids or full 40-hex candidate commits.", "err")); return;
|
|
252
|
+
}
|
|
253
|
+
go("compare", { study: study.dir, ...(attempts ? { attempts: ids.join(",") } : { candidates: ids.join(",") }) });
|
|
254
|
+
}), errors);
|
|
255
|
+
const comparison = snapshot.comparison;
|
|
256
|
+
if (!comparison) return [...sections, ui.empty("Choose records to compare", "Failed and unknown attempts remain visible; retries are not independent samples.")];
|
|
257
|
+
sections.push(ui.notice("Reused computation is historical, not a new independent sample. Original compute and current verification/materialization overhead stay separate; no savings are inferred.", "neutral"), ...readNotices(comparison, "compare"), h("p", { class: "ares-sub ares-identifiers", text: `Source sha256: ${text(comparison.sourceSha256)} | ledger bytes: ${number(comparison.ledgerPosition)}` }), ui.notice("Aggregation unavailable; performed: false. These descriptive rows do not pool retries or create a verdict. Existing closed investigation and fresh final remain the result authorities.", "neutral"));
|
|
258
|
+
const aggregation = record(comparison.aggregation);
|
|
259
|
+
sections.push(h("section", { class: "ares-card" }, h("h3", { text: "Input compatibility" }),
|
|
260
|
+
ui.chip(aggregation.compatible === true ? "compatible inputs" : "compatibility unavailable or restricted", aggregation.compatible === true ? "neutral" : "warn"),
|
|
261
|
+
reasonRows(aggregation.reasons)));
|
|
262
|
+
for (const row of rows(comparison.rows).slice(0, 8)) {
|
|
263
|
+
const attempts = rows(row.attempts).slice(0, 128), columns = [
|
|
264
|
+
["id", "Attempt"], ["code", "Code commit / tree / snapshot"], ["protocol", "Protocol hash"], ["seed", "Seed"], ["status", "Status"], ["retry", "Retry ancestry / sample group"], ["metrics", "Metrics and units"], ["digests", "Artifact digests (not read)"], ["wall", "Wall ms (recorded)"], ["bytes", "Output bytes"], ["execution", "Execution / independent samples"], ["reuseSources", "Reused source references"], ["reuseCosts", "Original / incremental overhead"], ["other", "Other costs"],
|
|
265
|
+
].map(([key, label]) => ({ key, label, ...(["seed", "wall", "bytes"].includes(key) ? { align: "end" } : {}) }));
|
|
266
|
+
const cost = value => typeof value === "number" && Number.isFinite(value) ? value : "unknown";
|
|
267
|
+
const tableRows = attempts.map(attempt => {
|
|
268
|
+
const code = record(attempt.code), costs = record(attempt.costs), reuse = record(attempt.reuse), reuseCosts = record(reuse.costs);
|
|
269
|
+
return { id: text(attempt.id), code: [text(code.commit), text(code.treeId), text(code.snapshotSha256, "unknown")].join(" / "), protocol: text(attempt.protocolHash), seed: number(attempt.seed), status: text(attempt.status),
|
|
270
|
+
retry: `${text(attempt.retryOf, "none")} | ancestry: ${rows(attempt.retryAncestry).join(" -> ") || "none"} | sample group: ${text(attempt.sampleGroup, "unknown")}`,
|
|
271
|
+
metrics: rows(attempt.metrics).slice(0, 32).map(metric => `${text(metric.name)}: ${number(metric.value)} ${text(metric.unit, "unit unavailable")}`).join("; ") || "unknown",
|
|
272
|
+
digests: rows(attempt.artifactDigests).slice(0, 64).join("; ") || "none recorded", wall: cost(costs.wallMilliseconds), bytes: cost(costs.storageBytes),
|
|
273
|
+
execution: attempt.reuse ? `executed: ${number(reuse.executedStages)}; reused: ${number(reuse.reusedStages)}; fresh evaluator: ${number(reuse.freshEvaluations)}; independent samples: ${number(reuse.independentSamples)}` : "legacy/fresh receipt; reuse metadata unavailable",
|
|
274
|
+
reuseSources: rows(reuse.sources).slice(0, 16).map(raw => { const source = record(raw), ref = record(source.ref); return `${text(source.candidateStage)} <- ${text(ref.attemptId)} / ${text(ref.stage)} / ${text(ref.sha256)}`; }).join("; ") || "none recorded",
|
|
275
|
+
reuseCosts: attempt.reuse ? `original wall seconds: ${cost(reuseCosts.originalWallSeconds)}; original GPU hours: ${cost(reuseCosts.originalGpuHours)}; current verification ms: ${cost(reuseCosts.verificationMilliseconds)}; current materialization ms: ${cost(reuseCosts.materializationMilliseconds)}; preflight failure ms (overlapping subset): ${cost(reuseCosts.observedPreflightFailureMilliseconds)}; total failure/CPU/storage/transfer: unknown; do not sum clock subsets` : "unknown",
|
|
276
|
+
other: ["compute", "transfer", "verification", "retention", "materialization", "idle", "person"].map(name => `${name}: ${cost(costs[name])}`).join("; ") };
|
|
277
|
+
});
|
|
278
|
+
const candidate = record(row.candidate), perSeed = rows(candidate.perSeed).slice(0, 128);
|
|
279
|
+
const recorded = value => typeof value === "number" && Number.isFinite(value) ? value : value === null ? "null (not recorded)" : "unknown";
|
|
280
|
+
const candidateSummary = row.candidate && typeof row.candidate === "object" ? h("section", { class: "ares-card" },
|
|
281
|
+
h("h3", { text: "Recorded closed candidate summary" }),
|
|
282
|
+
ui.notice("Existing closed investigation values only: no recalculation or new eligibility judgment.", "neutral"),
|
|
283
|
+
ui.table({ caption: "Recorded closed candidate summary", columns: [{ key: "reason", label: "Recorded reason" }, { key: "eligible", label: "Recorded eligible" }, { key: "mean", label: "Recorded mean" }, { key: "baselineMean", label: "Recorded baseline mean" }, { key: "delta", label: "Recorded delta" }],
|
|
284
|
+
rows: [{ reason: text(candidate.reason, "unknown"), eligible: typeof candidate.eligible === "boolean" ? String(candidate.eligible) : "unknown", mean: recorded(candidate.mean), baselineMean: recorded(candidate.baselineMean), delta: recorded(candidate.delta) }] }),
|
|
285
|
+
ui.table({ caption: "Recorded per-seed values", columns: [{ key: "seed", label: "Seed", align: "end" }, { key: "attempt", label: "Attempt" }, { key: "value", label: "Recorded value", align: "end" }],
|
|
286
|
+
rows: perSeed.map(sample => ({ seed: recorded(sample.seed), attempt: text(sample.attempt), value: recorded(sample.value) })) }),
|
|
287
|
+
rows(candidate.perSeed).length > perSeed.length ? ui.notice("Per-seed display shortened to the first 128 records. Inspect the complete closed investigation with the ares CLI.", "warn") : null) : null;
|
|
288
|
+
sections.push(h("section", { class: "ares-card ares-identifiers" }, h("h3", { text: `${text(row.kind)}: ${text(row.id)}` }), ui.chip(text(row.state), tone(row.state)), candidateSummary,
|
|
289
|
+
reasonRows(row.reasons),
|
|
290
|
+
ui.table({ caption: "Recorded attempt comparison", columns, rows: tableRows }),
|
|
291
|
+
ui.rows(attempts, attempt => ui.row({ title: `Trace attempt ${text(attempt.id)}`, sub: rows(attempt.comparabilityReasons).join("; "), onOpen: () => trace(study.dir, { kind: "attempt", id: attempt.id }) })),
|
|
292
|
+
rows(row.attempts).length > attempts.length || attempts.some(attempt => rows(attempt.metrics).length > 32 || rows(attempt.artifactDigests).length > 64) ? ui.notice("Display shortened to bounded rows or inventories. Inspect the full read-only comparison with the ares CLI.", "warn") : null));
|
|
293
|
+
}
|
|
294
|
+
return sections;
|
|
295
|
+
};
|
|
296
|
+
const harnessView = (snapshot) => {
|
|
297
|
+
const sections = readHeader("Harness rounds", snapshot), study = record(snapshot.study), harness = record(snapshot.harness);
|
|
298
|
+
if (!study.dir) return [...sections, chooseStudy(snapshot, "harness")];
|
|
299
|
+
if (!snapshot.harness) return [...sections, ui.empty("Harness records unavailable", "Restore the recorded round sources and refresh.")];
|
|
300
|
+
sections.push(ui.notice("Experimental records only. Correctness is unavailable; transfer is not demonstrated. Fixture compatibility is not matched live execution or scientific evidence.", "warn"));
|
|
301
|
+
const roundViews = rows(harness.rounds).slice(0, 16);
|
|
302
|
+
sections.push(ui.rows(roundViews, view => {
|
|
303
|
+
const definition = record(view.definition), readiness = record(record(view.transitions).readiness);
|
|
304
|
+
return ui.row({title: text(definition.id, "Round"), sub: `Task ${text(record(definition.task).id)} | binding ${text(view.binding)}`, chip: {text: text(readiness.state, "open"), tone: readiness.state === "stale" ? "warn" : "neutral"}, onOpen: () => go("harness", {study: study.dir, round: definition.id})});
|
|
305
|
+
}) ?? ui.empty("No harness rounds", "No declared round is recorded for this experiment."));
|
|
306
|
+
if (harness.truncated || Number(harness.remaining) > 0 || rows(harness.rounds).length > roundViews.length) sections.push(ui.notice("Round list shortened. Inspect the complete records with the ares CLI; this view is not a complete evidence set.", "warn"));
|
|
307
|
+
const selected = roundViews.filter(view => typeof params.round === "string" ? record(view.definition).id === params.round : roundViews.length === 1);
|
|
308
|
+
if (!selected.length && roundViews.length) sections.push(ui.notice("Choose a round to inspect its recorded comparison and edit-to-evidence chain.", "neutral"));
|
|
309
|
+
const describe = value => {
|
|
310
|
+
const items = Array.isArray(value) ? value.filter(item => typeof item === "string") : null;
|
|
311
|
+
const omitted = items ? value.length - Math.min(items.length, 16) : 0;
|
|
312
|
+
const raw = items ? items.slice(0, 16).join("; ") : text(value, "Not recorded");
|
|
313
|
+
return (raw.length > 4000 ? raw.slice(0, 4000) + "... (text display incomplete)" : raw) + (omitted > 0 ? ` (${omitted} more entries; display incomplete)` : "");
|
|
314
|
+
};
|
|
315
|
+
const actorLabel = value => {const actor = record(value); return `${text(actor.kind, "actor unavailable")}${typeof actor.id === "string" ? `: ${actor.id}` : ""}`;};
|
|
316
|
+
const recorded = entry => `${text(entry.sha256)} | ${actorLabel(entry.actor)} | ${at(entry.at)}`;
|
|
317
|
+
for (const view of selected) {
|
|
318
|
+
const definition = record(view.definition), transitions = record(view.transitions), readiness = record(transitions.readiness), hypothesis = record(definition.hypothesis);
|
|
319
|
+
sections.push(h("section", {class: "ares-card ares-identifiers"}, h("h3", {text: `Round ${text(definition.id)}`}),
|
|
320
|
+
h("p", {text: `Declared authoring: ${text(definition.authoring)} | round ${text(view.binding)} | transitions ${text(transitions.fingerprint)}`}),
|
|
321
|
+
h("p", {text: `Deficiency: ${describe(hypothesis.deficiency)}`}), h("p", {text: `Predicted change: ${describe(hypothesis.predictedChange)}`}),
|
|
322
|
+
ui.chip(`Recorded state: ${text(readiness.state, "open")}`, readiness.state === "stale" ? "warn" : "neutral"),
|
|
323
|
+
h("p", {text: "Experimental: true | correctness: unavailable | transfer: not-demonstrated"}),
|
|
324
|
+
ui.table({caption: "Declared guidance identities", columns: [{key: "arm", label: "Arm"}, {key: "hash", label: "Guidance SHA-256"}], rows: [{arm: "baseline", hash: text(record(definition.baseline).guidanceSha256)}, ...rows(definition.candidates).slice(0, 2).map(candidate => ({arm: text(candidate.id), hash: text(candidate.guidanceSha256)}))]})));
|
|
325
|
+
sections.push(h("section", {class: "ares-card ares-identifiers"}, h("h3", {text: "Recorded comparisons"}),
|
|
326
|
+
ui.table({caption: "Fixture comparison identities", columns: [{key: "arm", label: "Arm"}, {key: "compatible", label: "Declared inputs compatible"}, {key: "matched", label: "Matched live evidence"}, {key: "source", label: "Source strength"}, {key: "reasons", label: "Reasons / confounders"}],
|
|
327
|
+
rows: rows(view.comparisons).slice(0, 3).map(comparison => ({arm: text(comparison.arm), compatible: String(comparison.compatible === true), matched: "false", source: text(comparison.sourceStrength, "producer-unavailable"), reasons: describe([...rows(comparison.reasons), ...rows(comparison.confounders)])}))}),
|
|
328
|
+
h("p", {text: `Historical fixture imports: ${number(view.historicalImports)}. Real import and end-to-end evaluation remain unavailable.`})));
|
|
329
|
+
if (rows(view.comparisons).length > 3) sections.push(ui.notice("Comparison display shortened; inspect ares harness show --json for the complete admitted identities.", "warn"));
|
|
330
|
+
if (typeof transitions.nextStep === "string") sections.push(ui.notice(transitions.nextStep, "neutral"));
|
|
331
|
+
const contrasts = rows(transitions.contrasts).slice(0, 32);
|
|
332
|
+
if (!contrasts.length) sections.push(ui.empty("No recorded contrasts"));
|
|
333
|
+
for (const entry of contrasts) {
|
|
334
|
+
const form = record(entry.form), evidence = rows(form.evidence).slice(0, 16);
|
|
335
|
+
const account = form.basis === "actor-claim" ? "Actor claim (not observed evidence)" : form.basis === "blinded-judgment" ? "Recorded blinded judgment" : form.basis === "deterministic-check" ? "Recorded deterministic-check account" : "Recorded account (basis unavailable)";
|
|
336
|
+
sections.push(h("section", {class: "ares-card ares-identifiers"}, h("h3", {text: `Recorded contrast ${text(form.id)}`}),
|
|
337
|
+
h("p", {text: `${text(form.arm)} | outcome ${text(form.outcome)} | provenance basis ${text(form.basis)}${form.basis === "blinded-judgment" ? ` | judge ${text(form.judge, "not declared")}` : ""} | model ${text(form.model, "not declared")}`}),
|
|
338
|
+
h("p", {class: "ares-prose", text: `${account}: ${describe(form.observations)}`}), h("p", {class: "ares-prose", text: `Uncertainty: ${describe(form.uncertainty)}`}),
|
|
339
|
+
h("p", {class: "ares-prose", text: `Explanations: ${describe(form.explanations)}`}), h("p", {class: "ares-sub", text: recorded(entry)}),
|
|
340
|
+
ui.table({caption: "Recorded contrast evidence references", columns: [{key: "probe", label: "Probe"}, {key: "projection", label: "Projection SHA-256"}, {key: "output", label: "Output manifest SHA-256"}],
|
|
341
|
+
rows: evidence.map(item => ({probe: typeof item.probe === "string" ? item.probe : text(record(item.probe).id), projection: text(item.projectionSha256), output: text(item.outputManifestHash, "not recorded")}))}),
|
|
342
|
+
rows(form.evidence).length > evidence.length ? ui.notice("Evidence references shortened to the first sixteen; inspect the full round with the CLI.", "warn") : null));
|
|
343
|
+
}
|
|
344
|
+
if (rows(transitions.contrasts).length > contrasts.length) sections.push(ui.notice(`${rows(transitions.contrasts).length - contrasts.length} more contrasts; inspect ares harness show --json for the complete round.`, "warn"));
|
|
345
|
+
const composition = record(transitions.composition), compositionForm = record(composition.form), edits = rows(compositionForm.sections).slice(0, 32);
|
|
346
|
+
if (transitions.composition) sections.push(h("section", {class: "ares-card ares-identifiers"}, h("h3", {text: `Recorded per-section edit-to-evidence ${text(compositionForm.id)}`}),
|
|
347
|
+
h("p", {text: `Composed successor SHA-256: ${text(compositionForm.successorSha256, "none recorded")}`}),
|
|
348
|
+
h("p", {class: "ares-sub", text: recorded(composition)}),
|
|
349
|
+
ui.table({caption: "Recorded composition decisions", columns: [{key: "section", label: "Section"}, {key: "decision", label: "Recorded decision"}, {key: "contrasts", label: "Contrast ids / hashes"}, {key: "reason", label: "Reason"}],
|
|
350
|
+
rows: edits.map(edit => ({section: text(edit.section), decision: text(edit.decision), contrasts: rows(edit.contrasts).slice(0, 16).map(contrast => `${text(contrast.id)} @ ${text(contrast.sha256)}`).join("; ") || "none recorded", reason: describe(edit.reason)}))}),
|
|
351
|
+
rows(compositionForm.sections).length > edits.length || edits.some(edit => rows(edit.contrasts).length > 16) ? ui.notice("Composition display shortened to bounded sections or contrast references.", "warn") : null));
|
|
352
|
+
else sections.push(ui.empty("No recorded composition"));
|
|
353
|
+
const adoption = record(transitions.adoption), adoptionForm = record(adoption.form), independent = record(adoptionForm.independentCheck), checkSource = record(independent.source);
|
|
354
|
+
if (transitions.adoption) sections.push(h("section", {class: "ares-card ares-identifiers"}, h("h3", {text: `Recorded adoption ${text(adoptionForm.id)}`}),
|
|
355
|
+
h("p", {text: `${text(adoptionForm.decision)} | arm ${text(adoptionForm.arm)} | ${describe(adoptionForm.reason)}`}), h("p", {class: "ares-sub", text: recorded(adoption)}),
|
|
356
|
+
ui.chip(`Independent check state: ${text(independent.state, "unavailable")}`, "neutral"), h("p", {text: `Independent check source kind: ${text(checkSource.kind, "unavailable")}`}),
|
|
357
|
+
ui.notice("Judgment basis and independent-check source/status are separate. Synthetic fixture references do not promote a check into verified correctness or transfer evidence.", "neutral"),
|
|
358
|
+
ui.table({caption: "Recorded adoption probe references", columns: [{key: "probe", label: "Declared probe"}, {key: "projection", label: "Projection SHA-256"}, {key: "output", label: "Output manifest SHA-256"}], rows: rows(adoptionForm.checks).slice(0, 16).map(ref => ({probe: text(ref.probe), projection: text(ref.projectionSha256), output: text(ref.outputManifestHash, "not recorded")}))}),
|
|
359
|
+
rows(adoptionForm.checks).length > 16 ? ui.notice("Adoption probe references shortened to sixteen records.", "warn") : null,
|
|
360
|
+
ui.table({caption: "Recorded independent-check source references", columns: [{key: "probe", label: "Probe"}, {key: "projection", label: "Projection SHA-256"}, {key: "output", label: "Output manifest SHA-256"}], rows: rows(checkSource.refs).slice(0, 16).map(ref => ({probe: text(ref.probe), projection: text(ref.projectionSha256), output: text(ref.outputManifestHash, "not recorded")}))}),
|
|
361
|
+
rows(checkSource.refs).length > 16 ? ui.notice("Independent-check references shortened to sixteen records.", "warn") : null));
|
|
362
|
+
const closure = record(transitions.closure), closureForm = record(closure.form);
|
|
363
|
+
if (transitions.closure) sections.push(h("section", {class: "ares-card ares-identifiers"}, h("h3", {text: `Recorded closure ${text(closureForm.id)}`}),
|
|
364
|
+
ui.chip(closure.current === true ? "current closure" : "stale closure", closure.current === true ? "neutral" : "warn"),
|
|
365
|
+
h("p", {text: `Recorded outcome: ${text(closureForm.outcome)} | ${describe(closureForm.reason)}`}), h("p", {class: "ares-sub", text: recorded(closure)}),
|
|
366
|
+
h("p", {text: `Binding ${text(closure.binding)} | synthetic-fixture | matched: false${typeof closureForm.adoptionSha256 === "string" ? ` | adoption SHA-256 ${closureForm.adoptionSha256}` : ""}`}),
|
|
367
|
+
ui.notice("An adopted-experimental closure does not activate guidance or demonstrate correctness or transfer.", "neutral")));
|
|
368
|
+
else sections.push(ui.empty("Round remains open", "No immutable closure is recorded."));
|
|
369
|
+
const history = rows(transitions.closures).slice(0, 16);
|
|
370
|
+
if (history.length) sections.push(h("section", {class: "ares-card ares-identifiers"}, h("h3", {text: "Recorded closure history"}),
|
|
371
|
+
ui.table({caption: "Immutable closure records", columns: [{key: "id", label: "Closure"}, {key: "outcome", label: "Recorded outcome"}, {key: "currency", label: "Binding state"}, {key: "binding", label: "Binding"}, {key: "record", label: "Recorded hash / actor / time"}], rows: history.map(entry => ({id: text(record(entry.form).id), outcome: text(record(entry.form).outcome), currency: entry.current === true ? "current" : entry.current === false ? "stale" : "not asserted", binding: text(entry.binding), record: recorded(entry)}))})));
|
|
372
|
+
const remainingClosures = (Number.isSafeInteger(transitions.remainingClosures) && transitions.remainingClosures >= 0 ? transitions.remainingClosures : 0) + rows(transitions.closures).length - history.length;
|
|
373
|
+
if (remainingClosures > 0) sections.push(ui.notice(`${remainingClosures} more closure records; displayed history is incomplete. Inspect the complete immutable history with the CLI.`, "warn"));
|
|
374
|
+
const lessons = rows(snapshot.lessonCandidates).filter(row => record(row.proposal).round === definition.id), visibleLessons = lessons.slice(0, 32);
|
|
375
|
+
if (Number(snapshot.remainingLessonCandidates) > 0) sections.push(ui.notice(`${Number(snapshot.remainingLessonCandidates)} more lesson candidates omitted by the bounded snapshot; inspect ares lesson list --json.`, "warn"));
|
|
376
|
+
sections.push(h("h3", {text: "Linked lesson candidates"}));
|
|
377
|
+
if (!lessons.length) sections.push(ui.empty("No stored lesson candidates for this round"));
|
|
378
|
+
for (const lesson of visibleLessons) {
|
|
379
|
+
const proposal = record(lesson.proposal), changes = rows(proposal.change).slice(0, 16), behavior = rows(proposal.behavior).slice(0, 16), disposition = record(lesson.disposition);
|
|
380
|
+
sections.push(h("section", {class: "ares-card ares-identifiers"}, h("h3", {text: `Lesson ${describe(proposal.name)}`}),
|
|
381
|
+
ui.chip(`Stored disposition: ${text(lesson.state)}`, tone(lesson.state)), ui.chip(lesson.current === true ? "current proposal" : "stale proposal", lesson.current === true ? "neutral" : "warn"),
|
|
382
|
+
ui.notice("synthetic-fixture; not evidence of real agent behavior. Single-task observation; transfer: not-demonstrated. No success or scientific support is inferred.", "warn"),
|
|
383
|
+
h("p", {text: `Kind: ${text(proposal.kind)} | evidence label: ${text(proposal.evidenceLabel)} | stored exportable flag: ${String(lesson.exportable === true)}`}),
|
|
384
|
+
ui.notice(proposal.kind === "no-lesson" ? "No-lesson candidates never export. Stored eligibility is not fresh proof." : "Stored exportability is local eligibility only, not fresh proof. Owner source recheck is required before archive.", "neutral"),
|
|
385
|
+
h("p", {text: "Needs source recheck: true. Stored inspection receipts are not a current privacy check; this panel performs no source checks or activation."}),
|
|
386
|
+
h("p", {text: `Summary: ${describe(proposal.summary)}`}), h("p", {text: `Procedure: ${describe(proposal.procedure)}`}),
|
|
387
|
+
h("p", {text: `Applicability: ${describe(proposal.applicability)}`}), h("p", {text: `Limitations: ${describe(proposal.limitations)}`}),
|
|
388
|
+
h("p", {text: `When not to use: ${describe(proposal.whenNotToUse)}`}), h("p", {text: `Failure: ${describe(proposal.failure)}`}), h("p", {text: `Retry when: ${describe(proposal.retryWhen)}`}),
|
|
389
|
+
h("p", {class: "ares-sub", text: `Proposal SHA-256: ${text(lesson.sha256)} | source closure: ${text(proposal.closureSha256)} | round binding: ${text(proposal.roundBinding)} | source fingerprint: ${text(proposal.sourceFingerprint)} | evidence fingerprint: ${text(lesson.evidenceFingerprint)}`}),
|
|
390
|
+
h("p", {class: "ares-sub", text: recorded(lesson)}),
|
|
391
|
+
ui.table({caption: "Lesson change references", columns: [{key: "kind", label: "Change kind"}, {key: "id", label: "Native id"}, {key: "hash", label: "Recorded SHA-256"}], rows: changes.map(change => ({kind: text(change.kind), id: text(change.id), hash: text(change.sha256)}))}),
|
|
392
|
+
ui.table({caption: "Lesson behavior references", columns: [{key: "probe", label: "Declared probe"}, {key: "projection", label: "Projection SHA-256"}, {key: "output", label: "Output manifest SHA-256"}], rows: behavior.map(ref => ({probe: text(ref.probe), projection: text(ref.projectionSha256), output: text(ref.outputManifestHash, "not recorded")}))}),
|
|
393
|
+
rows(proposal.change).length > changes.length || rows(proposal.behavior).length > behavior.length ? ui.notice("Lesson reference display incomplete; inspect the stored candidate with the CLI.", "warn") : null,
|
|
394
|
+
skillInspections(proposal.inspections, "Stored lesson inspections"),
|
|
395
|
+
lesson.disposition ? h("p", {text: `Recorded decision: ${text(disposition.decision)} | reason: ${describe(disposition.reason)} | strength acknowledged: ${describe(disposition.acknowledgeStrength)} | ${recorded(disposition)} | evidence fingerprint: ${text(disposition.evidenceFingerprint)}`}) : null));
|
|
396
|
+
}
|
|
397
|
+
if (lessons.length > visibleLessons.length) sections.push(ui.notice(`${lessons.length - visibleLessons.length} more lesson candidates; display incomplete.`, "warn"));
|
|
398
|
+
const successor = record(transitions.successor);
|
|
399
|
+
if (transitions.successor) sections.push(h("section", {class: "ares-card ares-identifiers"}, h("h3", {text: "Successor guidance"}),
|
|
400
|
+
h("p", {text: `SHA-256 ${text(successor.guidanceSha256)} | ${text(successor.execution)}${typeof successor.probeId === "string" ? ` | probe ${successor.probeId}` : ""}`}),
|
|
401
|
+
ui.notice(successor.execution === "unexecuted" ? "Successor guidance is unexecuted and untested." : "Successor guidance remains untested: a fixture declaration is not live execution or an independent correctness check.", "warn")));
|
|
402
|
+
}
|
|
403
|
+
return sections;
|
|
404
|
+
};
|
|
148
405
|
const render = (snapshot) => {
|
|
149
406
|
if (destroyed || !visible || snapshot.changed === false) return;
|
|
150
407
|
last = { key: viewKey(), snapshot };
|
|
151
|
-
const body = snapshot.error && panel !== "study" ? [ui.notice(String(snapshot.error), "err")]
|
|
408
|
+
const body = panel === "harness" ? harnessView(snapshot) : panel === "lineage" ? lineageView(snapshot) : panel === "compare" ? compareView(snapshot) : snapshot.error && panel !== "study" ? [ui.notice(String(snapshot.error), "err")]
|
|
152
409
|
: panel === "studies" ? studies(snapshot) : panel === "study" ? studyView(snapshot) : [ui.empty("Unknown research panel", "Choose Studies from the console.")];
|
|
153
410
|
root.replaceChildren(...body.filter(Boolean));
|
|
154
411
|
};
|
package/src/ui/plugin.ts
CHANGED
|
@@ -4,11 +4,12 @@ import { join } from "node:path";
|
|
|
4
4
|
import { fileURLToPath } from "node:url";
|
|
5
5
|
import { version } from "../../package.json";
|
|
6
6
|
import * as ops from "../commands.ts";
|
|
7
|
+
import { attemptReuseView, validateExecutionReference } from "../provenance.ts";
|
|
7
8
|
import { foldPlan, canonical, PLAN_GATE_BYTES } from "../plan/state.ts";
|
|
8
9
|
import { readRegistry, MAX_REGISTERED_STUDIES } from "../console/registry.ts";
|
|
9
10
|
import { readAttemptRecords, type Attempt } from "../exp/attempts.ts";
|
|
10
11
|
import { createHttp } from "../http.ts";
|
|
11
|
-
import { previewArchive,
|
|
12
|
+
import { previewArchive, archiveExportBatch, ArchivePartialError } from "../memory/archive.ts";
|
|
12
13
|
import { spawnRunner, type ProcessRunner } from "../exp/executor.ts";
|
|
13
14
|
import { readProtocol } from "../exp/protocol.ts";
|
|
14
15
|
import { readSelection, selectionPath } from "../exp/selection.ts";
|
|
@@ -16,7 +17,7 @@ import { investigateResultPath } from "../exp/investigate.ts";
|
|
|
16
17
|
import { readClosedFinal, finalResultPath } from "../exp/final.ts";
|
|
17
18
|
import { readCurrentBuild, paperBuildPaths } from "../paper/build.ts";
|
|
18
19
|
import { loadCandidates } from "../lit/candidates.ts";
|
|
19
|
-
import { openStudy, readLedger, readBytesBounded, readTextBounded, sha256, boundedText, plain, type LedgerEvent } from "../study.ts";
|
|
20
|
+
import { openStudy, readLedger, readBytesBounded, readTextBounded, sha256, boundedText, plain, isHarnessGate, type LedgerEvent } from "../study.ts";
|
|
20
21
|
|
|
21
22
|
type Args = Record<string, unknown>;
|
|
22
23
|
interface Context { home: string; log(line: string): void; features?: readonly string[] }
|
|
@@ -73,6 +74,7 @@ export function gateWaitingTimes(events: LedgerEvent[], inputs: GateInputs, obse
|
|
|
73
74
|
for (const event of events) {
|
|
74
75
|
const data = event.data;
|
|
75
76
|
switch (event.type) {
|
|
77
|
+
case "harness.round.set": if (plain(data.round) && isHarnessGate(`harness:${String(data.round.id)}`) && typeof data.binding === "string") observe(`harness:${data.round.id}`, data.binding, event.at); break;
|
|
76
78
|
case "scope.set": if (typeof data.sha256 === "string") observe("scope", data.sha256, event.at); break;
|
|
77
79
|
case "lit.screen": {
|
|
78
80
|
let changed = false;
|
|
@@ -83,7 +85,7 @@ export function gateWaitingTimes(events: LedgerEvent[], inputs: GateInputs, obse
|
|
|
83
85
|
if (changed) observe("screen", included.size ? [...included].sort() : undefined, event.at); break;
|
|
84
86
|
}
|
|
85
87
|
case "protocol.set":
|
|
86
|
-
if (typeof data.sha256 === "string" && typeof data.treeHash === "string") protocol = [data.sha256, data.treeHash];
|
|
88
|
+
if (typeof data.sha256 === "string" && typeof data.treeHash === "string") protocol = [typeof data.identitySha256 === "string" ? data.identitySha256 : data.sha256, data.treeHash];
|
|
87
89
|
experiment(event.at); break;
|
|
88
90
|
case "selection.set": if (typeof data.sha256 === "string") selection = data.sha256; experiment(event.at); break;
|
|
89
91
|
case "final.seeds.set": if (typeof data.sha256 === "string") reserved = data.sha256; experiment(event.at); break;
|
|
@@ -102,13 +104,16 @@ export function gateWaitingTimes(events: LedgerEvent[], inputs: GateInputs, obse
|
|
|
102
104
|
function attempts(dir: string, all: boolean) {
|
|
103
105
|
const byStatus = { running: 0, succeeded: 0, failed: 0, cancelled: 0, unknown: 0 }, rows: Pick<Attempt, "id" | "status" | "reason">[] = [];
|
|
104
106
|
let total = 0;
|
|
107
|
+
const reuse = {attempts: 0, executedStages: 0, reusedStages: 0, freshEvaluations: 0, independentSamples: 0};
|
|
105
108
|
for (const row of readAttemptRecords(dir)) {
|
|
106
109
|
total++; byStatus[row.status]++;
|
|
110
|
+
const view = attemptReuseView(row);
|
|
111
|
+
if (view) { reuse.attempts++; reuse.executedStages += view.executedStages; reuse.reusedStages += view.reusedStages; reuse.freshEvaluations += view.freshEvaluations; reuse.independentSamples += view.independentSamples; }
|
|
107
112
|
if (!all || (row.status !== "failed" && row.status !== "unknown")) continue;
|
|
108
113
|
if (row.reason !== undefined && (typeof row.reason !== "string" || row.reason.length > 500)) throw new Error("attempt inbox: malformed reason; restore the last valid bounded attempt record and refresh");
|
|
109
114
|
rows.push({ id: row.id, status: row.status, ...(row.reason === undefined ? {} : { reason: row.reason }) });
|
|
110
115
|
}
|
|
111
|
-
return { total, byStatus, rows };
|
|
116
|
+
return { total, byStatus, rows, ...(reuse.attempts ? {reuse} : {}) };
|
|
112
117
|
}
|
|
113
118
|
/** Presence is not validity: any present artifact is still checked by its existing bounded reader. */
|
|
114
119
|
function recordPresent(file: string): boolean {
|
|
@@ -197,7 +202,7 @@ function loadStudy(dir: string, features: readonly string[], input: { panel: str
|
|
|
197
202
|
failures.map(([name, reason]) => `${name}: ${line(reason, Math.max(20, perFailure - name.length - 2))}`).join("; ") + "; Inspect the study panel, restore readable records or use a compatible ares version, then refresh.");
|
|
198
203
|
}
|
|
199
204
|
const summary = { id: study.id, dir, available: true, question: status.question, mode: status.mode, autonomy: status.autonomy, gates,
|
|
200
|
-
attempts: attempt ? { total: attempt.total, byStatus: attempt.byStatus } : study.mode === "experiment" ? { available: false, reason: errors.attempts ?? "Attempt records could not be read; inspect ares attempt list and restore readable records, then refresh" } : { total: 0, byStatus: {} },
|
|
205
|
+
attempts: attempt ? { total: attempt.total, byStatus: attempt.byStatus, ...(attempt.reuse ? {reuse: attempt.reuse} : {}) } : study.mode === "experiment" ? { available: false, reason: errors.attempts ?? "Attempt records could not be read; inspect ares attempt list and restore readable records, then refresh" } : { total: 0, byStatus: {} },
|
|
201
206
|
final: final ? { status: final.status, ...(final.reason ? { reason: final.reason } : {}) } : null,
|
|
202
207
|
review: review ? { ready: review.ready, unmet: review.unmet } : null, lastWatch };
|
|
203
208
|
return { summary, targets, detail: detailed ? { ...summary, investigation, investigationArtifact: investigationArtifact ?? null, final, posthoc, review, skills, watch, archive, manuscript, errors } : null, items, at };
|
|
@@ -268,14 +273,47 @@ function boundAction(value: Selection) {
|
|
|
268
273
|
binding = skill; preview.push(`${value.decision} skill ${skill.name}`, `Proposal: ${skill.sha256}`, ...(value.pr ? [`Reviewed PR: ${value.pr}`] : []));
|
|
269
274
|
} else {
|
|
270
275
|
const archive = previewArchive(study); archiveFingerprint = archive.fingerprint; binding = { fingerprint: archive.fingerprint, pending: archive.notes.map(row => row.sha256) };
|
|
271
|
-
preview.push(`Export ${
|
|
276
|
+
preview.push(`Export ${archiveExportBatch(study, archive.notes).length} of ${archive.notes.length} pending lesson(s) to amem`, `Archive fingerprint: ${archive.fingerprint}`, ...(archive.recovery ? [archive.recovery] : []));
|
|
272
277
|
}
|
|
273
278
|
if (value.reason) preview.push(`Reason: ${value.reason}`);
|
|
274
279
|
return { fingerprint: sha256(canonical({ selection: value, study: identity, binding })), preview, archiveFingerprint };
|
|
275
280
|
}
|
|
281
|
+
const LINEAGE_PARAMS = ["rootKind", "rootId", "rootRevision", "rootSha256", "graphCursor", "attempts", "candidates"] as const;
|
|
282
|
+
function readParam(input: Args, name: typeof LINEAGE_PARAMS[number]): string | undefined {
|
|
283
|
+
const value = input[name]; if (value === undefined) return undefined;
|
|
284
|
+
if (typeof value !== "string" || value.includes("\0") || Buffer.byteLength(value) > 4096) throw new Error(`console ${name}: bounded text required; correct the view parameters and retry`);
|
|
285
|
+
return value;
|
|
286
|
+
}
|
|
287
|
+
/** Explicit read panels only; the ordinary overview/inbox polling paths never call these operations. */
|
|
288
|
+
function executionPanel(dir: string, input: Args): Args {
|
|
289
|
+
if (input.panel === "harness") {
|
|
290
|
+
const harness = ops.harnessShow(dir, input.round as string | undefined), selected = new Set(harness.rounds.filter(row => typeof input.round === "string" ? row.definition.id === input.round : harness.rounds.length === 1).map(row => row.definition.id));
|
|
291
|
+
const candidates = ops.lessonList(dir).filter(row => selected.has(row.proposal.round));
|
|
292
|
+
const lessonCandidates: typeof candidates = [];
|
|
293
|
+
for (const row of candidates) {if (Buffer.byteLength(JSON.stringify({harness, lessonCandidates: [...lessonCandidates, row], remainingLessonCandidates: candidates.length})) > 1_048_576) break; lessonCandidates.push(row);}
|
|
294
|
+
return {harness, lessonCandidates, remainingLessonCandidates: candidates.length - lessonCandidates.length};
|
|
295
|
+
}
|
|
296
|
+
if (input.panel === "compare") {
|
|
297
|
+
if (["rootKind", "rootId", "rootRevision", "rootSha256", "graphCursor"].some(name => input[name] !== undefined)) throw new Error("console compare: use only attempts or candidates selection parameters; clear lineage filters and retry");
|
|
298
|
+
const attempts = readParam(input, "attempts"), candidates = readParam(input, "candidates");
|
|
299
|
+
if (attempts === undefined && candidates === undefined) return {comparison: null};
|
|
300
|
+
return {comparison: ops.lineageCompare(dir, {...(attempts === undefined ? {} : {attempts: attempts.split(",")}), ...(candidates === undefined ? {} : {candidates: candidates.split(",")})})};
|
|
301
|
+
}
|
|
302
|
+
if (input.attempts !== undefined || input.candidates !== undefined) throw new Error("console lineage: use root fields and graphCursor; clear comparison selectors and retry");
|
|
303
|
+
const kind = readParam(input, "rootKind"), id = readParam(input, "rootId"), revision = readParam(input, "rootRevision"), hash = readParam(input, "rootSha256"), cursor = readParam(input, "graphCursor");
|
|
304
|
+
const rooted = [kind, id, revision, hash].some(value => value !== undefined);
|
|
305
|
+
if (rooted && (kind === undefined || id === undefined)) throw new Error("console lineage: partial root; pass rootKind and rootId together and retry");
|
|
306
|
+
let root;
|
|
307
|
+
if (rooted) {
|
|
308
|
+
root = validateExecutionReference({v: 1, tool: "ares", projectKey: "pending-study-identity", kind, id, ...(revision === undefined ? {} : {revision}), ...(hash === undefined ? {} : {sha256: hash})});
|
|
309
|
+
try { root = {...root, projectKey: openStudy(dir).study.id}; }
|
|
310
|
+
catch { return {lineage: ops.lineageShow(dir)}; }
|
|
311
|
+
}
|
|
312
|
+
return {lineage: ops.lineageShow(dir, {...(root === undefined ? {} : {root}), ...(cursor === undefined ? {} : {cursor})})};
|
|
313
|
+
}
|
|
276
314
|
export function createPlugin(runtime: Runtime = {}) { return {
|
|
277
315
|
manifest: { api: 1 as const, tool: "ares", version, title: "Research", icon: "agents", pollMs: 15000,
|
|
278
|
-
panels: [{ id: "studies", title: "Studies", order: 1 }, { id: "study", title: "Study", order: 2 }],
|
|
316
|
+
panels: [{ id: "studies", title: "Studies", order: 1 }, { id: "study", title: "Study", order: 2 }, { id: "lineage", title: "Lineage", order: 3 }, { id: "compare", title: "Compare attempts", order: 4 }, {id: "harness", title: "Harness rounds", order: 5}],
|
|
279
317
|
capabilities: { actions: Object.keys(ACTIONS), confirm: true, inbox: true, multiProject: false, search: false } },
|
|
280
318
|
async open(ctx: Context): Promise<Provider> {
|
|
281
319
|
const assets = { js: readTextBounded(fileURLToPath(new URL("./panel.js", import.meta.url)), 262144), css: readTextBounded(fileURLToPath(new URL("./panel.css", import.meta.url)), 262144) };
|
|
@@ -285,11 +323,18 @@ export function createPlugin(runtime: Runtime = {}) { return {
|
|
|
285
323
|
return {
|
|
286
324
|
assets,
|
|
287
325
|
async snapshot(input) {
|
|
326
|
+
const explicitRead = input.panel === "lineage" || input.panel === "compare" || input.panel === "harness";
|
|
327
|
+
const emptyRead = input.panel === "harness" ? {harness: null} : {lineage: null, comparison: null};
|
|
328
|
+
if (explicitRead) {
|
|
329
|
+
const allowed = ["panel", "study", "after", ...(input.panel === "harness" ? ["round"] : LINEAGE_PARAMS)], extra = Object.keys(input).find(name => !allowed.includes(name));
|
|
330
|
+
if (extra !== undefined) return {cursor: 0, changed: true, study: null, ...emptyRead, error: `console read snapshot: unknown field ${line(extra, 80)}; allowed fields: ${allowed.join(", ")}; correct the view parameters and retry`};
|
|
331
|
+
if (input.panel === "harness" && input.round !== undefined && (typeof input.round !== "string" || !isHarnessGate(`harness:${input.round}`))) return {cursor: 0, changed: true, study: null, harness: null, error: "console harness: invalid round; pass a 1..64 character ASCII run-name and retry"};
|
|
332
|
+
}
|
|
288
333
|
const registry = readRegistry(ctx.home);
|
|
289
334
|
const cursor = registry.studies.reduce((sum, dir) => {
|
|
290
335
|
try { const info = statSync(join(dir, "ledger.jsonl")); return sum + (info.isFile() ? info.size : 0); } catch { return sum; }
|
|
291
336
|
}, 0);
|
|
292
|
-
const view =
|
|
337
|
+
const view = canonical([input.panel, str(input.study) ?? str(input.id) ?? "", ...(input.panel === "harness" ? ["round"] : LINEAGE_PARAMS).map(name => typeof input[name] === "string" ? sha256(input[name] as string) : typeof input[name])]);
|
|
293
338
|
const deliver = (payload: Args): Args => {
|
|
294
339
|
const hash = sha256(canonical(payload));
|
|
295
340
|
if (input.after === cursor && seen.get(view) === hash) return { cursor, changed: false };
|
|
@@ -297,6 +342,19 @@ export function createPlugin(runtime: Runtime = {}) { return {
|
|
|
297
342
|
seen.set(view, hash);
|
|
298
343
|
return { ...payload, changed: true };
|
|
299
344
|
};
|
|
345
|
+
if (explicitRead) {
|
|
346
|
+
const choices = registry.studies.map(dir => ({dir})), selected = str(input.study);
|
|
347
|
+
if (!selected || !registry.studies.includes(selected)) return deliver({cursor, studies: choices, study: null, ...emptyRead, error: selected ? "Requested study is not registered; use ares console add or choose a registered study" : "Choose a registered study"});
|
|
348
|
+
if (input.panel === "harness") {
|
|
349
|
+
try {if (realpathSync(selected) !== selected) throw new Error();}
|
|
350
|
+
catch {return deliver({cursor, studies: choices, study: {dir: selected, available: false}, harness: null, error: "Registered study is missing or now resolves elsewhere; restore its canonical directory and refresh"});}
|
|
351
|
+
}
|
|
352
|
+
let summary: Args = {dir: selected};
|
|
353
|
+
try { const {study} = openStudy(selected); summary = {...summary, id: study.id, question: study.question, mode: study.mode, available: true}; }
|
|
354
|
+
catch { summary = {...summary, available: false, reason: "Study metadata unavailable; restore valid study.json and refresh"}; }
|
|
355
|
+
try { return deliver({cursor, studies: choices, study: summary, ...executionPanel(selected, input)}); }
|
|
356
|
+
catch (cause) { return deliver({cursor, studies: choices, study: summary, ...emptyRead, error: error(cause)}); }
|
|
357
|
+
}
|
|
300
358
|
const registered = new Set(registry.studies); for (const dir of lastAt.keys()) if (!registered.has(dir)) lastAt.delete(dir);
|
|
301
359
|
if (input.panel === "inbox") targets.clear();
|
|
302
360
|
const studies: Args[] = [], details = new Map<string, Args>(), items: Item[] = [];
|
|
@@ -347,8 +405,8 @@ export function createPlugin(runtime: Runtime = {}) { return {
|
|
|
347
405
|
};
|
|
348
406
|
if (target.action === "gate") await ops.gateDecide(target.study, target.gate!, target.decision as "approve" | "reject", target.reason, command, guard);
|
|
349
407
|
else if (target.action === "screen") await ops.screen(target.study, target.ids!, target.decision as "include" | "exclude", target.reason, command, guard);
|
|
350
|
-
else if (target.action === "skill.decide") await ops.skillDecide(target.study, target.name!, target.decision!, target.reason!, target.pr,
|
|
351
|
-
else await ops.archive(target.study, archive, command, env, guard);
|
|
408
|
+
else if (target.action === "skill.decide") await ops.skillDecide(target.study, target.name!, target.decision!, target.reason!, target.pr, {actor, ...(runtime.runner ? {runner: runtime.runner} : {}), ...(runtime.now ? {now: runtime.now} : {})}, guard, env);
|
|
409
|
+
else await ops.archive(target.study, archive, command, env, guard, {...runtime, env});
|
|
352
410
|
seen.clear(); return { ok: true, message: `${target.wireAction} recorded; refresh the study to inspect its ledger` };
|
|
353
411
|
} catch (cause) {
|
|
354
412
|
const message = cause instanceof ArchivePartialError
|