Repository navigation
Read docs through one internal compiler (no output change) - #6484
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
There was a problem hiding this comment.
This is a clean internal refactor: all reference-topic docs reads now go through one compiler, and I verified the behavior-preserving points (error order and messages, overlay and merge order, single-level reference linking, per-section isolation) alongside passing suites for the compiler, docs readers, doctor, and search.
No action needed from the contributor. Note it is stacked and should land after its base.
[Automated review]
There was a problem hiding this comment.
This is a clean internal refactor: all reference-topic docs reads now go through one compiler, and I verified the behavior-preserving points (error order and messages, overlay and merge order, single-level reference linking, per-section isolation) alongside passing suites for the compiler, docs readers, doctor, and search.
No action needed from the contributor. Note it is stacked and should land after its base.
[Automated review]
3f696bc to
a6e3787
Compare
a6e3787 to
5e6ab3b
Compare
There was a problem hiding this comment.
This is a clean internal refactor: all reference-topic docs reads now go through one compiler, and I verified the behavior-preserving points (error order and messages, overlay and merge order, single-level reference linking, per-section isolation) alongside passing suites for the compiler, docs readers, doctor, and search.
No action needed from the contributor. Note it is stacked and should land after its base.
[Automated review]
`astryx docs`, doctor and search each drove doc loading themselves: overlays, extension merge, key stamping and token-ref resolution were called from four places in their own order. That now happens in one place. The doc compiler lowers a topic (overlay each file, merge extensions, stamp keys) and links its token references, and every reader reads the compiled node through a lens. Output is unchanged: 16,556 reads (topics, indexes, sections, queries, errors, doctor's docs checks, search) compared byte-for-byte against the previous head, across this repo and three consumer projects.
Two extensions replacing one section: the later-configured one wins. A mutation that merged extensions in reverse survived every existing test.
Three review findings, none of which changed any output: - A memoized node was shared by every read of one catalog, and the lenses handed out its blocks, so editing one result changed the next. Memoized nodes are now frozen and every view is a fresh copy. - A node could hold what JSON cannot (a function, a Date, `undefined`) and the parser accepted it. The compiler now builds the node as JSON, and the parser rejects anything else, plus untyped blocks, paths in provenance, and resolutions that do not match the node's new `stage` (lowered or linked). - The rule that only the docs adapter and leaves drive the compiler was a regex over call names, which an import alias defeated. It is now an ESLint `no-restricted-imports` rule, plus a test that parses every import, including dynamic `import()`.
5e6ab3b to
448330c
Compare
Follows #6471, now merged. This branch is rebased onto
main, and its diff is only the compiler.Maintainer impact
astryx docs,astryx doctorandastryx searcheach drove doc loading themselves: overlay loading, extension merge, key stamping and token-reference resolution were called from four places, each in its own order. Every new reader (the docs sites, MCP, the docs graph) would have added another copy. This puts those steps in one internal compiler, and every current reader consumes its output.Intended invariant
Every
docs()response (docs.list,docs.detail,docs.index,docs.detail.section), every docs error,astryx doctor's docs checks andastryx searchresults stay byte-identical. The compiler is internal: no new package export, anddocs()stays the public way in.Change
foundation/doc-compiler/compile.mjs—lowerReferenceTopicoverlays each file, merges extensions in order and stamps section keys;linkReferenceTopic/linkReferenceSectionresolve token references against the target topic lowered for the same language. The output is a schema-versioned node in plain JSON with astage(lowered, thenlinked). A section's authored title travels as data (sourceTitles), not a symbol. An authored value JSON cannot hold (a function, a Date,undefined) takes its JSON form when the node is built, which is what--jsonoutput always showed; no shipped doc has one.foundation/doc-compiler/lenses.mjs— the response shapes, read off compiled nodes. Every view is a fresh copy.foundation/doc-compiler/ir.mjs— the sealed parser for a node read back from JSON: plain JSON throughout, typed blocks, package names (not paths) in provenance, and token-reference resolutions exactly when the node is linked. It returns the value as given, so key order survives.api/docs/_adapter.mjsloads authored files into compiler input and memoizes lowered nodes per catalog. Memoized nodes are frozen, since every read of the catalog shares them. A file that fails to load is recorded, and the compiler throws it in the order a reader meets it, so error messages are unchanged.no-restricted-importsrule forapi/andclients/, plus a test that parses every file's imports (aliases, namespace imports, re-exports and dynamicimport()).Evidence
astryx docscommands identical on stdout, stderr and exit code: text,--json,--index,--lang zh|dense, every section by key, and errors.id, and appends only when the key is absent. So by induction over extensions, no merge can leave two sections under one key. The check stays as a tripwire for a future change to merge.Scope
Testing
mainafter Add typed documentation graph contracts #6471 merged: the three commits replayed without conflicts, and every file they change is byte-identical to the head the evidence above was run on.Next in this stack: the other doc kinds (components, hooks, pages), then list and search from one cached bundle.