Ver Fonte

docs: plan benchmark metric integrity fixes

Problem: Model elapsed includes consumer backpressure, missing provider usage appears as zero tokens, and the parallel benchmark does not prove handler overlap.

Risk: Adding a deterministic parallel probe and stricter usage completeness can turn previously passing live runs into explicit semantic failures when providers omit usage or execution becomes serial.
zhenyu.hu há 2 semanas atrás
pai
commit
e809f7fe92

+ 39 - 0
docs/plans/todo-52.12-benchmark-metric-integrity-and-parallel-proof.md

@@ -0,0 +1,39 @@
+# Todo 52.12 Benchmark Metric Integrity and Parallel Proof Plan
+
+**Status:** in_progress
+
+## Goal
+
+Ensure benchmark latency, token-cost, and multi-event concurrency results measure the claimed behavior rather than consumer overhead, persistence defaults, or event cardinality alone.
+
+## Observation
+
+- `TimingChatClient.elapsed_ms` spans the outer generator's `yield`, so downstream Runtime/audit/queue work and consumer pauses inflate the value described as pure model-call elapsed.
+- Successful calls without a provider usage chunk are persisted as zero-token rows and currently become a false `0 tokens` benchmark result.
+- The parallel case verifies two successful events but does not prove their handlers overlap; a serial executor can still pass the benchmark.
+
+## Scope
+
+- Measure model elapsed as the accumulated time awaiting the wrapped provider iterator, excluding time while the caller processes yielded items.
+- Preserve provider TTFT and first-visible timing semantics independently from provider-await elapsed.
+- Require complete usage coverage across all model/fallback calls before reporting token totals. Missing usage produces nullable token metrics plus an explicit semantic failure instead of zero or a partial sum.
+- Add a benchmark-owned execution probe for the parallel volume/schedule case that deterministically requires both handlers to start before either completes.
+- Record the parallel-overlap result in `BenchmarkRunResult`, include it in report output, and fail the parallel case if overlap is absent.
+- Keep mock and live runs on the same probe/registry path and keep non-parallel case behavior unchanged.
+
+## Files
+
+- Modify: `src/agent_lab/application/benchmark.py`
+- Modify: `src/agent_lab/infrastructure/benchmark_reporting.py`
+- Modify: `tests/test_benchmark_runner.py`
+- Modify: `tests/test_benchmark_reporting.py`
+- Modify: `README.md`
+
+## Verification
+
+- `uv run pytest tests/test_benchmark_runner.py tests/test_benchmark_reporting.py -q`
+- `uv run pytest tests/test_benchmark_config.py tests/test_benchmark_runner.py tests/test_benchmark_reporting.py tests/test_benchmark_cli.py tests/test_tool_invocation_comparison.py -q`
+- zero-network mock CLI still reports 12 attempted runs and validates parallel overlap
+- `uv run pytest`
+- `git diff --check`
+

+ 1 - 0
docs/plans/todos.md

@@ -112,3 +112,4 @@
 | 52.9 | done | `docs/plans/todo-52.9-atomic-report-bundles-and-audit-parity.md` | Replace two-path report publication with one atomic bundle boundary and close report/CLI audit parity gaps. | Concurrent writers publish complete bundles without rollback deletion races; Markdown preserves all failure facts and output errors map to exit code 2. |
 | 52.10 | done | `docs/plans/todo-52.10-benchmark-bundle-cli-contract.md` | Align CLI report discovery tests with the atomically published bundle layout. | CLI tests consume the reported bundle paths without restoring root-level compatibility copies or weakening redaction, exit-code, and cardinality checks. |
 | 52.11 | done | `docs/plans/todo-52.11-bundle-interrupt-and-path-safety.md` | Preserve complete bundles across post-symlink interrupts and reject unsafe report timestamp path components. | Interruptions cannot leave dangling public bundles; explicit timestamps stay inside output_dir; fsync tests verify both files and both directories. |
+| 52.12 | in_progress | `docs/plans/todo-52.12-benchmark-metric-integrity-and-parallel-proof.md` | Exclude consumer backpressure from model elapsed, reject missing token usage, and prove parallel handlers overlap. | Model latency measures provider-await time; absent usage cannot appear as zero cost; the parallel case fails unless both handlers start concurrently. |