Skip to content

feat: improve latency of prospect search - #587

Closed
rafchen wants to merge 15 commits into
mainfrom
low-latency
Closed

rafchen wants to merge 15 commits into
mainfrom
low-latency

Conversation

@rafchen

@rafchen rafchen commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Finding prospects was slow because keyless runs read companies' websites one company at a time, at about 5s per company.
  • Keyless runs now read 5 companies at once, through a new optional enrichConcurrency port and a small mapInPool helper. Each company's own site is still read one page at a time, so no site sees more load.
  • Scoring, the fit check and the page rules are unchanged. Sample runs and the worker's durable job are also unchanged.

Related

None.

Checklist

  • pnpm check passes (lint + typecheck): not run; only the pipelines typecheck was run
  • pnpm --filter @launchstack/web test passes: not run; only the pipelines distribution tests were run
  • Changeset added (if a publishable package under packages/* or pipelines/ changed — pnpm changeset)
  • New env vars documented in .env.example and apps/web/src/env.ts: N/A, no new env vars
  • UI changes exercised in a browser (not just a green build): N/A, no UI changes
  • Docs updated if behavior changed: N/A, results are unchanged and only the timing differs

Testing

  • npx vitest run src/distribution in pipelines: 14 files, 127 tests pass. New tests cover the concurrency limit, result order, stopping, and failure handling.

  • npx tsc --noEmit -p tsconfig.json in pipelines: clean.

  • Prettier check on the changed code files: clean.

  • Timing on 15 real sites from a cafe segment in Baltimore, using the real page profiler with database writes stubbed:

    • One at a time: 74.8s
    • Five at once: 14.4s
    • Dossiers and pages read: identical on all 15

    The five-at-once pass ran second, so warm caches may flatter it slightly. It also used a throwaway script's pool rather than mapInPool.

Not tested: a full run through the app (Docker and the database were down), so model calls, database writes and publishing to Sources weren't timed or exercised under concurrency.

Notes for reviewers

  • Scope: only runDistributionPipeline uses the new limit, and it defaults to 1. Only keyless ports set it (to 5). The Inngest job keeps its own loop, so keyless runs on the worker don't get faster yet. Parallel steps there would also be held back by its concurrency limit of 2 per company.
  • Failure behaviour: when a candidate throws, no new candidates start and in-progress ones finish before the run is marked failed, so nothing is still writing afterwards.
  • Azure rate limits: embedding and fit-check calls now overlap, up to 5 at a time. If a post-research fit check is rate-limited, that company keeps its score without the second check and only a warning is logged. If embeddings fail, its score leaves out relevance by meaning. Worth checking the logs on the first real run.
  • Publishing to Sources: publishDossier can now run concurrently, but it was off in my environment because FILE_ACCESS_TOKEN_SECRET was unset, so this is untested.
  • Deferred follow-ups:
    • Overpass took 57.6s to add 3 places in one sample, and the place sources have no timeout of their own.
    • 136 of 158 page requests failed, mostly guessed paths like /over-ons on US sites.

rafchen and others added 2 commits November 3, 2026 17:45
The pipeline researches candidates one at a time, and most of that time is
spent waiting on other people's websites. This helper runs work a few at a
time, keeps results in input order, and on a failure starts nothing new and
waits for what already started, so a caller can mark a run failed knowing
nothing is still writing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Finding prospects spent about 5s per company reading websites one company at
a time. Measured on 15 real sites, reading five at once took 74.8s down to
14.4s with identical dossiers and pages on all 15. Each company's own site is
still read one page at a time, so no site sees more load.

The limit is a new optional enrichConcurrency port that defaults to one, so
fixture runs are unchanged. The worker's durable job schedules its own steps
and does not use it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
pdr-ai-v2 Ignored Ignored Nov 30, 2026 1:15am UTC

rafchen and others added 13 commits November 13, 2026 15:20
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…a screen

Every switch between Prospects screens remounted the screen and refetched
from a skeleton, and the server rebuilt the whole segment each time.
useResource gains an opt-in keepAcrossMounts: the last result per key is
kept for the page load, shown immediately, and refreshed in the background.
Turned on for the Prospects screens.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Companies list becomes a directory of cards, like Clay or Apollo, with
the table one toggle away (kept in the URL). Each card shows the picture the
company's own homepage declares, its location and domain, why it fits, fit,
stage and people.

- The page reader picks up a page's share image (og:image, twitter:image)
  and icon (apple-touch-icon, icon) from its <head>: https only, resolved
  against the page, never guessed paths.
- Research stores them on the company from the first own-site page it
  reads, with no extra request. Migration: partner_orgs.image_url, icon_url.
- A picture that fails to load falls back to the icon, then to initials,
  so a card never shows a broken image; images load lazily with
  no referrer. The table gains the icon beside each name.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Scenarios read the 12 best-fit prospects of the whole workspace, with no way
to choose and no way back. Now:

- Prospects gains Simulate: on Companies (the segment, or the companies
  selected) and on a company page. It opens the Scenarios form prefilled
  with the situation and aimed at those prospects.
- The Scenarios form has a Which prospects picker (a segment, or the
  companies picked in Prospects); the run stores prospectSegmentId and
  prospectIds and reads only those.
- Each prospect source links to its company page in Growth › Prospects.
- Source options list the segments that have companies.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…client

Anyone with an access key (read scope) can ask for real companies like the
buyers they describe, in the place they name, without opening Prospects:
offering, buyers and place in; up to 15 companies out, best first, each with
website, address, location, relevance and the fit check's reason.

- server/prospects/similar.ts runs the same pieces as a keyless run: the
  place through OpenStreetMap's geocoder, place kinds chosen by meaning,
  OpenStreetMap places (plus Exa's company index when configured), matched
  by meaning, then checked by the workspace's model for type and location.
  Synchronous (about 20s live) and stores nothing.
- Runs inside the MCP route's model scope; rate limited to 20 calls an hour
  per person and workspace; annotated open-world, since it reads public
  sources.
- Tests: the service with stubbed sources and a deterministic embedder; the
  registry and annotation checks know the new tool.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The pictures are optional on CompanyRow, as the card already treats them;
the tool's result is a plain record for MCP's structured content; an Exa hit
without a name keeps its homepage title; the test's embedder is its own.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each Find companies run now fills in pictures for companies still missing
one (homepage share image, else its icon, else /favicon.ico), rechecking
a site at most weekly. A backfill (2026-11-prospect-pictures) does the
same for companies found before pictures existed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
find_similar_companies takes several places, exclusions, the seller (so
competitors are told from buyers) and a quick/thorough depth; thorough
reads each homepage for what it does and its pictures. It answers within
about a minute and says in warnings what it had to skip. Exa is asked
for each kind of buyer, not the offering, so it stops returning sellers.
list_prospects reads the workspace's saved segments and companies.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Growth Prospects: cards with pictures, faster switching, Scenarios link, MCP tools
Resolves #587's conflicts with main. Both sides kept in the MCP tool
list, backfills and Scenarios (main's new layout and v2 runs, with the
segment/company prospect picks passed through to v2). The partner-org
pictures migration is regenerated on top of main's newest migration
(same three columns), so the drizzle snapshot chain stays linear.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CI's migrations-apply builds the schema from migrations and from the
TypeScript tables and diffs them. ADD COLUMN appends, so image_url,
icon_url and pictures_checked_at come after updated_at; they were
declared before it. Order only: no migration.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The trigger's *:data-[slot=select-value] classes compile to a rule on
the trigger's own data-slot, so they never reach the value span and a
long name ran ~157px past the box. Target the child directly
([&>[data-slot=select-value]]): it now ends in an ellipsis with the full
name as the title, and long names wrap in the open list.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Resolves #587's conflicts with main (16 new commits):
- Prospects for every workspace (#646): the Scenarios prospects source,
  segment list and picker drop the beta gate like main, and keep the
  segment / company picks (now passed to v2 runs).
- Keyless runs keep reading five companies at once alongside main's
  place pool (#654); run.ts keeps the pictures, pool and redaction
  imports (#657).
- The partner-org pictures migration is regenerated after main's newest
  migration (same three columns, still last in the table).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@rafchen

rafchen commented Nov 30, 2026

Copy link
Copy Markdown
Collaborator Author

Combined into #632, which contains every commit from this branch (low-latency) plus the Growth Prospects work, merged with main. Closing so there's one PR to review and merge.

🤖 Generated with Claude Code

@rafchen rafchen closed this Nov 30, 2026
rafchen added a commit that referenced this pull request Nov 30, 2026
Growth Prospects: faster search, Clay-style cards, Find companies like this, Scenarios link, MCP (includes #587)
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