Repository navigation
docs(spec): front-door and branded-types examples compile against the real exports map (+os:check markers) - #11531
Conversation
… real exports map (+os:check markers) Fixes #11436 Four self-contained TSDoc @example blocks in packages/spec/src did not compile against the package's own built declarations. index.ts's front-door header taught a root namespace-import style the root has never exported, and two subpath-import styles named the nonexistent `@objectstack/spec/auth` (the real subpath is `@objectstack/spec/identity`). branded-types.zod.ts named ObjectNameSchema/FieldNameSchema from the root; both resolve only from `@objectstack/spec/shared`. Rewrote all four against the current exports map and built declarations, reframing (not dropping) the front door's Style 1 around the defineX factory imports the root genuinely does export, and added the os:check marker to all four so check:skill-examples keeps them honest. Spec-source surface: 6 -> 10 marked blocks. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01T9cDbY2NBiVJWYx3BpWfH2
📓 Docs Drift Check5 anchor(s) derived from 1 changed package(s); no hand-written page names any of them. ✅ What this run could not see
Coarse fallback — 126 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 78886d7a65e91b5ad25e38e700427ae3da793a62 && git checkout 78886d7a65e91b5ad25e38e700427ae3da793a62
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin d10e2146263913d0f81b36607b41d21926249837 41ea937bc7a1ac1d909ba503c47caf9f5cec5be4 && git checkout -B drift-repro d10e2146263913d0f81b36607b41d21926249837 && git merge --no-ff 41ea937bc7a1ac1d909ba503c47caf9f5cec5be4
node scripts/docs-audit/affected-docs.mjs --json d10e2146263913d0f81b36607b41d21926249837 |
Fixes #11436
Status: DRAFT — clause-② path limb (diff lives under
packages/spec/src/**,substantively no accept/reject or export-surface change).
needs:contract-reviewis on the card; this PR stays draft for the PM's review, per the dispatch
contract.
Two defect classes
packages/spec/src/index.ts— the front door's three import-styleblocks. Style 1 taught a root namespace-import style
(
import { Data, UI, System, Auth, AI, API } from '@objectstack/spec') theroot has never exported — the file's own preamble already conceded as much.
Styles 2–3 both named
@objectstack/spec/auth, a subpath theexportsmaphas never declared (the real one is
@objectstack/spec/identity).packages/spec/src/shared/branded-types.zod.ts:14— namedObjectNameSchema/FieldNameSchemafrom the package root. Both symbolsexist, but resolve from
@objectstack/spec/shared, never the root.What each block teaches now
Measured against the package's real
exportsmap (packages/spec/package.json)and its built declarations — no new export, no widened surface, docblocks only:
genuinely does export a curated set of authoring
defineXfactories(
defineStack,defineView,defineApp,defineFlow,defineAgent,defineTool,defineSkill, …) for direct top-level use, even though itexports no type namespaces. The block now imports
defineSkillfrom theroot and calls it with a real, compiling config — teaching the true
root-level surface instead of a fabricated one.
import * as Identity from '@objectstack/spec/identity'replaces the/authimport;Auth.User→Identity.User.import { User } from '@objectstack/spec/identity'replacesimport { User, Session } from '@objectstack/spec/auth'.Sessionis dropped rather than mis-sourced —the bare
Sessiontype is deliberately not declared inidentity(see thecomment at
identity.zod.ts:164); the wire shape lives in@objectstack/spec/apiand pulling in a third subpath for one name did notearn its place in an already-two-subpath example.
Userliterals gained the schema's two required timestamp fields(
createdAt,updatedAt) — present in the type, silently never checkedbefore because the broken import made every downstream usage unreachable to
tsc.branded-types.zod.ts:@objectstack/spec→@objectstack/spec/shared.No other change.
Front-door docs-shape decision
The card flagged this as worth deciding rather than guessing: whether
index.ts's header should keep documenting a namespace-import style at all.Went with the measurement-driven default stated in the dispatch — but chose
"truthfully reframe" over "drop" for Style 1, because the root really does
export something meaningful at that path (the
defineXfactories), anddropping it down to two styles would have made the header thinner without
making it more honest. The header's opening prose was rewritten to state
plainly what the root does and does not export, rather than leaving the old
"this package does NOT export types at the root level" sentence to silently
disagree with a fixed Style 1 block the way it disagreed with the broken one.
Verified at
41ea937bc7(this PR's head commit).Gate count
pnpm --filter @objectstack/spec check:skill-examples— spec-source surface6 → 10 marked blocks (4 new: 3 in
index.ts, 1 inbranded-types.zod.ts),matching the card's acceptance count exactly (the reframed Style 1 counts as
the 4th new block, same as a literal one-for-one repair would have).
Verification
pnpm --filter @objectstack/spec buildpnpm --filter @objectstack/spec check:skill-examples— green,10markedspec-source block(s) (was 6),
257 prose examples type-check across 3 surface(s)overall.os:checkmarker to all four blocksagainst the OLD (broken) text first. Gate went red with exactly the card's
diagnostics — TS2305 on
Data/UI/System/Auth/AI/API, TS2307 on@objectstack/spec/auth(×2), TS2305 onObjectNameSchema/FieldNameSchema.Rewrote to the real exports/declarations in place (still committed as the
repair, no separate revert needed since the final state is the marked+fixed
text) — gate went green.
pnpm --filter @objectstack/spec typecheck— green (tsc --noEmit+check:scripts-typecheck+check:test-typecheck, test-layer debt ledgerunchanged).
pnpm --filter @objectstack/spec test— green:Test Files 420 passed (420),Tests 11204 passed (11204).pnpm --filter @objectstack/spec check:generated— 1 artifact proved stale(
check:docs, because the fixed@exampleinbranded-types.zod.tsfeedsthe generated reference page) →
pnpm --filter @objectstack/spec gen:docs,re-ran clean (14/14). Regen diff audited: exactly the one-line specifier fix
propagated into
content/docs/references/shared/branded-types.mdx, nothingelse moved.
index.ts,branded-types.zod.ts) — clean.node scripts/pm/dispatch-gates.mjs --repo objectstack-ai/objectstackderived27 matched local gate families (+5 changeset-triggered once the changeset was
added) for this diff; all ran green except
node scripts/check-dev-prereqs.mjs,which failed on unrelated packages' missing
dist/(this worktree never ran afull
pnpm build) — an environment precondition, not a regression from thisdiff (spec's own
distis fresh and green everywhere else)..changeset/front-door-examples-compile.md(patch,@objectstack/spec).Generated by Claude Code