Repository navigation
fix(global): recover from malformed manifest objects - #5025
azizur100389 wants to merge 3 commits into
Conversation
Refs Graphify-Labs#5020. Co-Authored-By: OpenAI Codex <[email protected]>
|
Thanks for the pull request, @azizur100389. A maintainer will review it soon. Want to talk it through while it is in review? Come join us on our Discord server. For longer-form discussion there is also GitHub Discussions. A couple of things that speed up review: make sure the test suite passes on Python 3.10 and 3.13, and that the change keeps extraction deterministic. |
There was a problem hiding this comment.
Graphify reviewed this change.
No issues found by static checks — no coupling regressions or blocking issues in the code graph. That is not the same as safe to merge: see what was not checked.
Not checked: tests were not run; formal verification proved 0 of 1 changed function(s) (1 sampled, not proven).
Formal verification. PR-changed functions: 1/1 verified (0 proven, 1 may-equivalent, 0 distinguished) · 0 not verified.
Graphify review — findings
Tightens _load_manifest so a global manifest that parses as JSON but has the wrong shape (not an object, no repos map, or a repos entry that isn't an object) goes down the same recovery path as unparseable JSON. The bad file is moved aside to a .corrupt.* backup with a warning on stderr, and the commands start from an empty manifest instead of failing later on bad data. Adds tests covering those malformed payloads, plus one confirming a valid manifest is left untouched.
No blocking issues surfaced. 1 lower-confidence candidate did not survive cross-model review.
Analysis details — impact, health, verification
Impact & health
Graphify review
Impact — 303 functions depend on the 17 functions this change touches.
Health — grade A; 6 existing hotspot(s) in the area this change touches (pre-existing, not introduced here):
dispatch_command()— 5 callers, 146 callees (high)main()— 122 callers, 3 callees (high)global_add()— 14 callers, 10 callees (high)_run_cli()— 11 callers, 8 callees (high)global_remove()— 5 callers, 5 callees (medium)test_poisoned_manifest_is_healed()— 0 callers, 6 callees (medium)
Verification — 303 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: 41 function(s) in the blast radius were not formally verified this run
Test selection
Test selection
4 of 519 test file(s) selected (1%) via static blast radius.
tests/test_export_direction.py— impacttests/test_global_add_tag_inference.py— impacttests/test_global_graph.py— impacttests/test_global_manifest_shape.py— impact, changed-test
Selection is safe under the controlled-regression assumption; always-run tests + a periodic full run are the backstops. Advisory — it never changes the check verdict.
Formal verification
No difference found (not proven): No behavior difference found in \_load\_manifest (not a proof).
The verifier ran both versions of \_load\_manifest 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.
…#5020) Follow-up to #5025. The landed guard raised on any non-dict repo value, so a single malformed entry backed up the whole manifest and dropped every tracked repo. Keep the whole-file backup only for an unrecoverable shape (non-dict root or repos map); when repos is a dict, drop just the malformed entries, keep the valid repos, and report which went. Matches the per-entry isolation of #5024. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Landed on |
Fixes #5020.
What does this PR do?
The JSON decoder succeeds, but consumers receive the wrong shape. Depending on the value, a command crashes or reports an empty graph without preserving the malformed manifest as a recovery backup.
The global manifest reader checks that the decoded value contains a repository map of objects before returning it. Invalid shapes use the existing backup and warning path.
Reproduction
In a disposable home directory, create
~/.graphify/global-manifest.jsonwithnulland rungraphify global list. Repeat with{"repos":[]}or{"repos":{"example":"invalid"}}.Verification
uv sync --all-extras --frozenon Python 3.12.python -m pytest -q --tb=short tests/test_global_manifest_shape.py— 6 passed. The new failure cases reproduce on unchangedv8at59b5ab11.python -m ruff check .,python -m pre_commit run --all-files, and all fivepython -m tools.skillgenchecks passed.