Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

revert(links): keep a mention edge next to a typed edge to the same target

garrytan011bd0b6a03b
diff --git a/src/core/link-extraction.ts b/src/core/link-extraction.ts
index b70d9232fe..7ad71f6629 100644
--- a/src/core/link-extraction.ts
+++ b/src/core/link-extraction.ts
@@ -969,15 +969,11 @@ function dedupeCandidates(candidates: LinkCandidate[]): LinkCandidate[] {
// (link_source) and link_type, and the audit trail (which kind of reference
// created the edge) is worth more than collapsing them. graph-query callers
// that want a unique target set dedup on to_slug themselves.
- // A mention of a target this page also links with a typed verb (same link
- // source) adds nothing: the typed edge already states the relationship.
- const edgeKey = (c: LinkCandidate) => `${c.fromSlug ?? ''}\u0000${c.targetSourceId ?? ''}\u0000${c.targetSlug}\u0000${c.linkSource ?? ''}`;
- const typed = new Set(candidates.filter(c => c.linkType !== 'mentions').map(edgeKey));
const seen = new Set<string>();
const result: LinkCandidate[] = [];
for (const c of candidates) {
const key = `${c.fromSlug ?? ''}\u0000${c.targetSourceId ?? ''}\u0000${c.targetSlug}\u0000${c.linkType}\u0000${c.linkSource ?? ''}\u0000${c.canonicalAttendance ?? false}`;
- if (seen.has(key) || (c.linkType === 'mentions' && typed.has(edgeKey(c)))) continue;
+ if (seen.has(key)) continue;
seen.add(key);
result.push(c);
}
diff --git a/test/link-extraction-line-grammar.test.ts b/test/link-extraction-line-grammar.test.ts
index 3709dff590..d020674d78 100644
--- a/test/link-extraction-line-grammar.test.ts
+++ b/test/link-extraction-line-grammar.test.ts
@@ -25,11 +25,6 @@ describe('typed relation lines', () => {
]);
});
- test('a mention of a target the page also links with a typed edge adds no second edge', async () => {
- const content = 'Alice mentions [[companies/acme-example]] in passing.\n\n- works_at [[companies/acme-example]] (since 2024)';
- expect(await types(content)).toEqual([['companies/acme-example', 'works_at']]);
- });
-
test('a sentence line keeps inference', async () => {
expect(await types('- works_at [[companies/acme-example]] since 2024')).toEqual([['companies/acme-example', 'mentions']]);
});