feat: require consistent pair deltas for orchestration claims

Carries forward the 2026-09-29 review request on #2761 with the
contributor's scenario and attribution preserved.

- scenario.json declares a machine-readable pair_consistency_rule:
  per-pair quality, time, and cost deltas (orchestrated minus single
  agent) from retained attempts, no averaging, and an inconclusive
  result when any metric is mixed-sign or unavailable, fewer than three
  pairs ran, or run order never alternated.
- Aggregate cost now covers controller, workers, verifier, and retries,
  matching the master plan's orchestration evidence template.
- Adds synthetic, illustrative sign-consistent and mixed-sign pair
  fixtures; the mixed-sign fixture promotes no candidate.
- The evaluator RAG test recomputes deltas from raw attempts, checks
  cost totals, and exercises unavailable, two-pair, fixed-order, and
  reversed-pair rejections.

Co-authored-by: phelan <2509508+Phelan164@users.noreply.github.com>
This commit is contained in:
haelyraandphelan committed 2026-11-16 21:03:22 -05:00
1 parent 10de39d41b
commit 83c4fa1e94
9 files changed
+599 -17

No files matched your search

+6 -3
View File
@@ -24,9 +24,10 @@ amendment can be promoted. A deep-analyzer evidence scenario requires analyzer
corpus cases, expected-output comparisons, and risk-taxonomy proof before
repository or commit-analysis behavior can change.
In an orchestration-efficiency evidence scenario, single-agent controls must be
matched, and aggregate controller and worker cost, accepted quality,
coordination costs, and sequential paired replications are required before
parallelism is called faster or cheaper.
matched, and aggregate controller, worker, verifier, and retry cost, accepted
quality, coordination costs, and sequential paired replications are required
before parallelism is called faster or cheaper. Per-pair deltas that are
mixed-sign or unavailable make the result inconclusive and block the claim.
## Reference Pressure
@@ -130,6 +131,8 @@ Current corpus:
matched single-agent controls, common acceptance gates, aggregate worker
costs, retained failures and coordination overhead, and repeated sequential
pairs before an orchestration-efficiency recommendation can be promoted.
Per-pair quality, time, and cost deltas must keep one sign across every pair;
otherwise the result is `inconclusive` and no candidate is promoted.
- `connector-diagnostics-gap`: inventories an already-used connector, separates
observed gaps from unavailable research, and requires evidence before a new
@@ -23,13 +23,37 @@ agent.
6. Record per candidate:
- acceptance and evidence completeness;
- elapsed time;
- total tokens or cost across controller, every worker, and retries;
- total tokens or cost across controller, every worker, the verifier, and
retries;
- worker count and ownership;
- conflicts, integration rework, retries, and human corrections.
7. Write `unavailable` for telemetry the harness does not expose. Never estimate
missing totals.
8. Repeat at least three fresh pairs before recommending a task-class boundary.
Report raw receipts before interpretation.
9. Compute each pair's quality, time, and cost delta (orchestrated minus
single agent) from the retained attempts, then apply the pair consistency
rule below.
## Pair Consistency Rule
The machine-readable rule is `pair_consistency_rule` in `scenario.json`.
- A metric has a direction only when every pair reports an available delta and
all deltas share one nonzero sign, or all are zero (`no_difference`).
- Never average pair deltas. With three pairs, one reversed pair means the
metric is `inconclusive`, even when the mean points one way.
- The result is `consistent` only when at least three pairs ran, both run orders
occur, and every metric has a direction. Otherwise it is `inconclusive`.
- An `inconclusive` result blocks every task-class claim and promotes no
candidate. Keep the raw attempts and run more fresh pairs if the decision
still matters.
- A `consistent` claim names its task class and every metric direction,
including higher cost or lower quality.
`pairs-sign-consistent.json` shows an accepted, task-class-scoped claim.
`pairs-mixed-sign.json` shows a reversed time delta that blocks the claim. Both
use synthetic, illustrative attempts rather than executed runs.
## Rejected Path
@@ -45,6 +69,8 @@ conflicts and integration work outside the result.
Do not publish a general claim from one pair, overlapping variants, fixed run
order, or unavailable aggregate telemetry.
Do not average opposite-sign or unavailable pair deltas into a recommendation.
## Minimum Validation
- `node tests/lib/orchestration-session.test.js`
@@ -52,6 +78,9 @@ order, or unavailable aggregate telemetry.
- Raw run receipts containing all controlled fields and coordination costs
- `git diff --check`
- At least three sequential pairs with alternated order before a general claim
- Per-pair quality, time, and cost deltas with a `consistent` result before any
task-class claim
- `node tests/docs/evaluator-rag-prototype.test.js`
Record the evidence source and attribution when an external experiment informs
the scenario. Keep publication, agent launch, candidate edits, and repository
@@ -0,0 +1,180 @@
{
"schema_version": "ecc.evaluator-rag.verifier.v1",
"scenario_id": "orchestration-efficiency-evidence",
"run_id": "illustrative-mixed-sign-pairs",
"read_only": true,
"illustrative": true,
"evaluation_status": "illustrative_synthetic_attempts_not_executed_runs",
"task_class": "parallel repairs across shared test helpers",
"raw_attempts": [
{
"attempt_id": "pair-1-single_agent",
"pair": 1,
"variant": "single_agent",
"run_order": 1,
"accepted": true,
"quality_score": 1,
"elapsed_ms": 900000,
"cost_breakdown_usd": {
"controller": 1.2,
"workers": 0,
"verifier": 0.1,
"retries": 0
},
"total_cost_usd": 1.3,
"worker_count": 1,
"conflicts": 0,
"integration_rework": 0,
"human_corrections": 0
},
{
"attempt_id": "pair-1-orchestrated",
"pair": 1,
"variant": "orchestrated",
"run_order": 2,
"accepted": true,
"quality_score": 1,
"elapsed_ms": 660000,
"cost_breakdown_usd": {
"controller": 0.4,
"workers": 1.3,
"verifier": 0.1,
"retries": 0
},
"total_cost_usd": 1.8,
"worker_count": 3,
"conflicts": 0,
"integration_rework": 0,
"human_corrections": 0
},
{
"attempt_id": "pair-2-orchestrated",
"pair": 2,
"variant": "orchestrated",
"run_order": 1,
"accepted": true,
"quality_score": 1,
"elapsed_ms": 1080000,
"cost_breakdown_usd": {
"controller": 0.45,
"workers": 1.5,
"verifier": 0.1,
"retries": 0.35
},
"total_cost_usd": 2.4,
"worker_count": 3,
"conflicts": 1,
"integration_rework": 1,
"human_corrections": 0
},
{
"attempt_id": "pair-2-single_agent",
"pair": 2,
"variant": "single_agent",
"run_order": 2,
"accepted": true,
"quality_score": 1,
"elapsed_ms": 900000,
"cost_breakdown_usd": {
"controller": 1.25,
"workers": 0,
"verifier": 0.1,
"retries": 0
},
"total_cost_usd": 1.35,
"worker_count": 1,
"conflicts": 0,
"integration_rework": 0,
"human_corrections": 0
},
{
"attempt_id": "pair-3-single_agent",
"pair": 3,
"variant": "single_agent",
"run_order": 1,
"accepted": true,
"quality_score": 1,
"elapsed_ms": 960000,
"cost_breakdown_usd": {
"controller": 1.3,
"workers": 0,
"verifier": 0.1,
"retries": 0
},
"total_cost_usd": 1.4,
"worker_count": 1,
"conflicts": 0,
"integration_rework": 0,
"human_corrections": 0
},
{
"attempt_id": "pair-3-orchestrated",
"pair": 3,
"variant": "orchestrated",
"run_order": 2,
"accepted": true,
"quality_score": 1,
"elapsed_ms": 900000,
"cost_breakdown_usd": {
"controller": 0.4,
"workers": 1.2,
"verifier": 0.1,
"retries": 0
},
"total_cost_usd": 1.7,
"worker_count": 3,
"conflicts": 0,
"integration_rework": 0,
"human_corrections": 0
}
],
"pair_deltas": [
{
"pair": 1,
"order": "single_agent_first",
"quality_delta": 0,
"time_delta_ms": -240000,
"cost_delta_usd": 0.5
},
{
"pair": 2,
"order": "orchestrated_first",
"quality_delta": 0,
"time_delta_ms": 180000,
"cost_delta_usd": 1.05
},
{
"pair": 3,
"order": "single_agent_first",
"quality_delta": 0,
"time_delta_ms": -60000,
"cost_delta_usd": 0.3
}
],
"metric_directions": {
"quality": "no_difference",
"time": "inconclusive",
"cost": "single_agent_better"
},
"result": "inconclusive",
"rejected_aggregate": {
"statistic": "mean_time_delta_ms",
"value": -40000,
"why_rejected": "a mean of opposite-sign pair deltas hides that one of three pairs reversed direction"
},
"candidates": [
{
"candidate_id": "task-class-direction-claim",
"decision": "not_promoted",
"claim": null,
"reasons": [
"pair 2 reverses the time direction of pairs 1 and 3, so time has no direction",
"averaging the three time deltas would suggest orchestration is faster, which the pair evidence does not support",
"pair 2 retains its edit conflict, integration rework, and retry cost instead of dropping it as an outlier",
"an inconclusive result blocks any task-class claim, including the cost direction that is consistent"
],
"rollback": "Make no claim; keep every raw attempt and run more fresh alternated pairs if the decision still matters."
}
],
"promoted_candidate_id": null
}
@@ -0,0 +1,175 @@
{
"schema_version": "ecc.evaluator-rag.verifier.v1",
"scenario_id": "orchestration-efficiency-evidence",
"run_id": "illustrative-sign-consistent-pairs",
"read_only": true,
"illustrative": true,
"evaluation_status": "illustrative_synthetic_attempts_not_executed_runs",
"task_class": "independent documentation updates with disjoint file ownership",
"raw_attempts": [
{
"attempt_id": "pair-1-single_agent",
"pair": 1,
"variant": "single_agent",
"run_order": 1,
"accepted": true,
"quality_score": 1,
"elapsed_ms": 1200000,
"cost_breakdown_usd": {
"controller": 1.5,
"workers": 0,
"verifier": 0.1,
"retries": 0
},
"total_cost_usd": 1.6,
"worker_count": 1,
"conflicts": 0,
"integration_rework": 0,
"human_corrections": 0
},
{
"attempt_id": "pair-1-orchestrated",
"pair": 1,
"variant": "orchestrated",
"run_order": 2,
"accepted": true,
"quality_score": 1,
"elapsed_ms": 720000,
"cost_breakdown_usd": {
"controller": 0.5,
"workers": 1.4,
"verifier": 0.1,
"retries": 0
},
"total_cost_usd": 2.0,
"worker_count": 3,
"conflicts": 0,
"integration_rework": 0,
"human_corrections": 0
},
{
"attempt_id": "pair-2-orchestrated",
"pair": 2,
"variant": "orchestrated",
"run_order": 1,
"accepted": true,
"quality_score": 1,
"elapsed_ms": 780000,
"cost_breakdown_usd": {
"controller": 0.5,
"workers": 1.5,
"verifier": 0.1,
"retries": 0
},
"total_cost_usd": 2.1,
"worker_count": 3,
"conflicts": 0,
"integration_rework": 0,
"human_corrections": 0
},
{
"attempt_id": "pair-2-single_agent",
"pair": 2,
"variant": "single_agent",
"run_order": 2,
"accepted": true,
"quality_score": 1,
"elapsed_ms": 1140000,
"cost_breakdown_usd": {
"controller": 1.45,
"workers": 0,
"verifier": 0.1,
"retries": 0
},
"total_cost_usd": 1.55,
"worker_count": 1,
"conflicts": 0,
"integration_rework": 0,
"human_corrections": 0
},
{
"attempt_id": "pair-3-single_agent",
"pair": 3,
"variant": "single_agent",
"run_order": 1,
"accepted": true,
"quality_score": 1,
"elapsed_ms": 1260000,
"cost_breakdown_usd": {
"controller": 1.55,
"workers": 0,
"verifier": 0.1,
"retries": 0
},
"total_cost_usd": 1.65,
"worker_count": 1,
"conflicts": 0,
"integration_rework": 0,
"human_corrections": 0
},
{
"attempt_id": "pair-3-orchestrated",
"pair": 3,
"variant": "orchestrated",
"run_order": 2,
"accepted": true,
"quality_score": 1,
"elapsed_ms": 810000,
"cost_breakdown_usd": {
"controller": 0.55,
"workers": 1.45,
"verifier": 0.1,
"retries": 0
},
"total_cost_usd": 2.1,
"worker_count": 3,
"conflicts": 0,
"integration_rework": 0,
"human_corrections": 0
}
],
"pair_deltas": [
{
"pair": 1,
"order": "single_agent_first",
"quality_delta": 0,
"time_delta_ms": -480000,
"cost_delta_usd": 0.4
},
{
"pair": 2,
"order": "orchestrated_first",
"quality_delta": 0,
"time_delta_ms": -360000,
"cost_delta_usd": 0.55
},
{
"pair": 3,
"order": "single_agent_first",
"quality_delta": 0,
"time_delta_ms": -450000,
"cost_delta_usd": 0.45
}
],
"metric_directions": {
"quality": "no_difference",
"time": "orchestrated_better",
"cost": "single_agent_better"
},
"result": "consistent",
"candidates": [
{
"candidate_id": "task-class-direction-claim",
"decision": "accepted",
"claim": "For this task class only, orchestration finished faster in all three pairs and cost more in all three pairs, with no quality difference.",
"reasons": [
"every pair reports available quality, time, and cost deltas from retained attempts",
"time and cost deltas keep one sign across all three pairs and quality deltas are all zero",
"both run orders occur, so a fixed-order effect cannot explain the direction",
"the claim states the higher aggregate cost instead of reporting only the faster time"
],
"rollback": "Withdraw the claim and keep every raw attempt if a later pair reverses any metric direction."
}
],
"promoted_candidate_id": "task-class-direction-claim"
}
@@ -31,10 +31,23 @@
"id": "replication-before-recommendation",
"severity": "warning",
"summary": "One pair, overlapping variants, or fixed run order can qualify a harness but cannot establish a general orchestration efficiency boundary."
},
{
"id": "pair-consistency-before-direction",
"severity": "warning",
"summary": "With three pairs, one reversed pair delta makes that metric inconclusive; averaging opposite-sign deltas would publish a direction the evidence does not support."
}
],
"recommended_next_action": {
"candidate_id": "controlled-paired-orchestration-evaluation",
"action": "Use the promoted playbook to design sequential paired runs, preserve every attempt, and recommend orchestration only for task classes where accepted quality and measured coordination cost justify it."
},
"evidence_coverage": {
"kind": "synthetic_fixture_only",
"pair_fixtures": [
"pairs-sign-consistent.json",
"pairs-mixed-sign.json"
],
"executed_runs": 0
}
}
@@ -35,15 +35,17 @@
"Which task dependencies and exclusive write surfaces justify multiple workers?",
"Were the single-agent and orchestrated candidates run from the same task, revision, model, reasoning effort, permissions, tools, time limit, and evaluator?",
"Did every attempted candidate meet the same acceptance and evidence-quality gates?",
"What were total tokens or cost across the controller and all workers, elapsed time, retries, conflicts, integration rework, and human corrections?",
"What were total tokens or cost across the controller, all workers, the verifier, and retries, plus elapsed time, conflicts, integration rework, and human corrections?",
"Were failures and unavailable telemetry retained rather than estimated or excluded?",
"How many sequential paired runs and alternated run orders support the recommendation?"
"How many sequential paired runs and alternated run orders support the recommendation?",
"What were each pair's quality, time, and cost deltas, and do they point the same direction across every pair?"
],
"forbidden_actions": [
"claiming that parallel agents are faster or cheaper without a matched accepted single-agent baseline",
"comparing candidates with different tasks, revisions, models, reasoning effort, permissions, tools, time limits, or evaluators",
"reporting controller-only tokens or cost while omitting worker totals",
"excluding failed candidates, edit conflicts, integration rework, retries, or human corrections",
"averaging opposite-sign or unavailable pair deltas into a task-class recommendation",
"estimating unavailable telemetry or turning one overlapping smoke run into a general efficiency claim",
"launching workers, editing candidate repositories, publishing benchmarks, or posting announcements from this read-only evaluator run"
],
@@ -51,10 +53,54 @@
"dependency graph and exclusive ownership boundaries are recorded",
"single-agent and orchestrated controls are matched",
"all attempted candidates use the same acceptance evaluator",
"aggregate controller and worker cost is recorded or explicitly unavailable",
"aggregate controller, worker, verifier, and retry cost is recorded or explicitly unavailable",
"elapsed time, retries, conflicts, integration rework, and human corrections are retained",
"failed candidates remain in the comparison",
"at least three fresh sequential pairs with alternated order are completed before promotion",
"every raw attempt is retained and each pair reports quality, time, and cost deltas computed from those attempts",
"mixed-sign or unavailable pair deltas yield an inconclusive result that blocks any task-class claim",
"at least one one-run parallelism claim is rejected"
]
],
"pair_consistency_rule": {
"delta_definition": "orchestrated minus single_agent for the same pair, computed from the retained raw attempts",
"minimum_pairs": 3,
"required_orders": [
"single_agent_first",
"orchestrated_first"
],
"unavailable_value": "unavailable",
"metrics": [
{
"name": "quality",
"attempt_field": "quality_score",
"delta_field": "quality_delta",
"better_when": "higher"
},
{
"name": "time",
"attempt_field": "elapsed_ms",
"delta_field": "time_delta_ms",
"better_when": "lower"
},
{
"name": "cost",
"attempt_field": "total_cost_usd",
"delta_field": "cost_delta_usd",
"better_when": "lower"
}
],
"aggregate_cost_components": [
"controller",
"workers",
"verifier",
"retries"
],
"metric_direction": "A metric has a direction only when every pair reports an available delta and all deltas are nonzero with the same sign, or all deltas are zero (no_difference). Any other pattern is inconclusive; deltas are never averaged.",
"result": "consistent only when the minimum pair count is met, both run orders occur, and every metric has a direction; otherwise inconclusive",
"claim_allowed_only_if": "result is consistent; the claim names its task class and every metric direction, including any cost or quality loss",
"fixtures": [
"pairs-sign-consistent.json",
"pairs-mixed-sign.json"
]
}
}
@@ -31,9 +31,11 @@
},
{
"phase": "verification",
"summary": "Accepted the controlled paired evaluation because it matches controls, evaluates quality first, aggregates worker cost, and keeps negative results. Rejected the intuition-only claim because it relies on one overlapping run with unavailable token totals.",
"summary": "Accepted the controlled paired evaluation because it matches controls, evaluates quality first, aggregates worker cost, and keeps negative results. Rejected the intuition-only claim because it relies on one overlapping run with unavailable token totals. Applied the pair consistency rule: the sign-consistent fixture permits only a task-class-scoped claim, and the mixed-sign fixture returns inconclusive with no promoted claim.",
"evidence": [
"examples/evaluator-rag-prototype/orchestration-efficiency-evidence/verifier-result.json"
"examples/evaluator-rag-prototype/orchestration-efficiency-evidence/verifier-result.json",
"examples/evaluator-rag-prototype/orchestration-efficiency-evidence/pairs-sign-consistent.json",
"examples/evaluator-rag-prototype/orchestration-efficiency-evidence/pairs-mixed-sign.json"
]
},
{
@@ -12,9 +12,10 @@
"records a dependency graph and exclusive write ownership before delegation",
"matches task, revision, model, reasoning effort, permissions, tools, time limit, and evaluator",
"requires acceptance and evidence quality before comparing elapsed time or cost",
"aggregates controller, worker, and retry tokens or cost and marks unavailable telemetry honestly",
"aggregates controller, worker, verifier, and retry tokens or cost and marks unavailable telemetry honestly",
"retains failed candidates, conflicts, integration rework, retries, and human corrections",
"requires repeated sequential pairs and alternated run order before a general recommendation"
"requires repeated sequential pairs and alternated run order before a general recommendation",
"derives per-pair quality, time, and cost deltas from retained attempts and returns inconclusive when any metric is mixed-sign or unavailable"
],
"rollback": "Withdraw the recommendation and retain the raw run receipts if later replications reverse the result; this read-only playbook launches no workers and changes no candidate repository."
},
@@ -27,7 +28,8 @@
"has no matched accepted single-agent baseline",
"reports no aggregate worker token or cost total",
"ignores overlap, machine contention, conflicts, integration rework, and failed attempts",
"turns one smoke run with unavailable telemetry into a general efficiency claim"
"turns one smoke run with unavailable telemetry into a general efficiency claim",
"would average opposite-sign pair results into one direction"
],
"rollback": "Do not publish the claim; restart from matched controls, acceptance evidence, complete run receipts, and sequential paired replications."
}
+136 -4
View File
@@ -428,7 +428,8 @@ test('orchestration efficiency scenario rejects intuition-only parallelism claim
'claiming that parallel agents are faster or cheaper without a matched accepted single-agent baseline',
'reporting controller-only tokens or cost while omitting worker totals',
'excluding failed candidates, edit conflicts, integration rework, retries, or human corrections',
'estimating unavailable telemetry or turning one overlapping smoke run into a general efficiency claim'
'estimating unavailable telemetry or turning one overlapping smoke run into a general efficiency claim',
'averaging opposite-sign or unavailable pair deltas into a task-class recommendation'
]) {
assert.ok(scenario.forbidden_actions.includes(blocked), `Missing orchestration forbidden action: ${blocked}`);
}
@@ -437,9 +438,11 @@ test('orchestration efficiency scenario rejects intuition-only parallelism claim
'dependency graph and exclusive ownership boundaries are recorded',
'single-agent and orchestrated controls are matched',
'all attempted candidates use the same acceptance evaluator',
'aggregate controller and worker cost is recorded or explicitly unavailable',
'aggregate controller, worker, verifier, and retry cost is recorded or explicitly unavailable',
'failed candidates remain in the comparison',
'at least three fresh sequential pairs with alternated order are completed before promotion'
'at least three fresh sequential pairs with alternated order are completed before promotion',
'every raw attempt is retained and each pair reports quality, time, and cost deltas computed from those attempts',
'mixed-sign or unavailable pair deltas yield an inconclusive result that blocks any task-class claim'
]) {
assert.ok(scenario.acceptance_gates.includes(required), `Missing orchestration acceptance gate: ${required}`);
}
@@ -459,10 +462,139 @@ test('orchestration efficiency scenario rejects intuition-only parallelism claim
assert.ok(externalExperiment, 'Missing external orchestration experiment source');
assert.ok(retrieval, 'Missing orchestration retrieval trace event');
assert.ok(retrieval.evidence.includes(externalExperiment.url));
assert.ok(playbook.includes('total tokens or cost across controller, every worker, and retries'));
assert.ok(playbook.includes('total tokens or cost across controller, every worker, the verifier, and'));
assert.ok(playbook.includes('At least three sequential pairs with alternated order'));
});
const ORCHESTRATION_ROOT = 'orchestration-efficiency-evidence/';
function roundDelta(value) {
return Math.round(value * 1e6) / 1e6;
}
function metricDirection(metric, deltas) {
if (deltas.some(delta => typeof delta !== 'number')) return 'inconclusive';
if (deltas.every(delta => delta === 0)) return 'no_difference';
const orchestratedHigher = deltas.every(delta => delta > 0);
const orchestratedLower = deltas.every(delta => delta < 0);
if (!orchestratedHigher && !orchestratedLower) return 'inconclusive';
return orchestratedHigher === (metric.better_when === 'higher') ? 'orchestrated_better' : 'single_agent_better';
}
function evaluatePairEvidence(rule, attempts) {
const pairIds = [...new Set(attempts.map(attempt => attempt.pair))].sort((a, b) => a - b);
const pairDeltas = pairIds.map(pair => {
const single = attempts.find(attempt => attempt.pair === pair && attempt.variant === 'single_agent');
const orchestrated = attempts.find(attempt => attempt.pair === pair && attempt.variant === 'orchestrated');
assert.ok(single && orchestrated, `Pair ${pair} must retain both raw attempts`);
const delta = { pair, order: single.run_order === 1 ? 'single_agent_first' : 'orchestrated_first' };
for (const metric of rule.metrics) {
const orchestratedValue = orchestrated[metric.attempt_field];
const singleValue = single[metric.attempt_field];
delta[metric.delta_field] = typeof orchestratedValue === 'number' && typeof singleValue === 'number'
? roundDelta(orchestratedValue - singleValue)
: rule.unavailable_value;
}
return delta;
});
const metricDirections = Object.fromEntries(rule.metrics.map(metric => [
metric.name,
metricDirection(metric, pairDeltas.map(delta => delta[metric.delta_field]))
]));
const bothOrders = rule.required_orders.every(order => pairDeltas.some(delta => delta.order === order));
const consistent = pairDeltas.length >= rule.minimum_pairs
&& bothOrders
&& Object.values(metricDirections).every(direction => direction !== 'inconclusive');
return { pair_deltas: pairDeltas, metric_directions: metricDirections, result: consistent ? 'consistent' : 'inconclusive' };
}
test('orchestration pair fixtures derive recorded deltas from retained raw attempts', () => {
const scenario = readFixtureJson(`${ORCHESTRATION_ROOT}scenario.json`);
const rule = scenario.pair_consistency_rule;
assert.ok(rule, 'Missing machine-readable pair consistency rule');
assert.strictEqual(rule.minimum_pairs, 3);
assert.deepStrictEqual(rule.metrics.map(metric => metric.name), ['quality', 'time', 'cost']);
assert.deepStrictEqual(rule.aggregate_cost_components, ['controller', 'workers', 'verifier', 'retries']);
assert.ok(rule.metric_direction.includes('deltas are never averaged'));
for (const fixture of rule.fixtures) {
const evidence = readFixtureJson(`${ORCHESTRATION_ROOT}${fixture}`);
assert.strictEqual(evidence.scenario_id, scenario.scenario_id);
assert.strictEqual(evidence.read_only, true);
assert.strictEqual(evidence.illustrative, true);
assert.strictEqual(evidence.evaluation_status, 'illustrative_synthetic_attempts_not_executed_runs');
assert.strictEqual(evidence.raw_attempts.length, evidence.pair_deltas.length * 2, `${fixture} dropped raw attempts`);
for (const attempt of evidence.raw_attempts) {
assert.deepStrictEqual(Object.keys(attempt.cost_breakdown_usd), rule.aggregate_cost_components);
const total = Object.values(attempt.cost_breakdown_usd).reduce((sum, value) => sum + value, 0);
assert.strictEqual(roundDelta(total), attempt.total_cost_usd, `${attempt.attempt_id} total omits a cost component`);
}
const derived = evaluatePairEvidence(rule, evidence.raw_attempts);
assert.deepStrictEqual(evidence.pair_deltas, derived.pair_deltas, `${fixture} pair deltas do not match raw attempts`);
assert.deepStrictEqual(evidence.metric_directions, derived.metric_directions);
assert.strictEqual(evidence.result, derived.result);
}
});
test('mixed-sign orchestration pairs are inconclusive and promote no candidate', () => {
const evidence = readFixtureJson(`${ORCHESTRATION_ROOT}pairs-mixed-sign.json`);
const timeDeltas = evidence.pair_deltas.map(delta => delta.time_delta_ms);
const meanTimeDelta = timeDeltas.reduce((sum, value) => sum + value, 0) / timeDeltas.length;
assert.ok(timeDeltas.some(delta => delta > 0) && timeDeltas.some(delta => delta < 0), 'Fixture must contain opposite-sign time deltas');
assert.ok(meanTimeDelta < 0, 'Fixture must show that averaging would suggest a misleading direction');
assert.strictEqual(evidence.rejected_aggregate.value, meanTimeDelta);
assert.strictEqual(evidence.metric_directions.time, 'inconclusive');
assert.strictEqual(evidence.metric_directions.cost, 'single_agent_better');
assert.strictEqual(evidence.result, 'inconclusive');
assert.strictEqual(evidence.promoted_candidate_id, null);
assert.ok(evidence.candidates.every(candidate => candidate.decision !== 'accepted'));
assert.strictEqual(evidence.candidates[0].claim, null);
const reversedPair = evidence.raw_attempts.find(attempt => attempt.attempt_id === 'pair-2-orchestrated');
assert.ok(reversedPair.conflicts > 0 && reversedPair.cost_breakdown_usd.retries > 0, 'Reversed pair must keep its coordination cost');
});
test('sign-consistent orchestration pairs allow only a task-class-scoped claim', () => {
const evidence = readFixtureJson(`${ORCHESTRATION_ROOT}pairs-sign-consistent.json`);
const accepted = evidence.candidates.find(candidate => candidate.decision === 'accepted');
assert.strictEqual(evidence.result, 'consistent');
assert.deepStrictEqual(evidence.metric_directions, {
quality: 'no_difference', time: 'orchestrated_better', cost: 'single_agent_better'
});
assert.ok(accepted, 'Missing accepted task-class claim');
assert.strictEqual(evidence.promoted_candidate_id, accepted.candidate_id);
assert.ok(accepted.claim.startsWith('For this task class only'));
assert.ok(accepted.claim.includes('cost more'), 'Claim must disclose the higher aggregate cost');
});
test('unavailable, too few, or fixed-order orchestration pairs are inconclusive', () => {
const rule = readFixtureJson(`${ORCHESTRATION_ROOT}scenario.json`).pair_consistency_rule;
const { raw_attempts: attempts } = readFixtureJson(`${ORCHESTRATION_ROOT}pairs-sign-consistent.json`);
assert.strictEqual(evaluatePairEvidence(rule, attempts).result, 'consistent');
const unavailableCost = attempts.map(attempt => (attempt.attempt_id === 'pair-2-orchestrated'
? { ...attempt, total_cost_usd: rule.unavailable_value }
: attempt));
const unavailable = evaluatePairEvidence(rule, unavailableCost);
assert.strictEqual(unavailable.pair_deltas[1].cost_delta_usd, rule.unavailable_value);
assert.strictEqual(unavailable.metric_directions.cost, 'inconclusive');
assert.strictEqual(unavailable.result, 'inconclusive');
const twoPairs = evaluatePairEvidence(rule, attempts.filter(attempt => attempt.pair !== 3));
assert.strictEqual(twoPairs.result, 'inconclusive');
const fixedOrder = attempts.map(attempt => ({ ...attempt, run_order: attempt.variant === 'single_agent' ? 1 : 2 }));
assert.strictEqual(evaluatePairEvidence(rule, fixedOrder).result, 'inconclusive');
const reversedTime = attempts.map(attempt => (attempt.attempt_id === 'pair-3-orchestrated'
? { ...attempt, elapsed_ms: 1500000 }
: attempt));
const reversed = evaluatePairEvidence(rule, reversedTime);
assert.strictEqual(reversed.metric_directions.time, 'inconclusive');
assert.strictEqual(reversed.result, 'inconclusive');
});
test('connector gap artifacts share identity and preserve read-only scope', () => {
const scenario = readFixtureJson('connector-diagnostics-gap/scenario.json');
assert.strictEqual(scenario.scenario_id, 'connector-diagnostics-gap');