feat(scan): size portions from measured per-answer cost and isolate the kill culprit

The 7.8 trace showed the completion loss was a sizer death spiral, not
expensive families: after two kills the budget fell to 3 sink visits and
never recovered, because portions finishing in 25-30 s sat under an assumed
70 s fixed start and read as "no information", so the budget could only
shrink.

- taint.sc streams each answer's own cost (`ms`); the backend carries it as a
  reserved `__timing__` list through shards, partitions and reuse.
- The sizer budgets predicted seconds from per-family seconds-per-visit rates
  learned from those costs, and measures the fixed start as the wall time the
  answers do not explain (median), instead of assuming it.
- A kill names its culprit: the first unanswered id in request order. The ids
  behind it never started and are re-queued at once; the culprit is asked
  alone after the rest. One that still fails alone after more than a
  portion's target is reported as `query_too_expensive`, apart from
  `query_failed`.
- Portions grow id by id from the queue head, and a single-portion scan now
  goes through the queue too, so a kill there re-asks its remainder.
- Fix: the reuse wrapper wrapped only `run_batch`, so since 7.8 every
  portioned query bypassed the graph-reuse cache and its source-root
  normalization. `run_batch_once` is wrapped too.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01EmM1j46qgKMh3zqD1QMwEo
This commit is contained in:
Marius Ciepluch
2026-09-23 07:55:33 +02:00
co-authored by Claude Opus 5.5
parent c1a689f4b3
commit 1b28465a61
10 changed files with 427 additions and 143 deletions
+4
View File
@@ -435,6 +435,10 @@ _COVERAGE_DEGRADATIONS: dict[str, str] = {
),
"files_unparsed": "{count} file(s) could not be parsed and are absent from the graph: {files}.",
"query_failed": "A `{kind}` query failed for {requests} region(s), so those regions were not decided.",
"query_too_expensive": (
"{requests} `{kind}` question(s) could not be answered even when asked alone, spending up to "
"{max_seconds} s each, so those regions were not decided. This is the cost of the question, not a transient failure."
),
"budget_exhausted": "The model-call budget ran out with {regions_unasked} region(s) still unasked.",
"regions_truncated": (
"Only the **{examined} highest-ranked of {total} regions** were examined. Nothing above says anything "