Skip to content

fix(docapi): clean-checkout safe check:public:docapi (no generate first)#3472

Merged
caio-pizzol merged 2 commits into
mainfrom
caio-pizzol/SD-typecheck-docapi-cleancheckout
May 24, 2026
Merged

fix(docapi): clean-checkout safe check:public:docapi (no generate first)#3472
caio-pizzol merged 2 commits into
mainfrom
caio-pizzol/SD-typecheck-docapi-cleancheckout

Conversation

@caio-pizzol
Copy link
Copy Markdown
Contributor

PR 3 of the type-checking organization plan. Makes check:public:docapi (and the umbrella check:public) work on a fresh git clone without first running generate:docapi. The check is now truly non-mutating and clean-checkout safe. Builds on #3471 (now merged).

Why this PR

Before this PR, pnpm check:public:docapi on a fresh checkout failed with:

contract output artifacts check failed
missing generated file: packages/document-api/generated/agent/compatibility-hints.json
missing generated file: packages/document-api/generated/agent/remediation-map.json
missing generated file: packages/document-api/generated/agent/workflow-playbooks.json
missing generated file: packages/document-api/generated/schemas/document-api-contract.json
missing generated file: packages/document-api/generated/schemas/README.md

Those paths are gitignored. The check was asking the developer to first run generate:docapi (which mutates the worktree), then check. That coupling makes a "check" command implicitly require a "generate" workflow — wrong shape.

How

Split checkGeneratedFiles()'s on-disk roots into two categories:

Option Meaning Used for
roots (tracked) Strict: existence, content equality, and no extras on disk apps/docs/document-api/reference/ (committed)
inMemoryRoots (gitignored) Build artifact in memory; on-disk presence not required. If files happen to exist locally, content equality is still checked packages/document-api/generated/schemas/ + generated/agent/

check-contract-outputs.ts now passes the gitignored schema/agent roots as inMemoryRoots and only the tracked reference-docs root as the strict roots.

The artifact BUILDERS still run for both root types — any builder error still propagates. We're just relaxing the "must exist on disk" assertion for paths that are gitignored.

The other three docapi check scripts (check-contract-parity, check-examples, check-overview-alignment) already read only tracked files, so they're clean-checkout safe without changes.

What didn't change

  • generate:docapi remains the explicit mutating command. Use it when you need the artifacts materialized locally (SDK builds, publishing). It's no longer a prerequisite for check:public:docapi.
  • Stale-file detection still works for both root kinds. Tracked stale-file detection is unchanged. For gitignored paths: if the artifacts exist locally (from a previous generate:docapi run), stale content is still caught; missing gitignored artifacts are allowed on a clean checkout.

Verified (worktree had no packages/document-api/generated/ on disk)

  • pnpm check:public:docapi → PASS (was: missing-file failures)
  • pnpm check:public (umbrella) → PASS end-to-end on clean checkout
  • pnpm run check:types → tsc clean
  • Stale committed .mdx (edited a file in apps/docs/.../reference/) → still caught as "stale generated file content"
  • Stale gitignored JSON (wrote bogus JSON to generated/agent/workflow-playbooks.json then ran the check) → still caught as "stale generated file content"
  • node .github/scripts/agent-docs-l1.mjs --target . → root AGENTS.md has 0 broken path refs

Doc updates

  • AGENTS.md: dropped the "Requires generated artifacts to be current; run generate:docapi first" guidance on check:public:docapi. Reworded to avoid the literal gitignored path so the L1 agent-docs scanner stays clean on a fresh checkout.
  • packages/superdoc/scripts/README.md: rewrote the check:public:docapi row and the check-contract-outputs.ts row to describe the new tracked-vs-inMemory split. README keeps the literal path because the L1 scanner only runs against AGENTS.md / CLAUDE.md and the path helps contributors find the directory.

Before this PR, running `check:public:docapi` (or `check:public`) on
a fresh checkout failed with "missing generated file" errors for
artifacts under `packages/document-api/generated/`, which is
gitignored. Contributors had to run `generate:docapi` first to
materialize those files. Making a check command implicitly require
a generate-then-check workflow is the wrong shape: a clean checkout
should be able to validate the public surface without writing files.

Fix: split the on-disk roots into two categories in
checkGeneratedFiles().

- `roots` (tracked): committed reference docs + overview block.
  Existence, content, and "no extras on disk" still enforced.
- `inMemoryRoots` (gitignored): `packages/document-api/generated/`
  subtrees. The artifacts are still BUILT in memory (so any builder
  error still propagates), but their on-disk presence is no longer
  required. If a developer happens to have stale files on disk from
  a previous `generate:docapi` run, the content-equality check
  still surfaces them.

check-contract-outputs.ts passes the gitignored schema/agent roots
as inMemoryRoots and only the tracked reference-docs root as the
strict `roots`. The other three docapi check scripts
(check-contract-parity, check-examples, check-overview-alignment)
already read only tracked files, so they're clean-checkout safe
without changes.

`generate:docapi` remains the explicit way to materialize the
gitignored artifacts locally (needed for SDK builds, publishing,
etc.). It is no longer a prerequisite for any check command.

Verified (worktree had no packages/document-api/generated/ on disk
for the entire run):
- pnpm check:public:docapi -> PASS (was: missing-file failures)
- pnpm check:public -> PASS end-to-end on clean checkout
- pnpm run check:types -> tsc clean
- Stale tracked file (edited an .mdx in apps/docs/...reference/)
  -> still caught as "stale generated file content" (kind: 'content')
- Stale gitignored file (wrote bogus JSON to
  packages/document-api/generated/agent/workflow-playbooks.json)
  -> still caught as "stale generated file content" (kind: 'content')

Updated AGENTS.md and packages/superdoc/scripts/README.md to remove
the "Requires generated artifacts to be current; run generate:docapi
first" guidance and describe the new clean-checkout behavior.
L1 agent-docs scanner does `existsSync` on every backticked
path-looking string in AGENTS.md / CLAUDE.md files and flags any
that don't resolve. The clean-checkout state of this PR (no
`packages/document-api/generated/` on disk) means the literal path
fails that check.

Reword the two lines in AGENTS.md so they describe the artifacts
without naming the exact gitignored path. The README at
`packages/superdoc/scripts/README.md` keeps the literal path
because the scanner only runs against AGENTS.md / CLAUDE.md,
and the path makes the README clearer for contributors hunting
for the directory.

Verified: `node .github/scripts/agent-docs-l1.mjs --target .`
reports 0 broken path refs on root `AGENTS.md` after the fix
(pre-existing findings on other AGENTS.md files are unrelated).
@caio-pizzol caio-pizzol requested a review from a team as a code owner May 23, 2026 22:48
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@caio-pizzol caio-pizzol merged commit a07f693 into main May 24, 2026
74 checks passed
@caio-pizzol caio-pizzol deleted the caio-pizzol/SD-typecheck-docapi-cleancheckout branch May 24, 2026 00:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants