Skip to content

fix: keep PowerShell member calls tied to their receiver - #4163

Closed
oleksii-tumanov wants to merge 2 commits into
Graphify-Labs:v8from
oleksii-tumanov:codex/fix-powershell-receiver-owner-20261006
Closed

oleksii-tumanov wants to merge 2 commits into
Graphify-Labs:v8from
oleksii-tumanov:codex/fix-powershell-receiver-owner-20261006

Conversation

@oleksii-tumanov

Copy link
Copy Markdown
Contributor

What does this PR do?

PowerShell methods with the same name in different classes can create a call edge to the wrong class. Resolve PowerShell member calls only when a direct lexical self or complete unique local type proves the receiver owner; preserve uncertain calls as raw.

Fixes #4158.

Type of change

  • Bug fix
  • New feature
  • Documentation
  • Tests or CI
  • Refactor
  • Security fix

Verification & Invariants

A definite member-call edge must have a proven local receiver owner. Tests cover both class orders, case-insensitive names, duplicate declarations, qualified or partially parsed type literals, properties, nested calls and unresolved member calls through corpus extraction.

  • Read the CONTRIBUTING.md guide.
  • Reproduced the issue and identified the invariant.
  • Made the smallest fix necessary.
  • Added a regression test (if bug fix) or isolated boundary test.
  • Kept the PR description synchronized with the final implementation.
  • Documented any limitations / unsupported cases explicitly.

How was this tested?

uv sync --all-extras --frozen --offline
uv run --frozen pytest tests/test_languages.py -k powershell -q
uv run --frozen pytest tests/test_languages.py tests/test_multilang.py -q
uv run --frozen pytest tests/ -q
uv run --frozen ruff check .
uv run --frozen pyright
uv run --frozen python -m tools.skillgen --check
uv run --frozen python -m tools.skillgen --audit-coverage
uv run --frozen python -m tools.skillgen --schema-singleton
uv run --frozen python -m tools.skillgen --monolith-roundtrip
uv run --frozen python -m tools.skillgen --always-on-roundtrip
uv run --frozen graphify update .

47 PowerShell tests, 565 adjacent language/multilang tests, and 6,634 full tests passed (15 skipped).
Ruff, skill-generation guards and offline graph update passed. Pyright diagnostics match the exact base: 597 on each, no new diagnostics.

No live PowerShell runtime execution; parser/extractor and corpus paths were tested. Reusing an editable same-version cache requires a forced extraction; normal package-version cache invalidation remains unchanged. This does not add type/dataflow, inheritance or cross-file member inference.

Graphify-specific checklist

  • I updated generated skill artifacts when changing their source fragments. (Not applicable: no source fragments changed; generation guards passed.)
  • I confirmed that AST/structural extraction remains deterministic (no ambient state dependencies like ENV variables).
  • I reviewed changes for security implications (no unsafe interpolation into shell/Python).
  • I confirmed no API keys or local-only graph data are included.
  • (If applicable) I disclosed AI authorship in my commit messages.

AI assistance is disclosed separately in AI-Assistance commit metadata.

@github-actions

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown

Thanks for the pull request, @oleksii-tumanov. 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.

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

Looks safe to merge — no coupling regressions and no blocking issues, checked against the code graph (not a self-assessment).

Formal verification. PR-changed functions: 1/1 verified (0 proven, 1 may-equivalent, 0 distinguished) · 0 not verified.


Graphify review — findings

Fixes PowerShell member-call resolution so $this.M() and [Type]::M() bind to the method on the receiver's own class instead of any same-named method in the file. A call resolves only when the receiver is $this inside a uniquely named class, or a complete, error-free [Type] literal naming exactly one local class (case-insensitive), and the member is a plain name. Every other receiver (typed or local variables, chained, cast, dynamic, nested or assembly-qualified types, and duplicate class names) now stays in raw_calls as an unresolved member call rather than guessing a target.

No blocking issues surfaced. 2 lower-confidence candidates did not survive cross-model review.

Analysis details — impact, health, verification

Impact & health

Graphify review

Impact — 656 functions depend on the 656 functions this change touches.

Health — this change adds coupling hotspots:

  • new: extract_powershell() — 26 callers, 6 callees
  • new: extract_powershell_manifest() — 10 callers, 3 callees
  • new: walk() — 1 callers, 6 callees

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

Test selection

Test selection

1 of 334 test file(s) selected (0%) via static blast radius.

  • tests/test_languages.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.

Docs that may be stale (advisory)

Formal verification

No difference found (not proven): No behavior difference found in extract\_powershell (not a proof).

The verifier ran both versions of extract\_powershell 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.

· 3 more finding(s) on lines outside this diff (see the check run).

safishamsi pushed a commit that referenced this pull request Oct 6, 2026
Replaces the name-only member-call resolver with receiver-proven binding:
$this.M() binds to the enclosing class only when its name is unique, and
[Type]::M() only to a single unambiguous local class; value/cast/dynamic/
duplicate/external receivers fall through to raw_calls. Fixes the same-name-
method caveat from the 0.9.77 member-call work (#3992).

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

Copy link
Copy Markdown
Member

Landed in v0.9.78 via an authorship-preserving cherry-pick, so your commit is on v8 with you credited as the author. Closing as shipped — thanks @oleksii-tumanov!

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.

[Bug]: PowerShell member calls bind to another class with the same method name

2 participants