Skip to content

feat: enrich INHERITS edges from SCIP's compiler-verified relationships#23

Open
pradeepmouli wants to merge 3 commits into
intuit:mainfrom
pradeepmouli:fix/scip-inherits-enrichment
Open

feat: enrich INHERITS edges from SCIP's compiler-verified relationships#23
pradeepmouli wants to merge 3 commits into
intuit:mainfrom
pradeepmouli:fix/scip-inherits-enrichment

Conversation

@pradeepmouli

Copy link
Copy Markdown
Contributor

Summary

import_scip_index defines an ImportStats.relations_added counter that's displayed in CLI output but was never actually incremented — SCIP's Relationship.is_implementation field (compiler/language-server-verified "Dog implements/extends Animal" data) was parsed into the index but discarded.

This maps is_implementation relationships onto RelationKind::Inherits, the same relation kind tree-sitter's @inherit.child/@inherit.parent captures already produce. SCIP has no separate flag for "extends" vs "implements" (the scip crate's own doc comment for is_implementation uses exactly the Dog implements Animal example), and no language's relations.scm distinguishes them either, so this keeps both sources consistent without touching any of the ~13 existing Inherits-consuming call sites (pattern detection, type-hierarchy traversal, viz, export, multi-repo graph combination).

Resolution reuses the existing scip_sym_to_file_name + file_name_to_ids two-step lookup and the Parquet-COPY-with-UNWIND-fallback bulk write already used for CALLS edges.

Verification

Verified end-to-end against a real scip-typescript index of a TypeScript monorepo (the only readily available real indexer that emits is_implementationrust-analyzer's SCIP output has zero Relationship entries of any kind, so it can't exercise this path): INHERITS edge count went from 38 to 249, with correct edges surfacing real interface implementations (e.g. WebSocketTransport.onError -> Transport.onError).

Test plan

  • cargo test -p infigraph-core --lib scip:: — 2 new unit tests (is_implementation_relationship_creates_inherits_edge, non_implementation_relationship_does_not_create_inherits_edge) covering both the positive case and that non-is_implementation relationships (e.g. is_reference) are correctly ignored
  • cargo build -p infigraph-core
  • End-to-end verification against a real scip-typescript-generated index (see above)

🤖 Generated with Claude Code

https://claude.ai/code/session_01TAXDJyFdnA4BV1U2fxufdC

import_scip_index defined an ImportStats.relations_added counter that
was displayed in CLI output but never actually incremented -- SCIP's
Relationship.is_implementation field (compiler/language-server-verified
"Dog implements/extends Animal" data) was parsed into the index but
discarded.

Map is_implementation relationships onto RelationKind::Inherits, the
same relation kind tree-sitter's @inherit.child/@inherit.parent
captures already produce. SCIP has no separate flag for "extends" vs
"implements" (confirmed against the scip crate's own doc comment,
which uses exactly the Dog-implements-Animal example for
is_implementation), and no language's relations.scm distinguishes them
either, so this keeps both sources consistent. Resolution reuses the
same scip_sym_to_file_name + file_name_to_ids two-step lookup and
Parquet-COPY-with-UNWIND-fallback bulk write already used for CALLS
edges.

Verified end-to-end against a real scip-typescript index of lspeasy
(the only available real indexer that emits is_implementation --
rust-analyzer's scip output has zero Relationship entries of any kind):
INHERITS edges went from 38 to 249, with correct edges like
WebSocketTransport.onError -> Transport.onError.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TAXDJyFdnA4BV1U2fxufdC
@murari316

Copy link
Copy Markdown
Collaborator

@pradeepmouli we've got few features lineup, would you be interested to work on them? after fixing all these bugs that you're raising PRs for?

@pradeepmouli

Copy link
Copy Markdown
Contributor Author

@pradeepmouli we've got few features lineup, would you be interested to work on them? after fixing all these bugs that you're raising PRs for?

I would love to

Unrelated to this PR's SCIP INHERITS-enrichment change, but the
pre-commit hook's fmt/clippy checks block all commits until fixed.
- scip/mod.rs: cargo fmt drift
- lsp-to-scip/main.rs, vuln/mod.rs: allow question_mark /
  useless_borrows_in_formatting lints that newly apply because the
  'stable' toolchain drifted since this code was written in May, not
  because the code changed (CI's dtolnay/rust-toolchain@stable also
  resolves to rustc 1.97.x).
Rewrites the two spots suppressed in the prior commit instead of
disabling the lints:
- lsp-to-scip/main.rs: replace if-let/else-if-let/else with ? operator
- vuln/mod.rs: remove redundant & in format! arg
@pradeepmouli

Copy link
Copy Markdown
Contributor Author

@pradeepmouli we've got few features lineup, would you be interested to work on them? after fixing all these bugs that you're raising PRs for?

I would love to

How'd you like to proceed?

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.

2 participants