Move item registry reconciliation into shared operations

This commit is contained in:
2026-11-25 15:57:33 +00:00
parent bbb667b9b2
commit dc198cfc0c
4 changed files with 117 additions and 147 deletions

View File

@@ -30,9 +30,6 @@ func TestModuleContractAndNativeDependencies(t *testing.T) {
if err := Register(registry); err != nil {
t.Fatal(err)
}
if _, err := New(nil, Options{}); err == nil {
t.Fatal("New() accepted nil native engine")
}
got := ModuleSpec()
got.Prompts[0] = "caller mutation"
if !reflect.DeepEqual(ModuleSpec(), want) {
@@ -427,7 +424,12 @@ func (c *recordingNormalizerClient) Generate(ctx context.Context, request prompt
return &promptkit.GenerateResponse{Content: response}, nil
}
func newNormalizer(t *testing.T, client promptkit.LLMClient) *Normalizer {
type normalizerFixture struct {
*Normalizer
engine *promptkit.Engine
}
func newNormalizer(t *testing.T, client promptkit.LLMClient) *normalizerFixture {
t.Helper()
type settings struct {
PromptKit promptkit.Settings `yaml:"promptkit"`
@@ -451,11 +453,20 @@ func newNormalizer(t *testing.T, client promptkit.LLMClient) *Normalizer {
if err != nil {
t.Fatal(err)
}
normalizer, err := New(engine, Options{})
normalizer, err := New(Options{})
if err != nil {
t.Fatal(err)
}
return normalizer
return &normalizerFixture{Normalizer: normalizer, engine: engine}
}
func (fixture *normalizerFixture) Normalize(ctx context.Context, req contracts.TypedNormalizeRequest[dnd.ItemRegistry]) (pipeline.OperationResult[dnd.ItemRegistry], error) {
op := req.Operation
execution := pipeline.ExecutionContext[dnd.ItemRegistry]{Engine: fixture.engine, Controls: op.Controls, Assess: op.Assess, Execution: op.Execution, ReuseEligible: op.ReuseEligible, Cache: op.Cache}
input := contracts.NormalizeInput[dnd.ItemRegistry]{Source: req.Source, LaneID: req.LaneID, MergeOutput: req.MergeOutput, SourceInput: req.SourceInput, SessionID: req.SessionID, References: req.References, LLMProfile: req.LLMProfile, Metadata: req.Metadata}
return pipeline.ExecuteOperation(ctx, execution, func(ctx context.Context) (contracts.PreparedOperation[dnd.ItemRegistry], error) {
return fixture.Normalizer.PrepareNormalize(ctx, input)
})
}
func renderedInput(t *testing.T, request promptkit.GenerateRequest, name string) []byte {