autophagy: dead-code trim 2026-08-14 - #769
Conversation
`fs` and `path` are imported in test/plugins/context-graph-activate.test.js and never referenced anywhere in the file. Import-only change, no test behavior touched. Co-Authored-By: Claude <noreply@anthropic.com>
Review record: PR #769 @
|
Autophagy code-cleanup sweep over
origin/master(8c08185). Proposal only: a human disposes.Scope of the sweep: every
.jsundersrc/,hypaware-core/(plugin workspaces + smoke flows + smoke lib),bin/,scripts/, andtest/, plus every.d.tsand every non-JS asset in those trees. Checks run: whole-tree module-orphan scan, exported-symbol reachability scan, module-local declaration scan, static-import usage scan, JSDoc@importusage scan, unreachable-statement heuristic, and a commented-out-code grep.Trim 1: unused
fsandpathimportstest/plugins/context-graph-activate.test.js:4and:5Neither name is referenced anywhere in the file. The test builds a fake activation
ctxfrom object literals and asserts on whatactivate()registered; it never touches the filesystem.Evidence (run from the repo root):
That is the whole result: two hits, both the imports. No other use in the file, and imports are file-local so no other file can be affected.
Confirmed mechanically over the whole tree by the import-usage scan (parses each static import clause, strips it from the source, and greps the remainder for each bound name). The only two hits in the entire repo were these two lines.
What I deliberately did NOT trim
1.
loadPickerDescriptorsinsrc/core/cli/walkthrough.js:2023- provably unreferenced, but@ref-annotated.This is the one genuinely dead export the sweep found. Its name appears exactly once in the whole repository, on its own definition line:
It is a one-line wrapper over
loadPickerCatalog().descriptors, andloadPickerCatalog(defined 10 lines below it) is what every caller now uses. Its JSDoc still claims "the picker prompt options andcomposePickerConfig's fold both read from it", which is no longer true.I left it because its JSDoc carries
@ref LLP 0130#picker-block, and a live@refis a signal the construct realizes a documented decision rather than that it is scrap. Removing it means deciding whether LLP 0130's picker-block section still wants this entry point named, which is a design call, not a mechanical one. Flagging it for a human: if LLP 0130 does not require this specific export, it is a clean delete, and the stale JSDoc claim should go with it.2. Exported constants and helpers that are used only inside their own module.
The exported-symbol scan surfaced ~70 exports with no importer anywhere:
buildUnit/unitPathFor/SystemdUnitError(src/core/daemon/linux.js),buildPlist/plistPathFor/realLaunchctl(src/core/daemon/macos.js),planDaemonInstall,daemonLogDir,planClientAssets,detectShadowedPlugins,normalizeAttributes,nsToHrTime,urlToPath,ATTACH_WAIT_DEFAULT_MS,BATCH_BYTE_LIMIT,OAUTH_*,SESSION_CONTEXT_*,PROSPECT_*,mapFinishReason,resolvePollIntervalMs, and the rest.Every single one is called or read from inside its defining file. None is dead code; at most the
exportkeyword is broader than today's usage. Narrowing an export is a visible API change (and these are seams a test or a future consumer may want), so it is out of scope for a mechanical trim.3. Unreferenced
interface/typedeclarations in.d.tsfiles.Eleven exported type names appear exactly once in the tree (their own declaration):
LocalOnlyListFile,FolderAskFile,ClientSyncListFile(src/core/usage-policy/types.d.ts),ConfigMergeResult(src/core/config/types.d.ts),ObservabilityHandle(src/core/observability/types.d.ts),ParsedNeighbors(context-graph),CreateEmbedder(embedder-openai),ShardBuildReport(vector-search), andIngestSignal/IdentityResponse/IdentityBootstrapRequest(central).Left alone:
tsconfig.build.jsonemitssrc/into a publishedtypes/tree, so these are package type surface a downstream consumer can import even with no in-repo reference. Worth a human look as a separate question, not a mechanical trim.4.
firstPartyPluginMetadatainsrc/core/config/validate.js:61.Marked
@deprecated, but its own doc says it is "retained only for tests and public-API consumers that have not migrated to the catalog path yet", and it does have in-repo references. Deliberate retention, not scrap.5. Zero orphan modules.
No
.jsfile undersrc/,hypaware-core/plugins-workspace/,bin/, orscripts/is unreachable. The orphan scan's only hits were smoke flows underhypaware-core/smoke/flows/and files undertest/- both discovered by directory walk / by name rather than by import, so those are expected false positives, not dead files. No unused JSDoc@importtype names, no unreachable statements (the two heuristic hits insrc/core/cache/partition.jsandsrc/core/cache/spool.jsare hoisted helper declarations after areturn, which are reachable), and no commented-out code blocks anywhere.Checks
Baseline
origin/master(8c08185) was already green in this worktree, and stays green with the change:npm test: 4029 pass, 0 fail, 1 skipped (identical before and after)npm run typecheck: clean before and after