Skip to content

ci(checks): run the Knip production analysis during verification - #89

Open
PerfectPan wants to merge 1 commit into
mainfrom
ci/knip-production-verify
Open

PerfectPan wants to merge 1 commit into
mainfrom
ci/knip-production-verify

Conversation

@PerfectPan

Copy link
Copy Markdown
Owner

Summary

Run the existing pnpm knip:production script in pnpm verify, right after pnpm knip, so the Verify job also fails on files and exports that only tests reach. Updates the two tests that pin the verify string and documents the gate where #84 listed knip (README, CONTRIBUTING, AGENTS, technology decisions).

Closes #88.

Knip configuration

No pattern changes were needed. The config in knip.ts already carries the production marking from #84: project: ["src/**/*.ts!", "scripts/**/*.mjs", "tests/support/**/*.ts"] — src/**/*.ts! is the suffixed (production) pattern, while scripts/**/*.mjs and tests/support/**/*.ts are unsuffixed and therefore stay out of the production analysis. The inline *.test.ts files are excluded from production mode by Knip itself.

Deleted files

Every deleted file was reachable only from its own test (verified with knip --production on main):

  • src/integrations/deepseek/provider.ts + provider.test.ts — DeepSeekSearchLive Layer wrapper; the news flow constructs DeepSeekSearchClient directly (src/app/products/news/flow.ts).
  • src/integrations/doubao/provider.ts + provider.test.ts — same shape around DoubaoSearchClient.
  • src/integrations/grok/provider.ts — same shape around GrokSearchClient; cli.test.ts exercised the client through the SearchProvider surface via this layer, so the test now builds the identical layer inline (grokSearchLive helper).
  • src/integrations/github/repository/mapper.ts + mapper.test.ts — production imports repositoryMetadata from repository/dto.js (src/integrations/github/catalog.ts); the mapper was test-only.

@internal tags

treatTagHintsAsErrors keeps this honest: any @internal symbol that production code still references fails knip --production with an "unused tag" hint, so every tag below is on an export that production never imports (tests import it directly, or through the barrel).

  • Domain/application/integration helpers that tests exercise directly: validators and DTO guards (validateDeepSeekInput, validateDoubaoInput, normalizeEvent, hasGitHubHomeFeedMarkup…), pure policy functions (retryDelayMs, retryEffect, searchWithRetry, fallbackTriggerCodes, buildNewsStories, selectNewsStories, presentationDepthForCandidate, rssPublicationType, parseFeed…), mappers and trace helpers (credibilityForAuthority, credibilityForAuthLevel, projectActivity, acquireActivityCard, acquireHomeCard, normalizeHomeCardSnapshot, acquireWebPage…), CLI/config parse helpers (packageAsset, optionalString, requireBoundedInteger, requireBoundedNumber, requireStringList, parseNewsTopics, parseResearchSuggestions, writeGithubHomeHelp…), browser helpers (readConduitSnapshots, readRenderedSnapshots), audit helpers (errorAudit, withPageAudit, clonePageAudit, isNativeCall, isNativeReceipt), and small utilities (isOk, isPrivateIpv4, formatStarCount, documentMethods, Document, GrokProcess…).
  • Layer factories kept for tests only: AcquisitionLive, AppLive, appLiveOptions, GlmSearchLive, NotifierLive, FeedStateFileLive, RunArchiveFilesLive, searchProviderLayer — production assembles these ports in src/app/layers.ts/src/delivery/index.ts without the standalone factories.
  • Types used only by tests: OpenSearchBudget, NewsSearchPage, NewsSearchResult, SearchUsage, AcquisitionOptions, AppLiveOptions, NewsBriefEdition, RivusNewsBriefInput, CandidateCopy, CandidateCopyOptions, RunDelivery, DailyAiDiagnosticSnapshot.
  • Barrel clauses that mix production-used and test-only re-exports were split so only the test-only ones carry the tag (e.g. src/delivery/index.ts keeps loadFeedState untagged while saveFeedState/FeedStateFileLive move to a /** @internal */ clause); clauses whose every item is test-only were tagged whole (src/delivery/index.ts run-archive clause, src/acquisition/domain/source/index.ts).

Validation

  • On main at 9cdde62, pnpm knip:production exited 1 with 4 unused files, 93 unused exports, and 16 unused exported types; on this branch it exits 0.
  • pnpm knip (default mode) still exits 0, including tag-hint checking.
  • pnpm install --frozen-lockfile, pnpm fmt, and pnpm lint passed.
  • pnpm verify passed: layout, format/lint/type checks, duplicate gate, Knip, knip:production, all 845 tests (4 test files were removed with the deleted code, −9 cases vs. the 854 on main), the TypeScript build, and the installed-package check.
  • gh repo-checks repository, gh repo-checks pr-title "ci(checks): run the Knip production analysis during verification", and gh repo-checks pr-body passed.

Wire the existing knip:production script into pnpm verify after pnpm knip,
update the two tests that pin the verify string, and document the gate in
README, CONTRIBUTING, AGENTS and the technology-decisions record.

- Delete the test-only provider layers (deepseek, doubao, grok) and the
  github repository mapper together with their tests; the grok transport
  suite builds its SearchProvider layer inline now.
- Tag exports and types that only tests reach with @internal, which knip
  ignores in production mode; split barrel clauses so production-used
  symbols keep their untagged re-export.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Task]: run knip:production in verify

1 participant