Integrate history prefixes into load handoffs

This commit is contained in:
2026-10-26 17:15:30 +00:00
parent 738c8a9cc7
commit 408dd13c24
7 changed files with 200 additions and 20 deletions

View File

@@ -50,6 +50,12 @@ func TestPostDecodeOverrideContextOrdersDecodeCLIAndResolutionEvidence(t *testin
t.Fatalf("applyDecodedOverrides() issues = %#v", issues)
}
prepared := preparePostDecodeOverrideContext(input, decoded, assigned)
if prepared.historyBuilder == nil || prepared.historyBuilder != prepared.metadata.historyBuilder || !prepared.historyBuilder.prefixReady {
t.Fatal("post-decode handoff did not retain the completed history prefix")
}
if prepared.resolution.metadata.historyBuilder != nil || prepared.resolution.metadata.historyModel != nil {
t.Fatal("resolution entry view borrowed mutable or historical state")
}
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")
@@ -78,11 +84,37 @@ func TestPostDecodeOverrideContextOrdersDecodeCLIAndResolutionEvidence(t *testin
if info, ok := prepared.resolution.lookup(Keys("count")); !ok || !info.Explicit || info.Origin.Layer != LayerCLI {
t.Fatalf("resolution entry count = %#v, %v", info, ok)
}
countSource := batch.overrides[1].source.ID
if location, ok := metadataFieldLocation(prepared.metadata, Keys("count"), Origin{Layer: LayerDefault}); !ok || location.SourceID != countSource {
t.Fatalf("pre-resolution historical location = %#v, %v", location, ok)
}
cliSource := batch.overrides[3].source.ID
if source, ok := prepared.resolution.source(cliSource); !ok || source.Layer != LayerCLI || source.Label != "--api-key" {
t.Fatalf("resolution CLI source = %#v, %v", source, ok)
}
resolvedContext, resolveDiagnostics := resolveLoadInput(schema, Definition[config]{Resolve: func(value *config, resolution *Resolution) error {
value.Count = 6
resolution.Record(Keys("count"), ChangeNormalization, "normalize count")
return nil
}}, input, preparePostDecodeOverrideContext(input, decoded, assigned))
if len(resolveDiagnostics) != 0 {
t.Fatalf("resolveLoadInput() diagnostics = %#v", resolveDiagnostics)
}
if resolvedContext.historyBuilder == nil || resolvedContext.historyBuilder != resolvedContext.metadata.historyBuilder ||
resolvedContext.historyBuilder.model.resolutionPayload == nil || len(resolvedContext.historyBuilder.model.resolutionPayload.snapshots) != 1 {
t.Fatal("resolution evidence was not appended once to the handed-off model")
}
if location, ok := metadataFieldLocation(resolvedContext.metadata, Keys("count"), Origin{Layer: LayerResolution}); !ok || location.SourceID != countSource {
t.Fatalf("post-resolution historical location = %#v, %v", location, ok)
}
if info, ok := prepared.resolution.lookup(Keys("count")); !ok || !info.Explicit || info.Origin.Layer != LayerCLI {
t.Fatalf("resolution entry view changed after resolution: %#v, %v", info, ok)
}
if value, ok := documentAtPath(resolvedContext.referenceInput, Keys("count")); !ok || value.Location.SourceID != countSource {
t.Fatalf("post-resolution reference location = %#v, %v", value, ok)
}
finalizeMetadataPaths(&prepared.metadata, assigned.final, prepared.historyApplications(), decoded.baseline, prepared.structuralInput, prepared.preCLI, assigned.final)
inspection := Inspection{
metadata: prepared.metadata, baseline: decoded.baseline, input: assigned.final, inputOrigins: assigned.origins,