@ultimat3/manifest 31.20.0 → 31.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CLAUDE.md CHANGED
@@ -34,6 +34,7 @@ by the CLI, not imported.
34
34
  | `docs-search-subpath.ts` | the `./docs-search` entry: `searchDocs`, `nearestTopics`, the entry types. Nothing with I/O may join its graph — an island imports it (`docs-search-subpath.test.ts` bundles it for a browser) |
35
35
  | `docs-wiki.ts` | read-only: a shipped `wiki/` directory → `DocEntry[]`, topic `wiki.<Page>#<GitHub anchor>`; `wikiSection` is one whole section. Never reads `Error-Codes.md` |
36
36
  | `docs-tokens.ts` | pure: the query/name splitter and the one-suffix stem both sides of `docs-search` share |
37
+ | `docs-synonyms.ts` | pure data: a task word (`paginate`, `poll`, `typing`) → the mechanism that does it (`keyset`, `pollEvery`, `debounce`). Keyed on the word, never the stem |
37
38
  | `diff-rows.ts` | a read's row, member by member: removed, retyped or no longer required is breaking, added is additive. Never `canonicalJson` inequality: an entity gaining a column would flip every `rows: X.$schema` read |
38
39
  | `diff-mounts.ts` | a bearer mount's cut, per (scope, name): the one classifier that sees a held token's 404, because the primitive stays registered |
39
40
  | `diff-consumers.ts` | the `consumers` section: a consumer removed is breaking (its stream is never read again, nothing throws); every field that moved is internal |
@@ -121,6 +122,9 @@ by the CLI, not imported.
121
122
  - A guide topic is unique within its package — repeated headings take a document-order suffix.
122
123
  - **`docs-search-eval-set-fixture.ts` is the ranking's regression set**: `docs-search.test.ts` holds it at
123
124
  `EVAL_FLOOR` (18 of 20) over the repo's `packages/` and `wiki/`. Ranking is not a stable surface.
125
+ - **`docs-synonyms.test.ts` holds the synonyms table**: ten task questions each land their page in
126
+ the top 3 (no floor), four unrelated ones sharing a table word stay off its target, and every
127
+ target is a name the shipped tree carries. A row whose word means more than one task fails there.
124
128
  - Neither docs module may import a registry or a clock. `docs-search.ts` is pure; `docs-scan.ts`
125
129
  reads files and nothing else.
126
130
  - **A new manifest field ⇒ a `diff-*.ts` rule for it.** Always — a field nothing classifies is a
package/README.md CHANGED
@@ -168,7 +168,10 @@ the one copy: `scripts/wiki-anchors.ts` and `scripts/release-notes.ts` import th
168
168
  heading of its level — for `x docs Upgrading#<anchor>`. `tokenize()` is the query and name splitter
169
169
  (camelCase and digit runs, stop words dropped); `searchDocs()` compares one-suffix stems, and at an
170
170
  equal score ranks a guide over a source header. The ranking is not a stable surface; the regression
171
- set is `docs-search-eval-set-fixture.ts`, held at 18 of 20 by `docs-search.test.ts`.
171
+ set is `docs-search-eval-set-fixture.ts`, held at 18 of 20 by `docs-search.test.ts`. A question
172
+ phrased as the task reaches the mechanism through `docs-synonyms.ts` — "paginate a query with a
173
+ cursor" ranks `db.keyset` first, "poll every N seconds" `realtime.query-poll` — held by ten task
174
+ questions in `docs-synonyms.test.ts`, every one in the top 3.
172
175
 
173
176
  `@ultimat3/manifest/docs-search` is the ranker alone — `searchDocs`, `nearestTopics` and the
174
177
  `DocEntry`/`DocHit` types — for a browser island that searches a prebuilt index: no scanner, no
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ultimat3/manifest",
3
- "version": "31.20.0",
3
+ "version": "31.22.0",
4
4
  "description": "x.manifest.json: deterministic generated facts, contract diff, AGENTS.md budget",
5
5
  "keywords": [
6
6
  "ultimate",
@@ -43,12 +43,12 @@
43
43
  "test": "bun test"
44
44
  },
45
45
  "dependencies": {
46
- "@ultimat3/action": "31.20.0",
47
- "@ultimat3/core": "31.20.0",
48
- "@ultimat3/entity": "31.20.0",
49
- "@ultimat3/jobs": "31.20.0",
50
- "@ultimat3/query": "31.20.0",
51
- "@ultimat3/realtime": "31.20.0",
52
- "@ultimat3/schema": "31.20.0"
46
+ "@ultimat3/action": "31.22.0",
47
+ "@ultimat3/core": "31.22.0",
48
+ "@ultimat3/entity": "31.22.0",
49
+ "@ultimat3/jobs": "31.22.0",
50
+ "@ultimat3/query": "31.22.0",
51
+ "@ultimat3/realtime": "31.22.0",
52
+ "@ultimat3/schema": "31.22.0"
53
53
  }
54
54
  }
@@ -2,6 +2,7 @@
2
2
  // order it produces is a function of its input alone, and a scan plus a search is reproducible.
3
3
 
4
4
  import type { DocEntry } from './docs-scan';
5
+ import { SYNONYMS } from './docs-synonyms';
5
6
  import { stem, tokenize } from './docs-tokens';
6
7
 
7
8
  /**
@@ -47,6 +48,14 @@ const COVERAGE = 0.5;
47
48
  */
48
49
  const EXACT_SYMBOL = 12;
49
50
  const PARTIAL_SYMBOL = 4;
51
+ /**
52
+ * A task word the synonyms table maps to a mechanism. Where the entry EXPORTS that name, it is the
53
+ * strongest signal the ranker has — stronger than typing the name, because a curated row says
54
+ * this is the page the task is answered on, and prose that discusses the task must not outrank
55
+ * it. An entry that only mentions the name (a header, a longer symbol) earns a partial symbol's.
56
+ */
57
+ const SYNONYM_EXPORT = 2 * EXACT_SYMBOL;
58
+ const SYNONYM_MENTION = PARTIAL_SYMBOL;
50
59
  const TOPIC = 7;
51
60
  const PACKAGE = 3;
52
61
  const TITLE = 3;
@@ -85,6 +94,28 @@ function prepare(entry: DocEntry): Prepared {
85
94
  return prepared;
86
95
  }
87
96
 
97
+ interface SynonymHit {
98
+ readonly target: string;
99
+ readonly score: number;
100
+ }
101
+
102
+ /** The mechanism `word` stands for, when this entry exports it or its symbols or header name it. */
103
+ function synonymOf(
104
+ word: string,
105
+ symbolsLower: readonly string[],
106
+ titleLower: string,
107
+ ): SynonymHit | undefined {
108
+ const targets = SYNONYMS.get(word);
109
+ if (targets === undefined) return undefined;
110
+ const exported = targets.find((target) => symbolsLower.includes(target));
111
+ if (exported !== undefined) return { target: exported, score: SYNONYM_EXPORT };
112
+ const mentioned = targets.find(
113
+ (target) =>
114
+ titleLower.includes(target) || symbolsLower.some((symbol) => symbol.includes(target)),
115
+ );
116
+ return mentioned === undefined ? undefined : { target: mentioned, score: SYNONYM_MENTION };
117
+ }
118
+
88
119
  function scoreEntry(
89
120
  entry: DocEntry,
90
121
  tokens: readonly string[],
@@ -96,6 +127,7 @@ function scoreEntry(
96
127
  let textScore = 0;
97
128
 
98
129
  let covered = 0;
130
+ let answered = false;
99
131
  for (const word of tokens) {
100
132
  const before = score + textScore;
101
133
  // The stem, not the word, against every name and every line of prose: `upgrade` has to reach
@@ -107,14 +139,20 @@ function scoreEntry(
107
139
  const exact = symbolsLower.indexOf(word);
108
140
  const partial = exact >= 0 ? -1 : symbolsLower.findIndex((symbol) => symbol.includes(word));
109
141
  const symbolScore = exact >= 0 ? EXACT_SYMBOL : partial >= 0 ? PARTIAL_SYMBOL : 0;
142
+ const synonym = synonymOf(word, symbolsLower, titleLower);
110
143
  const nameScore = Math.max(
111
144
  symbolScore,
145
+ synonym?.score ?? 0,
112
146
  topicStems.includes(root) ? TOPIC : 0,
113
147
  packageStem === root ? PACKAGE : 0,
114
148
  );
115
149
  score += nameScore;
116
150
  const named = entry.symbols[exact >= 0 ? exact : partial];
117
- if (symbolScore > 0 && named !== undefined) matched.push(named);
151
+ if (synonym?.score === SYNONYM_EXPORT) answered = true;
152
+ if (exact >= 0 && named !== undefined) matched.push(named);
153
+ else if (synonym !== undefined) {
154
+ if (!matched.includes(synonym.target)) matched.push(synonym.target);
155
+ } else if (symbolScore > 0 && named !== undefined) matched.push(named);
118
156
  else if (nameScore > 0 && !matched.includes(word)) matched.push(word);
119
157
 
120
158
  // Prose is independent evidence of the same word, and is counted on top — capped, so a long
@@ -136,7 +174,10 @@ function scoreEntry(
136
174
  entry,
137
175
  score: score + (rationale && entry.kind === 'guide' ? RATIONALE_BONUS : 0),
138
176
  matched,
139
- covered,
177
+ // The coverage floor exists to refuse an entry that merely MENTIONS one word of a long
178
+ // question. The export a synonym names is not a mention: the table asserts the question names this mechanism's
179
+ // task ("wait until the user stops typing" is `debounce`), so the whole question is answered.
180
+ covered: answered ? tokens.length : covered,
140
181
  };
141
182
  }
142
183
 
@@ -0,0 +1,28 @@
1
+ // Task words → the mechanism that does the task. An agent asks "paginate with a cursor", never
2
+ // "keyset"; this table is that bridge. Pure data, read by `docs-search.ts`, held by
3
+ // `docs-synonyms.test.ts` (ten task questions, and every target a name the shipped tree carries).
4
+
5
+ /**
6
+ * Keyed on the query's own lowercased word, NOT its stem: `typing` stems to `typ`, which `type`
7
+ * shares, and "type" is no question about debounce. Every inflection is therefore its own row.
8
+ * A target is matched against an entry's symbols and its header line, case-folded, as a
9
+ * substring — so `latestby` reaches `LatestByOptions` and `lockkeys` the header naming `lockKeys`.
10
+ * Only words that name ONE task belong here: `page`, `batch` and `count` mean too many things.
11
+ */
12
+ const ROWS: readonly (readonly [readonly string[], readonly string[]])[] = [
13
+ [['paginate', 'paginated', 'paginating', 'pagination'], ['keyset']],
14
+ [
15
+ ['poll', 'polls', 'polling', 'timer', 'interval'],
16
+ ['pollevery', 'visibleinterval'],
17
+ ],
18
+ [['concurrency', 'concurrently'], ['mapbounded']],
19
+ [['memoize', 'memoise'], ['retrymemo']],
20
+ [['newest', 'latest'], ['latestby']],
21
+ [['typing', 'keystroke', 'keystrokes'], ['debounce']],
22
+ [['advisory', 'mutex'], ['lockkeys']],
23
+ [['denormalize', 'denormalise', 'denormalized', 'denormalised'], ['countedin']],
24
+ ];
25
+
26
+ export const SYNONYMS: ReadonlyMap<string, readonly string[]> = new Map(
27
+ ROWS.flatMap(([words, targets]) => words.map((word) => [word, targets] as const)),
28
+ );