Skip to content

fix(bash): resolve caller-defined variable bases in sourced scripts (#5563) - #5602

Closed
m3lonxd wants to merge 1 commit into
Graphify-Labs:v8from
m3lonxd:fix/bash-caller-var-base-5563
Closed

m3lonxd wants to merge 1 commit into
Graphify-Labs:v8from
m3lonxd:fix/bash-caller-var-base-5563

Conversation

@m3lonxd

@m3lonxd m3lonxd commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #5563.

This is the surgical follow-up to #5592 requested by @safishamsi, rebased and layered directly on top of #5589 (cross-library sibling-sourced resolution) and #5597 (single-script variable tracking) in v0.9.123.

Rather than the earlier ~1500-line rewrite, this PR adds ONLY the distinct missing capability for caller-defined variable bases in sourced scripts (. "$VAR/rel.sh" / source "$VAR/rel.sh"):

  1. Source-order snapshotting: Top-level variable assignments, declarations, and unsets are tracked in program order. Sourcing snapshots active variable bases; assignments occurring after source lines do not leak backward.
  2. Propagation across sourcing chains: Propagates caller variable bases across nested sourcing chains (entry.sh -> bootstrap.sh -> lib/x.sh) using bounded fixed-point propagation.
  3. Multi-caller conflict & cycle safety: Conflicting caller bases or unmodeled/poisoned assignments (None poison sentinel) fail closed with 0 false edges.
  4. Decoy supersede: Outdated local fallback decoy edges (Bash: source "${VAR}/lib.sh" emits an unresolvable edge — sourced libraries appear orphaned #2079) are cleanly superseded and removed when caller variables resolve to different targets.
  5. Fail-closed security: Strict UNC and out-of-scan-root probe guards prevent stat probes outside scan_root at both extraction and resolution stages.
  6. Zero cache drift: Leaves graphify/cache.py completely untouched (0 diff lines), preserving AST cache schema 59.

Testing & Verification

  • 147 passed on targeted test suites (tests/test_symbol_resolution.py, tests/test_unc_probe_guard.py, tests/test_extract.py -k "bash or unc or 5563").
  • Full test suite passes: 12,165 passed in parallel suite, 285 passed in serial suite.
  • Clean ruff check ., clean bandit -ll, and 100% python -m tools.skillgen --check audit compliance.

…raphify-Labs#5563)

Surgical resubmission of Graphify-Labs#5592 layered directly on Graphify-Labs#5589 cross-library
sibling-sourced resolution and Graphify-Labs#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 Graphify-Labs#5563
@m3lonxd
m3lonxd requested a review from safishamsi as a code owner November 28, 2026 21:32
@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.

@github-actions github-actions Bot added the contributor Pull request from a returning community contributor label Nov 28, 2026

@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 · 10 possible issues to check · Merge confidence 5/5

10 possible issues to check · High impact

The Bash extractor now tracks variable assignments in source order and records variable-based source paths for cross-file resolution.

10 possible issues we couldn't confirm

They don't change the score.

What this review covered
  • Some lookups asked for files or lines that do not exist; the review was told and carried on.
  • 5 of 5 changed files inspected. This is scope, not a correctness guarantee.
Code graph · 4139 functions depend on this change
  • 4 functions became more coupled. Largest: extract() (1429 callers), extract_bash() (62 callers), resolve_bash_source_edges() (18 callers).
  • 3 of 658 test files are affected by this change.
  • Gate, test list and every flagged function: in the Graphify check.

Reviewed cb00f8a

safishamsi added a commit that referenced this pull request Nov 30, 2026
Extractor accuracy (Swift #5641, Apex #5627, Python #5647, TypeScript
#5604/#5614/#5612, Bash caller-var #5602), GitHub Actions run-step
extraction (#5603), incremental correctness (#5634/#5638/#5636), symlink
and semantic-cache fixes (#5617/#5618), export/report hardening and perf
(#5643/#5644/#5645/#5646/#5619/#5620/#5621), and CLI/docs/skill/install
work (#5629/#5628/#5626/#5624/#5623/#5625/#5642/#5583). AST cache schema
59 to 60; Swift/Apex/Python/Bash/GHA inputs re-extract on first build.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@safishamsi

Copy link
Copy Markdown
Member

Landed in v0.9.124 (just released to PyPI), cherry-picked with your authorship preserved so it shows under your name in the history. Thanks @m3lonxd for resolving caller-defined variable bases in sourced scripts — verified green in the full suite and, where applicable, smoke-tested against the published package. 🙏

@safishamsi safishamsi closed this Nov 30, 2026
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.

Bash extractor: a sourced file's . "$ROOT/lib/x.sh" gets no edge when ROOT is set by the script that loads it

2 participants