Skip to content

feat(spec): type-check packages/spec/src TSDoc examples as a third surface - #11433

Merged
os-steve merged 2 commits into
mainfrom
claude/issue-10924-spec-tsdoc-example-surface
Aug 23, 2026
Merged

os-steve merged 2 commits into
mainfrom
claude/issue-10924-spec-tsdoc-example-surface

Conversation

@os-steve

@os-steve os-steve commented Aug 23, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #10924

check:skill-examples gains a third surface: packages/spec/src/** TSDoc code blocks.
This is the ADR-0033 authoring channel — a schema's @example is what an AI author
copies, and it sits inches from the tombstone written for that same reader — and until
now nothing compiled it. check:doc-formula-expressions walks the same blocks but judges
formula expressions with @objectstack/formula, never TypeScript.

A new SURFACES entry, not a second extractor, as the card and triage required: the
marker/tsc pipeline was already surface-parameterised, commentPrefixed: true already
strips the JSDoc gutter, and SourceRoot.ext was already kept wide for this. Zero new
extraction code.

Why opt-in marking, measured

Of the 146 fenced ts blocks in packages/spec/src, 128 carry no import of their own —
fragments by construction. Of the 18 self-contained ones, both traps in the script's own
header fired on the first run:

  • Trap 1 (syntactic diagnostics suppress the semantic pass). Three blocks are
    ellipsis-placeholder prose — defineStack({ ... }), SystemObjectName.USER, { ... } —
    whose TS1109 errors stopped tsc before it type-checked anything. The first run
    reported 15 "clean" blocks that had simply never been checked. Excluding those three and
    re-running turned six of the remaining fifteen red on real semantics.
  • Trap 2 (bare names / unresolvable imports). @oclif/core, a relative
    ./realtime-shared.zod, and undefined names (data, engine, SomeSchema) — all
    fragments, all correctly left unmarked.

A blanket sweep would have misfired on every one of them. The :93 fragment in
skill.zod.ts flagged in the parent card (a case 'in': excerpt of the cloud consumer's
switch) is in the 128 — it carries no import and stays unmarked, as required.

Marked-block census — 6 marked, 140 skipped

Marked (compiles green)
ai/skill.zod.ts:249 SkillSchema @example
ai/skill.zod.ts:444 defineSkill @example
shared/expression.zod.ts:149 tagged-template helpers (cel/F/P)
studio/object-designer.zod.ts:40 @example
studio/plugin.zod.ts:37 @example
system/metadata-form-registry.ts:58 @example

shared/expression.zod.ts:149 is a docblock fence not tagged @example — declared
deliberately: it is the same channel (a docblock example a reader copies), it is
self-contained, and it compiles. Everything else is unmarked: 128 no-import fragments,
3 ellipsis fragments, 5 unresolvable fragments, and 4 blocks that are real rot, filed
as #11436 rather than folded, per the triage clause.

Two things the surface needed

1. Surfaces sharing a resolution dir must not share a build dir. Both spec surfaces
resolve against packages/spec, and writeBuildDir() wipes its target on entry — so the
second surface would delete the first's extracted blocks. Sequential execution hides that
today; --keep would already retain only the last dir, and a reordered loop would make a
surface type-check another's blocks. Added Surface.buildDirName +
findDuplicateBuildDir(), asserted on every run and pinned in both directions in the
self-test (a guard that can only ever return null is indistinguishable from a correct
config).

2. The marker leaked into generated reference pages. The marker sits above the
fence, so it is a prose line, and renderFileDescription emits prose verbatim — landing
os:check in content/docs/references/studio/object-designer.mdx and .../plugin.mdx,
the two spec modules whose marked examples live in the module block rather than on a
declaration. MDX has no HTML comments (fumadocs-mdx fails the build outright), so this
would have both published an internal annotation to a customer-facing page and broken the
docs build. The MDX wrapper spelling cannot be used in a .ts docblock — it ends in the
two characters that terminate a block comment — so the fix is to strip the marker during
generation, at prose level only: the same text inside a fence is an author
illustrating the convention, and is content. Pinned both ways in
file-description.test.ts. After the strip the generated tree is byte-identical to
main — this PR touches no file under content/docs/, and check:generated reports
all 14 artifacts up to date.

Second commit: adding a third surface made its per-surface zero-block guard fire on the
dist-freshness-adoption sandbox's stubbed packages/spec/src, ahead of the freshness
refusal those cases probe — the same interaction #10969 hit and solved with
seedClientSdkSurface(). Seeded into the file srcMtime already governs, so no second
ungoverned mtime knob; the surface-count assertion moves 2 → 3.

Reverse verification — predicted RED, observed RED

Reintroducing triggerPhrases (a retiredKey() in that same file) into a marked block:

✗ [spec source TSDoc (@objectstack/spec)] examples do not compile:
  packages/spec/src/ai/skill.zod.ts:255:3
      error TS2322: Type 'string[]' is not assignable to type 'undefined'.

Gate exit 1, and :255 is exactly the injected line — the block-line → source-line
remapping is correct. Both legs ran under a restore trap and proved themselves on disk
rather than trusting an editor's exit code: mutation leg INJECTED_TEXT_COUNT=1 + present
in 2 built .d.ts files; restore leg count 0, --absent over 209 built files, gate back
to exit 0. Both legs rebuilt packages/spec — editing src/ makes dist stale, and
the gate's freshness guard would otherwise refuse with a message that is neither a pass nor
a real red.

This confirms the sibling card's finding that compile-only is sufficient for this class:
a retired key surfaces as undefined in z.input, so passing it is a type error, no
runner involved.

Verification (all at final commit e9c40a11fc, tree clean vs HEAD)

  • check:skill-examples — exit 0, 253 prose examples type-check across 3 surface(s)
    (skills+docs 228 · spec source 6 · client SDK 19)
  • check:generated — exit 0, All 14 generated artifacts are up to date
  • pnpm --filter @objectstack/spec test — exit 0, 419 passed (419) / 11148 passed (11148)
  • pnpm --filter @objectstack/spec exec tsc --noEmit — exit 0
  • 26 gate families derived from the actual diff via dispatch-gates.mjs --repo (no paths
    passed) — 26 pass / 0 fail, re-run at the final head
  • check:type-check-coverage — exit 0

Changeset

patch for @objectstack/spec, measured not assumed: the marker lands in the published
dist/skill.zod-*.d.ts (2 occurrences) and spec's files also publishes
src/**/*.zod.ts, so it is consumer-visible text. Same precedent as the sibling card, and
the same inert-comment trade-off already accepted for the 228 markers shipping in
skills/. Not skip-changeset — this PR publishes bytes.

Out of scope, filed not folded

#11355 interaction — not touched

The open finding on the extraction loop's fence-awareness is not required by this
surface and is not fixed here. The new root needs no nested-fence extraction, and the
marked-block census is closed, so no block reaches tsc through that path. Noted rather
than folded, per dispatch.


Generated by Claude Code

…rface

`check:skill-examples` gains a `packages/spec/src/**` surface — the ADR-0033
authoring channel, where a schema's `@example` sits inches from the tombstone
written for the same reader and, until now, was compiled by nothing.

A new SURFACES entry, not a second extractor: the marker/tsc pipeline was
already surface-parameterised and `commentPrefixed` already strips the JSDoc
gutter. Compilation stays opt-in; six self-contained blocks are marked.

Two things the surface needed:

- Surfaces sharing a resolution dir must not share a throwaway build dir —
  it is wiped when written, so the second would delete the first's blocks.
  `buildDirName` + `findDuplicateBuildDir()`, pinned both directions.
- The marker is a prose line, so `renderFileDescription` emitted it into
  generated MDX. MDX has no HTML comments, so a marker on a module-level
  docblock both published an internal annotation to a reference page and
  broke the docs build. Stripped at prose level during generation.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T9cDbY2NBiVJWYx3BpWfH2
@github-actions

github-actions Bot commented Aug 23, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

Nothing in this diff resolved to a documentable surface (no symbol, route or SDK anchor derived from 1 changed package(s)), so this run has no opinion about the docs.

What this run could not see
  • 5 changed file(s) yielded no anchor (packages/spec/src/ai/skill.zod.ts, packages/spec/src/shared/expression.zod.ts, packages/spec/src/studio/object-designer.zod.ts, …) — pages documenting those are invisible to this run

Coarse fallback — 126 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json a41069ba379cd9fdc48d1a23fd4c366d0ebe068e → packageMentionDocs.

@github-actions github-actions Bot added documentation Improvements or additions to documentation protocol:ai protocol:system tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Aug 23, 2026
…s sandbox

Adding a third check:skill-examples surface made its per-surface zero-block
guard fire on the sandbox's stubbed `packages/spec/src`, ahead of the freshness
refusal these cases exist to probe — the same interaction #10969 hit and solved
with `seedClientSdkSurface()`.

Seeded into the file `srcMtime` already governs, so the surface adds no second
ungoverned mtime knob, and the surface count assertion moves 2 -> 3.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T9cDbY2NBiVJWYx3BpWfH2
@os-steve os-steve added needs:contract-review Marker only — PR awaits its at-tier Contract review PASS; no check reads it, the record decides and removed needs:contract-review Marker only — PR awaits its at-tier Contract review PASS; no check reads it, the record decides labels Aug 23, 2026 — with Claude
@os-steve
os-steve marked this pull request as ready for review August 23, 2026 19:44
@os-steve
os-steve added this pull request to the merge queue Aug 23, 2026
Merged via the queue into main with commit 14cfc00 Aug 23, 2026
41 checks passed
@os-steve
os-steve deleted the claude/issue-10924-spec-tsdoc-example-surface branch August 23, 2026 20:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation protocol:ai protocol:system size/m tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants