fix: scope endpoint identity by project and honour the URL host when linking - #883
Conversation
…re-endpoint-identity
…re-endpoint-identity
…re-endpoint-identity
…re-endpoint-identity
|
@greptile review |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughEndpoint resources now use project-scoped qualified names and project metadata. Live endpoint linking narrows candidates by normalized host and project stems while preserving legacy fallback behavior. Tests cover the updated identity and linking semantics. ChangesProject-scoped endpoint resolution
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant EndpointResources
participant link_endpoints
participant NetworkURL
EndpointResources->>link_endpoints: provide endpoint identity and project
NetworkURL->>link_endpoints: provide hostname and URL template
link_endpoints->>link_endpoints: compare normalized host and project stems
link_endpoints->>NetworkURL: create matching RESOLVES_TO edges
Possibly related issues
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Greptile SummaryThis PR scopes endpoint linking to the service named by each URL host. The main changes are:
Confidence Score: 5/5This looks safe to merge. The legacy-row fix keeps project-less endpoints linkable when a host matches a scoped project. The project-name fix removes only the final generated suffix. No blocking issues were found in the changed code.
What T-Rex did
Important Files Changed
Reviews (3): Last reviewed commit: "style: apply ruff format" | Re-trigger Greptile |
Greptile SummaryThis PR scopes endpoint resources by project and uses URL hosts to narrow endpoint linking. The main changes are:
Confidence Score: 4/5The host-aware linking path can still drop valid legacy links or fail to narrow realistic service hosts.
What T-Rex did
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Network URL] --> B[Parse and normalize host]
C[Live endpoint resources] --> D[Normalize project names]
B --> E{Matching project endpoints exist?}
D --> E
E -->|Yes| F[Use matching project endpoints]
E -->|No| G[Use all endpoints]
F --> H[Check direction and path template]
G --> H
H --> I[Create RESOLVES_TO edges]
Prompt To Fix All With AIFix the following 3 code review issues. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 3
codebase_rag/parsers/endpoints.py:347
**Mixed Graph Drops Legacy Endpoints**
When a hostname matches any project-owned endpoint, `owned` becomes non-empty and this branch excludes every legacy endpoint whose `project` is null. During a partial migration, matching legacy routes therefore lose their existing `RESOLVES_TO` edges even though legacy rows are meant to remain linkable.
### Issue 2 of 3
codebase_rag/parsers/endpoints.py:318
**Project Stem Truncates Valid Names**
A project base name can itself contain `__`, such as `billing__worker`; its generated name becomes `billing__worker__<hash>`, but splitting at the first separator reduces the stem to `billing`. Requests to the corresponding `billing__worker` service then miss host scoping and retain cross-project fan-out.
### Issue 3 of 3
codebase_rag/parsers/endpoints.py:310-311
**Cluster FQDN Bypasses Host Scoping**
A Kubernetes URL such as `http://user-service.default.svc.cluster.local/health` yields the full hostname, which cannot equal the `user-service` project stem. The linker therefore falls back to all endpoints and can recreate the cross-project traces this change is intended to remove.
Reviews (2): Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." | Re-trigger Greptile |
|
@greptile review |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@codebase_rag/tests/test_endpoint_extraction.py`:
- Around line 551-562: Update
test_project_stem_keeps_double_underscore_base_names to assert that the single
created link targets the order__worker__2adc9027 endpoint, not merely that one
link was created. Use the returned link/edge data from helper._link and preserve
the existing cardinality assertion.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 78133c30-e084-413d-b05c-801e1aa07b92
📒 Files selected for processing (2)
codebase_rag/parsers/endpoints.pycodebase_rag/tests/test_endpoint_extraction.py
🚧 Files skipped from review as they are similar to previous changes (1)
- codebase_rag/parsers/endpoints.py
|



Fixes #879.
ENDPOINT resources were keyed by
METHOD /templatealone, so two services exposingGET /healthcollapsed into one shared node with EXPOSES edges from both handlers, and any matching URL's trace fanned out to every service, including ones the call can never reach. The URL names its target service in the host (compose and cluster DNS use the service name) and that evidence was discarded.Endpoint qns are now scoped by owning project (
resource::ENDPOINT::<project>::METHOD /template, with aprojectproperty; EXPOSES always comes from within one project, so the owner is known at emission). The linker became host-aware: when the URL's hostname stem matches an indexed project's name stem (hash suffix stripped, underscores and dashes interchangeable), only that project's endpoints are candidates; a host matching no project keeps the full permissive fan-out, and legacy endpoint rows without a project stay linkable. This also stops unknown-lead (/**) templates in one project from tail-matching another service's URLs.Verified live on a five-project graph (three fixture services plus fastapi/full-stack-fastapi-template and paurakhsharma/python-microservice-fastapi): the health-check trace now reaches only the addressed service, and every one of the seven caller-to-handler traces is exact, with zero cross-project fabrication.
RED then GREEN in commit history; combined with the direction gate from #881 in one linker pass.
Summary by CodeRabbit