Remove unused history document copies
This commit is contained in:
@@ -321,6 +321,13 @@ Findings: **D02, D03**.
|
||||
Owners: `internal/engine/override_decode.go`, `override_context.go`, `load.go`,
|
||||
`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
|
||||
unused output. Keep the pre-CLI context actually built from `before.final`.
|
||||
Remove `Inspection.structuralInput`, the final publication clone made solely for
|
||||
|
||||
@@ -93,7 +93,6 @@ type Inspection struct {
|
||||
baseline *document.Node
|
||||
input *document.Node
|
||||
inputOrigins map[string]Origin
|
||||
structuralInput *document.Node
|
||||
preCLI *document.Node
|
||||
preCLIOrigins map[string]Origin
|
||||
postDecodeApps []historyApplication
|
||||
|
||||
@@ -109,14 +109,13 @@ func publishLoadResult[T any](schema *schemaDescriptor, definition Definition[T]
|
||||
}
|
||||
decoded, metadata := resolved.decoded, resolved.metadata
|
||||
final, applications, resolutionSnapshots := resolved.final, resolved.applications, resolved.snapshots
|
||||
structuralInput := document.Clone(resolved.structuralInput)
|
||||
preCLI := document.Clone(resolved.preCLI)
|
||||
allApplications := append(cloneHistoryApplications(applications), cloneHistoryApplications(resolved.postDecodeApps)...)
|
||||
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)
|
||||
sources := sourceInfosWithVersionEvidence(accumulator.sources, resolved.versionEvidence, secrets, false)
|
||||
retainedTrees := make([]*document.Node, 0, len(allApplications)+5)
|
||||
retainedTrees = append(retainedTrees, decoded.final, final, structuralInput, preCLI)
|
||||
retainedTrees := make([]*document.Node, 0, len(allApplications)+4)
|
||||
retainedTrees = append(retainedTrees, decoded.final, final, preCLI)
|
||||
for _, application := range allApplications {
|
||||
retainedTrees = append(retainedTrees, application.value)
|
||||
}
|
||||
@@ -128,7 +127,6 @@ func publishLoadResult[T any](schema *schemaDescriptor, definition Definition[T]
|
||||
baseline: decoded.baseline,
|
||||
input: decoded.final,
|
||||
inputOrigins: cloneOriginIndex(decoded.origins),
|
||||
structuralInput: structuralInput,
|
||||
preCLI: preCLI,
|
||||
preCLIOrigins: cloneOrigins(resolved.preCLIOrigins),
|
||||
postDecodeApps: cloneHistoryApplications(resolved.postDecodeApps),
|
||||
|
||||
@@ -50,7 +50,7 @@ func TestPostDecodeOverrideContextOrdersDecodeCLIAndResolutionEvidence(t *testin
|
||||
t.Fatalf("applyDecodedOverrides() issues = %#v", issues)
|
||||
}
|
||||
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 {
|
||||
t.Fatal("structural, pre-CLI, post-CLI, and located snapshots are not detached")
|
||||
}
|
||||
@@ -88,10 +88,10 @@ func TestPostDecodeOverrideContextOrdersDecodeCLIAndResolutionEvidence(t *testin
|
||||
|
||||
inspection := Inspection{
|
||||
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,
|
||||
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.postDecodeApps[2].value, prepared.postDecodeApps[3].value),
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@ import (
|
||||
// contributions alongside the effective typed value and its inspection data.
|
||||
type decodedOverrideResult struct {
|
||||
value reflect.Value
|
||||
preCLI *document.Node
|
||||
final *document.Node
|
||||
presence map[string]inputPresence
|
||||
origins map[string]Origin
|
||||
@@ -30,7 +29,6 @@ func applyDecodedOverrides(
|
||||
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())
|
||||
if cloneIssue != nil {
|
||||
return decodedOverrideResult{}, []decodeIssue{decodeIssueFromProjection(cloneIssue)}
|
||||
@@ -76,7 +74,6 @@ func applyDecodedOverrides(
|
||||
|
||||
return decodedOverrideResult{
|
||||
value: working,
|
||||
preCLI: preCLI,
|
||||
final: final,
|
||||
presence: presence,
|
||||
origins: origins,
|
||||
|
||||
@@ -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 {
|
||||
t.Fatalf("post-decode configuration = %#v", got)
|
||||
}
|
||||
if result.preCLI == result.final || !reflect.DeepEqual(result.preCLI, decoded.final) || len(result.overrides) != len(batch.overrides) {
|
||||
t.Fatalf("result snapshots/contributions = pre:%p final:%p overrides:%d", result.preCLI, result.final, len(result.overrides))
|
||||
if len(result.overrides) != len(batch.overrides) {
|
||||
t.Fatalf("result override contributions = %d, want %d", len(result.overrides), len(batch.overrides))
|
||||
}
|
||||
if _, explicit := result.presence["/items/0/enabled"]; explicit {
|
||||
t.Fatalf("replacement list inherited presence from its discarded item: %#v", result.presence)
|
||||
|
||||
Reference in New Issue
Block a user