Navigation
ELOWEN · Documentation

Last updated: October 27, 2026

Browse documentation · Documentation indexing
Developer reference

Documentation indexing

Core owns documentation sources and the DocsSearch / docs control contract. Source ingestion belongs exclusively to the background worker: src/search/docsCorpusIngest.ts builds the source snapshot and docsPresentationIngest.ts owns safe file/asset reads and article rendering. Both consume the canonical parsed-source contract in docsCorpusSource.ts: it owns DocFile, DocVariant, CorpusArticle, ParsedCorpus and chunk descriptors, with variant metadata inferred directly from its unchanged articleMetadata validator and category lookup. The builder consumes the validator and source types; presentation imports only the types, never the snapshot builder. This keeps the builder-to-presentation dependency one-way, including erased TypeScript dependencies, without duplicating the source schema. The source contract imports no ingestion implementation. Neither ingestion module imports a database runtime, embedding service, queue or daemon lifecycle. The database package owns persisted immutable revisions, bounded readers and the single SQL ranker; live runtime authority and query accounting remain outside ingestion.

DocsSearchService is a bounded database adapter, constructed with corpora: repositories.search.corpora, embeddings and asynchronous embeddingConfig. It owns no source roots, files, parsed corpus, assets, projections, token index, loading promise or vector map; the former documents() queue interface is removed. The old docsSearchCorpus.ts module has no compatibility re-export. Daemon and runner readers import neither ingestion module. The worker publication/lifecycle owner connects the source snapshot to the repository; the builder itself never opens a connection, schedules work or publishes a revision.

ingestDocsCorpus({root, pluginDirs}, sourceKey, identity) returns exactly one DocsCorpusSnapshot; the caller supplies the installation's source key: a repository-typed revision header, ordered DocsDocument rows, a DocsPresentationBatch and the exact source manifest. The worker supplies the database package's pure searchOwnerKey, searchLexicalHash and searchRevision identity functions as identity; the builder imports their signatures and row types only. This keeps identity serialization under one owner without pulling database initialization into source traversal. The focused ingestion tests are direct consumers with deterministic identity fixtures; integrated publication must additionally use the package-owned functions.

The snapshot contains no Markdown AST, token counts, BM25 index, vector map or query result. Parsed trees and image-resolution maps are local to the ingestion attempt and become unreachable after it returns. The same attempt works without a configured model or an embedding queue. Publication batches, boot/generation fencing, cancellation before activation, durable error status, native vector backfill and pending embedding pages belong to the worker/repository owners, not to a second ingestion scheduler. See the semantic index.

Daemon bootstrap supplies the trusted numbered-manual root next to the package through worker IPC. On a pinned compiled boot it maps docs/site through runtimeSourcePath to the real original installation: core documentation is neither copied nor symlinked into the runtime snapshot. Bundled-plugin documentation stays under the copied dist/plugins scan root. The ordinary source-root and file symlink prohibitions apply unchanged to both. readCorpus reads Markdown pages whose filenames start with at least two digits and a hyphen under docs/site (including three-digit article numbers and actual .cs.md / .sk.md variants), recursively, plus the curated docs/modules and docs/plugin-author trees. The package ships those two developer trees. Private plans, reviews, tools notes, audit files and top-level operator references are outside that allowlist. Missing curated trees are an installation error; an empty parsed corpus also rejects rather than becoming a successful empty snapshot.

readPluginDocs walks each manifested plugin's docs/ tree recursively and preserves its complete logical citation path. Canonical bundled-first scan roots come from the host; the first root wins a plugin-name collision. Disabled installed plugins remain part of product documentation. A missing optional plugin root or a manifested plugin without docs contributes nothing. Sources are read as data, never imported. Authored metadata is retained for core and bundled sources; installed plugin sources choose an authored group, defaulting only an absent group to plugin-reference. A present group must identify an everyday, advanced or administrator category. Its audience comes from that category, not from the installed source's authored audience. An installed docs/developer/ subtree instead receives plugin-development / developer ownership.

The shared packages/plugin-shared/document.mjs parser owns YAML validation, Markdown tokens, headings, explicit stable section IDs, translations, links and image references. parseCorpus adds source/category ownership, requires authored article identity and, for core/bundled sources, an explicit section mapping for every heading. An invalid source reports search.docs_frontmatter_invalid and rejects the attempt; it is never silently omitted. The worker yields between parsed files, but no query process parses Markdown or builds an Intl.Segmenter index.

English canonical metadata owns slug, category, audience, order and related/featured ownership. Every category has one section (user, advanced, admin, developer); audience must agree with it. Only an everyday category may use featuredOrder. The Guides route segments category and section are reserved slugs. Duplicate canonical slugs, duplicate locale occurrences, translations without their canonical sibling, changed canonical translation metadata and changed section identities/depth reject ingestion. Only the actual variants of articles with a Guides page are persisted as HTML: user and admin articles plus the plugin-authors category, the one developer category Guides renders (hasGuidesPage in src/search/docsCorpusSource.ts). Repository readers choose the complete requested locale or the complete canonical English variant, never fabricate a translated variant or mix paragraphs. Other developer locales (developer-reference, plugin-development) remain in search rows, not reader variants.

The parser exposes each section's Markdown in DocumentSection.markdown and original block tokens in DocumentSection.tokens, without a redundant whole-section plain-text field. The worker's chunksForVariant is the real consumer of the shared documentTokenChunks(tokens) projection: it packs complete small AST units as raw Markdown and their visible text as one {body,text} pair, with each body bounded to 1,500 UTF-16 code units. Only exterior section whitespace is normalized. Oversized paragraphs and blockquotes descend through their actual child tokens, lists through item tokens and tables through row/cell tokens. A list item keeps its raw Markdown when bounded; a table row keeps its parser-provided cell Markdown together when bounded, descending into cells only for an oversized row. This preserves a definition and its description as one unit rather than arbitrarily separating neighboring cells. An oversized atomic leaf, including fenced code or HTML, is divided deterministically from its parser-projected literal or visible text without splitting a surrogate pair; its retrieval body becomes that same text, not an incomplete Markdown fence or link. Link labels contribute lexical evidence, destinations do not; code blocks and inline code retain literal content, including entity spellings. Other tokens retain documentTokenText semantics. No source-range guessing, regex Markdown stripping, second parser or legacy chunker participates. The helper does not mutate the AST: heading identity, renderer HTML and metadata presentation are unchanged. It runs only during bounded source ingestion, never on queries, and owns no model or persistence work.

IDs remain ${slug}:${locale}#${sectionId}:${part}; chunkPart is produced in AST-unit order, not recovered from a path heuristic. AST packing can change boundaries, bodies, part identities and hashes, including when a previous character cut divided a link, list or code block. The exact embedding text is ${docTitle} › ${heading}\n${body}, hashed with the shared hashText; there is no hash adjustment for synthetic vectors. Provider, model, vector space, query and boot do not affect that content identity. The existing lexicalTitle field comes directly from the parser's local section.text (or the variant's metadata title for the intro before any heading), not from splitting the display breadcrumb. A literal › inside an authored heading remains part of that one local heading. lexicalBody is the bounded chunk's paired token text, not a reparsed slice or the whole section repeated for each part. Format 5, which renders the plugin-author guides, invalidates prior unchanged-boot reuse; the typed IPC source, coordinator and producer use that same format. Each row also retains locale, category, reader section, audience, logical path and the existing optional citation URL as nullable storage data. Citations of articles with a Guides page (user, admin and plugin-author) point to /guides/<slug>#<sectionId>; other developer citations have no Guides URL.

Presentation rows retain every category's stable ordinal, section, icon and Czech/Slovak/English label and description. Article rows retain canonical order (including fractional values), audience, category, reviewed date, featured order and related features. Actual variant rows of articles with a Guides page carry their own title, summary, source path, sanitized HTML, TOC and resolved linked slugs. Other developer sources retain search documents, article metadata and referenced asset membership, but are never rendered and have no HTML variant row, including no empty fallback HTML, because they have no article endpoint. The shared renderer uses omitTitleHeading:true, retaining the title anchor without another visible H1, then the Node sanitizeDocumentHtml boundary. Navigation, related-guide selection and catalog locale fallback remain bounded repository projections over those rows; the catalog lists exactly the articles that have a variant row, so the variant join, not a second audience rule, keeps the other developer references out of Guides. Plugin-author guides form the Guides developer section and are English-only, shown with the English-fallback badge. Audience is a reader label, not a new ACL: administrator guides remain readable through the existing authenticated surface.

Link resolution preserves original authored HTTP/HTTPS/mailto links and existing application /settings deep links. Known canonical slugs, /guides/ / /docs/ article paths, source-relative Markdown and stable anchors resolve to Guides URLs. Section validation uses the target's requested variant with complete English fallback. Targets without a Guides page (developer references other than the plugin-author guides) render their formatted label without a link. An existing non-indexed regular file inside an owning plugin package, such as ../NOTICE, also renders as a label: its bytes are neither read nor served, and its membership is revalidated before a snapshot is accepted. Unknown links/sections, non-file protocols, directories, symlinks and package escapes reject. Developer page bodies without a Guides page are not rendered, matching the article endpoint's reader scope, so their own links to non-indexed references such as top-level operator docs do not block a snapshot. Plugin-author guides are rendered; a link of theirs that resolves to no indexed article renders as its label, so the same links still never block a snapshot, while the shipped guides name repository-only documents (docs/DEPLOYMENT.md, the elowen-plugin-shared README) as code, because those files are not in the installed package. An article pointing into a page without one still validates the target section before suppressing the link; skipping that presentation never weakens reader link validation.

Source reads reject symlinks and root escapes, check containment of the opened descriptor, cap Markdown at 1 MiB and images and videos at 10 MiB, and compare descriptor/path identity, size, mtime and ctime after reading. Replacing a still-open source is a failure, not a reusable stat-cache hit. Traversed documentation subtrees cannot silently disappear behind symlink directories. Only parser-discovered local PNG/JPEG/GIF/WebP/MP4 references with nonempty alt text enter presentation membership; extension and byte signature must agree (an MP4 must open with an ISO base media ftyp box). Remote/query/fragment image URLs, SVG and other video containers are refused rather than fetched.

A guide video is an MP4 referenced with image syntax, ![Caption](videos/<slug>/<name>.mp4); core sources keep it under docs/site/videos/ (shipped through package.json files beside docs/site/images/), plugins under their own docs/. The presentation adapter resolves it to {src, video: true} on the same asset URL, and the shared renderer replaces the image with <video controls preload="metadata" playsinline> whose accessible name and fallback text are the caption. Authored HTML <video> fails parsing, so every player comes from a resolved asset. sanitizeDocumentHtml keeps a video only with a source matching the videoSource pattern its caller passes, here DOCS_VIDEO_SOURCE (/api/docs/assets/<slug>/<sha256>.mp4; a caller without one keeps no video), and only the src, controls, preload="metadata", playsinline and aria-label attributes; source, track, audio, iframe and poster stay forbidden, so autoplay, external, data: and third-party embeds never reach Guides. Video bytes never enter search text: chunks come from the Markdown tokens, where a video is only its caption. Plugin images and videos stay within that plugin's docs/ root even though a private notice link may refer to the owning package.

Asset IDs remain raw-byte SHA-256 plus extension, with URLs /api/docs/assets/<slug>/<assetId>. Every slug/asset membership, MIME and exact bytes is part of the presentation batch. Equal content may share a blob in storage, but another article's membership never authorizes an asset. Only referenced assets are emitted. Changing image bytes changes source/presentation revision and the URL without changing an unchanged chunk's text hash; removing a reference removes its membership on the next published snapshot.

The manifest records canonical source roots in precedence order; every selected file's logical/physical path, containment root, metadata owner, exact byte hash and byte count; complete category identity through its hash; every referenced asset's path/root/hash/MIME/size; and private-link membership dependencies without private bytes. No mtime, boot, provider or query enters content revision. DOCS_CORPUS_FORMAT_VERSION must change when parser/rendering or descriptor projection semantics change. The source key identifies the installation (['docs', instanceRoot], computed by CorpusIngestionCoordinator and passed to ingestDocsCorpus), never the documentation directory: a versioned install unpacks every release into its own directory, so a release that moves the root, like a plugin-root change, publishes a new revision under the same source; source revision includes the full manifest, and the package-owned revision function includes the format and complete ordered document descriptors.

isDocsSourceCurrent({root, pluginDirs}, manifest) is the worker-only unchanged-revision check: it rescans and hashes selected source bytes, compares root precedence, metadata ownership and category identity, rereads referenced assets and revalidates private-link membership, without parsing or rendering. The worker must also compare the stored format version before reusing a revision. The revision header supplies the exact serialized object manifest as sourceManifest:{json} (at most 8 MiB of UTF-8), and sourceRevision hashes those same JSON bytes. Persist and reload that manifest with the revision so this is a content check after restart, never an mtime-only or process-cache authority. A changed source returns false; unsafe, missing required or unreadable sources reject. A fresh ingest rechecks that same manifest after rendering and refuses a source that changed during the attempt. No database transaction spans traversal or rendering. Successful publication/reuse persists the owning boot's verification; same-boot refresh/source/embedding failures retain last-good readiness, even for a fresh runner. A new boot must verify again, and native storage incompatibility revokes readiness only for its corpus. stage alone never proves verification.

DocsLookupControl and the importless DTOs in src/shared/docs.ts keep search(query, limit, context?, execution?), catalog(locale), article(slug, locale) and asset(slug, assetId). The reader additionally implements searchResult(query, limit, context?, execution?), returning {revision,hits} from one repository query snapshot; search() delegates to that operation and returns only its passages. Its user-projection overload returns navigable guide passages. searchDocs() retains the tool's mode/model/coverage/reason envelope and adds the same database revision beside bounded ranked sections. The importless DocsSearchMatch DTO replaces the tool's parser-owned type import. Catalog, article and asset methods delegate directly to typed repository readers without rendering or source access. DocsSearch defaults to English/all; Guides and both Ask AI consumers request an explicit locale and user projection, with an optional category. Search passage IDs retain their section/part grammar and display headings retain their breadcrumb bytes; AST repacking may change the part population. The single database ranker owns exact-identifier ordering, requested-locale section substitution, article deduplication before limit and fixed semantic:keyword RRF 2:1 (K=60). Its documentation BM25 uses persisted term frequencies/lengths and computes document frequency and average length only within the eligible locale/audience/category projection. Canonical packed FP32 bytes back an additive native FP32 exact cosine scan, not an ANN index or JavaScript vector map. Ingestion does not rank or decide vector coverage.

Server-only DocsSearchExecution carries the caller's userId and cancellation signal separately from retrieval data. HTTP supplies its authenticated account; tools use the current contribution account; explicit null remains instance work. Query embedding uses the shared querySemantics operation: one caller-billed query vector and exact space, never corpus vectors. Interactive search/searchResult use its 2,500 ms budget; agent searchDocs has no provider deadline. Before query admission, corpora.docsProjection({kind:'docs', ...context}) reads the active ready revision and hasDocuments in one bounded SQL statement. Its EXISTS predicate shares the ranker's exact locale/audience/category projection; it loads neither document bodies nor vectors. An unavailable snapshot rejects, while an empty projection returns {revision,mode:'keyword',hits:[]} from that metadata without reading embedding configuration, admitting inference or dispatching ranking. For a nonempty projection, preflight metadata is not reused as the query revision: a publication during inference is reflected by the actual ranked SQL result and its own atomic revision. Provider outages can return SQL keyword results with a reason; account refusals, space/configuration faults, database failures and unavailable snapshots propagate. Cancellation is checked before provider/DB dispatch and after the awaited SQL result. Source ingestion and catalog/body/asset reads perform no inference. A missing model does not prevent ingestion or keyword retrieval, and does not introduce a new palette suggestion UX.

The authenticated/licence-gated HTTP adapter in src/api/routes/docs.ts and the docs host control keep their public DTOs and status contracts. Developer pages other than the plugin-author guides stay outside Guides. The user search projection still excludes every developer source from unscoped searches, so the Guides search, the palette and Ask AI do not surface plugin-author guides; a search inside one category (the group Guides sends from a category page) also reaches that category's articles that have a rendered variant, so searching inside Plugin authors finds them (docsProjectionWhere in packages/db/src/search/corpusScope.ts). DocsSearch with the all projection cites them with their Guides URL. Missing articles and unreferenced assets answer 404; unavailable or failed ingestion never becomes a successful empty catalog. Asset membership is checked in the chosen active revision before ETag/304, with exact bytes, the persisted MIME, nosniff and private, no-cache. A removed plugin/image can therefore invalidate an old article's asset URL at the next atomic publication; a stale URL is not a retained permission. The asset answers accept-ranges: bytes: one satisfiable byte range (overlapping or adjacent ranges merge into one) returns 206 with content-range (Safari plays a video only from such a server), an unsatisfiable bytes= range 416, and a malformed header or several disjoint ranges the whole asset. Each range request reads the asset's blob from the database once, which is why guide videos stay small. The same-origin BFF keeps authentication, path validation, streaming, disconnect and conditional-header behavior.

DOCS_SEARCH_TOOL remains the account-grant name consumed by the core tool factory and standard capability composition. Administrators hold the same finite tool grants as other accounts; this storage/worker change widens no grant. Guides, the command palette, Ask AI and declared plugin consumers continue to use the host-owned control, never a plugin-owned index. The control contract is documented in plugin controls, with the seam catalog as the contribution inventory.

Builder regression coverage lives in tests/search/docsIngestion.test.ts and docsAssetsIngestion.test.ts: citation/text identity, actual locale rows and fallback prerequisites, canonical metadata/category ownership, root precedence, nested/disabled installed sources, duplicate/invalid translations, render/link/sanitizer parity, referenced asset identity, bounded no-symlink reads, concurrent source changes, unchanged verification without parser/render/model work, developer search/metadata/assets without HTML, rendered plugin-author guides, complete shipped-corpus reader ingestion and every What's new link to a shipped guide resolving to a rendered anchor. Reader/publication coverage uses tests/helpers/docsDatabaseFixture.ts: test setup ingests with the database package's real identity functions, appends bounded document/presentation batches and seals a ready snapshot in an ephemeral PostgreSQL database. Content, locale, asset retirement, tool, error and deadline tests consume that repository rather than a filesystem-backed service. docsDatabaseRead.test.ts forbids ingestion/AST runtime imports on a fresh reader; docsCorpusContent.test.ts publishes the complete shipped corpus and compares every reader variant and referenced asset. The frozen-corpus acceptance contract preserves source/file/category hashes, scope, coverage and citation identity; ranking acceptance measures correct answers, not parity with the former equal-weight ranker. Each query needs a source-grounded answering article/section in top three; broad multi-article questions use top five with a recorded rationale. Exact identifiers/error codes/API names require their defining section at rank one. Every accepted alternative needs a source-grounded reason; the no-model SQL keyword path has its own correctness gate. Synthetic vectors characterize mechanics, not empirical semantic quality. Neither policy approval nor old-order overlap establishes a passed quality gate. Browser and multi-process integration suites separately prove real flows and runner boundaries.