Remove brittle and duplicate test assertions

This commit is contained in:
2026-12-02 21:10:04 +00:00
parent 17f930b8d5
commit d3b4f25f71
5 changed files with 42 additions and 42 deletions

View File

@@ -41,9 +41,9 @@ their scope. Unless assigned otherwise, a finding remains independent audit
remediation. Shared code does not make a refactoring a prerequisite or assign
the whole finding to a roadmap.
Nineteen entries are closed by the safety, transfer, audio discovery, S3
planning, prerequisite-history, publication-import, CLI classification, inspection aggregation, and
associated documentation work; 24 remain open. **Planned** identifies
Twenty-one entries are closed by the safety, transfer, audio discovery, S3
planning, prerequisite-history, publication-import, CLI classification,
inspection aggregation, test maintenance, and associated documentation work; 22 remain open. **Planned** identifies
an agreed remedy awaiting implementation. **Potentially eliminated** requires verification that the offending
lifecycle is removed. **Coordinate** identifies shared changes, not a commitment
that a related feature implements the entire finding. Findings close only after their
@@ -877,7 +877,10 @@ Related: [CAT-19](#cat-19--p3-describe-stable-prepared-products-once-for-materia
### CAT-35 — P3: Remove assertions on incidental serialization and validation order
Status: Open
Status: Closed
**Closure.** Metadata tests compare decoded JSON members and omissions; the native campaign
validation test locates its diagnostic without requiring its position.
Original findings: [TE-07](08-testing.md#te-07--p3-some-assertions-freeze-incidental-serialization-or-validation-order).
@@ -966,7 +969,10 @@ configuration ownership or introduce new destination semantics.
### CAT-41 — P3: Remove the duplicate normalized-transcript test
Status: Open
Status: Closed
**Closure.** The duplicate analysis test was removed; the manifest-authoritative source test
remains.
Original findings: [TE-08](08-testing.md#te-08--p3-two-normalized-transcript-tests-are-exact-duplicates).

View File

@@ -121,7 +121,7 @@ Validation: `go test ./internal/app -run 'Test.*(Inspection|SessionState|Publish
## Stage 2: Remove Incidental And Duplicate Test Constraints
CAT IDs: CAT-35, CAT-41. Status: Pending.
CAT IDs: CAT-35, CAT-41. Status: Complete.
Read [TE-07](audit/08-testing.md#te-07--p3-some-assertions-freeze-incidental-serialization-or-validation-order)
and [TE-08](audit/08-testing.md#te-08--p3-two-normalized-transcript-tests-are-exact-duplicates).

View File

@@ -2,7 +2,7 @@ package artifactmodel
import (
"encoding/json"
"strings"
"reflect"
"testing"
)
@@ -29,16 +29,27 @@ func TestArtifactMetadataJSON(t *testing.T) {
if err != nil {
t.Fatalf("Marshal() complete metadata error = %v", err)
}
wantComplete := `{"contract":{"media_type":"application/json","schema_id":"notarius.dnd.npc_registry","schema_version":"v1","module_key":"dnd/npc-registry"},"external_provenance":{"system":"notarius","run_id":"run-123","pipeline_id":"dnd-session","artifact_id":"npc-registry"}}`
if string(complete) != wantComplete {
t.Fatalf("complete metadata JSON = %s, want %s", complete, wantComplete)
var got map[string]any
if err := json.Unmarshal(complete, &got); err != nil {
t.Fatal(err)
}
want := map[string]any{
"contract": map[string]any{"media_type": "application/json", "schema_id": "notarius.dnd.npc_registry", "schema_version": "v1", "module_key": "dnd/npc-registry"},
"external_provenance": map[string]any{"system": "notarius", "run_id": "run-123", "pipeline_id": "dnd-session", "artifact_id": "npc-registry"},
}
if !reflect.DeepEqual(got, want) {
t.Fatalf("complete metadata = %#v, want %#v", got, want)
}
omitted, err := json.Marshal(envelope{})
if err != nil {
t.Fatalf("Marshal() omitted metadata error = %v", err)
}
if string(omitted) != `{}` {
got = nil
if err := json.Unmarshal(omitted, &got); err != nil {
t.Fatal(err)
}
if len(got) != 0 {
t.Fatalf("omitted metadata JSON = %s, want {}", omitted)
}
@@ -50,7 +61,12 @@ func TestArtifactMetadataJSON(t *testing.T) {
if err != nil {
t.Fatalf("Marshal() contract without module key error = %v", err)
}
if strings.Contains(string(withoutModule), "module_key") {
t.Fatalf("contract JSON unexpectedly contains omitted module_key: %s", withoutModule)
got = nil
if err := json.Unmarshal(withoutModule, &got); err != nil {
t.Fatal(err)
}
want = map[string]any{"contract": map[string]any{"media_type": "application/json", "schema_id": "notarius.dnd.npc_registry", "schema_version": "v1"}}
if !reflect.DeepEqual(got, want) {
t.Fatalf("metadata without module = %#v, want %#v", got, want)
}
}

View File

@@ -110,7 +110,13 @@ narratio:
t.Fatalf("campaign validation lost its native error: %v", err)
}
findings := loadError.Diagnostics()
if len(findings) == 0 || findings[0].Code != configkit.CodeValidateError || findings[0].Path.String() != "/narratio/inputs/speakers_file" {
found := false
for _, finding := range findings {
if finding.Code == configkit.CodeValidateError && finding.Path.String() == "/narratio/inputs/speakers_file" {
found = true
}
}
if !found {
t.Fatalf("campaign validation findings = %+v", findings)
}
}

View File

@@ -1304,34 +1304,6 @@ func TestAnalyzeSupportsCanonicalNormalizedTranscriptSourceFromManifestOutput(t
}
}
func TestAnalyzeSupportsNormalizedTranscriptSourceFromManifestOutput(t *testing.T) {
env, m, fake := setupAnalyzeEnv(t)
paths := sessionPathsForEnv(env, m.SessionID)
fallbackPath := filepath.Join(paths.TranscriptsDir, "final.json")
manifestPath := filepath.Join(paths.ArtifactsDir, "normalized.from-manifest.json")
writeAnalyzeFile(t, fallbackPath, `{"segments":[{"id":999}]}`)
writeAnalyzeFile(t, manifestPath, `{"segments":[{"id":10}]}`)
setCurrentBuiltInEvidence(t, m, "normalize", artifacts.TranscriptOutputKindFinal, artifacts.ArtifactTranscriptFinal, manifestPath)
artifact := env.Config.ArtifactCatalog.Artifacts["session_recap"]
artifact.Inputs["transcript"] = config.ScriptoriumInputConfig{
Source: "narratio.transcript.final",
Required: true,
}
env.Config.ArtifactCatalog.Artifacts["session_recap"] = artifact
_, err := (analyzeStage{}).Run(context.Background(), env, m)
if err != nil {
t.Fatalf("Run() error = %v", err)
}
if len(fake.RunRequests) != 1 {
t.Fatalf("run requests = %d, want 1", len(fake.RunRequests))
}
if fake.RunRequests[0].InputPaths["transcript"] != manifestPath {
t.Fatalf("transcript input = %q, want manifest normalized transcript path", fake.RunRequests[0].InputPaths["transcript"])
}
}
func TestAnalyzeFailsWhenNormalizedTranscriptMissing(t *testing.T) {
env, m, fake := setupAnalyzeEnv(t)
artifact := env.Config.ArtifactCatalog.Artifacts["session_recap"]