Skip to content

fix(powershell): link enum members with case_of instead of contains - #4092

Closed
rajatnagda45 wants to merge 1 commit into
Graphify-Labs:v8from
rajatnagda45:fix/powershell-enum-case-of
Closed

rajatnagda45 wants to merge 1 commit into
Graphify-Labs:v8from
rajatnagda45:fix/powershell-enum-case-of

Conversation

@rajatnagda45

Copy link
Copy Markdown
Contributor

Problem

Closes #4091.

A PowerShell enum linked its members to the enum with a contains edge — the relation used for real declared members. Every other language with enums emits case_of per member (Java #1719, C#, Swift, Rust, VB.NET #4054). PowerShell was still an outlier.

Implementation

One-line relation change in graphify/extractors/powershell.py: the enum-member edge now uses case_of instead of contains. File-level containment of the enum type itself is untouched and keeps contains.

This is not cosmetic: case_of targets are excluded from constructor binding (_member_nids in extract.py), so an enum member named like a type can no longer be mistaken for a constructable member.

Verification

  • Updated the existing test_powershell_enum_is_extracted_and_reference_resolves to expect case_of, and added test_powershell_enum_members_emit_case_of_not_contains. Verified the new test FAILS on pre-fix v8 and passes with the change.
  • uv run pytest tests/ → 6491 passed, 15 skipped (security/wheel env-only tests deselected).
  • ruff check clean; pyright on the changed file adds no new errors (the single pre-existing _make_id baseline error is unchanged).

Limitations

PowerShell class properties are not emitted as member nodes today, so the regression test uses the file→enum containment edge as the contains control.

A PowerShell enum member is a discriminant case, not a declared field, so it
should hang off its enum with a case_of edge like every other language that
has enums (Java Graphify-Labs#1719, C#, Swift, Rust, VB.NET). PowerShell was routing enum
members through the same contains path used for class members.

The relation is not cosmetic: case_of targets are excluded from constructor
binding, so an enum member named like a type could previously be mistaken for
one.

Update the existing enum test to expect case_of and add a focused regression
test asserting enum members get case_of (and not contains) while the file
still contains the enum type via contains.
@github-actions

github-actions Bot commented Oct 5, 2026

Copy link
Copy Markdown

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

Switches PowerShell enum members to hang off their enum via case_of instead of contains, matching how Java, C#, Swift, Rust and VB.NET model enum cases. Because case_of targets are excluded from constructor binding, an enum member whose name matches a type no longer resolves as that type. The file-to-enum relation still uses contains, and a new test pins down both relations.

No blocking issues surfaced. 1 lower-confidence candidate did not survive cross-model review.

Analysis details — impact, health, verification

Impact & health

Graphify review

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

Health — this change adds coupling hotspots:

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

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

Test selection

Test selection

1 of 329 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

Copy link
Copy Markdown
Member

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

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.

PowerShell enum members use contains instead of case_of

2 participants