Repository navigation
feat(metadata): build port-neutral docs view from loaded model - #665
Merged
Merged
Conversation
Every documentation page reads one port-neutral document of facts, the docs view, and a port builds it from the model it has already loaded rather than from re-derived JSON. This is the first step of making docs ordinary configured Mustache codegen in every port. - metadata: buildDocsView / serializeDocsView. Nodes of any type with effective attrs, members grouped by type (declaredOn for an inherited member), refs from the loader's own resolution and their reverse, claims through the gate's resolver, files and routes; the requirements flat with depth, status, links and roll-up; packages, counts, advisories and slices. Facts only, every key always present, object values in code-unit key order. - docs-site: the explorer pages read the view through a ViewIndex. build.ts, index-model.ts and types.ts are deleted, with markInherited and the seven-kind edge list. The pages look the same: a member with no row gets an empty anchor in the crumbs, and "Referenced by" and the map now carry every resolved reference. The map draws only edges whose two ends it draws. Templates are unchanged, so an ejected theme keeps working. - fixtures/explorer-conformance: shop re-pinned as the view (effective.json dropped, routes.json added); new crm case with provider.json vocabulary whose members and refs appear with no docs code that names them. - docs: docs/features/docs-view.md (the contract); explorer-data.md rewritten around the inputs; explorer-site, CONFORMANCE, READMEs and CHANGELOG updated.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What Changed
buildDocsViewandserializeDocsViewin@metaobjectsdev/metadata(src/docs-view/). They build one facts-only docs view from the loaded, resolved model: nodes with effective attrs, grouped members, resolved references and reverse references, requirements flat with depth and status roll-ups, claims, generated files, packages, counts and verify advisories. No HTML or Markdown.docs-site/src/explorer/build.tsandindex-model.tsare removed, replaced byview-index.ts.docsSiteFile()builds the view fromctx.loadedRootandgenerateExplorerSitewrites it asexplorer.json.fixtures/explorer-conformance/crmcorpus (custom vocabulary, with provider, verify and expected outputs), reworksshopexpected output, and gates the view withmetadata/test/docs-view-conformance.test.ts. The contract is indocs/features/docs-view.md.Evidence
Corpus diff (
fixtures/explorer-conformance/,main...HEAD):shop/expected.jsonis re-pinned as the docs view (10 nodes, 9 requirements).effective.jsonis gone, because the view is built from the loaded model, not frommeta export --effective.routes.jsonis new.crm/is new. Its vocabulary (page.list,block.table,capability.module) is declared only inprovider.json. Its members and@objectRefreferences appear in the view with no docs code that names them. It also pins three id rules: a same-name page declared before its entity (the entity keeps its claims),@ofon an inherited member (it lands on the owner's row), and a namelesssource.rdbwith@parameterRef(its label keeps#0).Site build:
mainversus this branch. Each side builds the explorer withgenerateExplorerSite, from the same loaded model.generateExplorerSitethrows on a dangling link, so every build below also passed the link check.<span id="m-…">addedshop(same inputs, no routes)persistence-conformance/canonical)crm(new)@from/@spine, a projection's@of/@via, a junction's@through. For example,ProgramgainsLiveIntroPrograms,ProgramsByMonthandRecentPrograms. The other two (AllTypesBreakdown,LiveIntroPrograms) print@filterwith its keys in code-unit order. No link was lost.payloadbecomespayloadRef,replybecomesresponseRef, andassociationbecomesobjectRef. Fitness goes from 51 edges to 71.mainshipped one dangling edge,IntEnumArray→PublishState, to a node the map does not draw. The branch emits only edges whose two ends are drawn.Drift gate.
gen-docs-generators.test.tscovers it: a secondmeta genrun is identical, andmeta verify --codegenreports clean.Local checks before the gate. Root
bun run buildandbun run typecheckpass. The metadata, docs-site, codegen-ts and cli suites pass with 0 failures, and so doesscripts/ci-local.sh --only gates.The no-mistakes gate took 1 run: three review fix rounds and one document fix.
Validation
Risk Assessment
✅ Low: The latest fix round is small. It changes refLink to one byPlain lookup and pins the three id rules in the crm corpus. I traced the crm view and found the expected results: Lead keeps its claims while the page is declared first, and @Of Lead.score lands on Lead.html#m-score with declaredOn Scored. The nameless source keeps its #0 label. The spec, README and CONFORMANCE notes match the code.
Testing
Baseline ci-local --affected passed at target commit. Live probe of the builder on a disposable project with the requirement declared before its entity: the shadowing fix holds (entity keeps claim; requirement gets its own node). Docs-view conformance and ref tests pass (17), but that is not live evidence. Inherited-member links, nameless member labels, and CLI explorer.json output were not driven live. Worktree clean. No evidence files written; no background processes.
Pipeline
Updates from git push no-mistakes
✅ **Intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
server/typescript/packages/metadata/src/docs-view/build.ts:195-byPlainkeeps whichever node with a given plain path the walk reaches first (if (!this.byPlain.has(plain))). That contradicts the id rule a few lines up, under which an object keeps the plain id even when it is declared later. Concrete sequence: a pageLead(or a requirementOrder) is declared before the entity of the same name, for example pages in meta.app.json loading before entities in meta.crm.json. ThenbyPlain.get("acme::crm::Lead")returns the page. Members also collide, because a qualified top's members buildplainfrom the unqualifiedparent.plain: a page blockemailshadows the entity fieldemail. Every resolution-key lookup then lands on the wrong node with no error: (1) claims at build.ts:391, whereresolveClaimTargetreturns the entity but the claim, the requirement's targets and the link go to the page; (2) manifestsourceNodeat :416, so generated files are listed on the page; (3) routes at :428; (4) advisories at :443, sosubjectand the entity'sunclaimedflag (:447/:520) move to the page and the entity page loses its unclaimed outline. The old builder keyed these by id, where the object held the plain id. The crm fixture declares the entity first, so the corpus misses this. Fix: when a plain path is already held, let the walked node whose top holds the unqualified id (w.top.id === w.top.plain) take over. Add a corpus or unit case with the non-object declared first.ℹ️
docs/features/docs-view.md:73- The spec says "A link to an inherited member lands on the node that declares it, because a reference to that member resolves there". The builder does not do this for the two main link sources. A claim such as@implementedBy: Customer.id, withidinherited from BaseEntity, resolves throughbyPlainto the walk under Customer, so it lands onCustomer.html#m-id(build.ts:391; the corpus test asserts exactly that path for the inherited member). A reference valueacme::shop::Customer.idfails thetopLevelNodeOf(exact) === ownercheck (build.ts:239), so it falls back to the owner and lands onCustomer.html, not on BaseEntity. OnlydeclaredOnand a member'sextendsland on the declaring node. Since other ports will be held to this spec, either correct the sentence or make the builder match it.server/typescript/packages/docs-site/src/index.ts:7- Simplification: the change adds new public exports that no intent requirement needs.@metaobjectsdev/docs-sitenow exportsViewIndex,STATUSESandSTATUS_GLYPH, plus thePageNode,ReqEntry,ClaimandModelEdgetypes, at index.ts:7-8. Nothing outside the docs-site package imports them.@metaobjectsdev/metadataalso exportsdocsPackageDiranddocsPageStemthrough docs-view/index.ts:1, and only build.ts uses them. The intent asks only forbuildDocsView/serializeDocsViewand the view types to be public. ViewIndex is page-side scaffolding that part B (moving HTML into templates and deleting pages.ts/html.ts) will likely reshape, so exporting it now in unreleased 1.3.0 creates API surface that later has to be broken. Suggested fix: remove these exports, unless they are meant for owned themes.ℹ️
CHANGELOG.md:1469- Inline fix. The CHANGELOG ("never a list of attribute names"), docs/features/docs-view.md:34 and docs/features/explorer-data.md:29 said a provider's vocabulary gets its links with no change. But the loader resolves only attributes in the fixed core setREF_BEARING_ATTR_NAMES(resolve-references.ts:137 viaisRefBearingAttr). A provider attribute with another name (for example@entityRef) stays text, and the crm fixture links only because it reuses@objectRef. I reworded all three places: a provider attribute links when the loader resolves it as a reference (such as@objectRef). The test header comment in metadata/test/docs-view-conformance.test.ts:6-8 makes the same overstatement and is left for the fixer, because I do not edit test files inline.server/typescript/packages/metadata/src/docs-view/build.ts:195- This round-1 finding is still open. The only commit after the original change (633ac38, reviewer inline fixes) edits docs only.byPlainkeeps the first walked holder of a plain path (if (!this.byPlain.has(plain))). That contradicts the id rule at :143-160, under which the object holds the plain id even when it is declared later. I reproduced it with a probe on the current code. Packageacme::shopdeclaresrequirement.functional Order(@implementedBy: ["Order"]) beforeobject.entity Order, with routes and manifest keyedacme::shop::Order. The result has the entityacme::shop::Orderwith 0 claims, 0 routes and 0 files.acme::shop::Order[requirement.functional]gets 1 claim, 1 route and 1 file. The implementedBy link also points at the requirement's own page. Nothing errors. Members collide the same way: a qualified top builds its members'plainfrom the unqualifiedparent.plain(:162), so a page blockemailwould shadow an entity fieldemail. Every consumer ofbyPlainlands on the wrong node: claims at :391 (resolveClaimTargetreturned the entity, but the lookup by its resolution key gets the other node); the manifestsourceNodeat :416; routes at :428; advisorysubjectat :443, and thereforeunclaimedIdsat :447 and the entity'sunclaimedflag at :520. The crm corpus declares the entity first, so the corpus does not catch this. Fix: when a plain path is already held, let the node whose top holds the unqualified id (w.top.id === w.top.plain) replace the holder, or keybyPlainonly from walks under plain-id tops. Add a corpus or unit case in which the non-object is declared first.server/typescript/packages/metadata/src/docs-view/build.ts:239- Round 1 reported this as a doc mismatch (info). It is still unfixed, and it is a wrong value, not only wording. When a reference value names a member the owner inherits,refLinkdrops the member and links to the owner. The guardtopLevelNodeOf(exact) === ownerfails because the member physically sits on the base. Probe:Base(abstract) declarestotal, andOrder extends Base. Anorigin.aggregatewith@of: "Order.total"produces a link toacme::shop::Order/model/acme/shop/Order.html, with no member anchor. Two specs disagree with this. docs-view.md:157-159 says the link points at the member the dotted tail names. docs-view.md:73-74 says a link to an inherited member lands on the node that declares it. The builder applies three different rules to the same member:extendslands on the declaring node (Base.html#m-total); a claim@implementedBy: Order.totallands on the subtype's row (Order.html#m-total, viabyPlainat :391); an attribute reference lands on the owner page with no member. Other ports will be pinned to this corpus, and no corpus case has a dotted reference to an inherited member. Pick one rule. Suggested fix: whenexactis not physically underowner, resolve the walk ofownerplus the dotted tail throughbyPlain(consistent with claims). Then correct the sentence at docs-view.md:73-74 to state that rule (extends/declaredOn still name the declaring node), and add a corpus case.server/typescript/packages/docs-site/src/index.ts:7- Simplification, still open from round 1 with no recorded decision.@metaobjectsdev/docs-sitenow exportsViewIndex,STATUSES,STATUS_GLYPHand the typesPageNode,ReqEntry,ClaimandModelEdge. Nothing outside the package imports them.@metaobjectsdev/metadataalso exportsdocsPackageDiranddocsPageStem(docs-view/index.ts:1), and only build.ts uses them. The intent asks forbuildDocsView/serializeDocsViewand the view types. ViewIndex is page-side scaffolding that part B (pages into Mustache templates, deleting pages.ts/html.ts) will probably reshape. Exporting it in unreleased 1.3.0 creates API surface that a later step would have to break. A related point: docs-site/src/explorer/pages.ts:134 keeps its ownpkgDir, a second copy of thedocsPackageDirrule, for the package index path. IfdocsPackageDirstays exported, pages.ts should use it. Otherwise drop the export. Recommendation: remove the docs-site exports and the two helper exports, unless they are meant for owned themes.ℹ️
server/typescript/packages/metadata/src/docs-view/build.ts:225- A direct member with no name has the id<top>#<index>(:163). The member label is built asw.id.slice(w.top.id.length + 1), so the#is cut off. A probe gives{label: "Order.3", id: "acme::shop::Order#3"}, which contradicts the spec rule<owner name>.<member path>and the id. The same slice producesDocsViewClaim.memberat :400. Nameless members with a reference attribute are legal, for example a namelesssource.rdbwith@parameterRef. No corpus case has one, so the bytes other ports will match are still open. Fix: slice fromtop.id.lengthand drop a leading.only, so nameless members keep#<index>.ℹ️
server/typescript/packages/metadata/test/docs-view-conformance.test.ts:6- Left open from round 1 (the reviewer does not edit tests inline). The header says a provider's references "must come out linked with no change to the builder: the view reads the loader's resolution, never a list of attribute names". The loader resolves only attributes in the fixed core setREF_BEARING_ATTR_NAMES(naming-refs.ts:57, viaisRefBearingAttr). The crm fixture links only because it reuses@objectRef. Reword to match CHANGELOG/docs-view.md: a provider attribute links when the loader resolves it as a reference (such as@objectRef).🔧 Fix applied.
4 infos still open:
server/typescript/packages/metadata/test/docs-view-conformance.test.ts:6- Left open from round 1 (the reviewer does not edit tests inline). The header says a provider's references "must come out linked with no change to the builder: the view reads the loader's resolution, never a list of attribute names". The loader resolves only attributes in the fixed core setREF_BEARING_ATTR_NAMES(naming-refs.ts:57, viaisRefBearingAttr). The crm fixture links only because it reuses@objectRef. Reword to match CHANGELOG/docs-view.md: a provider attribute links when the loader resolves it as a reference (such as@objectRef).server/typescript/packages/metadata/test/docs-view-conformance.test.ts:195- The round-2 fix round added three view rules, and only TypeScript unit tests pin them: (1) the plain-id holder owns byPlain whatever the declaration order (build.ts:196); (2) a reference value naming an inherited member lands on the owner's own row (build.ts:243); (3) a nameless member keeps#<index>in its label and claim member (build.ts:226, :249). Neither shared fixture exercises them. shop and crm have no dotted reference attribute, no same-name node declared before an object, and no nameless member with a reference. The intent says the view is pinned by the corpus so that every port's view is byte-identical. A later port could therefore diverge on all three rules and still pass the corpus. Suggested fix: add these cases to a corpus fixture (for example crm: a projection with@ofon an inherited member, a namelesssource.rdbwith@parameterRef, and a page declared before the same-name entity), then re-pin expected.json with UPDATE_DOCS_VIEW=1. Once the corpus covers them, the unit tests can stay or be dropped.server/typescript/packages/codegen-ts/src/generators/docs-site-file.ts:158- Inline fix. The change left two JSDoc blocks stacked aboveinterface RunRoute, and the stale one, which describesrunRoutes, sat first. I moved therunRoutesdoc comment down onto the function.server/typescript/packages/metadata/src/docs-view/types.ts:14- Inline fix. The fix round changed the member label and the claimmemberso that a nameless member keeps#<index>, and it updated docs-view.md to match. It did not update the type doc comments.DocsViewLink.labelstill said<owner name>.<member path>, andDocsViewClaim.member(line 66) still said "dotted member path". I reworded both to match the spec: the member's id after the owner's id, withOrder#3/#3for a nameless member.🔧 Fix applied.
📝 2 wording or comment-placement notes left for the author (no fix round spent):
server/typescript/packages/codegen-ts/src/generators/docs-site-file.ts:158- Inline fix. The change left two JSDoc blocks stacked aboveinterface RunRoute, and the stale one, which describesrunRoutes, sat first. I moved therunRoutesdoc comment down onto the function.server/typescript/packages/metadata/src/docs-view/types.ts:14- Inline fix. The fix round changed the member label and the claimmemberso that a nameless member keeps#<index>, and it updated docs-view.md to match. It did not update the type doc comments.DocsViewLink.labelstill said<owner name>.<member path>, andDocsViewClaim.member(line 66) still said "dotted member path". I reworded both to match the spec: the member's id after the owner's id, withOrder#3/#3for a nameless member.server/typescript/packages/metadata/src/docs-view/build.ts:243- Live check of the inherited-member link (fix round 4 rule) and nameless member label was not driven; only unit tests cover them and the shared corpus does not yet pin them. Recommend a corpus case, as the review asked.scripts/ci-local.sh --affected --strict-toolchainsProbe: MetaDataLoader.fromDirectory + buildDocsView on a temp project with requirement declared before same-name object (byPlain shadowing regression), run under DEV_SCRATCH and removed afterwardsbun test test/docs-view-conformance.test.ts test/docs-ref.test.ts(server/typescript/packages/metadata): 17 pass, 0 fail, 73 expect calls🔧 **Document** - 1 issue found → auto-fixed ✅
docs/features/codegen-data-shapes.md:87- States the requirement rows are what the explorer graph holds. The docs view now builds requirements from the verify ledger and loaded model, so this may be stale. Not verified in code; confirm whether requirementRows still feeds explorer.json.🔧 Fix applied.
✅ Re-checked - no issues remain.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.