Remove unused history document copies

This commit is contained in:
2026-10-25 21:47:53 +00:00
parent 0f9ecf12ed
commit 119b42c810
6 changed files with 14 additions and 13 deletions

View File

@@ -321,6 +321,13 @@ Findings: **D02, D03**.
Owners: `internal/engine/override_decode.go`, `override_context.go`, `load.go`, Owners: `internal/engine/override_decode.go`, `override_context.go`, `load.go`,
`load_result.go`, and corresponding tests. `load_result.go`, and corresponding tests.
Status: **complete** (D02, D03). Prior completed commits: `2736ddf`,
`deb9aa5`, `ae3408a`, `ea27f17`, `08a8c25`, `877c497`, `8aba43d`,
`7bf2f0c`, `0f9ecf1`. Validation passed:
`env GOTOOLCHAIN=local GOPROXY=off GOTELEMETRY=off go test ./internal/engine -run 'Override|History|Explain|Secret|Independent' -count=1`,
`env GOTOOLCHAIN=local GOPROXY=off GOTELEMETRY=off go test ./internal/engine -count=1`,
and `git diff --check`.
Remove `decodedOverrideResult.preCLI`, its clone, and assertions only about that Remove `decodedOverrideResult.preCLI`, its clone, and assertions only about that
unused output. Keep the pre-CLI context actually built from `before.final`. unused output. Keep the pre-CLI context actually built from `before.final`.
Remove `Inspection.structuralInput`, the final publication clone made solely for Remove `Inspection.structuralInput`, the final publication clone made solely for

View File

@@ -93,7 +93,6 @@ type Inspection struct {
baseline *document.Node baseline *document.Node
input *document.Node input *document.Node
inputOrigins map[string]Origin inputOrigins map[string]Origin
structuralInput *document.Node
preCLI *document.Node preCLI *document.Node
preCLIOrigins map[string]Origin preCLIOrigins map[string]Origin
postDecodeApps []historyApplication postDecodeApps []historyApplication

View File

@@ -109,14 +109,13 @@ func publishLoadResult[T any](schema *schemaDescriptor, definition Definition[T]
} }
decoded, metadata := resolved.decoded, resolved.metadata decoded, metadata := resolved.decoded, resolved.metadata
final, applications, resolutionSnapshots := resolved.final, resolved.applications, resolved.snapshots final, applications, resolutionSnapshots := resolved.final, resolved.applications, resolved.snapshots
structuralInput := document.Clone(resolved.structuralInput)
preCLI := document.Clone(resolved.preCLI) preCLI := document.Clone(resolved.preCLI)
allApplications := append(cloneHistoryApplications(applications), cloneHistoryApplications(resolved.postDecodeApps)...) allApplications := append(cloneHistoryApplications(applications), cloneHistoryApplications(resolved.postDecodeApps)...)
finalizeMetadataPaths(&metadata, final, allApplications, decoded.baseline, resolved.structuralInput, resolved.preCLI, decoded.final) finalizeMetadataPaths(&metadata, final, allApplications, decoded.baseline, resolved.structuralInput, resolved.preCLI, decoded.final)
secrets := classifySecretPathsWithEvidence(schema, definition.Secret, metadata, final, allApplications, resolved.versionEvidence, decoded.baseline, resolved.structuralInput, resolved.preCLI, decoded.final) secrets := classifySecretPathsWithEvidence(schema, definition.Secret, metadata, final, allApplications, resolved.versionEvidence, decoded.baseline, resolved.structuralInput, resolved.preCLI, decoded.final)
sources := sourceInfosWithVersionEvidence(accumulator.sources, resolved.versionEvidence, secrets, false) sources := sourceInfosWithVersionEvidence(accumulator.sources, resolved.versionEvidence, secrets, false)
retainedTrees := make([]*document.Node, 0, len(allApplications)+5) retainedTrees := make([]*document.Node, 0, len(allApplications)+4)
retainedTrees = append(retainedTrees, decoded.final, final, structuralInput, preCLI) retainedTrees = append(retainedTrees, decoded.final, final, preCLI)
for _, application := range allApplications { for _, application := range allApplications {
retainedTrees = append(retainedTrees, application.value) retainedTrees = append(retainedTrees, application.value)
} }
@@ -128,7 +127,6 @@ func publishLoadResult[T any](schema *schemaDescriptor, definition Definition[T]
baseline: decoded.baseline, baseline: decoded.baseline,
input: decoded.final, input: decoded.final,
inputOrigins: cloneOriginIndex(decoded.origins), inputOrigins: cloneOriginIndex(decoded.origins),
structuralInput: structuralInput,
preCLI: preCLI, preCLI: preCLI,
preCLIOrigins: cloneOrigins(resolved.preCLIOrigins), preCLIOrigins: cloneOrigins(resolved.preCLIOrigins),
postDecodeApps: cloneHistoryApplications(resolved.postDecodeApps), postDecodeApps: cloneHistoryApplications(resolved.postDecodeApps),

View File

@@ -50,7 +50,7 @@ func TestPostDecodeOverrideContextOrdersDecodeCLIAndResolutionEvidence(t *testin
t.Fatalf("applyDecodedOverrides() issues = %#v", issues) t.Fatalf("applyDecodedOverrides() issues = %#v", issues)
} }
prepared := preparePostDecodeOverrideContext(input, decoded, assigned) prepared := preparePostDecodeOverrideContext(input, decoded, assigned)
if prepared.structuralInput == structural || prepared.preCLI == decoded.final || prepared.decoded.final == assigned.preCLI || if prepared.structuralInput == structural || prepared.preCLI == decoded.final ||
prepared.decoded.final == assigned.final || prepared.referenceInput == assigned.final { prepared.decoded.final == assigned.final || prepared.referenceInput == assigned.final {
t.Fatal("structural, pre-CLI, post-CLI, and located snapshots are not detached") t.Fatal("structural, pre-CLI, post-CLI, and located snapshots are not detached")
} }
@@ -88,10 +88,10 @@ func TestPostDecodeOverrideContextOrdersDecodeCLIAndResolutionEvidence(t *testin
inspection := Inspection{ inspection := Inspection{
metadata: prepared.metadata, baseline: decoded.baseline, input: assigned.final, inputOrigins: assigned.origins, metadata: prepared.metadata, baseline: decoded.baseline, input: assigned.final, inputOrigins: assigned.origins,
structuralInput: prepared.structuralInput, preCLI: prepared.preCLI, preCLIOrigins: prepared.preCLIOrigins, preCLI: prepared.preCLI, preCLIOrigins: prepared.preCLIOrigins,
postDecodeApps: prepared.postDecodeApps, final: assigned.final, postDecodeApps: prepared.postDecodeApps, final: assigned.final,
applications: prepared.applications, applications: prepared.applications,
immutableLookup: buildDocumentLookup(prepared.structuralInput, prepared.preCLI, assigned.final, immutableLookup: buildDocumentLookup(prepared.preCLI, assigned.final,
prepared.applications[0].value, prepared.postDecodeApps[0].value, prepared.postDecodeApps[1].value, prepared.applications[0].value, prepared.postDecodeApps[0].value, prepared.postDecodeApps[1].value,
prepared.postDecodeApps[2].value, prepared.postDecodeApps[3].value), prepared.postDecodeApps[2].value, prepared.postDecodeApps[3].value),
} }

View File

@@ -10,7 +10,6 @@ import (
// contributions alongside the effective typed value and its inspection data. // contributions alongside the effective typed value and its inspection data.
type decodedOverrideResult struct { type decodedOverrideResult struct {
value reflect.Value value reflect.Value
preCLI *document.Node
final *document.Node final *document.Node
presence map[string]inputPresence presence map[string]inputPresence
origins map[string]Origin origins map[string]Origin
@@ -30,7 +29,6 @@ func applyDecodedOverrides(
return decodedOverrideResult{}, []decodeIssue{{code: CodeSchemaUnsupportedType, message: "decoded configuration does not match the schema"}} return decodedOverrideResult{}, []decodeIssue{{code: CodeSchemaUnsupportedType, message: "decoded configuration does not match the schema"}}
} }
preCLI := document.Clone(decoded.final)
working, cloneIssue := cloneConfiguration(schema, decoded.value, defaultProjectionLimits()) working, cloneIssue := cloneConfiguration(schema, decoded.value, defaultProjectionLimits())
if cloneIssue != nil { if cloneIssue != nil {
return decodedOverrideResult{}, []decodeIssue{decodeIssueFromProjection(cloneIssue)} return decodedOverrideResult{}, []decodeIssue{decodeIssueFromProjection(cloneIssue)}
@@ -76,7 +74,6 @@ func applyDecodedOverrides(
return decodedOverrideResult{ return decodedOverrideResult{
value: working, value: working,
preCLI: preCLI,
final: final, final: final,
presence: presence, presence: presence,
origins: origins, origins: origins,

View File

@@ -622,8 +622,8 @@ func TestApplyDecodedOverridesUsesSchemaAndPreservesTypedOwnership(t *testing.T)
got.Text != "cli text" || got.Delay != 250*time.Millisecond || got.APIKey.name != "CLI_SECRET" || got.Maybe != nil { got.Text != "cli text" || got.Delay != 250*time.Millisecond || got.APIKey.name != "CLI_SECRET" || got.Maybe != nil {
t.Fatalf("post-decode configuration = %#v", got) t.Fatalf("post-decode configuration = %#v", got)
} }
if result.preCLI == result.final || !reflect.DeepEqual(result.preCLI, decoded.final) || len(result.overrides) != len(batch.overrides) { if len(result.overrides) != len(batch.overrides) {
t.Fatalf("result snapshots/contributions = pre:%p final:%p overrides:%d", result.preCLI, result.final, len(result.overrides)) t.Fatalf("result override contributions = %d, want %d", len(result.overrides), len(batch.overrides))
} }
if _, explicit := result.presence["/items/0/enabled"]; explicit { if _, explicit := result.presence["/items/0/enabled"]; explicit {
t.Fatalf("replacement list inherited presence from its discarded item: %#v", result.presence) t.Fatalf("replacement list inherited presence from its discarded item: %#v", result.presence)