docpack Docs
Ctrl K
UP TO DATE Reviewed Jul 26, 2026 · next review Jan 22, 2027 Edit this page

Search

reference · last reconciled 2026-11-18 · docs/search.md

Contents 4 sections · ~1,932 tokens whole page · every section is individually addressable
  1. 1 What gets indexed ~117
  2. 2 Trust-aware ranking ~1,028
  3. 3 A narrow query still finds something useful ~262
  4. 4 Two transports, one result ~368

Token figures are estimates — chars/4 (estimate — docpack has no tokenizer). Section run receipts are not shown: docpack’s runs: ledger records a run against a PAGE, never a section, so a per-section outcome would be invented.

docpack indexes a corpus at the section level — one entry per heading, plus one per named command snippet — so a search returns the specific part of a page that matches, not just the whole document. The same index and ranking power three surfaces: the docpack search command line verb, the search box in a built site, and the search_docs tool an agent calls over MCP.

bash
docpack --root pack search "trust model"

See run docpack search for the full command and flag reference, and the MCP server for how search_docs returns the same hits to an agent.

1What gets indexed

Every section of every page — the text under each heading — and every named command snippet get their own searchable entry. A command's copy-exact text is indexed too, so a query can match on the contents of a command, not only the prose around it. Each entry also carries its page's title, its file name and id (its slug), its computed freshness badge (see freshness and badges), and whether the page is quarantined.

2Trust-aware ranking

A match is scored by where the term hit — a title match counts for more than a match in the page's file name or id, which counts for more than a heading match, which counts for more than a match in the body text — so a page filed as run-docpack-adopt is recognised as being about adopting even when its title words differ. The result is then adjusted by how much the page can be trusted: a page badged "up to date" ranks higher than an otherwise-equal hit on a stale, failing, or quarantined page. A draft page is shown, never hidden, but its score is multiplied by 0.75, so a verified page that matches about as well leads it. Ranking favors trusted pages by design, so a stale result has to be a noticeably better match to outrank a fresh one, not a marginal one. Quarantined pages are excluded from results entirely unless you explicitly ask to include them — the same refusal behavior quarantine enforces everywhere else in docpack.

Scoring asks only whether a word appears in a field, not how often, so many sections score exactly the same — every green section that mentions a flag once has the identical score. Those exact ties are broken first by page kind, a how-to page coming ahead of any other kind, and then by how densely your words occur in the section (title, heading and body together, counted per length of the section, so a short section that repeats a word is ranked as being about it and a long one that repeats it by chance is not): the section that defines a term comes ahead of one that mentions it in passing, and only sections that tie on both keep their order in the corpus. The count is a tie-break and nothing more — it never lifts a section past one that scored higher on field, trust, draft status or coverage — and it applies to the fallback below as well as to the first pass. The search box on a built site follows the same rules, but counts only in what it holds of each section — the first 400 characters, plus a code block's copy text — so a tie can order differently there when the repeats fall further down a long section.

Four more rules shape the score, all measured against a 69-query eval (page hit@1 rose from 0.75 to 0.83, section hit@1 from 0.62 to 0.71):

  • Short terms match whole words. A query word of two characters or fewer (after stemming) must equal a whole word in the field, not sit inside another word, so AGGREGATOR-X no longer matches every section containing "experiment". Longer words still match as substrings.
  • Literal identifiers get credit. A query word written as an identifier (at least four characters, containing _, -, ., / or @, such as CF_API_TOKEN or docs/a.md) earns +4 for appearing verbatim in a heading and +3 in the body, before the trust multipliers. The credit applies only when the identifier appears in 20 sections or fewer; one that is everywhere does not discriminate and earns nothing. Underscores inside identifiers also survive indexing now, so CF_API_TOKEN is no longer stored as CFAPITOKEN. Text inside a Markdown code span is likewise kept literal when excerpts and the index are built (emphasis rules do not run inside a span), so a span holding pkg/__init__.py is indexed and excerpted as written, never read as pkg/init.py.
  • A query ranks on at most 32 distinct words. Words are stemmed and a repeat of one adds nothing; past the 32nd distinct word the rest are ignored. The MCP tool and the CLI also refuse a query over 1,024 bytes.
  • A contiguous phrase earns +6. When the query has three or more words and a section's heading or body holds them as one unbroken run (filler words included, so "revert on regression" matches a sentence saying exactly that), the section gains 6. Unlike the other bonuses it is added after the trust and draft multipliers, so a stale or draft page's discount does not shrink it away.
  • Stemming also strips word endings. Endings such as -ies, -ation, -ification, -ment, -acy, -ate and a final -y are cut so related words meet: policies and policy, verification and verify, deployment and deploy.

3A narrow query still finds something useful

By default, every word in a query has to match somewhere for a section to be a hit, apart from filler words like "how" and "the", which are ignored unless the query is nothing but filler. One exception widens that: when at least one section already matches every word, a section that misses a word is still admitted if at least two of your words appear in its page's title or file name, so a page titled "Adopt an existing repo" answers "adopt an existing docs folder". But when that turns up nothing — the way a specific, natural-language phrase sometimes does — search doesn't just return an empty page. It falls back to ranking every section that matched at least one of your words, ordered by how many distinct words it matched. A narrow query that has no exact hit still surfaces the closest related pages instead of a dead end. Either way, one page can't fill the front of the list: after its two best sections, a page's other hits move to the end of the ranking instead of being dropped.

4Two transports, one result

docpack search on the command line and the search_docs tool an agent calls over MCP return the same ranked hits, in the same shape — a title, the matched heading, an excerpt, the page's route, one trust line (the badge word and why it computed), and a count of the page's other matching sections, plus an also list naming up to three of them by heading and anchor so a reader can see where else the page matched — and each page appears once, at its best section. A hit also says whether its page keeps open questions or recorded decisions: it carries open_questions and decisions, the counts of entries under the page's Open questions and Decisions headings, and, when the matched section is not the open-questions section, open_questions_text with the first three open questions as plain text (mcp.AttachMarks, which strips Markdown with the exported search.StripMarkdown, the same plain-text form the excerpts use). The excerpt is about 400 characters of that section: its opening, unless a later stretch holds more of the query's distinct words, in which case the excerpt starts there with "… ". An excerpt cut short ends at a whole word with "…"; one that is not cut carries none. The sentence that answers a query often sits past the opening, and an agent that never sees it reads the wrong page. The site's search box ranks the same way but keeps its per-section list and always shows each section's opening.

Run history
● 2026-11-18 · reconciled
● 2026-11-18 · corrected · “(note withheld from the public build)”
● 2026-11-11 · corrected · claude-fable-5-2 · “(note withheld from the public build)”
● 2026-11-11 · corrected · “(note withheld from the public build)”
● 2026-11-09 · corrected · “(note withheld from the public build)”
show all 14 runs
● 2026-10-28 · corrected · “(note withheld from the public build)”
● 2026-10-28 · corrected · claude · “(note withheld from the public build)”
● 2026-10-27 · reconciled
● 2026-10-27 · corrected · “(note withheld from the public build)”
● 2026-10-15 · corrected · claude · “(note withheld from the public build)”
● 2026-10-15 · reconciled · claude
● 2026-10-15 · reconciled
● 2026-10-01 · corrected · claude · “(note withheld from the public build)”
● 2026-07-22 · reconciled · claude-fable