On this page
Revision 1 November 5, 2026 code-liveness-policy.md

Code Vitality Policy

Type: Policy. How to classify code during refactoring audit, deletion audit and cleanup pass.

Purpose

An audit helps find code that has lost its role in the working application and determine what can be removed or moved to the roadmap. The evidence comes from verifiable connections to startup, a supported API, configuration, or an adopted project policy. Compilation, exports, and tests alone do not show how code is used.

The sections below describe how to trace those connections and classify findings for a decision. Implementations used only by tests are considered separately; future ideas can remain on the roadmap rather than as placeholders in src.

An ADR explains a decision’s origin. When code is retained for a current requirement without an active consumer, that requirement remains in a current policy or contract.

Production graph and test graph

Production Graph

Production graph starts from runtime entrypoints and project work connections:

  • package.json main, bin, exports and runtime scripts;
  • src/index.ts;
  • bootstrap and command registry;
  • CLI command handlers;
  • application use-cases, pipelines, services and ports, which are actually connected to the runtime flow;
  • infrastructure adapters, transport, persistence and runtime configuration;
  • dynamic runtime bindings, if supported by code or configuration.

Code reachable from the production graph cannot be deleted as dead code.

For a UI project, the framework's routes and loaders, HTML entrypoints, Workers, new URL(..., import.meta.url), CSS/static assets and browser bindings are also taken into account. The supported developer showcase and build graph are considered separately. A file cannot be considered unused just because a regular import is missing.

Test Graph

Test graph starts from *.test.ts and test runner.

Tests confirm that the code has testable behavior. Tests do not prove that the code is used by the application at runtime.

Use by tests alone is considered separately; see Test-only Implementation.

Categories

Category Distinguishing features
Active Runtime Code The code has a confirmed path from the production graph.
Unused File The file has no incoming links.
Placeholder The file contains only a TODO, a comment, or an empty architectural template.
Test-only Implementation The real implementation is used only by tests.
Barrel-only Export The code is exported via index.ts or another barrel, but is not used by production code.
Orphaned Island A group of files uses each other, but the entire group does not have an incoming production reference.
Roadmap Code The code expresses a future intent but has no current consumer.

Active Runtime Code

Other reasons to retain code, such as its role in builds or a supported API, are listed under Keep.

Decision: keep.

Unused File

Signs:

  • no imports;
  • no barrel exports;
  • no test references;
  • no docs references;
  • no package script / entrypoint references;
  • no dynamic string references;
  • file is not a declaration/config/entrypoint file.

Solution: delete candidate if there is no architectural intent or public contract.

Placeholder

Signs:

  • no executable code;
  • no meaningful exports;
  • no production usage;
  • text describes a future idea, not a current implementation.

Solution: move to roadmap or delete candidate.

Test-only Implementation

Signs:

  • is executable code;
  • is tests; The
  • no production imports;
  • no CLI/use-case/bootstrap/runtime usage.

Solution: needs owner decision.

Such code cannot be removed mechanically: first you need to understand whether it is an outdated implementation, a lost runtime flow, or a deliberately saved contract.

Barrel-only Export

Signs:

  • is export * from ... or named re-export;
  • symbols are not imported by active runtime code;
  • tests may or may not exist;
  • package public API not confirmed by package.json.

Solution: needs owner decision.

Barrel export in itself does not prove the viability of the code.

Orphaned Island

Signs:

  • module appears to be in use because another file imports it;
  • this other file is not itself reachable from the production graph;
  • island can have tests and internal utilities;
  • deleting one file requires considering the entire group.

Solution: needs owner decision or a separate small deletion pass after confirmation of the owner.

An internal dependency within an island does not make the island active.

Roadmap Code

Examples include a planned port, strategy, service, adapter or design example that is not used by the running application. An empty interface, stub or TODO-only implementation also has the characteristics of a Placeholder.

Decision: move to roadmap.

Solutions

Decision When it applies
Keep The code is used or needed for builds, types, configuration, a supported API, or a current policy or contract.
Delete Candidate The code is unused and meets all the conditions listed below for consideration for deletion.
Move To Roadmap Record a future capability with no current consumer in documentation, an issue or a plan when its intent is better expressed as a description than a source-code placeholder.
Needs Owner Decision The owner’s decision is needed when the use or purpose of code remains unclear.

Keep

Used if code:

  • reachable from production graph;
  • is needed by assembly, types, declarations or runtime config;
  • is package entrypoint;
  • is supported as public/internal API;
  • has a valid documented contract;
  • is required by a valid policy or contract, even if it temporarily does not have a consumer feature.

Delete Candidate

Used if code:

  • does not have production usage;
  • does not have a public/internal API role;
  • does not need a test harness as a conscious contract;
  • is not declaration/config/entrypoint;
  • does not contain important architectural intent.

Removal is performed only by small batches.

Move To Roadmap

This decision applies to Placeholder and Roadmap Code.

Needs Owner Decision

Cases requiring an owner decision are described under Test-only Implementation, Barrel-only Export and Orphaned Island. Architecturally significant code without a confirmed path from the production graph also needs separate consideration.

Such code must not be deleted during automatic cleanup.

Audit checklist

Before deletion pass you need to check:

  • imports by file name;
  • imports by exported symbols;
  • barrel exports;
  • test references;
  • docs references;
  • package main, bin, exports and scripts;
  • tsconfig include/exclude;
  • CLI command registry;
  • bootstrap wiring;
  • infrastructure bindings;
  • runtime config;
  • dynamic string references;
  • applicable current policies and contracts;
  • related ADR as rationale and history of owner decision;
  • whether the file is part of orphaned island.

Minimum Removal Rule

Deletion is limited to the files listed in advance and follows the change policy.

Prerequisites:

  • do not update dependencies;
  • do not delete owner-decision candidates without confirmation;
  • do not delete infrastructure baseline assigned by current architecture policy or contract; if the replacement passes the ADR admission gate, first accept the new ADR;
  • run build, tests, lint and diff checks;
  • show diff summary.

If there is any doubt about the file, it remains in needs owner decision.