Share a source index across each pipeline run

This commit is contained in:
2026-11-26 01:34:51 +00:00
parent 4b03a439cb
commit 6345727601
10 changed files with 127 additions and 13 deletions

View File

@@ -197,6 +197,35 @@ func TestTypedCacheDecodeUsesCodecAndCurrentSourceWithoutSemanticAssessment(t *t
}
}
func TestTypedCacheDecodeUsesCurrentSourceLayout(t *testing.T) {
_, store := filesystemProducerCache(t)
registry := NewArtifactCodecRegistry()
mustRegisterArtifactCodec(t, registry, notesCodec())
entry, _, err := registry.entry("test/notes")
if err != nil {
t.Fatal(err)
}
typed := &preparedTypedLane{codec: entry, cacheEvidence: func(any) ([]source.SourceRef, error) {
return []source.SourceRef{{SourceID: "source", StartUnitID: 1, EndUnitID: 2}}, nil
}}
for _, reversed := range []bool{false, true} {
doc := typedTestDocumentWithUnits(2)
if reversed {
doc.Units[0], doc.Units[1] = doc.Units[1], doc.Units[0]
}
index := source.NewDocumentIndex(doc)
for _, supplied := range []*source.DocumentIndex{nil, &index} {
var warnings []contracts.ProducerDiagnostic
cache := artifactProducerCache(RunInput{Cache: store, sourceIndex: supplied}, typed, contracts.ExecutionClassLLMBacked,
contracts.DiagnosticOrigin{}, doc, nil, &warnings)
_, err := cache.Decode([]byte(`{"items":[]}`))
if (err != nil) != reversed {
t.Fatalf("reversed=%t supplied=%t: decode error = %v", reversed, supplied != nil, err)
}
}
}
}
func TestProducerCacheCancellationDuringHitCannotDeliverAcceptance(t *testing.T) {
_, store := filesystemProducerCache(t)
engine := nativeProducerEngine(t, producerClientFunc(func(context.Context, promptkit.GenerateRequest) (*promptkit.GenerateResponse, error) {