Route merge and normalization through core with domain migrations pending

This commit is contained in:
2026-11-25 15:30:04 +00:00
parent ccecf13a4c
commit 8240566281
20 changed files with 173 additions and 177 deletions

View File

@@ -75,22 +75,20 @@ func (p *runnerNotesProducer) PrepareExtraction(ctx context.Context, request con
return p.fallback(ctx, "extract")
}}, nil
}
func (p *runnerNotesProducer) Merge(ctx context.Context, request contracts.TypedMergeRequest[codecNotes]) (contracts.TypedMergeResult[codecNotes], error) {
p.probe.record(p.name+"/merge", request.Operation.ReuseEligible)
if p.references {
if slot, ok := request.References.Slots["context"]; ok && len(slot.Items) > 0 {
p.probe.record(p.name+"/reference", request.Operation.ReuseEligible)
}
}
func (p *runnerNotesProducer) PrepareMerge(ctx context.Context, request contracts.MergeInput[codecNotes]) (contracts.PreparedOperation[codecNotes], error) {
value := codecNotes{Items: []string{}}
for _, output := range request.ExtractOutputs {
value.Items = append(value.Items, output.Value.Items...)
}
return contracts.TypedMergeResult[codecNotes]{Value: value, Fallback: func(ctx context.Context) (codecNotes, error) { return p.fallback(ctx, "merge") }}, nil
return contracts.DeterministicOperation[codecNotes]{Evaluation: contracts.CandidateEvaluation[codecNotes]{Result: contracts.EvaluationView[codecNotes]{Candidate: &value}}, Fallback: func(ctx context.Context, _ contracts.Evaluation[codecNotes]) (codecNotes, error) {
return p.fallback(ctx, "merge")
}}, nil
}
func (p *runnerNotesProducer) Normalize(ctx context.Context, request contracts.TypedNormalizeRequest[codecNotes]) (contracts.TypedNormalizeResult[codecNotes], error) {
p.probe.record(p.name+"/normalize", request.Operation.ReuseEligible)
return contracts.TypedNormalizeResult[codecNotes]{Value: request.MergeOutput.Value, Fallback: func(ctx context.Context) (codecNotes, error) { return p.fallback(ctx, "normalize") }}, nil
func (p *runnerNotesProducer) PrepareNormalize(ctx context.Context, request contracts.NormalizeInput[codecNotes]) (contracts.PreparedOperation[codecNotes], error) {
value := request.MergeOutput.Value
return contracts.DeterministicOperation[codecNotes]{Evaluation: contracts.CandidateEvaluation[codecNotes]{Result: contracts.EvaluationView[codecNotes]{Candidate: &value}}, Fallback: func(ctx context.Context, _ contracts.Evaluation[codecNotes]) (codecNotes, error) {
return p.fallback(ctx, "normalize")
}}, nil
}
func registerRunnerNotes(t *testing.T, catalog ModuleCatalog, producer runnerNotesProducer) ArtifactLaneProfile {
@@ -120,9 +118,27 @@ func registerRunnerNotes(t *testing.T, catalog ModuleCatalog, producer runnerNot
if err := RegisterMerger(catalog.Mergers, spec(StageMerge), func() (contracts.Merger[codecNotes], error) { copy := producer; return &copy, nil }); err != nil {
t.Fatal(err)
}
mergerKey := artifactVariantKey{module: producer.name, kind: "test/notes"}
merger := catalog.Mergers.typedEntries[mergerKey]
merge := merger.merge
merger.merge = func(ctx context.Context, module any, input contracts.MergeInput[any], execution ExecutionContext[any]) (erasedTypedResult, error) {
producer.probe.record(producer.name+"/merge", execution.ReuseEligible)
if slot, ok := input.References.Slots["context"]; producer.references && ok && len(slot.Items) > 0 {
producer.probe.record(producer.name+"/reference", execution.ReuseEligible)
}
return merge(ctx, module, input, execution)
}
catalog.Mergers.typedEntries[mergerKey] = merger
if err := RegisterNormalizer(catalog.Normalizers, spec(StageNormalize), func() (contracts.Normalizer[codecNotes], error) { copy := producer; return &copy, nil }); err != nil {
t.Fatal(err)
}
normalizer := catalog.Normalizers.typedEntries[mergerKey]
normalize := normalizer.normalize
normalizer.normalize = func(ctx context.Context, module any, input contracts.NormalizeInput[any], execution ExecutionContext[any]) (erasedTypedResult, error) {
producer.probe.record(producer.name+"/normalize", execution.ReuseEligible)
return normalize(ctx, module, input, execution)
}
catalog.Normalizers.typedEntries[mergerKey] = normalizer
return ArtifactLaneProfile{Extract: Binding(producer.name), Merge: Binding(producer.name), Normalize: Binding(producer.name)}
}