Use main for the main provenance layer

This commit is contained in:
2026-10-27 15:15:39 +00:00
parent 9833ca3aa3
commit 1ce147c9f6
51 changed files with 120 additions and 106 deletions

View File

@@ -1,6 +1,6 @@
# Pre-v1 Public API Cleanup Implementation Plan
Status: in progress; Stages 1–6 are complete and Stages 7–11 are pending.
Status: in progress; Stages 1–7 are complete and Stages 8–11 are pending.
Baseline: `07e4ae5d9236935389e81b207d4a8f00543fafce`.
Audience: a Luna coding agent executing the stages sequentially.
@@ -298,7 +298,7 @@ is unchanged.
## Stage 7 — Use Main Consistently In Provenance
Status: pending. Implements N2.
Status: complete. Implements N2.
1. Replace `LayerBase = "base"` with `LayerMain = "main"` in root/engine
records. Migrate producer references across acquisition, composition,

View File

@@ -60,7 +60,7 @@ func TestCollectionBundleAssemblesMountedPeersAndResources(t *testing.T) {
}
versionInfo, ok := result.Metadata().Lookup(configkit.Keys("version"))
if !ok || !versionInfo.Explicit || versionInfo.Origin.Layer != configkit.LayerBase || len(versionInfo.Origin.Locations) != 1 {
if !ok || !versionInfo.Explicit || versionInfo.Origin.Layer != configkit.LayerMain || len(versionInfo.Origin.Locations) != 1 {
t.Fatalf("main-owned version metadata = %#v, %v", versionInfo, ok)
}
collectionVersionPath := configkit.Keys("collections", "weatherreporter", "version")

View File

@@ -119,7 +119,7 @@ func TestCatalogRetainsPresenceAndSourceContext(t *testing.T) {
}
for _, key := range []string{"enabled", "workers"} {
info, found := result.Metadata().Lookup(configkit.Keys(key))
if !found || !info.Explicit || info.Origin.Layer != configkit.LayerBase {
if !found || !info.Explicit || info.Origin.Layer != configkit.LayerMain {
t.Fatalf("%s presence = %#v, %v", key, info, found)
}
}

View File

@@ -405,7 +405,7 @@ func TestFacadeMountedMainAndUnderlayInspectionResourcesAndDiff(t *testing.T) {
if err != nil || string(data) != "source-relative summary" {
t.Fatalf("completed relative resource = %q, %v", data, err)
}
if info, ok := result.Metadata().Lookup(titlePath); !ok || info.Origin.Layer != configkit.LayerBase {
if info, ok := result.Metadata().Lookup(titlePath); !ok || info.Origin.Layer != configkit.LayerMain {
t.Fatalf("mounted title metadata = %#v, %v", info, ok)
}
if history := result.Metadata().History(titlePath); len(history) < 2 {

View File

@@ -142,7 +142,7 @@ func TestFacadeSearchWorksForLayeredMainAndUnderlay(t *testing.T) {
t.Fatalf("layered search = %#v, %v", result, err)
}
sources := result.Sources()
if len(sources) != 2 || sources[0].Path != canonicalFacadePath(t, mainPath) || sources[0].Layer != LayerBase ||
if len(sources) != 2 || sources[0].Path != canonicalFacadePath(t, mainPath) || sources[0].Layer != LayerMain ||
sources[1].Path != canonicalFacadePath(t, underlayPath) || sources[1].Layer != LayerUnderlay {
t.Fatalf("layered search sources = %#v", sources)
}

View File

@@ -69,7 +69,7 @@ func TestEquivalentSourceFormsPreserveInputSemantics(t *testing.T) {
}
for _, field := range []string{"version", "name", "enabled", "count", "items", "optional"} {
info, ok := result.Metadata().Lookup(configkit.Keys(field))
if !ok || !info.Explicit || info.Origin.Layer != configkit.LayerBase || info.Null != (field == "optional") {
if !ok || !info.Explicit || info.Origin.Layer != configkit.LayerMain || info.Null != (field == "optional") {
t.Errorf("%s input info = %#v, %v", field, info, ok)
}
}

View File

@@ -85,16 +85,16 @@ func assertPublicShapeHistory(t *testing.T, metadata configkit.Metadata, operati
}
var keyDefinition, keyReplacement, indexReplacement bool
for _, change := range keyHistory {
keyDefinition = keyDefinition || change.Origin.Layer == configkit.LayerBase
keyDefinition = keyDefinition || change.Origin.Layer == configkit.LayerMain
keyReplacement = keyReplacement || change.Origin.Layer == operationLayer && change.Path.String() == "/shape"
}
for _, change := range indexHistory {
if change.Origin.Layer == configkit.LayerBase {
if change.Origin.Layer == configkit.LayerMain {
t.Fatalf("introduced index inherited mapping-key history: %#v", indexHistory)
}
indexReplacement = indexReplacement || change.Origin.Layer == operationLayer && change.Path.String() == "/shape"
for _, previous := range change.Previous {
if previous.Layer == configkit.LayerBase {
if previous.Layer == configkit.LayerMain {
t.Fatalf("introduced index inherited mapping-key previous origin: %#v", change)
}
}

View File

@@ -67,6 +67,14 @@ entries:
}
sources := result.Sources()
if len(sources) < 3 || sources[0].Layer != LayerMain || string(sources[0].Layer) != "main" {
t.Fatalf("main source attribution = %#v", sources)
}
for _, source := range sources[1:] {
if source.ImportedFrom != nil && (source.Layer != LayerMain || string(source.Layer) != "main") {
t.Errorf("imported main source attribution = %#v", source)
}
}
filesByID := make(map[string]string, len(sources))
for _, source := range sources {
filesByID[source.ID] = source.Path

View File

@@ -80,7 +80,7 @@ func TestFacadeLayeredMixedSourcesAndInspection(t *testing.T) {
if len(sources) != 8 {
t.Fatalf("sources = %#v", sources)
}
wantLayers := []configkit.Layer{configkit.LayerBase, configkit.LayerUnderlay, configkit.LayerUnderlay, configkit.LayerUnderlay, configkit.LayerUnderlay, configkit.LayerUnderlay, configkit.LayerOverlay, configkit.LayerCLI}
wantLayers := []configkit.Layer{configkit.LayerMain, configkit.LayerUnderlay, configkit.LayerUnderlay, configkit.LayerUnderlay, configkit.LayerUnderlay, configkit.LayerUnderlay, configkit.LayerOverlay, configkit.LayerCLI}
wantIndexes := []int{0, 1, 1, 1, 1, 2, 0, 0}
wantKinds := []configkit.SourceKind{configkit.SourceKindFile, configkit.SourceKindFilesystem, configkit.SourceKindFilesystem, configkit.SourceKindMapping, configkit.SourceKindFilesystem, configkit.SourceKindMapping, configkit.SourceKindFilesystem, configkit.SourceKindCLI}
for index, source := range sources {

View File

@@ -36,7 +36,7 @@ func TestFacadeMappingSnapshotsAndMatchesYAML(t *testing.T) {
if !reflect.DeepEqual(result.Config, want) {
t.Fatalf("mapping config = %#v, want %#v", result.Config, want)
}
if sources := result.Sources(); len(sources) != 1 || sources[0].ID != "source-1" || sources[0].Kind != configkit.SourceKindMapping || sources[0].Layer != configkit.LayerBase || sources[0].Path != "" {
if sources := result.Sources(); len(sources) != 1 || sources[0].ID != "source-1" || sources[0].Kind != configkit.SourceKindMapping || sources[0].Layer != configkit.LayerMain || sources[0].Path != "" {
t.Fatalf("mapping sources = %#v", sources)
}
info, ok := result.Metadata().Lookup(configkit.Keys("name"))
@@ -89,7 +89,7 @@ func TestFacadeMappingImportsUseExplicitContext(t *testing.T) {
if err != nil || result.Config.Name != "imported" || !result.Config.Enabled {
t.Fatalf("mapping import = %#v, %v", result, err)
}
if sources := result.Sources(); len(sources) != 2 || sources[0].Kind != configkit.SourceKindMapping || sources[1].Kind != configkit.SourceKindFilesystem || sources[1].Layer != configkit.LayerBase {
if sources := result.Sources(); len(sources) != 2 || sources[0].Kind != configkit.SourceKindMapping || sources[1].Kind != configkit.SourceKindFilesystem || sources[1].Layer != configkit.LayerMain {
t.Fatalf("mapping import sources = %#v", sources)
}
checkMappingCode(t, source, configkit.Options[mappingFacadeConfig]{Imports: true}, configkit.CodeOptionsInvalid)

View File

@@ -125,7 +125,7 @@ func TestFacadeRegisteredReplacementExplainsRemovedDescendants(t *testing.T) {
t.Fatalf("removal not explained: %#v", explanation)
}
last := explanation.History[len(explanation.History)-1]
if !last.Before.Present || last.After.Present || last.Origin.Layer != configkit.LayerBase || len(last.Origin.Locations) != 1 || last.Origin.Locations[0].SourceID != result.Sources()[0].ID {
if !last.Before.Present || last.After.Present || last.Origin.Layer != configkit.LayerMain || len(last.Origin.Locations) != 1 || last.Origin.Locations[0].SourceID != result.Sources()[0].ID {
t.Fatalf("wrong removal transition/origin: %#v", last)
}
})
@@ -612,7 +612,7 @@ entries:
t.Error("resolver treated an omitted field as explicit")
}
info, found := resolution.EntryInfo(configkit.Keys("entries").Index(0).Key("count"))
if !found || info.Origin.Layer != configkit.LayerBase {
if !found || info.Origin.Layer != configkit.LayerMain {
t.Errorf("resolver current-record input info = %#v, %v", info, found)
}
for _, id := range []string{"source-3", "source-4"} {

View File

@@ -64,7 +64,7 @@ func TestMainVersionDecodingFollowsSequenceMovement(t *testing.T) {
t.Fatal("unrelated underlay payload was treated as the main declaration")
}
for _, source := range loaded.Sources() {
if source.Layer == configkit.LayerBase && source.VersionEvidence.Path.String() != path.String() {
if source.Layer == configkit.LayerMain && source.VersionEvidence.Path.String() != path.String() {
t.Fatal("effective movement changed source-local version evidence")
}
}

View File

@@ -223,7 +223,7 @@ func composeDocumentsWithCollectionPolicy(
rangesBySource[assigned.sourceIndex] = append(rangesBySource[assigned.sourceIndex], assigned)
}
for sourceIndex, input := range inputs {
application := historyApplication{layer: LayerBase, value: input}
application := historyApplication{layer: LayerMain, value: input}
for _, assigned := range rangesBySource[sourceIndex] {
pointer := assigned.path.String()
mode := sequenceHistoryAppend
@@ -255,7 +255,7 @@ func composeDocumentsWithCollectionPolicy(
func completeCompositionOrigins(node *document.Node, path Path, origins map[string]Origin) {
pointer := path.String()
if _, present := origins[pointer]; !present {
origins[pointer] = Origin{Layer: LayerBase, Locations: []Location{publicLocation(node.Location)}}
origins[pointer] = Origin{Layer: LayerMain, Locations: []Location{publicLocation(node.Location)}}
}
switch node.Kind {
case document.Mapping:
@@ -513,7 +513,7 @@ func projectedCompositionOrigins(inputs []*document.Node, ranges []sequenceRange
walkHistoryApplication(application, func(_, effective Path, node *document.Node) {
pointer := effective.String()
origin := origins[pointer]
origin.Layer = LayerBase
origin.Layer = LayerMain
origin.Locations = append(origin.Locations, publicLocation(node.Location))
origins[pointer] = origin
})

View File

@@ -92,7 +92,7 @@ values: [one, two]
{SourceID: "source-1", Line: 2, Column: 3},
{SourceID: "source-2", Line: 2, Column: 3},
}
if !reflect.DeepEqual(serviceOrigin, Origin{Layer: LayerBase, Locations: wantLocations}) {
if !reflect.DeepEqual(serviceOrigin, Origin{Layer: LayerMain, Locations: wantLocations}) {
t.Fatalf("services origin = %#v, want composite origin", serviceOrigin)
}
wantClaimPaths := []string{"", "/services", "/services/api", "/services/api/enabled", "/empty", "", "/services", "/services/worker", "/services/worker/enabled", "/values"}

View File

@@ -448,7 +448,7 @@ func collectPresence(node *document.Node, path Path, presence map[string]inputPr
func collectOrigins(node *document.Node, path Path, presence map[string]inputPresence, origins map[string]Origin) {
if input, ok := presence[path.String()]; ok {
origins[path.String()] = Origin{Layer: LayerBase, Locations: []Location{{SourceID: input.location.SourceID, Line: input.location.Line, Column: input.location.Column}}}
origins[path.String()] = Origin{Layer: LayerMain, Locations: []Location{{SourceID: input.location.SourceID, Line: input.location.Line, Column: input.location.Column}}}
} else {
origins[path.String()] = Origin{Layer: LayerDefault}
}

View File

@@ -141,7 +141,7 @@ custom: accepted
if _, ok := decoded.presence[Keys("nested", "a").String()]; ok {
t.Fatal("parent mapping made omitted child explicit")
}
if decoded.origins[Keys("nested", "a").String()].Layer != LayerDefault || decoded.origins[Keys("nested", "b").String()].Layer != LayerBase {
if decoded.origins[Keys("nested", "a").String()].Layer != LayerDefault || decoded.origins[Keys("nested", "b").String()].Layer != LayerMain {
t.Fatalf("origins = %#v", decoded.origins)
}
if decoded.origins[Keys("nested", "b").String()].Locations[0].Line == 0 {

View File

@@ -481,7 +481,7 @@ func resolveSearchInput(source Source, sourceID string, helpers discoveryDirecto
if len(diagnostics) == 0 || selected.kind != sourceFile {
return selected, nil, diagnostics
}
info := &SourceInfo{ID: sourceID, Label: selected.label, Path: selected.path, Layer: LayerBase, Kind: SourceKindFile}
info := &SourceInfo{ID: sourceID, Label: selected.label, Path: selected.path, Layer: LayerMain, Kind: SourceKindFile}
for index := range diagnostics {
diagnostics[index].Primary = &Location{SourceID: sourceID}
}

View File

@@ -77,7 +77,7 @@ settings: {underlay: value}
Keys("settings", "main"), Keys("settings", "underlay"), Keys("settings", "imported"))
sources := searched.Inspection.Sources()
if len(sources) != 3 || sources[0].ID != "source-1" || sources[0].Layer != LayerBase || sources[1].ID != "source-2" || sources[1].Layer != LayerUnderlay || sources[2].Path != canonicalTestPath(t, importPath) || sources[2].UnderlayIndex != 1 {
if len(sources) != 3 || sources[0].ID != "source-1" || sources[0].Layer != LayerMain || sources[1].ID != "source-2" || sources[1].Layer != LayerUnderlay || sources[2].Path != canonicalTestPath(t, importPath) || sources[2].UnderlayIndex != 1 {
t.Fatalf("layered search source evidence = %#v", sources)
}
}

View File

@@ -44,7 +44,7 @@ func (r *Inspection) WriteExplanation(output io.Writer, path Path) error {
rendered.WriteString("input to canonical typed\n")
} else if change.Origin.Operation == ChangeInheritance {
rendered.WriteString("structural inheritance\n")
} else if change.Origin.Layer == LayerBase || change.Origin.Layer == LayerUnderlay || change.Origin.Layer == LayerOverlay || change.Origin.Layer == LayerCLI {
} else if change.Origin.Layer == LayerMain || change.Origin.Layer == LayerUnderlay || change.Origin.Layer == LayerOverlay || change.Origin.Layer == LayerCLI {
rendered.WriteString("policy-validated input\n")
} else {
rendered.WriteString("canonical typed\n")

View File

@@ -137,7 +137,7 @@ dynamic: selected
if got := explanationValues(concurrency); !reflect.DeepEqual(got, []string{"4\n", "8\n", "1\n", "2\n", "3\n"}) {
t.Fatalf("concurrency history = %#v", got)
}
if got := historyValueLayers(concurrency); !reflect.DeepEqual(got, []Layer{LayerDefault, LayerBase, LayerOverlay, LayerCLI, LayerResolution}) {
if got := historyValueLayers(concurrency); !reflect.DeepEqual(got, []Layer{LayerDefault, LayerMain, LayerOverlay, LayerCLI, LayerResolution}) {
t.Fatalf("concurrency layers = %#v", got)
}
if concurrency.History[4].Before.YAML != "2\n" || concurrency.History[4].Reasons[0] != "normalized\nconcurrency" ||
@@ -265,7 +265,7 @@ dynamic: selected
var invalidInput bytes.Buffer
if err := result.WriteExplanation(&invalidInput, Keys("limit")); err != nil ||
!strings.Contains(invalidInput.String(), "policy-validated input") ||
strings.Contains(invalidInput.String(), "wrong-before-overlay\n source: layer=\"base\"\n before (canonical typed)") {
strings.Contains(invalidInput.String(), "wrong-before-overlay\n source: layer=\"main\"\n before (canonical typed)") {
t.Fatalf("historical representation rendering = %v\n%s", err, invalidInput.String())
}
}
@@ -312,7 +312,7 @@ func TestHistoryNodeBudgetCountsSharedTreesOnce(t *testing.T) {
builder.model.baseline = root
builder.model.final = root
builder.model.sourcePayloads = []historySourcePayload{{
kind: historySourceApplicationPayload, application: historyApplication{layer: LayerBase, value: root},
kind: historySourceApplicationPayload, application: historyApplication{layer: LayerMain, value: root},
}}
model := builder.freeze()
inspection := &Inspection{history: model, metadata: Metadata{historyModel: model}, final: root}
@@ -325,7 +325,7 @@ func TestHistoryNodeBudgetCountsSharedTreesOnce(t *testing.T) {
builder.model.baseline = root
builder.model.final = root
builder.model.sourcePayloads = []historySourcePayload{{
kind: historySourceApplicationPayload, application: historyApplication{layer: LayerBase, value: other},
kind: historySourceApplicationPayload, application: historyApplication{layer: LayerMain, value: other},
}}
model = builder.freeze()
inspection.history = model
@@ -445,7 +445,7 @@ func TestIntegerVersionInspectionRetainsInputAndReconcilesTypedValue(t *testing.
}
info, ok := first.Metadata().Lookup(Keys("version"))
if !ok || !info.Explicit || info.Null || info.Origin.Layer != LayerBase || len(info.Origin.Locations) != 1 ||
if !ok || !info.Explicit || info.Null || info.Origin.Layer != LayerMain || len(info.Origin.Locations) != 1 ||
info.Origin.Locations[0].SourceID != "source-1" || info.Origin.Locations[0].Line != 1 {
t.Fatalf("version metadata = %#v, %v", info, ok)
}
@@ -455,7 +455,7 @@ func TestIntegerVersionInspectionRetainsInputAndReconcilesTypedValue(t *testing.
}
foundInput, foundDecoding := false, false
for _, change := range explanation.History {
if change.After.YAML == "4\n" && change.Origin.Layer == LayerBase {
if change.After.YAML == "4\n" && change.Origin.Layer == LayerMain {
foundInput = true
}
if change.Before.YAML == "4\n" && change.After.YAML == "'4'\n" && change.Origin.Operation == ChangeDecoding {

View File

@@ -38,7 +38,7 @@ func TestCLIOverrideRecordsTrackConcreteShapeChanges(t *testing.T) {
setOverrideTestDocumentSource(incomingRoot, "cli-source")
incoming, _ := documentAtPath(incomingRoot, Keys("target"))
origins := make(map[string]Origin)
collectOverlayOrigins(origins, before, Path{}, LayerBase)
collectOverlayOrigins(origins, before, Path{}, LayerMain)
records := overrideMetadataRecords(decodedConfiguration{final: before, origins: origins}, []preparedOverride{{
path: Keys("target"), value: incoming, source: SourceInfo{ID: "cli-source"},
}})
@@ -83,7 +83,7 @@ func TestCLIHistoryEvidenceKeepsCheckpointsAndConditionalReconciliation(t *testi
structural := parseDocumentForDecode(t, "count: 7\nsettings: {a: 1, b: 2}\nitems: {old: value}\n")
preCLI := parseDocumentForDecode(t, "count: '7'\nsettings: {a: 1, b: 2}\nitems: {old: value}\ndefaulted: 9\n")
preOrigins := map[string]Origin{
Keys("count").String(): {Layer: LayerBase, Locations: []Location{{SourceID: "input"}}},
Keys("count").String(): {Layer: LayerMain, Locations: []Location{{SourceID: "input"}}},
Keys("defaulted").String(): {Layer: LayerDefault},
}
countRoot := parseDocumentForDecode(t, "count: 7\n")

View File

@@ -14,9 +14,9 @@ func TestInheritanceEvidenceUsesOrderedPayloadAndConcreteTransferShapes(t *testi
effective := parseDocumentForDecode(t, "id: child\nbranch: replaced\n")
root := parseDocumentForDecode(t, "parent: {unused: true}\nchild: {id: child, extends: parent, branch: {local: stale}}\n")
parentOrigins := map[string]Origin{
Keys("parent", "branch").String(): {Layer: LayerBase, Locations: []Location{{SourceID: "parent"}}},
Keys("parent", "branch", "deep").String(): {Layer: LayerBase, Locations: []Location{{SourceID: "parent"}}},
Keys("parent", "branch", "deep", "leaf").String(): {Layer: LayerBase, Locations: []Location{{SourceID: "parent"}}},
Keys("parent", "branch").String(): {Layer: LayerMain, Locations: []Location{{SourceID: "parent"}}},
Keys("parent", "branch", "deep").String(): {Layer: LayerMain, Locations: []Location{{SourceID: "parent"}}},
Keys("parent", "branch", "deep", "leaf").String(): {Layer: LayerMain, Locations: []Location{{SourceID: "parent"}}},
}
effectiveOrigins := map[string]Origin{
Keys("child", "branch").String(): {Layer: LayerOverlay, Locations: []Location{{SourceID: "child"}}},
@@ -76,7 +76,7 @@ func TestInheritanceModelSharesProjectionAttribution(t *testing.T) {
from, to, reference := Keys("parents", "base"), Keys("children", "item"), Keys("parents", "base")
path := to.Key("nested").Key("value")
parent := Origin{Layer: LayerBase, Locations: []Location{{SourceID: "base"}}}
parent := Origin{Layer: LayerMain, Locations: []Location{{SourceID: "base"}}}
child := Origin{Layer: LayerOverlay, Locations: []Location{{SourceID: "child"}}}
parentDocument := parseDocumentForDecode(t, "nested: {value: parent}\n")
effectiveDocument := parseDocumentForDecode(t, "nested: {value: child}\n")
@@ -121,7 +121,7 @@ func TestInheritanceEvidenceSeparatesCollidingKeyAndIndexShapes(t *testing.T) {
childPath := to.Key("items").Key("0").Key("value")
operation := inheritanceOperation{
transfer: &transfer, parent: parent, effective: effective,
parentOrigins: map[string]Origin{parentPath.String(): {Layer: LayerBase, Locations: []Location{{SourceID: "parent"}}}},
parentOrigins: map[string]Origin{parentPath.String(): {Layer: LayerMain, Locations: []Location{{SourceID: "parent"}}}},
effectiveOrigins: map[string]Origin{childPath.String(): {Layer: LayerOverlay, Locations: []Location{{SourceID: "child"}}}},
childOrigins: map[string]Origin{childPath.String(): {Layer: LayerOverlay, Locations: []Location{{SourceID: "child"}}}},
}

View File

@@ -58,7 +58,7 @@ func TestHistorySelectionSeparatesNumericShapesAndGroupsParsedSides(t *testing.T
builder.observeDocument(mapping, historyPhaseBaseline)
builder.observeDocument(sequence, historyPhaseResolution)
baseOrigin := Origin{Layer: LayerBase}
baseOrigin := Origin{Layer: LayerMain}
baseAttribution := builder.addAttribution(baseOrigin, nil, nil)
keyPath := Keys("shape", "0")
indexPath := Keys("shape").Index(0)
@@ -125,7 +125,7 @@ func TestHistorySelectionSeparatesNumericShapesAndGroupsParsedSides(t *testing.T
if len(keySelections) != 2 || keySelections[0].role != historyRoleDefinition || keySelections[1].before != true || keySelections[1].after {
t.Fatalf("mapping-key selections = %#v", keySelections)
}
if len(keySelections[1].previous) != 1 || keySelections[1].previous[0].Layer != LayerBase {
if len(keySelections[1].previous) != 1 || keySelections[1].previous[0].Layer != LayerMain {
t.Fatalf("mapping-key previous origins = %#v", keySelections[1].previous)
}
@@ -163,7 +163,7 @@ func TestHistorySelectionMatchesDeepSidesOfAncestorShapeChange(t *testing.T) {
builder := newHistoryBuilder()
builder.observeDocument(parseDocumentForDecode(t, "shape: {'0': {leaf: old}}\n"), historyPhaseSources)
builder.observeDocument(parseDocumentForDecode(t, "shape: [{leaf: new}]\n"), historyPhaseResolution)
base := builder.addAttribution(Origin{Layer: LayerBase}, nil, nil)
base := builder.addAttribution(Origin{Layer: LayerMain}, nil, nil)
oldPath := Keys("shape", "0", "leaf")
newPath := Keys("shape").Index(0).Key("leaf")
definition := builder.nextPayload(historyPhaseSources)
@@ -187,7 +187,7 @@ func TestHistorySelectionMatchesDeepSidesOfAncestorShapeChange(t *testing.T) {
t.Fatalf("new descendant selections = %#v", newSelections)
}
oldSelections := model.selectHistory(oldPath)
if len(oldSelections) != 2 || !oldSelections[1].before || oldSelections[1].after || len(oldSelections[1].previous) != 1 || oldSelections[1].previous[0].Layer != LayerBase {
if len(oldSelections) != 2 || !oldSelections[1].before || oldSelections[1].after || len(oldSelections[1].previous) != 1 || oldSelections[1].previous[0].Layer != LayerMain {
t.Fatalf("removed descendant selections = %#v", oldSelections)
}
if selections := model.selectHistory(Keys("shape").Index(0).Key("missing")); len(selections) != 0 {
@@ -207,7 +207,7 @@ func TestHistoryModelFinalizesLocationAndSensitivityWithoutRetainingInventoryTre
builder := newHistoryBuilder()
builder.observeDocument(root, historyPhaseSources)
definitionAttribution := builder.addAttribution(Origin{
Layer: LayerBase, Locations: []Location{{SourceID: "base.yml", Line: 4, Column: 2}},
Layer: LayerMain, Locations: []Location{{SourceID: "base.yml", Line: 4, Column: 2}},
}, nil, nil)
definition := builder.nextPayload(historyPhaseSources)
builder.addObservation(historyObservation{

View File

@@ -107,7 +107,7 @@ func TestTierSequenceHistoryReplaysSelectedOperation(t *testing.T) {
t.Fatal(diagnostics)
}
assembly := newAssemblyAccumulator(lower)
if diagnostics := assembly.applyOverlayWithCollectionPolicy(higher.root, higher.origins, higher.collectionPolicies, higher.applications, LayerBase, policy, declarations); len(diagnostics) != 0 {
if diagnostics := assembly.applyOverlayWithCollectionPolicy(higher.root, higher.origins, higher.collectionPolicies, higher.applications, LayerMain, policy, declarations); len(diagnostics) != 0 {
t.Fatal(diagnostics)
}
if len(assembly.current.applications) != 3 {
@@ -176,7 +176,7 @@ func TestSequenceHistoryPreservesTierReplacementAndEmptyLists(t *testing.T) {
if diagnostics := assembly.applyOverlay(second.root, second.origins, second.applications, LayerUnderlay); len(diagnostics) != 0 {
t.Fatalf("second tier handoff diagnostics = %#v", diagnostics)
}
if diagnostics := assembly.applyOverlay(main.root, main.origins, main.applications, LayerBase); len(diagnostics) != 0 {
if diagnostics := assembly.applyOverlay(main.root, main.origins, main.applications, LayerMain); len(diagnostics) != 0 {
t.Fatalf("main handoff diagnostics = %#v", diagnostics)
}
if len(assembly.current.applications) != 4 {
@@ -201,7 +201,7 @@ func TestSequenceHistoryPreservesTierReplacementAndEmptyLists(t *testing.T) {
// The same identity may appear in separate tiers, while each tier still
// retains its individual source applications for explanation replay.
if got := []Layer{assembly.current.applications[0].layer, assembly.current.applications[1].layer,
assembly.current.applications[2].layer, assembly.current.applications[3].layer}; !reflect.DeepEqual(got, []Layer{LayerUnderlay, LayerUnderlay, LayerUnderlay, LayerBase}) {
assembly.current.applications[2].layer, assembly.current.applications[3].layer}; !reflect.DeepEqual(got, []Layer{LayerUnderlay, LayerUnderlay, LayerUnderlay, LayerMain}) {
t.Fatalf("application layers = %#v", got)
}
}
@@ -250,14 +250,14 @@ func TestLayeredUpsertExplanationFollowsStructuralOrder(t *testing.T) {
t.Fatal("structural upsert was misreported as a decoding reconciliation")
}
}
if last := explanation.History[len(explanation.History)-1]; last.After.YAML != explanation.Effective.YAML || last.Origin.Layer != LayerBase {
if last := explanation.History[len(explanation.History)-1]; last.After.YAML != explanation.Effective.YAML || last.Origin.Layer != LayerMain {
t.Fatalf("main contribution did not produce the effective collection: %#v", last)
}
removed, ok := loaded.Explain(Keys("records").Index(1).Key("removed"))
if !ok || len(removed.History) == 0 || removed.Effective.Present {
t.Fatalf("missing displaced field history: %#v, %v", removed, ok)
}
if last := removed.History[len(removed.History)-1]; last.After.Present || last.Origin.Layer != LayerBase || last.Origin.Operation == ChangeDecoding {
if last := removed.History[len(removed.History)-1]; last.After.Present || last.Origin.Layer != LayerMain || last.Origin.Operation == ChangeDecoding {
t.Fatalf("upsert removal attribution = %#v", last)
}
}
@@ -650,7 +650,7 @@ func TestHistorySourceSequenceReplacementTracksMappedAndWholeSides(t *testing.T)
finalSequence, _ := documentAtPath(finalRoot, Keys("records"))
*finalSequence = *document.Clone(combined.value)
lowerOrigins := make(map[string]Origin)
collectOverlayOrigins(lowerOrigins, lowerRoot, Path{}, LayerBase)
collectOverlayOrigins(lowerOrigins, lowerRoot, Path{}, LayerMain)
higherOrigins := make(map[string]Origin)
collectOverlayOrigins(higherOrigins, higherRoot, Path{}, LayerOverlay)
assembly := newAssemblyAccumulator(&composedDocument{root: finalRoot, origins: lowerOrigins})
@@ -667,7 +667,7 @@ func TestHistorySourceSequenceReplacementTracksMappedAndWholeSides(t *testing.T)
}
higherApplication.sequencesByPath = indexSequenceHistoryContributions(higherApplication.sequences)
applications := []historyApplication{
{layer: LayerBase, value: lowerRoot}, higherApplication,
{layer: LayerMain, value: lowerRoot}, higherApplication,
}
builder := newHistoryBuilder()
builder.observeSourceEvidence(finalRoot, assembly.current.origins, applications, assembly.current.overlays)
@@ -728,7 +728,7 @@ func TestHistorySourceSequenceReplacementTracksMappedAndWholeSides(t *testing.T)
wholeFinalSequence, _ := documentAtPath(wholeFinal, Keys("records"))
*wholeFinalSequence = *document.Clone(whole.value)
wholeLowerOrigins := make(map[string]Origin)
collectOverlayOrigins(wholeLowerOrigins, wholeLower, Path{}, LayerBase)
collectOverlayOrigins(wholeLowerOrigins, wholeLower, Path{}, LayerMain)
wholeHigherOrigins := make(map[string]Origin)
collectOverlayOrigins(wholeHigherOrigins, wholeHigher, Path{}, LayerOverlay)
wholeAssembly := newAssemblyAccumulator(&composedDocument{root: wholeFinal, origins: wholeLowerOrigins})
@@ -743,7 +743,7 @@ func TestHistorySourceSequenceReplacementTracksMappedAndWholeSides(t *testing.T)
wholeHigherApplication.sequencesByPath = indexSequenceHistoryContributions(wholeHigherApplication.sequences)
wholeBuilder := newHistoryBuilder()
wholeBuilder.observeSourceEvidence(wholeFinal, wholeAssembly.current.origins, []historyApplication{
{layer: LayerBase, value: wholeLower}, wholeHigherApplication,
{layer: LayerMain, value: wholeLower}, wholeHigherApplication,
}, wholeAssembly.current.overlays)
wholeModel := wholeBuilder.freeze()
if len(wholeAssembly.current.overlays) != 1 {

View File

@@ -17,10 +17,10 @@ func TestHistorySourceObservationsPreserveRawAndCompositeDefinitions(t *testing.
setHistoryDocumentSource(overlay, "overlay")
baseOrigins := make(map[string]Origin)
collectOverlayOrigins(baseOrigins, base, Path{}, LayerBase)
collectOverlayOrigins(baseOrigins, base, Path{}, LayerMain)
baseApplication := historyApplication{
layer: LayerBase, value: base,
origin: overlayOrigin(LayerBase, base.Location),
layer: LayerMain, value: base,
origin: overlayOrigin(LayerMain, base.Location),
}
composition := &composedDocument{
root: document.Clone(base), origins: baseOrigins,
@@ -91,7 +91,7 @@ func TestHistorySourceObservationsPreserveRawAndCompositeDefinitions(t *testing.
explanation, explained := inspection.Explain(Keys("section", "empty"))
var contributionSources []string
for _, change := range explanation.History {
if change.Origin.Layer == LayerBase || change.Origin.Layer == LayerOverlay {
if change.Origin.Layer == LayerMain || change.Origin.Layer == LayerOverlay {
contributionSources = append(contributionSources, locationSourceIDs(change.Origin.Locations)...)
}
}
@@ -109,12 +109,12 @@ func TestHistorySourceReplacementTracksConcreteBeforeAndAfterShapes(t *testing.T
setHistoryDocumentSource(base, "base")
setHistoryDocumentSource(overlay, "overlay")
baseOrigins := make(map[string]Origin)
collectOverlayOrigins(baseOrigins, base, Path{}, LayerBase)
collectOverlayOrigins(baseOrigins, base, Path{}, LayerMain)
overlayOrigins := make(map[string]Origin)
collectOverlayOrigins(overlayOrigins, overlay, Path{}, LayerOverlay)
composition := &composedDocument{
root: document.Clone(base), origins: baseOrigins,
applications: []historyApplication{{layer: LayerBase, value: base, origin: overlayOrigin(LayerBase, base.Location)}},
applications: []historyApplication{{layer: LayerMain, value: base, origin: overlayOrigin(LayerMain, base.Location)}},
}
assembly := newAssemblyAccumulator(composition)
if diagnostics := assembly.applyOverlay(overlay, overlayOrigins, []historyApplication{{layer: LayerOverlay, value: overlay, origin: overlayOrigin(LayerOverlay, overlay.Location)}}, LayerOverlay); len(diagnostics) != 0 {
@@ -175,7 +175,7 @@ func TestOverlayReplacementCapturesIntroducedPathOrigins(t *testing.T) {
setHistoryDocumentSource(incoming, "overlay")
path := Keys("section")
origins := make(map[string]Origin)
collectOverlayOrigins(origins, existing, path, LayerBase)
collectOverlayOrigins(origins, existing, path, LayerMain)
incomingOrigins := make(map[string]Origin)
collectOverlayOrigins(incomingOrigins, incoming, path, LayerOverlay)
result := &composedDocument{

View File

@@ -304,7 +304,7 @@ func (s *importTraversal) admitImportSource(canonical string, identity resourceI
kind = SourceKindFilesystem
label = s.access.label + "/" + canonical
}
info := SourceInfo{ID: sourceID, Label: label, Path: canonical, Destination: s.sourceDestination(destination), Layer: LayerBase, Kind: kind, ImportedFrom: &location}
info := SourceInfo{ID: sourceID, Label: label, Path: canonical, Destination: s.sourceDestination(destination), Layer: LayerMain, Kind: kind, ImportedFrom: &location}
if policy.placement == PlacementModeSequenceItem {
info.placementMode = PlacementModeSequenceItem
}

View File

@@ -185,7 +185,7 @@ func TestLoadImportsFromProfilesDirectoryAsBaseInput(t *testing.T) {
result, err := testLoad[importTestConfig](File(mainPath), Options[importTestConfig]{Imports: true})
if err != nil || result.Config.Settings.Root != "imported" || len(result.Sources()) != 2 ||
result.Sources()[1].Layer != LayerBase {
result.Sources()[1].Layer != LayerMain {
t.Fatalf("profiles import = %#v, %v", result, err)
}
}
@@ -573,7 +573,7 @@ func TestProjectNestedEvidenceUsesMappedSequenceItemIndex(t *testing.T) {
}
outer.sequencesByPath = indexSequenceHistoryContributions(outer.sequences)
nestedRoot := parseCompositionDocument(t, "nested-source", "settings: {value: nested}\n")
nestedOrigin := Origin{Layer: LayerBase, Locations: []Location{{SourceID: "nested-source"}}}
nestedOrigin := Origin{Layer: LayerMain, Locations: []Location{{SourceID: "nested-source"}}}
nested := &composedDocument{
root: nestedRoot, applications: []historyApplication{{value: nestedRoot}},
origins: map[string]Origin{"/settings/value": nestedOrigin},

View File

@@ -165,7 +165,7 @@ func TestInheritanceHistoryFollowsFinalParentAfterSourceOverlay(t *testing.T) {
t.Fatalf("overlaid parent contribution = %#v, %v", explanation, found)
}
parentHistory := inspection.Metadata().History(Keys("parent", "value"))
if len(parentHistory) < 2 || parentHistory[0].Origin.Layer != LayerBase ||
if len(parentHistory) < 2 || parentHistory[0].Origin.Layer != LayerMain ||
parentHistory[len(parentHistory)-1].Origin.Layer != LayerOverlay {
t.Fatalf("parent source history = %#v", parentHistory)
}

View File

@@ -12,7 +12,7 @@ func directInheritanceOrigins(node *document.Node, root Path, input map[string]O
walkDocument(node, root, func(path Path, value *document.Node) {
origin, found := input[path.String()]
if !found {
origin = Origin{Layer: LayerBase, Locations: []Location{publicLocation(value.Location)}}
origin = Origin{Layer: LayerMain, Locations: []Location{publicLocation(value.Location)}}
}
origin = cloneOrigin(origin)
if len(origin.contributors) == 0 {

View File

@@ -104,7 +104,7 @@ func TestInheritanceWideIndependentYamlCollectionScopes(t *testing.T) {
t.Fatalf("independent scope %s composed incorrectly: %#v", name, group)
}
path := Keys("groups", name, "child", "items").Index(0).Key("value")
if info, exists := metadata.Lookup(path); !exists || !info.Explicit || info.Origin.Layer != LayerBase {
if info, exists := metadata.Lookup(path); !exists || !info.Explicit || info.Origin.Layer != LayerMain {
t.Fatalf("inherited destination lost source metadata at %s", path)
}
}

View File

@@ -375,7 +375,7 @@ func TestOverlaySequenceTransfersIncomingItemPolicyOwnership(t *testing.T) {
root: lowerRoot, collectionPolicies: makePolicies("id"), origins: make(map[string]Origin),
})
if diagnostics := assembly.applyOverlayWithCollectionPolicy(
incomingRoot, nil, makePolicies("slug"), nil, LayerBase, registered, test.declarations,
incomingRoot, nil, makePolicies("slug"), nil, LayerMain, registered, test.declarations,
); len(diagnostics) != 0 {
t.Fatalf("overlay diagnostics = %#v", diagnostics)
}
@@ -412,7 +412,7 @@ func TestAncestorReplacementRequiresIdentityWhenRetainedModeReturns(t *testing.T
t.Helper()
if diagnostics := assembly.applyOverlayWithCollectionPolicy(
parseItemPolicyDocument(t, "remove", "catalog: null\n"), nil, collectionPolicyScope{}, nil,
LayerBase, sequencePolicy{}, nil,
LayerMain, sequencePolicy{}, nil,
); len(diagnostics) != 0 {
t.Fatalf("ancestor removal diagnostics = %#v", diagnostics)
}
@@ -427,7 +427,7 @@ func TestAncestorReplacementRequiresIdentityWhenRetainedModeReturns(t *testing.T
}
diagnostics := assembly.applyOverlayWithCollectionPolicy(
parseItemPolicyDocument(t, "reintroduction", "catalog:\n prompts: [{id: restored, name: restored}]\n"), nil,
collectionPolicyScope{}, nil, LayerBase, sequencePolicy{}, nil,
collectionPolicyScope{}, nil, LayerMain, sequencePolicy{}, nil,
)
if len(diagnostics) != 1 || diagnostics[0].Code != CodeSequenceInvalid {
t.Fatalf("append without renewed identity diagnostics = %#v", diagnostics)
@@ -442,7 +442,7 @@ func TestAncestorReplacementRequiresIdentityWhenRetainedModeReturns(t *testing.T
}
diagnostics := assembly.applyOverlayWithCollectionPolicy(
parseItemPolicyDocument(t, "keyed", "catalog:\n prompts: [{name: next}]\n"), nil,
collectionPolicyScope{}, nil, LayerBase, sequencePolicy{}, []sequenceDeclarationSpec{declaration},
collectionPolicyScope{}, nil, LayerMain, sequencePolicy{}, []sequenceDeclarationSpec{declaration},
)
if len(diagnostics) != 0 {
t.Fatalf("renewed identity diagnostics = %#v", diagnostics)

View File

@@ -132,7 +132,7 @@ func applyInputLayers(source Source, filesystem *FilesystemContext, overlay stri
func completeOrdinaryResourceContexts(input assembledInput, main loadInput) (assembledInput, []Diagnostic) {
baseSources := make([]SourceInfo, 0, len(input.sources))
for _, source := range input.sources {
if source.Layer == LayerBase {
if source.Layer == LayerMain {
baseSources = append(baseSources, source)
}
}

View File

@@ -152,7 +152,7 @@ func assembleLayeredInput[T any](request loadRequest[T], input assembledInput, p
if mainComposition != nil {
input.versionState.locateMainVersion(mainComposition.root)
operations, diagnostics := applyCompletedTier(
&assembly, mainComposition, mainComposition.collectionPolicies, LayerBase, policy.sequencePolicy,
&assembly, mainComposition, mainComposition.collectionPolicies, LayerMain, policy.sequencePolicy,
input.sources[:mainSourceCount], mainEvidence,
)
if len(diagnostics) != 0 {

View File

@@ -294,7 +294,7 @@ func TestGroupedLoadPrecedenceSourceOrderAndSingleLifecycle(t *testing.T) {
if len(sources) != 7 {
t.Fatalf("sources = %#v", sources)
}
wantLayers := []Layer{LayerBase, LayerBase, LayerUnderlay, LayerUnderlay, LayerUnderlay, LayerOverlay, LayerCLI}
wantLayers := []Layer{LayerMain, LayerMain, LayerUnderlay, LayerUnderlay, LayerUnderlay, LayerOverlay, LayerCLI}
wantIndexes := []int{0, 0, 1, 1, 2, 0, 0}
for index, source := range sources {
if source.ID != "source-"+string(rune('1'+index)) || source.Layer != wantLayers[index] || source.UnderlayIndex != wantIndexes[index] {
@@ -315,7 +315,7 @@ func TestGroupedLoadPrecedenceSourceOrderAndSingleLifecycle(t *testing.T) {
layers = append(layers, change.Origin.Layer)
}
}
if !reflect.DeepEqual(layers, []Layer{LayerUnderlay, LayerBase, LayerOverlay, LayerCLI}) {
if !reflect.DeepEqual(layers, []Layer{LayerUnderlay, LayerMain, LayerOverlay, LayerCLI}) {
t.Fatalf("history layers = %#v", layers)
}
}

View File

@@ -523,17 +523,17 @@ func TestLoadMetadataReflectsDefaultsInputAndDetachedRecords(t *testing.T) {
t.Fatalf("kept = %#v, %v", kept, ok)
}
set, ok := metadata.Lookup(Keys("nested", "set"))
if !ok || !set.Explicit || set.Origin.Layer != LayerBase || len(set.Origin.Locations) != 1 {
if !ok || !set.Explicit || set.Origin.Layer != LayerMain || len(set.Origin.Locations) != 1 {
t.Fatalf("set = %#v, %v", set, ok)
}
nullable, ok := metadata.Lookup(Keys("nullable"))
if !ok || !nullable.Explicit || !nullable.Null || nullable.Origin.Layer != LayerBase {
if !ok || !nullable.Explicit || !nullable.Null || nullable.Origin.Layer != LayerMain {
t.Fatalf("nullable = %#v, %v", nullable, ok)
}
if metadata.IsExplicit(Keys("nested", "kept")) || !metadata.IsExplicit(Keys("nested", "set")) {
t.Fatal("explicit presence disagrees with lookup")
}
if history := metadata.History(Keys("nested", "set")); len(history) != 2 || history[0].Origin.Layer != LayerDefault || history[1].Origin.Layer != LayerBase || len(history[1].Previous) != 1 {
if history := metadata.History(Keys("nested", "set")); len(history) != 2 || history[0].Origin.Layer != LayerDefault || history[1].Origin.Layer != LayerMain || len(history[1].Previous) != 1 {
t.Fatalf("history = %#v", history)
}

View File

@@ -117,7 +117,7 @@ func TestHistoricalLocationSelectionSeparatesNumericKeyAndIndex(t *testing.T) {
}}}
builder := newHistoryBuilder()
builder.observeSourceEvidence(sequenceRoot, nil, []historyApplication{
{layer: LayerBase, value: mappingRoot},
{layer: LayerMain, value: mappingRoot},
{layer: LayerOverlay, value: sequenceRoot},
}, nil)
model := builder.freeze()

View File

@@ -146,7 +146,7 @@ func TestHistoricalPathsExposeHiddenBaseOwnershipWithoutResolvingBaseSecrets(t *
found = true
owners := map[string]bool{}
for _, change := range metadata.History(path) {
if change.Origin.Layer == LayerBase {
if change.Origin.Layer == LayerMain {
for _, location := range change.Origin.Locations {
owners[location.SourceID] = true
}
@@ -188,7 +188,7 @@ func TestMetadataQueriesReturnDetachedRecords(t *testing.T) {
path.String(): {
Explicit: true,
Origin: Origin{
Layer: LayerBase,
Layer: LayerMain,
Locations: []Location{{SourceID: "source-1", Line: 2, Column: 3}},
},
},
@@ -246,7 +246,7 @@ func TestResolutionInputKeepsDetachedEntryMetadata(t *testing.T) {
}
metadata := metadataFromDecoded(decoded)
input := newResolutionInput(metadata, decoded.final, []SourceInfo{{
ID: "source-1", Label: "decode.yml", Layer: LayerBase,
ID: "source-1", Label: "decode.yml", Layer: LayerMain,
ImportedFrom: &Location{SourceID: "parent", Line: 1, Column: 1},
}})

View File

@@ -146,7 +146,7 @@ func structuralHistoryApplications(input assembledInput) []historyApplication {
if input.document == nil {
return nil
}
return []historyApplication{{layer: LayerBase, value: input.document}}
return []historyApplication{{layer: LayerMain, value: input.document}}
}
// documentWithMetadataLocations attaches effective origin coordinates to a

View File

@@ -33,7 +33,7 @@ func TestPostDecodeOverrideContextOrdersDecodeCLIAndResolutionEvidence(t *testin
if len(issues) != 0 {
t.Fatalf("decodeConfigurationWithContext() issues = %#v", issues)
}
sources := []SourceInfo{{ID: "source-1", Label: "main input", Layer: LayerBase, Kind: SourceKindMapping}}
sources := []SourceInfo{{ID: "source-1", Label: "main input", Layer: LayerMain, Kind: SourceKindMapping}}
contexts := map[string]ResourceContext{"source-1": {BaseDir: "/config"}}
input := assembledInput{document: structural, sources: sources, contexts: contexts}
batch, diagnostics := preparePostStructuralOverrides(overridePreparationInput{root: structural}, sources, []Override{
@@ -114,7 +114,7 @@ func TestPostDecodeOverrideContextOrdersDecodeCLIAndResolutionEvidence(t *testin
t.Fatal("Explain(rate) did not return a history")
}
if len(rateExplanation.History) != 4 || rateExplanation.History[0].Origin.Layer != LayerDefault ||
rateExplanation.History[1].Origin.Layer != LayerBase || rateExplanation.History[2].Origin.Operation != ChangeDecoding ||
rateExplanation.History[1].Origin.Layer != LayerMain || rateExplanation.History[2].Origin.Operation != ChangeDecoding ||
rateExplanation.History[3].Origin.Layer != LayerCLI {
t.Fatalf("rate history order = %#v", rateExplanation.History)
}

View File

@@ -62,7 +62,7 @@ func TestCLIHistoryFollowsInheritanceAndPrecedesResolution(t *testing.T) {
t.Fatal("inheritance reported after CLI")
}
inherited = true
} else if change.Origin.Layer == LayerBase && cli {
} else if change.Origin.Layer == LayerMain && cli {
t.Fatal("source definition reappeared after CLI")
}
if change.Origin.Layer == LayerCLI {

View File

@@ -29,7 +29,7 @@ func TestNestedCLIOverridePreservesRetainedInputPresence(t *testing.T) {
definition := Definition[config]{Resolve: func(value *config, resolution *Resolution) error {
for _, key := range []string{"count", "zero", "enabled"} {
info, ok := resolution.InputInfo(Keys("settings", "nested", key))
if !ok || !info.Explicit || info.Origin.Layer != LayerBase {
if !ok || !info.Explicit || info.Origin.Layer != LayerMain {
t.Errorf("retained %s input info = %#v, %v", key, info, ok)
}
}
@@ -54,7 +54,7 @@ func TestNestedCLIOverridePreservesRetainedInputPresence(t *testing.T) {
}
for _, key := range []string{"count", "zero", "enabled"} {
info, ok := result.Metadata().Lookup(Keys("settings", "nested", key))
if !ok || !info.Explicit || info.Origin.Layer != LayerBase || len(info.Origin.Locations) != 1 || info.Origin.Locations[0].SourceID != "source-1" {
if !ok || !info.Explicit || info.Origin.Layer != LayerMain || len(info.Origin.Locations) != 1 || info.Origin.Locations[0].SourceID != "source-1" {
t.Errorf("retained %s metadata = %#v, %v", key, info, ok)
}
}
@@ -112,7 +112,7 @@ func TestPostDecodeOverrideLifecycleMatchesOrdinaryAndLayeredLoads(t *testing.T)
if result.Config.Count != 5 || result.Config.Derived != 8 {
t.Errorf("%s resolved configuration = %#v", name, result.Config)
}
if got := historyLayers(result.Metadata().History(Keys("count"))); !reflect.DeepEqual(got, []Layer{LayerDefault, LayerBase, LayerCLI, LayerResolution}) {
if got := historyLayers(result.Metadata().History(Keys("count"))); !reflect.DeepEqual(got, []Layer{LayerDefault, LayerMain, LayerCLI, LayerResolution}) {
t.Errorf("%s count history layers = %#v", name, got)
}
info, ok := result.Metadata().Lookup(Keys("count"))

View File

@@ -52,12 +52,12 @@ func TestBroadPartialCLIOverrideRetainsUnchangedMetadata(t *testing.T) {
value := result.value.Interface().(config).Records[name]
for _, key := range []string{"zero", "enabled"} {
pointer := path.Key(key).String()
if _, explicit := result.presence[pointer]; !explicit || result.origins[pointer].Layer != LayerBase {
if _, explicit := result.presence[pointer]; !explicit || result.origins[pointer].Layer != LayerMain {
t.Fatalf("retained explicit field lost metadata at %s", pointer)
}
}
if index%2 != 0 {
if value.Count != 9 || len(value.Items) != 1 || value.Maybe == nil || result.origins[path.Key("count").String()].Layer != LayerBase {
if value.Count != 9 || len(value.Items) != 1 || value.Maybe == nil || result.origins[path.Key("count").String()].Layer != LayerMain {
t.Fatalf("omitted record changed at %s", path)
}
continue

View File

@@ -95,7 +95,7 @@ func TestOverridesRunAtHighestInputPrecedenceBeforeResolutionAndValidation(t *te
t.Fatalf("effective settings = %#v", result.Config.Settings)
}
sources := result.Sources()
if len(sources) != 3+len(overrides) || sources[0].Layer != LayerBase || sources[1].Layer != LayerBase || sources[2].Layer != LayerOverlay {
if len(sources) != 3+len(overrides) || sources[0].Layer != LayerMain || sources[1].Layer != LayerMain || sources[2].Layer != LayerOverlay {
t.Fatalf("sources = %#v", sources)
}
for index, override := range overrides {
@@ -104,7 +104,7 @@ func TestOverridesRunAtHighestInputPrecedenceBeforeResolutionAndValidation(t *te
}
}
history := result.Metadata().History(Keys("settings", "target"))
wantLayers := []Layer{LayerDefault, LayerBase, LayerOverlay, LayerCLI, LayerResolution}
wantLayers := []Layer{LayerDefault, LayerMain, LayerOverlay, LayerCLI, LayerResolution}
if got := historyLayers(history); !reflect.DeepEqual(got, wantLayers) {
t.Fatalf("target history layers = %#v, want %#v; history %#v", got, wantLayers, history)
}
@@ -392,7 +392,7 @@ func TestOverrideEqualReplacementStillAppearsInHistory(t *testing.T) {
if err != nil {
t.Fatal(err)
}
if got := historyLayers(result.Metadata().History(Keys("value"))); !reflect.DeepEqual(got, []Layer{LayerDefault, LayerBase, LayerCLI}) {
if got := historyLayers(result.Metadata().History(Keys("value"))); !reflect.DeepEqual(got, []Layer{LayerDefault, LayerMain, LayerCLI}) {
t.Fatalf("equal override history = %#v", result.Metadata().History(Keys("value")))
}
}
@@ -453,7 +453,7 @@ func TestPreparedOverrideBatchDetachesInputsAndAllocatesSourcesInOrder(t *testin
if len(diagnostics) != 0 {
t.Fatal(diagnostics)
}
sources := []SourceInfo{{ID: "source-1", Label: "base", Layer: LayerBase, Kind: SourceKindMapping}}
sources := []SourceInfo{{ID: "source-1", Label: "base", Layer: LayerMain, Kind: SourceKindMapping}}
firstValue := map[string]any{"nested": map[string]any{"name": "original"}}
secondValue := []any{map[string]any{"enabled": true}}
batch, diagnostics := preparePostStructuralOverrides(overridePreparationInput{
@@ -630,7 +630,7 @@ func TestApplyDecodedOverridesUsesSchemaAndPreservesTypedOwnership(t *testing.T)
}
if result.presence["/items/0/name"].location.SourceID != batch.overrides[2].source.ID ||
result.presence["/nested"].location.SourceID != "source-1" ||
result.origins["/items/0/name"].Layer != LayerCLI || result.origins["/nested/name"].Layer != LayerBase ||
result.origins["/items/0/name"].Layer != LayerCLI || result.origins["/nested/name"].Layer != LayerMain ||
result.origins["/nested/enabled"].Layer != LayerCLI || result.origins["/labels/default/name"].Layer != LayerDefault {
t.Fatalf("presence/origins = %#v / %#v", result.presence, result.origins)
}

View File

@@ -99,7 +99,7 @@ empty: {}
nullable, _ := metadata.Lookup(Keys("nullable"))
empty, _ := metadata.Lookup(Keys("empty"))
firstValue, _ := metadata.Lookup(Keys("values").Index(0))
if !equal.Explicit || equal.Origin.Layer != LayerBase || derived.Explicit || derived.Origin.Operation != ChangeDerivedDefault ||
if !equal.Explicit || equal.Origin.Layer != LayerMain || derived.Explicit || derived.Origin.Operation != ChangeDerivedDefault ||
!nullable.Explicit || !nullable.Null || nullable.Origin.Layer != LayerOverlay ||
!empty.Explicit || empty.Origin.Layer != LayerOverlay || len(empty.Origin.Locations) != 2 ||
!firstValue.Explicit || firstValue.Origin.Operation != ChangeNormalization {
@@ -116,14 +116,14 @@ empty: {}
}
assertHistoryLayersAndPaths(t, metadata.History(Keys("values").Index(1)),
[]Layer{LayerDefault, LayerBase, LayerOverlay, LayerResolution},
[]Layer{LayerDefault, LayerMain, LayerOverlay, LayerResolution},
[]string{"/values/1", "/values/1", "/values", "/values"})
assertHistoryLayersAndPaths(t, metadata.History(Keys("value", "child")),
[]Layer{LayerDefault, LayerBase, LayerOverlay},
[]Layer{LayerDefault, LayerMain, LayerOverlay},
[]string{"/value/child", "/value/child", "/value"})
removedHistory := metadata.History(Keys("items", "remove", "value"))
assertHistoryLayersAndPaths(t, removedHistory,
[]Layer{LayerBase, LayerResolution},
[]Layer{LayerMain, LayerResolution},
[]string{"/items/remove/value", "/items"})
if !reflect.DeepEqual(removedHistory[1].Reasons, []string{"removed disabled items"}) {
t.Fatalf("removed history = %#v", removedHistory)

View File

@@ -5,7 +5,7 @@ type Layer string
const (
LayerDefault Layer = "default"
LayerBase Layer = "base"
LayerMain Layer = "main"
LayerUnderlay Layer = "underlay"
LayerOverlay Layer = "overlay"
LayerCLI Layer = "cli"

View File

@@ -208,7 +208,7 @@ func TestDocumentLookupMatchesPathScan(t *testing.T) {
}
func TestApplyResolutionMetadataPreservesOverlappingDeltaOrder(t *testing.T) {
oldOrigin := Origin{Layer: LayerBase}
oldOrigin := Origin{Layer: LayerMain}
parentOrigin := Origin{Layer: LayerResolution, Operation: ChangeNormalization}
childOrigin := Origin{Layer: LayerResolution, Operation: ChangeDerivedDefault}
beforeLeaf := &document.Node{Kind: document.String, Text: "before"}

View File

@@ -153,7 +153,7 @@ value: scalar
}
changed, _ := result.Metadata().Lookup(Keys("settings", "changed"))
kept, _ := result.Metadata().Lookup(Keys("settings", "kept"))
if changed.Origin.Layer != LayerOverlay || changed.Origin.Locations[0].SourceID != "source-3" || kept.Origin.Layer != LayerBase {
if changed.Origin.Layer != LayerOverlay || changed.Origin.Locations[0].SourceID != "source-3" || kept.Origin.Layer != LayerMain {
t.Fatalf("origins = changed %#v kept %#v", changed, kept)
}
if _, ok := result.Metadata().Lookup(Keys("value", "child")); ok {
@@ -248,7 +248,7 @@ items: [{id: c, value: replacement}]
if test.mode == "append" {
base, _ := result.Metadata().Lookup(Keys("items").Index(0).Key("value"))
added, _ := result.Metadata().Lookup(Keys("items").Index(2).Key("value"))
if base.Origin.Layer != LayerBase || added.Origin.Layer != LayerOverlay {
if base.Origin.Layer != LayerMain || added.Origin.Layer != LayerOverlay {
t.Fatalf("append origins = base %#v added %#v", base.Origin, added.Origin)
}
history := result.Metadata().History(Keys("items").Index(2).Key("value"))

View File

@@ -222,7 +222,7 @@ func readSource(source Source, sourceID string, limits sourceLimits) (sourceRead
if limit < 0 {
limit = 0
}
info := &SourceInfo{ID: sourceID, Label: source.label, Layer: LayerBase, Kind: sourceSourceKind(source.kind)}
info := &SourceInfo{ID: sourceID, Label: source.label, Layer: LayerMain, Kind: sourceSourceKind(source.kind)}
var input io.Reader
switch source.kind {
@@ -285,7 +285,7 @@ func mappingSourceInfo(source Source, sourceID string) *SourceInfo {
if !validOverrideLabel(label) {
label = "mapping"
}
return &SourceInfo{ID: sourceID, Label: label, Layer: LayerBase, Kind: SourceKindMapping}
return &SourceInfo{ID: sourceID, Label: label, Layer: LayerMain, Kind: SourceKindMapping}
}
func sourceConstructorDiagnostic(source Source) *Diagnostic {

View File

@@ -208,7 +208,7 @@ func TestCompleteSingleSourceLifecycleKeepsMetadataAgreement(t *testing.T) {
input, _ := result.Metadata().Lookup(Keys("input"))
derived, _ := result.Metadata().Lookup(Keys("derived"))
history := result.Metadata().History(Keys("derived"))
if result.Config != (config{Input: 3, Derived: 6}) || !input.Explicit || input.Origin.Layer != LayerBase || derived.Explicit || derived.Origin.Operation != ChangeDerivedDefault || history[len(history)-1].Dependencies[0].String() != "/input" {
if result.Config != (config{Input: 3, Derived: 6}) || !input.Explicit || input.Origin.Layer != LayerMain || derived.Explicit || derived.Origin.Operation != ChangeDerivedDefault || history[len(history)-1].Dependencies[0].String() != "/input" {
t.Fatalf("config/metadata = %#v / %#v / %#v / %#v", result.Config, input, derived, history)
}
}

View File

@@ -5,7 +5,7 @@ type Layer string
const (
LayerDefault Layer = "default"
LayerBase Layer = "base"
LayerMain Layer = "main"
LayerUnderlay Layer = "underlay"
LayerOverlay Layer = "overlay"
LayerCLI Layer = "cli"

View File

@@ -8,6 +8,12 @@ import (
"gitea.maximumdirect.net/eric/ConfigKit/internal/engine"
)
func TestLayerMainString(t *testing.T) {
if got := string(LayerMain); got != "main" {
t.Fatalf("main layer string = %q", got)
}
}
func TestOverlayPublicValues(t *testing.T) {
if LayerOverlay != "overlay" {
t.Fatalf("LayerOverlay = %q", LayerOverlay)