Repository navigation
v0.44.1.0 fix(extract): subject-scope link-type inference + reserved-slug fuzzy guard - #2408
JiraiyaETH wants to merge 1 commit into
Conversation
… + FS-path routing (garrytan#2408) inferLinkType takes selfName and applies the page-role prior only when the role's clause subject is the page subject (was a whole-page scan that leaked a third party's role onto the subject). The FS-source extract path routes through canonical extractPageLinks instead of the dir-based inferTypeByDir bypass, so the guard reaches 'gbrain extract' + the autopilot cycle. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
… + FS-path routing (garrytan#2408) inferLinkType takes selfName and applies the page-role prior only when the role's clause subject is the page subject (was a whole-page scan that leaked a third party's role onto the subject). The FS-source extract path routes through canonical extractPageLinks instead of the dir-based inferTypeByDir bypass, so the guard reaches 'gbrain extract' + the autopilot cycle. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
f84979a to
b40c9f1
Compare
|
Confirming this fixes a real, reproducible problem on a production brain — and that fix #3 (the FS-path gap) is the load-bearing one for remote/MCP setups. Setup: personal brain, ~145 pages (people/companies/meetings), Postgres/Supabase, driven by an external agent over MCP + Symptom: the
Running the canonical Also confirms fix #1 (whole-page role prior): the owner's page carries Iron-Law back-links to other people's roles ("Managing Partner at Axcel", "investor in Griptel"). The old page-wide prior read those and stamped Can't run the v0.44 test suite directly (brain is on v0.37), but the mechanism reproduces exactly as described and the code paths match. This is the right fix. |
… + FS-path routing (garrytan#2408) inferLinkType takes selfName and applies the page-role prior only when the role's clause subject is the page subject (was a whole-page scan that leaked a third party's role onto the subject). The FS-source extract path routes through canonical extractPageLinks instead of the dir-based inferTypeByDir bypass, so the guard reaches 'gbrain extract' + the autopilot cycle. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Merging — I confirmed on master that the page-role prior scans |
Summary
Three correctness fixes to the deterministic (no-LLM) link-type extractor:
1. Subject-scoped page-role prior (
src/core/link-extraction.ts).inferLinkType's page-role prior previously scanned the whole page for role keywords ("investor", "works at") and stamped the verb (invested_in/works_at/advises) on every company link on the page — so a third party's role described on someone else's page leaked onto the page subject (e.g. "Alice invested in Acme" on Bob's page recorded Bob as an Acme investor). The prior now fires only when the role's clause subject is the page subject (new optionalselfNamearg), keeps distinct people who merely share a name token apart (token-subset match), scans every role mention so an earlier third-party reference can't suppress the subject's own later role, and falls back tomentionsotherwise. Legacy callers withoutselfNamekeep prior behavior.2. Reserved-slug fuzzy guard (
src/core/link-extraction.ts).makeResolver'sfindByTitleFuzzypath could let a weak/partial wikilink or attendee name cross the 0.55 similarity floor and resolve to an internal_-prefixed page (e.g. a leftover test fixture). Reserved slugs are now excluded as fuzzy-resolution targets.3. Filesystem extraction path now applies the guard (
src/commands/extract.ts). The FS-source path (extract.links_fs→extractLinksFromFile, used bygbrain extractand the autopilot cycle) had its own markdown scanner + a directory-basedinferTypeByDirthat bypassed the canonicalextractPageLinks/inferLinkTypeentirely — so fixes (1) and (2) never reached the FS path. FS extraction now routes throughextractPageLinkswith the parsed body + frontmatter (soselfNamederives and the guard fires); the FS-relative fallback uses the canonicalinferLinkType; the duplicate directory-based inference is removed. This was the path that re-created the mis-typed edges in practice.Test Coverage
Regression tests across
test/link-extraction.test.ts+test/extract.test.ts(full extraction sweep: 279 pass / 0 fail), covering: third-party suppression (investor / employee / advisor arms), subject-attributed roles still inferring, shared-token people kept apart, pronoun-led clauses, scan-all-matches (third-party mentioned first), reserved-slug fuzzy rejection (+ control),selfNamederivation, and the FS path applying the subject-scope guard (third-party →mentions; subject-title-match →invested_in). Legacy behavior pinned. The dir→verb inference shift on the FS path is asserted by the updated FS tests.Review
Known limitations
Both fail safe to the pre-guard "apply" (never worse than before), noted in the helper's doc-comment:
<Name> - <role>" splits at the list-marker boundary.Test plan
bun run typecheck— clean🤖 Generated with Claude Code