Conversation
On a full rebuild `rebuilt_sources` is every file in the corpus, so `_accounted` returned True for every lost node and `_check_shrink` could never refuse. The protection was structurally absent on exactly the path its own refusal message recommends as the remedy. Membership in `rebuilt_sources` says a file was scanned, not that losing its nodes was intended. A re-extracted source now accounts for its own losses only while it still contributes something to the new graph: a source that goes from N nodes to none while still on disk is the silent shrink this guard exists for. Files the caller declared deleted stay exempt, since contributing nothing is the correct outcome for them. An emptied-but-present file keeps its file node, so a legitimate "removed every symbol" edit still passes without --force.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #3579.
_check_shrinkcannot refuse a write on a full rebuild.rebuilt_sourcesis the whole corpus there:and
_accountedtreats membership as evidence that a loss was intended, soall(_accounted(n) for n in lost)is true for every node that has asource_fileand for every node that has none. The guard is structurally absent on exactly the path its own refusal message recommends: "Run a full rebuild to be safe."Observable on
v8with two files and no fixtures — a full rebuild that emptiesa.pygoes 5 nodes to 3 and writes without a word:The change
Membership says a file was scanned. It does not say that losing its nodes was intended. A re-extracted source now accounts for its own lost nodes only while it still contributes something to the new graph, with two exemptions kept intact:
deleted_sources(the set the call sites already fold intorebuilt_sources) is passed separately and exempted.failed_sources. Unchanged, and still takes precedence: extraction did not complete, so the disappearance is the silent shrink.The "removed every symbol" case does not regress, and that is measured rather than assumed: graphify keeps a file node for an emptied-but-present file (
a.py: 1above), so such a source stays in the surviving set and the write is still allowed without--force.Test
Six cells in
tests/test_watch.py, beside the existing guard cells. The one that names the defect fails onv8:The other five pin the boundaries: a symbol removed from a rebuilt source still passes (#1116), a deleted source still passes, a failed source still refuses, a node with no
source_fileis still accounted, and a loss from a source that was not rebuilt still refuses (the incremental case this guard was written for, which had no cell of its own — a mutation that dropped the membership check survived until it was added).tests/test_watch.pyandtests/test_build_merge_shrink_guard.pyare green at 166 passed, 3 skipped. The fulltests/run has 26 failures, and the identical 26 fail on an unmodifiedv8atfe66389here — the two sets compare equal, so none of them are this change.Mutation-checked: five seeded defects, including restoring the original
_accounted, dropping the deleted-file exemption, and dropping thefailed_sourcesprecedence. Each is caught by a named cell; none survive.On the sibling report: this is the guard half of what #3580 describes, so a rebuild that zeroes files would now refuse rather than write silently. It does not address why those files were zeroed — I could not reproduce that part on
v8and have posted the harness and the negative result there.