@clay-design-system/kb 0.0.0-stage → 0.14.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.
Files changed (45) hide show
  1. package/dist/contract.d.ts +227 -0
  2. package/dist/contract.d.ts.map +1 -0
  3. package/dist/contract.js +134 -0
  4. package/dist/contract.js.map +1 -0
  5. package/dist/core/memory.d.ts +20 -0
  6. package/dist/core/memory.d.ts.map +1 -0
  7. package/dist/core/memory.js +23 -0
  8. package/dist/core/memory.js.map +1 -0
  9. package/dist/core/model.d.ts +47 -0
  10. package/dist/core/model.d.ts.map +1 -0
  11. package/dist/core/model.js +21 -0
  12. package/dist/core/model.js.map +1 -0
  13. package/dist/core/prose.d.ts +40 -0
  14. package/dist/core/prose.d.ts.map +1 -0
  15. package/dist/core/prose.js +106 -0
  16. package/dist/core/prose.js.map +1 -0
  17. package/dist/core/query.d.ts +87 -0
  18. package/dist/core/query.d.ts.map +1 -0
  19. package/dist/core/query.js +637 -0
  20. package/dist/core/query.js.map +1 -0
  21. package/dist/core/rank.d.ts +123 -0
  22. package/dist/core/rank.d.ts.map +1 -0
  23. package/dist/core/rank.js +429 -0
  24. package/dist/core/rank.js.map +1 -0
  25. package/dist/core/route-email.d.ts +48 -0
  26. package/dist/core/route-email.d.ts.map +1 -0
  27. package/dist/core/route-email.js +172 -0
  28. package/dist/core/route-email.js.map +1 -0
  29. package/dist/core/route.d.ts +431 -0
  30. package/dist/core/route.d.ts.map +1 -0
  31. package/dist/core/route.js +1769 -0
  32. package/dist/core/route.js.map +1 -0
  33. package/dist/core/search.d.ts +64 -0
  34. package/dist/core/search.d.ts.map +1 -0
  35. package/dist/core/search.js +123 -0
  36. package/dist/core/search.js.map +1 -0
  37. package/dist/index.d.ts +3 -0
  38. package/dist/index.d.ts.map +1 -0
  39. package/dist/index.js +2 -0
  40. package/dist/index.js.map +1 -0
  41. package/dist/snapshot-email.json +1 -0
  42. package/dist/snapshot-foundations.json +1 -0
  43. package/dist/snapshot-web.json +1 -0
  44. package/package.json +28 -3
  45. package/README.md +0 -3
@@ -0,0 +1,431 @@
1
+ /**
2
+ * `clay route` (K4): "what do I need for this stage?" — the ordered, minimal units for one skill × mode × stage,
3
+ * plus what the brief mentions, inlined within a token budget. It replaces the skills' "read these files up front"
4
+ * lists.
5
+ *
6
+ * Tiers, in output order (each unit appears once; background units are never routed):
7
+ * 1. Do the skill's procedure(s) for the stage — full bodies (mode-specific first).
8
+ * 2. Decides units the procedures yield to (`relations.precedence`) and Critical mode-specific policies — bodies.
9
+ * 3. Brief (mapping / structure, with --brief) one row per brief section: item count + the best-fitting
10
+ * layout candidates (item range from the derived layout facts, what the layout drops).
11
+ * 4. Watch gotchas / policies / rules of the stage, ranked by severity, by the brief (BM25) and by the
12
+ * brief candidates' sections and layouts — one line each (id + summary).
13
+ * 5. More the next ids (`clay get <id>`), as long as the budget allows.
14
+ */
15
+ import type { Kb, KbUnit, Stage } from './model.js';
16
+ import type { SearchSource } from './search.js';
17
+ export declare const DEFAULT_BUDGET = 2500;
18
+ /** A route with a brief also carries the candidates table and the item shapes. K5 raised this to 3k; K5b deduped the
19
+ * route (the precedence table once, no Mode A inputs in a Mode B route) and brought it back to 2.5k. */
20
+ export declare const BRIEF_BUDGET = 2500;
21
+ /**
22
+ * Units a skill fetches once at the start of a mode (web-compose SKILL.md "Modes": `pnpm clay get
23
+ * policy.mode-b.precedence policy.mode-b.defaults`). A route names them in one line instead of inlining them again
24
+ * (K5 QA F5: the precedence table was printed twice). k5b.test.ts keeps this list and the skill text in sync.
25
+ */
26
+ export declare const MODE_START_UNITS: Record<'A' | 'B', string[]>;
27
+ /** A procedure body with "**Mode A …**" / "**Mode B …**" blocks keeps only the requested mode's block (K5b F5). */
28
+ export declare function modeSlice(body: string, mode?: 'A' | 'B'): string;
29
+ export interface RouteOptions {
30
+ skill: string;
31
+ mode?: 'A' | 'B';
32
+ stage: Stage;
33
+ /** Brief text (Markdown). */
34
+ brief?: string;
35
+ /** Label for the brief in the header (its path). */
36
+ briefLabel?: string;
37
+ budget?: number;
38
+ /**
39
+ * K8 session / `--since`: units the build was already served — bodies (never inlined again, named by id) and lines
40
+ * (never listed again in Watch / More).
41
+ */
42
+ seen?: {
43
+ bodies: Set<string>;
44
+ lines: Set<string>;
45
+ };
46
+ /** K8: sections the build looked at (`clay section`); Watch keeps section-specific units only for these. */
47
+ sections?: string[];
48
+ /** K8: `Section.layout` picks the build looked at; later stages get one fact line per pick. */
49
+ layouts?: string[];
50
+ /**
51
+ * K10 compact view (the CLI default inside a session): no blank lines, a one-line header, at most WATCH_MAX_COMPACT
52
+ * Watch lines, item shapes for every candidate (so mapping needs fewer `clay section` calls) and, at copy / page-file,
53
+ * the item fields of each layout the build picked.
54
+ */
55
+ compact?: boolean;
56
+ }
57
+ /** K8: Watch lists at most this many one-liners (run D: ~80% of a 35-line Watch list was irrelevant). */
58
+ export declare const WATCH_MAX = 10;
59
+ /** K11 F1: the Watch score edge a Critical unit has over a non-Critical one of the same rank. */
60
+ export declare const CRITICAL_EDGE = 0.1;
61
+ /**
62
+ * K11 G1: how far below a Minor unit kept in Watch a Critical unit may score and still take its slot at the cut (see
63
+ * `guardCriticalAtCut`, which makes the Critical guarantee independent of BM25 drift in the edge).
64
+ */
65
+ export declare const CRITICAL_CUT_MARGIN = 0.15;
66
+ export declare const MORE_MAX = 12;
67
+ /** K10: the compact route's Watch list (the rest are ids under More). */
68
+ export declare const WATCH_MAX_COMPACT = 5;
69
+ export interface BriefSection {
70
+ n: number;
71
+ title: string;
72
+ text: string;
73
+ items: number | null;
74
+ }
75
+ export interface BriefRow {
76
+ section: BriefSection;
77
+ /** `part` (K11): the half of a split section a candidate is for (`b` = the hero's item section, `policy.mode-b.hero-item-split`). */
78
+ candidates: {
79
+ id: string;
80
+ line: string;
81
+ fit: 'fits' | 'over' | 'under' | 'unknown';
82
+ part?: 'b';
83
+ }[];
84
+ }
85
+ export interface RouteResult {
86
+ text: string;
87
+ tokens: number;
88
+ budget: number;
89
+ units: {
90
+ id: string;
91
+ tier: string;
92
+ inlined: 'body' | 'summary' | 'id';
93
+ }[];
94
+ brief: BriefRow[];
95
+ }
96
+ /**
97
+ * Brief sections: numbered headings — `## N. Title` (the `pnpm capture --brief` format) or `### N. Title` under a
98
+ * `## Sections` heading (the documented Mode B template, `procedure.compose.inputs`) — at whichever level carries the
99
+ * numbered headings; with none, every `##` heading. A section runs to the next heading of the same or a higher level.
100
+ * Item counts come from tables / lists / "·" lists.
101
+ */
102
+ export declare function parseBrief(text: string): BriefSection[];
103
+ /** The groups of a capture --brief "**Layout (derived):** section · 6 accordion · 2 tabs" line, outermost first. */
104
+ export declare function derivedLayout(body: string): {
105
+ top: string;
106
+ groups: {
107
+ n: number;
108
+ kind: string;
109
+ }[];
110
+ };
111
+ /**
112
+ * A `pnpm capture --brief` section (it has a "**Layout (derived):**" line), sized by its OUTER structure (K8): the first
113
+ * derived group that is not a logo row and is not media-only — "6 accordion · 2 tabs" is 6 (the 2-tab carousel inside
114
+ * one panel is content), "4 logos · 3 cards" is 3, "4 cards · 3 cards" of bare images (floating cards) is no item list.
115
+ * Items blocks are never summed (a desktop and a mobile copy of the same 3 cards are 3), nested Items blocks (bullets /
116
+ * tags inside an item) don't count. No usable group: the first top-level Items block whose items carry text; no Items
117
+ * block: repeated same-label CTAs (one per card) give the count.
118
+ */
119
+ /** The top-level "**Items (N, kind):**" blocks of a capture --brief section, with how many of their items carry text. */
120
+ export declare function itemBlocks(body: string): {
121
+ n: number;
122
+ kind: string;
123
+ text: number;
124
+ }[];
125
+ /**
126
+ * K10 (`policy.mode-b.two-item-groups`): a brief section that holds two different item groups with copy — e.g. "4 tabs"
127
+ * and "3 cards" in one live band. A desktop / mobile copy of one group (same count and kind), media-only groups, logo rows
128
+ * and a 2-slide carousel control inside a panel are not a second group.
129
+ */
130
+ export declare function twoItemGroups(body: string): {
131
+ a: {
132
+ n: number;
133
+ kind: string;
134
+ };
135
+ b: {
136
+ n: number;
137
+ kind: string;
138
+ };
139
+ } | null;
140
+ export declare function captureItemCount(body: string): number | null;
141
+ /** A capture --brief section body (`pnpm capture --brief` output). */
142
+ export declare const isCaptureSection: (body: string) => boolean;
143
+ /**
144
+ * K11: the shape of a section's items — per item a name, bullets, tags, media; stat-led or quote-led. Capture --brief
145
+ * items are ` N. **Name** — … video …` lines with nested `- **Items (k, list):**` (bullets) and
146
+ * `- **Items (k, labels):**` (tags) blocks; a hand-written brief's items say "bullets:" / "tags:" inline.
147
+ */
148
+ export interface ItemShape {
149
+ n: number;
150
+ named: number;
151
+ bullets: number;
152
+ tags: number;
153
+ media: number;
154
+ /** Items with copy beyond a bare label (a description, bullets, tags or media). */
155
+ rich: number;
156
+ stats: number;
157
+ quotes: number;
158
+ }
159
+ export declare function itemShape(body: string): ItemShape;
160
+ /** Agent cards: named items, most with bullets and media (tags are optional per card) — `RevealCard`'s shape. */
161
+ export declare const isAgentCards: (sh: ItemShape) => boolean;
162
+ /**
163
+ * K11 (`policy.mode-b.hero-item-split`): the hero's item group when no HeaderSection slot holds it — items with copy
164
+ * of their own (a description, bullets, tags or per-item media). Bare labels (the `options` row), logos and media-only
165
+ * items are not one.
166
+ */
167
+ export declare function heroItemGroup(sec: BriefSection): {
168
+ n: number;
169
+ agentCards: boolean;
170
+ heroMedia: boolean;
171
+ } | null;
172
+ /** K11 B2: the top-level items of a section as `{ name, desc }` — the bold name and the copy after the first " — ". */
173
+ export declare function textItems(body: string): {
174
+ name: string;
175
+ desc: string;
176
+ }[];
177
+ /**
178
+ * K11 B2 (`policy.tabs.layout-by-count`, vertical item list): a section whose items stack in one vertical list, each
179
+ * showing its own copy and expanding in place — an accordion, or what a capture labels "tabs" when the tab items carry
180
+ * their description (a horizontal tab row is a group of bare labels, its copy sits in the panels). It needs a visual:
181
+ * one per item (on the item lines, or a media-only group of the same count that swaps per item) → `item`; one shared
182
+ * section visual → `shared`. Not one: nested item groups (an accordion driving a card carousel), no visual, an FAQ (B3:
183
+ * `faqSection`: most item names are questions, or the title says FAQ — even with a section image), a layout line that
184
+ * says the tabs sit in a horizontal row (B3).
185
+ */
186
+ export declare function verticalItemList(sec: BriefSection): {
187
+ n: number;
188
+ visual: 'item' | 'shared';
189
+ labelled: 'tabs' | 'accordion';
190
+ } | null;
191
+ /**
192
+ * K11 B3: an FAQ — most item names are questions (whatever the title says), or the title says FAQ / frequently asked.
193
+ * A features title that mentions "questions" over non-question items is not one.
194
+ */
195
+ export declare function faqSection(sec: BriefSection): boolean;
196
+ /** A section-level visual line (`- **Image:** …`, `- **Video:** …`): one visual for the whole section. */
197
+ export declare const hasSectionVisual: (body: string) => boolean;
198
+ /**
199
+ * K11 B3 (`policy.features.layout-diversity`): the accordion + media family — accordion rows beside a media panel.
200
+ * The benchmark accepts any of them for "vertical accordion + media panel" (`policy.benchmark.rubric-layout`);
201
+ * side-by-side / side-by-side-lines show the active item's own media, accordion-media-right one shared visual.
202
+ */
203
+ export declare const ACCORDION_MEDIA_FAMILY: string[];
204
+ /**
205
+ * K11 B3: two FeaturesSections on one page never share a layout (`policy.features.layout-diversity`). When the route's
206
+ * first pick for a section is an accordion + media layout an earlier section already took first, the later section
207
+ * lists the next one of the family nobody took first: `side-by-side-lines`, then `side-by-side`, then
208
+ * `accordion-media-right` when it also has a shared section visual. A section with only a shared visual takes
209
+ * `accordion-media-right` or nothing (side-by-side / -lines show per-item media). Rows are changed in place; returns a
210
+ * note per changed row index (`[§ of the earlier section, from, to]`), or `[§, from, null]` when no family layout is left.
211
+ */
212
+ export declare function diversifyAccordionFamily(rows: BriefRow[], byId: Map<string, KbUnit>, skip?: (i: number) => boolean): Map<number, {
213
+ prev: number;
214
+ from: string;
215
+ to: string | null;
216
+ }>;
217
+ /**
218
+ * K11 F1 (`policy.layout.accordion-carousel`, C42): an accordion of categories that drives a card carousel — selecting a
219
+ * category swaps a row of cards that carry their own copy. A capture's outer group is the accordion and a later group
220
+ * holds (or nests) cards with a name + description; a hand-written brief's layout line names an accordion and the
221
+ * carousel / cards it drives. `cards`: the cards with copy (a carousel control such as "Go to last slide" is not one).
222
+ */
223
+ export declare function accordionCarousel(sec: BriefSection): {
224
+ n: number;
225
+ cards: number;
226
+ } | null;
227
+ /** K11 F1: the §Nb card section of an accordion-driven carousel — cards with copy keep it (name, description, CTA, image). */
228
+ export declare const accordionCarouselCards: (cards: number) => "layout.CardsSection.horizontal-reveal" | "layout.CardsSection.side-by-side";
229
+ /**
230
+ * K11 F1 (`policy.layout.accordion-carousel`): the one ordered answer for an accordion that drives a card carousel.
231
+ * 1. `tab-cards-carousel` + `[GAP]` when no other section on the page takes `tab-cards-carousel` first; 2. otherwise the
232
+ * no-repeat fallback `accordion-media-right` (the categories + one shared visual), same `[GAP]`; the cards with copy go to
233
+ * §Nb directly below (`accordionCarouselCards`). Rows change in place; returns per row the § that holds tab-cards-carousel
234
+ * (or null) and the card section.
235
+ */
236
+ /** The ordered answer's two layouts: step 1, then the no-repeat fallback (kb/inventory/shape-layout.json `accordion-driving-card-carousel`). */
237
+ export declare const ACCORDION_CAROUSEL_LAYOUTS: readonly ["layout.FeaturesSection.tab-cards-carousel", "layout.FeaturesSection.accordion-media-right"];
238
+ export declare function resolveAccordionCarousels(rows: BriefRow[], byId: Map<string, KbUnit>, skip?: (i: number) => boolean): Map<number, {
239
+ takenBy: number | null;
240
+ layout: string;
241
+ cards: number;
242
+ nb: string | null;
243
+ }>;
244
+ /**
245
+ * K11 F1 (`policy.layout.statement-stand-in`): a statement with media (heading + body [+ CTA] + a visual, no items) has
246
+ * no section of its own; its stand-in is a 1-item FeaturesSection. Two FeaturesSections on a page never share a layout
247
+ * (`policy.features.layout-diversity`), so each statement takes the next stand-in no other FeaturesSection on the page
248
+ * took first: `stacked-rows`, then `stacked-media-left`. Rows change in place; returns per moved row the § that holds
249
+ * the earlier stand-in, or `to: null` when none is left.
250
+ */
251
+ export declare const STATEMENT_STANDINS: string[];
252
+ export declare function diversifyStatements(rows: BriefRow[], byId: Map<string, KbUnit>, isStatement: (i: number) => boolean, skip?: (i: number) => boolean): Map<number, {
253
+ prev: number | null;
254
+ to: string | null;
255
+ }>;
256
+ /**
257
+ * K11 F1 (`policy.benchmark.rubric-layout-hero`): the hero's direction. A layout cue in the brief (split / side by side /
258
+ * copy left / media right vs centered / text above / media below / text-only) decides; else a selector hero — a row of
259
+ * bare tab labels plus a visual per tab (a media-only group of the same count; the live Homepage and work-management
260
+ * heroes) — reads as split (copy + tabs left, visual right); else a hero with one visual takes the chooser default
261
+ * `centered-image` (`policy.layout.chooser.HeaderSection`). No hero visual → null.
262
+ */
263
+ export declare function heroDirection(sec: BriefSection): {
264
+ dir: 'split' | 'centered' | 'text';
265
+ why: 'cue' | 'selector' | 'default';
266
+ } | null;
267
+ export declare const HERO_FAMILIES: Record<'split' | 'centered' | 'text', string[]>;
268
+ /**
269
+ * K11 B2: plain text cards — every item a name + description, no media, bullets, tags, stats or quotes, in a section
270
+ * with no visual and no tab / accordion structure ("Full control": 6 icon + title + description cards). Their layout
271
+ * is an icon list, not a card carousel. `short`: the descriptions fit `BulletItem` (title ≤ 18c, description ≤ 84c).
272
+ */
273
+ export declare function textCards(sec: BriefSection): {
274
+ n: number;
275
+ short: boolean;
276
+ } | null;
277
+ /**
278
+ * K11 item-shape priors: a brief section whose items have the shape a layout was built for. A matching prior
279
+ * multiplies that layout's score by `factor` and always lists it among the candidates (`unit` says why). Add a row for
280
+ * a new shape → layout fit; `test` sees the section and its item shape.
281
+ */
282
+ export interface ShapePrior {
283
+ name: string;
284
+ test: (sec: BriefSection, sh: ItemShape) => boolean;
285
+ layout: string;
286
+ factor: number;
287
+ unit?: string;
288
+ }
289
+ export declare const SHAPE_PRIORS: ShapePrior[];
290
+ /** K11 (`policy.mode-b.precedence`, tint exception 2): layouts whose cards are always grey (grey-300) and take no tint. */
291
+ export declare const GREY_CARD_LAYOUTS: Set<string>;
292
+ /** The live page shows the section on a grey band: capture --brief "bg rgb(…)" grey, or a hand-written grey / muted cue. */
293
+ export declare function greyBand(sec: BriefSection): boolean;
294
+ /** What a brief section reads like, beyond its item count (K5: statement / grid / 2-card sections were mis-matched). */
295
+ export interface SectionShape {
296
+ statement: boolean;
297
+ grid: boolean;
298
+ hasCta: boolean;
299
+ hasMedia: boolean;
300
+ /** Each item has its own image / its own CTA (K5b F4: "two product cards, each with image + CTA"). */
301
+ itemMedia: boolean;
302
+ itemCta: boolean;
303
+ /** Tabbed content: capture --brief derived "N tabs" as the outer structure, or a tabs cue in a hand-written brief. */
304
+ tabs: boolean;
305
+ /** Accordion content (outer structure / cue). */
306
+ accordion: boolean;
307
+ /** K8: a logo row with no copy of its own (no body, no CTA, no items): `customer` or `integration` logos. */
308
+ logoStrip: 'customer' | 'integration' | null;
309
+ /** Logos in the section ("Logos (7)", "7 logos") — never items. */
310
+ logos: number | null;
311
+ /** Two or more case-study links / stat-led customer cards. */
312
+ caseStudy: boolean;
313
+ /** capture --brief "Visible: mobile only / desktop only". */
314
+ visibleAt: 'mobile' | 'desktop' | null;
315
+ /** "responsive variant of §N" (capture --brief). */
316
+ variantOf: number | null;
317
+ }
318
+ export declare function sectionShape(sec: BriefSection): SectionShape;
319
+ /**
320
+ * K8 (`policy.mode-b.responsive-variants`): the section a one-viewport section twins — the marked "responsive variant of
321
+ * §N", else a section visible at the other viewport (or both) whose title shares most words, or the same item count
322
+ * and a shared title word.
323
+ */
324
+ export declare function twinOf(secs: BriefSection[], i: number): {
325
+ n: number;
326
+ marked: boolean;
327
+ hero?: boolean;
328
+ } | null;
329
+ /** Skills a skill hands stages to: their units are in scope; units owned only by an unrelated skill are pushed down. */
330
+ export declare const SKILL_DELEGATES: Record<string, string[]>;
331
+ /** One-line layout capability from the derived facts: range, tab label, dropped section props, sub-44px CTAs. */
332
+ export declare function layoutLine(u: KbUnit): string;
333
+ /**
334
+ * Brief section → the best layout candidates. Two signals: which SECTION the brief text reads like (BM25 over the
335
+ * section units: derived props + handbook use cases, hand-written usage) and which LAYOUT (BM25 over the derived
336
+ * layout units). A layout scores by both, then by item-count fit. Page anatomy priors from the stage-1B checks:
337
+ * the first brief section is the hero (HeaderSection), and HeaderSection is a hero only; a closing CTA section is a
338
+ * CtaSection.
339
+ */
340
+ export declare function briefCandidates(kb: Kb, index: SearchSource, sec: BriefSection, byId: Map<string, KbUnit>, pos?: {
341
+ first: boolean;
342
+ last: boolean;
343
+ }, k?: number): BriefRow['candidates'];
344
+ /** A short note for brief sections no layout expresses well (shown in the candidates table). */
345
+ export declare function briefHint(sec: BriefSection, pos: {
346
+ first: boolean;
347
+ last: boolean;
348
+ }, twin?: {
349
+ n: number;
350
+ marked: boolean;
351
+ hero?: boolean;
352
+ } | null, candidates?: BriefRow['candidates'], page?: HintContext['page']): string;
353
+ /** What a candidates-table note sees: the section, its position, its responsive twin and its candidates. */
354
+ export interface HintContext {
355
+ sec: BriefSection;
356
+ pos: {
357
+ first: boolean;
358
+ last: boolean;
359
+ };
360
+ twin?: {
361
+ n: number;
362
+ marked: boolean;
363
+ hero?: boolean;
364
+ } | null;
365
+ candidates: BriefRow['candidates'];
366
+ /** K11 F1: what the page-level passes decided for this row (accordion carousel, statement stand-in). */
367
+ page?: {
368
+ carousel?: {
369
+ takenBy: number | null;
370
+ layout: string;
371
+ cards: number;
372
+ nb: string | null;
373
+ };
374
+ statement?: {
375
+ prev: number | null;
376
+ to: string | null;
377
+ };
378
+ };
379
+ }
380
+ /**
381
+ * The candidates-table notes, in order. A rule returns '' when it doesn't apply; a `stop` rule that applies ends the
382
+ * list (a twin or a logo strip needs no other note). K11 made this a list so a rule-collision note (grey band + grey
383
+ * cards) can sit next to a layout note; add a row for a new collision the mapping stage must see.
384
+ */
385
+ export declare const BRIEF_HINTS: {
386
+ name: string;
387
+ stop?: boolean;
388
+ hint: (c: HintContext) => string;
389
+ }[];
390
+ /** Compact limit text from a derived limit unit's facts: `16–37c`, `≤3w`, `1–2s`. */
391
+ export declare function limitShort(u: KbUnit | undefined): string;
392
+ /** One line per item type a layout renders: the rendered fields (● required) with their copy limits. */
393
+ export declare function itemShapeLines(u: KbUnit, byId: Map<string, KbUnit>): string[];
394
+ /** The search text for one brief section: the title and any layout / interaction hint lines weigh double. */
395
+ export declare function briefQuery(sec: BriefSection): string;
396
+ /**
397
+ * Email brief blocks (K7): `**Section NN:** <name>` lines (the Lifecycle brief layout, e.g. examples/brief-example.md),
398
+ * else the items of a "Must-have blocks" list, else the brief's `###` headings. Each block keeps its text until the next.
399
+ */
400
+ export declare function emailBriefRows(brief: string): {
401
+ title: string;
402
+ text: string;
403
+ }[];
404
+ /** K10: the navbar + footer code the compact page-file route inlines. */
405
+ export declare const CHROME_EXAMPLES: string[];
406
+ export declare function route(kb: Kb, index: SearchSource, o: RouteOptions): RouteResult;
407
+ /**
408
+ * K11 G1 — the Critical guarantee at the Watch cut: a Minor unit never pushes a competing Critical unit out of Watch.
409
+ *
410
+ * `ranked` is the Watch ranking (best first, CRITICAL_EDGE included); its first `n` entries take the Watch slots (an
411
+ * entry the build already saw takes a slot unprinted). A Critical entry below the cut *competes* for the cut when it
412
+ * scores within `margin` of the lowest-ranked Minor entry above the cut; the two then swap: the Critical takes the last
413
+ * kept place, the Minor heads the rest (More). Repeated pairwise (next Critical below, next Minor above) while the pair
414
+ * is a near-tie. Nothing else moves, and a seen entry neither swaps in (it would print nothing) nor out.
415
+ *
416
+ * Why this rule (G1): CRITICAL_EDGE alone is a nudge, so BM25 drift from unrelated unit edits kept flipping
417
+ * `policy.mode-b.precedence` (Critical) against `gotcha.TrustSection.layout-props` (Minor) in run F/G service; raising
418
+ * the edge reorders every route. The swap acts only at the cut and only against a Minor — two severity tiers below,
419
+ * already 1.2 behind on severity weight, so a Minor that still ties a Critical does so on brief relevance alone. A
420
+ * Major, one tier below, keeps its slot (a Major/Critical near-tie is the ranking working: every no-brief route has
421
+ * several at the 0.1 score quantum, and swapping them reshuffled ROUTING.md). Units with no severity (procedures,
422
+ * stats) are not ranked by severity and never swap out. The margin sits in the gap of the run E/F/G route corpus
423
+ * (Minor/Critical near-ties at ≤ 0.09 and ≥ 0.19) and is 5× the 0.03 deficit precedence had.
424
+ */
425
+ export declare function guardCriticalAtCut<T extends {
426
+ u: {
427
+ severity?: string;
428
+ };
429
+ s: number;
430
+ }>(ranked: T[], n: number, seen?: (e: T) => boolean, margin?: number): T[];
431
+ //# sourceMappingURL=route.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../src/core/route.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAQ,MAAM,YAAY,CAAA;AAEzD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAW/C,eAAO,MAAM,cAAc,OAAO,CAAA;AAClC;wGACwG;AACxG,eAAO,MAAM,YAAY,OAAO,CAAA;AAEhC;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,GAAG,GAAG,GAAG,EAAE,MAAM,EAAE,CAGxD,CAAA;AAED,mHAAmH;AACnH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,GAAG,GAAG,MAAM,CAgBhE;AAED,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,GAAG,GAAG,GAAG,CAAA;IAChB,KAAK,EAAE,KAAK,CAAA;IACZ,6BAA6B;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,oDAAoD;IACpD,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf;;;OAGG;IACH,IAAI,CAAC,EAAE;QAAE,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;QAAC,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;KAAE,CAAA;IAClD,4GAA4G;IAC5G,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAA;IACnB,+F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