Skip to content

fix(global): recover from malformed manifest objects - #5025

Closed
azizur100389 wants to merge 3 commits into
Graphify-Labs:v8from
azizur100389:codex/global-manifest-shape
Closed

azizur100389 wants to merge 3 commits into
Graphify-Labs:v8from
azizur100389:codex/global-manifest-shape

Conversation

@azizur100389

@azizur100389 azizur100389 commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

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.json with null and run graphify global list. Repeat with {"repos":[]} or {"repos":{"example":"invalid"}}.

Verification

  • uv sync --all-extras --frozen on Python 3.12.
  • python -m pytest -q --tb=short tests/test_global_manifest_shape.py — 6 passed. The new failure cases reproduce on unchanged v8 at 59b5ab11.
  • python -m ruff check ., python -m pre_commit run --all-files, and all five python -m tools.skillgen checks passed.
  • GitHub CI passed on Python 3.10, 3.12, 3.13 and 3.14 with 9,998 tests passed per version, 20 built-in skips and one expected failure. The 20 Bun Pi guard tests and CLI install smoke checks passed.
  • Fresh wheel installation, CLI help, skill install and AST-only graph update passed on Windows. Pyright, Bandit, pip-audit and native Bun results match clean v8.
  • The first two Linux runs failed in different existing watch fixtures. The final retry ran the entire matrix on identical source and tests. GitHub limits direct reruns to maintainers, so the two retries use empty commits.
  • Full Windows Python 3.12 suite: 9829 passed, 30 failed, 159 built-in skips and one expected failure. Clean v8 reproduced 29 failing test IDs. The additional test stopped at a transient git add error before running its post-commit hook. It passed in isolation on clean v8 and all three affected branches.

@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown

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.

@github-actions github-actions Bot added the contributor Pull request from a returning community contributor label Nov 5, 2026
@azizur100389
azizur100389 marked this pull request as ready for review November 5, 2026 11:27

@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.

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 — impact
  • tests/test_global_add_tag_inference.py — impact
  • tests/test_global_graph.py — impact
  • tests/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.

safishamsi added a commit that referenced this pull request Nov 8, 2026
…#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]>
@safishamsi

Copy link
Copy Markdown
Member

Landed on v8 and shipped in 0.9.104 (now on PyPI), cherry-picked with -x to keep your authorship. I added a small follow-up (#5020): the guard raised on any non-dict repo value, which backed up the whole manifest and dropped every tracked repo on a single bad entry. The follow-up isolates just the malformed entries and keeps the valid repos, matching the per-entry handling in #5024. Thanks @azizur100389.

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

Labels

contributor Pull request from a returning community contributor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: valid JSON with the wrong global-manifest shape bypasses recovery

2 participants