Repository navigation
ci(checks): run the Knip production analysis during verification - #89
Open
PerfectPan wants to merge 1 commit into
Open
PerfectPan wants to merge 1 commit into
PerfectPan wants to merge 1 commit into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Run the existing
pnpm knip:productionscript inpnpm verify, right afterpnpm 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 listedknip(README, CONTRIBUTING, AGENTS, technology decisions).Closes #88.
Knip configuration
No pattern changes were needed. The config in
knip.tsalready carries the production marking from #84:project: ["src/**/*.ts!", "scripts/**/*.mjs", "tests/support/**/*.ts"]—src/**/*.ts!is the suffixed (production) pattern, whilescripts/**/*.mjsandtests/support/**/*.tsare unsuffixed and therefore stay out of the production analysis. The inline*.test.tsfiles are excluded from production mode by Knip itself.Deleted files
Every deleted file was reachable only from its own test (verified with
knip --productiononmain):src/integrations/deepseek/provider.ts+provider.test.ts—DeepSeekSearchLiveLayer wrapper; the news flow constructsDeepSeekSearchClientdirectly (src/app/products/news/flow.ts).src/integrations/doubao/provider.ts+provider.test.ts— same shape aroundDoubaoSearchClient.src/integrations/grok/provider.ts— same shape aroundGrokSearchClient;cli.test.tsexercised the client through theSearchProvidersurface via this layer, so the test now builds the identical layer inline (grokSearchLivehelper).src/integrations/github/repository/mapper.ts+mapper.test.ts— production importsrepositoryMetadatafromrepository/dto.js(src/integrations/github/catalog.ts); the mapper was test-only.@internaltagstreatTagHintsAsErrorskeeps this honest: any@internalsymbol that production code still references failsknip --productionwith an "unused tag" hint, so every tag below is on an export that production never imports (tests import it directly, or through the barrel).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…).AcquisitionLive,AppLive,appLiveOptions,GlmSearchLive,NotifierLive,FeedStateFileLive,RunArchiveFilesLive,searchProviderLayer— production assembles these ports insrc/app/layers.ts/src/delivery/index.tswithout the standalone factories.OpenSearchBudget,NewsSearchPage,NewsSearchResult,SearchUsage,AcquisitionOptions,AppLiveOptions,NewsBriefEdition,RivusNewsBriefInput,CandidateCopy,CandidateCopyOptions,RunDelivery,DailyAiDiagnosticSnapshot.src/delivery/index.tskeepsloadFeedStateuntagged whilesaveFeedState/FeedStateFileLivemove to a/** @internal */clause); clauses whose every item is test-only were tagged whole (src/delivery/index.tsrun-archive clause,src/acquisition/domain/source/index.ts).Validation
mainat9cdde62,pnpm knip:productionexited 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, andpnpm lintpassed.pnpm verifypassed: 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 onmain), 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", andgh repo-checks pr-bodypassed.