14 KiB
Dead Code And Obsolete Functionality Audit
Baseline And Method
Reviewed revision 17a73ca762d0ad3cae36bb314d2a753bd626f62b on 2026-11-24.
This pass changes only this report. No production code, tests, dependencies, or
configuration were changed or removed.
The review followed executable/composition-root reachability, registered module and validator construction, typed interface dispatch, configuration selection, native producer/cache paths, and retained compatibility behavior. The architecture policy, implemented package map, current documentation, tests, and accepted decisions supplied context for distinguishing obsolete code from optional or intentionally retained behavior.
Code-graph discovery collected all 4,216 indexed function/method records and
triaged zero-inbound candidates. Repository-wide reference searches and source
inspection then checked actual uses, including function values and generic
instantiations that the graph did not connect. An additional temporary Go
go/parser/go/ast inventory counted identifiers by package directory, including
test files, and identified private function/type/variable/constant declarations
with only their declaration occurrence. It scanned Go files across build
constraints, excluding .git, vendor material, and test fixtures under
testdata. The analysis program and its output remained outside the repository.
This is a conservative source/reachability audit, not whole-program SSA analysis. Name counts can miss unused declarations when unrelated identifiers share a name; zero graph callers are particularly unreliable for callbacks and methods. Candidates were not reported solely on either heuristic. Exported symbols, reflection/serialization hooks, registration paths, tests, build constraints, and documented consumer purposes were considered before recommending removal.
No deadcode, staticcheck, or golangci-lint executable was found on PATH.
Available standard Go tooling was used; no analysis dependency was installed.
Current Architecture And Overall Assessment
The fixed typed workflow remains:
input -> chunk -> ordered steps [per-chunk extract -> merge -> normalize] -> output
The CLI composes native libraries, registrars, configuration, physical state, publication, and reporting. The framework owns preparation, complete assessment, native producer coordination, ready-job execution, generated handoffs, and accepted-result reuse. Domain families own transformations, identity, validators, codecs, references, and prompts. Embedded assets remain content-only.
The large superseded subsystems described by historical ADRs are not still running alongside their replacements. Current production paths use native kit loading/execution/presentation and the unified accepted-result cache rather than a second configuration parser, private retry engine, checkpoint resume workflow, or source-only plan cache. The review did not substantiate an entire production package or supported feature that should be removed.
Two focused cleanup findings remain. Their impact is maintenance clarity rather than a measured performance improvement: the uncalled functions and unused constants already perform no work during a run.
DEAD-001 — Three Private Helpers Have No References
Priority: Low. These are confirmed unused declarations, not merely unexecuted branches in the coverage profile.
| Declaration | Location | Evidence and current replacement |
|---|---|---|
cloneStringMap |
core/config/config.go:99 | Its name occurs only at its declaration in this package, including tests. Runtime configuration now copies pipeline profiles, reference-source maps, and option maps through other helpers; this string-map copier is disconnected. The spell catalog has a separate live helper with the same name and is not included in this finding. |
laneReferencesReuseEligible |
pipeline/handoff.go:50 | Its name occurs only at its declaration repository-wide. Current extraction, merge, normalization, and initial lane accounting call referenceTargetReuseEligible for the relevant operation, not this aggregate conjunction. |
sortValidatorSpecs |
pipeline/validator_registry.go:342 | Its name occurs only at its declaration repository-wide. RegisteredSpecs traverses already sorted RegisteredKeys, so listing does not call or need this extra sorting helper. |
These are unexported package functions. They are not interface methods, registered
callbacks, generic instantiation targets, or serialization hooks. Searches found
no go:linkname use or documented retention requirement for them. The package-local
identifier inventory independently confirmed their declaration-only status.
Potential removal: Delete the three functions and remove an import only if it
then becomes unused. In particular, do not blindly remove sort from the validator
registry: other live sorting there must remain. Keep referenceTargetReuseEligible
and its operation-specific callers; wiring the dead aggregate back in could change
dependency/reuse granularity rather than simply clean up dead code.
No replacement abstraction or new test is needed for declaration-only deletion. Run focused configuration/pipeline tests, retaining existing sorted registry listing, fallback lineage, and cache-reuse coverage. This work can be combined with the earlier configuration-copy consolidation, but does not depend on it.
DEAD-002 — Obsolete Private Policy Labels Remain Disconnected
Priority: Medium for clarity; no current runtime defect is claimed.
Relevant declarations: The source inventory found 48 private constants with no identifier use beyond their declarations:
- 44 constants named
policyin deterministic D&D validator packages. - Three
correctionPolicyconstants in the NPC/item/location registry identity validators. normalizerPolicyin the scene-description normalizer.
The complete validator inventory below identifies the affected
internal/modules/dnd/validate/<family>/<check>/validator.go files:
| Family | Checks containing the unused policy constant |
|---|---|
combatturns |
invariants, shape, source_refs, source_relatedness |
enemyevents |
engagements, invariants, shape, source_refs, source_relatedness |
itemoccurrences |
invariants, registry, shape, source_refs, source_relatedness |
itemregistry |
identity, shape, source_refs, source_relatedness |
locationoccurrences |
invariants, registry, shape, source_refs, source_relatedness |
locationregistry |
identity, shape, source_refs, source_relatedness |
npcoccurrences |
invariants, registry, shape, source_refs, source_relatedness |
npcregistry |
identity, shape, source_refs, source_relatedness |
scenedescriptions |
invariants, shape, source_refs, source_relatedness |
spells |
catalog, shape, source_refs, source_relatedness |
Examples include combat shape, item identity and its correction label, location identity, NPC identity, and scene normalization.
Evidence and obsolescence: These constants are not returned by current specs, included in results, used in execution decisions, or consulted by the cache. Validator registration still uses the live key, execution class, builder, and option validator; deleting the private labels does not unregister a validator. The old policy-fingerprint responsibility is superseded by ADR-0023. Current cache construction and state documentation use the native initial message-content key without policy/version dimensions.
Keeping these unused version strings suggests that bumping them changes execution, validation, or reuse. It does not. There is no current documentation describing a retention purpose for these particular private labels.
Potential removal: Delete the 48 private constants. Retain validator keys,
reason codes, corrective guidance, enums, prompt IDs, schema versions, and actual
domain identity policy constants. In particular,
items/identity.Policy
is included in the hashed identity bytes by DeriveID; removing or changing it
would change durable IDs. The unused validator alias to that constant is not the
same thing as the live identity policy itself.
Do not restore fingerprint interfaces or add policy labels to cache keys merely to give these constants a use. That would reverse an accepted architecture decision. Existing validator/normalizer and asset tests are appropriate validation for the deletion; new tests asserting the absence or count of these labels would be change detectors, not useful behavioral protection.
Related exported surface, not part of the confirmed private deletion: Six
normalizers (spells, combatturns, enemyevents, itemoccurrences,
npcoccurrences, locationoccurrences) expose NormalizationPolicy aliases with
no repository references beyond their declarations. Their private
normalizationPolicy strings feed only those aliases. This suggests additional
obsolete metadata surface, but exported declaration-only status is not by itself
proof that an intended integration has no purpose. Review any intended internal
consumer contract before removing those pairs; the confirmed 48-constant cleanup
can proceed independently. Do not include identity-package aliases or live ID
derivation constants in a broad name-based deletion.
Candidates Investigated And Retained
- Registration callbacks and generic functions: Option validators,
parseRequiredRunValue,parseConfigurationOverride,checkPipelineRunInput,typedCandidateAssessor, andexactTypedValuehave real function-value or generic call sites despite missing incoming graph edges. They are not dead. - Once-initialized schema compilation:
loadAndCompileSchemainchunkmapandevidencecontextis passed as a function value tosync.Once.Do. Removing it on zero direct-call evidence would break codec/schema behavior. - Interface and serialization methods: Codec methods,
ReferenceSlots, validator methods, errorUnwrap, andMarshalJSONare used through typed registrations, interfaces, standard serialization, or error inspection. No finding follows from a missing named direct call. - Explicitly retained compatibility: The
rosterreference fallback to thepartyprompt input remains implemented and covered by compatibility tests. It is not obsolete merely because the identifier is described as legacy. Conversely, tests proving rejection of retired controls or ignoring old cache records do not imply that a legacy loader/cache implementation remains live. - Optional modules and paths: Generic no-op/append modules, explicit accept/reject validators, semantic scene validation, debug capture, cache modes, auxiliary artifacts, and operation-time references are supported extension or configured paths. Default-example selection and low coverage do not determine their liveness.
- Exported convenience APIs:
ValidID, typed convenience constructors, registry views, andSynchronizedDebugRecorderwere not recommended for removal solely for lacking production call sites. The synchronization implementation itself is live inRunner.Run; its exported wrapper describes use with shared injected clients/recorders. Narrow API redundancy is not sufficient proof of obsolescence without checking intended consumers. - Earlier duplication findings: Repeated copying, reconciliation lifecycle, and duplicate grouping are active code, not dead implementations. The equivalence and boundary reports own their consolidation recommendations; they are not counted again here.
No additional obsolete configuration option, entire unused package, abandoned compatibility engine, or unconditional unreachable production branch was confirmed in the inspected paths. Defensive error handling was not treated as dead merely because the available tests did not execute it. These are bounded conclusions, not a claim that every possible unused symbol has been proven absent.
Validation And Limits
Both commands completed successfully with cached dependencies and no live services:
GOWORK=off GOTOOLCHAIN=go1.27.0 GOPROXY=off go vet -mod=readonly ./...
GOWORK=off GOTOOLCHAIN=go1.27.0 GOPROXY=off go test -mod=readonly -count=1 \
./internal/core/config ./internal/framework/pipeline \
./internal/modules/dnd/normalize/... ./internal/modules/dnd/validate/... \
./internal/modules ./assets
Vet success does not prove absence of unused private declarations. The temporary AST inventory is a triage aid rather than an installed static analyzer or a new repository maintenance tool. References were checked in actual source and tests before classifying the confirmed findings. No reachability experiment deleted code or altered a condition, and no API credentials or production inputs were used. No speedup, binary-size reduction, or exhaustive cross-platform dead-code result is claimed.
Report links and the staged documentation diff are checked before committing.