Repository navigation
fix(cli)!: docs/metadata-embed-ref judges a package doc against its package and declared dependencies - #27204
Conversation
…ckage and declared dependencies A multi-package artifact carries its definitions under packages[] and nothing at the top level, so the embed check, which read the artifact's top level, refused a package doc embedding its own package's object. Each owner's docs are now judged against that owner's body plus the packages of the artifact it declares in manifest.dependencies; the stack-level docs keep the stack's top level and add the package the artifact manifest names. Body docs get the same pass. Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5kKDkUCEhVR7RZ3Npk
Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5kKDkUCEhVR7RZ3Npk
…-owned read census The read predates this branch; the census's codeOnly masker lost its place in a nested template literal earlier in the file and blanked it, along with the embed check's old stack.objects/flows/permissions reads. Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5kKDkUCEhVR7RZ3Npk
…typecheck Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5kKDkUCEhVR7RZ3Npk
📓 Docs Drift Check3 anchor(s) derived from 1 changed package(s); no hand-written page names any of them, so this run has nothing to list — not a clean bill of health. This check sees only pages that NAME a derived anchor: one that documents this change in prose, or enumerates it in an authoring dialect, names none and stays invisible to it on every run. What this run could not see
Coarse fallback — 32 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 6d09a2eae24df8ecacd0e684b4552f0ca27d66e9 && git checkout 6d09a2eae24df8ecacd0e684b4552f0ca27d66e9
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 4265176cf34d47055346443f483ba826bd117161 8149b3d240e97680ab25dc5da74241c05816d87b && git checkout -B drift-repro 4265176cf34d47055346443f483ba826bd117161 && git merge --no-ff 8149b3d240e97680ab25dc5da74241c05816d87b
node scripts/docs-audit/affected-docs.mjs --json 4265176cf34d47055346443f483ba826bd117161 |
Contract reviewServed-tier: Face: narrowing ( ① Derived judgmentsYardstick: triage
Nothing in the diff lands outside the three hits plus the changeset; no governed path (Queue Guard green). ② Semver level
③ Boundary flags
Check-runs on Implemented-by: VERDICT: PASS Generated by Claude Code |
席位核对ACCEPT · The maintainer's standing authorisation for landing reviewed PRs, verbatim: 「按照 pm-dispatch 规则复核过的都授权」.
Generated by Claude Code |
Requested by Leehom · project thread
Fixes #27090
Clause-②: yes (narrowing)
Metadata-protocol: none
Skills-docs: follow-up owed — skills/objectstack-ui/rules/pages.md (its "Inline metadata views" section says a referenced item "must exist in this package"; it should add "or a package it declares in
manifest.dependencies")维护者速读
os build/os validate/os lint检查文档里的```metadata嵌入(状态机、流程、权限集)时,不再拿整个产物的顶层去找被引用的对象,而是拿"发这篇文档的那个包"加上"它在manifest.dependencies里声明的包"去找。顶层src/docs/的文档仍按栈自身的定义判,再加上产物manifest.id指向的那个包(这些文档就落在它身上)及其声明的依赖。composeStacks(…, { manifest: 'preserve' }))把定义都放在packages[]里,顶层是空的,所以包文档连自己包的对象都嵌不了(HotCRM 实测,被迫改用手写 mermaid)。分诊裁定:按发文档的包加它声明的依赖判,不是"产物里有就行"。defineStack({ docs }))里引用不存在的对象(以前根本没人检查),以及顶层保留扁平副本的产物里,包文档嵌入一个它没声明依赖的兄弟包的对象。只改构建期检查,不改元数据协议,也不改运行时渲染。回滚即 revert。packages/cli/src/utils/collect-docs.ts的lintMetadataEmbeds(唯一的 map 构建,现在吃 own + dependencies)和collectAndLintDocs里的embedScope;collect-docs.package-docs.test.ts新增的docs/metadata-embed-ref judges a package doc …一组。pnpm --filter @objectstack/cli exec vitest run --maxWorkers=2 src/utils/collect-docs.package-docs.test.ts,预期 49/49 通过;在main上同一文件 8 条失败。What changes
lintMetadataEmbeds(packages/cli/src/utils/collect-docs.ts) is the ADR-0051 embed check. It built its object, flow and permission maps from the stack it was handed, andcollectAndLintDocshanded it the artifact's top level both times: for the stack-level docs, and for each package's directory docs. A composed multi-package artifact carries its definitions underpackages[]and nothing at the top level (#14512), so every package-doc embed was refused, including one naming the package's own object.origin/main6866e2e7)src/PKG/docs/)manifest.dependenciesnamespackages[i].manifest.docs)src/docs/, unclaimed inline docs)manifest.idnames one of its packages (flatDocsOwner), that package's body and its declared dependencies. Those docs ship on that body (#22190) and the door registers the top level under that id.packages[]embedScopeanswers[stack]and no dependencieslintMetadataEmbeds(docs, own, dependencies = []).ownis one record or a list of them (a stack, a body, or both). The maps are built once from[...dependencies' bodies, ...own], so an owner's object wins a name a dependency also carries. No second builder, and every existing one-stack caller is unchanged.declaredDependencyIdsfrom@objectstack/corereadsmanifest.dependencies(the{ [packageId]: range }record) for the artifact load order (ADR-0130 D5). An id the artifact does not carry is an installed package's business and is not judged here. The edge is one-way. No new manifest key.lintDocs. The stack pass judgesstackScoped, the package pass judgesentry.all. A body doc's top-level copy (a reconciled composition keeps one) is no longer judged a second time against the whole artifact.collectAndLintDocsandlintDocsdocblocks said embeds resolve artifact-wide, the same as links. Links still do. The docblocks now say why embeds do not: an embed renders another package's live metadata, and ADR-0051 resolves it through the dependency set only.Tests
packages/cli/src/utils/collect-docs.package-docs.test.ts, a new block over a realcomposeStacks([service, app], { manifest: 'preserve' })artifact (each package owns one object with astate_machinerule):mainservice's directory doc embedsservice's own object: builds (acceptance 1). The test also asserts the artifact's top level carries noobjects.app's doc embedsservice's object,appdeclares nothing: refused (acceptance 2)appdeclaresserviceservicedeclaresapp, andapp's embed ofservice's object stays refusedsrc/docs/doc resolves in the owner package's scope, and reachesserviceonceappdeclares itpackages[]: a stack object embeds, a dead name is refused with "this package" (acceptance 3)The existing case
metadata embeds and links are partitioned the SAME way — artifact-widepinned the old artifact-wide resolution, which the triage ruling retires. It is restated in place asa link resolves artifact-wide while an embed resolves in its OWNER's scope (#27090): both links resolve,core's embed of the top-level flow builds (core owns the top level), andorders' embed is refused.Red on main: 8 failed, 41 passed (collect-docs.ts restored from origin/main, tests at head)
Restore proven: the file's blob equals HEAD's and
git diff HEADis empty.Ablations (scripts/ablation-replace.mjs, restored and verified each time)
return [];: anchor 1 → 0, blobf85d1bed→85f76a70. 4 failed / 45 passed: the "declares", "one-way", "names them" and "flat doc reaches service" cases. Restored, blob == HEAD.index === flatOwner?.index ? [stack, body] : [body]→[body]): 1 failed / 63 passed (collect-docs.package-docs+collect-docs.flat-docs-owner): the link/embed case. Restored, blob == HEAD.Live: HotCRM (four packages, `preserve`), the card's own probe
HotCRM
main353dace, withsrc/service/docs/crm_probe_service.mdandsrc/docs/crm_probe_app.md, each embeddingstate_machinecrm_case/case_status_progression(crm_caseis the service package's;servicedeclaresapp.objectstack.hotcrm, and the app package declares nothing).@objectstack/cli18.2.0: exit 1,Package docs validation failed (2 issues), both docs refused with "does not exist in this package".node packages/cli/bin/run.js build): exit 1, 1 issue, onlydocs/crm_probe_app(the app package does not declare the service package, which is the ruled refusal).Build complete, anddist/objectstack.jsoncarriescrm_probe_serviceon theapp.objectstack.hotcrm.servicebody.Other suites: cli unit project (
--project unit) and clitypecheckare in Verification.Acceptance notes
objectConflict: 'merge', or an input that keeps its own collections) the top level is the flattened union, so the owner's docs still resolve artifact-wide there. That follows the order's ruling that stack-level docs are judged against the stack's own definitions. A non-owner package in the same artifact gets its own scope.examples/app-multi-packageships no docs).test/normalized-call-sites.test.tsgets atop-levelrow for collect-docs'stack.booksread (inlintDocNavTargets, untouched here). The read was onmainalready, and the census never saw it: itscodeOnlymasker loses its place in a template literal nested inside another one (the did-you-mean suffix of each embed refusal), and onmainit blanked collect-docs'stack.objects/stack.flows/stack.permissions/stack.booksreads, all four. This head's literals shifted the parity and exposedstack.books. The masker defect is reported to the seat, not fixed here.Skills-docs: follow-up owed).Verification
Every reading below is at head
8149b3d2, after the last commit.pnpm --filter @objectstack/cli exec vitest run --project unit --maxWorkers=2. Lock VERDICT command-exit 0, Test Files 344/344, Tests 4987/4987. The integration project is left to CI (no spawn entry or integration-tier file is touched).pnpm --filter @objectstack/cli run typecheck(tsc --noEmit && pnpm check:test-typecheck, which covers the test files). VERDICT command-exit 0.pnpm exec eslint --no-inline-configon the three touched TS files): exit 0.node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstackgives 61 commands. Each was run with its exit code captured before any pipe, and all 61 exited 0.--ran: "61 derived famil(ies) accounted for — 61 run, 0 NOT-MEASURED". This was after a fullturbo run build(VERDICT 0), socheck:dual-build-cjs-loads,check:dts-closureandcheck:i18n-coveragemeasured, and thecheck-plugin-teardown-shape --self-testpositive control was fetched.(narrowing)arm):pnpm --filter @objectstack/dogfood testunder the lock. VERDICT command-exit 0, Test Files 348 passed / 3 skipped (351), Tests 2804 passed / 20 skipped (2824), no failures.os buildofexamples/app-multi-packageat this head: exit 0, "0 collected" docs (it ships none, so nothing moves there). HotCRM is in Tests.pnpm lint, Test Core shards, Type Check lanes and the familiesdispatch-gateslists outside its derived total.Human Minimum
packages/specholds no runtime logic. (packages/specuntouched)pnpm lintpasses. (eslint on the touched files: exit 0; the repo-wide run is CI's)main, one pull request.packages/spectouched: n/a.content/docs/references/,packages/*/CHANGELOG.mdorcontent/docs/releases/.Generated by Claude Code