Skip to content

28 eval-informed mental models and critical-thinking skills for Claude Code, GitHub Copilot, Codex, Cursor, and other Agent Skills-compatible tools

feat: gate workflow runner on evidence

Travis Boudreaux1d63b0d0fe2f
diff --git a/analysis/evidence.json b/analysis/evidence.json
index d7c6e7a..1c73ae7 100644
--- a/analysis/evidence.json
+++ b/analysis/evidence.json
@@ -2,14 +2,14 @@
"schema_version": 2,
"created_at": "2026-07-16T00:00:00.000Z",
"updated_at": "2026-07-16T00:00:00.000Z",
- "phase": 4,
- "title": "Canonical evidence registry — 28-skill manual-only portfolio",
+ "phase": 5,
+ "title": "Canonical evidence registry — 28 manual-only skills; workflow machinery rejected",
"authority": "analysis/evidence.json",
"generated_by": "node evals/generate-evidence-registry.js",
"registry_ref": {
"path": "evals/studies/registry.json",
- "registry_version": "phase4-portfolio-v1",
- "sha256": "7bf021d6dd4c34cd5bd91c74874114f98e1dc952ebb279021add62af8416c91e"
+ "registry_version": "phase5-workflow-v1",
+ "sha256": "39eb7264b5e1f516aa5e67e4c7ab06d968c72453d5de8e5396aee69b665f039d"
},
"policy": {
"confirmatory_requires": [
@@ -27,14 +27,15 @@
"Historical estimates remain provisional unless their declared study bundle independently passes every confirmation gate.",
"A statistically significant row cannot silently become an ELEVATE product verdict.",
"portfolio-v1 was preregistered, but zero solver calls were eligible under its frozen power and budget constraints.",
- "All 28 active skills remain manual-only; 11 removed skills are preserved separately with absorption provenance."
+ "All 28 active skills remain manual-only; 11 removed skills are preserved separately with absorption provenance.",
+ "workflow-v1 made zero solver calls after its frozen 24-case design failed the pre-run power gate; workflow-only machinery is marked for deletion."
],
"auto_retain_count": 0
},
"summary": {
"active_skill_count": 28,
"deleted_skill_count": 11,
- "study_count": 8,
+ "study_count": 9,
"elevate_count": 0,
"robust_elevate_count": 0,
"auto_retain_count": 0,
@@ -42,6 +43,10 @@
"portfolio_run_status": "no_run",
"portfolio_model_calls": 0,
"portfolio_decision_eligible_count": 0,
+ "workflow_run_status": "no_run",
+ "workflow_model_calls": 0,
+ "workflow_decision_eligible": false,
+ "workflow_product_disposition": "delete_workflow_machinery",
"historical_statistical_status_counts_active": {
"ceiling_or_near_ceiling": 4,
"directional_not_significant": 1,
@@ -595,7 +600,7 @@
"aggregate_path": "evals/studies/portfolio-v1/aggregate.json",
"items_path": "evals/studies/portfolio-v1/items.jsonl",
"prereg_sha256": "f38cc1c34f7c1e185e687d6b8c2cb0d78c84cc91a501d40a934c56cd150a12c7",
- "manifest_sha256": "c7a460e5a241585344ecdc42a99cbae7090c971636a39b9a61328e695842e313",
+ "manifest_sha256": "c1b257932dbee6ee40b254782dd258ef75f3512e5653aa51eb5d679037f266e9",
"input_registry_ref": {
"path": "evals/studies/registry.json",
"git_commit": "c2e4a73a6aded6c53d419f1f3d2a011fea91946f",
@@ -604,6 +609,7 @@
},
"current_registry_ref": {
"path": "evals/studies/registry.json",
+ "git_commit": "3d1f67de41495a2fa979b196a76fc5a3e66235e0",
"registry_version": "phase4-portfolio-v1",
"sha256": "7bf021d6dd4c34cd5bd91c74874114f98e1dc952ebb279021add62af8416c91e",
"role": "post-gate output; not a preregistration input"
@@ -636,6 +642,81 @@
"replication": 325,
"hard_negatives": 353
}
+ },
+ {
+ "study_id": "workflow-v1",
+ "bundle_dir": "evals/studies/workflow-v1",
+ "prereg_path": "evals/studies/workflow-v1/prereg.md",
+ "manifest_path": "evals/studies/workflow-v1/manifest.json",
+ "cases_path": "evals/studies/workflow-v1/cases.json",
+ "aggregate_path": "evals/studies/workflow-v1/aggregate.json",
+ "items_path": "evals/studies/workflow-v1/items.jsonl",
+ "prereg_sha256": "0f8dfba5b4c816b27a39e38dbb0aef344184415f1a349fc55cb5d21dffda1834",
+ "manifest_sha256": "e87b2d7c76695bc4077ff7a67b070b8b5ff2e228e67310be9036cffc30991181",
+ "input_registry_ref": {
+ "path": "evals/studies/registry.json",
+ "git_commit": "3d1f67de41495a2fa979b196a76fc5a3e66235e0",
+ "registry_version": "phase4-portfolio-v1",
+ "sha256": "7bf021d6dd4c34cd5bd91c74874114f98e1dc952ebb279021add62af8416c91e"
+ },
+ "current_registry_ref": {
+ "path": "evals/studies/registry.json",
+ "registry_version": "phase5-workflow-v1",
+ "sha256": "39eb7264b5e1f516aa5e67e4c7ab06d968c72453d5de8e5396aee69b665f039d",
+ "role": "post-gate output; not a preregistration input"
+ },
+ "frozen_artifacts": {
+ "runner": {
+ "path": "evals/run-agentic.js",
+ "sha256": "4b8aeaa3c83ea000a15d66ae05c4cd4ff2d8fc1dabec1a13d9ab82230e410cda"
+ },
+ "pure_evaluator": {
+ "path": "evals/lib/agentic.js",
+ "sha256": "cef02f317cf9749824b550e6bb893a23b0f3d577e91832ee402bf781aafabf58"
+ },
+ "dataset": {
+ "path": "evals/datasets/workflow-cases-replication.jsonl",
+ "sha256": "3108849eae5636b7748cf800d49b25a9c5d9aaac78bd6986559ea5e2aaa7b0ef",
+ "split": "replication",
+ "n_cases": 24,
+ "n_candidate_nodes": 42,
+ "n_gold_nodes": 30
+ },
+ "cases": {
+ "path": "evals/studies/workflow-v1/cases.json",
+ "sha256": "54638d7dbf74b350a5d1041bb2d141ce0c2818231ef9b3c05d715482564c6c1a"
+ }
+ },
+ "candidate": "workflow_typed",
+ "comparators": [
+ "dynamic_typed",
+ "workflow_none_typed"
+ ],
+ "models": [
+ "claude-haiku-4-5-20251001",
+ "claude-sonnet-4-6",
+ "claude-opus-4-6"
+ ],
+ "run_status": "no_run",
+ "measured_result": null,
+ "statistical_status": "unmeasured_preregistered_power_blocked",
+ "replication_status": "not_run",
+ "evidence_validity": "preregistered_blocked",
+ "product_disposition": "delete_workflow_machinery",
+ "decision_eligible": false,
+ "model_calls": 0,
+ "retention_gates": {
+ "quality": "not_eligible",
+ "efficiency": "not_eligible"
+ },
+ "blockers": [
+ "available_replication_case_clusters_below_power_requirement",
+ "quality_gate_not_estimable_at_declared_precision",
+ "efficiency_noninferiority_gate_not_estimable_at_declared_precision",
+ "no_solver_calls_permitted_after_pre_run_power_failure",
+ "neither_retention_gate_passed"
+ ],
+ "frozen_case_count": 24
}
],
"skills": {
@@ -2435,5 +2516,31 @@
"absorbed_mechanisms": [],
"deletion_reason": null
}
+ },
+ "workflow_form": {
+ "study_id": "workflow-v1",
+ "measured_result": null,
+ "statistical_status": "unmeasured_preregistered_power_blocked",
+ "replication_status": "not_run",
+ "evidence_validity": "preregistered_blocked",
+ "product_disposition": "delete_workflow_machinery",
+ "decision_eligible": false,
+ "model_calls": 0,
+ "candidate": "workflow_typed",
+ "comparators": [
+ "dynamic_typed",
+ "workflow_none_typed"
+ ],
+ "retention_gates": {
+ "quality": "not_eligible",
+ "efficiency": "not_eligible"
+ },
+ "blockers": [
+ "available_replication_case_clusters_below_power_requirement",
+ "quality_gate_not_estimable_at_declared_precision",
+ "efficiency_noninferiority_gate_not_estimable_at_declared_precision",
+ "no_solver_calls_permitted_after_pre_run_power_failure",
+ "neither_retention_gate_passed"
+ ]
}
}
diff --git a/evals/README.md b/evals/README.md
index 7cd53ea..7b54940 100644
--- a/evals/README.md
+++ b/evals/README.md
@@ -41,14 +41,14 @@ limit self-preference. Pair ordering is assigned by problem-index parity
## Agentic workflow ablation
-`run-agentic-workflow.js` is a pilot for multi-step route-vs-node scoring. It
-separates control-flow route accuracy from per-node binary decision accuracy,
-typed I/O effects, validator/repair effects, and verifier effects. Do not cite
-it as powered proof until the dataset is enlarged and pre-registered.
+`run-agentic.js` is the corrected multi-step route-vs-node runner. Its arms run
+independently, declared skill-route correctness is part of case success, and
+typed self-check arms make a separate semantic review call. Workflow results
+remain non-confirmatory until the frozen workflow study passes its evidence gate.
```bash
EVAL_RUN=workflow-pilot CONC=3 SOLVER_MODEL=claude-sonnet-4-6 \
- node evals/run-agentic-workflow.js
+ node evals/run-agentic.js
```
## Running
diff --git a/evals/generate-evidence-registry.js b/evals/generate-evidence-registry.js
index 2da8c16..8587044 100755
--- a/evals/generate-evidence-registry.js
+++ b/evals/generate-evidence-registry.js
@@ -9,6 +9,7 @@ const REPO_ROOT = path.resolve(__dirname, '..');
const REGISTRY_PATH = path.join(__dirname, 'studies', 'registry.json');
const EVIDENCE_PATH = path.join(REPO_ROOT, 'analysis', 'evidence.json');
const PORTFOLIO_DIR = path.join(__dirname, 'studies', 'portfolio-v1');
+const WORKFLOW_DIR = path.join(__dirname, 'studies', 'workflow-v1');
function readJson(file) {
return JSON.parse(fs.readFileSync(file, 'utf8'));
@@ -37,6 +38,9 @@ function main() {
const manifest = readJson(path.join(PORTFOLIO_DIR, 'manifest.json'));
const aggregate = readJson(path.join(PORTFOLIO_DIR, 'aggregate.json'));
const cases = readJson(path.join(PORTFOLIO_DIR, 'cases.json'));
+ const workflowManifest = readJson(path.join(WORKFLOW_DIR, 'manifest.json'));
+ const workflowAggregate = readJson(path.join(WORKFLOW_DIR, 'aggregate.json'));
+ const workflowCases = readJson(path.join(WORKFLOW_DIR, 'cases.json'));
const previousRows = {
...(previous.deleted_skills || {}),
@@ -135,9 +139,38 @@ function main() {
},
};
+ const workflowStudy = {
+ study_id: workflowAggregate.study_id,
+ bundle_dir: 'evals/studies/workflow-v1',
+ prereg_path: 'evals/studies/workflow-v1/prereg.md',
+ manifest_path: 'evals/studies/workflow-v1/manifest.json',
+ cases_path: 'evals/studies/workflow-v1/cases.json',
+ aggregate_path: 'evals/studies/workflow-v1/aggregate.json',
+ items_path: 'evals/studies/workflow-v1/items.jsonl',
+ prereg_sha256: workflowManifest.preregistration.sha256,
+ manifest_sha256: sha256File(path.join(WORKFLOW_DIR, 'manifest.json')),
+ input_registry_ref: workflowManifest.input_registry_ref,
+ current_registry_ref: workflowManifest.current_registry_ref,
+ frozen_artifacts: workflowManifest.frozen_artifacts,
+ candidate: workflowManifest.primary_arm,
+ comparators: workflowManifest.comparators,
+ models: workflowManifest.models,
+ run_status: workflowAggregate.run_status,
+ measured_result: workflowAggregate.measured_result,
+ statistical_status: workflowAggregate.statistical_status,
+ replication_status: workflowAggregate.replication_status,
+ evidence_validity: workflowAggregate.evidence_validity,
+ product_disposition: workflowAggregate.product_disposition,
+ decision_eligible: workflowAggregate.health.decision_eligible,
+ model_calls: workflowAggregate.usage.calls,
+ retention_gates: workflowAggregate.retention_gates,
+ blockers: workflowAggregate.reasons,
+ frozen_case_count: workflowCases.cases.length,
+ };
+
const studies = (previous.studies || [])
- .filter(study => study.study_id !== aggregate.study_id)
- .concat(portfolioStudy)
+ .filter(study => study.study_id !== aggregate.study_id && study.study_id !== workflowAggregate.study_id)
+ .concat(portfolioStudy, workflowStudy)
.sort((a, b) => a.study_id.localeCompare(b.study_id));
const historicalStatuses = Object.values(skills).map(row => row.statistical_status || 'unknown');
@@ -145,8 +178,8 @@ function main() {
schema_version: 2,
created_at: previous.created_at,
updated_at: aggregate.created_at,
- phase: 4,
- title: 'Canonical evidence registry — 28-skill manual-only portfolio',
+ phase: 5,
+ title: 'Canonical evidence registry — 28 manual-only skills; workflow machinery rejected',
authority: 'analysis/evidence.json',
generated_by: 'node evals/generate-evidence-registry.js',
registry_ref: {
@@ -163,6 +196,7 @@ function main() {
'A statistically significant row cannot silently become an ELEVATE product verdict.',
'portfolio-v1 was preregistered, but zero solver calls were eligible under its frozen power and budget constraints.',
'All 28 active skills remain manual-only; 11 removed skills are preserved separately with absorption provenance.',
+ 'workflow-v1 made zero solver calls after its frozen 24-case design failed the pre-run power gate; workflow-only machinery is marked for deletion.',
],
},
summary: {
@@ -176,6 +210,10 @@ function main() {
portfolio_run_status: aggregate.run_status,
portfolio_model_calls: aggregate.usage.calls,
portfolio_decision_eligible_count: aggregate.health.decision_eligible ? aggregate.summary.skill_count : 0,
+ workflow_run_status: workflowAggregate.run_status,
+ workflow_model_calls: workflowAggregate.usage.calls,
+ workflow_decision_eligible: workflowAggregate.health.decision_eligible,
+ workflow_product_disposition: workflowAggregate.product_disposition,
historical_statistical_status_counts_active: countBy(historicalStatuses),
product_disposition_counts_active: countBy(Object.values(skills).map(row => row.product_disposition)),
evidence_validity: 'provisional',
@@ -184,7 +222,20 @@ function main() {
studies,
skills,
deleted_skills: deletedSkills,
- workflow_form: previous.workflow_form,
+ workflow_form: {
+ study_id: workflowAggregate.study_id,
+ measured_result: workflowAggregate.measured_result,
+ statistical_status: workflowAggregate.statistical_status,
+ replication_status: workflowAggregate.replication_status,
+ evidence_validity: workflowAggregate.evidence_validity,
+ product_disposition: workflowAggregate.product_disposition,
+ decision_eligible: workflowAggregate.health.decision_eligible,
+ model_calls: workflowAggregate.usage.calls,
+ candidate: workflowManifest.primary_arm,
+ comparators: workflowManifest.comparators,
+ retention_gates: workflowAggregate.retention_gates,
+ blockers: workflowAggregate.reasons,
+ },
};
if (Object.keys(skills).length !== 28) throw new Error('expected exactly 28 active skill rows');
@@ -195,6 +246,12 @@ function main() {
if (aggregate.usage.calls !== 0 || aggregate.health.decision_eligible !== false) {
throw new Error('portfolio aggregate no longer records the zero-call blocked outcome');
}
+ if (workflowAggregate.usage.calls !== 0 || workflowAggregate.health.decision_eligible !== false) {
+ throw new Error('workflow aggregate no longer records the zero-call blocked outcome');
+ }
+ if (workflowAggregate.product_disposition !== 'delete_workflow_machinery') {
+ throw new Error('workflow disposition no longer requires failed-gate cleanup');
+ }
fs.writeFileSync(EVIDENCE_PATH, `${JSON.stringify(evidence, null, 2)}\n`);
console.log(JSON.stringify(evidence.summary, null, 2));
diff --git a/evals/lib/agentic.js b/evals/lib/agentic.js
new file mode 100644
index 0000000..8c98894
--- /dev/null
+++ b/evals/lib/agentic.js
@@ -0,0 +1,255 @@
+'use strict';
+
+const { mcnemar } = require('./stats');
+
+const AGENTIC_ARMS = Object.freeze([
+ 'dynamic_loose',
+ 'dynamic_typed',
+ 'dynamic_typed_self_checked',
+ 'workflow_loose',
+ 'workflow_typed',
+ 'workflow_none_typed',
+ 'workflow_typed_self_checked',
+]);
+
+const AGENTIC_CONTRASTS = Object.freeze([
+ ['workflow_loose_vs_dynamic_loose', 'workflow_loose', 'dynamic_loose'],
+ ['workflow_typed_vs_workflow_loose', 'workflow_typed', 'workflow_loose'],
+ ['workflow_typed_vs_workflow_none_typed', 'workflow_typed', 'workflow_none_typed'],
+ ['workflow_typed_self_checked_vs_workflow_typed', 'workflow_typed_self_checked', 'workflow_typed'],
+ ['dynamic_typed_self_checked_vs_dynamic_typed', 'dynamic_typed_self_checked', 'dynamic_typed'],
+ ['workflow_typed_self_checked_vs_dynamic_typed', 'workflow_typed_self_checked', 'dynamic_typed'],
+ ['workflow_typed_self_checked_vs_workflow_none_typed', 'workflow_typed_self_checked', 'workflow_none_typed'],
+]);
+
+function escapeRe(value) {
+ return String(value).replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
+}
+
+function extractRouteFromText(text, knownSkillNames) {
+ const hay = String(text || '');
+ const hits = [];
+ for (let order = 0; order < knownSkillNames.length; order++) {
+ const name = knownSkillNames[order];
+ const bare = name.replace(/^thinking-/, '');
+ const exact = new RegExp(`(^|[^A-Za-z0-9])${escapeRe(name)}([^A-Za-z0-9]|$)`, 'i');
+ const short = new RegExp(`(^|[^A-Za-z0-9])${escapeRe(bare)}([^A-Za-z0-9]|$)`, 'i');
+ const exactMatch = exact.exec(hay);
+ const shortMatch = short.exec(hay);
+ const indexes = [exactMatch, shortMatch].filter(Boolean).map(match => match.index + (match[1] ? match[1].length : 0));
+ if (indexes.length) hits.push({ name, index: Math.min(...indexes), order });
+ }
+ hits.sort((a, b) => (a.index - b.index) || (a.order - b.order));
+ return hits.map(hit => hit.name);
+}
+
+function evalBranchRules(rules, afterNodeId, answersByDecisionKey, completedNodeIds, queuedNodeIds) {
+ const completed = completedNodeIds instanceof Set ? completedNodeIds : new Set(completedNodeIds || []);
+ const queued = queuedNodeIds instanceof Set ? queuedNodeIds : new Set(queuedNodeIds || []);
+ const out = [];
+ for (const rule of rules || []) {
+ if (rule.after !== afterNodeId) continue;
+ if (!Object.prototype.hasOwnProperty.call(answersByDecisionKey, rule.if.decision_key)) {
+ throw new Error(`missing branch decision answer for ${rule.if.decision_key}`);
+ }
+ const chosen = answersByDecisionKey[rule.if.decision_key] === rule.if.equals ? rule.then : rule.else;
+ for (const nodeId of chosen || []) {
+ if (completed.has(nodeId) || queued.has(nodeId) || out.includes(nodeId)) continue;
+ out.push(nodeId);
+ }
+ }
+ return out;
+}
+
+function scoreRoute(selectedRoute, goldRoute) {
+ const selected = Array.isArray(selectedRoute) ? selectedRoute : [];
+ const gold = Array.isArray(goldRoute) ? goldRoute : [];
+ const routeExact = selected.length === gold.length && selected.every((value, index) => value === gold[index]);
+ const selectedSet = new Set(selected);
+ const goldSet = new Set(gold);
+ const union = new Set([...selectedSet, ...goldSet]);
+ let intersection = 0;
+ for (const value of selectedSet) if (goldSet.has(value)) intersection++;
+ return {
+ route_exact: routeExact,
+ route_jaccard: union.size === 0 ? 1 : intersection / union.size,
+ };
+}
+
+function expectedBranch(rule, goldSet) {
+ const thenBranch = rule.then || [];
+ const elseBranch = rule.else || [];
+ const thenIncluded = thenBranch.filter(id => goldSet.has(id));
+ const elseIncluded = elseBranch.filter(id => goldSet.has(id));
+ const thenMatches = thenIncluded.length === thenBranch.length && elseIncluded.length === 0;
+ const elseMatches = elseIncluded.length === elseBranch.length && thenIncluded.length === 0;
+
+ if (thenMatches && !elseMatches) return thenBranch;
+ if (elseMatches && !thenMatches) return elseBranch;
+ if (thenBranch.length === 0 && elseIncluded.length === 0) return thenBranch;
+ if (elseBranch.length === 0 && thenIncluded.length === 0) return elseBranch;
+ return [];
+}
+
+function scoreCaseResult(workflowCase, armResult) {
+ const nodesById = new Map((workflowCase.nodes || []).map(node => [node.node_id, node]));
+ const goldRoute = (workflowCase.gold_node_ids || []).map(id => {
+ const node = nodesById.get(id);
+ if (!node) throw new Error(`${workflowCase.id || 'case'}: unknown gold node ${id}`);
+ return node.skill;
+ });
+ const selectedRoute = Array.isArray(armResult.selected_route) ? armResult.selected_route : [];
+ const selectedNodeIds = Array.isArray(armResult.selected_node_ids)
+ ? armResult.selected_node_ids
+ : (Array.isArray(armResult.scheduled_node_ids)
+ ? armResult.scheduled_node_ids
+ : (Array.isArray(armResult.node_answers)
+ ? armResult.node_answers.map(answer => answer && answer.node_id).filter(Boolean)
+ : []));
+ const goldNodeIds = workflowCase.gold_node_ids || [];
+ const route = scoreRoute(selectedRoute, goldRoute);
+ const nodeRoute = scoreRoute(selectedNodeIds, goldNodeIds);
+ const selectedSet = new Set(selectedNodeIds);
+ const goldSet = new Set(goldNodeIds);
+ const overRoutingNodeIds = selectedNodeIds.filter(id => !goldSet.has(id));
+ const underRoutingNodeIds = goldNodeIds.filter(id => !selectedSet.has(id));
+ const answers = new Map();
+ for (const answer of armResult.node_answers || []) {
+ if (answer && typeof answer.node_id === 'string' && typeof answer.answer === 'boolean') {
+ answers.set(answer.node_id, answer.answer);
+ }
+ }
+
+ let correct = 0;
+ for (const nodeId of goldNodeIds) {
+ const node = nodesById.get(nodeId);
+ if (node && answers.get(nodeId) === node.label) correct++;
+ }
+ const goldCount = goldNodeIds.length;
+ const nodeAcc = goldCount ? correct / goldCount : 0;
+ const allGoldCorrect = goldCount > 0 && correct === goldCount;
+ const branchDecisions = [];
+ for (const rule of workflowCase.workflow_branch_rules || []) {
+ const afterNode = nodesById.get(rule.after);
+ const answer = afterNode ? answers.get(rule.after) : undefined;
+ if (typeof answer !== 'boolean') continue;
+ const actual = answer === rule.if.equals ? (rule.then || []) : (rule.else || []);
+ const expected = expectedBranch(rule, goldSet);
+ branchDecisions.push({
+ after: rule.after,
+ decision_key: rule.if.decision_key,
+ actual,
+ expected,
+ correct: JSON.stringify(actual) === JSON.stringify(expected),
+ });
+ }
+ const branchDecisionAcc = branchDecisions.length
+ ? branchDecisions.filter(branch => branch.correct).length / branchDecisions.length
+ : null;
+ const parseOk = armResult.parse_ok !== false;
+
+ return {
+ selected_route: selectedRoute,
+ gold_route: goldRoute,
+ selected_node_ids: selectedNodeIds,
+ gold_node_ids: goldNodeIds,
+ route_exact: route.route_exact,
+ route_jaccard: route.route_jaccard,
+ node_route_exact: nodeRoute.route_exact,
+ node_route_jaccard: nodeRoute.route_jaccard,
+ over_routing_count: overRoutingNodeIds.length,
+ under_routing_count: underRoutingNodeIds.length,
+ over_routing_node_ids: overRoutingNodeIds,
+ under_routing_node_ids: underRoutingNodeIds,
+ branch_decisions: branchDecisions,
+ branch_decision_acc: branchDecisionAcc,
+ node_acc: nodeAcc,
+ parse_ok: parseOk,
+ case_success: route.route_exact
+ && nodeRoute.route_exact
+ && overRoutingNodeIds.length === 0
+ && underRoutingNodeIds.length === 0
+ && (branchDecisionAcc === null || branchDecisionAcc === 1)
+ && allGoldCorrect
+ && parseOk,
+ };
+}
+
+function rate(items, predicate) {
+ return items.length ? +(items.filter(predicate).length / items.length).toFixed(3) : 0;
+}
+
+function summarizeOne(items) {
+ const n = items.length;
+ const branchRows = items.filter(row => typeof row.branch_decision_acc === 'number');
+ return {
+ n,
+ case_success_rate: rate(items, row => row.case_success),
+ route_exact_rate: rate(items, row => row.route_exact),
+ route_jaccard_avg: n ? +(items.reduce((sum, row) => sum + (row.route_jaccard || 0), 0) / n).toFixed(3) : 0,
+ over_routing_avg: n ? +(items.reduce((sum, row) => sum + (row.over_routing_count || 0), 0) / n).toFixed(3) : 0,
+ under_routing_avg: n ? +(items.reduce((sum, row) => sum + (row.under_routing_count || 0), 0) / n).toFixed(3) : 0,
+ branch_decision_acc: branchRows.length
+ ? +(branchRows.reduce((sum, row) => sum + row.branch_decision_acc, 0) / branchRows.length).toFixed(3)
+ : null,
+ node_acc: n ? +(items.reduce((sum, row) => sum + (row.node_acc || 0), 0) / n).toFixed(3) : 0,
+ parse_ok_rate: rate(items, row => row.parse_ok !== false),
+ };
+}
+
+function summarizeArms(scoredCases, arms) {
+ const out = {};
+ for (const arm of arms) {
+ const items = scoredCases.map(row => row.by_arm && row.by_arm[arm]).filter(Boolean);
+ const summary = summarizeOne(items);
+ const strata = {};
+ for (const workflowCase of scoredCases) {
+ const result = workflowCase.by_arm && workflowCase.by_arm[arm];
+ if (!result) continue;
+ const key = `${workflowCase.stability}|${workflowCase.branching}|${workflowCase.novelty}`;
+ (strata[key] ||= []).push(result);
+ }
+ summary.by_stratum = Object.fromEntries(Object.entries(strata).map(([key, rows]) => [key, summarizeOne(rows)]));
+ out[arm] = summary;
+ }
+ return out;
+}
+
+function contrast(scoredCases, left, right) {
+ const pairs = scoredCases
+ .map(workflowCase => [workflowCase.by_arm && workflowCase.by_arm[left], workflowCase.by_arm && workflowCase.by_arm[right]])
+ .filter(([leftResult, rightResult]) => leftResult && rightResult);
+ const leftWins = pairs.filter(([leftResult, rightResult]) => leftResult.case_success && !rightResult.case_success).length;
+ const rightWins = pairs.filter(([leftResult, rightResult]) => !leftResult.case_success && rightResult.case_success).length;
+ const leftRate = pairs.length ? pairs.filter(([leftResult]) => leftResult.case_success).length / pairs.length : 0;
+ const rightRate = pairs.length ? pairs.filter(([, rightResult]) => rightResult.case_success).length / pairs.length : 0;
+ return {
+ delta_case_success_pp: +((leftRate - rightRate) * 100).toFixed(1),
+ mcnemar_p: +mcnemar(leftWins, rightWins).toFixed(3),
+ discordant: leftWins + rightWins,
+ left_wins: leftWins,
+ right_wins: rightWins,
+ };
+}
+
+function computeContrasts(scoredCases, arms, contrasts = AGENTIC_CONTRASTS) {
+ const available = new Set(arms);
+ const out = {};
+ for (const [name, left, right] of contrasts) {
+ if (available.has(left) && available.has(right)) out[name] = contrast(scoredCases, left, right);
+ }
+ return out;
+}
+
+module.exports = {
+ AGENTIC_ARMS,
+ AGENTIC_CONTRASTS,
+ extractRouteFromText,
+ evalBranchRules,
+ scoreRoute,
+ scoreCaseResult,
+ summarizeOne,
+ summarizeArms,
+ contrast,
+ computeContrasts,
+};
diff --git a/evals/lib/workflow-prompts.js b/evals/lib/workflow-prompts.js
new file mode 100644
index 0000000..aea0cc4
--- /dev/null
+++ b/evals/lib/workflow-prompts.js
@@ -0,0 +1,117 @@
+'use strict';
+
+const { neutralFiller, triggerSummary, wordCount } = require('./conditions');
+
+
+/** Concise deterministic workflows for testing workflow-form instructions vs full SKILL.md guides. */
+
+const WORKFLOW_FRIENDLY_SKILLS = [
+ 'thinking-socratic',
+ 'thinking-cynefin',
+ 'thinking-reversibility',
+ 'thinking-margin-of-safety',
+ 'thinking-map-territory',
+ 'thinking-pre-mortem',
+ 'thinking-red-team',
+ 'thinking-scientific-method',
+ 'thinking-kepner-tregoe',
+ 'thinking-five-whys-plus',
+];
+
+const OBJECTIVE_AUTHORED_COVERAGE = [
+ 'thinking-socratic',
+ 'thinking-cynefin',
+ 'thinking-reversibility',
+ 'thinking-margin-of-safety',
+ 'thinking-map-territory',
+ 'thinking-pre-mortem',
+ 'thinking-red-team',
+ 'thinking-scientific-method',
+ 'thinking-kepner-tregoe',
+ 'thinking-five-whys-plus',
+];
+
+const WORKFLOW_PROMPTS = {
+ 'thinking-socratic': `Use this workflow before proposing a solution:\n1. Restate the concrete decision to be made.\n2. List the request's hidden assumptions and undefined terms.\n3. Identify what evidence would distinguish the stated solution from alternatives.\n4. If a missing answer would change the work, ask that question before designing; otherwise proceed with the smallest justified next step.\n5. End with the questions or next action that prevents guessing.`,
+
+ 'thinking-cynefin': `Use this workflow to choose the operating mode:\n1. Classify the situation as clear, complicated, complex, chaotic, or confused.\n2. If clear, apply known best practice directly.\n3. If complicated, analyze with expertise before acting.\n4. If complex, run safe-to-fail probes and learn before scaling.\n5. If chaotic, stabilize first, then reassess.\n6. State the classification and the matching next action.`,
+
+ 'thinking-reversibility': `Use this workflow before deciding how much deliberation is needed:\n1. Decide whether the action is a one-way door or two-way door.\n2. Name what would make reversal costly: data loss, contracts, user trust, migration, lock-in, safety, or legal exposure.\n3. If two-way, prefer a fast bounded trial.\n4. If one-way, look for canaries, flags, backups, staged rollout, rollback, or delay.\n5. Recommend the reversible version of the decision when possible.`,
+
+ 'thinking-margin-of-safety': `Use this workflow for estimates, capacity, limits, and commitments:\n1. Identify the expected load, estimate, or requirement.\n2. Identify the cost of being under the requirement versus over it.\n3. Check variance, unknowns, tails, and correlated failure modes.\n4. Choose a buffer proportional to downside risk, not to optimism.\n5. State whether the margin is adequate and what buffer or contingency is needed.`,
+
+ 'thinking-map-territory': `Use this workflow when a plan depends on a model, doc, dashboard, test, or assumption:\n1. State the map being relied on.\n2. Identify the territory observation that would prove or disprove it.\n3. Prefer direct evidence from running code, production behavior, logs, users, or data.\n4. If territory contradicts the map, update the conclusion and stop reasoning from the stale description.\n5. Recommend the next verification or correction.`,
+
+ 'thinking-pre-mortem': `Use this workflow before a launch, migration, or plan commitment, or when optimism may hide failure paths:\n1. Assume it is later and the plan has failed badly, or ask how you would guarantee failure.\n2. Write the most plausible high-probability or high-damage failure story in concrete terms.\n3. Separate preventable/controllable causes from acceptable residual risks.\n4. Convert the top preventable causes into launch blockers, requirements, constraints, tests, or monitoring.\n5. Recommend the simplest changes that make failure less likely before proceeding.`,
+
+ 'thinking-red-team': `Use this workflow for security-sensitive code, auth, APIs, data, and permissions:\n1. Identify assets, trust boundaries, actors, and attacker goals.\n2. Enumerate concrete attack paths, not generic concerns.\n3. Check authn/authz, input handling, secrets, data exposure, rate limits, and unsafe defaults.\n4. Keep only findings with a reproducible exploit path and realistic impact.\n5. Report severity, exploit steps, and the minimal fix.`,
+
+ 'thinking-scientific-method': `Use this workflow to debug an uncertain symptom or choose among competing causes:\n1. State the observed symptom precisely.\n2. Generate competing falsifiable hypotheses and count the assumptions each requires.\n3. Rank them by prior likelihood, assumption count, and cheapness of discriminating tests; prefer the least-assumptive hypothesis that fits known facts.\n4. Run or propose the cheapest observation that would rule hypotheses in or out; escalate only when evidence rules out the simple explanation.\n5. Update based on evidence and choose the next test or fix, avoiding exotic causes until boring ones fail.`,
+
+ 'thinking-kepner-tregoe': `Use this workflow for selective defects:\n1. Define the deviation from expected behavior.\n2. Map what IS affected by object, location, time, and extent.\n3. Map what IS NOT affected but could have been.\n4. Compare the boundary and ask what changed there.\n5. Test the cause that explains all IS facts and none of the IS-NOT facts.`,
+
+ 'thinking-five-whys-plus': `Use this workflow when a proximate fault is known but the systemic root is not:\n1. Start with the observed fault and immediate cause.\n2. Ask why each cause was possible, grounding each answer in evidence.\n3. At every step, test whether fixing that cause would prevent recurrence.\n4. Stop at the first actionable systemic cause with a clear counterfactual.\n5. Recommend the prevention, not just the patch.`,
+
+ 'thinking-second-order': `Use this workflow when a decision has effects beyond the immediate outcome:\n1. State the decision and its intended first-order effect.\n2. Ask "and then what?" — trace how people, systems, or incentives will adapt.\n3. Identify reinforcing or balancing feedback loops that amplify or dampen the effect.\n4. Consider second and third-order consequences across different time horizons.\n5. Decide whether the goal survives the downstream cascade before committing.`,
+};
+
+function workflowPromptFor(skillName) {
+ const prompt = WORKFLOW_PROMPTS[skillName];
+ if (!prompt) throw new Error(`missing workflow prompt for ${skillName}`);
+ return prompt;
+}
+
+function padToWords(content, targetWords) {
+ const have = wordCount(content);
+ return targetWords > have ? `${content}\n\nAdditional neutral context for length control:\n${neutralFiller(targetWords - have)}` : content;
+}
+
+function buildFactorialPrompt(form, problemText, skillContent, skillName, options = {}) {
+ const workflow = workflowPromptFor(skillName);
+ const targetWords = options.targetWords || Math.max(wordCount(skillContent), wordCount(workflow), wordCount(triggerSummary(skillContent, skillName)));
+ const tail = '\n\nThink carefully and give your best, decision-useful answer.';
+ const typedVerifier = options.behavioralOutput
+ ? 'Before giving your final answer, self-check it against the exact decision instruction above: does your answer follow from the steps? If not, revise. Then give your full reasoning and conclusion as prose.'
+ : 'Use the same typed decision schema and self-check for this answer: first decide whether the correct answer is true/false, then verify it against the exact decision instruction and problem facts. Return a single JSON object only, with no markdown or extra prose: { "answer": true | false, "rationale": "<one concise sentence>" }.';
+ let body;
+ if (form === 'full_skill_prose') {
+ body = `Use the following thinking-skill guide to structure your reasoning. Apply it substantively; do not merely name it.\n\n=== THINKING SKILL ===\n${skillContent}\n=== END THINKING SKILL ===`;
+ } else if (form === 'full_skill_workflow') {
+ body = `Execute the following thinking-skill guide as a deterministic workflow. Turn its guidance into explicit ordered steps while preserving the full substance of the guide.\n\n=== THINKING SKILL CONTENT TO EXECUTE AS WORKFLOW ===\n${skillContent}\n=== END THINKING SKILL CONTENT ===`;
+ } else if (form === 'concise_skill_prose') {
+ body = `Consider this concise thinking approach and apply it substantively if relevant.\n\n=== CONCISE THINKING SKILL ===\n${triggerSummary(skillContent, skillName)}\n=== END CONCISE THINKING SKILL ===`;
+ } else if (form === 'concise_workflow') {
+ body = `Use this deterministic workflow to structure your reasoning. Follow the steps substantively; do not merely name the workflow.\n\n=== WORKFLOW ===\n${workflow}\n=== END WORKFLOW ===`;
+ } else if (form === 'workflow_validated') {
+ body = `Use this deterministic workflow to structure your reasoning. Follow the steps substantively; do not merely name the workflow.\n\n=== WORKFLOW ===\n${workflow}\n=== END WORKFLOW ===\n\n=== SELF-CHECK VERIFIER ===\n${typedVerifier}\n=== END SELF-CHECK VERIFIER ===`;
+ } else if (form === 'full_skill_typed_verified') {
+ body = `Use the following thinking-skill guide to structure your reasoning. Apply it substantively; do not merely name it.\n\n=== THINKING SKILL ===\n${skillContent}\n=== END THINKING SKILL ===\n\n=== SELF-CHECK VERIFIER ===\n${typedVerifier}\n=== END SELF-CHECK VERIFIER ===`;
+ } else if (form === 'placebo') {
+ body = 'Some general notes before the task:';
+ } else {
+ throw new Error(`unknown factorial prompt form ${form}`);
+ }
+ const padded = form === 'placebo'
+ ? `${body}\n\n${neutralFiller(targetWords)}`
+ : padToWords(body, targetWords);
+ return `${padded}\n\nNow address this problem:\n\n${problemText}${tail}`;
+}
+
+function factorialForms() {
+ return ['full_skill_prose', 'full_skill_workflow', 'concise_skill_prose', 'concise_workflow', 'placebo'];
+}
+
+function objectiveForms() {
+ return ['placebo', 'full_skill_prose', 'concise_workflow', 'workflow_validated', 'full_skill_typed_verified'];
+}
+
+module.exports = {
+ WORKFLOW_FRIENDLY_SKILLS,
+ OBJECTIVE_AUTHORED_COVERAGE,
+ WORKFLOW_PROMPTS,
+ workflowPromptFor,
+ padToWords,
+ buildFactorialPrompt,
+ factorialForms,
+ objectiveForms,
+};
diff --git a/evals/run-agentic.js b/evals/run-agentic.js
new file mode 100644
index 0000000..3193afd
--- /dev/null
+++ b/evals/run-agentic.js
@@ -0,0 +1,467 @@
+#!/usr/bin/env node
+'use strict';
+
+/**
+ * Pilot eval for multi-step agentic workflow control flow.
+ *
+ * Separates route/control-flow accuracy from binary node execution accuracy for
+ * dynamic skill choice vs deterministic workflow scheduling. The dataset stores
+ * references to authored binary-decision items; labels are used only for scoring.
+ */
+
+const fs = require('fs');
+const path = require('path');
+const crypto = require('crypto');
+const { droidExecWithRetry, extractJson, maxEffortFor, usageSummary, aggregateUsage } = require('./lib/droid');
+const { loadAllSkills, readSkill } = require('./lib/skills');
+const { runDir, writeJson, mapPool, runHealthWarnings } = require('./lib/io');
+const { preregistrationMeta, runMetadata, claimStatus } = require('./lib/prereg');
+const {
+ AGENTIC_ARMS,
+ extractRouteFromText,
+ evalBranchRules,
+ scoreCaseResult,
+ summarizeArms,
+ computeContrasts,
+} = require('./lib/agentic');
+
+const SOLVER = process.env.SOLVER_MODEL || 'claude-sonnet-4-6';
+const SOLVER_EFFORT = process.env.SOLVER_EFFORT || 'medium';
+const CONC = parseInt(process.env.CONC || '3', 10);
+const LIMIT = process.env.LIMIT ? parseInt(process.env.LIMIT, 10) : null;
+const DEFAULT_ARMS = AGENTIC_ARMS.join(',');
+const ARMS = (process.env.ARMS || DEFAULT_ARMS).split(',').map(s => s.trim()).filter(Boolean);
+const OUTFILE = process.env.OUTFILE || path.join(runDir(), 'agentic-workflow.json');
+const DATASET = process.env.WORKFLOW_DATASET ? path.resolve(process.env.WORKFLOW_DATASET) : path.join(__dirname, 'datasets', 'workflow-cases.jsonl');
+const REPO_ROOT = path.join(__dirname, '..');
+
+const ALL_ARMS = new Set(AGENTIC_ARMS);
+
+
+function readJsonl(file) {
+ return fs.readFileSync(file, 'utf8')
+ .split('\n')
+ .map(l => l.trim())
+ .filter(Boolean)
+ .map((line, i) => {
+ try { return JSON.parse(line); }
+ catch (e) { throw new Error(`${file}:${i + 1}: invalid JSON: ${e.message}`); }
+ });
+}
+
+function sha256(s) {
+ return crypto.createHash('sha256').update(s).digest('hex');
+}
+
+function loadSourceIndex(sourceFile, cache) {
+ if (!cache.has(sourceFile)) {
+ const full = path.join(REPO_ROOT, sourceFile);
+ if (!fs.existsSync(full)) throw new Error(`missing source file: ${sourceFile}`);
+ const byId = new Map();
+ for (const item of readJsonl(full)) byId.set(item.id, item);
+ cache.set(sourceFile, byId);
+ }
+ return cache.get(sourceFile);
+}
+
+function validateRuleShape(rule, caseId, nodeIds, decisionKeys) {
+ if (!rule || typeof rule !== 'object') throw new Error(`${caseId}: invalid branch rule`);
+ if (!nodeIds.has(rule.after)) throw new Error(`${caseId}: branch rule references unknown after node ${rule.after}`);
+ if (!rule.if || typeof rule.if.decision_key !== 'string') throw new Error(`${caseId}: branch rule missing if.decision_key`);
+ if (!decisionKeys.has(rule.if.decision_key)) throw new Error(`${caseId}: branch rule references unknown decision key ${rule.if.decision_key}`);
+ if (typeof rule.if.equals !== 'boolean') throw new Error(`${caseId}: branch rule if.equals must be boolean`);
+ for (const nid of [...(rule.then || []), ...(rule.else || [])]) {
+ if (!nodeIds.has(nid)) throw new Error(`${caseId}: branch rule references unknown node ${nid}`);
+ }
+}
+
+function validateAndHydrateCase(row, sourceCache, seenIds) {
+ if (!row || typeof row !== 'object') throw new Error('workflow row must be an object');
+ if (!row.id) throw new Error('workflow row missing id');
+ if (seenIds.has(row.id)) throw new Error(`duplicate workflow row id: ${row.id}`);
+ seenIds.add(row.id);
+ if (!Array.isArray(row.nodes) || row.nodes.length === 0) throw new Error(`${row.id}: missing nodes`);
+ if (!Array.isArray(row.initial_node_ids)) throw new Error(`${row.id}: missing initial_node_ids`);
+ if (!Array.isArray(row.workflow_branch_rules)) throw new Error(`${row.id}: missing workflow_branch_rules`);
+ if (!Array.isArray(row.gold_node_ids) || row.gold_node_ids.length === 0) throw new Error(`${row.id}: missing gold_node_ids`);
+
+ const nodeIds = new Set();
+ const decisionKeys = new Set();
+ const nodes = row.nodes.map(node => {
+ if (!node.node_id || !node.skill || !node.decision_key || !node.source_file || !node.source_id) {
+ throw new Error(`${row.id}: node missing required fields`);
+ }
+ if (nodeIds.has(node.node_id)) throw new Error(`${row.id}: duplicate node id ${node.node_id}`);
+ nodeIds.add(node.node_id);
+ decisionKeys.add(node.decision_key);
+ try { readSkill(node.skill); }
+ catch (_) { throw new Error(`${row.id}: missing skill directory for ${node.skill}`); }
+ const source = loadSourceIndex(node.source_file, sourceCache).get(node.source_id);
+ if (!source) throw new Error(`${row.id}: missing source id ${node.source_id} in ${node.source_file}`);
+ if (typeof source.label !== 'boolean') throw new Error(`${row.id}: source ${node.source_id} missing boolean label`);
+ if (!source.prompt || !source.decision_instruction) throw new Error(`${row.id}: source ${node.source_id} missing prompt or decision_instruction`);
+ const sourceHash = sha256(JSON.stringify({ source_file: node.source_file, source_id: node.source_id, prompt: source.prompt, decision_instruction: source.decision_instruction, label: source.label }));
+ return { ...node, prompt: source.prompt, decision_instruction: source.decision_instruction, label: source.label, source_sha256: sourceHash };
+ });
+
+ for (const nid of row.initial_node_ids) {
+ if (!nodeIds.has(nid)) throw new Error(`${row.id}: initial_node_ids references unknown node ${nid}`);
+ }
+ for (const nid of row.gold_node_ids) {
+ if (!nodeIds.has(nid)) throw new Error(`${row.id}: gold_node_ids references unknown node ${nid}`);
+ }
+ for (const rule of row.workflow_branch_rules) validateRuleShape(rule, row.id, nodeIds, decisionKeys);
+ return { ...row, nodes };
+}
+
+function loadCases(options = {}) {
+ const applyLimit = options.applyLimit !== false;
+ const sourceCache = new Map();
+ const seenIds = new Set();
+ let cases = readJsonl(DATASET).map(row => validateAndHydrateCase(row, sourceCache, seenIds));
+ if (applyLimit && LIMIT != null) cases = cases.slice(0, LIMIT);
+ return cases;
+}
+
+function extractYesNo(text) {
+ if (!text) return null;
+ const m = text.match(/ANSWER:\s*(yes|no)/i) ||
+ text.match(/\b(YES|NO)\b[.!]*\s*$/im) ||
+ text.match(/\b(yes|no)\b[.!]*\s*$/im);
+ return m ? m[1].toLowerCase() : null;
+}
+
+
+function nodeListForPrompt(workflowCase) {
+ return workflowCase.nodes.map(n => [
+ `NODE ${n.node_id}`,
+ `skill: ${n.skill}`,
+ `decision_key: ${n.decision_key}`,
+ `decision_instruction: ${n.decision_instruction}`,
+ `prompt: ${n.prompt}`,
+ ].join('\n')).join('\n\n');
+}
+
+function buildCatalog(skills) {
+ return skills.map(s => `${s.name}: ${s.description}`).join('\n');
+}
+
+function dynamicLoosePrompt(workflowCase, catalog) {
+ return `You are choosing which thinking-skill analyses are warranted for a composite workflow case.\n\n=== CASE BRIEF ===\n${workflowCase.case_brief}\n\n=== CANDIDATE NODES ===\n${nodeListForPrompt(workflowCase)}\n\n=== SKILL CATALOG ===\n${catalog}\n\nChoose only the warranted skill sequence. Then answer the selected binary node prompts.\nUse skill slugs when naming the route. For each selected node, include a line like: <node_id>: ANSWER: <Yes or No>.\nDo not answer nodes you did not select.`;
+}
+
+function dynamicTypedPrompt(workflowCase, catalog) {
+ return `You are choosing which thinking-skill analyses are warranted for a composite workflow case.\n\n=== CASE BRIEF ===\n${workflowCase.case_brief}\n\n=== CANDIDATE NODES ===\n${nodeListForPrompt(workflowCase)}\n\n=== SKILL CATALOG ===\n${catalog}\n\nReturn ONLY JSON with exactly this shape:\n{ "selected_route": ["thinking-..."], "node_answers": [{ "node_id": "...", "answer": true, "rationale": "..." }], "final": "..." }\n\nselected_route must be the ordered skill slug sequence you chose. node_answers must include one answer per selected candidate node, using the source decision_instruction for that node.`;
+}
+
+function dynamicVerifyPrompt(workflowCase, catalog, candidate) {
+ return `Repair and verify the following dynamic workflow JSON. You must choose the warranted skill route and binary node answers using only the case brief and candidate node prompts. Do not invent node IDs.\n\n=== CASE BRIEF ===\n${workflowCase.case_brief}\n\n=== CANDIDATE NODES ===\n${nodeListForPrompt(workflowCase)}\n\n=== SKILL CATALOG ===\n${catalog}\n\n=== CANDIDATE OUTPUT ===\n${candidate}\n\nReturn ONLY repaired JSON with exactly this shape:\n{ "selected_route": ["thinking-..."], "node_answers": [{ "node_id": "...", "answer": true, "rationale": "..." }], "final": "..." }`;
+}
+
+function workflowLoosePrompt(node, skillMd) {
+ return `Use the following thinking-skill guide to answer exactly one binary decision node.\n\n=== THINKING SKILL ===\n${skillMd}\n=== END SKILL ===\n\n=== DECISION INSTRUCTION ===\n${node.decision_instruction}\n\n=== NODE PROMPT ===\n${node.prompt}\n\nEnd your response with exactly: ANSWER: <Yes or No>`;
+}
+
+function workflowTypedPrompt(node, skillMd) {
+ return `Use the following thinking-skill guide to answer exactly one binary decision node.\n\n=== THINKING SKILL ===\n${skillMd}\n=== END SKILL ===\n\n=== DECISION INSTRUCTION ===\n${node.decision_instruction}\n\n=== NODE ID ===\n${node.node_id}\n\n=== NODE PROMPT ===\n${node.prompt}\n\nReturn ONLY JSON with exactly this shape:\n{ "node_id": "${node.node_id}", "answer": true, "rationale": "..." }`;
+}
+
+
+function workflowSelfCheckPrompt(node, skillMd, candidateOutput) {
+ return `Independently check the candidate node answer against the thinking-skill guide, decision instruction, and node prompt. Correct either the answer or rationale when needed. Do not merely repair syntax.\n\n=== THINKING SKILL ===\n${skillMd}\n=== END SKILL ===\n\n=== DECISION INSTRUCTION ===\n${node.decision_instruction}\n\n=== NODE ID ===\n${node.node_id}\n\n=== NODE PROMPT ===\n${node.prompt}\n\n=== CANDIDATE OUTPUT ===\n${candidateOutput}\n\nReturn ONLY JSON with exactly this shape:\n{ "node_id": "${node.node_id}", "answer": true, "rationale": "..." }`;
+}
+
+function validateDynamicJson(json, nodeIds) {
+ if (!json || typeof json !== 'object') return { ok: false, error: 'not an object' };
+ if (!Array.isArray(json.selected_route) || !json.selected_route.every(s => typeof s === 'string')) return { ok: false, error: 'selected_route must be string[]' };
+ if (!Array.isArray(json.node_answers)) return { ok: false, error: 'node_answers must be an array' };
+ for (const ans of json.node_answers) {
+ if (!ans || typeof ans.node_id !== 'string' || !nodeIds.has(ans.node_id) || typeof ans.answer !== 'boolean' || typeof ans.rationale !== 'string') {
+ return { ok: false, error: 'node_answers entries must have known node_id, boolean answer, rationale string' };
+ }
+ }
+ if (typeof json.final !== 'string') return { ok: false, error: 'final must be a string' };
+ return { ok: true, error: null };
+}
+
+function validateNodeJson(json, expectedNodeId) {
+ if (!json || typeof json !== 'object') return { ok: false, error: 'not an object' };
+ if (json.node_id !== expectedNodeId) return { ok: false, error: 'missing or wrong node_id' };
+ if (typeof json.answer !== 'boolean') return { ok: false, error: 'answer must be boolean' };
+ if (typeof json.rationale !== 'string') return { ok: false, error: 'rationale must be string' };
+ return { ok: true, error: null };
+}
+
+function extractNodeAnswersFromText(text, nodes) {
+ const answers = [];
+ const full = String(text || '');
+ for (const node of nodes) {
+ const re = new RegExp(`${escapeRe(node.node_id)}[\\s\\S]{0,160}?ANSWER:\\s*(yes|no)`, 'i');
+ const m = full.match(re);
+ if (m) answers.push({ node_id: node.node_id, answer: m[1].toLowerCase() === 'yes', rationale: 'extracted from free-form text' });
+ }
+ if (answers.length === 0 && nodes.length === 1) {
+ const yn = extractYesNo(full);
+ if (yn) answers.push({ node_id: nodes[0].node_id, answer: yn === 'yes', rationale: 'extracted from free-form text' });
+ }
+ return answers;
+}
+
+function compactRaw(text) {
+ const s = String(text || '').replace(/\s+/g, ' ').trim();
+ return s.length > 600 ? `${s.slice(0, 600)}...` : s;
+}
+const _solverStatsByCase = new Map();
+function solverStatsFor(caseId) {
+ if (!_solverStatsByCase.has(caseId)) _solverStatsByCase.set(caseId, { calls: 0, attempts: 0, failures: 0, retried: 0, usage: [] });
+ return _solverStatsByCase.get(caseId);
+}
+async function trackedSolverCall(caseId, opts) {
+ const stats = solverStatsFor(caseId);
+ const r = await droidExecWithRetry(opts);
+ const attempts = r.attempts || 1;
+ stats.calls++;
+ stats.attempts += attempts;
+ if (attempts > 1) stats.retried++;
+ if (!r.ok) stats.failures++;
+ if (r.usage) stats.usage.push(usageSummary(r.usage, SOLVER));
+ return r;
+}
+function aggregateSolverStats(caseIds) {
+ let calls = 0, attempts = 0, failures = 0, retried = 0;
+ const allUsage = [];
+ for (const id of caseIds) {
+ const s = _solverStatsByCase.get(id);
+ if (!s) continue;
+ calls += s.calls; attempts += s.attempts; failures += s.failures; retried += s.retried;
+ if (s.usage) allUsage.push(...s.usage);
+ }
+ return { solver_calls: calls, solver_attempts: attempts, solver_failures: failures, retried_calls: retried, failure_rate: calls ? +(failures / calls).toFixed(4) : 0, decision_eligible: failures === 0, token_usage: aggregateUsage(allUsage) };
+}
+
+async function runDynamicTypedCore(workflowCase, catalog, callSolver = trackedSolverCall) {
+ const nodeIds = new Set(workflowCase.nodes.map(n => n.node_id));
+ const r = await callSolver(workflowCase.id, { model: SOLVER, effort: SOLVER_EFFORT, prompt: dynamicTypedPrompt(workflowCase, catalog) });
+ if (!r.ok) return { parse_ok: false, selected_route: [], node_answers: [], final: '', error: r.error, raw: compactRaw(r.raw) };
+ const json = extractJson(r.text);
+ const valid = validateDynamicJson(json, nodeIds);
+ if (!valid.ok) return { parse_ok: false, selected_route: [], node_answers: [], final: '', error: valid.error, raw: compactRaw(r.text) };
+ return { parse_ok: true, selected_route: json.selected_route, node_answers: json.node_answers, final: json.final, raw: compactRaw(r.text) };
+}
+
+async function runDynamicArm(workflowCase, arm, catalog, knownSkillNames, callSolver = trackedSolverCall) {
+ if (arm === 'dynamic_loose') {
+ const r = await callSolver(workflowCase.id, { model: SOLVER, effort: SOLVER_EFFORT, prompt: dynamicLoosePrompt(workflowCase, catalog) });
+ if (!r.ok) return { parse_ok: true, selected_route: [], node_answers: [], final: '', error: r.error, raw: compactRaw(r.raw) };
+ return {
+ parse_ok: true,
+ selected_route: extractRouteFromText(r.text, knownSkillNames),
+ node_answers: extractNodeAnswersFromText(r.text, workflowCase.nodes),
+ final: r.text,
+ raw: compactRaw(r.text),
+ };
+ }
+
+ if (arm === 'dynamic_typed') {
+ return runDynamicTypedCore(workflowCase, catalog, callSolver);
+ }
+
+ if (arm === 'dynamic_typed_self_checked') {
+ const first = await runDynamicTypedCore(workflowCase, catalog, callSolver);
+ const nodeIds = new Set(workflowCase.nodes.map(n => n.node_id));
+ const candidate = first.parse_ok
+ ? JSON.stringify({ selected_route: first.selected_route, node_answers: first.node_answers, final: first.final }, null, 2)
+ : (first.raw || first.error || '');
+ const r = await callSolver(workflowCase.id, { model: SOLVER, effort: SOLVER_EFFORT, prompt: dynamicVerifyPrompt(workflowCase, catalog, candidate) });
+ if (!r.ok) return { parse_ok: false, selected_route: [], node_answers: [], final: '', error: r.error, first, raw: compactRaw(r.raw) };
+ const json = extractJson(r.text);
+ const valid = validateDynamicJson(json, nodeIds);
+ if (!valid.ok) return { parse_ok: false, selected_route: [], node_answers: [], final: '', error: valid.error, first, raw: compactRaw(r.text) };
+ return { parse_ok: true, selected_route: json.selected_route, node_answers: json.node_answers, final: json.final, first_parse_ok: first.parse_ok, raw: compactRaw(r.text) };
+ }
+
+ throw new Error(`unknown dynamic arm ${arm}`);
+}
+
+async function runWorkflowTypedBaseNode(node, skillCache, caseId, callSolver = trackedSolverCall) {
+ const skillMd = skillCache.get(node.skill) || readSkill(node.skill).content;
+ skillCache.set(node.skill, skillMd);
+ const r = await callSolver(caseId, { model: SOLVER, effort: SOLVER_EFFORT, prompt: workflowTypedPrompt(node, skillMd) });
+ if (!r.ok) {
+ return { parse_ok: false, node_answer: { node_id: node.node_id, answer: null, rationale: r.error }, raw: compactRaw(r.raw), invalid_output: r.raw };
+ }
+ const json = extractJson(r.text);
+ const valid = validateNodeJson(json, node.node_id);
+ return valid.ok
+ ? { parse_ok: true, node_answer: { node_id: json.node_id, answer: json.answer, rationale: json.rationale }, raw: compactRaw(r.text), invalid_output: null }
+ : { parse_ok: false, node_answer: { node_id: node.node_id, answer: null, rationale: valid.error }, raw: compactRaw(r.text), invalid_output: r.text };
+}
+
+async function runWorkflowNode(node, arm, skillCache, caseId, callSolver = trackedSolverCall) {
+ if (arm === 'workflow_none_typed') {
+ const response = await callSolver(caseId, { model: SOLVER, effort: SOLVER_EFFORT, prompt: workflowTypedPrompt(node, '') });
+ if (!response.ok) {
+ return { parse_ok: false, node_answer: { node_id: node.node_id, answer: null, rationale: response.error }, raw: compactRaw(response.raw) };
+ }
+ const json = extractJson(response.text);
+ const valid = validateNodeJson(json, node.node_id);
+ return valid.ok
+ ? { parse_ok: true, node_answer: { node_id: json.node_id, answer: json.answer, rationale: json.rationale }, raw: compactRaw(response.text) }
+ : { parse_ok: false, node_answer: { node_id: node.node_id, answer: null, rationale: valid.error }, raw: compactRaw(response.text) };
+ }
+
+ const skillMd = skillCache.get(node.skill) || readSkill(node.skill).content;
+ skillCache.set(node.skill, skillMd);
+
+ if (arm === 'workflow_loose') {
+ const response = await callSolver(caseId, { model: SOLVER, effort: SOLVER_EFFORT, prompt: workflowLoosePrompt(node, skillMd) });
+ if (!response.ok) return { parse_ok: true, node_answer: { node_id: node.node_id, answer: null, rationale: response.error }, raw: compactRaw(response.raw) };
+ const yesNo = extractYesNo(response.text);
+ return { parse_ok: true, node_answer: { node_id: node.node_id, answer: yesNo == null ? null : yesNo === 'yes', rationale: 'extracted from free-form text' }, raw: compactRaw(response.text) };
+ }
+ if (arm !== 'workflow_typed' && arm !== 'workflow_typed_self_checked') {
+ throw new Error(`unknown workflow arm ${arm}`);
+ }
+
+ const base = await runWorkflowTypedBaseNode(node, skillCache, caseId, callSolver);
+ if (arm === 'workflow_typed') return { ...base, self_checked: false };
+
+ const candidate = base.parse_ok
+ ? JSON.stringify(base.node_answer)
+ : (base.invalid_output || base.raw || base.node_answer.rationale || '');
+ const review = await callSolver(caseId, { model: SOLVER, effort: SOLVER_EFFORT, prompt: workflowSelfCheckPrompt(node, skillMd, candidate) });
+ if (!review.ok) return { parse_ok: false, node_answer: { node_id: node.node_id, answer: null, rationale: review.error }, raw: base.raw, self_checked: false, first_parse_ok: base.parse_ok };
+ const reviewJson = extractJson(review.text);
+ const reviewValid = validateNodeJson(reviewJson, node.node_id);
+ if (!reviewValid.ok) return { parse_ok: false, node_answer: { node_id: node.node_id, answer: null, rationale: reviewValid.error }, raw: compactRaw(review.text), self_checked: false, first_parse_ok: base.parse_ok };
+ return { parse_ok: true, node_answer: { node_id: reviewJson.node_id, answer: reviewJson.answer, rationale: reviewJson.rationale }, raw: compactRaw(review.text), self_checked: true, first_parse_ok: base.parse_ok };
+}
+
+async function runWorkflowArm(workflowCase, arm, skillCache, callSolver = trackedSolverCall) {
+ const nodesById = new Map(workflowCase.nodes.map(n => [n.node_id, n]));
+ const queue = [...workflowCase.initial_node_ids];
+ const queued = new Set(queue);
+ const completed = new Set();
+ const answersByDecisionKey = {};
+ const nodeAnswers = [];
+ const scheduledNodeIds = [];
+ let parseOk = true;
+
+ while (queue.length) {
+ const nodeId = queue.shift();
+ queued.delete(nodeId);
+ const node = nodesById.get(nodeId);
+ if (!node) throw new Error(`${workflowCase.id}: scheduler reached unknown node ${nodeId}`);
+ if (completed.has(nodeId)) continue;
+ const nodeResult = await runWorkflowNode(node, arm, skillCache, workflowCase.id, callSolver);
+ scheduledNodeIds.push(nodeId);
+ nodeAnswers.push(nodeResult.node_answer);
+ completed.add(nodeId);
+ if (nodeResult.parse_ok === false) parseOk = false;
+ if (typeof nodeResult.node_answer.answer === 'boolean') answersByDecisionKey[node.decision_key] = nodeResult.node_answer.answer;
+ else answersByDecisionKey[node.decision_key] = null;
+
+ const additions = evalBranchRules(workflowCase.workflow_branch_rules, nodeId, answersByDecisionKey, completed, queued);
+ for (const add of additions) {
+ queue.push(add);
+ queued.add(add);
+ }
+ }
+
+ return {
+ parse_ok: parseOk,
+ selected_route: scheduledNodeIds.map(id => nodesById.get(id).skill),
+ scheduled_node_ids: scheduledNodeIds,
+ node_answers: nodeAnswers,
+ final: '',
+ };
+}
+
+async function runArmCase(workflowCase, arm, shared, callSolver = trackedSolverCall) {
+ if (arm.startsWith('dynamic_')) return runDynamicArm(workflowCase, arm, shared.catalog, shared.knownSkillNames, callSolver);
+ if (arm.startsWith('workflow_')) return runWorkflowArm(workflowCase, arm, shared.skillCache, callSolver);
+ throw new Error(`unknown arm ${arm}`);
+}
+
+
+async function main() {
+ for (const arm of ARMS) {
+ if (!ALL_ARMS.has(arm)) throw new Error(`unknown arm: ${arm}`);
+ }
+
+ const validateOnly = process.argv.includes('--validate-only');
+ const cases = loadCases({ applyLimit: !validateOnly });
+ if (validateOnly) {
+ console.log(`validated ${cases.length} workflow cases`);
+ return;
+ }
+
+ const skills = loadAllSkills();
+ const catalog = buildCatalog(skills);
+ const knownSkillNames = skills.map(s => s.name);
+ const shared = { catalog, knownSkillNames, skillCache: new Map() };
+
+ console.log(`Agentic workflow pilot: ${cases.length} cases, arms=${ARMS.join(',')}, solver=${SOLVER}(${SOLVER_EFFORT}; max=${maxEffortFor(SOLVER)}), conc=${CONC}`);
+
+ let done = 0;
+ const scoredCases = await mapPool(cases, CONC, async (workflowCase) => {
+ const caseOut = {
+ id: workflowCase.id,
+ stability: workflowCase.stability,
+ branching: workflowCase.branching,
+ novelty: workflowCase.novelty,
+ case_brief: workflowCase.case_brief,
+ gold_node_ids: workflowCase.gold_node_ids,
+ source_provenance: workflowCase.nodes.map(n => ({ node_id: n.node_id, source_file: n.source_file, source_id: n.source_id, source_sha256: n.source_sha256 })),
+ by_arm: {},
+ };
+ _solverStatsByCase.delete(workflowCase.id);
+ for (const arm of ARMS) {
+ const armRaw = await runArmCase(workflowCase, arm, shared);
+ const scored = scoreCaseResult(workflowCase, armRaw);
+ caseOut.by_arm[arm] = { ...scored, scheduled_node_ids: armRaw.scheduled_node_ids, node_answers: armRaw.node_answers, error: armRaw.error };
+ }
+ done++;
+ console.log(` [${done}/${cases.length}] ${workflowCase.id}`);
+ return caseOut;
+ });
+
+ const byArm = summarizeArms(scoredCases, ARMS);
+ const runHealth = aggregateSolverStats(scoredCases.map(c => c.id));
+ const out = {
+ mode: 'agentic-workflow',
+ solver: SOLVER,
+ solver_effort: SOLVER_EFFORT,
+ arms: ARMS,
+ n: cases.length,
+ dataset: DATASET,
+ dataset_sha256: sha256(fs.readFileSync(DATASET, 'utf8')),
+ preregistration: preregistrationMeta(),
+ run: runMetadata(),
+ run_health: runHealth,
+ warnings: runHealthWarnings(runHealth),
+ claim_status: claimStatus(runHealth, { isPilot: true }),
+ scoring_notes: ['dynamic_loose free-form route extraction is intentionally strict because unobservable control flow is part of the tested failure mode', 'case_success requires node-level route exactness, no over/under-routing, correct branch decisions, all gold answers correct, and parse_ok'],
+ by_arm: byArm,
+ contrasts: computeContrasts(scoredCases, ARMS),
+ cases: scoredCases,
+ };
+
+ writeJson(OUTFILE, out);
+ console.log(`-> ${OUTFILE}`);
+}
+
+if (require.main === module) {
+ main().catch(err => {
+ console.error(err && err.stack || err);
+ process.exit(1);
+ });
+}
+
+module.exports = {
+ extractYesNo,
+ loadCases,
+ runDynamicArm,
+ runWorkflowArm,
+ runArmCase,
+};
diff --git a/evals/studies/portfolio-v1/manifest.json b/evals/studies/portfolio-v1/manifest.json
index 58096d6..0033e36 100644
--- a/evals/studies/portfolio-v1/manifest.json
+++ b/evals/studies/portfolio-v1/manifest.json
@@ -28,6 +28,7 @@
},
"current_registry_ref": {
"path": "evals/studies/registry.json",
+ "git_commit": "3d1f67de41495a2fa979b196a76fc5a3e66235e0",
"registry_version": "phase4-portfolio-v1",
"sha256": "7bf021d6dd4c34cd5bd91c74874114f98e1dc952ebb279021add62af8416c91e",
"role": "post-gate output; not a preregistration input"
diff --git a/evals/studies/registry.json b/evals/studies/registry.json
index 3670e8e..14fd137 100644
--- a/evals/studies/registry.json
+++ b/evals/studies/registry.json
@@ -1,11 +1,11 @@
{
"schema_version": 1,
- "registry_version": "phase4-portfolio-v1",
- "generated_note": "Executable registry for the 28-skill catalog and portfolio-v1 evidence gate. The portfolio was preregistered but no solver calls were eligible: all survivors remain manual-only, with zero automatic elevations.",
+ "registry_version": "phase5-workflow-v1",
+ "generated_note": "Executable registry for the 28-skill manual-only catalog. portfolio-v1 made zero eligible calls; workflow-v1 failed its pre-run power gate and requires deletion of workflow-only machinery while preserving the no-run evidence.",
"catalog": {
"baseline_count": 39,
"cutover_count": 28,
- "current_phase": "portfolio_evidence",
+ "current_phase": "workflow_evidence",
"expected_count": 28,
"expected_dirs": [
"thinking-bounded-rationality",
@@ -2438,6 +2438,16 @@
"decision_eligible": false,
"status": "preregistered_blocked",
"product_disposition": "manual_only_quarantine"
+ },
+ {
+ "study_id": "workflow-v1",
+ "path": "evals/studies/workflow-v1",
+ "kind": "workflow_value_gate_no_run",
+ "skill_id": null,
+ "confirmatory_eligible_by_default": false,
+ "decision_eligible": false,
+ "status": "preregistered_power_blocked",
+ "product_disposition": "delete_workflow_machinery"
}
],
"workflow": {
@@ -2454,12 +2464,15 @@
},
"replication": {
"path": "evals/datasets/workflow-cases-replication.jsonl",
- "sha256": "628ba407a038f957e01c747ff008cda849d29c1eedd44a13ddfaf1eea736cf72",
+ "sha256": "3108849eae5636b7748cf800d49b25a9c5d9aaac78bd6986559ea5e2aaa7b0ef",
"exists": true
}
},
"retain_only_if_gate_passes": true,
- "engine_path_conditional": "evals/run-agentic.js"
+ "engine_path_conditional": "evals/run-agentic.js",
+ "study_id": "workflow-v1",
+ "decision_eligible": false,
+ "product_disposition": "delete_workflow_machinery"
},
"evidence_confirmation_requirements": [
"matching_preregistration_sha256",
diff --git a/evals/studies/workflow-v1/aggregate.json b/evals/studies/workflow-v1/aggregate.json
new file mode 100644
index 0000000..ac72d47
--- /dev/null
+++ b/evals/studies/workflow-v1/aggregate.json
@@ -0,0 +1,62 @@
+{
+ "schema_version": 1,
+ "study_id": "workflow-v1",
+ "study_version": "2026-07-16-freeze",
+ "created_at": "2026-07-16T00:00:00.000Z",
+ "run_status": "no_run",
+ "measured_result": null,
+ "statistical_status": "unmeasured_preregistered_power_blocked",
+ "replication_status": "not_run",
+ "evidence_validity": "preregistered_blocked",
+ "product_disposition": "delete_workflow_machinery",
+ "health": {
+ "attempted": 0,
+ "completed": 0,
+ "parsed": 0,
+ "scored": 0,
+ "failures": 0,
+ "decision_eligible": false
+ },
+ "usage": {
+ "input_tokens": 0,
+ "output_tokens": 0,
+ "cached_tokens": 0,
+ "calls": 0,
+ "latency_ms": 0,
+ "estimated_cost_usd": 0
+ },
+ "frozen_design": {
+ "candidate": "workflow_typed",
+ "comparators": [
+ "dynamic_typed",
+ "workflow_none_typed"
+ ],
+ "models": [
+ "claude-haiku-4-5-20251001",
+ "claude-sonnet-4-6",
+ "claude-opus-4-6"
+ ],
+ "available_independent_cases_per_model": 24,
+ "target_power": 0.9,
+ "powered": false
+ },
+ "retention_gates": {
+ "quality": "not_eligible",
+ "efficiency": "not_eligible"
+ },
+ "reasons": [
+ "available_replication_case_clusters_below_power_requirement",
+ "quality_gate_not_estimable_at_declared_precision",
+ "efficiency_noninferiority_gate_not_estimable_at_declared_precision",
+ "no_solver_calls_permitted_after_pre_run_power_failure",
+ "neither_retention_gate_passed"
+ ],
+ "cleanup_contract": {
+ "delete_old_runner_name": "evals/run-agentic-workflow.js",
+ "delete_new_runner_name": "evals/run-agentic.js",
+ "delete_pure_agentic_evaluator": "evals/lib/agentic.js",
+ "delete_workflow_prompt_registry": "evals/lib/workflow-prompts.js",
+ "delete_workflow_only_datasets_and_tests": true,
+ "preserve_this_null_record": true
+ }
+}
diff --git a/evals/studies/workflow-v1/cases.json b/evals/studies/workflow-v1/cases.json
new file mode 100644
index 0000000..38eb0a1
--- /dev/null
+++ b/evals/studies/workflow-v1/cases.json
@@ -0,0 +1,41 @@
+{
+ "schema_version": 1,
+ "study_id": "workflow-v1",
+ "study_version": "2026-07-16-freeze",
+ "dataset": {
+ "path": "evals/datasets/workflow-cases-replication.jsonl",
+ "sha256": "3108849eae5636b7748cf800d49b25a9c5d9aaac78bd6986559ea5e2aaa7b0ef",
+ "row_hash_algorithm": "sha256(canonical JSON with recursively sorted keys and compact separators)",
+ "n_cases": 24,
+ "n_candidate_nodes": 42,
+ "n_gold_nodes": 30
+ },
+ "prompts_included": false,
+ "responses_included": false,
+ "cases": [
+ { "id": "wfc-repl-001", "row_sha256": "c7dcec17cc063863afd63c7d4635f32cd5022153a55f0b67a61688347c2ee62f" },
+ { "id": "wfc-repl-002", "row_sha256": "a8eeb6927246eec6764fefc30ba241ce80410e5e1de9d5fbddd4dec6867d5ca6" },
+ { "id": "wfc-repl-003", "row_sha256": "9656329d516f7ec0381497249d5916163d457a02851b0d9c1b28c1779dce3b84" },
+ { "id": "wfc-repl-004", "row_sha256": "1015918210f7334ca98d467845051b3f115259eea9a1b38f00cd35bb72ff8400" },
+ { "id": "wfc-repl-005", "row_sha256": "895aeb20535933f74f1010044d85d93ca39681ad22a893ad5a2b9b9b8b7d006f" },
+ { "id": "wfc-repl-006", "row_sha256": "9578b5a1a3a048cdd60367bd486262f68e7ca24db77bfad4714fc544fef4e0a1" },
+ { "id": "wfc-repl-007", "row_sha256": "3d64bd9bfcb821643bd372353ed50f14240c6abad53eab0b929977d68fd8201c" },
+ { "id": "wfc-repl-008", "row_sha256": "498386784ee36f748b045c75f1eb2ec9f306fd95b2c613cc5b0451c894b5935d" },
+ { "id": "wfc-repl-009", "row_sha256": "7a806c870403a995008f302fd4350510f7b1ec820dc53b0989439af4cac86ba0" },
+ { "id": "wfc-repl-010", "row_sha256": "1022b559d6cee8855b963b942ead391593886672af0f32ed8e33a2d296199b58" },
+ { "id": "wfc-repl-011", "row_sha256": "0a761afa7151b1815ff6ec3466d980d1c0e5589aa1f7900e3100b72af1f7ad63" },
+ { "id": "wfc-repl-012", "row_sha256": "d4610bc410c511cd87b29286b9d0fc24252744fc3d9aed7305e3f94367826772" },
+ { "id": "wfc-repl-013", "row_sha256": "b32db4e7f77e5dc71dfb960418cccbb58df13fa6b2ab79b728f83631c46754f3" },
+ { "id": "wfc-repl-014", "row_sha256": "5948ae94148c5663569d3ebf261573f2456d8571c7089d50f307a846f9c6dae6" },
+ { "id": "wfc-repl-015", "row_sha256": "4f4c1b3a28e39bd5373524d991d4bc8394bf54d9629ada286282332a1e84f911" },
+ { "id": "wfc-repl-016", "row_sha256": "9a601c934c09d26b7b247dc2690d0014da9260e06846ddc245ffa4a8ce06f2b2" },
+ { "id": "wfc-repl-017", "row_sha256": "5e2e1a12d892b25142b36f293fad549c92394a2f0ffaf2abb3ad968df3b33dc1" },
+ { "id": "wfc-repl-018", "row_sha256": "4d809d537d8edb4696ba070dc9f4cc6ca48e559135c4cb487d81ae4e52d02ef1" },
+ { "id": "wfc-repl-019", "row_sha256": "4fb5f41d308d515b19d6c38d200d19a17b5bbf8216468bc625af0f9e18538f61" },
+ { "id": "wfc-repl-020", "row_sha256": "94e9917dfbdf3da4bffd2a1a43bb41df8590237ae4d1f682ee28505ba0fd5505" },
+ { "id": "wfc-repl-021", "row_sha256": "3f34fd661bdbfd83b6a18b2278103ba4e1f0b08ef0e49c63a6d3d1697de7fbb0" },
+ { "id": "wfc-repl-022", "row_sha256": "c7ea6069d6b85fb4f6221ca0143f0d0f602f1ab636fae1e55bc62ce9ce09d1ee" },
+ { "id": "wfc-repl-023", "row_sha256": "44f9918bc503db5f886ab8309174c30206523e341a41b00216126686247e0540" },
+ { "id": "wfc-repl-024", "row_sha256": "9f04708385dca303121374834c6ef56b30641d6f9463c8a72d1b5e0ed183e4b7" }
+ ]
+}
diff --git a/evals/studies/workflow-v1/items.jsonl b/evals/studies/workflow-v1/items.jsonl
new file mode 100644
index 0000000..e69de29
diff --git a/evals/studies/workflow-v1/manifest.json b/evals/studies/workflow-v1/manifest.json
new file mode 100644
index 0000000..f738349
--- /dev/null
+++ b/evals/studies/workflow-v1/manifest.json
@@ -0,0 +1,116 @@
+{
+ "schema_version": 1,
+ "study_id": "workflow-v1",
+ "study_version": "2026-07-16-freeze",
+ "created_at": "2026-07-16T00:00:00.000Z",
+ "bundle_kind": "workflow_value_gate_no_run",
+ "preregistration": {
+ "path": "evals/studies/workflow-v1/prereg.md",
+ "sha256": "0f8dfba5b4c816b27a39e38dbb0aef344184415f1a349fc55cb5d21dffda1834"
+ },
+ "input_registry_ref": {
+ "path": "evals/studies/registry.json",
+ "git_commit": "3d1f67de41495a2fa979b196a76fc5a3e66235e0",
+ "registry_version": "phase4-portfolio-v1",
+ "sha256": "7bf021d6dd4c34cd5bd91c74874114f98e1dc952ebb279021add62af8416c91e"
+ },
+ "current_registry_ref": {
+ "path": "evals/studies/registry.json",
+ "registry_version": "phase5-workflow-v1",
+ "sha256": "39eb7264b5e1f516aa5e67e4c7ab06d968c72453d5de8e5396aee69b665f039d",
+ "role": "post-gate output; not a preregistration input"
+ },
+ "files": {
+ "prereg": "prereg.md",
+ "manifest": "manifest.json",
+ "cases": "cases.json",
+ "aggregate": "aggregate.json",
+ "items": "items.jsonl"
+ },
+ "frozen_artifacts": {
+ "runner": {
+ "path": "evals/run-agentic.js",
+ "sha256": "4b8aeaa3c83ea000a15d66ae05c4cd4ff2d8fc1dabec1a13d9ab82230e410cda"
+ },
+ "pure_evaluator": {
+ "path": "evals/lib/agentic.js",
+ "sha256": "cef02f317cf9749824b550e6bb893a23b0f3d577e91832ee402bf781aafabf58"
+ },
+ "dataset": {
+ "path": "evals/datasets/workflow-cases-replication.jsonl",
+ "sha256": "3108849eae5636b7748cf800d49b25a9c5d9aaac78bd6986559ea5e2aaa7b0ef",
+ "split": "replication",
+ "n_cases": 24,
+ "n_candidate_nodes": 42,
+ "n_gold_nodes": 30
+ },
+ "cases": {
+ "path": "evals/studies/workflow-v1/cases.json",
+ "sha256": "54638d7dbf74b350a5d1041bb2d141ce0c2818231ef9b3c05d715482564c6c1a"
+ }
+ },
+ "models": [
+ "claude-haiku-4-5-20251001",
+ "claude-sonnet-4-6",
+ "claude-opus-4-6"
+ ],
+ "primary_arm": "workflow_typed",
+ "comparators": [
+ "dynamic_typed",
+ "workflow_none_typed"
+ ],
+ "diagnostic_arms": [
+ "dynamic_loose",
+ "workflow_loose",
+ "dynamic_typed_self_checked",
+ "workflow_typed_self_checked"
+ ],
+ "primary_metric": "case_success",
+ "secondary_metrics": [
+ "route_exactness",
+ "route_jaccard",
+ "branch_correctness",
+ "invalid_output_recovery",
+ "solver_failure_rate",
+ "calls",
+ "input_tokens",
+ "output_tokens",
+ "cached_tokens",
+ "latency_ms",
+ "estimated_cost_usd"
+ ],
+ "independence": {
+ "unit": "workflow_case",
+ "fresh_session_per_case_model_arm": true,
+ "response_reuse_forbidden": true,
+ "self_check_owns_independent_candidate": true,
+ "seed": "workflow-v1-2026-07-16"
+ },
+ "power": {
+ "design": "paired_binary_case_success_with_cluster_aware_cost_ratios",
+ "target_power": 0.9,
+ "alpha_one_sided": 0.05,
+ "multiplicity_adjusted": true,
+ "available_independent_cases_per_model": 24,
+ "optimistic_unpaired_one_sided_margin_pp_at_p_0_5": 16.79,
+ "quality_effect_gate_pp": 5,
+ "efficiency_noninferiority_margin_pp": -2,
+ "powered": false,
+ "decision_eligible": false,
+ "reason": "Twenty-four independent cases cannot resolve the preregistered +5pp quality or -2pp efficiency quality bounds before multiplicity adjustment."
+ },
+ "budget": {
+ "ceiling_usd": 2000,
+ "estimated_cost_usd": 0,
+ "calls_eligible": 0,
+ "reason": "Power gate failed before solver execution."
+ },
+ "raw_response_policy": {
+ "verbatim_responses_in_git": false,
+ "response_sha256_required_if_run": true,
+ "restore_tested_archive_uri_required_if_run": true
+ },
+ "run_status": "no_run",
+ "evidence_validity": "preregistered_blocked",
+ "product_disposition": "delete_workflow_machinery"
+}
diff --git a/evals/studies/workflow-v1/prereg.md b/evals/studies/workflow-v1/prereg.md
new file mode 100644
index 0000000..02d75d5
--- /dev/null
+++ b/evals/studies/workflow-v1/prereg.md
@@ -0,0 +1,87 @@
+# Workflow value gate: `workflow-v1`
+
+## Identity and frozen inputs
+
+- **study_id:** `workflow-v1`
+- **study_version:** `2026-07-16-freeze`
+- **created_at:** `2026-07-16T00:00:00.000Z`
+- **seed:** `workflow-v1-2026-07-16`
+- **input registry:** `evals/studies/registry.json` at Git commit `3d1f67de41495a2fa979b196a76fc5a3e66235e0` (`phase4-portfolio-v1`, SHA-256 `7bf021d6dd4c34cd5bd91c74874114f98e1dc952ebb279021add62af8416c91e`)
+- **runner:** `evals/run-agentic.js` SHA-256 `4b8aeaa3c83ea000a15d66ae05c4cd4ff2d8fc1dabec1a13d9ab82230e410cda`
+- **pure evaluator:** `evals/lib/agentic.js` SHA-256 `cef02f317cf9749824b550e6bb893a23b0f3d577e91832ee402bf781aafabf58`
+- **replication dataset:** `evals/datasets/workflow-cases-replication.jsonl` SHA-256 `3108849eae5636b7748cf800d49b25a9c5d9aaac78bd6986559ea5e2aaa7b0ef`
+- **available replication cases:** 24 cases, 42 candidate nodes, 30 gold nodes
+
+The input registry pin is immutable. A later registry update that records this outcome is a separate output reference and is not part of this preregistration freeze.
+
+## Decision gated
+
+Whether the agentic workflow runner, pure scheduler/scorer, workflow prompt registry, workflow-only datasets, tests, and any workflow form deserve to remain. The default is deletion unless untouched replication passes a predeclared quality or efficiency gate against both the frozen non-workflow comparator and no-skill.
+
+## Corrected contracts required before any run
+
+1. The executable is atomically named `evals/run-agentic.js`; the old `run-agentic-workflow.js` path is absent.
+2. Hydration, branch scheduling, route scoring, case scoring, arm summaries, and contrasts are pure functions in `evals/lib/agentic.js`.
+3. `case_success` requires the exact declared skill route, exact node route, correct branch choice, all gold node answers correct, and valid parsing.
+4. Every arm owns independent solver calls. No typed output may be reused by a self-checked arm.
+5. `dynamic_typed_self_checked` and `workflow_typed_self_checked` make a distinct semantic review call even when the first typed result parses.
+6. The no-skill arm executes the same deterministic scheduler and byte-identical typed prompt wrapper without reading a skill guide; only the guide-block contents differ.
+
+## Frozen arms
+
+### Primary candidate
+
+- `workflow_typed`: deterministic branch scheduler; each reached node runs the declared lean skill with typed output.
+
+### Frozen comparators
+
+- `dynamic_typed`: best machine-observable non-workflow arm eligible for comparison. It chooses a typed route from the case, candidate nodes, and skill catalog; unlike free-form `dynamic_loose`, its route and node outputs are directly scoreable.
+- `workflow_none_typed`: no-skill control using the same deterministic scheduler and typed node I/O. Its prompt is identical to `workflow_typed` except that the guide block is empty.
+
+### Diagnostic-only arms
+
+- `dynamic_loose`, `workflow_loose`, `dynamic_typed_self_checked`, and `workflow_typed_self_checked` are not eligible to replace either frozen comparator in this version. Diagnostics cannot drive retention.
+
+## Models, cases, independence, and ordering
+
+- Deployment strata: `claude-haiku-4-5-20251001`, `claude-sonnet-4-6`, and `claude-opus-4-6`.
+- Replication unit: one untouched workflow case.
+- Use exactly the 24 ordered IDs and row hashes in `cases.json`.
+- Each case × model × arm observation runs in a fresh independent session with no shared response, repair candidate, cache object, or conversational state.
+- Arm order is deterministically randomized from the frozen seed and case/model identity; the order and seed must be recorded per observation.
+- Source prompts and verbatim model responses are not committed. A decision-eligible run requires per-observation response SHA-256 plus a restore-tested access-controlled archive reference.
+
+## Outcomes
+
+### Primary quality outcome
+
+`case_success`: exact declared skill route, exact node route, no over/under-routing, correct branch decisions, every gold node answer correct, and valid parse.
+
+### Secondary outcomes
+
+Route exactness, route Jaccard, branch correctness, invalid-output recovery, solver failures, calls, input/output/cache tokens, latency, and estimated cost. Cost metrics use cluster-aware one-sided ratio intervals at the workflow-case cluster.
+
+## Multiplicity and terminal retention gates
+
+Multiplicity covers both primary comparisons, three model strata, and every candidate workflow form. Missing or underpowered strata fail closed.
+
+A workflow form is retained only if untouched replication passes one gate against **both** `dynamic_typed` and `workflow_none_typed`:
+
+- **Quality:** point improvement at least +5 percentage points and multiplicity-adjusted one-sided quality lower bound above 0 against both comparators; one-sided 95% upper ratio bounds at most 1.25 for total tokens and estimated cost; every nonwinning deployment model has adjusted quality lower bound above -3pp.
+- **Efficiency:** quality lower bound above -2pp; preregistered one-sided 95% upper bound at most 0.80 for the chosen total-token or latency ratio; every unchosen calls/token/latency/cost ratio upper bound at most 1.05; one-sided 95% upper bound for workflow minus baseline failure rate below +2pp against both comparators; every deployment model has adjusted quality lower bound above -3pp.
+
+No post-hoc arm substitution, pooling, threshold change, or exception is allowed.
+
+## Pre-run power and feasibility gate
+
+The frozen replication set contains only 24 independent case clusters. Even under the optimistic unpaired Bernoulli approximation at 50% success, a one-sided 95% standard-error margin is about 16.8 percentage points (`1.645 × sqrt(0.25 / 24)`), before multiplicity adjustment. That cannot establish either a >0 lower bound for a +5pp quality effect or a >-2pp noninferiority bound for the efficiency gate. Pairing cannot guarantee rescue because the discordance rate is unknown and was not estimated from an independent corrected-engine pilot.
+
+The study therefore fails the predeclared 90% power requirement before solver execution. The permitted action is a **zero-call no-run**, not an underpowered exploratory replication. The terminal product disposition is `delete_workflow_machinery`; the null/no-run record must remain in canonical evidence.
+
+## Artifacts
+
+- `evals/studies/workflow-v1/prereg.md`
+- `evals/studies/workflow-v1/manifest.json`
+- `evals/studies/workflow-v1/cases.json`
+- `evals/studies/workflow-v1/aggregate.json`
+- `evals/studies/workflow-v1/items.jsonl` (empty because no calls are eligible)
diff --git a/evals/tests/agentic-workflow.test.js b/evals/tests/agentic-workflow.test.js
new file mode 100644
index 0000000..a3f5357
--- /dev/null
+++ b/evals/tests/agentic-workflow.test.js
@@ -0,0 +1,385 @@
+'use strict';
+
+const test = require('node:test');
+const assert = require('node:assert');
+const {
+ AGENTIC_ARMS,
+ extractRouteFromText,
+ evalBranchRules,
+ scoreRoute,
+ scoreCaseResult,
+ summarizeArms,
+} = require('../lib/agentic');
+const { runDynamicArm, runWorkflowArm } = require('../run-agentic');
+
+test('evalBranchRules: schedules then branch when answer equals rule value', () => {
+ const rules = [{ after: 'a', if: { decision_key: 'flag', equals: true }, then: ['b'], else: ['c'] }];
+ assert.deepStrictEqual(evalBranchRules(rules, 'a', { flag: true }, new Set(['a']), new Set()), ['b']);
+});
+
+test('evalBranchRules: schedules else branch when answer differs from rule value', () => {
+ const rules = [{ after: 'a', if: { decision_key: 'flag', equals: true }, then: ['b'], else: ['c'] }];
+ assert.deepStrictEqual(evalBranchRules(rules, 'a', { flag: false }, new Set(['a']), new Set()), ['c']);
+});
+
+test('evalBranchRules: does not enqueue completed or already queued duplicates', () => {
+ const rules = [{ after: 'a', if: { decision_key: 'flag', equals: true }, then: ['b', 'c', 'd'], else: [] }];
+ assert.deepStrictEqual(evalBranchRules(rules, 'a', { flag: true }, new Set(['a', 'b']), new Set(['c'])), ['d']);
+});
+
+test('scoreRoute: identical routes are exact with Jaccard 1', () => {
+ const scored = scoreRoute(['thinking-a', 'thinking-b'], ['thinking-a', 'thinking-b']);
+ assert.strictEqual(scored.route_exact, true);
+ assert.strictEqual(scored.route_jaccard, 1);
+});
+
+test('scoreRoute: partial overlap has expected Jaccard and is not exact', () => {
+ const scored = scoreRoute(['thinking-a', 'thinking-c'], ['thinking-a', 'thinking-b']);
+ assert.strictEqual(scored.route_exact, false);
+ assert.strictEqual(scored.route_jaccard, 1 / 3);
+});
+
+function fixtureCase() {
+ return {
+ id: 'fixture',
+ nodes: [
+ { node_id: 'a', skill: 'thinking-a', label: true },
+ { node_id: 'b', skill: 'thinking-b', label: false },
+ ],
+ gold_node_ids: ['a', 'b'],
+ };
+}
+
+test('scoreCaseResult: wrong declared skill route fails even when node answers are correct', () => {
+ const scored = scoreCaseResult(fixtureCase(), {
+ parse_ok: true,
+ selected_route: ['thinking-a'],
+ selected_node_ids: ['a', 'b'],
+ node_answers: [{ node_id: 'a', answer: true }, { node_id: 'b', answer: false }],
+ });
+ assert.strictEqual(scored.node_acc, 1);
+ assert.strictEqual(scored.route_exact, false);
+ assert.strictEqual(scored.node_route_exact, true);
+ assert.strictEqual(scored.case_success, false);
+});
+
+test('scoreCaseResult: right skill route but wrong node route is not case_success', () => {
+ const scored = scoreCaseResult(fixtureCase(), {
+ parse_ok: true,
+ selected_route: ['thinking-a', 'thinking-b'],
+ selected_node_ids: ['a'],
+ node_answers: [{ node_id: 'a', answer: true }, { node_id: 'b', answer: false }],
+ });
+ assert.strictEqual(scored.route_exact, true);
+ assert.strictEqual(scored.node_route_exact, false);
+ assert.strictEqual(scored.under_routing_count, 1);
+ assert.strictEqual(scored.case_success, false);
+});
+
+test('scoreCaseResult: right route with one wrong node answer is not case_success', () => {
+ const scored = scoreCaseResult(fixtureCase(), {
+ parse_ok: true,
+ selected_route: ['thinking-a', 'thinking-b'],
+ selected_node_ids: ['a', 'b'],
+ node_answers: [{ node_id: 'a', answer: true }, { node_id: 'b', answer: true }],
+ });
+ assert.strictEqual(scored.route_exact, true);
+ assert.strictEqual(scored.node_route_exact, true);
+ assert.strictEqual(scored.node_acc, 0.5);
+ assert.strictEqual(scored.case_success, false);
+});
+
+test('scoreCaseResult: right route with all gold node labels correct is case_success', () => {
+ const scored = scoreCaseResult(fixtureCase(), {
+ parse_ok: true,
+ selected_route: ['thinking-a', 'thinking-b'],
+ selected_node_ids: ['a', 'b'],
+ node_answers: [{ node_id: 'a', answer: true }, { node_id: 'b', answer: false }],
+ });
+ assert.strictEqual(scored.route_exact, true);
+ assert.strictEqual(scored.node_route_exact, true);
+ assert.strictEqual(scored.node_acc, 1);
+ assert.strictEqual(scored.over_routing_count, 0);
+ assert.strictEqual(scored.under_routing_count, 0);
+ assert.strictEqual(scored.case_success, true);
+});
+
+test('scoreCaseResult: over-routing with extra node is not case_success', () => {
+ const c = fixtureCase();
+ c.nodes.push({ node_id: 'c', skill: 'thinking-c', label: true });
+ const scored = scoreCaseResult(c, {
+ parse_ok: true,
+ selected_route: ['thinking-a', 'thinking-b', 'thinking-c'],
+ selected_node_ids: ['a', 'b', 'c'],
+ node_answers: [{ node_id: 'a', answer: true }, { node_id: 'b', answer: false }, { node_id: 'c', answer: true }],
+ });
+ assert.strictEqual(scored.node_acc, 1);
+ assert.strictEqual(scored.over_routing_count, 1);
+ assert.deepStrictEqual(scored.over_routing_node_ids, ['c']);
+ assert.strictEqual(scored.case_success, false);
+});
+
+test('scoreCaseResult: under-routing with missing gold node is not case_success', () => {
+ const scored = scoreCaseResult(fixtureCase(), {
+ parse_ok: true,
+ selected_route: ['thinking-a'],
+ selected_node_ids: ['a'],
+ node_answers: [{ node_id: 'a', answer: true }],
+ });
+ assert.strictEqual(scored.under_routing_count, 1);
+ assert.deepStrictEqual(scored.under_routing_node_ids, ['b']);
+ assert.strictEqual(scored.case_success, false);
+});
+
+function branchingFixture() {
+ return {
+ id: 'branch-fixture',
+ nodes: [
+ { node_id: 'gate', skill: 'thinking-a', label: true },
+ { node_id: 'left', skill: 'thinking-b', label: true },
+ { node_id: 'right', skill: 'thinking-c', label: false },
+ ],
+ gold_node_ids: ['gate', 'left'],
+ workflow_branch_rules: [
+ { after: 'gate', if: { decision_key: 'gate', equals: true }, then: ['left'], else: ['right'] },
+ ],
+ };
+}
+
+test('scoreCaseResult: correct route but wrong branch decision is not case_success', () => {
+ const scored = scoreCaseResult(branchingFixture(), {
+ parse_ok: true,
+ selected_route: ['thinking-a', 'thinking-c'],
+ selected_node_ids: ['gate', 'right'],
+ node_answers: [{ node_id: 'gate', answer: false }, { node_id: 'right', answer: false }],
+ });
+ assert.strictEqual(scored.over_routing_count, 1);
+ assert.strictEqual(scored.under_routing_count, 1);
+ assert.strictEqual(scored.branch_decision_acc, 0);
+ assert.strictEqual(scored.case_success, false);
+});
+
+test('scoreCaseResult: correct route and correct branch decision is case_success', () => {
+ const scored = scoreCaseResult(branchingFixture(), {
+ parse_ok: true,
+ selected_route: ['thinking-a', 'thinking-b'],
+ selected_node_ids: ['gate', 'left'],
+ node_answers: [{ node_id: 'gate', answer: true }, { node_id: 'left', answer: true }],
+ });
+ assert.strictEqual(scored.branch_decision_acc, 1);
+ assert.strictEqual(scored.case_success, true);
+});
+
+function isolatedBranchFixture() {
+ return {
+ id: 'isolated-branch',
+ nodes: [
+ { node_id: 'gate', skill: 'thinking-a', label: true },
+ { node_id: 'left', skill: 'thinking-b', label: true },
+ { node_id: 'right', skill: 'thinking-c', label: false },
+ ],
+ gold_node_ids: ['left', 'right'],
+ workflow_branch_rules: [
+ { after: 'gate', if: { decision_key: 'gate', equals: true }, then: ['left'], else: ['right'] },
+ ],
+ };
+}
+
+test('scoreCaseResult: exact node route and all gold answers correct but wrong branch is not case_success', () => {
+ const scored = scoreCaseResult(isolatedBranchFixture(), {
+ parse_ok: true,
+ selected_route: ['thinking-b', 'thinking-c'],
+ selected_node_ids: ['left', 'right'],
+ node_answers: [
+ { node_id: 'gate', answer: false },
+ { node_id: 'left', answer: true },
+ { node_id: 'right', answer: false },
+ ],
+ });
+ assert.strictEqual(scored.node_route_exact, true);
+ assert.strictEqual(scored.over_routing_count, 0);
+ assert.strictEqual(scored.under_routing_count, 0);
+ assert.strictEqual(scored.node_acc, 1);
+ assert.strictEqual(scored.branch_decision_acc, 0);
+ assert.strictEqual(scored.case_success, false);
+});
+
+function emptyBranchFixture() {
+ return {
+ id: 'empty-branch-fixture',
+ nodes: [
+ { node_id: 'gate', skill: 'thinking-a', label: false },
+ { node_id: 'extra', skill: 'thinking-b', label: true },
+ ],
+ gold_node_ids: ['gate', 'extra'],
+ workflow_branch_rules: [
+ { after: 'gate', if: { decision_key: 'gate', equals: true }, then: [], else: ['extra'] },
+ ],
+ };
+}
+
+test('scoreCaseResult: empty then with gold else branch, correct else-route is case_success', () => {
+ const scored = scoreCaseResult(emptyBranchFixture(), {
+ parse_ok: true,
+ selected_route: ['thinking-a', 'thinking-b'],
+ selected_node_ids: ['gate', 'extra'],
+ node_answers: [
+ { node_id: 'gate', answer: false },
+ { node_id: 'extra', answer: true },
+ ],
+ });
+ assert.strictEqual(scored.node_route_exact, true);
+ assert.strictEqual(scored.over_routing_count, 0);
+ assert.strictEqual(scored.under_routing_count, 0);
+ assert.strictEqual(scored.node_acc, 1);
+ assert.strictEqual(scored.branch_decision_acc, 1);
+ assert.strictEqual(scored.case_success, true);
+});
+
+test('scoreCaseResult: empty then with gold else branch, wrong then-route is not case_success', () => {
+ const scored = scoreCaseResult(emptyBranchFixture(), {
+ parse_ok: true,
+ selected_route: ['thinking-a'],
+ selected_node_ids: ['gate'],
+ node_answers: [
+ { node_id: 'gate', answer: true },
+ ],
+ });
+ assert.strictEqual(scored.branch_decision_acc, 0);
+ assert.strictEqual(scored.under_routing_count, 1);
+ assert.strictEqual(scored.case_success, false);
+});
+
+test('extractRouteFromText: recognizes slugs, preserves mention order, and rejects substrings', () => {
+ const known = ['thinking-scientific-method', 'thinking-pre-mortem'];
+ assert.deepStrictEqual(extractRouteFromText('Use thinking-scientific-method first.', known), ['thinking-scientific-method']);
+ assert.deepStrictEqual(extractRouteFromText('Then use scientific-method.', known), ['thinking-scientific-method']);
+ assert.deepStrictEqual(extractRouteFromText('Start with pre-mortem, then scientific-method.', known), ['thinking-pre-mortem', 'thinking-scientific-method']);
+ assert.deepStrictEqual(extractRouteFromText('This is unscientific-methodology, not a route.', known), []);
+});
+
+test('summarizeArms: two-case fixture produces expected aggregate and stratum metrics', () => {
+ const cases = [
+ {
+ id: 'one', stability: 'stable', branching: 'linear', novelty: 'familiar',
+ by_arm: { arm_a: { case_success: true, route_exact: true, route_jaccard: 1, node_acc: 1, parse_ok: true } },
+ },
+ {
+ id: 'two', stability: 'stable', branching: 'linear', novelty: 'familiar',
+ by_arm: { arm_a: { case_success: false, route_exact: false, route_jaccard: 0.5, node_acc: 0, parse_ok: false } },
+ },
+ ];
+ const out = summarizeArms(cases, ['arm_a']);
+ assert.strictEqual(out.arm_a.n, 2);
+ assert.strictEqual(out.arm_a.case_success_rate, 0.5);
+ assert.strictEqual(out.arm_a.route_exact_rate, 0.5);
+ assert.strictEqual(out.arm_a.route_jaccard_avg, 0.75);
+ assert.strictEqual(out.arm_a.node_acc, 0.5);
+ assert.strictEqual(out.arm_a.parse_ok_rate, 0.5);
+ assert.deepStrictEqual(Object.keys(out.arm_a.by_stratum), ['stable|linear|familiar']);
+ assert.strictEqual(out.arm_a.by_stratum['stable|linear|familiar'].n, 2);
+});
+
+test('agentic arm catalog uses honest self-check names', () => {
+ assert.deepStrictEqual(AGENTIC_ARMS, [
+ 'dynamic_loose',
+ 'dynamic_typed',
+ 'dynamic_typed_self_checked',
+ 'workflow_loose',
+ 'workflow_typed',
+ 'workflow_none_typed',
+ 'workflow_typed_self_checked',
+ ]);
+ assert.ok(!AGENTIC_ARMS.some(arm => arm.includes('verified') || arm.includes('validated')));
+});
+
+function oneNodeCase() {
+ return {
+ id: 'independent-arm-case',
+ case_brief: 'Decide the node.',
+ nodes: [{
+ node_id: 'node-1',
+ skill: 'thinking-a',
+ decision_key: 'flag',
+ decision_instruction: 'Answer Yes or No.',
+ prompt: 'Is the flag set?',
+ label: true,
+ }],
+ initial_node_ids: ['node-1'],
+ workflow_branch_rules: [],
+ gold_node_ids: ['node-1'],
+ };
+}
+
+test('dynamic typed and self-check arms make independent candidate calls', async () => {
+ const prompts = [];
+ const response = JSON.stringify({
+ selected_route: ['thinking-a'],
+ node_answers: [{ node_id: 'node-1', answer: true, rationale: 'set' }],
+ final: 'done',
+ });
+ const fakeCall = async (_caseId, options) => {
+ prompts.push(options.prompt);
+ return { ok: true, text: response, attempts: 1 };
+ };
+ const workflowCase = oneNodeCase();
+
+ await runDynamicArm(workflowCase, 'dynamic_typed', 'thinking-a: test', ['thinking-a'], fakeCall);
+ await runDynamicArm(workflowCase, 'dynamic_typed_self_checked', 'thinking-a: test', ['thinking-a'], fakeCall);
+
+ assert.strictEqual(prompts.length, 3);
+ assert.strictEqual(prompts[0], prompts[1]);
+ assert.notStrictEqual(prompts[1], prompts[2]);
+});
+
+test('workflow typed and self-check arms make independent node calls', async () => {
+ const prompts = [];
+ const fakeCall = async (_caseId, options) => {
+ prompts.push(options.prompt);
+ return { ok: true, text: JSON.stringify({ node_id: 'node-1', answer: true, rationale: 'set' }), attempts: 1 };
+ };
+ const workflowCase = oneNodeCase();
+ const skillCache = new Map([['thinking-a', 'test skill']]);
+
+ await runWorkflowArm(workflowCase, 'workflow_typed', skillCache, fakeCall);
+ await runWorkflowArm(workflowCase, 'workflow_typed_self_checked', skillCache, fakeCall);
+
+ assert.strictEqual(prompts.length, 3);
+ assert.strictEqual(prompts[0], prompts[1]);
+ assert.notStrictEqual(prompts[1], prompts[2]);
+});
+
+test('workflow no-skill arm changes only the guide block', async () => {
+ const prompts = [];
+ const fakeCall = async (_caseId, options) => {
+ prompts.push(options.prompt);
+ return { ok: true, text: JSON.stringify({ node_id: 'node-1', answer: true, rationale: 'direct' }), attempts: 1 };
+ };
+ const workflowCase = oneNodeCase();
+
+ await runWorkflowArm(workflowCase, 'workflow_typed', new Map([['thinking-a', 'test skill']]), fakeCall);
+ const result = await runWorkflowArm(workflowCase, 'workflow_none_typed', new Map(), fakeCall);
+
+ assert.strictEqual(result.parse_ok, true);
+ assert.strictEqual(prompts.length, 2);
+ assert.strictEqual(prompts[1], prompts[0].replace('test skill', ''));
+ assert.doesNotMatch(prompts[1], /without any thinking-skill guide/i);
+});
+
+test('workflow self-check reviews its own invalid candidate', async () => {
+ const responses = [
+ { ok: true, text: 'not json', attempts: 1 },
+ { ok: true, text: JSON.stringify({ node_id: 'node-1', answer: true, rationale: 'repaired' }), attempts: 1 },
+ ];
+ const fakeCall = async () => responses.shift();
+ const result = await runWorkflowArm(
+ oneNodeCase(),
+ 'workflow_typed_self_checked',
+ new Map([['thinking-a', 'test skill']]),
+ fakeCall
+ );
+
+ assert.strictEqual(responses.length, 0);
+ assert.strictEqual(result.parse_ok, true);
+ assert.deepStrictEqual(result.node_answers, [{ node_id: 'node-1', answer: true, rationale: 'repaired' }]);
+});
diff --git a/evals/tests/evidence-registry-generation.test.js b/evals/tests/evidence-registry-generation.test.js
index c6722e8..4961107 100644
--- a/evals/tests/evidence-registry-generation.test.js
+++ b/evals/tests/evidence-registry-generation.test.js
@@ -10,6 +10,7 @@ const { execFileSync } = require('child_process');
const REPO_ROOT = path.resolve(__dirname, '..', '..');
const EVIDENCE_PATH = path.join(REPO_ROOT, 'analysis', 'evidence.json');
const REGISTRY_PATH = path.join(REPO_ROOT, 'evals', 'studies', 'registry.json');
+const WORKFLOW_AGGREGATE_PATH = path.join(REPO_ROOT, 'evals', 'studies', 'workflow-v1', 'aggregate.json');
const AGGREGATE_PATH = path.join(REPO_ROOT, 'evals', 'studies', 'portfolio-v1', 'aggregate.json');
const GENERATOR_PATH = path.join(REPO_ROOT, 'evals', 'generate-evidence-registry.js');
@@ -77,5 +78,34 @@ test('preregistered input registry remains distinct from post-gate output regist
{ cwd: REPO_ROOT }
);
assert.equal(sha256(frozenRegistry), portfolio.input_registry_ref.sha256);
- assert.equal(sha256(fs.readFileSync(REGISTRY_PATH)), portfolio.current_registry_ref.sha256);
+ const postGateRegistry = execFileSync(
+ 'git',
+ ['show', `${portfolio.current_registry_ref.git_commit}:${portfolio.current_registry_ref.path}`],
+ { cwd: REPO_ROOT }
+ );
+ assert.equal(sha256(postGateRegistry), portfolio.current_registry_ref.sha256);
+});
+
+test('workflow power failure is preserved as a zero-call deletion disposition', () => {
+ const aggregate = readJson(WORKFLOW_AGGREGATE_PATH);
+ const evidence = readJson(EVIDENCE_PATH);
+ const workflow = evidence.studies.find(study => study.study_id === 'workflow-v1');
+
+ assert.ok(workflow);
+ assert.equal(aggregate.run_status, 'no_run');
+ assert.equal(aggregate.usage.calls, 0);
+ assert.equal(aggregate.health.decision_eligible, false);
+ assert.equal(workflow.model_calls, 0);
+ assert.equal(workflow.decision_eligible, false);
+ assert.equal(workflow.product_disposition, 'delete_workflow_machinery');
+ assert.equal(evidence.workflow_form.product_disposition, 'delete_workflow_machinery');
+ assert.deepEqual(workflow.comparators, ['dynamic_typed', 'workflow_none_typed']);
+
+ const frozenRegistry = execFileSync(
+ 'git',
+ ['show', `${workflow.input_registry_ref.git_commit}:${workflow.input_registry_ref.path}`],
+ { cwd: REPO_ROOT }
+ );
+ assert.equal(sha256(frozenRegistry), workflow.input_registry_ref.sha256);
+ assert.equal(sha256(fs.readFileSync(REGISTRY_PATH)), workflow.current_registry_ref.sha256);
});