All checks were successful
ci/woodpecker/push/verify Pipeline was successful
335 lines
18 KiB
Markdown
335 lines
18 KiB
Markdown
# Test Coverage And Effectiveness Audit
|
||
|
||
Reviewed: 2026-11-30
|
||
|
||
Baseline: `8f7d2ab1811314f0ae0af9feb4bdc67d2b27ff5a`
|
||
|
||
## Scope, Policy, And Evidence
|
||
|
||
This audit evaluated both missing behavioral protection and candidates for
|
||
removal or simplification against the [testing policy](../../policy/testing.md).
|
||
The review covered CLI classification, configuration, stage transitions,
|
||
speaker/artifact checkpoints, adapters, publication/restore, concurrency,
|
||
destructive operations, and shared file/manifest helpers. Existing contract and
|
||
implementation documents supplied the requirements; coverage percentages did
|
||
not create additional requirements.
|
||
|
||
The knowledge graph located tests and collaborators. Source inspection
|
||
supplemented its incomplete indexing of same-named receiver methods. The review
|
||
examined assertions and fixture behavior as well as executed statements.
|
||
|
||
Verification used Go 1.27.4 on Linux:
|
||
|
||
- `go test -count=1 -covermode=atomic -coverpkg=./... -coverprofile=<temporary-file> ./...`
|
||
passed. `go tool cover -func=<temporary-file>` reported **83.9%** total
|
||
statement coverage. Cross-package instrumentation includes coverage supplied
|
||
by consumers, rather than treating each package's own tests as its only
|
||
protection.
|
||
- `go test -race -shuffle=on -count=3 ./...` passed.
|
||
- `go test -count=1 ./internal/doccheck` passed after writing the report.
|
||
- Two temporary S3 adapter mutations were evaluated with Go's `-overlay`
|
||
option. Replacing the upload body with fixed incorrect bytes survived the
|
||
full existing suite. Changing the provider request key failed the existing
|
||
upload test, establishing that the overlay was effective.
|
||
- A temporary metadata struct-field reorder failed the existing JSON test
|
||
while retaining the same JSON object members and values.
|
||
|
||
Coverage profiles, overlay files, and mutated source copies were outside the
|
||
repository. No application code or tests were changed. The mutation checks were
|
||
targeted experiments, not an exhaustive mutation score. No paid services, live
|
||
object storage, or optional external-binary compatibility checks were used.
|
||
|
||
## Architecture And Existing Strengths
|
||
|
||
Narratio is a fixed-stage Go orchestrator. CommandKit owns CLI execution and
|
||
reporting; ConfigKit owns configuration resolution. Narratio derives and
|
||
validates its domain configuration, then runs stages under a session lock.
|
||
Stages use adapter interfaces for WhisperX, Seriatim, Audita, Notarius,
|
||
Scriptorium, and object storage. Shared manifest persistence records stage and
|
||
sub-stage progress. Publication selects an immutable remote snapshot through a
|
||
current pointer; restore verifies that snapshot and installs manifest authority
|
||
last. Cleanup is a separate stage and a separate whole-session command.
|
||
|
||
The suite generally follows the policy's classical style: real local files and
|
||
manifest stores, HTTP test servers, subprocess helper executables, and fakes at
|
||
external boundaries. Particularly useful protection includes:
|
||
|
||
- durable speaker/artifact progress after adapter and checkpoint failures;
|
||
- retry reuse and preservation of unrelated completed work;
|
||
- cancellation propagation, request-body replay, process-tree cleanup, and
|
||
credential redaction across subprocess integrations;
|
||
- bounded-read boundary cases and atomic replacement preserving old content;
|
||
- immutable publication ordering, conditional remote locks, and interrupted
|
||
restore recovery;
|
||
- configuration provenance, secret-safe projections, maintained examples,
|
||
native structured CLI reports, and output-delivery failures.
|
||
|
||
These tests should be retained. The findings below concern specific missing
|
||
conditions or avoidable coupling, not a proposal to replace the suite.
|
||
|
||
## TE-01 — P2: S3 upload tests do not verify the transmitted content
|
||
|
||
Status: Open
|
||
|
||
**Functionality and tests.**
|
||
[S3 backend](../../../internal/adapters/storage/s3_backend.go), `uploadReader`;
|
||
[S3 tests](../../../internal/adapters/storage/s3_backend_test.go),
|
||
`fakeS3API.PutObject` (lines 111–119), `TestS3BackendUploadAndExists`, and
|
||
`TestS3BackendConditionalUploadUsesProviderPrecondition`.
|
||
|
||
**Deficiency.** The fake records `PutObjectInput` and returns an ETag without
|
||
consuming its body. Assertions inspect keys, returned metadata, and
|
||
preconditions, but never compare the supplied stream with the expected bytes.
|
||
Higher-level publication tests use the separate `storage.FakeBackend`, so they
|
||
also bypass this production adapter mapping.
|
||
|
||
**Evidence and unprotected failure.** A temporary overlay changed the production
|
||
request from `Body: source` to a reader containing a fixed incorrect string.
|
||
`go test -count=1 -overlay=<overlay> ./...` still passed. A separate wrong-key
|
||
overlay failed `TestS3BackendUploadAndExists` as expected. Thus the suite can
|
||
accept an adapter that uploads unrelated content despite exercising the upload
|
||
function. This is a test gap; the unmodified adapter currently passes the
|
||
correct source reader.
|
||
|
||
**Improvement.** Have the narrow SDK fake consume and retain request bytes during
|
||
`PutObject`, then compare them with the caller's payload for file-backed and
|
||
reader/conditional uploads. Include propagation of a simulated stream-read
|
||
failure where warranted. A small HTTP test server exercising the real SDK is
|
||
also viable if it adds useful transport confidence. Live S3 is unnecessary.
|
||
Retain the current key and precondition checks; they detected the control
|
||
mutation.
|
||
|
||
## TE-02 — P2: Publication and restore tests do not prove carried-output authority is coherent
|
||
|
||
Status: Open
|
||
|
||
**Functionality and tests.**
|
||
[Publication tests](../../../internal/stage/publish_test.go),
|
||
`TestPublishCarriesLockedRequiredOutputAndCommits` (line 726);
|
||
[restore commit tests](../../../internal/app/restore_commit_test.go),
|
||
`TestCommittedRestoreDownloadsCarriedOutputFromDeclaredRun` (line 129) and
|
||
`seedCommittedRestoreSnapshot` (line 442);
|
||
[restore workflow tests](../../../internal/app/restore_workflow_test.go).
|
||
|
||
**Deficiency.** Publication assertions prove that a lock carries the old object
|
||
declaration and avoids uploading a replacement. Restore assertions prove that
|
||
the exact carried object is downloaded. They do not follow a real publication
|
||
through restoration and resolve the resulting artifact against its restored
|
||
stage/per-artifact evidence. The general restore fixture uses a synthetic
|
||
`fixture` stage rather than authentic producer/checkpoint state. One previous-
|
||
cache workflow repairs manifest evidence after restoration before testing the
|
||
consumer, so that test proves the consumer's behavior after repair.
|
||
|
||
**Unprotected behavior.** Publish A, lock it, generate local B, republish while
|
||
carrying A, and restore into an empty workspace. The restored bytes and
|
||
completion authority must agree. [FC-02](01-correctness.md) establishes that
|
||
current code can return successful restoration with A's bytes and B's evidence;
|
||
the existing green tests do not detect that interaction.
|
||
|
||
**Improvement.** Add one focused cross-package round trip using the real publish,
|
||
remote-state discovery, restore, and artifact resolver with an in-memory object
|
||
store. Inspect restored bytes, checksums/provenance, and appropriate reuse or
|
||
rebuild decisions without repairing the restored manifest in the test. Include
|
||
the distinct built-in and configured-artifact authority paths when fixing
|
||
FC-02. Keep narrow transfer tests for their separate risks; every restore test
|
||
does not need a full pipeline fixture.
|
||
|
||
## TE-03 — P2: Previous-session hydration coverage stops short of dependency closure
|
||
|
||
Status: Open
|
||
|
||
**Functionality and tests.**
|
||
[Effective-set tests](../../../internal/artifacts/effective_set_test.go),
|
||
`TestCollectPreviousArtifactRequirementsUsesExactEffectiveSet`;
|
||
[prepare selection test](../../../internal/stage/prepare_effective_artifacts_test.go),
|
||
`TestCollectPreparePreviousRequirementsUsesExplicitDisabledArtifact`;
|
||
[hydration tests](../../../internal/stage/prepare_previous_test.go);
|
||
[incremental analysis tests](../../../internal/stage/analyze_incremental_execution_test.go),
|
||
`TestAnalyzeRebuildsNestedStalePrerequisitesInDependencyOrder`.
|
||
|
||
**Deficiency.** Requirement-collection tests select a disabled artifact directly.
|
||
Analysis tests independently verify rebuilding disabled prerequisites. Hydration
|
||
tests pass an already constructed requirements list. These fixtures omit the
|
||
combination in which an enabled or explicitly selected child requires a disabled
|
||
prerequisite that itself consumes previous-session input.
|
||
|
||
**Unprotected behavior.** Preparation must hydrate history needed by actual
|
||
prerequisite work while excluding unrelated disabled artifacts. Required
|
||
history must reach the downstream request; optional history must not disappear
|
||
solely because its consumer was scheduled as a prerequisite. The missing
|
||
combination allowed [FC-01](01-correctness.md).
|
||
|
||
**Improvement.** Exercise preparation followed by analysis for a selected child,
|
||
a disabled prerequisite with a previous-session binding, and an unrelated
|
||
disabled artifact. Use real selection/hydration/planning and fake external
|
||
storage/generation. Assert the hydrated source identity and downstream binding,
|
||
as well as exclusion of unrelated work. A small required/optional table can
|
||
protect the different observable failure modes. Do not broaden the meaning of
|
||
explicit publication targets merely to make this test pass.
|
||
|
||
## TE-04 — P2: Whole-session cleanup tests never contend with an active invocation
|
||
|
||
Status: Open
|
||
|
||
**Functionality and tests.**
|
||
[Manual cleanup](../../../internal/app/clean_command.go);
|
||
[cleanup command tests](../../../internal/app/clean_test.go) and
|
||
[selection tests](../../../internal/app/clean_command_test.go);
|
||
[local lock tests](../../../internal/artifacts/local_test.go);
|
||
[restore locking tests](../../../internal/app/restore_recovery_test.go),
|
||
`TestRestoreHoldsTransitionLockBeforePlanning`.
|
||
|
||
**Deficiency.** Manual cleanup tests verify scope, preserved storage, missing
|
||
targets, dry-run behavior, and unsafe destinations with no lock holder. Separate
|
||
tests prove that the lock implementation and restore coordinate with runners.
|
||
No test combines `session clean` or `--all` with an active runner, restore, or
|
||
preflight. Final-stage cleanup tests exercise a different, already locked path.
|
||
|
||
**Unprotected behavior.** Deletion must not dismantle an active session's
|
||
single-writer exclusion or let a second invocation acquire a new lock inode
|
||
while the first still writes. [CN-01](04-concurrency.md) records the current
|
||
production defect. A passing race detector cannot establish this filesystem
|
||
coordination property.
|
||
|
||
**Improvement.** Use real temporary workspaces and OS locks, with channels
|
||
holding an invocation at a known active point. Exercise session-scoped and
|
||
whole-workspace deletion and a second contender. Assert no deletion during
|
||
active ownership and no overlapping writers. Encode wait-versus-busy behavior
|
||
after that remediation decision is selected; the test should not invent it.
|
||
Include whole-workspace admission behavior in the `--all` case rather than
|
||
assuming a single existing session lock covers new invocations.
|
||
|
||
## TE-05 — P2: Subprocess lifecycle tests do not exercise a delayed reap after escalation
|
||
|
||
Status: Open
|
||
|
||
**Functionality and tests.**
|
||
[Owned execution](../../../internal/adapters/subprocess/execution.go),
|
||
`terminateAndReap` (lines 73–92);
|
||
[execution unit test](../../../internal/adapters/subprocess/execution_test.go),
|
||
`TestTerminateAndReapPreservesWaitAndCleanupErrors`;
|
||
[process-tree tests](../../../internal/adapters/subprocess/process_tree_supported_test.go).
|
||
|
||
**Deficiency.** The unit test preloads the wait channel, so it always takes the
|
||
early completion path. Real-process cancellation, timeout, capture-limit, and
|
||
descendant-disposal tests cover useful ordinary behavior, but none withholds
|
||
wait completion beyond escalation. Coverage reports `terminateAndReap` at
|
||
45.5%; its post-grace escalation and final forceful-wait outcomes are unexecuted
|
||
in this run.
|
||
|
||
**Unprotected behavior.** A delayed waiter or stream copier must retain ownership
|
||
until the relevant cleanup boundary is safe. Otherwise caller cleanup can race
|
||
with still-running work. [CN-03](04-concurrency.md) identifies that exceptional
|
||
path in the production implementation. Ordinary process tests and a successful
|
||
race run do not exercise it.
|
||
|
||
**Improvement.** When addressing CN-03, use a controlled process-tree/waiter
|
||
boundary that completes only after escalation and observes when output
|
||
resources are released. Assert the ownership/join relationship and preservation
|
||
of wait/cleanup causes. Reuse the existing real-process tests for normal OS
|
||
behavior. Avoid requiring an actual unkillable process, freezing private delay
|
||
constants, or adding a new absolute kernel-I/O completion guarantee.
|
||
|
||
## TE-06 — P3: CLI classification tests omit real resolved-domain rejections
|
||
|
||
Status: Open
|
||
|
||
**Functionality and tests.**
|
||
[Outcome tests](../../../internal/app/commands_boundary_test.go),
|
||
`TestOperationOutcomePreservesCausesAndOperationalPrecedence`;
|
||
[catalog command tests](../../../internal/app/config_artifacts_test.go),
|
||
`TestNativeCatalogValidationErrorsAreUsage`;
|
||
[configuration validation tests](../../../internal/config/storage_publish_test.go).
|
||
|
||
**Deficiency.** Tests cover native loader errors, explicit request markers,
|
||
artifact-catalog markers, and joined operational causes. Configuration tests
|
||
check that conflicting storage selections fail, but do not carry that actual
|
||
failure through a command and assert its exit classification. Destination
|
||
validation likewise lacks that CLI assertion.
|
||
|
||
**Unprotected behavior.** Identified domain configuration mistakes should produce
|
||
status `2` under the [CLI contract](../../cli.md#cancellation-and-exit-status).
|
||
[EH-01](06-error-handling.md) reproduced status `1` for both a storage/audio
|
||
conflict and a product-path collision while the current suite passed.
|
||
|
||
**Improvement.** Add a small real-command table covering those two rejections,
|
||
their valid counterparts, and operational precedence where causes are joined.
|
||
Assert status and cause/classification rather than complete error prose. Keep
|
||
missing/unreadable sources and environmental failures operational; do not
|
||
reclassify every configuration-package error as invalid input.
|
||
|
||
## TE-07 — P3: Some assertions freeze incidental serialization or validation order
|
||
|
||
Status: Open
|
||
|
||
**Relevant tests.**
|
||
|
||
- [Metadata serialization](../../../internal/artifactmodel/metadata_test.go),
|
||
`TestArtifactMetadataJSON` (lines 32–34), compares the entire JSON byte string,
|
||
including object-member order.
|
||
- [Native campaign validation](../../../internal/config/native_results_test.go),
|
||
`TestNativeCampaignResultValidatesConfigurationWithoutReadingResources`
|
||
(lines 106–114), supplies a campaign missing multiple required application
|
||
fields and requires the first diagnostic to identify `speakers_file`.
|
||
|
||
**Deficiency and evidence.** A temporary overlay swapping only the declaration
|
||
order of `ContractMetadata.SchemaID` and `MediaType` failed the metadata test.
|
||
The JSON object still had identical members and values. The asserted byte order
|
||
is not the data-shape contract. Likewise, reordering otherwise valid campaign
|
||
checks would fail the diagnostic assertion even though the same invalid input
|
||
is rejected. These assertions make correct internal changes unnecessarily
|
||
expensive under the testing policy.
|
||
|
||
**Improvement/removal scope.** Replace the complete byte snapshot with structural
|
||
JSON assertions for the public member names, values, and omission behavior.
|
||
Give the campaign test one intended invalid condition or locate the relevant
|
||
diagnostic without prescribing its position. Retain the meaningful
|
||
serialization, native-error, and path-context checks; the whole tests need not
|
||
be deleted. This recommendation does not apply to deliberately canonical byte
|
||
formats used by fingerprints or remote commit contracts.
|
||
|
||
## TE-08 — P3: Two normalized-transcript tests are exact duplicates
|
||
|
||
Status: Open
|
||
|
||
**Relevant tests.** In
|
||
[analysis tests](../../../internal/stage/analyze_test.go):
|
||
|
||
- `TestAnalyzeSupportsCanonicalNormalizedTranscriptSourceFromManifestOutput`
|
||
(lines 1279–1305);
|
||
- `TestAnalyzeSupportsNormalizedTranscriptSourceFromManifestOutput`
|
||
(lines 1307–1333).
|
||
|
||
**Deficiency.** Their bodies are identical. Both create the same incidental
|
||
`final.json`, declare the same alternate manifest-backed file, bind the same
|
||
`narratio.transcript.final` source, run the same stage, and assert the same
|
||
request path. Their different names do not exercise separate formats or
|
||
contracts. The second execution adds no distinct protection.
|
||
|
||
**Improvement/removal scope.** Remove one copy and retain the manifest-authority
|
||
test. Keep neighboring missing-input and other source-kind cases, which protect
|
||
different behavior. If future cases differ only in source kind, a small table
|
||
can consolidate shared setup while preserving the distinct assertions.
|
||
|
||
## Proportionate Follow-Up
|
||
|
||
TE-01 provides a direct, low-cost opportunity to strengthen an external adapter
|
||
boundary. TE-02 through TE-06 should accompany their associated remediation
|
||
work; the earlier audit records remain the owners of the production defects.
|
||
TE-07 and TE-08 reduce test maintenance without weakening selected contracts.
|
||
|
||
Other earlier findings, including concurrent session initialization, same-size
|
||
S3 object replacement, and oversized download handling, also identify useful
|
||
regression conditions when their implementations are corrected. Their existing
|
||
audit records describe those conditions; this report does not duplicate each
|
||
one as another testing finding.
|
||
|
||
No blanket coverage threshold, exhaustive fault matrix, generic mock framework,
|
||
mandatory live service test, or native macOS CI gate is recommended. Uncovered
|
||
dead helpers and trivial executable wrappers do not automatically warrant new
|
||
tests. Optional external compatibility checks remain explicitly opt-in.
|
||
|
||
The suite has substantial behavioral coverage, but is not fully aligned with
|
||
the policy's sufficiency criteria: consequential cross-package gaps coexist
|
||
with a small amount of redundant and implementation-sensitive protection.
|