B1 pre-registration Accepted (D1-D5; D4 with the no-tuning rule); cost proxies over all runs, safety metric renamed
This commit is contained in:
1 parent
035ea19834
commit
6366d6c014
6 files changed
+134
-29
No files matched your search
@@ -1,6 +1,6 @@
|
|||||||
# B1: the first held-out benchmark after Phase 5 (pre-registration)
|
# B1: the first held-out benchmark after Phase 5 (pre-registration)
|
||||||
|
|
||||||
Status: **Proposed.** Accepted by the owner before the benchmark author starts. Frozen at `ajieval freeze`. After that nothing in this document changes until the last run.
|
Status: **Accepted** (owner, 2026-10-06). D1–D5 were decided as recorded at the end; D4 carries the no-tuning rule. Frozen at `ajieval freeze`. After that nothing in this document changes until the last run.
|
||||||
Decision context: owner, 2026-10-06. Phase 5 is closed. Phases 7 and 8 are on **hold** until B1 is analyzed.
|
Decision context: owner, 2026-10-06. Phase 5 is closed. Phases 7 and 8 are on **hold** until B1 is analyzed.
|
||||||
|
|
||||||
```text
|
```text
|
||||||
@@ -11,14 +11,14 @@ Phase 5 exit → B1 (this document) → analysis H1/H2/H4/H5 → decision: Phase
|
|||||||
|
|
||||||
1. Does Aji/source raise verified success over Rust and Zig on systems tasks that load ownership, concurrency and atomics (H1)?
|
1. Does Aji/source raise verified success over Rust and Zig on systems tasks that load ownership, concurrency and atomics (H1)?
|
||||||
2. Does it reduce repair work (H2)?
|
2. Does it reduce repair work (H2)?
|
||||||
3. How does success degrade from the strongest to the weakest agent stack in each language? The question is whether the degradation curve is flatter for Aji: the shape of degradation, not only the end points (H4).
|
3. How does success degrade from the strongest to the weakest agent stack in each language? The question is whether the degradation curve is flatter for Aji: the shape of degradation, not only the end points. B1 measures this as a **stack-level capability compression signal**, not as evidence for H4 (D1).
|
||||||
4. What does a correct solution cost in tokens and time (H5 proxies; see D5)?
|
4. What does a correct solution cost in tokens and time? Proxies only: H5 is not tested in B1 (D5).
|
||||||
|
|
||||||
## 2. Design
|
## 2. Design
|
||||||
|
|
||||||
| Variable | Values |
|
| Variable | Values |
|
||||||
|---|---|
|
|---|---|
|
||||||
| Language (condition) | Rust, Zig, Aji/source. Aji/AIR is not in the main matrix (D2). |
|
| Language (condition) | Rust, Zig, Aji/source. Aji/AIR is excluded (D2); a later diagnostic AIR experiment would not be part of B1. |
|
||||||
| Agent stack (Track B, native agents) | N1 Codex + `gpt-6.1-sol` (high), N2 Claude Code + `claude-opus-5-5` (high), N3 OpenCode + `zai-coding-plan/glm-5.3-flash`, configured as in P6A-9 |
|
| Agent stack (Track B, native agents) | N1 Codex + `gpt-6.1-sol` (high), N2 Claude Code + `claude-opus-5-5` (high), N3 OpenCode + `zai-coding-plan/glm-5.3-flash`, configured as in P6A-9 |
|
||||||
| Task | 6 private held-out tasks, 2 per family (§3) |
|
| Task | 6 private held-out tasks, 2 per family (§3) |
|
||||||
| Repetition | 3 independent runs per cell |
|
| Repetition | 3 independent runs per cell |
|
||||||
@@ -68,7 +68,35 @@ Each task must be solvable in Rust, Zig and Aji/source. More than one implementa
|
|||||||
| medium | the weakest stack understands the task and writes a program, but systems errors (ownership, races, orderings, resource paths) are common in at least one language |
|
| medium | the weakest stack understands the task and writes a program, but systems errors (ownership, races, orderings, resource paths) are common in at least one language |
|
||||||
| hard | beyond the weakest stack |
|
| hard | beyond the weakest stack |
|
||||||
|
|
||||||
**H4 is tested on the medium level.** A task on which the weakest stack spends its whole budget reasoning and writes no program measures nothing about the language; task C in P6A-9 showed this. Distribution: 1 easy, 4 medium, 1 hard, with at least one medium task per family (D3). Calibration: D4.
|
The stack-level signal is measured on the medium level. A task on which the weakest stack spends its whole budget reasoning and writes no program measures nothing about the language; task C in P6A-9 showed this.
|
||||||
|
|
||||||
|
**Distribution (D3).**
|
||||||
|
|
||||||
|
- 6 tasks, 2 per family: A × 2, B × 2, C × 2.
|
||||||
|
- 1 easy, 4 medium and 1 hard.
|
||||||
|
- Every family has at least one medium task, so the easy and the hard task are never in the same family.
|
||||||
|
- The author assigns each task its **target band** before any pilot.
|
||||||
|
|
||||||
|
**Calibration (D4).** Every candidate task gets one pilot run per agent stack in **each** of the three languages: 9 runs per task, 54 for six tasks. A task is kept only if its pilot fits its target band under these language-symmetric rules, fixed now. "Strong" means N1 and N2, "weak" means N3, and "succeeds" means the evaluator accepts.
|
||||||
|
|
||||||
|
| Band | Rule |
|
||||||
|
|---|---|
|
||||||
|
| EASY | the strong stacks pass in ≥ 5 of their 6 language cells, AND the weak stack succeeds in ≥ 2 of 3 languages |
|
||||||
|
| MEDIUM | each strong stack succeeds in ≥ 2 of 3 languages, AND the weak stack succeeds in 1 or 2 of 3 languages, AND the weak stack produces code in all three languages |
|
||||||
|
| HARD | each strong stack succeeds in ≥ 2 of 3 languages, AND the weak stack succeeds in 0 of 3, AND in every language it produced a substantive implementation: a source file, and at least one compiler, verifier or test invocation on it |
|
||||||
|
|
||||||
|
**No tuning.** After a task's first pilot run the task is never edited. That covers its statement, tests, limits and evaluator. The only outcomes are:
|
||||||
|
|
||||||
|
```text
|
||||||
|
task fits its target band → kept unchanged
|
||||||
|
task does not fit its band → discarded completely; the author writes a new task; the new task gets a fresh pilot
|
||||||
|
```
|
||||||
|
|
||||||
|
Looking at where a pilot failed and adjusting the same task is forbidden.
|
||||||
|
|
||||||
|
- Before the first pilot, a reference writer may still report a real ambiguity, and the author may correct the task, as `benchmark-authoring.md` says.
|
||||||
|
- Pilot runs are never part of B1's statistics and are never reported as results of a language, not even to the language developer.
|
||||||
|
- Only the number of candidates discarded by calibration may be published, with no performance by language.
|
||||||
|
|
||||||
## 5. Metrics
|
## 5. Metrics
|
||||||
|
|
||||||
@@ -85,12 +113,18 @@ Per run, from the run record (protocol §13–§16, §27):
|
|||||||
|
|
||||||
New in B1 (implemented in `ajieval`, §8):
|
New in B1 (implemented in `ajieval`, §8):
|
||||||
|
|
||||||
- **Statically prevented safety failures.** Safety diagnostics the compiler or verifier reported during the run, before any test ran. The code sets are fixed before freeze, one per language:
|
- **Pre-test statically caught safety errors.** Safety diagnostics the compiler or verifier reported during the run, before any test ran. The code sets are fixed before freeze, one per language:
|
||||||
- Aji: ownership, borrow, resource, island, concurrency, atomic and unsafe codes;
|
- Aji: ownership, borrow, resource, island, concurrency, atomic and unsafe codes;
|
||||||
- Rust: borrow-checker, move, lifetime and `Send`/`Sync` codes;
|
- Rust: borrow-checker, move, lifetime and `Send`/`Sync` codes;
|
||||||
- Zig: none (its safety checks are dynamic).
|
- Zig: none (its safety checks are dynamic).
|
||||||
|
|
||||||
This metric says *where* a defect was stopped. It is not a success measure.
|
This metric is **not symmetric across languages**. It is used only to analyze the mechanism within Aji and Rust: where defects are stopped. A cross-language claim about safety ("Aji caught more, so Aji is safer") must not be made from it. Cross-language conclusions about safety come only from the hidden, fuzz and runtime gates of the evaluator.
|
||||||
|
- **Cost proxies (D5).** For each agent stack × language, the totals over **all** runs, failures included, divided by the accepted runs:
|
||||||
|
- `uncached_input_per_accepted`;
|
||||||
|
- `output_tokens_per_accepted`;
|
||||||
|
- `wall_seconds_per_accepted`.
|
||||||
|
|
||||||
|
Next to them: the median tokens, wall time and tool calls per run. An unreliable but cheap stack therefore does not look artificially cheap.
|
||||||
- **Race and atomic-ordering failures.** Failed runs classified `CONCURRENCY`, `DEADLOCK` or `ATOMIC_ORDERING`.
|
- **Race and atomic-ordering failures.** Failed runs classified `CONCURRENCY`, `DEADLOCK` or `ATOMIC_ORDERING`.
|
||||||
- **Unsafe usage.** A static count in the final program:
|
- **Unsafe usage.** A static count in the final program:
|
||||||
- Aji: functions declaring `unsafe`, `ref unchecked`, `assume`;
|
- Aji: functions declaring `unsafe`, `ref unchecked`, `assume`;
|
||||||
@@ -104,7 +138,12 @@ New in B1 (implemented in `ajieval`, §8):
|
|||||||
2. **Degradation shape:** for each language, VSR along N1/N2 → N3, and the difference to the best baseline per agent stack. A flatter Aji curve is the signal. With three stacks this is three points, not a capability curve (D1).
|
2. **Degradation shape:** for each language, VSR along N1/N2 → N3, and the difference to the best baseline per agent stack. A flatter Aji curve is the signal. With three stacks this is three points, not a capability curve (D1).
|
||||||
3. **H1** (protocol §35): for the weakest stack, Aji VSR ≥ the best Rust/Zig VSR + 15 percentage points on families A and B. B1 reports this as *preliminary*: n = 18 per cell is too small for confirmation.
|
3. **H1** (protocol §35): for the weakest stack, Aji VSR ≥ the best Rust/Zig VSR + 15 percentage points on families A and B. B1 reports this as *preliminary*: n = 18 per cell is too small for confirmation.
|
||||||
4. **H2:** median repair cycles among accepted runs, Aji ≤ 70 % of the best baseline.
|
4. **H2:** median repair cycles among accepted runs, Aji ≤ 70 % of the best baseline.
|
||||||
5. **H4 (descriptive, D1):** N3 + Aji is compared with N1/N2 + Rust/Zig, non-inferior within 5 percentage points. The strongest form is N3 + Aji ≈ N1/N2 + Rust/Zig.
|
5. **Stack-level capability compression signal (D1, not H4).** N3 + Aji is compared with N1/N2 + Rust/Zig, non-inferior within 5 percentage points. The strongest form is N3 + Aji ≈ N1/N2 + Rust/Zig. It is reported as a preliminary practical signal: the stacks differ in more than the model. Strict H4 is only the follow-up controlled experiment (same scaffold, direct APIs, 4 capability levels, Rust / Zig / Aji).
|
||||||
|
5a. **Two figures** carry the analysis:
|
||||||
|
- stack strength against VSR, one line per language;
|
||||||
|
- task difficulty band (easy, medium, hard) against VSR per language.
|
||||||
|
|
||||||
|
The signal of interest is the weak stack keeping its success on Aji longer than on Rust/Zig across the four medium tasks, while the strong stacks stay at about the same level.
|
||||||
6. **Variance:** the spread across the three runs of each cell is reported. A cell whose three runs disagree is shown as such.
|
6. **Variance:** the spread across the three runs of each cell is reported. A cell whose three runs disagree is shown as such.
|
||||||
7. **Failures:** every failed run is classified (§27 category, where caught, §38 cause) before the summary is shared. No language change is decided from B1 before this classification.
|
7. **Failures:** every failed run is classified (§27 category, where caught, §38 cause) before the summary is shared. No language change is decided from B1 before this classification.
|
||||||
8. **Negative results** are kept and reported (protocol §37).
|
8. **Negative results** are kept and reported (protocol §37).
|
||||||
@@ -127,20 +166,12 @@ As `benchmark-authoring.md`:
|
|||||||
|
|
||||||
The language developer receives only numbers, codes, gate names, hashes and file names. B1's tasks become dev material once their results are used for a design decision (protocol §7).
|
The language developer receives only numbers, codes, gate names, hashes and file names. B1's tasks become dev material once their results are used for a design decision (protocol §7).
|
||||||
|
|
||||||
## Decisions requested from the owner
|
## Decisions (owner, 2026-10-06)
|
||||||
|
|
||||||
- **D1. Track B and H4.** Protocol §39a says Track B results are never evidence for H4, because they measure model and agent stack together.
|
| | Decision |
|
||||||
- Proposal: B1 reports H4 as *stack-level capability compression* (descriptive, labeled H4-B).
|
|---|---|
|
||||||
- Confirmatory H4 stays with Track A: one scaffold, direct APIs, 4 capability levels. That is the follow-up experiment.
|
| D1 | **Accepted.** B1 is not evidence for H4: the stacks differ in more than the model. It reports a *stack-level capability compression signal*. Strict H4 needs the controlled follow-up. Protocol §39a stays unchanged. |
|
||||||
- The alternative is to amend §39a.
|
| D2 | **Accepted.** Aji/AIR is excluded completely. |
|
||||||
- **D2. Aji/AIR.** Not in the main matrix.
|
| D3 | **Accepted.** 1 easy, 4 medium, 1 hard; 2 tasks per family; at least one medium per family (§4). |
|
||||||
- Proposal: leave it out entirely. AIR has served its research role (P6A-9), and every AIR run costs as much as a main run.
|
| D4 | **Accepted, with the no-tuning rule** (§4): symmetric calibration, 54 pilot runs, explicit band rules, and no edits after the first pilot. A misfitting task is discarded and replaced by a new one with a fresh pilot. Pilots are excluded from statistics and never reported by language. |
|
||||||
- The option: 1 run per cell as a diagnostic control (+54 runs).
|
| D5 | **Accepted.** H5 is not tested; dollar cost is N/A. Cost proxies are counted over all runs per accepted run, next to the per-run medians (§5). |
|
||||||
- **D3. Difficulty distribution.** Proposal: 1 easy, 4 medium, 1 hard, with at least one medium per family.
|
|
||||||
- **D4. Calibration without selection bias.** If tasks are tuned until Rust/Zig fail often on the same agents, and then Aji is measured on those agents, the comparison is biased toward Aji: a selection effect. Proposal:
|
|
||||||
- calibration is **language-symmetric**: the operator makes one pilot run per stack in **each** of the three languages (54 runs);
|
|
||||||
- the criteria use only language-blind aggregates. For example, medium means N3 writes a compiling or verified program in ≥ 2 of the 3 languages, and N1/N2 pass in ≥ 2 of 3;
|
|
||||||
- pilot runs are discarded, never reported to the language developer, and never reused as B1 runs.
|
|
||||||
|
|
||||||
The cheaper alternative is the author's judgment plus the reference writers' cycle counts, with no pilots.
|
|
||||||
- **D5. H5.** On subscriptions there is no honest cost per solution (protocol §39a). Proposal: B1 reports output tokens, uncached input and wall time per *accepted* run as proxies. Cost in dollars waits for Track A.
|
|
||||||
@@ -256,7 +256,7 @@ Lines are compared after removing line-number prefixes (`12→`, `12:`) and grep
|
|||||||
- `diagnostics`: `E0001-E0006`, `E5001`, `E5002`, `E1001`, `E7005`, `other_E7xxx`, then `ownership`, `borrow` (including `memory.*`), `resource`, `concurrency`, `runtime_traps` by the code's kind in `reference/error-codes.md`, and `other` for every remaining code (effects, capabilities, unsafe…), so nothing is dropped; `ir_form_total` is the sum of the first three;
|
- `diagnostics`: `E0001-E0006`, `E5001`, `E5002`, `E1001`, `E7005`, `other_E7xxx`, then `ownership`, `borrow` (including `memory.*`), `resource`, `concurrency`, `runtime_traps` by the code's kind in `reference/error-codes.md`, and `other` for every remaining code (effects, capabilities, unsafe…), so nothing is dropped; `ir_form_total` is the sum of the first three;
|
||||||
- `program`: source bytes, and for `aji_source` the lowered AIR bytes and both `mechanical_air_eliminated` metrics.
|
- `program`: source bytes, and for `aji_source` the lowered AIR bytes and both `mechanical_air_eliminated` metrics.
|
||||||
- B1 fields ([`b1-heldout-plan.md`](b1-heldout-plan.md) §5):
|
- B1 fields ([`b1-heldout-plan.md`](b1-heldout-plan.md) §5):
|
||||||
- `statically_prevented_safety`: safety diagnostics reported during the run. For Aji these are codes of kind ownership, borrow, init, memory, island, resource, concurrency, atomic, task, sync or unsafe. For Rust: E0382, E0499, E0502, E0505, E0506, E0507, E0596, E0597, E0716, E0373, plus the `Send`/`Sync` messages. For Zig it is 0, since its safety checks are dynamic.
|
- `pretest_static_safety_caught`: safety diagnostics reported during the run, before any test. The metric is not symmetric across languages: use it for the mechanism within Aji and Rust, never for a cross-language safety claim. For Aji these are codes of kind ownership, borrow, init, memory, island, resource, concurrency, atomic, task, sync or unsafe. For Rust: E0382, E0499, E0502, E0505, E0506, E0507, E0596, E0597, E0716, E0373, plus the `Send`/`Sync` messages. For Zig it is 0, since its safety checks are dynamic.
|
||||||
- `unsafe_usage`: a static count in the final workspace. For Aji: `effects [unsafe]`, `ref unchecked` and `assume`. For Rust: `unsafe`. For Zig: `@ptrCast`, `@ptrFromInt`, `@intFromPtr`, `@alignCast`, `@constCast`, `@volatileCast` and `@setRuntimeSafety(false)`.
|
- `unsafe_usage`: a static count in the final workspace. For Aji: `effects [unsafe]`, `ref unchecked` and `assume`. For Rust: `unsafe`. For Zig: `@ptrCast`, `@ptrFromInt`, `@intFromPtr`, `@alignCast`, `@constCast`, `@volatileCast` and `@setRuntimeSafety(false)`.
|
||||||
- `failure_class`, `caught_by` and `atomic_error` come from `ajieval classify`. `--atomic-error memory_model|algorithmic` applies to failed runs of the atomic family.
|
- `failure_class`, `caught_by` and `atomic_error` come from `ajieval classify`. `--atomic-error memory_model|algorithmic` applies to failed runs of the atomic family.
|
||||||
|
|
||||||
@@ -275,6 +275,7 @@ python3 -m ajieval journal PLAN.json "observation" [--run RUN_ID]
|
|||||||
python3 -m ajieval summary RUNS_DIR # shareable: PASS/FAIL matrix, per-cell metrics, aggregates
|
python3 -m ajieval summary RUNS_DIR # shareable: PASS/FAIL matrix, per-cell metrics, aggregates
|
||||||
python3 -m ajieval checkpoint RUNS_DIR... [--json] # M checkpoint / P6A-9 rows (below)
|
python3 -m ajieval checkpoint RUNS_DIR... [--json] # M checkpoint / P6A-9 rows (below)
|
||||||
python3 -m ajieval vsr RUNS_DIR... [--tasks T1,T2] [--json] # B1 §6.1: VSR per agent × language, 95 % Wilson intervals
|
python3 -m ajieval vsr RUNS_DIR... [--tasks T1,T2] [--json] # B1 §6.1: VSR per agent × language, 95 % Wilson intervals
|
||||||
|
python3 -m ajieval costs RUNS_DIR... [--tasks T1,T2] [--json] # B1 §5: totals over all runs per accepted run, per-run medians
|
||||||
python3 -m ajieval profile RUNS_DIR # shareable: termination, output tokens, tool calls, solution size, lowered AIR size (aji_source), docs files read, IR-form and type-mismatch diagnostic counts, diagnostic-code occurrences
|
python3 -m ajieval profile RUNS_DIR # shareable: termination, output tokens, tool calls, solution size, lowered AIR size (aji_source), docs files read, IR-form and type-mismatch diagnostic counts, diagnostic-code occurrences
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -157,5 +157,5 @@ Targets for Phase 6A, measured on dev tasks:
|
|||||||
| P6A | done (exit review in `phase-6-source-language.md`; P6A-9 [results](../evaluation/results/2026-10-05-p6a-9.md)): the agent-facing source language over AIR is the architecture |
|
| P6A | done (exit review in `phase-6-source-language.md`; P6A-9 [results](../evaluation/results/2026-10-05-p6a-9.md)): the agent-facing source language over AIR is the architecture |
|
||||||
| P4 | done (exit review in the phase file) |
|
| P4 | done (exit review in the phase file) |
|
||||||
| P5 | done (exit review in the phase file): atomics through every layer; litmus 20/20 exact against the independent oracle; race detector on every run test |
|
| P5 | done (exit review in the phase file): atomics through every layer; litmus 20/20 exact against the independent oracle; race detector on every run test |
|
||||||
| B1 | the first held-out benchmark after Phase 5 (owner decision, 2026-10-06): pre-registration [`b1-heldout-plan.md`](../evaluation/b1-heldout-plan.md) is Proposed; the independent author starts after its acceptance |
|
| B1 | the first held-out benchmark after Phase 5 (owner decision, 2026-10-06): pre-registration [`b1-heldout-plan.md`](../evaluation/b1-heldout-plan.md) Accepted; private side: independent author → references → symmetric calibration → freeze → 162 runs |
|
||||||
| P7, P8 | on hold until B1 is analyzed (owner decision, 2026-10-06) |
|
| P7, P8 | on hold until B1 is analyzed (owner decision, 2026-10-06) |
|
||||||
@@ -226,6 +226,12 @@ def main(argv=None):
|
|||||||
v.add_argument("--json", action="store_true")
|
v.add_argument("--json", action="store_true")
|
||||||
v.set_defaults(fn=lambda a: print(report.vsr_table(a.paths, set(a.tasks.split(",")) if a.tasks else None, a.json)))
|
v.set_defaults(fn=lambda a: print(report.vsr_table(a.paths, set(a.tasks.split(",")) if a.tasks else None, a.json)))
|
||||||
|
|
||||||
|
cs = sub.add_parser("costs", help="B1 §5: cost proxies per agent × language (totals over all runs per accepted run; per-run medians)")
|
||||||
|
cs.add_argument("paths", nargs="+")
|
||||||
|
cs.add_argument("--tasks", help="comma-separated task ids to include")
|
||||||
|
cs.add_argument("--json", action="store_true")
|
||||||
|
cs.set_defaults(fn=lambda a: print(report.cost_proxies(a.paths, set(a.tasks.split(",")) if a.tasks else None, a.json)))
|
||||||
|
|
||||||
a = p.parse_args(argv)
|
a = p.parse_args(argv)
|
||||||
a.fn(a)
|
a.fn(a)
|
||||||
|
|
||||||
|
|||||||
@@ -280,8 +280,11 @@ def _diagnostic_buckets(codes):
|
|||||||
return b
|
return b
|
||||||
|
|
||||||
|
|
||||||
# B1 (docs/evaluation/b1-heldout-plan.md §5): safety diagnostics a compiler
|
# B1 (docs/evaluation/b1-heldout-plan.md §5): pre-test statically caught
|
||||||
# or verifier reported before any test ran. Fixed before the freeze.
|
# safety errors, i.e. safety diagnostics a compiler or verifier reported
|
||||||
|
# before any test ran. Fixed before the freeze. Not symmetric across
|
||||||
|
# languages (Zig has none by definition): a mechanism measure for Aji and
|
||||||
|
# Rust, never a cross-language safety claim.
|
||||||
AJI_SAFETY_KINDS = {"ownership", "borrow", "init", "memory", "island", "resource", "concurrency", "atomic", "task", "sync", "unsafe"}
|
AJI_SAFETY_KINDS = {"ownership", "borrow", "init", "memory", "island", "resource", "concurrency", "atomic", "task", "sync", "unsafe"}
|
||||||
RUST_SAFETY_CODES = {"E0382", "E0499", "E0502", "E0505", "E0506", "E0507", "E0596", "E0597", "E0716", "E0373"}
|
RUST_SAFETY_CODES = {"E0382", "E0499", "E0502", "E0505", "E0506", "E0507", "E0596", "E0597", "E0716", "E0373"}
|
||||||
RUST_SEND_SYNC = ("cannot be sent between threads safely", "cannot be shared between threads safely")
|
RUST_SEND_SYNC = ("cannot be sent between threads safely", "cannot be shared between threads safely")
|
||||||
@@ -382,6 +385,51 @@ def vsr_table(paths, tasks=None, as_json=False):
|
|||||||
return "\n".join(out)
|
return "\n".join(out)
|
||||||
|
|
||||||
|
|
||||||
|
def _median(xs):
|
||||||
|
xs = sorted(x for x in xs if x is not None)
|
||||||
|
if not xs:
|
||||||
|
return None
|
||||||
|
m = len(xs) // 2
|
||||||
|
return xs[m] if len(xs) % 2 else (xs[m - 1] + xs[m]) / 2
|
||||||
|
|
||||||
|
|
||||||
|
def cost_proxies(paths, tasks=None, as_json=False):
|
||||||
|
"""B1 §5 (D5): per agent stack × language, totals over ALL runs divided
|
||||||
|
by accepted runs (the price of failures included), and per-run medians.
|
||||||
|
No dollar cost: subscriptions have no honest price per solution."""
|
||||||
|
runs = [r for r in load(paths) if tasks is None or r["task"]["id"] in tasks]
|
||||||
|
cells = {}
|
||||||
|
for r in runs:
|
||||||
|
cells.setdefault((_agent_key(r), r["language"]["name"]), []).append(r)
|
||||||
|
rows = []
|
||||||
|
for (agent, lang), rs in sorted(cells.items()):
|
||||||
|
acc = sum(1 for r in rs if r.get("accepted"))
|
||||||
|
unc = [((r["metrics"].get("context") or {}).get("provider_input_tokens") or {}).get("uncached") for r in rs]
|
||||||
|
out = [r["metrics"].get("output_tokens") for r in rs]
|
||||||
|
wall = [r["metrics"].get("elapsed_seconds") for r in rs]
|
||||||
|
tools = [r["metrics"].get("tool_calls") for r in rs]
|
||||||
|
|
||||||
|
def per_acc(xs):
|
||||||
|
if acc == 0 or any(x is None for x in xs):
|
||||||
|
return None
|
||||||
|
return round(sum(xs) / acc, 1)
|
||||||
|
|
||||||
|
rows.append({"agent": agent, "language": lang, "runs": len(rs), "accepted": acc,
|
||||||
|
"uncached_input_per_accepted": per_acc(unc), "output_tokens_per_accepted": per_acc(out),
|
||||||
|
"wall_seconds_per_accepted": per_acc(wall),
|
||||||
|
"median_uncached_input_per_run": _median(unc), "median_output_tokens_per_run": _median(out),
|
||||||
|
"median_wall_seconds_per_run": _median(wall), "median_tool_calls_per_run": _median(tools)})
|
||||||
|
if as_json:
|
||||||
|
return json.dumps(rows, indent=1)
|
||||||
|
head = ["agent", "language", "runs", "accepted", "uncached_input_per_accepted", "output_tokens_per_accepted",
|
||||||
|
"wall_seconds_per_accepted", "median_uncached_input_per_run", "median_output_tokens_per_run",
|
||||||
|
"median_wall_seconds_per_run", "median_tool_calls_per_run"]
|
||||||
|
lines = ["| " + " | ".join(head) + " |", "|" + "---|" * len(head)]
|
||||||
|
for row in rows:
|
||||||
|
lines.append("| " + " | ".join("n/a" if row[h] is None else str(row[h]) for h in head) + " |")
|
||||||
|
return "\n".join(lines)
|
||||||
|
|
||||||
|
|
||||||
def checkpoint_rows(paths):
|
def checkpoint_rows(paths):
|
||||||
"""One row per run with the fields of the M checkpoint and P6A-9 (plan,
|
"""One row per run with the fields of the M checkpoint and P6A-9 (plan,
|
||||||
P6A-9). Only what the record holds: a field the run did not collect is
|
P6A-9). Only what the record holds: a field the run did not collect is
|
||||||
@@ -443,7 +491,7 @@ def checkpoint_rows(paths):
|
|||||||
"diagnostics": _diagnostic_buckets(codes),
|
"diagnostics": _diagnostic_buckets(codes),
|
||||||
"program": program,
|
"program": program,
|
||||||
# B1 §5 (n/a in records without the data).
|
# B1 §5 (n/a in records without the data).
|
||||||
"statically_prevented_safety": statically_prevented(r, d, codes),
|
"pretest_static_safety_caught": statically_prevented(r, d, codes),
|
||||||
"unsafe_usage": unsafe_usage(r, d) if os.path.isdir(os.path.join(d, "workspace")) else na,
|
"unsafe_usage": unsafe_usage(r, d) if os.path.isdir(os.path.join(d, "workspace")) else na,
|
||||||
"failure_class": v((r.get("classification") or {}).get("category")),
|
"failure_class": v((r.get("classification") or {}).get("category")),
|
||||||
"caught_by": v((r.get("classification") or {}).get("caught_by")),
|
"caught_by": v((r.get("classification") or {}).get("caught_by")),
|
||||||
|
|||||||
@@ -41,5 +41,24 @@ class B1Metrics(unittest.TestCase):
|
|||||||
self.assertEqual(report.unsafe_usage({"language": {"name": "zig"}}, d), 1)
|
self.assertEqual(report.unsafe_usage({"language": {"name": "zig"}}, d), 1)
|
||||||
|
|
||||||
|
|
||||||
|
def test_cost_proxies_count_failures(self):
|
||||||
|
import json
|
||||||
|
|
||||||
|
def rec(d, n, accepted, unc, out, wall):
|
||||||
|
os.makedirs(d)
|
||||||
|
json.dump({"task": {"id": "T"}, "language": {"name": "rust"}, "track": "B",
|
||||||
|
"agent": {"name": "claude", "model": "m", "label": "N2"}, "accepted": accepted,
|
||||||
|
"metrics": {"output_tokens": out, "elapsed_seconds": wall, "tool_calls": 3,
|
||||||
|
"context": {"provider_input_tokens": {"uncached": unc}}}}, open(os.path.join(d, "run.json"), "w"))
|
||||||
|
with tempfile.TemporaryDirectory() as root:
|
||||||
|
rec(os.path.join(root, "a"), 1, True, 100, 10, 60)
|
||||||
|
rec(os.path.join(root, "b"), 2, False, 300, 30, 120)
|
||||||
|
row = json.loads(report.cost_proxies([root], as_json=True))[0]
|
||||||
|
# The failed run's cost is charged to the one accepted run.
|
||||||
|
self.assertEqual(row["uncached_input_per_accepted"], 400)
|
||||||
|
self.assertEqual(row["output_tokens_per_accepted"], 40)
|
||||||
|
self.assertEqual(row["median_wall_seconds_per_run"], 90)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
unittest.main()
|
unittest.main()
|
||||||
Reference in new issue
Block a user