Skip to content

Link companies that share an id automatically, and keep a rejected pair apart after renames and moves (GST-3127) - #9839

Merged
capy-ai[bot] merged 82 commits into
masterfrom
capy/company-auto-link
Nov 20, 2026
Merged

capy-ai[bot] merged 82 commits into
masterfrom
capy/company-auto-link

Conversation

@garrytan

@garrytan garrytan commented Nov 19, 2026 •

Copy link
Copy Markdown
Owner

Companies that are plainly one company across sources now link on their own after each sync, and gbrain dedupe reject keeps a wrong pair apart even after a rename or a move. People are never linked automatically.
Why: Garry approved automatic company linking (A1) and its stored data (E1 to E3); this is GST-3127 PR 2, the rebuild that closes the findings that pulled the first version out of #9762.
Reader: this branch contains #9831 (PR 1), which lands first. Its migration is written as v329, which master has since taken; it is renumbered to the next free number before landing.

What changed
  • Automatic company links. After a sync, the cross-source company groups its changed pages belong to are linked when the group is clean, its pages share a LinkedIn company page or their own site's domain (a site value with no URL path), and no two name different countries. Ids are read from links with query strings, fragments and trailing slashes too. The rows are entity_identities with established_by: dedupe:auto (entity id dedupe-auto/<decision id>), database only; rankings and enrichment count them once. Pages in a group a person linked or confirmed, pages in a "same" decision and pairs a "different" decision covers are never linked; on a brain that keeps decisions in git, a group with an owner-only or restricted page is not linked and a host without the checkout does not sweep.
  • Which pages a sync looks at. A git sync sweeps the pages it changed. A folder source without git and a managed sync, which list no pages, sweep the source's pages updated since the sync started (a full sweep past 1,000). gbrain dedupe reconcile and a first sync sweep every company. Pages written by gbrain import, put_page or capture link at the next sync or reconcile.
  • Links follow later pages. A group that a later page splits, or that no longer qualifies, is unlinked and its remaining pages are linked again. Every apply also removes automatic groups a decision now covers and groups left with one page, with no main page or with a deleted page; a sync that removes one runs the full sweep so the rest relink with one main page.
  • Stale sweeps write nothing. The plan carries each page's id and generation and the decisions' revision. applyIdentityDecisions writes it in the decisions' locked transaction, in set-based statements, and skips a group whose pages changed or joined another group since.
  • Rejects survive renames and moves (E2, one migration). A "different" decision keeps each member's fingerprint: a hash of its kind, variant name and strong key values, never the values. It lives in the decision file (evidence:) and in a new entity_identity_reviews.evidence column, so a rebuilt database keeps it. A page with no strong key gets no fingerprint, so rejecting it never hides an unrelated pair that only shares a name. Rejects recorded before this get fingerprints from their pages at the next sync or reconcile (database only). gbrain dedupe reject also accepts an automatic group's identity id or its group id.
  • Hand edits. A confirm takes an automatic group over. A hand link may move an automatic member, and the next sweep leaves it there. entity_identity_unlink refuses a page the sync linked (as it already did for confirmed groups), changes nothing, and offers gbrain dedupe reject <entity id> instead, since a removed link would come back at the next sync.
  • Main page. The default source's page when there is one, else the oldest page, never the longest (also for confirms).
  • No setting (E3) or flag. New internal fields on listEntityKeyRows rows (page id, generation, created_at, identity); the deletion inventory lists the new column.
Measurements
  • Bench (gbrain-evals messy company families, real finder, both engines): 0 automatic links on all 242 must-not-link pairs, including the shared-LinkedIn, subsidiary-root-domain and renamed-namesake families; 17 of 144 must-link pairs linked (strict names only, by design). With rejections recorded before 20 moves and renames: 0 relinked, 0 proposed again.
  • 50,000 companies (25,000 pairs), sweep after a sync of 100 changed pages: 750 to 910 ms on PGLite and 520 to 640 ms on Postgres, against a 1 s gate. A full sweep that links all 25,000 groups: about 5 s on PGLite and 6.5 s on Postgres.
Tests
  • test/entity-company-auto-link.test.ts (new, PGLite and Postgres, 18 cases): linking and main page, namesakes with different domains or countries, names that differ, contact-only pairs, a domain that is a page on another site, ids in links with query strings, fragments or trailing slashes, a person page carrying a company's LinkedIn page, reject then rename, move and rebuild from git, a keyless reject next to an unrelated same-name pair, reject by group id, stale plans, hand move versus refused unlink, confirm takeover, a later page that splits a group, deleting the main page of a three-page group, one-page cleanup, fingerprint backfill, rankings counting a linked company once, a folder source without git, owner-only and no-checkout on a git brain.
  • The dedupe decisions, finder, person-confirm, entity-identity, engine-parity, SQL-text, migration and catalog golden files pass on both engines.
Agent notes

GBRA-631 for GBRA-108; lands by hand after #9831.

  • /ship run ship3127b used both review rounds. Pass 1 (specialist testing/security/state-machine reads, red team, coverage audit): 7 findings, 6 fixed including 1 critical. Pass 2 (adversarial Opus read and a second-model review on GPT-6.1 Sol): 4 blocking findings (an id-parsing regression from the pass 1 fixes, a stale automatic group not unlinked, managed and folder syncs skipping the sweep, deleting a group's main page), all fixed with tests that failed first. GBRA-108 then chose one read-only full review of the final head with no fix round instead of a receipt.
  • Open notes, not fixed here: dedupe reconcile --json omits the sweep result; the migration's comment says "strict name" and the entity_identity_link op description still says manual-only (the comment goes with the renumber); two-hop chains are not followed; a host with no checkout and no decisions; the fingerprint backfill runs again on each sync.
  • The ratchet's two raw SQL reads were replaced by listPages and the apply's cleanup; no baseline row was raised.
  • Final read-only full review of b817bc7 (fresh Opus reader, whole diff, no fix round): 0 blocking. Two notes left open: after a reject between two pages that each share a different id with a third, the sweep links the third with one of them, and which one depends on insert order; the SQL id read trims only spaces while the finder trims all whitespace, so a value ending in a newline can make the near and full sweeps disagree. Unverified: the auto insert's conflict target does not cover the one-canonical index (no path to it found).
  • Docs audit: the first audit blocked on the identity_link_owned_by_dedupe text, which now covers the automatic unlink refusal (error-codes guide regenerated); the re-audit updated the key-files entries and ended updated with no blockers. The src/core/entity-identity.ts header comment still says no auto-matching.

Open in Capy

Agent notes
{"head":"66292e7fc0964d2b062155d9a114d23c4d9830a8","run":"ship3127b","status":"started","review_loop":{"passes":1,"blocking_found":1,"deferred":0,"noted":1,"fixed":6,"scope":"frozen","rounds":1,"dispatches":{"specialist":1,"red-team":1}}}

garrytan and others added 30 commits November 19, 2026 14:07
…s (GST-3170)

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…els into fundraise (GST-3170)

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
… reads (GST-3170)

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…aces too (GST-3170)

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…ll commands, no crash line on inspect, doctor re-checks the host skill list

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
… so every reader sees the old value end (GST-3170)

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…of failing the write (GST-3170)

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…es and Postgres arm in their inventories (GST-3170)

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…-running full setup

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…L.C. as LLC; judge restricted pages in the engine scope (GST-3127)

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…he scoped check

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…y lets it load; bound doctor's skills list probe at 20 s

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…olicy lets the plugin load

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…tials never read as a title

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…blish at once, keep the newest-first fact scans on their index, and stop folding runway, loan and target labels into fundraise (GST-3170)

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…ng does

The owner-only tests built their engines without the connect-time version
read, so on a snapshot-restored PGLite or a cloned Postgres brain the
restricted-page check fell back to treating every page as owner-only.
The two new owner-only tests also wrote the source config as a JSON
string on Postgres; they now write a real JSON object.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…w each reader's trust floor and access, so they go to a follow-up (GST-3170)

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…art instead of matching or merging it, and keep managed imports as read (GST-3170)

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…approved

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…ules at their previewed prefix

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…6143)

The race hunt planned each shard at 55 minutes of tests while the shards of
the 2026-11-19 nightly took 30 to 45 minutes with setup, so the 3-iteration
floor filled long before the runners did. Re-mine the stress iteration
weights from that night's 24 shard logs, and schedule the files listed in
test/postgres-unit-arms.txt before the importers of changed helpers, so a
widely imported helper can no longer push listed arms out of the night.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…cept rebuild included

The unmanaged expiry now pages through all of the purged pages' journal rows instead of stopping at the first 10,000, redacts the entry text kept in their timeline receipts (compacted ones included) as an explicit purge does, and the unmanaged concept rebuild's hard purge redacts too.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…included

The edit_page receipt keeps a unified diff of the page text in its outcome. Both the unmanaged expiry and the explicit purge now read the page's edit receipts with its timeline receipts and redact that diff.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
garrytan and others added 21 commits November 19, 2026 23:26
…page writes strip U+0000

Frontmatter parsing now removes U+0000 for page writes, which also reached two
readers that must not change:

- Rename identity (S-51) read a frontmatter title holding U+0000 with the character
  removed. Such a title reads as no value again, so the pair takes the
  unconfirmed-rename path and never matches a page with the plain title. A lone
  surrogate still reads as no value, as before.
- The skill resolver's module graph gained src/core/text-safe.ts through
  data-frontmatter.ts. The helper now lives in data-frontmatter.ts itself, so the
  resolver loads exactly the modules it loaded before.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
The mock's first prose answer now gets one re-ask (#9648) before the job
falls back, so the mock answers that re-ask in prose too and the agentic
loop's tool call moves to the third call. Every assertion stays; the call
count floor rises from 2 to 3.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

# Conflicts:
#	src/core/schema-migrations/registry.generated.ts
#	test/fixtures/goldens/migrations/records.json
Migrations renumbered (filename, export name, version literal):
  v329 -> v330 src/core/schema-migrations/v330-entity-identity-reviews-evidence.ts
Golden regeneration: migrations/records.json follows the renumbered versions.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…ys just before search_mode

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@capy-ai capy-ai Bot added the full-ci Maintainer-only: run the full Test and E2E suite on this PR head label Nov 20, 2026
@github-actions github-actions Bot removed the full-ci Maintainer-only: run the full Test and E2E suite on this PR head label Nov 20, 2026
…erage check

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@capy-ai capy-ai Bot added the full-ci Maintainer-only: run the full Test and E2E suite on this PR head label Nov 20, 2026
@github-actions github-actions Bot removed the full-ci Maintainer-only: run the full Test and E2E suite on this PR head label Nov 20, 2026
@capy-ai
capy-ai Bot merged commit 05d5c04 into master Nov 20, 2026
222 of 223 checks passed
This was referenced Nov 20, 2026
@capy-ai
capy-ai Bot deleted the capy/company-auto-link branch November 21, 2026 17:13
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