Skip to content

Reference profiles: Reference lookup and the rule's catalog picker (PR 5) - #278

Merged
sonyccd merged 5 commits into
mainfrom
reference-lookup
Oct 27, 2026
Merged

sonyccd merged 5 commits into
mainfrom
reference-lookup

Conversation

@sonyccd

@sonyccd sonyccd commented Oct 27, 2026

Copy link
Copy Markdown
Owner

PR 5 of Reference profiles (spec docs/superpowers/specs/2026-10-26-reference-profiles-design.md, decisions 11 and 14).

What it adds

  • search_references(query, program) (migration 20261027001500_reference_search.sql). Every word of the query must appear in the reference or the catalog name. Matching uses strpos on upper-cased text, so % and _ are literal. It reads only reference_catalog and reference_days, leaves hidden calls out of activations and last day, and returns the 25 most activated plus more. A shared reference_catalog_header helper builds the same header reference_profile does, and pgTAP checks the two agree. No new index.
  • reference-search Edge Function: public, verify_jwt = false, shares the profile's 30-a-minute lookup limit, rejects bad input with a 400 before any database call, and sends Cache-Control: public, max-age=300.
  • /ref Reference lookup page (public), per the Search and SearchPhone artboards. The query and program stay in the URL. With no query it shows Stats' most spotted references without a new request. A "Reference lookup" nav item follows "Callsign lookup" and is highlighted on /ref and /ref/*. /ref/<program>/ now redirects to /ref.
  • Catalog picker for the reference rule's is / is not values in the connection builder. It searches after 2 characters and a 300 ms pause, caches each (query, program), ignores stale responses, and narrows to one program when the sources hold exactly one of POTA/SOTAwatch/WWFF. Typing and pressing Enter still adds any reference (WWBOTA, IOTA, unlisted), and the existing shape check still applies.

Speed

Measured on the real lists (350,553 catalog rows) plus 2,000,000 synthetic reference_days rows: mitchell 0.2 s, us 0.4 s, an 0.8 s. The worst case, a query matching the whole catalog (- -), takes 1.1 s. Over 1/20 of the catalog matching, it switches from probing each match to one grouped pass. pgTAP checks that both paths agree.

For Brad to confirm

  • New picker copy, in the spec's Copy section under "Reference picker (PR 5)": placeholder US-2763 or Mount Mitchell, Searching the lists…, Not in the POTA, SOTA or WWFF lists. Press Enter to add it anyway., Search is unavailable. Press Enter to add a reference.
  • The SOTA region shows the list's own spelling (NC-Central Mountains), as PR 4's page does; the canvas draws Central Mountains.
  • In the picker, Enter on a typed name the lists match waits for an option. Leaving the field with "Mount Mitchell" typed still adds MOUNT and MITCHELL as two chips (autoSelect on blur). This is noted in the spec as an open call.

Checks

All pass locally: Deno fmt/lint/check/coverage, ESLint and typecheck, db lint, pgTAP (including the new reference_search.test.sql), the smoke test, the sender and profile-lock database tests, and web lint/build/coverage. The function was also served locally and curled.

Deploy, before merging

  1. supabase db push (20261027001500)
  2. supabase functions deploy reference-search
  3. Merge (Vercel ships the page)

🤖 Generated with Claude Code

sonyccd and others added 5 commits October 27, 2026 12:18
…R 5)

search_references(query, program) finds POTA, SOTA and WWFF list rows
by reference or name: every word of the trimmed query, upper-cased,
found with strpos (so % and _ are literal); 2 to 64 characters and at
most 6 words, else null. It reads only reference_catalog and
reference_days, counts activations as distinct (base, day) without
hidden calls, keeps retired and never-activated rows, and returns the
first 25 by activations then reference, with `more`. No new index: one
catalog scan, then each match's own primary-key range of
reference_days (`us` 0.4 s on the real lists with 2,000,000 synthetic
reference_days rows). The header comes from reference_catalog_header,
which pgTAP holds equal to reference_profile's catalog.

The public reference-search function (verify_jwt = false) refuses a bad
query or program with a 400 before any database call, shares the
profile's lookupLimit, never logs a query, and reads the reply with a
Zod schema.

The web gains /ref (Reference lookup, nav item after Callsign lookup,
highlighted on every /ref page): q and program in the URL, one request
per submitted search, and the Stats snapshot's most spotted references
with no query. /ref/<program>/ now goes to /ref. With is / is not, the
reference rule's values field searches the lists as you type
(debounced, cached for the editor's lifetime, stale answers dropped)
and still accepts any typed reference. database.types.ts regenerated;
CLAUDE.md, ARCHITECTURE, OPERATIONS and the spec updated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Keeps both new pages: `home` and `ref-lookup` in Page, `ref-lookup` in PublicPage, and the
AppShell nav test's order, LOCKED and OPEN lists with Home and Reference lookup.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- search_references: the activations come from one probe a match when there are few matches and
  from one grouped pass over reference_days' primary key when there are many (past a twentieth of
  its reltuples), and the catalog text is built once a row. A query that matches every row
  (`- -`, since every reference holds a `-`) took 3.8 s at 350,000 list rows and 2,000,000
  reference_days rows and now takes 1.1 s, the measured worst case. search_references_at takes
  the switch point, and pgTAP requires both ways to give the same payload. ARCHITECTURE.md and
  the spec record the real worst case.
- Reference lookup: Look up (or the chosen program chip) on a search that failed asks again,
  whatever order the URL put q and program in.
- Most spotted: the references are no longer h6 headings, nor are the picker's options.
- Reference picker: a search in flight is a shared promise in the editor's cache, so every row
  showing it hears its answer or failure, including after the row that sent it is gone.
- Reference picker: Enter on several words the lists match (a name such as "Mount Mitchell")
  waits for an option instead of adding MOUNT and MITCHELL; blur stays a point for Brad.

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

#277 added 20261027001400_home_flow_sources.sql, the version this branch's migration had, so
reference_search moves to 20261027001500 to sort after every migration on main. Its mentions in
CLAUDE.md, ARCHITECTURE.md, OPERATIONS.md, the spec and the pgTAP header follow; OPERATIONS.md
also names search_references_at.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- A refused query's error clears when Back or a link changes the search.
- nameParts marks the union of every word's occurrences, so overlapping
  words ("mitch hell" in Mitchell) are all set in medium weight.

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

vercel Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

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

Project Deployment Actions Updated
longlines Ready Ready Preview Oct 27, 2026 5:00pm UTC

@supabase

supabase Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Updates to Preview Branch (reference-lookup) ↗︎

Deployments Status Updated
Database ✅ Tue, 27 Oct 2026 17:00:08 UTC
Services ✅ Tue, 27 Oct 2026 17:00:08 UTC
APIs ✅ Tue, 27 Oct 2026 17:00:08 UTC

Tasks are run on every commit but only new migration files are pushed.
Close and reopen this PR if you want to apply changes from existing seed or migration files.

Tasks Status Updated
Configurations ✅ Tue, 27 Oct 2026 17:00:14 UTC
Migrations ✅ Tue, 27 Oct 2026 17:00:19 UTC
Seeding ✅ Tue, 27 Oct 2026 17:01:59 UTC
Edge Functions ✅ Tue, 27 Oct 2026 17:02:20 UTC

View logs for this Workflow Run ↗︎.
Learn more about Supabase for Git ↗︎.

@sonyccd
sonyccd merged commit 03616f8 into main Oct 27, 2026
10 checks passed
@sonyccd
sonyccd deleted the reference-lookup branch October 27, 2026 19:36

This branch was successfully deployed

1 active deployment
Preview — ddfc954b Deployed Oct 27, 2026 by vercel[bot]
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