16 KiB
Dead Code And Obsolete Functionality Audit
Reviewed: 2026-11-30
Baseline: bd8e8a0627e7dfe0425e380212e82f00c79aa1d2
Scope And Method
The review examined repository-owned functions, helpers, constants, structs, interfaces, configuration/defaulting paths, conditional branches, and retained compatibility behavior. It followed supported command entry points and checked tests, registrations, interface calls, reflection, build constraints, and documented retention purposes before classifying candidates.
Codebase-memory-mcp supplied discovery, source snippets, and caller searches. Its same-named Go method and constant-reference indexing is incomplete; graph degree alone was not used to establish deadness. Source searches and the following tools supplied independent evidence:
deadcodefromgolang.org/x/tools v0.52.0, built with Go 1.27.4, analyzed./cmd/narratiofor Linux amd64, Linux arm64, and macOS arm64. Each produced the same 88 unreachable-function candidates, including legitimate test fakes and library/test entry points.deadcode -test ./...on Linux amd64 reduced that list to 12 functions: six in production files and six in test files. DD-01 records those confirmed orphaned functions. Results were filtered to Narratio's module.- Staticcheck 2026.2.2 (
honnef.co/go/tools v0.8.2) with-checks=U1000reported the same ten unused unexported helpers on Linux amd64 and macOS arm64. The additional exported wrapper and its helper were found bydeadcode.-checks=U1000,SA4*,SA9*also reported DD-06's unused assignment. - A temporary standard-library
go/astscan counted references to declarations inconfig/defaults.goacross all repository Go source undercmd/andinternal/, including tests and platform files. Six constants occurred only at their declarations; source searches confirmed the DD-02 candidates.
Analyzer binaries, their build module, and the small AST diagnostic were kept outside the repository. Project dependencies were unchanged. Cross-target analysis is source/type-analysis evidence, not native macOS or arm64 execution. Analyzer diagnostics were reviewed as candidates rather than automatic deletion instructions.
go test -count=1 ./... and go vet ./... passed with Go 1.27.4 on Linux.
go test -count=1 ./internal/doccheck passed after writing this report.
Staticcheck's nonzero exit reflects the findings above. No production code,
tests, or functionality were changed, and no live providers or object storage
were used.
Current Architecture
Narratio is a fixed-stage orchestrator:
prepare → transcribe → merge → polish → normalize → trim → render → extract → analyze → publish → notify → cleanup.
The application owns command composition, invocation/session lifecycle,
planning, and restore. Stages own execution and semantic resume decisions;
adapters own external interactions. Manifests and typed speaker/artifact
collections provide durable progress. Artifact services provide identities,
evidence, canonical paths, and committed remote-state resolution. ConfigKit owns
configuration resolution, with Narratio's domain derivation after handoff.
The main supported paths are connected. The findings are focused remnants and redundant machinery rather than an abandoned pipeline subsystem.
DD-01 — P3: Completely orphaned helper functions remain in production and tests
Status: Open
Code And Evidence
The following production functions remain unreachable even when all test executables are included:
| File | Functions | Evidence |
|---|---|---|
| Notarius subprocess adapter | resolveRegularFile (line 244), requireRegularFileTree (line 273) |
U1000 and reachability analysis agree. The first calls the second, but neither has an external caller. Current bundle and lane validation use other paths. |
| Cleanup target validation | validateCleanRoot (line 69) |
U1000 and reachability analysis agree; supported cleaning uses validateScopedTarget. |
| Configuration validation helpers | validatePathWithinRoot (line 41) |
U1000 and reachability analysis agree; current product-destination validation is implemented elsewhere. |
| Effective pipeline helpers | NormalizedConfigurationPath (line 32), normalizedProvenancePath (line 65) |
The exported wrapper has no callers, including tests; its private path helper is used only by that wrapper. deadcode -test reports both. |
Six test helpers also have no callers; both analyzers report them:
- Notarius adapter tests:
cloneMap(line 557). - Application command tests:
writeManifestPathForExecute(line 509). - Configuration command tests:
writeInspectionOverlays(line 48). - Path test helpers:
mustPreviousArtifactPathForCampaign(line 9). - Extraction tests:
stringPointerForExtractTest(line 957). - Preparation tests:
assertManifestInputsSorted(line 766).
Source inspection found no registration, reflective lookup, build-tag consumer, or documented future/compatibility purpose for these helpers. In particular, the Notarius pair is a disconnected helper chain, not a live security check that merely lacks a direct call edge in the graph. The functions are in internal packages rather than a supported external Go library API.
Removal Approach And Cautions
Remove the orphaned declarations and any newly unused imports. Delete a helper file if it becomes empty. Keep live Notarius directory/file checks, current cleanup confinement, and current product-destination validation intact. Removing the unused sorting assertion does not imply removing the active preparation ordering assertions.
No replacement abstraction is needed. Re-run the analyzers and focused package tests after removal; do not replace these declarations with forwarding shims.
DD-02 — P3: Unused constants and retired workspace paths advertise obsolete concepts
Status: Open
Code And Evidence
Six constants in config/defaults.go have no Go identifier references beyond their declarations, including tests and alternate-platform files:
DefaultScriptoriumArtifactOutputRoot;PathTranscriptBase,PathTranscriptPolished, andPathTranscriptFinal;S3ManifestFileandS3RunIDFile.
Their exported names do not establish use. The active transcript vocabulary is
in artifactmodel; remote publication selects immutable commit declarations
through the current pointer. No supported source or documentation consumer of
these particular aliases/constants was found. Removing an unused name does not
remove the corresponding live transcript path or manifest/run identity.
Separately, artifacts/paths.go declares
SessionPaths.ReportsDir and ConfigDir (lines 25–26) and assigns
<session>/reports and <session>/config in buildSessionPathsFromRoot
(lines 239–240). Neither field is read elsewhere. Their only path constants,
PathReportsDirSegment and PathConfigDirSegment, feed those unused assignments.
LocalStore.ensureLayout does not create these directories.
The operator layout places actual
attempt diagnostics under runs/ and exposes latest logs/debug links. Prepared
configuration belongs in inputs/; the retained top-level path fields describe
an earlier organization without providing a live layout capability.
Removal Approach And Cautions
Remove the six disconnected constants, the two unused SessionPaths fields,
their assignments, and their two now-unnecessary directory constants. Keep the
canonical artifact-model vocabulary and current remote commit/key helpers.
This is code-model cleanup. It should not delete existing session directories, alter physical layout, migrate sessions, or add a default artifact output path. In particular, reconnecting an unused constant by inventing a new fallback would change behavior instead of removing dead code.
DD-03 — P3: Extraction still carries descriptor fields that the current model discarded
Status: Open
Code And Evidence
stage/extract.go, fingerprintOutput
(lines 261–268), retains MediaType, SchemaID, SchemaVersion, and
ModuleKey. All four have json:"-" tags. extractionFingerprint constructs
only key, lane ID, and filename; nothing writes or reads the four excluded
fields. They cannot affect the fingerprint's serialized payload.
artifacts/extraction_evidence.go
also retains ExtractionEvidenceOutput.Contract. Its sole production
construction supplies path, checksum, and size but never a contract. The nil
field is passed by HydrateExtractionArtifacts to
markAvailableFromExtractManifest in
catalog.go, where it is cloned back
to nil. There is no non-nil producer along this path.
The current configured extraction definition contains only lane, pipeline, and
filename. TestNotariusNativeControlsAndOutputs
expressly rejects the retired media_type output descriptor. Extraction
execution and resume validate the configured JSON products and provenance
without resurrecting those old descriptor fields.
Removal Approach And Cautions
Remove the four JSON-excluded fingerprint fields. Remove the always-nil
extraction evidence field and its extraction-only parameter/copy plumbing.
Keep shared CatalogEntry.Contract, manifest contract metadata, and the
analyze-generated contract path: they have live consumers and different roles.
The existing fingerprint JSON and digest can remain unchanged because the discarded fields are already excluded. This does not require a fingerprint or manifest schema migration, stricter lane validation, or reintroduction of retired configuration options. Retain current extraction/resume and dependent input-identity coverage.
DD-04 — P3: Manual cleaning retains a file-target mode unavailable through its CLI
Status: Open
Code And Evidence
app/clean_command.go,
cleanSelectedSession, passes directory=true for both supported target
choices: one entire session or the whole session-work tree for --all.
Its appendTarget closure forwards that boolean to cleanScopedTarget and
then to validateScopedTarget.
Only cleanup target unit tests
request the false/file branch through
validateScopedFile. The sibling
validateScopedDir wrapper is likewise test-only, while production bypasses
both wrappers. This preserves an artificial two-mode validation API for a
directory-only command.
The documented cleanup contract provides whole
local-session deletion and a separate publication-gated run-history stage.
Neither accepts individual file targets. No future file-clean command or
compatibility caller is documented. DD-01 separately covers the fully unused
validateCleanRoot helper in the same area.
Removal Or Consolidation Approach
Make the manual-clean validation path explicitly directory-oriented. Eliminate
the forwarded directory boolean, the false-only branch, and validateScopedFile.
Use one live directory validation entry point from commands and tests rather
than preserving test-only wrappers around the implementation.
Retain directory/root/traversal/symlink checks, missing-target behavior, dry-run behavior, and the selected command's deletion scope. Consolidate the unit tests onto that live contract, removing file-only cases. General file operations used elsewhere remain available. This cleanup does not resolve or replace CN-01's separate session-locking remediation.
DD-05 — P3: A superseded publish-default mutation helper survives only in a no-op test call
Status: Open
Code And Evidence
config/validate_publish.go,
applyMissingPublishDestinations (line 36), directly writes destinations into
its input configuration. Its only caller is
TestProductDestinationsPreserveExplicitRemotePaths in
product_destinations_test.go.
That fixture already supplies a destination, so deriveMissingPublishDestinations
returns no entries and the call performs no mutation.
The production path in
pipeline_configkit.go,
resolvePipelineConfig (lines 191–199), uses the shared derivation directly
and records actual defaults through native configkit.Normalize. Reachability
analysis therefore reports the old writer as absent from the production
command graph while retaining it when tests are roots.
Removal Or Consolidation Approach
Remove the unused writer. Keep deriveMissingPublishDestinations and the
native ConfigKit resolution path. Preserve explicit-destination testing through
the production loader/domain boundary; the current validator assertion can
also remain without the irrelevant helper call.
The configuration ownership decision already assigns resolution to ConfigKit's supported hooks. No new configuration semantics or stricter destination policy is needed, and this finding does not claim the obsolete writer currently mutates an authoritative runtime result.
DD-06 — P3: Input hashing stores a normalized path that is never consumed
Status: Open
stage/analyze_input_identity.go,
hashAnalyzeInputFile (line 262), assigns the normalized result back to
relative, then uses only err and opens the previously resolved target.
Staticcheck reports this assignment as SA4006. The original filepath.Rel
result is used as the normalization input; only the normalized return value
is discarded by all later code.
Use a blank identifier for that unused return value, or an equivalently clear error-only validation form. Keep the normalization call and its error check: they enforce the existing relative-path confinement rule. Removing the entire call to silence a dead-value diagnostic would remove live validation. This is a small mechanical cleanup, not a new path-resolution abstraction or a change to accepted input paths.
Deliberately Retained Behavior And Limits
- The fixed registry and stage interfaces make stage methods reachable without
direct concrete calls. ConfigKit callbacks such as
pipelineConfigDefaultsand validation hooks are explicitly registered function values. Thedeadcode -whyliveresult also retained the defaults callback, but its conservative reflection path is a static approximation rather than a runtime trace; the native definition's callback registration supplies the direct source evidence. - Fakes, test entry points, and loader conveniences with actual test consumers
are not dead merely because the CLI does not call them. The documented
package-internal compatibility form of
config.Loadis not proposed for removal. Future-facing aliases were not classified solely from production reachability. - No-op notification is an explicit supported mode. The documented one-time regeneration of aggregate-only transcription state also has a live recovery purpose. Neither is an obsolete feature to delete in this audit.
- Build-tagged locking and process-tree code was evaluated in the supported target configurations. Lack of an edge in one platform's graph does not establish deadness. No blanket deletion of alternate/unsupported-platform implementations is recommended; unsupported platforms were not build gates.
- Native YAML/JSON bindings, embedded schemas, and reflective semantic-type validation were considered. A missing direct field read is insufficient for bound configuration options. No operator-facing configuration option is recommended for removal merely because it is optional or indirectly consumed.
The recommended changes remove disconnected symbols, inert data, and superseded internal variants. They preserve the current supported workflow, selected compatibility behavior, and deliberate test seams.