Skip to content

fix(label): allow explicit graph overwrite - #2983

Open
oleksii-tumanov wants to merge 5 commits into
Graphify-Labs:v8from
oleksii-tumanov:fix/label-force-shrink-override
Open

oleksii-tumanov wants to merge 5 commits into
Graphify-Labs:v8from
oleksii-tumanov:fix/label-force-shrink-override

Conversation

@oleksii-tumanov

@oleksii-tumanov oleksii-tumanov commented Aug 23, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Adds graphify label --force for 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 --graph source before labeling if it would overwrite a different graph.

Fixes #2976

Type of change

  • Bug fix
  • New feature
  • Documentation
  • Tests or CI
  • Refactor
  • Security fix

Verification & Invariants

  • Read the CONTRIBUTING.md guide.
  • Reproduced the issue and identified the invariant.
  • Made the smallest fix necessary.
  • Added a regression test (if bug fix) or isolated boundary test.
  • Kept the PR description synchronized with the final implementation.
  • Documented any limitations / unsupported cases explicitly.

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 --force can 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.
  • Skill generation checks, coverage/schema audits and both round-trip guards: passed with the current v8 reference available.
  • 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

  • I updated generated skill artifacts (uv run python -m tools.skillgen --bless) when changing their source fragments. N/A: no source fragments changed; all five generated-artifact guards passed.
  • I confirmed that AST/structural extraction remains deterministic (no ambient state dependencies like ENV variables).
  • I reviewed changes for security implications (no unsafe interpolation into shell/Python).
  • I confirmed no API keys or local-only graph data are included.
  • (If applicable) I disclosed AI authorship in my commit messages.

@graphify-labs graphify-labs Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

graphify label discards all LLM work: graph.json grows mid-run and the #479 shrink guard refuses the final write (no --force on this path)

1 participant