Skip to content

fix(bash): resolve cross-library calls between sibling sourced scripts - #5589

Closed
m3lonxd wants to merge 1 commit into
Graphify-Labs:v8from
m3lonxd:fix/bash-sourced-sibling-call-edges-5564
Closed

m3lonxd wants to merge 1 commit into
Graphify-Labs:v8from
m3lonxd:fix/bash-sourced-sibling-call-edges-5564

Conversation

@m3lonxd

@m3lonxd m3lonxd commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

Closes #5564

What does this PR do?

Resolves Bash function calls across sibling libraries sourced into the same entry-script namespace during resolve_bash_source_edges, while preserving incremental-mode reachability context from extract().

Changes

  • graphify/symbol_resolution.py:
    • Added _context_file_nid helper to extract file-level node IDs from incremental context_nodes.
    • Updated resolve_bash_source_edges to accept keyword-only context_nodes and context_edges and resolve calls with strict three-tier precedence:
      1. Direct targets defined in files directly sourced by the caller (EXTRACTED, 1.0).
      2. Targets reachable via the caller's own transitive imports_from closure (EXTRACTED, 1.0), guarded by cycle-safe BFS/DFS.
      3. Targets defined in sibling files belonging to shared entry-script load pools (INFERRED, 0.85), remaining fail-closed on intra-pool ambiguity and deduplicated across shared pools.
  • graphify/extract.py: Passed context_nodes=resolution_context_nodes and context_edges=resolution_context_edges into resolve_bash_source_edges.
  • tests/test_symbol_resolution.py: Added regression test test_bash_sibling_libraries_sourced_by_same_entry_resolve_cross_calls (proven failing on pre-fix v8) plus tests covering tier precedence, multi-pool ambiguity, cross-pool isolation, cyclic transitive sources, and incremental context_nodes/context_edges.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Verification & Invariants

  • Deterministic output: sorted graph traversal order for transitive closures, entry roots, pools, and candidate matches.
  • Fail-closed behavior: ambiguous definitions within direct/transitive scope or within an entry pool produce no speculative edge; separate entry pools remain isolated unless linked by a shared entry script.
  • Provenance preserved: inferred sibling-pool edges are tagged INFERRED (confidence_score=0.85), keeping direct/own-transitive edges distinct as EXTRACTED (1.0).

How was this tested?

  • uv run --frozen pytest tests/test_symbol_resolution.py tests/test_node_id_canonical.py tests/test_cache.py tests/test_affected_cli.py tests/test_extractors_registry.py -q (159 passed, 1 skipped Windows-only test)
  • uv run --frozen pytest tests/test_extract.py -k 'bash' -q (66 passed, 309 deselected)
  • uv run --frozen ruff check . (passed)
  • uv run --frozen pyright tests/test_symbol_resolution.py (0 errors)
  • uv run --frozen python -m tools.skillgen --check (134 artifacts OK)

Graphify-specific checklist

  • Narrow, atomic change targeting only the issue scope
  • Regression test reproduces the pre-fix failure
  • Co-Authored-By trailer included

Resolve bash function calls across sibling libraries sourced by the
same entry script via three-tier precedence: direct edges (EXTRACTED),
own transitive reach (EXTRACTED), and sibling entry-pool targets
(INFERRED, 0.85 confidence) while remaining fail-closed on intra-pool
ambiguity and passing incremental resolution context through extract().

Fixes Graphify-Labs#5564

Co-Authored-By: Gemini <[email protected]>
@m3lonxd
m3lonxd requested a review from safishamsi as a code owner November 28, 2026 13:07
@github-actions

Copy link
Copy Markdown

Thanks for the pull request, @m3lonxd. 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.11 and 3.13, and that the change keeps extraction deterministic.

@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 review View in Graphify

Nothing blocking · 5 possible issues to check · Merge confidence 5/5

5 possible issues to check · High impact

Bash call resolution now uses transitive source relationships and shared entry-script pools to find functions in sibling libraries.

5 possible issues we couldn't confirm

They don't change the score.

Code graph · 5324 functions depend on this change
  • 2 functions became more coupled. extract() (1420 callers), resolve_bash_source_edges() (15 callers).
  • 383 of 652 test files are affected by this change.
  • Gate, test list and every flagged function: in the Graphify check.

Reviewed 0633b43

@safishamsi

Copy link
Copy Markdown
Member

Shipped in v0.9.123, landed via authorship-preserving cherry-pick so your commits keep your name. Thanks @m3lonxd!

@safishamsi safishamsi closed this Nov 28, 2026
safishamsi pushed a commit that referenced this pull request Nov 30, 2026
…5563)

Surgical resubmission of #5592 layered directly on #5589 cross-library
sibling-sourced resolution and #5597 variable tracking.

- Tracks caller assignments in source order at program level
- Propagates caller-defined variable bases across sourcing chains
- Fails closed on UNC, out-of-root, cycles, and multi-caller conflicts
- Supersedes local fallback decoy edges

Fixes #5563

(cherry picked from commit cb00f8a)
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.

Bash extractor: a call from one sourced library to another, both loaded by the same script, gets no edge

2 participants