Repository navigation
feat(tooling): gate a DECLARED-but-never-imported dependency, and remove the 37 this repository had - #8304
Conversation
`check:phantom-deps` judges imports that are not declared and says so in its own scope note; nothing judged the reverse, so a declaration could outlive its last consumer indefinitely (objectui#8198, split out of objectui#7625). New `scripts/check-unused-dependencies.mjs` (`pnpm check:unused-deps`) asks the reverse question over `dependencies` / `optionalDependencies` of every released package. It is a second script rather than a flag on the first because the two directions need OPPOSITE file populations: phantom-deps must read `src/` only, this one must read the whole package (a dependency consumed by `vite.config.ts`, a stylesheet at-rule or a `bin/` helper is consumed). Every parser helper is imported from phantom-deps so the two cannot disagree about what an import is. Three detection rules, no blanket ignores: module specifiers anywhere in the package; CSS `@import` / `@plugin` / `@config` / `@source` / `@use` targets; and `@types/X` follows X, with `@types/node` a named, counted carve-out because its consumer is a global scope rather than a module edge. `peerDependencies` and `devDependencies` are measured and printed but not gated, each for a stated reason. Allowances carry evidence, re-derive it on every run, and go red when they stop being NEEDED as well as when they stop holding. First enforcing run: 41 unused runtime declarations over 20 of 40 released packages. 37 removed here, each verified by a whole-package grep first; 4 allowed, both shapes verified per run. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FhBNJcLRZLe8M87VcUgpKr
…oundary The `react-dom/client` import in this snippet resolved only because `@object-ui/layout` carried a `react-dom` entry in its `dependencies` — an entry no file in that package consumes, removed by the commit before this one. `check:doc-snippet-types`' ROOT BOUND is explicit about the direction to fix this in: "a manifest is a claim about what a package needs, and a doc gate's convenience is not that claim" (maintainer ruling 2026-08-24). No `@object-ui/*` package installs a DOM renderer for its consumer — every one of them asks for `react-dom` as a PEER — so a reader copying this block never had the import backed by anything they install. It was green on this repository's own root `devDependencies`, which is exactly what that bound exists to refuse. The block now exports `App` and stops there; the mounting step is prose, naming `createRoot` and `StrictMode` without importing a package the guide cannot promise the reader has. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FhBNJcLRZLe8M87VcUgpKr
…sed-declared-deps-gate
✅ Console Performance Budget
The eager closure is every chunk the entry reaches through static imports — what the browser fetches and parses before the app renders. The entry chunk on its own is a small fraction of it. 📦 Bundle Size Report
Size Limits
|
|
ACCEPT (#8198 — the reverse-direction gate, and the 37 dead declarations it found) — reviewed on the tree at head Verified from the diff, not the report:
Next: CI convergence → flip ready (MCP channel is rate-limited at 09:20Z; retry at 09:40Z) → post-flip guard → auto-merge SQUASH → queue confirmation → landing probe on re-fetched Generated by Claude Code |
|
Armed: PR #8304 flipped ready at 2026-09-07T09:32:47Z on head Generated by Claude Code |
|
LANDED: merged at 2026-09-07T09:52:33Z as Generated by Claude Code |
Fixes #8198
check:phantom-depsjudges imports that are not declared, and its own scope note names the direction it leaves open. Nothing judged the reverse, so a declaration could outlive its last consumer indefinitely — which is what happened torechartsin@object-ui/componentsafter objectui#7397 deleted its only importer, and what objectui#7625 removed by hand.Notation note: this body spells placeholders as WORDS, never in their real angle-bracket form, because this repository has measured that GitHub's body sanitizer deletes tag-shaped fragments even inside backticks.
What landed
scripts/check-unused-dependencies.mjs—pnpm check:unused-deps, judgingdependenciesandoptionalDependenciesof every released package.scripts/__tests__/check-unused-dependencies.test.ts— 37 cases.package.jsonscripts block, besidecheck:phantom-deps. Merged (not rebased) ontoorigin/mainafter PR feat(tooling): port the comment-mask corpus sweep and measure objectui#7882 residue #8277 landedcheck:comment-mask-corpusinto the same block; both lines are present.@types/…orphaned by them.minorchangeset, because the removals can break a consumer relying on hoisting.Home decision: a new file, not a second direction inside
check-phantom-dependencies.mjsJudged on the four axes; the deciding one was the first.
src/only and must — avite.config.tsimport is not a shipped import. This gate must read the whole package — a dependency consumed only by a build config, only by a stylesheet, or only by abin/helper IS consumed. Measured: the wider scan is what clears 12 of the 41 hits. One scanner cannot serve both scopes without a per-question switch, which is two gates wearing one exit code. The exit codes matter separately: phantom-deps is green with zero findings, this direction had 41 onfc32921aa, so fusing them would have meant holding phantom-deps' verdict hostage to a cleanup or landing this one non-enforcing.discoverPackages,readReleaseGroup,moduleSpecifiers,packageNameOf,isBuiltin,SKIP_DIRS,SOURCE_FILE), pinned by a test, so the two directions cannot come to disagree about what an import is. No machinery is duplicated.The census, on
fc32921aa40 released packages, 361
dependencieskeys, 89 peers, 345 devDependencies.dependenciesoptionalDependenciespeerDependenciesdevDependenciesClass table, after the three detection rules — every hit classified before anything was decided, no class ignored without a reason:
@plugin 'tailwindcss-animate',@import 'tailwindcss').css/.scss/.sass/.less@types/glob, whoseglobis imported)@types/Xfollows X, with npm's@types/scope__namemangling inverted@types/node)process/Buffer/ theNodeJSnamespace, which no import scan can see; a scan that demanded a builtin import would red a package for reading an environment variablesrc/(a build config, abin/helper)@object-ui/cli)verify—objectui devruns the generated app against the CLI's own installobject-ui,tsupnoExternal)verifyzod/@objectstack/spec(prose in comments only)postcss.config/tailwind.configplugin mapThe 37 removals, verified by a whole-package grep each before removal:
dependenciesplugin-designer@dnd-kit/core,@dnd-kit/sortable,@dnd-kit/utilities,@object-ui/fieldsplugin-chatbotreact-markdown,react-syntax-highlighter,remark-gfm(+ the orphaned@types/react-syntax-highlighterfromdevDependencies)plugin-report@object-ui/plugin-grid,clsx,react-i18next,tailwind-mergeplugin-map@objectstack/spec,lucide-react,zodrunnerclass-variance-authority,clsx,tailwind-mergelayoutclsx,tailwind-merge,react-domplugin-dashboardclsx,tailwind-merge,react-domplugin-ai@object-ui/react,clsx,tailwind-mergecorelodash,zodfieldsclsx,tailwind-mergeconsole@object-ui/react-runtime,sucraseauth@object-ui/typesplugin-calendar@object-ui/fieldsplugin-editor,plugin-markdown@object-ui/reactreactreact-hook-formpnpm installafterwards:Packages: -10.layoutandplugin-dashboard'sreact-domis the interesting one — an exact pin independenciesalongside a peer range, i.e. a library hard-depending on the renderer it asks its host to supply. Their siblingsplugin-charts/plugin-form/plugin-listdo not do this. Thereacthalf of the same shape is invisible to this gate (reactIS imported) and is filed as objectui#8303.What is gated, and what is only MEASURED
peerDependenciesis NOT gated. A peer is a constraint on the HOST's graph, not a claim to import the name; 21 of the 22 unconsumed peers arereact-dom, the renderer these component libraries require of whatever mounts them. Gating it would red 21 packages on day one over a convention — a decision for the maintainer, filed as objectui#8300, not a rider here.devDependenciesis NOT gated. They are the field a consumer's install does not fetch, which is the premise phantom-deps' own runtime tier rests on; the 67 remaining are dominated by toolchain named BY STRING in a config rather than imported.Both counts are printed on every run, so the size of both concessions stays visible instead of being absorbed.
The Atoms constraint (AGENTS.md line 61): measured, and NOT given its own assertion
@object-ui/componentsdeclares 48 runtime dependencies today — 6 workspace siblings,@objectstack/spec, 28 Radix primitives, and 13 Shadcn upstream libraries (cmdk,date-fns,embla-carousel-react,input-otp,lucide-react,next-themes,react-day-picker,react-hook-form,react-resizable-panels,sonner,vaul, plus thecn()trio andtailwindcss-animate). Every one has a consumer; the package is green under the generic scan.An explicit allowed-list assertion was weighed on the four axes and not added, and the deciding evidence is the card's own instance:
recharts.rechartswas legitimately on the list the day it was added —chart.tsximported it — and the defect was that the importer went away. What catches that is exactly the generic unused-declaration scan, which is what landed. An allowlist is strictly weaker for the measured instance.Reported, not implemented. If the maintainer wants "heavy" made mechanical, that needs the definition first.
Controls
The card's own control, reproduced on this tree with the gate's scanner:
So the zero is a real zero, and
rechartsis the true negative this gate would have caught.Ablation, on the committed tree, trap-restored and blob-hash proved
Each leg proved its mutation reached disk by an on-disk marker count before and after, and each restore was proved by
git diff HEADbeing empty — never by agit checkoutexit code.Leg 3 is the one that matters most: an allowance that has stopped being NEEDED reds, not just one that has stopped holding. That is what keeps this from becoming a permanent allowlist.
The one thing that went red, and why the fix went where it did
scripts/__tests__/check-doc-snippet-types.test.tsfailed after the removals:That snippet's
react-dom/clientimport resolved only because@object-ui/layoutcarried thereact-domentry this PR removed — the doc gate'spathsmap is built fromdependenciesonly, and its own header says so.The remedy was NOT to put the entry back. That gate's header rules on this exact shape, quoted verbatim:
So the doc was wrong, and had been wrong on an accident: no
@object-ui/*package installs a DOM renderer for its consumer — every one asks for it as a peer — so a reader copying that block never had the import backed by anything they install. The block now exportsAppand stops at the component boundary; the mounting step is prose namingcreateRootandStrictModewithout importing a package the guide cannot promise the reader has. Adjacent context: objectui#8059 is about that same bound's remedy text for peer-declared specifiers.Gates run locally, with exit codes
pnpm check:unused-depspnpm check:phantom-depspnpm exec turbo run build --filter=!@object-ui/sitepnpm exec vitest run scripts/__tests__/pnpm exec vitest runauth core fields layout react runner clipnpm exec vitest runthe nine changed plugins + vscode-extensionpnpm exec vitest run apps/console/pnpm check:doc-snippetsnode scripts/check-doc-links.mjspnpm check:doc-types/pnpm check:doc-fencespnpm check:spec-floorspnpm check:dist-completenesspnpm check:self-import/check:side-effects-arraypnpm check:entry-guardpnpm type-check:scriptspnpm lint:rootno-explicit-any)pnpm check:control-bytesnode scripts/check-changeset-presence.mjscheck-changeset-no-major/-fixed/-overwritenode scripts/check-governed-queue-guard.mjs --test(all 25 paths)node scripts/check-comment-mask-corpus.mjs(after the merge)One gate is NOT green, and it is not this PR's:
node scripts/check-node-esm-load.mjsexits 1 on its provenance leg because turbo's shared cache replayed 5 packages built by a SIBLING WORKTREE in this container (objectui-issue-5174-b36):mobile,permissions,providers,react-runtime,types. None of those five has a dependency removed by this PR. Its load leg graded 29 entries and reported no failure outside its by-design list. CI builds fresh, so it has no shared-cache question.Deviation, declared
check:unused-depshas no step in.github/workflows/ci.ymlbeside its siblingcheck:phantom-deps, because that path was outside this session's declared file surface. It IS enforcing today through its pin test's repository-green case, whichpnpm testruns. The missing step is filed as objectui#8301 with the exact YAML.Findings filed out of scope
react-dompeer no file in them consumes; the convention needs a decision, not a gate.ci.ymlstep.vite.config.tsfiles carry alias and globals rows for packages the plugin never imports.layoutandplugin-dashboardpinreactindependencieswhile also asking for it as a peer.All four are unassigned, labelled
findingonly, deduplicated against the 455 open issues withcheck:phantom-depsas a control term that hit.Session:
https://claude.ai/code/session_01FhBNJcLRZLe8M87VcUgpKr🤖 Generated with Claude Code
https://claude.ai/code/session_01FhBNJcLRZLe8M87VcUgpKr
Generated by Claude Code