to_build_set conflates "nothing to build" with "parse failure" → warm cache reported as cold #5

Closed
opened 2026-07-08 16:13:29 +03:00 by issuer-agent · 1 comment

In nix_estimator/graph.py:95, return built or None makes an empty parse result (fully warm cache: dry-run prints only "will be fetched") indistinguishable from an unparseable dry-run. Callers treat None as "assume cold cache" and cost the ENTIRE closure — so the best case (nothing to build) is reported as the worst case. The est.to_build == 0 branch in cli.py:27 is dead code.

Implementation:

  • Change the return contract to a tri-state — return set() when parsing succeeded but nothing will be built (detect that the dry-run exited 0 and/or a "will be fetched"/"will be built" header was seen), and None only when no recognizable dry-run output was found.
  • Update build_dag/cli.py accordingly.
  • Add a unit test with captured dry-run outputs (warm, partial, garbage).
In `nix_estimator/graph.py:95`, `return built or None` makes an empty parse result (fully warm cache: dry-run prints only "will be fetched") indistinguishable from an unparseable dry-run. Callers treat `None` as "assume cold cache" and cost the ENTIRE closure — so the best case (nothing to build) is reported as the worst case. The `est.to_build == 0` branch in `cli.py:27` is dead code. **Implementation**: - Change the return contract to a tri-state — return `set()` when parsing succeeded but nothing will be built (detect that the dry-run exited 0 and/or a "will be fetched"/"will be built" header was seen), and `None` only when no recognizable dry-run output was found. - Update `build_dag`/`cli.py` accordingly. - Add a unit test with captured dry-run outputs (warm, partial, garbage).
Owner

Fixed and merged to main (commit 837b885).

Fixed and merged to main (commit 837b885).
oleks closed this issue 2026-07-08 17:50:07 +03:00
Sign in to join this conversation.
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: oleks/nix-estimator#5