Skip to content

fix(analyzer): path-qualify SERVICE node IDs to break PK collisions#151

Merged
aksOps merged 1 commit into
mainfrom
fix/enrich-duplicate-pk-service-id
May 13, 2026
Merged

fix(analyzer): path-qualify SERVICE node IDs to break PK collisions#151
aksOps merged 1 commit into
mainfrom
fix/enrich-duplicate-pk-service-id

Conversation

@aksOps
Copy link
Copy Markdown
Contributor

@aksOps aksOps commented May 13, 2026

Summary

`ServiceDetector` emitted node IDs as `service:`. In real polyglot codebases two modules can share a service name (e.g. `frontend/widgets/checkbox/` and `backend/components/checkbox/` both with `name = "checkbox"` in pyproject.toml) and the IDs collided. Kuzu's `BulkLoadNodes` COPY aborts the whole batch on duplicate PK — `codeiq enrich ~/projects/` exited non-zero with:

```
Copy exception: Found duplicated primary key value service:checkbox
```

Fix

  • Switch IDs to `service::` (e.g. `service:frontend/widgets/checkbox:checkbox`).
  • Root module (empty dir) uses `.` so the format stays consistent with the existing `FilePath` stamping at line 171.
  • Flip CONTAINS edge IDs from `edge:service::contains:...` to `edge:<sn.ID>:contains:...` — `sn.ID` is now the path-qualified identifier, `sn.Label` remains the friendly display name.

Test plan

🤖 Generated with Claude Code

ServiceDetector emitted node IDs as `"service:" + name`. When a
codebase contains two modules in different directories sharing a
service name (e.g. `frontend/widgets/checkbox/` and
`backend/components/checkbox/` both with `name = "checkbox"` in
pyproject.toml) the IDs collided. Kuzu's BulkLoadNodes COPY aborts
the whole batch on duplicate PK, so enrich exited non-zero on real
polyglot trees (~/projects/, polyglot-bench).

Switch IDs to `service:<dir>:<name>`, falling back to `.` for the
root module so the format mirrors the existing FilePath stamping.
Edge IDs flip from `edge:service:<label>:contains:...` to
`edge:<sn.ID>:contains:...` for consistency — sn.ID is now the
path-qualified identifier, sn.Label remains the friendly display
name.

Adds TestServiceDetectorPathQualifiedIDsBreakCollision which fails
on main and passes after this patch.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@aksOps aksOps merged commit 4a6d82a into main May 13, 2026
13 checks passed
@aksOps aksOps deleted the fix/enrich-duplicate-pk-service-id branch May 13, 2026 15:19
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.

1 participant