@hxp-tools/godplans 0.0.0-stage → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (146) hide show
  1. package/CHANGELOG.md +1202 -0
  2. package/LICENSE +21 -0
  3. package/PROMPT.md +4006 -0
  4. package/README.md +245 -2
  5. package/bin/godplans.js +93 -0
  6. package/docs/ARCHITECTURE.md +136 -0
  7. package/docs/RELEASING.md +107 -0
  8. package/docs/assets/badge-approved.svg +12 -0
  9. package/docs/assets/badge-done.svg +11 -0
  10. package/docs/assets/badge-graded.svg +12 -0
  11. package/docs/assets/badge-validated.svg +10 -0
  12. package/docs/assets/hero.svg +37 -0
  13. package/docs/assets/quest-map.svg +53 -0
  14. package/evals/README.md +295 -0
  15. package/evals/cases/brownfield-cli/EXPECTATIONS +15 -0
  16. package/evals/cases/brownfield-cli/INPUT/package.json +9 -0
  17. package/evals/cases/brownfield-cli/INPUT/src/cli.js +4 -0
  18. package/evals/cases/brownfield-cli/INPUT/src/format.js +3 -0
  19. package/evals/cases/brownfield-cli/INPUT/test/cli.test.js +7 -0
  20. package/evals/cases/brownfield-cli/REQUEST.baseline.md +10 -0
  21. package/evals/cases/brownfield-cli/REQUEST.md +10 -0
  22. package/evals/cases/compliance-refusal/EXPECTATIONS +4 -0
  23. package/evals/cases/compliance-refusal/REQUEST.baseline.md +9 -0
  24. package/evals/cases/compliance-refusal/REQUEST.md +8 -0
  25. package/evals/cases/greenfield-saas/EXPECTATIONS +21 -0
  26. package/evals/cases/greenfield-saas/REQUEST.baseline.md +11 -0
  27. package/evals/cases/greenfield-saas/REQUEST.md +11 -0
  28. package/evals/cases/nested-pillars/EXPECTATIONS +12 -0
  29. package/evals/cases/nested-pillars/REQUEST.baseline.md +10 -0
  30. package/evals/cases/nested-pillars/REQUEST.md +11 -0
  31. package/evals/cases/observability-evidence/EXPECTATIONS +10 -0
  32. package/evals/cases/observability-evidence/REQUEST.baseline.md +10 -0
  33. package/evals/cases/observability-evidence/REQUEST.md +11 -0
  34. package/evals/cases/product-business/EXPECTATIONS +18 -0
  35. package/evals/cases/product-business/REQUEST.baseline.md +13 -0
  36. package/evals/cases/product-business/REQUEST.md +14 -0
  37. package/evals/cases/product-form-routing/EXPECTATIONS +13 -0
  38. package/evals/cases/product-form-routing/REQUEST.baseline.md +11 -0
  39. package/evals/cases/product-form-routing/REQUEST.md +11 -0
  40. package/evals/cases/prose-integrity/EXPECTATIONS +19 -0
  41. package/evals/cases/prose-integrity/REQUEST.baseline.md +19 -0
  42. package/evals/cases/prose-integrity/REQUEST.md +20 -0
  43. package/evals/cases/replan-preserves-history/EXPECTATIONS +9 -0
  44. package/evals/cases/replan-preserves-history/INPUT/.godplans/PLAN.mdx +115 -0
  45. package/evals/cases/replan-preserves-history/INPUT/package.json +5 -0
  46. package/evals/cases/replan-preserves-history/REQUEST.baseline.md +10 -0
  47. package/evals/cases/replan-preserves-history/REQUEST.md +10 -0
  48. package/evals/cases/stale-prepublication/EXPECTATIONS +10 -0
  49. package/evals/cases/stale-prepublication/REQUEST.baseline.md +12 -0
  50. package/evals/cases/stale-prepublication/REQUEST.md +13 -0
  51. package/evals/cases/stale-source-evidence/EXPECTATIONS +10 -0
  52. package/evals/cases/stale-source-evidence/INPUT/package.json +8 -0
  53. package/evals/cases/stale-source-evidence/REQUEST.baseline.md +11 -0
  54. package/evals/cases/stale-source-evidence/REQUEST.md +12 -0
  55. package/evals/cases/weekend-library/EXPECTATIONS +19 -0
  56. package/evals/cases/weekend-library/REQUEST.baseline.md +10 -0
  57. package/evals/cases/weekend-library/REQUEST.md +11 -0
  58. package/evals/cases-roster.txt +19 -0
  59. package/evals/external/GRADE.schema.json +39 -0
  60. package/evals/external/README.md +42 -0
  61. package/evals/external/RUBRIC.md +32 -0
  62. package/evals/metrics/context-cost.json +154 -0
  63. package/evals/outcomes/README.md +65 -0
  64. package/evals/outcomes/cases/tenant-notes-api/REQUEST.baseline.md +14 -0
  65. package/evals/outcomes/cases/tenant-notes-api/REQUEST.md +13 -0
  66. package/evals/outcomes/cases/tenant-notes-api/VERIFY.sh +13 -0
  67. package/evals/outcomes/results/2026-07-23-tenant-notes-api-codex/README.md +93 -0
  68. package/evals/outcomes/results/2026-07-23-tenant-notes-api-codex/treatment/plan/PLAN.json +547 -0
  69. package/evals/runners/claude-baseline.sh +4 -0
  70. package/evals/runners/claude-grade.sh +3 -0
  71. package/evals/runners/claude.sh +4 -0
  72. package/evals/runners/codex-baseline.sh +181 -0
  73. package/evals/runners/codex-builder.sh +96 -0
  74. package/evals/runners/codex-godaudits.sh +84 -0
  75. package/evals/runners/codex.sh +147 -0
  76. package/evals/runners/gemini-baseline.sh +4 -0
  77. package/evals/runners/gemini-grade.sh +3 -0
  78. package/evals/runners/gemini.sh +4 -0
  79. package/evals/runners/vendor-cli.sh +257 -0
  80. package/evals/runners/vendor-grade.sh +82 -0
  81. package/install.sh +323 -0
  82. package/package.json +91 -4
  83. package/requirements/skills-ref.txt +2 -0
  84. package/scripts/build-catalog.js +114 -0
  85. package/scripts/build-prompt.sh +257 -0
  86. package/scripts/context-metrics.js +118 -0
  87. package/scripts/eval-external.js +226 -0
  88. package/scripts/eval-matrix.sh +172 -0
  89. package/scripts/eval-outcome.js +143 -0
  90. package/scripts/eval.sh +321 -0
  91. package/scripts/lint-parity.js +331 -0
  92. package/scripts/lint.sh +743 -0
  93. package/scripts/outcome-summary.js +126 -0
  94. package/scripts/release-check.sh +108 -0
  95. package/scripts/release-prepare.js +41 -0
  96. package/scripts/summarize-eval.js +91 -0
  97. package/scripts/summarize-matrix.js +101 -0
  98. package/scripts/version-sync.js +65 -0
  99. package/skills/godplans/SKILL.md +192 -0
  100. package/skills/godplans/references/agent-memory.md +168 -0
  101. package/skills/godplans/references/architecture.md +189 -0
  102. package/skills/godplans/references/build.md +130 -0
  103. package/skills/godplans/references/business.md +252 -0
  104. package/skills/godplans/references/code-quality.md +165 -0
  105. package/skills/godplans/references/compliance.md +59 -0
  106. package/skills/godplans/references/database.md +157 -0
  107. package/skills/godplans/references/deploy.md +146 -0
  108. package/skills/godplans/references/discovery.md +297 -0
  109. package/skills/godplans/references/doc-set.md +243 -0
  110. package/skills/godplans/references/exemplar.md +228 -0
  111. package/skills/godplans/references/launch.md +162 -0
  112. package/skills/godplans/references/llm.md +132 -0
  113. package/skills/godplans/references/observe.md +178 -0
  114. package/skills/godplans/references/plan-format.md +340 -0
  115. package/skills/godplans/references/product.md +130 -0
  116. package/skills/godplans/references/repo.md +184 -0
  117. package/skills/godplans/references/roadmap.md +158 -0
  118. package/skills/godplans/references/security.md +156 -0
  119. package/skills/godplans/references/seo.md +133 -0
  120. package/skills/godplans/references/stack.md +133 -0
  121. package/skills/godplans/references/style-genome.md +198 -0
  122. package/skills/godplans/references/ui.md +153 -0
  123. package/skills/godplans/references/ux.md +150 -0
  124. package/skills/godplans/schemas/PLAN.schema.json +275 -0
  125. package/skills/godplans/schemas/PLAN.v1.schema.json +258 -0
  126. package/skills/godplans/scripts/plan-halflife.sh +76 -0
  127. package/skills/godplans/scripts/style-stats.py +630 -0
  128. package/skills/godplans/scripts/validate-plan.sh +1709 -0
  129. package/skills/godplans/templates/PLAN.template.mdx +269 -0
  130. package/tests/agent-memory-guidance.sh +32 -0
  131. package/tests/build-catalog.sh +81 -0
  132. package/tests/codex-runner.sh +139 -0
  133. package/tests/eval-harness.sh +377 -0
  134. package/tests/evidence-harnesses.sh +243 -0
  135. package/tests/fixtures/plan-json-v1-1.13.0.json +472 -0
  136. package/tests/install-regression.sh +246 -0
  137. package/tests/lib/plan-schema-check.js +163 -0
  138. package/tests/lint-selftest.sh +582 -0
  139. package/tests/package-contents.sh +143 -0
  140. package/tests/portable-prompt.test.sh +261 -0
  141. package/tests/release-tooling.sh +204 -0
  142. package/tests/run.sh +14 -0
  143. package/tests/script-usage.sh +37 -0
  144. package/tests/style-stats.sh +170 -0
  145. package/tests/validate-plan.sh +1970 -0
  146. package/tests/vendor-runner.sh +291 -0
@@ -0,0 +1,226 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ const crypto = require('node:crypto');
5
+ const fs = require('node:fs');
6
+ const path = require('node:path');
7
+ const { spawnSync } = require('node:child_process');
8
+
9
+ const root = path.resolve(__dirname, '..');
10
+ const args = process.argv.slice(2);
11
+ let matrix;
12
+ let output;
13
+ let sourceProfile = 'codex';
14
+ let sample = 5;
15
+ const judges = [];
16
+
17
+ function take(flag, index) {
18
+ if (index + 1 >= args.length) throw new Error(`${flag} needs a value`);
19
+ return args[index + 1];
20
+ }
21
+
22
+ for (let index = 0; index < args.length; index++) {
23
+ switch (args[index]) {
24
+ case '--matrix': matrix = path.resolve(take('--matrix', index++)); break;
25
+ case '--output': output = path.resolve(take('--output', index++)); break;
26
+ case '--source-profile': sourceProfile = take('--source-profile', index++); break;
27
+ case '--sample': sample = Number(take('--sample', index++)); break;
28
+ case '--judge': {
29
+ const value = take('--judge', index++);
30
+ const separator = value.indexOf('=');
31
+ if (separator < 1) throw new Error('--judge uses LABEL=RUNNER, where RUNNER is a relative or absolute path');
32
+ // The label names the judge's grade directory, so it must be one safe
33
+ // path segment. A repeated label, or one that differs only in case (the
34
+ // same directory on a case-insensitive file system), would grade one
35
+ // judge against itself.
36
+ const label = value.slice(0, separator);
37
+ if (!/^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(label)) throw new Error(`invalid judge label: ${label}`);
38
+ if (judges.some((judge) => judge.label.toLowerCase() === label.toLowerCase())) throw new Error(`duplicate judge label: ${label}`);
39
+ judges.push({ label, runner: path.resolve(value.slice(separator + 1)) });
40
+ break;
41
+ }
42
+ case '-h':
43
+ case '--help':
44
+ process.stdout.write('Usage: node scripts/eval-external.js --matrix DIR --output DIR --judge LABEL=RUNNER --judge LABEL=RUNNER [--source-profile NAME] [--sample 5]\n');
45
+ process.exit(0);
46
+ default: throw new Error(`unknown option: ${args[index]}`);
47
+ }
48
+ }
49
+
50
+ if (!matrix || !output) throw new Error('--matrix and --output are required');
51
+ if (!Number.isInteger(sample) || sample < 5) throw new Error('--sample must be at least 5');
52
+ if (judges.length < 2) throw new Error('at least two external judges are required for an inter-rater gap');
53
+ for (const judge of judges) {
54
+ fs.accessSync(judge.runner, fs.constants.X_OK);
55
+ }
56
+
57
+ const source = path.join(matrix, sourceProfile);
58
+ const caseRoot = path.join(root, 'evals', 'cases');
59
+ const candidates = fs.readdirSync(source, { withFileTypes: true })
60
+ .filter((entry) => entry.isDirectory())
61
+ .map((entry) => entry.name)
62
+ .filter((name) => fs.existsSync(path.join(source, name, 'PLAN.mdx'))
63
+ && fs.existsSync(path.join(source, name, 'baseline', 'PLAN.mdx')))
64
+ .sort()
65
+ .slice(0, sample);
66
+ if (candidates.length < sample) {
67
+ throw new Error(`source profile has only ${candidates.length} complete plan pairs, need ${sample}`);
68
+ }
69
+
70
+ const rubric = fs.readFileSync(path.join(root, 'evals', 'external', 'RUBRIC.md'), 'utf8');
71
+ // Every judge reads the grade shape from its packet, so a judge whose CLI
72
+ // cannot enforce a JSON schema gets the same contract as one that can.
73
+ const gradeSchema = fs.readFileSync(path.join(root, 'evals', 'external', 'GRADE.schema.json'), 'utf8');
74
+ const packetDir = path.join(output, 'packets');
75
+ const gradeDir = path.join(output, 'grades');
76
+ fs.mkdirSync(packetDir, { recursive: true });
77
+ fs.mkdirSync(gradeDir, { recursive: true });
78
+
79
+ const blinding = {};
80
+ for (const caseName of candidates) {
81
+ const swap = parseInt(crypto.createHash('sha256').update(caseName).digest('hex').slice(0, 2), 16) % 2 === 1;
82
+ const treatment = fs.readFileSync(path.join(source, caseName, 'PLAN.mdx'), 'utf8');
83
+ const control = fs.readFileSync(path.join(source, caseName, 'baseline', 'PLAN.mdx'), 'utf8');
84
+ const brief = fs.readFileSync(path.join(caseRoot, caseName, 'REQUEST.baseline.md'), 'utf8');
85
+ const plans = swap ? { A: control, B: treatment } : { A: treatment, B: control };
86
+ blinding[caseName] = swap ? { A: 'control', B: 'treatment' } : { A: 'treatment', B: 'control' };
87
+ const packet = [
88
+ `# Packet ${caseName}`,
89
+ '',
90
+ '## Project brief',
91
+ '',
92
+ brief.trim(),
93
+ '',
94
+ rubric.trim(),
95
+ '',
96
+ '## Required JSON',
97
+ '',
98
+ 'Return one JSON object that validates against this schema. The criterion keys are decision_completeness, falsifiability, execution_actionability, risk_targeting, proportionality, and internal_consistency; total is their sum.',
99
+ '',
100
+ '```json',
101
+ gradeSchema.trim(),
102
+ '```',
103
+ '',
104
+ '## Plan A',
105
+ '',
106
+ plans.A.trim(),
107
+ '',
108
+ '## Plan B',
109
+ '',
110
+ plans.B.trim(),
111
+ '',
112
+ `Set packet_id to "${caseName}".`,
113
+ '',
114
+ ].join('\n');
115
+ fs.writeFileSync(path.join(packetDir, `${caseName}.md`), packet);
116
+ }
117
+
118
+ for (const judge of judges) {
119
+ const judgeDir = path.join(gradeDir, judge.label);
120
+ fs.mkdirSync(judgeDir, { recursive: true });
121
+ for (const caseName of candidates) {
122
+ const grade = path.join(judgeDir, `${caseName}.json`);
123
+ const result = spawnSync(judge.runner, [path.join(packetDir, `${caseName}.md`), grade], {
124
+ cwd: root,
125
+ stdio: 'inherit',
126
+ });
127
+ if (result.status !== 0) throw new Error(`judge ${judge.label} failed on ${caseName}`);
128
+ }
129
+ }
130
+
131
+ const criteria = ['decision_completeness', 'falsifiability', 'execution_actionability', 'risk_targeting', 'proportionality', 'internal_consistency'];
132
+ const raw = {};
133
+ for (const judge of judges) {
134
+ raw[judge.label] = {};
135
+ for (const caseName of candidates) {
136
+ const file = path.join(gradeDir, judge.label, `${caseName}.json`);
137
+ const grade = JSON.parse(fs.readFileSync(file, 'utf8'));
138
+ if (grade.packet_id !== caseName || !Array.isArray(grade.plans) || grade.plans.length !== 2) {
139
+ throw new Error(`invalid grade shape: ${file}`);
140
+ }
141
+ const labels = new Set();
142
+ for (const plan of grade.plans) {
143
+ if (!['A', 'B'].includes(plan.label) || labels.has(plan.label)) throw new Error(`invalid plan labels: ${file}`);
144
+ labels.add(plan.label);
145
+ let total = 0;
146
+ for (const criterion of criteria) {
147
+ const score = plan.scores?.[criterion];
148
+ if (!Number.isInteger(score) || score < 1 || score > 5) throw new Error(`invalid ${criterion}: ${file}`);
149
+ total += score;
150
+ }
151
+ if (plan.total !== total) throw new Error(`total does not match criterion scores: ${file}`);
152
+ }
153
+ if (!['A', 'B', 'tie'].includes(grade.preference) || typeof grade.rationale !== 'string' || !grade.rationale.trim()) {
154
+ throw new Error(`invalid preference or rationale: ${file}`);
155
+ }
156
+ raw[judge.label][caseName] = grade;
157
+ }
158
+ }
159
+
160
+ const judgeSummary = {};
161
+ for (const judge of judges) {
162
+ let treatment = 0;
163
+ let control = 0;
164
+ let treatmentPreferences = 0;
165
+ let controlPreferences = 0;
166
+ let ties = 0;
167
+ for (const caseName of candidates) {
168
+ const grade = raw[judge.label][caseName];
169
+ const byLabel = Object.fromEntries(grade.plans.map((plan) => [plan.label, plan]));
170
+ for (const label of ['A', 'B']) {
171
+ if (blinding[caseName][label] === 'treatment') treatment += byLabel[label].total;
172
+ else control += byLabel[label].total;
173
+ }
174
+ if (grade.preference === 'tie') ties++;
175
+ else if (blinding[caseName][grade.preference] === 'treatment') treatmentPreferences++;
176
+ else controlPreferences++;
177
+ }
178
+ judgeSummary[judge.label] = {
179
+ treatment_mean: treatment / candidates.length,
180
+ control_mean: control / candidates.length,
181
+ mean_delta: (treatment - control) / candidates.length,
182
+ preferences: { treatment: treatmentPreferences, control: controlPreferences, tie: ties },
183
+ };
184
+ }
185
+
186
+ let gapTotal = 0;
187
+ let gapCount = 0;
188
+ for (let left = 0; left < judges.length; left++) {
189
+ for (let right = left + 1; right < judges.length; right++) {
190
+ for (const caseName of candidates) {
191
+ const leftPlans = Object.fromEntries(raw[judges[left].label][caseName].plans.map((plan) => [plan.label, plan.total]));
192
+ const rightPlans = Object.fromEntries(raw[judges[right].label][caseName].plans.map((plan) => [plan.label, plan.total]));
193
+ for (const label of ['A', 'B']) {
194
+ gapTotal += Math.abs(leftPlans[label] - rightPlans[label]);
195
+ gapCount++;
196
+ }
197
+ }
198
+ }
199
+ }
200
+
201
+ const summary = {
202
+ format: 'godplans/external-grade@1',
203
+ source_profile: sourceProfile,
204
+ sample_size: candidates.length,
205
+ judges: judgeSummary,
206
+ mean_absolute_inter_rater_gap: gapCount ? gapTotal / gapCount : null,
207
+ cases: candidates,
208
+ };
209
+ fs.writeFileSync(path.join(output, 'BLINDING.json'), `${JSON.stringify(blinding, null, 2)}\n`);
210
+ fs.writeFileSync(path.join(output, 'SUMMARY.json'), `${JSON.stringify(summary, null, 2)}\n`);
211
+
212
+ const lines = [
213
+ '# Blind external grading summary',
214
+ '',
215
+ `Sample: ${candidates.length} plan pairs. Mean absolute inter-rater gap: ${summary.mean_absolute_inter_rater_gap.toFixed(2)} points on a 30-point scale.`,
216
+ '',
217
+ '| Judge | Treatment mean | Control mean | Delta | Preferences (treatment/control/tie) |',
218
+ '|---|---:|---:|---:|---:|',
219
+ ];
220
+ for (const judge of judges) {
221
+ const result = judgeSummary[judge.label];
222
+ lines.push(`| ${judge.label} | ${result.treatment_mean.toFixed(2)} | ${result.control_mean.toFixed(2)} | ${result.mean_delta.toFixed(2)} | ${result.preferences.treatment}/${result.preferences.control}/${result.preferences.tie} |`);
223
+ }
224
+ lines.push('', 'Raw packets and grades are retained beside this summary. The blinding map was applied only after every grade existed.', '');
225
+ fs.writeFileSync(path.join(output, 'SUMMARY.md'), `${lines.join('\n')}\n`);
226
+ process.stdout.write(`ok ${output}\n`);
@@ -0,0 +1,172 @@
1
+ #!/usr/bin/env bash
2
+ # Run the full behavioral matrix across three host-authenticated model families.
3
+
4
+ set -euo pipefail
5
+
6
+ ROOT="$(cd "$(dirname "$0")/.." && pwd)"
7
+ # The matrix is always the full roster. eval.sh is handed this path explicitly
8
+ # so an exported GODPLANS_EVAL_CASES cannot shrink a published run.
9
+ CASES="$ROOT/evals/cases"
10
+ ROSTER="$ROOT/evals/cases-roster.txt"
11
+ PROFILES="${GODPLANS_MATRIX_PROFILES:-codex claude gemini}"
12
+ OUTPUT=""
13
+ CHECK_ONLY=0
14
+
15
+ usage() {
16
+ cat <<'USAGE'
17
+ Usage: bash scripts/eval-matrix.sh [--check] [--output DIRECTORY]
18
+
19
+ Runs every behavioral case listed in evals/cases-roster.txt, skill and neutral
20
+ control arms, for the Codex, Claude, and Gemini runner families. The case
21
+ directories under evals/cases/ must match the roster exactly. Raw artifacts and
22
+ summaries are retained under evals/results/ by default. A failing case or
23
+ runner in one family still lets the other families run; the command then exits
24
+ non-zero.
25
+ USAGE
26
+ }
27
+
28
+ while [ "$#" -gt 0 ]; do
29
+ case "$1" in
30
+ --check) CHECK_ONLY=1 ;;
31
+ --output)
32
+ shift
33
+ [ "$#" -gt 0 ] || { echo "--output needs a directory" >&2; exit 2; }
34
+ OUTPUT=$1
35
+ ;;
36
+ -h|--help) usage; exit 0 ;;
37
+ *) echo "Unknown option: $1" >&2; exit 2 ;;
38
+ esac
39
+ shift
40
+ done
41
+
42
+ # The committed roster is the expected case set. Deriving it from the
43
+ # directories alone would let a deleted, renamed, or sparse-checkout-missing
44
+ # case shrink the published case count without any error, so the directories
45
+ # on disk must match the roster exactly, in both directions.
46
+ [ -d "$CASES" ] || { echo "case directory not found: $CASES" >&2; exit 1; }
47
+ [ -f "$ROSTER" ] || { echo "case roster not found: $ROSTER" >&2; exit 1; }
48
+ WORK=$(mktemp -d)
49
+ trap 'rm -rf "$WORK"' EXIT
50
+ sed -e 's/#.*//' -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' "$ROSTER" |
51
+ grep -v '^$' > "$WORK/roster.raw" || true
52
+ roster_ok=1
53
+ while IFS= read -r case_name; do
54
+ if ! printf '%s\n' "$case_name" | grep -Eq '^[A-Za-z0-9][A-Za-z0-9._-]*$'; then
55
+ echo "invalid case name in evals/cases-roster.txt: $case_name" >&2
56
+ roster_ok=0
57
+ fi
58
+ done < "$WORK/roster.raw"
59
+ LC_ALL=C sort "$WORK/roster.raw" > "$WORK/roster"
60
+ LC_ALL=C sort -u "$WORK/roster" > "$WORK/roster.unique"
61
+ find "$CASES" -mindepth 1 -maxdepth 1 -type d -print | sed 's|.*/||' | LC_ALL=C sort > "$WORK/disk"
62
+ LC_ALL=C uniq -d "$WORK/roster" > "$WORK/duplicate"
63
+ LC_ALL=C comm -23 "$WORK/disk" "$WORK/roster.unique" > "$WORK/unlisted"
64
+ LC_ALL=C comm -13 "$WORK/disk" "$WORK/roster.unique" > "$WORK/missing"
65
+ while IFS= read -r case_name; do
66
+ echo "duplicate case in evals/cases-roster.txt: $case_name" >&2
67
+ roster_ok=0
68
+ done < "$WORK/duplicate"
69
+ while IFS= read -r case_name; do
70
+ echo "case directory evals/cases/$case_name is not in evals/cases-roster.txt" >&2
71
+ roster_ok=0
72
+ done < "$WORK/unlisted"
73
+ while IFS= read -r case_name; do
74
+ echo "evals/cases-roster.txt lists $case_name, but evals/cases/$case_name does not exist" >&2
75
+ roster_ok=0
76
+ done < "$WORK/missing"
77
+ [ "$roster_ok" -eq 1 ] || exit 1
78
+ [ -s "$WORK/roster.unique" ] || { echo "evals/cases-roster.txt lists no cases" >&2; exit 1; }
79
+
80
+ # Each case must carry everything both arms read; a half-added case fails here
81
+ # instead of surfacing later as a missing arm.
82
+ while IFS= read -r case_name; do
83
+ for required in REQUEST.md REQUEST.baseline.md EXPECTATIONS; do
84
+ [ -f "$CASES/$case_name/$required" ] || {
85
+ echo "matrix case $case_name is incomplete: missing $required" >&2
86
+ exit 1
87
+ }
88
+ done
89
+ done < "$WORK/roster.unique"
90
+ GODPLANS_EVAL_CASES="$CASES" bash "$ROOT/scripts/eval.sh" --check-cases >/dev/null
91
+
92
+ profile_count=0
93
+ seen_profiles=" "
94
+ for profile in $PROFILES; do
95
+ if ! printf '%s\n' "$profile" | grep -Eq '^[A-Za-z0-9][A-Za-z0-9._-]*$'; then
96
+ echo "invalid matrix profile name: $profile" >&2
97
+ exit 2
98
+ fi
99
+ case "$seen_profiles" in
100
+ *" $profile "*) echo "duplicate matrix profile: $profile" >&2; exit 2 ;;
101
+ esac
102
+ seen_profiles="$seen_profiles$profile "
103
+ profile_count=$((profile_count + 1))
104
+ skill_runner="$ROOT/evals/runners/$profile.sh"
105
+ control_runner="$ROOT/evals/runners/$profile-baseline.sh"
106
+ [ -x "$skill_runner" ] || { echo "missing runner: $skill_runner" >&2; exit 1; }
107
+ [ -x "$control_runner" ] || { echo "missing runner: $control_runner" >&2; exit 1; }
108
+ bash -n "$skill_runner"
109
+ bash -n "$control_runner"
110
+ done
111
+ [ "$profile_count" -ge 3 ] || {
112
+ echo "matrix requires at least three model-family profiles" >&2
113
+ exit 1
114
+ }
115
+
116
+ if [ "$CHECK_ONLY" -eq 1 ]; then
117
+ echo "ok [eval-matrix]"
118
+ exit 0
119
+ fi
120
+
121
+ # Runner authentication belongs to the host. The skill and this coordinator
122
+ # never require, read, or prescribe provider credentials.
123
+ for profile in $PROFILES; do
124
+ case "$profile" in
125
+ codex)
126
+ command -v codex >/dev/null 2>&1 || { echo "codex CLI not found" >&2; exit 2; }
127
+ ;;
128
+ claude)
129
+ command -v claude >/dev/null 2>&1 || { echo "claude CLI not found" >&2; exit 2; }
130
+ ;;
131
+ gemini)
132
+ command -v gemini >/dev/null 2>&1 || { echo "gemini CLI not found" >&2; exit 2; }
133
+ ;;
134
+ *)
135
+ # Custom profiles own their capability and authentication preflight.
136
+ ;;
137
+ esac
138
+ done
139
+
140
+ if [ -z "$OUTPUT" ]; then
141
+ revision=$(git -C "$ROOT" rev-parse --short HEAD 2>/dev/null || echo no-git)
142
+ run_date=$(date -u +%Y-%m-%d)
143
+ OUTPUT="$ROOT/evals/results/$run_date-$revision"
144
+ fi
145
+ mkdir -p "$OUTPUT"
146
+ # A summary left by an earlier run into the same directory must not stand in
147
+ # for this one if it fails.
148
+ rm -f "$OUTPUT/MATRIX.json" "$OUTPUT/MATRIX.md"
149
+
150
+ # eval.sh exits non-zero on any failing case. Record that per profile instead
151
+ # of letting set -e discard the families that have not run yet.
152
+ status=0
153
+ for profile in $PROFILES; do
154
+ profile_output="$OUTPUT/$profile"
155
+ mkdir -p "$profile_output"
156
+ GODPLANS_EVAL_CASES="$CASES" \
157
+ GODPLANS_EVAL_RUNNER="$ROOT/evals/runners/$profile.sh" \
158
+ GODPLANS_EVAL_BASELINE_RUNNER="$ROOT/evals/runners/$profile-baseline.sh" \
159
+ bash "$ROOT/scripts/eval.sh" --baseline --output "$profile_output" \
160
+ | tee "$profile_output/EVAL.tsv" || status=1
161
+ done
162
+
163
+ # The summarizer rejects a profile that lacks a scored skill or control arm for
164
+ # any case (a runner-error marker is not a score), so a missing run fails the
165
+ # matrix instead of publishing a partial one.
166
+ node "$ROOT/scripts/summarize-matrix.js" "$OUTPUT" $PROFILES || status=1
167
+ if [ "$status" -eq 0 ]; then
168
+ echo "ok $OUTPUT"
169
+ else
170
+ echo "FAIL [eval-matrix] at least one family failed; per-family rows are under $OUTPUT" >&2
171
+ fi
172
+ exit "$status"
@@ -0,0 +1,143 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ const fs = require('node:fs');
5
+ const path = require('node:path');
6
+ const { spawnSync } = require('node:child_process');
7
+ const { writeOutcomeSummary } = require('./outcome-summary');
8
+
9
+ const root = path.resolve(__dirname, '..');
10
+ const args = process.argv.slice(2);
11
+ const options = {};
12
+ for (let index = 0; index < args.length; index++) {
13
+ const key = args[index];
14
+ if (key === '-h' || key === '--help') {
15
+ process.stdout.write('Usage: node scripts/eval-outcome.js --case ID --plan-runner PATH --control-plan-runner PATH --build-runner PATH --audit-runner PATH --output DIR\n');
16
+ process.exit(0);
17
+ }
18
+ if (!key.startsWith('--') || index + 1 >= args.length) throw new Error(`invalid option: ${key}`);
19
+ options[key.slice(2)] = args[++index];
20
+ }
21
+ for (const key of ['case', 'plan-runner', 'control-plan-runner', 'build-runner', 'audit-runner', 'output']) {
22
+ if (!options[key]) throw new Error(`--${key} is required`);
23
+ }
24
+
25
+ const caseDir = path.join(root, 'evals', 'outcomes', 'cases', options.case);
26
+ const output = path.resolve(options.output);
27
+ const input = path.join(caseDir, 'INPUT');
28
+ const request = path.join(caseDir, 'REQUEST.md');
29
+ const verify = path.join(caseDir, 'VERIFY.sh');
30
+
31
+ // A command that could not run is a fault in the harness, never evidence about
32
+ // the build. Any exit status VERIFY.sh itself returns, 126 and 127 included,
33
+ // is the verdict on the build: under set -e an `npm test` whose script names a
34
+ // tool the build never installed exits 127, and that is a failing build.
35
+ class HarnessError extends Error {}
36
+
37
+ function fail(error) {
38
+ const kind = error instanceof HarnessError ? 'harness error: ' : '';
39
+ process.stderr.write(`eval-outcome: ${kind}${error.message}\n`);
40
+ process.exit(1);
41
+ }
42
+
43
+ try {
44
+ fs.accessSync(request, fs.constants.R_OK);
45
+ } catch {
46
+ fail(new HarnessError(`REQUEST.md is not readable: ${request}`));
47
+ }
48
+ try {
49
+ fs.accessSync(verify, fs.constants.X_OK);
50
+ } catch {
51
+ fail(new HarnessError(`VERIFY.sh is not executable: ${verify}`));
52
+ }
53
+
54
+ function executable(file) {
55
+ try {
56
+ fs.accessSync(file, fs.constants.X_OK);
57
+ return fs.statSync(file).isFile();
58
+ } catch {
59
+ return false;
60
+ }
61
+ }
62
+
63
+ // A missing absolute interpreter surfaces as a spawn error, but
64
+ // `#!/usr/bin/env NAME` hands the lookup to env, which exits 127 when NAME is
65
+ // not on PATH: the same status as a failing command inside VERIFY.sh. Resolve
66
+ // the interpreter here, before any arm runs, so that case stays a harness error.
67
+ const shebang = fs.readFileSync(verify, 'utf8').split('\n', 1)[0];
68
+ if (!shebang.startsWith('#!')) fail(new HarnessError(`VERIFY.sh has no #! interpreter line: ${verify}`));
69
+ const [interpreter = '', ...interpreterArgs] = shebang.slice(2).trim().split(/\s+/);
70
+ const wanted = path.basename(interpreter) === 'env'
71
+ ? interpreterArgs.find((arg) => !arg.startsWith('-') && !arg.includes('='))
72
+ : interpreter;
73
+ const resolvable = Boolean(wanted) && (wanted.includes('/')
74
+ ? executable(wanted)
75
+ : (process.env.PATH || '').split(path.delimiter).some((dir) => executable(path.join(dir || '.', wanted))));
76
+ if (!resolvable) fail(new HarnessError(`VERIFY.sh interpreter ${wanted || '(none)'} cannot run: ${verify}`));
77
+
78
+ for (const key of ['plan-runner', 'control-plan-runner', 'build-runner', 'audit-runner']) {
79
+ options[key] = path.resolve(options[key]);
80
+ fs.accessSync(options[key], fs.constants.X_OK);
81
+ }
82
+
83
+ // spawnSync runs no shell, so a command that cannot start at all (missing,
84
+ // not executable, a bad #! line) arrives as result.error, and a signal leaves
85
+ // status null. Both are harness errors for every command. Returns the status.
86
+ function spawn(command, commandArgs, stdoutFile) {
87
+ const settings = { cwd: root, stdio: stdoutFile ? ['ignore', 'pipe', 'inherit'] : 'inherit' };
88
+ const result = spawnSync(command, commandArgs, settings);
89
+ if (stdoutFile && result.stdout) fs.writeFileSync(stdoutFile, result.stdout);
90
+ const name = path.basename(command);
91
+ if (result.error) throw new HarnessError(`${name} could not start: ${result.error.message}`);
92
+ if (result.status === null) throw new HarnessError(`${name} was stopped by ${result.signal}`);
93
+ return result.status;
94
+ }
95
+
96
+ // The plan, build, and audit runners are harness machinery: any failure stops
97
+ // the run, and 126/127 (a command the runner needs is missing) is named as a
98
+ // harness error.
99
+ function runStep(command, commandArgs) {
100
+ const status = spawn(command, commandArgs);
101
+ const name = path.basename(command);
102
+ if (status === 126 || status === 127) {
103
+ throw new HarnessError(`${name} could not execute a command (exit ${status})`);
104
+ }
105
+ if (status !== 0) throw new Error(`${name} exited ${status}`);
106
+ }
107
+
108
+ const arms = {
109
+ treatment: { planRunner: options['plan-runner'] },
110
+ control: { planRunner: options['control-plan-runner'] },
111
+ };
112
+ fs.mkdirSync(output, { recursive: true });
113
+ // A same-day rerun reuses the date-named output directory. A summary left by
114
+ // an earlier run must not stand beside this run's arms if this run fails.
115
+ fs.rmSync(path.join(output, 'SUMMARY.json'), { force: true });
116
+ fs.rmSync(path.join(output, 'SUMMARY.md'), { force: true });
117
+
118
+ try {
119
+ for (const [arm, config] of Object.entries(arms)) {
120
+ const armDir = path.join(output, arm);
121
+ const planDir = path.join(armDir, 'plan');
122
+ const buildDir = path.join(armDir, 'build');
123
+ const auditDir = path.join(armDir, 'audit');
124
+ fs.mkdirSync(planDir, { recursive: true });
125
+ runStep(config.planRunner, [request, path.join(planDir, 'PLAN.mdx')]);
126
+ runStep(options['build-runner'], [path.join(planDir, 'PLAN.mdx'), input, buildDir]);
127
+ const verifyLog = path.join(armDir, 'VERIFY.log');
128
+ const verifyPassed = spawn(verify, [path.join(buildDir, 'repository')], verifyLog) === 0;
129
+ fs.mkdirSync(auditDir, { recursive: true });
130
+ runStep(options['audit-runner'], [path.join(buildDir, 'repository'), auditDir]);
131
+ config.verifyPassed = verifyPassed;
132
+ }
133
+
134
+ writeOutcomeSummary({
135
+ output,
136
+ caseId: options.case,
137
+ treatmentVerified: arms.treatment.verifyPassed,
138
+ controlVerified: arms.control.verifyPassed,
139
+ });
140
+ } catch (error) {
141
+ fail(error);
142
+ }
143
+ process.stdout.write(`ok ${output}\n`);