Repository navigation
feat(gate): census the code generators emit from template literals (report-only) - #8138
Conversation
…7864) Code a generator EMITS from a template literal under `packages/*/src/**` is compiled by nothing: `tsc` sees a string, `tsup` copies it through, and every doc gate's scan surface — `check-doc-snippet-types`'s own `listDocuments()` included — stops at `content/docs`, the per-app docs trees and the package READMEs. Two members were already known when the card was filed. Route C: extend this repository's documentation-surface compiler, which already builds a scoped closure and compiles snippets against built `.d.ts`, so it can census code-emitting template literals through the same `compileSnippets()` a documentation block goes through. REPORT-ONLY, behind `--emit-census`, and the census is the deliverable. One known member is an open card this PR may not fix, so no finding here fails a build; the flag keeps the documentation verdict and exit code byte-identical for every existing caller (`--build-filter` output diffed clean against the base commit). The recogniser is the static import heuristic, with the `doc-snippet: emits` marker kept and honoured as its opt-in escape. A marker-only route was disqualified rather than merely judged weaker: the one site the card requires the census to show red sits in a file this PR may not touch, so an opt-in route would have censused one template and zero diagnostics. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FhBNJcLRZLe8M87VcUgpKr
|
Standing down on
Every other check on Generated by Claude Code |
|
Armed — squash auto-merge enabled and the PR is in the merge queue,
On MERGED: content probe on re-fetched Generated by Claude Code |
|
LANDED — merged at 2026-09-06T19:26:49Z as Content probe on re-fetched
#7864 closed by the Generated by Claude Code |
Fixes #7864
Route C, as ruled on the card:
scripts/check-doc-snippet-types.mjs— this repository's documentation-surface compiler, which already builds a scoped closure and compiles snippets against built.d.ts— now censuses the code this repository's generators emit from template literals underpackages/*/src/**. Report-only on first landing, and the census is the deliverable.The recogniser, and its blind side
import … from '…'statement/* doc-snippet: emits tsx */commentpackages/cli/src/utils/app-generator.ts, objectui#7472 — sits in a file this PR may not touch. Under a marker-only route it could not be marked, so the census would report 1 site and 0 diagnostics: a census that cannot see the member it was filed for measures nothing.The marker is honoured, not merely counted: a template it marks joins the census whether or not the heuristic saw it. Counting it without acting on it would be a declaration the runtime does not cash — the shape AGENTS.md commandment #0.1 refuses. It carries the same
doc-snippet:vocabulary as the existing fragment marker; no second spelling was invented.The blind side is printed every run, because a census that cannot see what it excludes is not a census:
exportand are seen by neither route.packages/*/src/**were excluded asTOOLING_FILE(regex imported fromscripts/check-phantom-dependencies.mjs, not copied). Three of them do hold import-bearing templates:packages/cli/src/__tests__/app-generator.test.ts,packages/types/src/__tests__/partial-schema-collapse-pin.test.ts,packages/vscode-extension/src/__tests__/export-to-react-compiles.test.ts.The census
Measured at
1184533dcon a built closure. Verbatim fromnode scripts/check-doc-snippet-types.mjs --emit-census:The number that decides the follow-up card is
2, not16. The headline is dominated by artefacts of the census's own method, and they are separated out on their own line rather than left in the total:sibling./App,./index.css,./theme-provider,./Layout,../app.json,./types. These generators write whole projects; a per-snippet compile structurally cannot resolve a sibling that exists only after the generator has run. Inherited deliberately from the documentation rule "in isolation, as its own module".interpolated${…}hole ('./schemas/__hole__','./__hole__Impl'). There is no specifier for any compiler to resolve — an artefact of the substitution, by construction.codePlus 4 sites refused by the root bound (they emit imports of
react-router-dom,@testing-library/react,vitest,@testing-library/jest-dom/vitest— specifiers that resolve here only through this repository's ownpackage.json, i.e. through nothing the emitted file's reader installs) and 1 parse failure, which is a heuristic misfire:packages/create-plugin/src/templates.ts:286emits a README, and thetsxfence inside it carries an import.The two
codediagnostics, both inpackages/create-plugin/src/templates.ts, both candidates for the PM to card::234TS2307: Cannot find module 'vite-plugin-dts'— the emittedvite.config.tsimports a package no documented package declares.:261TS2769: … 'test' does not exist in type 'UserConfigExport'— the emitted vite config passes atest:block todefineConfigimported from'vite'. That is the real shape of the class this card is about.objectui#7472's site shows up, as the ruling requires:
packages/cli/src/utils/app-generator.tscarries 4 of the 11packages/clisites and 5 of its 10 diagnostics. ⛔ This PR does not address it — that card ispm:on-hold.PR objectui#7863's repair holds:
packages/vscode-extension/src/extension.ts, 1 site, 0 diagnostics.packages/cli/src/app-generator.ts. The file is one directory deeper, atpackages/cli/src/utils/app-generator.ts. Pinned in the test file so nobody re-derives it.The instrument
A separate walk over
packages/*/src/**/*.ts{,x}minusTOOLING_FILE, extracting each recognised template from the AST (never a regex over the text — a backtick in a string or a comment is not a template), then handing each one to the gate's existingcompileSnippets()with the samepaths, the samedeclaredSpecifiersand the same four controls. An emitted snippet is judged exactly the way a documentation block is; that reuse is the whole argument for putting this here rather than in a per-package test.Holes. Each
${…}is substituted by the identifier__hole__, and a body that had any gets one appended line,declare var __hole__: any;. Both halves are stated in the source because the compiled snippet is then not byte-identical to what the generator writes:${vars.pascalName}Plugin) as often as in expression position (const schema = ${schemaJson};) — an expression-shaped placeholder is a syntax error in the first;var, notconst, because a block-scoped binding read above its own line is TS2448 — a diagnostic the instrument would have invented;export const ${vars.pascalName}becomesexport const __hole__). Measured: without that guard the census invented 2 TS2395s ontemplates.ts.What the substitution therefore cannot judge, said out loud in the header: whether the value a hole interpolates type-checks where it lands.
Behind a flag, per the seat's reading.
--emit-census. The documentation verdict and exit code do not move for existing callers, and--build-filter's output was diffed against the base commit's copy of the script and is byte-identical. The census runs after the precondition gate (it needs the same built closure) and returnsEXIT_CODES.verifiedon any finding; it returnscouldNotRunonly when the walk collapsed or a harness control failed — report-only means it declines to fail on its findings, never that it passes without looking.⛔ Burn-down licence — objectui#5174 batch 26 re-baselines from here
This change moves the strictness region objectui#5174's batches pin byte-identical. Allowed for this card; the new baseline, for batch 26's dev:
Fence scanningbanner23933ae25f46b5662ba336f026bca3a0003e0b7979789d48d0291fa5760be7d23c8ed01601184533dc5dfcd1b876c044ef33b6b5fed8a57ec719622ddbb20ce0ab539e5c985a233017UNGATED_DOCSis untouched — no row added, none removed. If the census wants its own ledger, that is the follow-up card's decision, not this PR's.Tests —
scripts/__tests__/check-doc-snippet-emitted-census.test.ts27 tests, all green, covering the three properties the binding constraint turns on:
__tests__/path that is excluded and counted;documentsFailed; on a built tree (locally) the full positive control runs: real[semantic]lines printed, status 0.Plus the hole substitution, the placeholder-collision guard, the diagnostic classifier, the marker vocabulary, the heuristic's bound, and the CI wiring.
Reverse verification. Committed first, then ablated:
const byHeuristic = EMITTED_IMPORT.test(template.text)replaced byfalseon disk (anchor count 1 → 0, mutant count 1, blobe84025fbb…→eecf59d63…). 6 of 27 tests turned red, includingrecognises at least the two members objectui#7864 namesand the spawned exit-code control. Restored withgit checkout HEAD -- …;git diff HEADempty and the disk blob equal to the HEAD blob again.CI
One report-only step in
.github/workflows/doc-snippet-types.yml, placed after the build and before the blocking gate — the number is meant to be re-read on every run, and after the blocking step it would be skipped on exactly the runs where the corpus moved. The matching write-up landed incontent/docs/guide/ci-cd-pipeline.md's Documented Snippet Types section, in the shape of thecheck-doc-expression-carriageentry: what it runs, that it exits 0 regardless of what it finds, and why report-only is a ruling rather than an oversight (objectui#3653 pins that page by command).Gates
All run at
1184533dc, exit codes captured by redirect-then-capture:pnpm check:doc-snippetsEvery covered documentation snippet compiles against the built types.(572 of 572 judged, 0 failed — unchanged)node scripts/check-doc-snippet-types.mjs --emit-censusREPORT-ONLY (exit 0), census as quoted above--build-filtervs. basediffempty against23933ae25's copy of the scriptpnpm exec vitest run scripts/__tests__/check-doc-snippet-emitted-census.test.tspnpm exec vitest run scripts/__tests__/pnpm check:doc-fencespnpm check:doc-typesEvery documented component type is registered.pnpm type-check:scriptspnpm lint:rootpnpm check:control-bytesgrep -naPself-scan of all 4 changed pathspnpm check:entry-guardpnpm check:pre-install-import-graphnode scripts/check-changeset-presence.mjsNo source or published contract of a released package changed in this rangenode scripts/check-governed-queue-guard.mjs --test(4 paths)NOT GOVERNED — 4 path(s) checked against 5 governed surface(s); none matched.pnpm type-check:coveragenode scripts/check-doc-links.mjsLinks are valid across 17 scan roots.No changeset is owed: the diff is the gate, its test, one workflow and one doc page — nothing publishes from a package.
packages/vscode-extensionwas not touched (the marker route was not taken), so the changeset the card warns about does not arise.Live E2E (informational)is red on every branch today for an upstream reason (objectui#7990 / objectstack#16186) — not this PR's.What this PR deliberately does not decide
Whether the corpus gets cleaned or gets a declared ledger, and whether any rule here should ever block. That is what the numbers above are for, on a follow-up card the PM opens. ⛔ objectui#7472 is not addressed here and remains open.
🤖 Generated with Claude Code
https://claude.ai/code/session_01FhBNJcLRZLe8M87VcUgpKr
Generated by Claude Code