Skip to content

fix(python): scope-resolution coverage gaps — F57, F58, F61 (#1932)#1964

Open
prajapatisparsh wants to merge 9 commits into
abhigyanpatwari:mainfrom
prajapatisparsh:fix/python-parsing-coverage
Open

fix(python): scope-resolution coverage gaps — F57, F58, F61 (#1932)#1964
prajapatisparsh wants to merge 9 commits into
abhigyanpatwari:mainfrom
prajapatisparsh:fix/python-parsing-coverage

Conversation

@prajapatisparsh
Copy link
Copy Markdown
Contributor

Closes #1932.
F57: heritage patterns for qualified/subscripted bases
F58: decorator patterns for nested-attribute decorators
F61: lambda as @scope.function
F59 already closed by #1920, F60 legacy-only

…patwari#1932)

F57: heritage patterns for qualified/subscripted bases
F58: decorator patterns for nested-attribute decorators
F61: lambda captured as @scope.function
F59 already closed by abhigyanpatwari#1920, F60 legacy-only
@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 1, 2026

@prajapatisparsh is attempting to deploy a commit to the NexusCore Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 1, 2026

CI Report

All checks passed

Pipeline Status

Stage Status Details
✅ Typecheck success tsc --noEmit
✅ Tests success unit tests, 3 platforms
✅ E2E success gitnexus-web changes only

Test Results

Tests Passed Failed Skipped Duration
10782 10772 0 10 643s

✅ All 10772 tests passed

10 test(s) skipped — expand for details
  • COBOL pipeline benchmark > scales with file count
  • C# pipeline benchmark > scales with file count — namespaces spread across the solution
  • C# pipeline benchmark > scales with file count — all types in one (global) namespace bucket
  • C# pipeline benchmark > scales with file count — all types in one (named) namespace bucket
  • Go pipeline benchmark > scales with file count (workers enabled)
  • Go pipeline benchmark — worker pool (issue Worker idle timeout kills long Go scope extraction and surfaces as Napi::Error during analyze #1848) > does not quarantine the large generated Go file on sub-batch idle timeout
  • PHP pipeline benchmark > scales with file count (workers enabled)
  • Ruby pipeline benchmark > scales with file count (workers enabled)
  • Rust pipeline benchmark > scales with file count (workers enabled)
  • buildTypeEnv > known limitations (documented skip tests) > Ruby block parameter: users.each { |user| } — closure param inference, different feature

Code Coverage

Tests

Metric Coverage Covered Base Delta Status
Statements 80.35% 37500/46667 79.84% 📈 +0.5 🟢 ████████████████░░░░
Branches 68.91% 23873/34642 68.5% 📈 +0.4 🟢 █████████████░░░░░░░
Functions 85.45% 3885/4546 84.94% 📈 +0.5 🟢 █████████████████░░░
Lines 83.92% 33743/40205 83.36% 📈 +0.6 🟢 ████████████████░░░░

📋 View full run · Generated by CI

@magyargergo
Copy link
Copy Markdown
Collaborator

Could you please resolve the conflict?

Copy link
Copy Markdown
Collaborator

@magyargergo magyargergo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Methods

5 Claude lanes (gitnexus-risk-architect, gitnexus-test-ci-verifier, ce-correctness-reviewer, ce-adversarial-reviewer) + Codex (codex-rescue). Codex was live. Two engines are Claude under different personas; strong signal = Codex + Claude agreement on decorator wiring and golden drift.

Final verdict

not production-ready

Capture/query work for F58/F61 and new tests are directionally right, but F58 does not reach ReferenceSites, the python-captures golden is still stale (reproduced locally), and the PR lowers global coverage thresholds while CI remains red. F57 query patterns are largely redundant on this branch because merged main already ships synthesizePythonInheritanceReferences in captures.ts (#1951)—qualified bases do emit inherits sites today; the PR’s @heritage.* tags remain topic: unknown in scope-extractor.ts.

Merge state classification

checks failing

Branch hygiene classification

merge-from-main commit present but harmless and merge-safe


Review bar for this PR

Issue #1932: close Python scope-resolution gaps F57 (heritage shapes), F58 (decorators), F61 (lambda scopes). Expect capture + registry-primary graph effects, golden/bench parity, and green CI.

Current PR state

  • 5 files in GitHub diff: query.ts, integration tests, heritage.py, bench fingerprint, vitest.config.ts.
  • 10/10 new integration tests pass locally (emitPythonScopeCaptures only).
  • Cross-repo head from prajapatisparsh/fix/python-parsing-coverage.

Merge status and mergeability

mergeable: MERGEABLE, mergeStateStatus: BLOCKED (required checks). Two merge-from-main commits on the branch; no conflict markers in the reviewed diff.

Repository history considered

  • #1951 / #1956 migrated inheritance to scope-resolution (captures.ts synthesis)—landed via merge from main, not in this PR’s 5-file diff.
  • Prior CI on older SHA showed golden failure; latest run still has benchmarks FAIL (coverage/scope-parity pending at review time).

PR-specific assessment

Parser / scope query (query.ts)

  • F61 lambda (lambda) @scope.function: creates Function scopes — solid [code-read].
  • F58 decorators @reference.decorator.call: emitted by tree-sitter, dropped in pass5CollectReferences because referenceKindFromAnchor has no decorator head (scope-extractor.ts:1027-1048, guard at :990-991). [code-read] extractParsedFile(@login_required)referenceSites: [].
  • F57 @heritage.* in query: matches are topicOfunknown (scope-extractor.ts:259-270) and skipped. However, captures.ts:208-225 synthesizes @reference.inherits from AST on merged head — class A(mod.Base){name:'Base', kind:'inherits'} [code-read]. PR query heritage is not what fixes EXTENDS on current head.
  • Duplicate captures: @api.v1.endpoint2 identical @reference.decorator.call rows (patterns at :260-270 overlap) [reproduced].

Tests / CI

  • P0 Golden expected-captures.json not updated; python-captures-golden.test.ts fails (189 vs 190 keys; synthetic:dao-20 +20 groups from new decorator captures) [reproduced].
  • P2 vitest.config.ts lowers all four coverage floors by 1 point—risks masking regressions while golden is still red.
  • Tests never call extractParsedFile / assert graph edges for F58.

Back-and-forth avoided by verifying

  • Ran python-parsing-coverage.test.ts (pass) and python-captures-golden.test.ts (fail).
  • emitPythonScopeCaptures duplicate count for nested decorators.
  • extractParsedFile for decorator and class A(mod.Base) on PR head.
  • bench/python-scope/measure.mjs --check PASS locally; CI benchmarks job FAIL on latest SHA (log pending).

Open questions

  • Is lowering vitest coverage thresholds intentional for capture inflation, or should golden regeneration make that unnecessary?
  • Should F58 use @reference.call.member / .free instead of a new decorator tag?

Inline findings (summary)

  1. P0@reference.decorator.call never becomes a ReferenceSite.
  2. P1 — Overlapping nested-decorator patterns double-match.
  3. P2 — Tests only assert capture layer; F58 untested end-to-end.
  4. P2 — Coverage thresholds lowered in vitest.config.ts.

Lower priority (body only)

  • Regenerate test/fixtures/python-captures-golden/expected-captures.json (UPDATE_GOLDEN=1 …) — blocks merge.
  • heritage.py unused by tests; PYTHON_QUERIES decorator block still single-hop identifier receiver (legacy routes)—out of this diff.
  • @app.route still produces module-scoped @reference.call.member for inner route call (pre-existing path).

Refuted / validated

  • Refuted as sole F57 fix: query-only @heritage.* without pipeline wiring (superseded on branch by captures.ts synthesis from main).
  • Validated: F61 lambda scope counts; heritage capture text for bare/qualified/subscripted snippets.

Automated multi-tool digest (1 Codex + 5 Claude lanes)—verify before acting.

return_type: (type) @type-binding.type) @type-binding.return

;; Decorators — simple @decorator
(decorator
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P0 — F58 never reaches the graph [code-read]

Trigger: Any @login_required / @app.route processed through registry-primary Python.

Evidence: Tag @reference.decorator.callreferenceKindFromAnchor parses head decorator (not in switch) → undefinedpass5CollectReferences skips (scope-extractor.ts:990-991, 1027-1048). extractParsedFile on @login_requiredreferenceSites: [].

Fix: Rename to existing @reference.call.free / .member, or add case 'decorator': return 'call' + pipeline test asserting referenceSites.

Blocks merge: yes (claimed F58 behavior not end-to-end)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@prajapatisparsh you missed this

attribute: (identifier) @reference.name)) @reference.decorator.call

;; Decorators — @a.b.decorator (nested attributes)
(decorator
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 — duplicate decorator captures [reproduced]

Trigger: @api.v1.endpoint on a function.

Evidence: Pattern at :260-264 (object: (_)) and :266-270 (object: (attribute)) both match nested attributes → 2 identical @reference.decorator.call rows (same range). Tests use toBeGreaterThanOrEqual(1) so this is invisible.

Fix: Make patterns disjoint (e.g. restrict :260 to object: (identifier) only) or dedupe in captures.ts; assert toBe(1) in F58 nested test.

Blocks merge: maybe (becomes edge inflation if F58 wiring is fixed)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@prajapatisparsh this was missed too

Comment thread gitnexus/test/integration/resolvers/python-parsing-coverage.test.ts Outdated
Comment thread gitnexus/vitest.config.ts Outdated
…lden regeneration, thresholds reverted, baseline update
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 1, 2026

✨ PR Autofix

Found fixable formatting / unused-import issues across 14 changed lines. Comment /autofix on this PR to apply them, or run npm run lint:fix && npm run format locally.

{"schema":"gitnexus.pr-autofix/v2","state":"fixes-available","pr_number":1964,"changed_lines":14,"head_sha":"42be3b2211b4c8da01988e116470ffc5d492b17d","run_id":"26773747052","apply_command":"/autofix"}

Comment thread gitnexus/test/integration/resolvers/python-parsing-coverage.test.ts Fixed
Comment thread gitnexus/test/integration/resolvers/python-parsing-coverage.test.ts Fixed
Comment thread gitnexus/test/integration/resolvers/python-parsing-coverage.test.ts Fixed
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.

Python: parsing-layer coverage gaps (5 findings)

3 participants