fix(graph): resolve relationship endpoints case-insensitively, accept body-form tags#957
fix(graph): resolve relationship endpoints case-insensitively, accept body-form tags#957shgew wants to merge 1 commit into
Conversation
… body-form tags Two fixes inside parseGraphXml: 1. Normalize endpoint names (trim + lowercase) via a name->node map so edges whose source/target differ only in case still resolve. 2. Parse both self-closing <relationship .../> AND body-form <relationship>...</relationship> elements. The original regex only matched self-closing. Adds a referential-integrity rule plus a few-shot to the extraction prompt so models emit endpoints that reference declared entities. Relations scored ~1/5 for every locally-hosted model in benchmarks even when entity extraction worked. Root cause was this parser plus prompt combination, not model capability: a perfect model could not satisfy both the case-sensitive name match and the self-closing-only XML expectation. Tests: test/graph-prompt.test.ts (+13 lines), test/graph.test.ts (+79 lines). Signed-off-by: Hleb Shauchenka <me@marleb.org>
|
@shgew is attempting to deploy a commit to the rohitg00's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthrough
ChangesGraph Relationship Resolution
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
What
Two fixes inside
parseGraphXml:name->nodemap so edges whosesource/targetdiffer only in case still resolve.<relationship .../>AND body-form<relationship>...</relationship>elements. The original regex only matched self-closing.Adds a referential-integrity rule plus a few-shot to the extraction prompt so models emit endpoints that reference declared entities.
Why
Relations scored ~1/5 for every locally-hosted model in benchmarks even when entity extraction worked. Root cause was this parser plus prompt combination, not model capability: a perfect model could not satisfy both the case-sensitive name match and the self-closing-only XML expectation.
Tests
test/graph-prompt.test.ts(new file, 1 case): prompt includes the referential-integrity rule + few-shot.test/graph.test.ts:parseGraphXml relation resolutiondescribe block (3 cases): case-insensitive resolution, body-form acceptance, drops relationships whose endpoint is not a declared entity.graph.test.ts+graph-prompt.test.ts).Compatibility
No env changes. Strict superset of previous parsing - any valid pre-fix XML still resolves to the same graph.
Summary by CodeRabbit
Bug Fixes
Tests