Repository navigation
fix(label): allow explicit graph overwrite - #2983
oleksii-tumanov wants to merge 5 commits into
Conversation
There was a problem hiding this comment.
Graphify reviewed this change.
Looks safe to merge — no coupling regressions and no blocking issues, checked against the code graph (not a self-assessment).
Formal verification. 1 change(s) tested, no difference found (not proven).
Graphify review — findings
Adds a --force flag to graphify label that lets a run overwrite graph.json even when a concurrent writer grew it during labeling, passing force=force_graph_write through to to_json. In dispatch_command, moves the output-directory resolution ahead of the labeling work and rejects --force with exit code 2 when the loaded --graph isn't the graph.json that would be overwritten, so a restore-source graph can't clobber a different file. Documents the flag in the README and CLI help, and covers the growth/rejection paths in tests/test_labeling.py.
No blocking issues surfaced. 7 lower-confidence candidates did not survive cross-model review.
Analysis details — impact, health, verification
Impact & health
Graphify review
Impact — 355 functions depend on the 167 functions this change touches.
Health — this change adds coupling hotspots:
- new:
dispatch_command()— 2 callers, 119 callees - new:
_stale_graph_sources()— 7 callers, 6 callees - new:
_run_hook_guard()— 4 callers, 7 callees - new:
test_poisoned_manifest_is_healed()— 0 callers, 6 callees
Verification — 355 functions in the blast radius were not formally verified this run (proofs are advisory here).
Gate & verification
graphify gate
PASS — objectively clean (no health regressions, tests not run — proofs not run this pass (advisory)). Grounded, not self-assessed.
Advisory (not blocking):
- verification_scope: 355 function(s) in the blast radius were not formally verified this run
Formal verification
Could not verify: Could not verify dispatch\_command.
The verifier did not have enough to check dispatch\_command, so it is saying so rather than guessing. No false assurance is the whole point.
Guarantee: No guarantee either way, this is an honest abstention, not a pass.
Note: Reason: not verifiable: all 23 sampled inputs raised on both versions — the function never executed, so 'no divergence' would be vacuous (mostly SystemExit — names the real obstacle, not a sampling gap)
No difference found (not proven): No behavior difference found in \_run\_cli (not a proof).
The verifier ran both versions of \_run\_cli on many inputs and saw identical behavior every time. Strong evidence the change is safe, but evidence, not a proof.
Guarantee: Empirical: differential testing (both versions run on many generated inputs). A divergence on an untested input remains possible, so this is 'no counterexample found', not 'proven equivalent'.
Note: An input the sampler did not try could still differ.
· 4 more finding(s) on lines outside this diff (see the check run).
Preserve the label-only force option while retaining upstream parallel-link metadata during serialization. Refs Graphify-Labs#2983 AI-Assistance: OpenAI Codex
Preserve the explicit label-only overwrite path and current CLI reference layout. AI-Assistance: OpenAI Codex
Refuse changed oversized destinations before replacing backups or sidecars, while retaining unchanged large-graph relabeling and explicit force. AI-Assistance: OpenAI Codex
Keep ordinary-size and oversized preservation regression cases distinct. AI-Assistance: OpenAI Codex
What does this PR do?
Adds
graphify label --forcefor an explicit overwrite when the saved graph grows during labeling. The default run preserves the newer graph and existing sidecars. A forced run rejects a detached--graphsource before labeling if it would overwrite a different graph.Fixes #2976
Type of change
Verification & Invariants
Tests cover default refusal, graphs already above or newly crossing the file-size limit, explicit overwrite, consumed option values, detached sources and preserved link metadata. Disabling the overwrite keyword makes the force regression fail; disabling the oversized-destination preflight makes four preservation cases fail. Unchanged oversized graphs can still be relabeled. The README keeps the current CLI-reference layout.
Explicit
--forcecan discard topology saved after labeling starts. It applies only to the same canonical graph loaded by that label run. For an oversized destination, the default checks its file metadata before writing and refuses a detected change; it does not provide atomic protection against a write after that check.How was this tested?
uv run --frozen pytest tests/test_labeling.py tests/test_export.py tests/test_extract_cli.py -q --tb=short: 160 passed.uv run --frozen pytest tests/ -q --tb=short: 8,402 passed, 15 skipped. One unchanged shell-tracing control fails with macOS Bash 3.2 and also fails on pristine current v8.uv run --frozen ruff check .: passed.uv run --frozen pyright --outputjson: 637 existing diagnostics, with no added diagnostics against current v8.uv run --frozen graphify update .: passed.The full suite ran before a fixture-only environment-isolation adjustment; the current focused suite was rerun afterward.
Tests ran with unrelated provider credentials removed. No live model calls were used.
Graphify-specific checklist
uv run python -m tools.skillgen --bless) when changing their source fragments. N/A: no source fragments changed; all five generated-artifact guards passed.