Skip to content

Prospects: the shortlist learns from each fit verdict and keeps what it learned - #653

Open
Deodat-Lawson wants to merge 5 commits into
mainfrom
claude/goofy-babbage-618d6a
Open

Deodat-Lawson wants to merge 5 commits into
mainfrom
claude/goofy-babbage-618d6a

Conversation

@Deodat-Lawson

@Deodat-Lawson Deodat-Lawson commented Nov 27, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • The Prospects fit check learns while it runs, and a run keeps what it learned. It asks about ten companies a round. After each round everyone not checked yet is re-ranked from the verdicts so far (LinUCB over the candidates' embeddings) and the highest ranked go next. Verdicts are kept in a new table, and the next run starts from them and from the stage people moved the segment's deals to.
  • A fit check that breaks off no longer leaves a short list. The open places go to the next companies down the ranking, unchecked, and the run's warning says which case happened. The run sheet's Shortlist step gains a "Fit check" row (English and Chinese) that shows as failed when the check broke off.
  • Ranking against a brief in the buyers' language was measured and not built. The gap the benchmark showed belongs to its small local embedding model. On the app's two built-in embedding indexes there is none, so Prospects does not translate the brief and the relevance-above-zero rule is unchanged.

Measured

The benchmark's pools replayed through the production code path (pipelines/experiments/company-search/production-replay), 20 seeds, 95% intervals.

Good companies found in 100 fit checks, seven pools, today's fixed ranking against the learner:

Embedding model Today Learner Difference Pools better / worse
nomic-embed-text (the benchmark's local model) 59.2 80.7 +21.5 (+11.9 to +32.1) 7 / 0
gemini-embedding-001 at 768 69.7 84.5 +14.9 (+5.1 to +25.2) 5 / 2
text-embedding-3-large at 1536 67.0 82.5 +15.5 (+6.5 to +23.4) 5 / 2

Good companies found in 100 checks by today's ranking, three Norwegian pools, English brief against Norwegian brief:

Embedding model English brief Norwegian brief Difference
nomic-embed-text 25.0 58.5 +33.5 (−1.0 to +60.7)
gemini-embedding-001 at 768 88.3 88.5 +0.2 (−3.8 to +4.4)
text-embedding-3-large at 1536 74.5 69.9 −4.6 (−10.7 to +2.4)

Related

Builds on #648 (the replayable company-search benchmark). These are items 3 and 4 of that work's plan, as two commits in that order: the measurement first (experiments only), then the product change. A third commit fixes the finding of the automated review on this PR (see Notes). Two merge commits bring in main (#654 to #658). Place search (#654) and the scheduler (#658) each added a migration first, so this PR's migration was regenerated after theirs (see Notes).

Checklist

  • pnpm check passes (lint + typecheck): on this head pnpm typecheck passes for all workspace packages and eslint passes on the 33 files this PR changes against main. On the first merge (d20d311ac) the whole pnpm lint had 0 errors and 26 warnings, none of them in those files; the second merge only brought in main's scheduler
  • pnpm --filter @launchstack/web test passes: CI's check job on this head decides this box. Run locally the way CI runs it, with no key variable set, on the first merge: 782 of 789 suites and 10,931 tests pass and 6 suites skip. One suite, __tests__/server/vector-retriever.test.ts, timed out at 7.7 s while the machine was loaded and passed 3 of 3 runs on its own in about 90 ms; it is not touched here. After the second merge the 36 suites it can reach pass (378 tests: Prospects, distribution, Inngest, scheduler, model scope, catalogues)
  • Changeset added (.changeset/prospects-shortlist-learns.md, minor, @launchstack/pipelines)
  • New env vars documented: none for the app. The replay tests read COMPANY_SEARCH_REPLAY_SEEDS, described in the folder's README
  • UI changes exercised in a browser (see Testing for what was and was not seen on screen)
  • Docs updated (docs/manual-testing-guide.md, the experiments READMEs)

Testing

Run locally on this head unless it says otherwise:

  • @launchstack/pipelines tests, as CI's new step runs them (CI: run the pipelines tests, which no job ran #655, with a scratch database): 99 files and 1,330 tests pass. 17 tests skip, all for want of the benchmark's recordings: 10 are this PR's replay tests, 6 are place search's sweep checks and 1 is from Company search experiments: a replayable benchmark for smarter Prospects search #648.
  • Replay tests with the recordings (on the first merge): this PR's three replay files pass on all three embedding models, 10 tests, with 3 skipping as before. They replay the benchmark's pools through fillShortlist and semanticRelevance and assert the effect beside today's ranking. The recordings hold public contact details of real people and are never committed, so these tests skip with a message anywhere else.
  • The three result files (results/production-*.json) are reproduced byte for byte by nine full-seed replays.
  • Whole web suite: see the checklist.
  • New web tests: five integration tests for kept verdicts against the real database (rows written, a second run starts from them, the after-research verdict saved by enrichCandidate, research's no on a segment with two buyer kinds, a moved area starts afresh), plus adapter and catalogue tests for the new row in both languages. The one for two buyer kinds fails without the review fix.
  • Migration gates, as CI runs them: drizzle-kit check, the journal check, both drift probes (no diff), check-no-push and check-schema-boundary pass. The engine set alone builds a database with no dangling foreign keys; both sets apply to an empty database, a second run is a no-op, and the result matches a schema pushed from TypeScript line for line (4,995 lines).

In the browser:

  • Seen: live Prospects runs on a local stack, both themes. The Shortlist step showed the "Fit check" row: "6 read, 1 turned away" on the first run, then "5 read, 1 turned away" with "6 earlier verdicts" on the runs after it.
  • Not seen on screen: the failed "Fit check" row, the singular "1 earlier verdict" and the row in Chinese. The run sheet opens only during a live run, so these are covered by tests in both languages only.
  • After the review fixes: only a sample-data run was walked through the UI, and sample data has no fit check.

Notes for reviewers

  • New stored data. distribution_fit_verdicts keeps one row per company and segment: name, listing text, verdict and the model's reason, for companies turned away as well. It is deleted with the workspace or the segment. Migration 20261129231658_distribution_fit_verdicts.
  • Migration order. Place search (Prospects: the free place search fills a pool of every place instead of keeping the first 40 #654) and the scheduler (Scheduler: a backend service for scheduled and on-demand agent runs (ADR-017) #658) merged first, each with a migration at the journal slot this PR's migration held. It was regenerated with drizzle-kit after each of them, never by hand, and is now 20261129231658_distribution_fit_verdicts at slot 60, after both; before the first merge it was 20261124154024_distribution_fit_verdicts. Its SQL is unchanged byte for byte. No deployed database ran the old name. A local one that did has a ledger row to rename, with the same checksum: UPDATE _launchstack_web_migrations SET tag = '20261129231658_distribution_fit_verdicts' WHERE tag = '20261124154024_distribution_fit_verdicts'.
  • What the gain is, and is not. A default 25-place shortlist fills in about 33 checks instead of 50 to 53, and most of that is the round size: the fixed order asked ten at a time needs 35 to 42. The first 25 checks are level on every model; the learner's lead opens around the 50th, so it pays on longer shortlists and on pools where few companies fit. Four of the fourteen pool and model pairs on the built-in indexes are worse, by 0.2 to 1.7 companies in 100 checks.
  • Real verdicts. One pool of 1,422 companies was judged in full by the production fit check (the fast route of the committed chat configuration). It agrees with the register on 96.8%, and 3 of 200 verdicts changed when asked again. On those verdicts the learner gains +48.0, +3.4 and +11.0 yes's in 100 checks on the three models. No live run has re-ranked anything yet: the live test segment found 8 places, which is one round.
  • Choices worth a second look.
    • People's decisions on a segment's deals always count, also after the segment is rewritten. Every stage past Lead except Nurture is a yes; "Not a fit" is a no.
    • The fit check's own verdicts are kept under the question they answered (segmentKey: offering, categories, constraints, buyer kinds and area, as the run narrowed them). Any edit to those, a typo fix included, starts them afresh.
    • A verdict from research is not overwritten by a later look at the listing under the same key.
    • The check after research asks about the one kind of buyer and the one area a company was filed under. Its yes is kept under the run's key; its no under that narrower question's own key (researchVerdictKey), so on a segment with several kinds or areas a no to one of them is not taken for the segment's answer. This is the third commit, from the automated review's finding; a database test on a segment with two buyer kinds fails without it.
    • Kept verdicts order the queue; they are not reused as answers, so a company found again is asked about again. Reusing them is a possible follow-up and is not in this PR.
  • Failure handling. A failure to read or keep verdicts never stops a run. A learner that cannot be built or cannot rank (a stored embedding that is not a number) hands over to the fixed ranking, and the log says which.
  • Cost of the learner. About 0.25 s for 500 candidates at 768 dimensions, 0.5 s at 1,536 and 4.6 s for 5,000 at 1,536. It yields to the event loop; the longest stretch without yielding was 0.41 s.
  • CI. apps/web/__tests__/middleware/request-body-after-middleware.test.ts is timing-fragile on main and is not touched here. Two database tests timed out once in a loaded local run and passed on their own: __tests__/server/vector-retriever.test.ts and the Scenarios store tests. Neither is touched here.
  • Not live until merged, migrated and deployed.

🤖 Generated with Claude Code

Deodat-Lawson and others added 2 commits November 27, 2026 02:55
…hing on the app's built-in embedders

E4 found that on Norwegian company texts a Norwegian brief finds 58.5 good
companies in 100 checks against 25.0 for an English one, and that with an
English brief the relevance-above-zero rule drops 40% and 89% of the good
companies in two pools. That was measured with the small local model.

Replayed through production's semanticRelevance on the app's two built-in
embedding models (packages/llm/src/embeddings/index-registry.ts), the gap
is gone:

  model                          English   Norwegian   difference (95%)
  nomic-embed-text (local)          25.0        58.5   +33.5 (-1.0 to +60.7)
  gemini-embedding-001 at 768       88.3        88.5    +0.2 (-3.8 to +4.4)
  text-embedding-3-large at 1536    74.5        69.9    -4.6 (-10.7 to +2.4)

With an English brief the zero-score rule keeps 91% to 95% of the good
companies on gemini-embedding-001 and 85% to 94% on text-embedding-3-large;
with a Norwegian brief it keeps nearly the whole pool and stops filtering.
So plan item 3 (translate the brief, or score against both) is not built,
and the zero-score rule stays as it is. No product code changes.

What is added is the replay that says so, in production-replay/:

- vectors.ts, models.ts: cached vectors per embedding model, the models
  read from the registry the app resolves its embedder from.
- record.ts: the one paid step. It sends nothing without record mode and a
  spend cap, prints its estimate first and never sends a text twice.
- brief-language.ts and its test: the three Norwegian pools ranked by
  semanticRelevance with each brief, 20 seeds, and what the zero-score rule
  keeps. The test runs where the recordings are; elsewhere it checks the
  committed result file.
- results/production-brief-language.json: one block per model, counts only.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…it learned

The fit check worked down a fixed ranking, 50 companies in its first round,
and every verdict was gone when the run ended. Now:

- Rounds of ten. After each round the ranking of everyone not checked yet
  is redone from the verdicts so far, and the highest ranked go next:
  LinUCB over the candidates' embeddings (src/distribution/learn.ts), driven
  by the loop in src/distribution/shortlist.ts. Before any verdict the
  learner predicts the fixed ranking exactly; its first round is close to
  that order, not equal to it, because a bonus goes to companies unlike the
  ones already asked about. Companies matched by shared words (no embedder)
  are checked in the fixed order and rounds as before.
- Verdicts are kept, one row per company and segment
  (distribution_fit_verdicts): the look at the listing, and what research
  found, which outranks it. The next run's ranking starts from them and
  from people's own decisions on the segment's deals (qualified, pursued or
  won is a yes; Not a fit is a no). The fit check's verdicts are kept under
  the question they answered: what the segment sells, who buys it and as
  what, what rules a company out, and where, as the run narrowed them. A
  rewritten or moved segment starts afresh; people's decisions always
  count. With no fit check to ask, earlier verdicts still order the list.
- A fit check that breaks off part-way no longer leaves a shortlist of only
  the companies it got through, which with rounds of ten could be two. The
  places it left open go to the next companies down the ranking, unchecked;
  a company named outside the area that was never read stays out, as with
  no fit check. The run's warning now says which happened: nothing was
  checked, part of the list is unchecked, or only the read ones are on it.
- The run sheet's Shortlist step has a Fit check row: how many companies
  were read and turned away, and how many earlier verdicts the ranking
  started from. A check that broke off shows as failed, with how far it
  got. English and Chinese.
- A failure in any of this does not stop a run or its fit check. When
  verdicts cannot be read or kept the run learns from its own verdicts
  alone; a learner that cannot be built, or cannot rank (a stored embedding
  that is not a number), hands over to the fixed ranking. The log says
  which.

Measured by replaying the benchmark's seven pools through this code
(experiments/company-search/production-replay, 20 seeds, 95% intervals):

  embedding model                 today   learner   found in 100 checks
  nomic-embed-text (local)         59.2      80.7   +21.5 (+11.9 to +32.1)
  gemini-embedding-001 at 768      69.7      84.5   +14.9 (+5.1 to +25.2)
  text-embedding-3-large at 1536   67.0      82.5   +15.5 (+6.5 to +23.4)

The first 25 checks are level on every model; the gain comes from about the
50th on. A 25-place shortlist fills in about 33 checks instead of 50 to 53,
and most of that is the round size: the fixed order asked ten at a time
needs 35 to 42. So a default run ends before the learner's lead has opened;
the lead is what a longer search gets. Four of the fourteen pool and model
pairs on the app's two built-in models are worse, by 0.2 to 1.7 companies
in 100 checks. The replay ranks every company of a pool; with a run's
relevance-above-zero rule applied first (--zero-score-rule) today's figures
do not move and the three gains are +21.3, +15.9 and +16.1.

On one pool judged in full by the real fit check (1,422 companies, the fast
route of the committed chat configuration) the fit check agrees with the
register on 96.8% of the companies, 3 of 200 verdicts changed when asked
again, and the learner behaves as it does on the labels: +48.0 yes's in 100
checks where the fixed ranking is poor, +3.4 where it already finds 92. A
second run on companies it has never seen, starting from the first run's
kept verdicts, gets 9.6 yes's in its first ten checks against 4.4 starting
from nothing where the ranking is poor, and 10.0 against 9.0 where it is
good.

Migration 20261124154024_distribution_fit_verdicts adds the one table; a
changeset (minor, @launchstack/pipelines) describes the change for the
package's consumers.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@vercel

vercel Bot commented Nov 27, 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 29, 2026 11:56pm UTC

@cursor

cursor Bot commented Nov 27, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: 7bffa279-ab34-4bb3-85ef-3f6ee418968a)

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-27T18:41:30.360963Z fd33fba PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fd33fbaef9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread pipelines/src/distribution/run.ts Outdated
Comment on lines +884 to +885
basis: "research",
segmentKey: segmentKey(program, run?.options),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Scope saved research verdicts to the question actually judged

For runs covering multiple territories or buyer kinds, the research check uses only relationship.territory and [relationship.kind], but this saves its answer under the entire run's segment key. For example, a run targeting Oslo and Bergen can assign a Norwegian company to Oslo (pickTerritory picks the first same-country territory), then research can reject it for being in Bergen—even though Bergen satisfies the full segment. That narrower rejection now replaces the full-segment listing verdict and trains subsequent runs as a negative; saveFitVerdicts also prevents later listing verdicts from correcting it because research takes precedence. Use the full run scope when judging a verdict saved under this key, or keep narrower research answers separate.

Useful? React with 👍 / 👎.

The fit check after research asks a narrower question than the run's look
at the listings: would this company buy as the one kind of buyer, in the
one area, it was filed under? Its verdict was kept under the run's key all
the same. On a segment with several buyer kinds or areas, a no to one of
them was then taken for the segment's answer (a company filed under the
segment's first area may sit in its second): it replaced the listing's
verdict, taught the next run's ranking a no, and a later look at the
listing could not correct it.

Now the verdict is kept under the question it answers (researchVerdictKey
in src/distribution/shortlist.ts):

- A yes goes under the run's key. A yes to one kind in one area is a yes
  to a run that asked for them among others.
- A no goes under the narrower question's own key, where only a run that
  asks that same question reads it. So does a yes to a kind or area the
  run did not ask for.
- A run that asks for one kind in one area has the same key both ways, so
  nothing changes there.

Found by the automated review on the pull request.

Tests: four unit tests for the key, and a test against a real database on
a segment with two buyer kinds, which fails on the code before this
change.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…earch's

main gained place search (#654), the pipelines tests in CI (#655), the
claim check's company profile (#656) and contact details kept out of the
fit check (#657). Place search's migration took journal slot 58, which
this branch's migration also held.

drizzle-kit builds on the snapshot whose name sorts last, and the
migration runner requires every journal entry to be later than the one
before, so this branch's migration cannot keep its earlier timestamp.
drizzle-kit regenerated it after place search's, nothing edited by hand:
20261124154024_distribution_fit_verdicts is now
20261129231658_distribution_fit_verdicts, slot 59. Its SQL is
byte-identical and its snapshot now builds on place search's. No
deployed database ran the old tag; a local one that did needs its ledger
row renamed to the new tag.

Everything else merged without a conflict. The changeset names the new
migration, and the experiments README says run.ts also runs
e1-production now.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The scheduler (#658) merged with its migration at journal slot 59, where
this branch's migration had just been placed. This time the migration
keeps its name: 20261129231658_distribution_fit_verdicts is later than
the scheduler's 20261129093142, so it moves to slot 60.

drizzle-kit regenerated it on main's journal and the SQL came out
byte-identical. The result was put back under the existing file name,
snapshot id and journal time, as the recipe for a second merge does; the
snapshot's contents and its link to the scheduler's snapshot are
drizzle-kit's own.

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

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit d3c7e20. Configure here.

table.companyId,
table.programId,
table.resolveKey
),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unique key wipes other-segment verdicts

Medium Severity

The unique index on distribution_fit_verdicts is per company and program, not per segmentKey. A research no is stored under the narrower researchVerdictKey, and setWhere only blocks a listing overwrite when the keys match, so a later listing save for the run's key replaces that row. The research finding is then gone for both the run's question and the narrower one, so a later run that actually asks that kind and area does not start from it.

Additional Locations (2)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit d3c7e20. Configure here.

This branch has not been deployed

No deployments
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