Skip to content

chore(tooling): make the dead-code job blocking (#1356) - #1371

Merged
devsuitup merged 3 commits into
mainfrom
chore/1356-deadcode-blocking
Nov 29, 2026
Merged

devsuitup merged 3 commits into
mainfrom
chore/1356-deadcode-blocking

Conversation

@devsuitup

@devsuitup devsuitup commented Nov 29, 2026 •

Copy link
Copy Markdown
Owner

Summary

Last part of #1356. After #1369 removed the surplus exports, the 45 exports knip still reported are false positives. This change silences them in knip.json and makes the deadcode job blocking: continue-on-error is gone from the step, and the job sets none, so a new unused file, export or dependency now fails the workflow. The job still runs once, on Node 22 / ubuntu-latest, with npm ci --ignore-scripts and the locked knip (6.45.1).

Whether deadcode is a required status check is a repository ruleset setting that only the maintainer can change. This PR does not change it.

Allow-list mapping

scripts/knip-preprocessor.js is the preprocessor of knip.json (knip 6.45.1, run-cli.js: the preprocessor receives the report, and the exit code is computed from the counters it returns). It drops exactly the 45 (file, export) pairs of the part-2 KEEP rows, one ALLOWED_UNUSED_EXPORTS entry each with a reason, and decrements counters.exports and counters.total. Any other unused export, in the same file or not, still fails knip. A listed pair knip no longer reports throws and fails the run, so stale entries get removed. No ignoreIssues remains. It is wired through the config key, so task deadcode and the CI step pick it up unchanged; a --preprocessor flag would replace it, and the test refuses one.

Reasons: namespace = CommonJS namespace access in app code, test-namespace = namespace access or destructuring in tests, fixture-spread = spread re-export in test/fixtures/trigger-watcher.cjs, source-loaded = module loaded as source by its test, self-read = module reads module.exports.name itself.

File Exports (reason)
archived-projects.js undoArchiveProjectFolders, filterArchivedProjects, retireArchivedEntries, relatedEntries (namespace)
jsonl-scan.js MAX_LINE_BYTES (self-read)
project-remap.js rewriteJsonlAtomic (source-loaded)
session-transitions.js detectPendingBackgroundContinuations, snapshotContinuationsBeforeSpawn, refreshDescriptorSessions, holdContinuationExit, currentSessionId, detectSessionTransitions, resolvePendingLaunches, sweepPendingLaunches, drainMetadataWrites, hasPendingLaunches (namespace); snapshotContinuations (test-namespace)
worktree-delete.js parseWorktreeList, runningSessions, removeWorktree, streamGit (namespace)
src/main/changes/git-changes-file.js resolveRepoDirs (namespace)
src/main/projects/project-delete-writer.js buildFinalizationUnits, buildDeletionUnits (test-namespace)
src/main/remote/remote-ssh-binary.js createBinaryResolver (test-namespace)
src/main/schedules/schedule-background.js launchBackgroundSchedule, backgroundRefusal (namespace)
src/main/schedules/schedule-delete-file.js deleteScheduleFile (source-loaded)
src/main/schedules/schedule-ipc.js ensureScheduleCreatorCommand, reportRunExit, init (namespace); SHIPPED_CREATOR_TEMPLATE_SHA256 (test-namespace)
src/main/schedules/schedule-run-results.js writeScheduleRunResult (test-namespace)
src/main/session-index/read-counters.js readBodyFile (test-namespace)
src/main/triggers/trigger-name.js requestedNameFields, hasLoneSurrogate, recoveredNaming, markerNaming (namespace)
src/main/triggers/trigger-watcher.js waitForCliIdleAfter, submitWithVerify, isCompactCommand, waitForBusyFall, SUBMITTED_RANK, weakestSubmitted (fixture-spread); deliverSingle (test-namespace)

Measured locally with npx --yes knip@6.45.1 --exclude binaries: exit 0 with the preprocessor. An unused export appended to jsonl-scan.js, one of the listed files, is reported (jsonl-scan.js: knipProbe) and knip exits 1 (reverted). A fake stale entry makes knip fail with jsonl-scan.js#goneExport named (reverted).

Docs

  • docs/development.md: the CI paragraph and "Dead-code report" now say the job fails on any finding. They name the false-positive patterns and describe the preprocessor allow-list. They say how to handle a new false positive: add one (file, export, reason) entry and give in the PR the line that reads the export, never a file-wide ignoreIssues, a glob or a global switch. They also note that task deadcode -- --preprocessor … replaces the allow-list for that run.
  • .ai/contexts/build-release.md: the deadcode paragraph describes a blocking job with no continue-on-error, the per-pair preprocessor, what the two tests check, and that required-check status is a ruleset setting.
  • Taskfile.yaml: the deadcode description no longer says "report only".

Tests

  • test/knip-preprocessor.test.js (new, 8 tests): every entry is one posix file, one identifier, a known reason, no duplicate. The listed pairs are dropped and an unlisted export in the same file is kept, with counters.exports and total matching. A listed symbol in another file is kept. Other issue types are untouched. A listed pair knip no longer reports rejects, naming the pair. A run that does not report exports is passed through. Backslash keys match. Red first against an identity stub: 6 of 8 failed on assertions (:46, :55, :63, :72, :77, :95). Green: 8/8.
  • test/deadcode-report.test.js: neither the job nor any step sets continue-on-error. shell: bash is kept so tee does not hide knip's exit. There is no global switch and no ignoreIssues, ignore is still only public/**, and preprocessor is ./scripts/knip-preprocessor.js. A new test checks that neither the task nor the CI step passes --preprocessor, --no-exit-code, --max-issues, --include or --exclude. Red on base 944791a at :59 (continue-on-error true). Red against the previous head's knip.json at :74 (ignoreIssues present). Green: 6/6.
  • test/build-workflow.test.js 17/17, test/check-docs.test.js 99/99, module-layout 7/7, eslint-main-scope 3/3, packaged-script-paths 1/1, check-fast 17/17 (Node 22).
  • eslint on the changed JS, node scripts/check-docs.js --validate, node scripts/check-doc-refs.js (0 failures), git diff --check and SKIP_TESTS=1 task check:fast all pass.
  • Without --exclude binaries, the local run also reports knip as an unlisted binary in Taskfile.yaml and test.yml. That comes from the local environment: the shared node_modules has no knip installed. CI installs it, and the main CI report did not show these findings.

Not verified

  • The knip run under CI on this head must report 0 issues. Locally the only remaining findings are the two unlisted-binary ones explained above; CI is the proof.
  • Required-check status of deadcode in the repository ruleset is unchanged; making it required is the maintainer's call.

no-changelog: tooling only, nothing users see.

The surplus exports are gone; what knip still reported were exports read
through CommonJS namespace access, a spread re-export in a test fixture, a
module loaded as source by its test, or module.exports read back by the
module itself. Silence those per file and for unused exports only, and drop
continue-on-error so a new finding fails the workflow.
@devsuitup devsuitup added the no-changelog The PR changes nothing a user sees; the CHANGELOG.md check is waived label Nov 29, 2026
A file-wide ignoreIssues entry also hid any new unused export in the same
file. A knip preprocessor now drops exactly the listed (file, export) pairs,
each with its reason, and lowers the counters knip derives its exit code
from; a listed pair knip no longer reports fails the run so stale entries
get removed.
@devsuitup
devsuitup merged commit 5d50e76 into main Nov 29, 2026
15 checks passed
@devsuitup
devsuitup deleted the chore/1356-deadcode-blocking branch November 29, 2026 05:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-changelog The PR changes nothing a user sees; the CHANGELOG.md check is waived

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant