Repository navigation
Description
Environment
- graphifyy 0.9.42
- Windows 11, Python 3.13, git 2.53.0.windows.1
Summary
On a full-corpus rebuild, _check_shrink can never refuse a write. The #479 shrink protection is structurally absent on exactly the code path the warning text recommends as the remedy ("Run a full rebuild (/graphify .) to be safe").
Mechanism
watch.py:1406-1414, inside _rebuild_code:
if changed_paths is None:
rebuilt_sources = {
_nsf(str(p.relative_to(project_root)), _rebuilt_root)
for p in code_files if p.is_relative_to(project_root)
}
else:
rebuilt_sources = {(_nsf(str(p), _rebuilt_root) or str(p)) for p in extract_targets}On a full rebuild rebuilt_sources is every code file in the corpus.
watch.py:889-901, inside _check_shrink:
if rebuilt_sources is not None:
...
def _accounted(n: dict) -> bool:
sf = n.get("source_file")
if sf and failed_sources and _norm_source_file(sf) in failed_sources:
return False
return (not sf
or sf in rebuilt_sources
or _norm_source_file(sf) in rebuilt_sources)
if all(_accounted(n) for n in lost):
return TrueA node is "accounted" when it has no source_file or its source_file is in rebuilt_sources. On a full rebuild both halves of that disjunction cover the entire node set, so all(_accounted(n) for n in lost) is always true and the guard returns True unconditionally. The only escape is failed_sources, i.e. a source whose AST extraction raised. A source that extracts "successfully" but yields nothing is not in failed_sources, and that is precisely the silent-shrink class the guard exists to catch.
Impact
A full rebuild that loses thousands of nodes to a silently-empty extraction pass writes them away with no warning and no refusal. The per-source accounting added for #1116 (so a legitimate delete does not need --force) is correct for the incremental path but degenerates to "always allow" for the full path.
Suggested direction
On a full rebuild, treat a source as accounting for its lost nodes only when it actually produced output this run (or is genuinely gone from disk), rather than merely having been scanned. rebuilt_sources as "the whole corpus" is not evidence that any particular loss was intentional.
Filed alongside a separate report of an incremental rebuild that zeroed 168 files and also got past this guard.
Activity
turzail-png commentedon Sep 15, 2026
Related: #3580, an incremental rebuild that lost 1588 nodes and also got past
_check_shrink.