Skip to content

fix(entities): prefix-expansion resolve for bare first names + stub guard#1009

Closed
garrytan-agents wants to merge 1 commit into
garrytan:masterfrom
garrytan-agents:fix/entity-resolution-prefix-expansion
Closed

fix(entities): prefix-expansion resolve for bare first names + stub guard#1009
garrytan-agents wants to merge 1 commit into
garrytan:masterfrom
garrytan-agents:fix/entity-resolution-prefix-expansion

Conversation

@garrytan-agents

Copy link
Copy Markdown
Contributor

Problem

resolveEntitySlug(Jared) fell through to slugify → bare jared because pg_trgm scores too low on short strings. writeFactsToFence then stub-created a phantom people/jared.md instead of routing to people/jared-friedman.

Three-layer fix

  1. Prefix expansion in resolveEntitySlug: queries people/token-% then companies/token-%, picks highest-connection match
  2. Stub creation guard in fence-write: refuses to create pages with no directory prefix
  3. Legacy fallback in backstop: routes blocked facts to DB-only path

Tests

13 new tests, all passing. Jared→jared-friedman, Diana→diana-hu, Sam→sam-altman, etc.

…uard

Root cause: resolveEntitySlug fell through to slugify('Jared') → 'jared'
because pg_trgm scores too low on short strings (similarity < 0.4).
writeFactsToFence then stub-created people/jared.md instead of routing
to the existing people/jared-friedman page.

Three-layer fix:
1. resolve.ts: new isBareName() + tryPrefixExpansion() step queries
   people/<token>-% then companies/<token>-%, picks highest-connection
   match as tiebreaker
2. fence-write.ts: stub-creation guard refuses to create pages with
   no directory prefix (bare 'jared' instead of 'people/jared-*')
3. backstop.ts: stubGuardBlocked result routes facts to legacy DB-only
   path so they aren't silently dropped

13 new tests (entity-resolve.test.ts), all passing.
@garrytan

Copy link
Copy Markdown
Owner

Moving to base-repo branch so CI secrets are available (garrytan-agents is a fork; pull_request workflows from forks don't get base-repo secrets). Replacement PR coming next from the same branch pushed to garrytan/gbrain.

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.

2 participants