Skip to content

fix(reflect): isolate malformed learning overlay entries - #5024

Closed
azizur100389 wants to merge 2 commits into
Graphify-Labs:v8from
azizur100389:codex/learning-overlay-input
Closed

azizur100389 wants to merge 2 commits into
Graphify-Labs:v8from
azizur100389:codex/learning-overlay-input

Conversation

@azizur100389

@azizur100389 azizur100389 commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #5019.

What does this PR do?

A non-string source raises TypeError while resolving a path. The MCP loader catches the exception and drops the entire overlay, including healthy entries. A non-object JSON root raises AttributeError before entries are read.

The reader checks the sidecar's object shape before accessing nodes and skips entries whose source_file has the wrong type. An inaccessible path is marked stale. An explicit null source still represents a source-less annotation.

Reproduction

Next to graph.json, save .graphify_learning.json containing {"nodes":{"bad":{"source_file":["app.py"]},"good":{"status":"preferred","score":2}}}. Call graphify.reflect.load_learning_overlay with the graph path. A second reproduction is a sidecar containing JSON null or [].

Verification

  • uv sync --all-extras --frozen on Python 3.12.
  • python -m pytest -q --tb=short tests/test_learning_overlay_input.py — 5 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 9997 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.
  • Full Windows Python 3.12 suite: 9828 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. The full Windows run used the initial patch. All 64 focused Windows tests and the full Linux matrix passed on the final revision, which also preserves explicit null sources.

@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:14

@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; no formal proof of the changed code.


Graphify review — findings

Hardens load_learning_overlay so a sidecar whose root isn't a JSON object returns {} instead of raising, and one bad entry no longer hides the healthy ones. Entries whose source_file isn't a string are skipped individually, and that guard also drops entries with an explicit null source_file, which were previously kept as non-stale. If the staleness check hits an OSError or ValueError on a path, the entry is kept and marked stale: True; new tests cover non-object roots and a mixed good, malformed and deleted-file sidecar.

No blocking issues surfaced.

Analysis details — impact, health, verification

Impact & health

Graphify review

Impact — 772 functions depend on the 59 functions this change touches.

Health — grade A; 10 existing hotspot(s) in the area this change touches (pre-existing, not introduced here):

  • _rebuild_code() — 252 callers, 73 callees (high)
  • dispatch_command() — 5 callers, 146 callees (high)
  • main() — 122 callers, 3 callees (high)
  • to_html() — 30 callers, 11 callees (high)
  • aggregate_lessons() — 30 callers, 6 callees (high)
  • run_pipeline() — 8 callers, 13 callees (high)
  • reflect() — 13 callers, 7 callees (high)
  • _run_cli() — 11 callers, 8 callees (high)
  • …and 2 more

Verification — 772 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: 153 function(s) in the blast radius were not formally verified this run

Test selection

Test selection

18 of 519 test file(s) selected (3%) via static blast radius.

  • tests/test_benchmark.py — impact
  • tests/test_benchmark_raw_graph.py — impact
  • tests/test_benchmark_real_query.py — impact
  • tests/test_export.py — impact
  • tests/test_export_direction.py — impact
  • tests/test_html_script_breakout.py — impact
  • tests/test_html_theme.py — impact
  • tests/test_labeling.py — impact
  • tests/test_learning_overlay_input.py — impact, changed-test
  • tests/test_mcp_graph_view_cache.py — impact
  • tests/test_pipeline.py — impact
  • tests/test_query_mcp_direction.py — impact
  • tests/test_reflect.py — impact
  • tests/test_report.py — impact
  • tests/test_serve.py — impact
  • tests/test_serve_http.py — impact
  • tests/test_terraform.py — impact
  • tests/test_watch.py — impact

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.

Keep source-less annotations while discarding malformed non-string paths. Refs Graphify-Labs#5019.

Co-Authored-By: OpenAI Codex <[email protected]>
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). I cherry-picked your commit with -x so it keeps your authorship. Thanks for isolating malformed learning-overlay entries (#5020), @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]: malformed learning sidecar data can hide valid annotations

2 participants