bmad-method-test-architecture-enterprise 4.3.1 → 4.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/cli/evaluate.js +6 -2
  3. package/cli/lib/evaluate/check.js +217 -11
  4. package/cli/lib/evaluate/corpus-index.js +52 -0
  5. package/cli/lib/evaluate/held-refusal.js +2 -3
  6. package/cli/lib/evaluate/run.js +16 -3
  7. package/cli/lib/evaluate/schemas/evaluation.schema.json +13 -0
  8. package/cli/lib/evaluate/score-inputs.js +13 -2
  9. package/cli/lib/isolate.js +351 -13
  10. package/cli/lib/run-agent.js +4 -0
  11. package/cli/lib/trace-live.js +54 -3
  12. package/cli/test-review.js +18 -5
  13. package/package.json +2 -2
  14. package/skills/bmad-tea/SKILL.md +2 -2
  15. package/skills/bmad-tea-automate/SKILL.md +2 -2
  16. package/skills/bmad-tea-automate/red/instructions.md +1 -1
  17. package/skills/bmad-tea-automate/red/steps-c/step-05-validate-and-complete.md +1 -1
  18. package/skills/bmad-tea-automate/red/steps-e/step-02-apply-edit.md +1 -1
  19. package/skills/bmad-tea-automate/red/steps-v/step-01-validate.md +1 -1
  20. package/skills/bmad-tea-automate/resources/test-generation-routing.md +1 -1
  21. package/skills/bmad-tea-automate/steps-c/step-04-validate-and-summarize.md +1 -1
  22. package/skills/bmad-tea-automate/steps-e/step-02-apply-edit.md +1 -1
  23. package/skills/bmad-tea-automate/steps-v/step-01-validate.md +1 -1
  24. package/skills/bmad-tea-evaluate/SKILL.md +3 -3
  25. package/skills/bmad-tea-evaluate/assets/README.md +1 -0
  26. package/skills/bmad-tea-evaluate/assets/gap-report.template.md +29 -0
  27. package/skills/bmad-tea-evaluate/references/ci.md +13 -0
  28. package/skills/bmad-tea-evaluate/references/corpus.md +2 -2
  29. package/skills/bmad-tea-evaluate/references/gaps.md +4 -0
  30. package/skills/bmad-tea-framework/SKILL.md +2 -2
  31. package/skills/bmad-tea-framework/resources/setup-phase-completion.md +1 -1
  32. package/skills/bmad-tea-framework/resources/setup-routing.md +1 -1
  33. package/skills/bmad-tea-nfr/SKILL.md +2 -2
  34. package/skills/bmad-tea-nfr/steps-c/step-05-generate-report.md +1 -1
  35. package/skills/bmad-tea-nfr/steps-e/step-02-apply-edit.md +1 -1
  36. package/skills/bmad-tea-nfr/steps-v/step-01-validate.md +1 -1
  37. package/skills/bmad-tea-teach-me-testing/SKILL.md +2 -2
  38. package/skills/bmad-tea-teach-me-testing/steps-c/step-05-completion.md +1 -1
  39. package/skills/bmad-tea-teach-me-testing/steps-e/step-e-02-apply-edits.md +1 -1
  40. package/skills/bmad-tea-teach-me-testing/steps-v/step-v-01-validate.md +1 -1
  41. package/skills/bmad-tea-test-design/SKILL.md +2 -2
  42. package/skills/bmad-tea-test-design/steps-c/step-01-detect-mode.md +2 -2
  43. package/skills/bmad-tea-test-design/steps-c/step-05-generate-output.md +1 -1
  44. package/skills/bmad-tea-test-design/steps-e/step-02-apply-edit.md +1 -1
  45. package/skills/bmad-tea-test-design/steps-v/step-01-validate.md +1 -1
  46. package/skills/bmad-tea-test-review/SKILL.md +2 -2
  47. package/skills/bmad-tea-test-review/steps-c/step-04-generate-report.md +1 -1
  48. package/skills/bmad-tea-test-review/steps-e/step-02-apply-edit.md +1 -1
  49. package/skills/bmad-tea-test-review/steps-v/step-01-validate.md +1 -1
  50. package/skills/bmad-tea-trace/SKILL.md +2 -2
  51. package/skills/bmad-tea-trace/steps-c/step-05-gate-decision.md +1 -1
  52. package/skills/bmad-tea-trace/steps-e/step-02-apply-edit.md +1 -1
  53. package/skills/bmad-tea-trace/steps-v/step-01-validate.md +1 -1
  54. package/skills/bmod-tea/bmod.toml +1 -1
  55. package/skills/bmod-tea/help/help.md +1 -1
@@ -31,7 +31,7 @@
31
31
  "name": "bmad-method-test-architecture-enterprise",
32
32
  "source": "./",
33
33
  "description": "Master Test Architect module for quality strategy, test generation in red and expand modes with automatic run-and-heal, combined framework and CI setup, CI/CD quality gates, and structured testing education. Existing CI and ATDD customizations can be migrated to the new skill names. Part of the BMad Method ecosystem.",
34
- "version": "4.3.1",
34
+ "version": "4.4.1",
35
35
  "author": {
36
36
  "name": "Murat K Ozcan (TEA Creator) & Brian (BMad) Madison"
37
37
  },
package/cli/evaluate.js CHANGED
@@ -123,7 +123,7 @@
123
123
  const { Command } = require('commander');
124
124
 
125
125
  const { readFolderFile, resolveEvaluationFolder } = require('./lib/evaluate/folder');
126
- const { checkEvaluation } = require('./lib/evaluate/check');
126
+ const { checkEvaluation, checkWarnings } = require('./lib/evaluate/check');
127
127
  const { CorpusIndexError, writeCorpusIndex } = require('./lib/evaluate/corpus-index');
128
128
  const { EngineUnavailableError, loadEngine } = require('./lib/evaluate/engine');
129
129
  const { EngineStageError } = require('./lib/evaluate/engine-cli');
@@ -159,11 +159,15 @@ function folderFrom(options) {
159
159
  async function runCheck(options) {
160
160
  const folder = folderFrom(options);
161
161
  const findings = await checkEvaluation(folder);
162
+ for (const finding of findings) process.stdout.write(findingLine(finding.file, finding.rule, finding.message));
163
+ // A warning never changes the exit: it names evidence to refresh, not an authoring defect, and it is read only after every finding
164
+ // is printed, so it can never hide one.
165
+ for (const warning of await checkWarnings(folder, findings))
166
+ process.stderr.write(`warning: ${findingLine(warning.file, warning.rule, warning.message)}`);
162
167
  if (findings.length === 0) {
163
168
  process.stdout.write(`${NAME} check: ${folder} has no authoring defects\n`);
164
169
  return EXIT_CODES.ok;
165
170
  }
166
- for (const finding of findings) process.stdout.write(findingLine(finding.file, finding.rule, finding.message));
167
171
  process.stdout.write(`${NAME} check: ${findings.length} authoring defect(s) in ${folder}\n`);
168
172
  return EXIT_CODES.authoring;
169
173
  }
@@ -25,7 +25,12 @@
25
25
  * workspace holds read-only.
26
26
  * - `web-interface`: the contract declares an interface of kind `web`.
27
27
  * - `written-file-signature`: a defect signature addresses a file the target wrote.
28
- * - `oracle-count`: a behavior a defect or gameability probe discharges does not declare exactly one oracle.
28
+ * - `oracle-count`: a behavior a defect, gameability or zero-action defect probe discharges does not declare exactly one oracle.
29
+ * - `held-out` coverage: a held-out set leaves a `material` or `critical` behavior without a qualifying probe or a documented exclusion.
30
+ * - `mandatory-action`: a behavior `mandatoryActionBehaviors` lists that the contract does not declare, or that no zero-action defect
31
+ * probe (`probeClass` `zero-action`, `expectedClean: false`, a defect on the behavior) covers.
32
+ * - Warnings (`checkWarnings`), which never change the exit: `held-out-drift`, the newest run with a completed held-out score recorded
33
+ * a `heldOutDigest` the committed held-out material no longer has.
29
34
  * - `id-pattern`: a probe, defect, behavior, oracle or mutation ID is off its pattern.
30
35
  * - `qualification-digest`: a `baseline/qualification/` reference's digest does not match the file.
31
36
  * - `baseline-digest` (Story 1.90, AD-12): a file of `baseline/` digests to something other than the entry of the
@@ -154,7 +159,7 @@ const { CALIBRATION_PATH, calibrationProblems, readCalibration } = require('./ca
154
159
  const { readConfiguration, recordsDirectory, verifyRecordsCalibration } = require('./records-calibration');
155
160
  const { baselineDigestFindings } = require('./baseline-digests');
156
161
  const { readPlan } = require('./ci-plan');
157
- const { MANIFEST_NAME } = require('./folder');
162
+ const { MANIFEST_NAME, readFolderFile } = require('./folder');
158
163
  const { addFormats } = require('./formats');
159
164
  const { HTTP_PORT_MODULE, originTarget, sharedOrigin } = require('./http-target');
160
165
  const { compileRefusals, lineNamesOperation, reportedOperations, reportsProblems } = require('./release-report');
@@ -187,6 +192,7 @@ const {
187
192
  STEP_ID,
188
193
  contractView,
189
194
  heldOutResponsePath,
195
+ loadContractView,
190
196
  mappingViewProblems,
191
197
  named,
192
198
  partitionPlanProblems,
@@ -199,7 +205,7 @@ const {
199
205
 
200
206
  /** The skill runner's infrastructure exit codes (`cli/skill-runner.js`), which a registry entry for it must declare. */
201
207
  const SKILL_RUNNER_INFRASTRUCTURE_CODES = [3, 4, 5, 6];
202
- const { CorpusIndexError, INDEX_NAME, corpusIndexProblem, unreadPaths } = require('./corpus-index');
208
+ const { CorpusIndexError, INDEX_NAME, corpusIndexProblem, heldOutDigestOf, unreadPaths } = require('./corpus-index');
203
209
 
204
210
  const Ajv = AjvModule.default ?? AjvModule;
205
211
 
@@ -209,6 +215,17 @@ function isPlainObject(value) {
209
215
  return value !== null && typeof value === 'object' && !Array.isArray(value);
210
216
  }
211
217
 
218
+ /**
219
+ * Whether a probe discharges the behaviors it names: a `defect` or `gameability` probe, or a `zero-action` probe that does not expect a
220
+ * clean run (a mandatory-action defect probe). A clean control and a canary test the instrument, so neither does. Every rule that asks
221
+ * which behaviors a probe exercises reads this one predicate: the oracle count, the held-out view's oracle count and held-out coverage.
222
+ */
223
+ function dischargesBehaviors(probe) {
224
+ if (!isPlainObject(probe)) return false;
225
+ if (probe.probeClass === 'defect' || probe.probeClass === 'gameability') return true;
226
+ return probe.probeClass === 'zero-action' && probe.expectedClean === false && probe.qualification?.route !== 'clean-control';
227
+ }
228
+
212
229
  const CONTRACT_NAME = 'contract.json';
213
230
  const POLICY_NAME = 'policy/scoring-policy.json';
214
231
  const CONDITIONS_NAME = 'policy/evaluator-conditions.json';
@@ -1123,7 +1140,7 @@ function checkProbe(report, relative, probe, context, behaviors, mutations, regi
1123
1140
  );
1124
1141
  }
1125
1142
 
1126
- if (behaviors !== undefined && (probe.probeClass === 'defect' || probe.probeClass === 'gameability')) {
1143
+ if (behaviors !== undefined && dischargesBehaviors(probe)) {
1127
1144
  const discharged = [probe.behaviorId, ...defects.map((defect) => defect?.behaviorId)].filter((id) => typeof id === 'string');
1128
1145
  for (const behaviorId of new Set(discharged)) {
1129
1146
  const behavior = behaviors.get(behaviorId);
@@ -1817,17 +1834,110 @@ async function checkProbes(report, folder, context, behaviors, mutations, regist
1817
1834
  return routes;
1818
1835
  }
1819
1836
 
1820
- function checkHeldOut(report, folder, evaluation) {
1821
- const selected = evaluation.heldOutProbes ?? [];
1822
- if (!Array.isArray(selected)) return;
1823
- const defectsOf = (probe) =>
1824
- Array.isArray(probe?.defects) ? probe.defects.filter((defect) => defect !== null && typeof defect === 'object') : [];
1837
+ /** The severities of a behavior a held-out partition must exercise (AD-22): a `low` behavior may stay in development alone. */
1838
+ const HELD_OUT_SEVERITIES = new Set(['material', 'critical']);
1839
+
1840
+ /** The defects a probe seeds, each an object. */
1841
+ function defectsOf(probe) {
1842
+ return Array.isArray(probe?.defects) ? probe.defects.filter((defect) => defect !== null && typeof defect === 'object') : [];
1843
+ }
1844
+
1845
+ /** The committed probes that parse, by probe ID; a file that does not parse is a `json` finding. */
1846
+ function probesById(report, folder) {
1825
1847
  const probes = new Map();
1826
1848
  for (const entry of listDirectory(folder, 'probes') ?? []) {
1827
1849
  if (!entry.isFile || !PROBE_FILE.test(entry.name)) continue;
1828
1850
  const probe = parseInto(report, folder, `probes/${entry.name}`);
1829
1851
  if (typeof probe?.probeId === 'string') probes.set(probe.probeId, probe);
1830
1852
  }
1853
+ return probes;
1854
+ }
1855
+
1856
+ /** The contract's behaviors that are objects with a string ID. */
1857
+ function behaviorsOf(contract) {
1858
+ return Array.isArray(contract?.behaviors)
1859
+ ? contract.behaviors.filter((behavior) => isPlainObject(behavior) && typeof behavior.id === 'string')
1860
+ : [];
1861
+ }
1862
+
1863
+ /**
1864
+ * A held-out set needs a probe for each material or critical behavior in scope. A documented exclusion records the limit of a
1865
+ * partial corpus without changing its accepted baseline.
1866
+ */
1867
+ function checkHeldOutCoverage(report, evaluation, contract, probes) {
1868
+ const selected = Array.isArray(evaluation.heldOutProbes) ? evaluation.heldOutProbes : [];
1869
+ if (selected.length === 0 && !isPlainObject(evaluation.partitionPlan)) return;
1870
+ const behaviors = behaviorsOf(contract);
1871
+ const required = new Set(behaviors.filter((behavior) => HELD_OUT_SEVERITIES.has(behavior.severity)).map((behavior) => behavior.id));
1872
+ const heldOutCoverageExclusions = isPlainObject(evaluation.heldOutCoverageExclusions) ? evaluation.heldOutCoverageExclusions : {};
1873
+ if (contract !== undefined) {
1874
+ for (const id of Object.keys(heldOutCoverageExclusions)) {
1875
+ if (!required.has(id))
1876
+ report.add(MANIFEST_NAME, 'held-out', `heldOutCoverageExclusions names ${id}, which is not a material or critical behavior`);
1877
+ }
1878
+ }
1879
+ const covered = new Set();
1880
+ for (const id of selected) {
1881
+ const probe = probes.get(id);
1882
+ if (!dischargesBehaviors(probe)) continue;
1883
+ for (const behaviorId of [probe.behaviorId, ...defectsOf(probe).map((defect) => defect.behaviorId)])
1884
+ if (typeof behaviorId === 'string') covered.add(behaviorId);
1885
+ }
1886
+ for (const behavior of behaviors) {
1887
+ if (!required.has(behavior.id) || covered.has(behavior.id)) continue;
1888
+ const reason = heldOutCoverageExclusions[behavior.id];
1889
+ if (typeof reason === 'string' && reason.trim()) continue;
1890
+ report.add(
1891
+ MANIFEST_NAME,
1892
+ 'held-out',
1893
+ `behavior ${behavior.id} is ${behavior.severity} and no probe in heldOutProbes exercises it; hold out a defect, gameability or zero-action defect probe of ${behavior.id} (a clean control or a canary does not count) and keep a development probe beside it`,
1894
+ );
1895
+ }
1896
+ }
1897
+
1898
+ /**
1899
+ * `mandatoryActionBehaviors`: each listed behavior is one the contract declares and has a zero-action defect probe, `probeClass`
1900
+ * `zero-action` with `expectedClean: false` and a defect on that behavior, so a target that skips the action is caught. A folder that
1901
+ * lists none is held to nothing more.
1902
+ */
1903
+ function checkMandatoryActions(report, evaluation, contract, probes) {
1904
+ const {
1905
+ // The optional list of behaviors whose required action must be proven to happen.
1906
+ mandatoryActionBehaviors: listed,
1907
+ } = evaluation;
1908
+ if (!Array.isArray(listed)) return;
1909
+ const declared = new Set(behaviorsOf(contract).map((behavior) => behavior.id));
1910
+ for (const behaviorId of listed) {
1911
+ if (typeof behaviorId !== 'string') continue;
1912
+ if (contract !== undefined && !declared.has(behaviorId)) {
1913
+ report.add(
1914
+ MANIFEST_NAME,
1915
+ 'mandatory-action',
1916
+ `mandatoryActionBehaviors names behavior ${behaviorId}, which contract.json does not declare`,
1917
+ );
1918
+ continue;
1919
+ }
1920
+ const proven = [...probes.values()].some(
1921
+ (probe) =>
1922
+ probe.probeClass === 'zero-action' &&
1923
+ dischargesBehaviors(probe) &&
1924
+ defectsOf(probe).some((defect) => defect.behaviorId === behaviorId),
1925
+ );
1926
+ if (!proven)
1927
+ report.add(
1928
+ MANIFEST_NAME,
1929
+ 'mandatory-action',
1930
+ `behavior ${behaviorId} is a mandatory action and no zero-action defect probe (probeClass zero-action, expectedClean false) seeds a defect on it; add one whose signature exposes the missing action`,
1931
+ );
1932
+ }
1933
+ }
1934
+
1935
+ function checkHeldOut(report, folder, evaluation, contract) {
1936
+ const probes = probesById(report, folder);
1937
+ checkMandatoryActions(report, evaluation, contract, probes);
1938
+ checkHeldOutCoverage(report, evaluation, contract, probes);
1939
+ const selected = evaluation.heldOutProbes ?? [];
1940
+ if (!Array.isArray(selected)) return;
1831
1941
  for (const id of selected) {
1832
1942
  const probe = probes.get(id);
1833
1943
  if (probe === undefined) {
@@ -1945,7 +2055,7 @@ function checkPartitionPlan(report, folder, evaluation, context, { openPlan = tr
1945
2055
  } catch {
1946
2056
  continue;
1947
2057
  }
1948
- if (!selected.includes(probe?.probeId) || (probe.probeClass !== 'defect' && probe.probeClass !== 'gameability')) continue;
2058
+ if (!selected.includes(probe?.probeId) || !dischargesBehaviors(probe)) continue;
1949
2059
  const defects = Array.isArray(probe.defects) ? probe.defects : [];
1950
2060
  for (const behaviorId of [probe.behaviorId, ...defects.map((defect) => defect?.behaviorId)]) {
1951
2061
  if (typeof behaviorId === 'string') heldOutBehaviors.add(behaviorId);
@@ -2519,7 +2629,7 @@ async function checkEvaluation(folder, { platform = process.platform, env = proc
2519
2629
  const mutations = checkMutations(report, folder, context, provision, skillRoot);
2520
2630
  checkSkillRunner(report, evaluation, context.contract, provision, platform);
2521
2631
  const routes = await checkProbes(report, folder, context, behaviors, mutations, registry, compiled, evaluation);
2522
- checkHeldOut(report, folder, evaluation);
2632
+ checkHeldOut(report, folder, evaluation, context.contract);
2523
2633
  const openPlan = partition !== 'development';
2524
2634
  const planFile = evaluation.partitionPlan?.heldOutPlan;
2525
2635
  const heldOutUnread = openPlan || typeof planFile !== 'string' ? [] : [HELD_OUT_DIRECTORY];
@@ -2571,6 +2681,101 @@ async function checkEvaluation(folder, { platform = process.platform, env = proc
2571
2681
  return report.findings;
2572
2682
  }
2573
2683
 
2684
+ /** A run directory's name, and a score invocation's: the runtime's flat invocation identifiers. */
2685
+ const RUN_ID = /^[A-Za-z0-9_-]+$/;
2686
+
2687
+ /** One parsed JSON object the evaluation folder holds, read through the folder's guarded walk, or null. */
2688
+ function folderJson(folder, relative) {
2689
+ const read = readFolderFile(folder, relative);
2690
+ if (!read.ok) return null;
2691
+ try {
2692
+ const value = JSON.parse(read.bytes.toString('utf8'));
2693
+ return isPlainObject(value) ? value : null;
2694
+ } catch {
2695
+ return null;
2696
+ }
2697
+ }
2698
+
2699
+ /**
2700
+ * Whether a completed run holds a completed score with held-out results: its `partitions.json`, which `score` replaces only after it
2701
+ * has written the score's `score.json`, names a score invocation whose `score.json` records this run, and lists at least one held-out
2702
+ * row. A score that stopped part way writes neither, so it never stands in for the complete evidence before it.
2703
+ */
2704
+ function scoredHeldOut(folder, runId) {
2705
+ const partitions = folderJson(folder, `runs/${runId}/partitions.json`);
2706
+ const scoreId = partitions?.scoreInvocationId;
2707
+ if (typeof scoreId !== 'string' || !RUN_ID.test(scoreId)) return false;
2708
+ if (!Array.isArray(partitions['held-out']) || partitions['held-out'].length === 0) return false;
2709
+ const summary = folderJson(folder, `runs/${runId}/scores/${scoreId}/score.json`);
2710
+ return summary?.invocationId === scoreId && summary.run === runId;
2711
+ }
2712
+
2713
+ /** Whether every index row is a `{ path, sha256 }` pair the digest can read. */
2714
+ function wellFormedIndex(index) {
2715
+ return (
2716
+ Array.isArray(index) &&
2717
+ index.every(
2718
+ (entry) =>
2719
+ isPlainObject(entry) && typeof entry.path === 'string' && typeof entry.sha256 === 'string' && /^[0-9a-f]{64}$/.test(entry.sha256),
2720
+ )
2721
+ );
2722
+ }
2723
+
2724
+ /** Findings that leave the held-out material unreadable or unsound, so no held-out comparison is made over them. */
2725
+ const UNSOUND_FOR_DRIFT = new Set(['json', 'schema', 'stale-index', 'corpus-file', 'partition-plan', 'file-name']);
2726
+
2727
+ /**
2728
+ * The non-blocking warnings `check` prints after its findings, which never change its exit. One today: the newest run with a completed
2729
+ * held-out score (`scoredHeldOut`) recorded a `heldOutDigest` the committed held-out material no longer has, so its held-out result no
2730
+ * longer describes the committed partition. A run that records no digest (one made before the field existed, or a development run) is
2731
+ * passed over. Nothing is compared while a finding leaves the corpus index, a probe, the contract or the held-out plan unsound, and an
2732
+ * error while comparing ends the comparison without a warning: the warning is advice and never stands in for a finding.
2733
+ *
2734
+ * @param {string} folder
2735
+ * @param {Array<{ file: string, rule: string }>} [findings] the folder's findings, from `checkEvaluation`
2736
+ * @returns {Promise<Array<{ file: string, rule: string, message: string }>>}
2737
+ */
2738
+ async function checkWarnings(folder, findings = []) {
2739
+ if (findings.some((finding) => UNSOUND_FOR_DRIFT.has(finding.rule) || finding.file === INDEX_NAME)) return [];
2740
+ try {
2741
+ const evaluation = folderJson(folder, MANIFEST_NAME);
2742
+ const index = (() => {
2743
+ const read = readFolderFile(folder, INDEX_NAME);
2744
+ return read.ok ? JSON.parse(read.bytes.toString('utf8')) : null;
2745
+ })();
2746
+ const heldOutProbes = Array.isArray(evaluation?.heldOutProbes) ? evaluation.heldOutProbes : [];
2747
+ if (heldOutProbes.length === 0 || !wellFormedIndex(index)) return [];
2748
+ const runs = path.join(folder, 'runs');
2749
+ if (!fs.lstatSync(runs, { throwIfNoEntry: false })?.isDirectory()) return [];
2750
+ for (const runId of fs
2751
+ .readdirSync(runs)
2752
+ .filter((name) => RUN_ID.test(name))
2753
+ .sort()
2754
+ .toReversed()) {
2755
+ const record = folderJson(folder, `runs/${runId}/run.json`);
2756
+ if (record?.command !== 'run' || record.completed !== true || typeof record.heldOutDigest !== 'string') continue;
2757
+ if (!scoredHeldOut(folder, runId)) continue;
2758
+ const current = await heldOutDigestOf({
2759
+ index,
2760
+ probes: [...probesById(createFindings(), folder).values()],
2761
+ heldOutProbes,
2762
+ contract: loadContractView({ folder, evaluation, partition: 'held-out' }).contract,
2763
+ });
2764
+ if (current === record.heldOutDigest) return [];
2765
+ return [
2766
+ {
2767
+ file: `runs/${runId}/run.json`,
2768
+ rule: 'held-out-drift',
2769
+ message: `the newest scored held-out run ${runId} measured held-out material that has changed since (heldOutDigest ${record.heldOutDigest}, now ${current}), so its held-out result no longer describes the committed partition; run and score the held-out partition again before you rely on it`,
2770
+ },
2771
+ ];
2772
+ }
2773
+ } catch {
2774
+ // Advice only: a folder the comparison cannot read is the findings' to report.
2775
+ }
2776
+ return [];
2777
+ }
2778
+
2574
2779
  module.exports = {
2575
2780
  KNOWN_EVALUATION_SCHEMA_VERSIONS,
2576
2781
  RUNTIME_OWNED_DEFECT_FIELDS,
@@ -2578,4 +2783,5 @@ module.exports = {
2578
2783
  RUNTIME_OWNED_QUALIFICATION_FIELDS,
2579
2784
  TEA_MANIFEST,
2580
2785
  checkEvaluation,
2786
+ checkWarnings,
2581
2787
  };
@@ -146,6 +146,56 @@ async function corpusDigestOf(index) {
146
146
  return engine.digestArtifact(index, INDEX_NAME);
147
147
  }
148
148
 
149
+ /** The name `heldOutDigestOf` digests its value under. */
150
+ const HELD_OUT_CONTENT = 'held-out-content';
151
+
152
+ /**
153
+ * The index entries that hold held-out material: every file under `corpus/held-out/`, and for each probe `heldOutProbes` lists, its
154
+ * probe file, its degenerate response under `corpus/gameability/` and the mutation file its qualification names.
155
+ *
156
+ * @param {Array<{ path: string, sha256: string }>} index
157
+ * @param {Array<object>} probes the committed probes, parsed
158
+ * @param {Iterable<string>} heldOutProbes
159
+ * @returns {Array<{ path: string, sha256: string }>}
160
+ */
161
+ function heldOutEntries(index, probes, heldOutProbes) {
162
+ const held = new Set(heldOutProbes);
163
+ const owned = new Set();
164
+ for (const probe of probes) {
165
+ if (probe === null || typeof probe !== 'object' || !held.has(probe.probeId)) continue;
166
+ owned.add(`probes/${probe.probeId}.probe.json`);
167
+ owned.add(`corpus/gameability/${probe.probeId}.json`);
168
+ const mutation = probe.qualification?.mutation;
169
+ if (typeof mutation === 'string') owned.add(`mutations/${mutation}.mutation.json`);
170
+ }
171
+ return index
172
+ .filter((entry) => entry !== null && typeof entry === 'object' && typeof entry.path === 'string')
173
+ .filter((entry) => entry.path.startsWith('corpus/held-out/') || owned.has(entry.path))
174
+ .map((entry) => ({ path: entry.path, sha256: entry.sha256 }))
175
+ .sort(byPath);
176
+ }
177
+
178
+ /**
179
+ * eval-quality's `digestArtifact` over the held-out material a run measured: the sorted `heldOutProbes`, the index entries
180
+ * `heldOutEntries` keeps, and the contract a held-out run executes (the held-out view under a `partitionPlan`: the shared steps, the
181
+ * held-out plan's steps and the oracles that view keeps). It reads digests from the index and opens no held-out file itself. It moves
182
+ * when a held-out probe, its seed, its degenerate response, a file under `corpus/held-out/`, the held-out list, a shared step or an
183
+ * oracle the held-out view keeps moves, and stays put when only development material does (a development probe, or a
184
+ * development-only step and the oracles that read it).
185
+ *
186
+ * @param {object} options
187
+ * @param {Array<{ path: string, sha256: string }>} options.index the corpus index
188
+ * @param {Array<object>} options.probes the committed probes, parsed
189
+ * @param {Iterable<string>} options.heldOutProbes
190
+ * @param {object} options.contract the contract a held-out run executes (`loadContractView` with `partition: 'held-out'`)
191
+ * @returns {Promise<string>}
192
+ */
193
+ async function heldOutDigestOf({ index, probes, heldOutProbes, contract }) {
194
+ const engine = await loadEngine();
195
+ const ids = [...new Set(heldOutProbes)].sort();
196
+ return engine.digestArtifact({ heldOutProbes: ids, files: heldOutEntries(index, probes, ids), contract }, HELD_OUT_CONTENT);
197
+ }
198
+
149
199
  /** Whether a path is absent or a regular file (never a directory or a symbolic link). */
150
200
  function isRegularOrAbsent(file) {
151
201
  try {
@@ -228,6 +278,8 @@ module.exports = {
228
278
  buildCorpusIndex,
229
279
  corpusDigestOf,
230
280
  corpusIndexProblem,
281
+ heldOutDigestOf,
282
+ heldOutEntries,
231
283
  unreadPaths,
232
284
  writeCorpusIndex,
233
285
  };
@@ -46,10 +46,9 @@ async function heldRefusal({ held, set, staged, exitCode, stderr }) {
46
46
  return `the call exited ${exitCode} where the verified inputs give ${expected.exitCode} (an in-process score of the held bytes)`;
47
47
  }
48
48
  if (expected.lines !== null && exitCode !== null) {
49
- // The CLI writes each line plus a newline and keeps any newline inside it (a mount path or a key can carry one), so
50
- // both sides go through the same split before the prefixed pieces are compared.
49
+ // Held inputs reproduce single-line diagnostics with caller values escaped as the CLI renders them.
51
50
  const printed = diagnosticLines(stderr);
52
- if (JSON.stringify(printed) !== JSON.stringify(diagnosticLines(expected.lines.map((line) => `${line}\n`).join('')))) {
51
+ if (JSON.stringify(printed) !== JSON.stringify(expected.lines)) {
53
52
  return "the call's eval-quality diagnostics differ from those the verified inputs give (an in-process score of the held bytes)";
54
53
  }
55
54
  }
@@ -97,7 +97,7 @@ const {
97
97
  const { callLabel, causeNote, faultRecord, hostEnvironmentPort, persistableRequest, reasonNote, runArm } = require('./arm');
98
98
  const { observeFrameworks, runCommandEvaluator } = require('./command-evaluator');
99
99
  const { effectiveProbeTimeoutMs, observationProblems, observedVersions, versionsRecord } = require('./frameworks');
100
- const { corpusDigestOf } = require('./corpus-index');
100
+ const { corpusDigestOf, heldOutDigestOf } = require('./corpus-index');
101
101
  const { calibrationObservation, calibrationPartial, calibrationStepPair, readCalibration, runCalibration } = require('./calibration');
102
102
  const { expectedSchemaVersion, loadEngine } = require('./engine');
103
103
  const { evaluateOracles, judgeTrial, oraclesOfBehaviors } = require('./evaluator');
@@ -115,7 +115,7 @@ const { holdDeployment, recordRefusal } = require('./historical');
115
115
  const { JudgeError, answerNonce, judgeConfigurationFor, judgeRubrics, recordedJudgeModel } = require('./judge');
116
116
  const { EvaluatorError, judgmentFromRows, setRecommendationOf, trialRecommendation } = require('./judgment-rows');
117
117
  const { QualificationError, applyReplaceExact } = require('./mutation');
118
- const { bothViewDesignation, committedProbes, selectPartition, unknownPartition } = require('./partition');
118
+ const { bothViewDesignation, committedProbes, loadContractView, selectPartition, unknownPartition } = require('./partition');
119
119
  const { PreflightOutcome, readJson, runPipeline } = require('./preflight');
120
120
  const { importRecords } = require('./records-evaluator');
121
121
  const { evaluatorConfiguration, isolationManifest, sealedRunRecord } = require('./records');
@@ -317,10 +317,22 @@ function runRunCommand(
317
317
  if (!(error instanceof EvaluatorLayerError)) throw error;
318
318
  return new PreflightOutcome({ stage: 'check', exitCode: 10, message: `the evaluation layer cannot be used: ${error.message}` });
319
319
  }
320
+ const index = readJson(path.join(folder, INDEX_PATH));
320
321
  snapshot = {
321
322
  policyBytes: fs.readFileSync(path.join(folder, ...POLICY_PATH.split('/'))),
322
323
  conditions: fs.existsSync(conditionsFile) ? readJson(conditionsFile) : null,
323
- index: readJson(path.join(folder, INDEX_PATH)),
324
+ index,
325
+ // The held-out material this run measures, so `check` can tell when a scored held-out result no longer describes the
326
+ // committed held-out partition. A development run measures none and records none; neither does a run with no held-out probe.
327
+ heldOutDigest:
328
+ partition === 'development' || heldOut.size === 0
329
+ ? null
330
+ : await heldOutDigestOf({
331
+ index,
332
+ probes: probes.map(({ probe }) => probe),
333
+ heldOutProbes: heldOut,
334
+ contract: loadContractView({ folder, evaluation: context.evaluation, partition: 'held-out' }).contract,
335
+ }),
324
336
  probeIds: probes
325
337
  .filter(({ probe }) => selectedProbeIds === null || selectedProbeIds.has(probe.probeId))
326
338
  .map(({ probe }) => probe.probeId),
@@ -2165,6 +2177,7 @@ async function completeRun(
2165
2177
  evaluatorConfigurationDigest: configurationDigest,
2166
2178
  partition: snapshot.partition,
2167
2179
  heldOutProbes: snapshot.heldOutProbes,
2180
+ ...(snapshot.heldOutDigest === null ? {} : { heldOutDigest: snapshot.heldOutDigest }),
2168
2181
  operationPhases: snapshot.operationPhases,
2169
2182
  runner: registry.entries.map((entry) => runnerOf(entry, registry)),
2170
2183
  evaluator: evaluatorRecord,
@@ -175,6 +175,19 @@
175
175
  "uniqueItems": true,
176
176
  "items": { "type": "string", "pattern": "^P-[0-9]{3,}$" }
177
177
  },
178
+ "heldOutCoverageExclusions": {
179
+ "description": "For an evaluation with a partial held-out set, map each material or critical behavior outside the held-out scope to its reason.",
180
+ "type": "object",
181
+ "propertyNames": { "pattern": "^B-[0-9]{3,}$" },
182
+ "additionalProperties": { "type": "string", "pattern": "\\S" }
183
+ },
184
+ "mandatoryActionBehaviors": {
185
+ "description": "Behaviors whose required action must be proven to happen, each a contract behavior ID. Optional and additive: absent, check holds nothing more. Declared, tea-evaluate check requires, for every listed behavior, a zero-action defect probe: probeClass zero-action, expectedClean false and a defect on that behavior, so a target that skips the action is caught.",
186
+ "type": "array",
187
+ "minItems": 1,
188
+ "uniqueItems": true,
189
+ "items": { "type": "string", "pattern": "^B-[0-9]{3,}$" }
190
+ },
178
191
  "partitionPlan": {
179
192
  "description": "Isolates interaction plan steps by evaluation partition (Story 1.51, AD-9, AD-22). Absent, every partition runs the whole contract.json plan. Declared, the development partition runs contract.json, whose plan holds the shared steps and the development-only ones, and the held-out partition runs the shared steps and the steps and oracles of a sealed held-out plan, so no artifact of one partition carries a request, an observation or an oracle meant only for the other. A command or sealed-brief-agent evaluator reads the mapping of its partition (evaluator/mapping.json's rows that bind what the partition declares, and for the held-out and both views the held-out plan's mappings), and a records evaluator's records name only what the partition declares.",
180
193
  "type": "object",
@@ -48,6 +48,17 @@ const FAULT_EXIT = 5;
48
48
  const USAGE_EXIT = 64;
49
49
  /** Every diagnostic line of the eval-quality CLI starts with this. */
50
50
  const DIAGNOSTIC_PREFIX = 'eval-quality: ';
51
+ const DIAGNOSTIC_SHORT_ESCAPES = { '\n': String.raw`\n`, '\r': String.raw`\r`, '\t': String.raw`\t` };
52
+ // eslint-disable-next-line no-control-regex
53
+ const DIAGNOSTIC_CONTROLS = /[\u0000-\u001F\u007F-\u009F]/gu;
54
+
55
+ /** Match eval-quality's 10.1.1 rendering before comparing an in-process diagnostic with stderr. */
56
+ function diagnosticValue(value) {
57
+ return value.replaceAll(
58
+ DIAGNOSTIC_CONTROLS,
59
+ (character) => DIAGNOSTIC_SHORT_ESCAPES[character] ?? String.raw`\u` + character.codePointAt(0).toString(16).padStart(4, '0'),
60
+ );
61
+ }
51
62
 
52
63
  /** The run directory's files that have one fixed name: the compiled contract, the policy, the preflight verdict and the evaluator configuration. */
53
64
  const RUN_FILES = Object.freeze({
@@ -417,9 +428,9 @@ class HeldInputs {
417
428
  signal: new AbortController().signal,
418
429
  });
419
430
  const lines = qualification.failures.map(
420
- (failure) => `${DIAGNOSTIC_PREFIX}${failure.code}: ${failure.artifactPath}: ${failure.detail}`,
431
+ (failure) => `${DIAGNOSTIC_PREFIX}${failure.code}: ${diagnosticValue(failure.artifactPath)}: ${diagnosticValue(failure.detail)}`,
421
432
  );
422
- if (ladder.verdict === null) lines.push(...ladder.basis.map((reason) => `${DIAGNOSTIC_PREFIX}invalid: ${reason}`));
433
+ if (ladder.verdict === null) lines.push(...ladder.basis.map((reason) => `${DIAGNOSTIC_PREFIX}invalid: ${diagnosticValue(reason)}`));
423
434
  return {
424
435
  artifact: artifact === null ? null : Buffer.from(this.#engine.serializeArtifact(artifact, 'EvidenceArtifact'), 'utf8'),
425
436
  exitCode: ladder.exitCode,