Complete source index reuse across extractors
This commit is contained in:
@@ -107,6 +107,10 @@ or unresolvable citations remain detectable, not silently repaired.
|
|||||||
Campaign references and generated context can disambiguate or route work, never
|
Campaign references and generated context can disambiguate or route work, never
|
||||||
supply new source evidence.
|
supply new source evidence.
|
||||||
|
|
||||||
|
Extraction borrows the run's whole-source index for source ordering, grounding,
|
||||||
|
and scene fallback; standalone calls construct a local index when none is supplied.
|
||||||
|
See [Module Internals](modules.md#preparing-operations) for its ownership boundary.
|
||||||
|
|
||||||
Typed chains retain separate structural, source, identity/domain, durable-schema,
|
Typed chains retain separate structural, source, identity/domain, durable-schema,
|
||||||
and advisory responsibilities; [Configuration](../config.md#production-validator-keys-and-default-chains)
|
and advisory responsibilities; [Configuration](../config.md#production-validator-keys-and-default-chains)
|
||||||
owns their order and replacement rules. Extraction containment requires the
|
owns their order and replacement rules. Extraction containment requires the
|
||||||
|
|||||||
@@ -20,8 +20,8 @@ The [Core And Integration API Roadmap](../core-integration-api.md) established
|
|||||||
the core/integration boundary. The reassessment below distinguishes its completed
|
the core/integration boundary. The reassessment below distinguishes its completed
|
||||||
work from the remaining audit remediation.
|
work from the remaining audit remediation.
|
||||||
|
|
||||||
The **45 original finding entries** reduce to **24 outstanding catalog entries
|
The **45 original finding entries** reduce to **23 outstanding catalog entries
|
||||||
and ten resolved entries**. Repeated responsibility findings are
|
and eleven resolved entries**. Repeated responsibility findings are
|
||||||
merged. Regression gaps are attached to the defects they protect rather than
|
merged. Regression gaps are attached to the defects they protect rather than
|
||||||
counted as additional runtime bugs. In particular, TEST-001, TEST-002, and
|
counted as additional runtime bugs. In particular, TEST-001, TEST-002, and
|
||||||
TEST-004 each cover several distinct defects; TEST-003's native-fixture oracle
|
TEST-004 each cover several distinct defects; TEST-003's native-fixture oracle
|
||||||
@@ -65,7 +65,7 @@ Original P2/P3 ratings and relative refactoring priorities are retained for
|
|||||||
context; they are not one universal severity scale. No audit establishes a P1
|
context; they are not one universal severity scale. No audit establishes a P1
|
||||||
incident or a measured end-to-end production speedup.
|
incident or a measured end-to-end production speedup.
|
||||||
|
|
||||||
CAT-001, CAT-002, CAT-004, CAT-007, CAT-011, CAT-012, CAT-013, CAT-015,
|
CAT-001, CAT-002, CAT-004, CAT-005, CAT-007, CAT-011, CAT-012, CAT-013, CAT-015,
|
||||||
CAT-016, and CAT-034 are resolved;
|
CAT-016, and CAT-034 are resolved;
|
||||||
the other entries remain outstanding. The original reports and their baseline
|
the other entries remain outstanding. The original reports and their baseline
|
||||||
observations are historical.
|
observations are historical.
|
||||||
@@ -152,6 +152,11 @@ dimension from each sparse lookup; it is not a measured overall runtime claim.
|
|||||||
|
|
||||||
**Assessment:** Source-established algorithmic opportunity; original P2.
|
**Assessment:** Source-established algorithmic opportunity; original P2.
|
||||||
|
|
||||||
|
**Status:** Resolved. A run-owned index is shared by extraction and cache
|
||||||
|
decoding; all ten D&D extraction paths use it, with local fallback for standalone
|
||||||
|
calls. Tests cover run isolation, changed source layouts, cache reuse, and
|
||||||
|
representative supplied-index extraction. No production speedup was measured.
|
||||||
|
|
||||||
**Source:** [EFF-001](02-efficiency.md#eff-001--reuse-the-full-source-position-index-across-extraction-jobs).
|
**Source:** [EFF-001](02-efficiency.md#eff-001--reuse-the-full-source-position-index-across-extraction-jobs).
|
||||||
|
|
||||||
Ten D&D extractors build the same document-position map per applicable chunk
|
Ten D&D extractors build the same document-position map per applicable chunk
|
||||||
|
|||||||
@@ -319,6 +319,15 @@ The optional index is not a new required caller argument.
|
|||||||
|
|
||||||
## Stage 9 — Complete Extraction Index Reuse
|
## Stage 9 — Complete Extraction Index Reuse
|
||||||
|
|
||||||
|
**Completed.** Spells, combat turns, enemy events, and scene descriptions now
|
||||||
|
borrow the run index, with local construction when omitted. Combat eligibility
|
||||||
|
still returns before ordering construction. The six registry/occurrence paths
|
||||||
|
use the same optional ordering constructor; location grounding shares its index,
|
||||||
|
and scene reuse/fallback validates against the same whole-source index. Focused
|
||||||
|
extractor and pipeline tests, pipeline/shared race tests, and full tests, vet,
|
||||||
|
and build passed. Cross-run layout and cache checks are covered by the preceding
|
||||||
|
framework tests. No production speedup was measured or follow-up deferred.
|
||||||
|
|
||||||
**Coverage:** CAT-005 completion. **Prerequisites:** Stages 6–8.
|
**Coverage:** CAT-005 completion. **Prerequisites:** Stages 6–8.
|
||||||
|
|
||||||
Migrate spells, combat turns, enemy events, and scene-description extractors.
|
Migrate spells, combat turns, enemy events, and scene-description extractors.
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ func (e *Extractor) PrepareExtraction(ctx context.Context, req contracts.Extract
|
|||||||
default:
|
default:
|
||||||
return nil, extractorErrorf("unsupported scene eligibility match state %q", match.State)
|
return nil, extractorErrorf("unsupported scene eligibility match state %q", match.State)
|
||||||
}
|
}
|
||||||
order := shared.NewSourceRefOrder(req.Source)
|
order := shared.NewSourceRefOrderForSource(req.Source, req.SourceIndex)
|
||||||
npcRegistry, err := e.npcResolver.Resolve(req.References)
|
npcRegistry, err := e.npcResolver.Resolve(req.References)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, extractorErrorf("resolve NPC registry: %w", err)
|
return nil, extractorErrorf("resolve NPC registry: %w", err)
|
||||||
|
|||||||
@@ -33,7 +33,10 @@ func TestExtractMapsAndOrdersCombatTurnsBySourcePosition(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}}}
|
}}}
|
||||||
|
|
||||||
result, err := runExtraction(context.Background(), newExtractor(t, client), extractionRequest(t))
|
req := extractionRequest(t)
|
||||||
|
index := source.NewDocumentIndex(req.Source)
|
||||||
|
req.SourceIndex = &index
|
||||||
|
result, err := runExtraction(context.Background(), newExtractor(t, client), req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Extract() error = %v, want nil", err)
|
t.Fatalf("Extract() error = %v, want nil", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ func mismatchedSourceInputRequest(req extractionTestInput) extractionTestInput {
|
|||||||
|
|
||||||
type extractionTestInput struct {
|
type extractionTestInput struct {
|
||||||
Source *source.SourceDocument
|
Source *source.SourceDocument
|
||||||
|
SourceIndex *source.DocumentIndex
|
||||||
Chunk *source.Chunk
|
Chunk *source.Chunk
|
||||||
AmbientContext map[string]any
|
AmbientContext map[string]any
|
||||||
SourceInput contracts.LLMInputMaterial
|
SourceInput contracts.LLMInputMaterial
|
||||||
@@ -116,7 +117,7 @@ func runExtraction(ctx context.Context, fixture *extractionFixture, req extracti
|
|||||||
}
|
}
|
||||||
op := req.Execution
|
op := req.Execution
|
||||||
execution := pipeline.ExecutionContext[dnd.CombatTurnList]{Engine: engine, Controls: op.Controls, Assess: op.Assess, Execution: op.Execution, ReuseEligible: op.ReuseEligible, Cache: op.Cache}
|
execution := pipeline.ExecutionContext[dnd.CombatTurnList]{Engine: engine, Controls: op.Controls, Assess: op.Assess, Execution: op.Execution, ReuseEligible: op.ReuseEligible, Cache: op.Cache}
|
||||||
input := contracts.ExtractionInput{Source: req.Source, Chunk: req.Chunk, SourceInput: req.SourceInput, SessionID: req.SessionID, References: req.References, LLMProfile: req.LLMProfile, Metadata: req.Metadata, AmbientContext: req.AmbientContext}
|
input := contracts.ExtractionInput{Source: req.Source, SourceIndex: req.SourceIndex, Chunk: req.Chunk, SourceInput: req.SourceInput, SessionID: req.SessionID, References: req.References, LLMProfile: req.LLMProfile, Metadata: req.Metadata, AmbientContext: req.AmbientContext}
|
||||||
return pipeline.ExecuteOperation(ctx, execution, func(ctx context.Context) (contracts.PreparedOperation[dnd.CombatTurnList], error) {
|
return pipeline.ExecuteOperation(ctx, execution, func(ctx context.Context) (contracts.PreparedOperation[dnd.CombatTurnList], error) {
|
||||||
return extractor.PrepareExtraction(ctx, input)
|
return extractor.PrepareExtraction(ctx, input)
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ func (e *Extractor) PrepareExtraction(ctx context.Context, req contracts.Extract
|
|||||||
return nil, extractorErrorf("resolve enemy-event grounding: %w", err)
|
return nil, extractorErrorf("resolve enemy-event grounding: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
order := shared.NewSourceRefOrder(req.Source)
|
order := shared.NewSourceRefOrderForSource(req.Source, req.SourceIndex)
|
||||||
sourceID := req.Source.ID
|
sourceID := req.Source.ID
|
||||||
materials := shared.PromptInputs(sourceInput, req.References)
|
materials := shared.PromptInputs(sourceInput, req.References)
|
||||||
for name, material := range grounding.PromptInputs() {
|
for name, material := range grounding.PromptInputs() {
|
||||||
|
|||||||
@@ -24,7 +24,10 @@ func TestExtractMapsEnemyEventsInSourceOrder(t *testing.T) {
|
|||||||
{Name: "Ashfang", Kind: "incapacitated", SourceRefs: []enemySourceRefResponse{{StartUnitID: 2, EndUnitID: 2}}},
|
{Name: "Ashfang", Kind: "incapacitated", SourceRefs: []enemySourceRefResponse{{StartUnitID: 2, EndUnitID: 2}}},
|
||||||
}}}
|
}}}
|
||||||
|
|
||||||
result, err := runExtraction(context.Background(), newEnemyExtractor(t, client), enemyExtractionRequest(t))
|
req := enemyExtractionRequest(t)
|
||||||
|
index := source.NewDocumentIndex(req.Source)
|
||||||
|
req.SourceIndex = &index
|
||||||
|
result, err := runExtraction(context.Background(), newEnemyExtractor(t, client), req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import (
|
|||||||
|
|
||||||
type extractionTestInput struct {
|
type extractionTestInput struct {
|
||||||
Source *source.SourceDocument
|
Source *source.SourceDocument
|
||||||
|
SourceIndex *source.DocumentIndex
|
||||||
Chunk *source.Chunk
|
Chunk *source.Chunk
|
||||||
AmbientContext map[string]any
|
AmbientContext map[string]any
|
||||||
SourceInput contracts.LLMInputMaterial
|
SourceInput contracts.LLMInputMaterial
|
||||||
@@ -69,7 +70,7 @@ func newEnemyExtractor(t *testing.T, client promptkit.LLMClient, references ...c
|
|||||||
func runExtraction(ctx context.Context, fixture *extractionFixture, req extractionTestInput) (pipeline.OperationResult[dnd.EnemyEventList], error) {
|
func runExtraction(ctx context.Context, fixture *extractionFixture, req extractionTestInput) (pipeline.OperationResult[dnd.EnemyEventList], error) {
|
||||||
op := req.Execution
|
op := req.Execution
|
||||||
execution := pipeline.ExecutionContext[dnd.EnemyEventList]{Engine: fixture.engine, Controls: op.Controls, Assess: op.Assess, Execution: op.Execution, ReuseEligible: op.ReuseEligible, Cache: op.Cache}
|
execution := pipeline.ExecutionContext[dnd.EnemyEventList]{Engine: fixture.engine, Controls: op.Controls, Assess: op.Assess, Execution: op.Execution, ReuseEligible: op.ReuseEligible, Cache: op.Cache}
|
||||||
input := contracts.ExtractionInput{Source: req.Source, Chunk: req.Chunk, SourceInput: req.SourceInput, SessionID: req.SessionID, References: req.References, LLMProfile: req.LLMProfile, Metadata: req.Metadata, AmbientContext: req.AmbientContext}
|
input := contracts.ExtractionInput{Source: req.Source, SourceIndex: req.SourceIndex, Chunk: req.Chunk, SourceInput: req.SourceInput, SessionID: req.SessionID, References: req.References, LLMProfile: req.LLMProfile, Metadata: req.Metadata, AmbientContext: req.AmbientContext}
|
||||||
return pipeline.ExecuteOperation(ctx, execution, func(ctx context.Context) (contracts.PreparedOperation[dnd.EnemyEventList], error) {
|
return pipeline.ExecuteOperation(ctx, execution, func(ctx context.Context) (contracts.PreparedOperation[dnd.EnemyEventList], error) {
|
||||||
return fixture.Extractor.PrepareExtraction(ctx, input)
|
return fixture.Extractor.PrepareExtraction(ctx, input)
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -72,7 +72,11 @@ func (e *Extractor) PrepareExtraction(ctx context.Context, req contracts.Extract
|
|||||||
}
|
}
|
||||||
|
|
||||||
chunk := source.Chunk{ID: req.Chunk.ID, Ref: req.Chunk.Ref}
|
chunk := source.Chunk{ID: req.Chunk.ID, Ref: req.Chunk.Ref}
|
||||||
index := source.NewDocumentIndex(req.Source)
|
index := req.SourceIndex
|
||||||
|
if index == nil {
|
||||||
|
local := source.NewDocumentIndex(req.Source)
|
||||||
|
index = &local
|
||||||
|
}
|
||||||
reuse := func(value dnd.SceneDescriptionList) (dnd.SceneDescriptionList, error) {
|
reuse := func(value dnd.SceneDescriptionList) (dnd.SceneDescriptionList, error) {
|
||||||
if len(value.Scenes) != 1 || value.Scenes[0].SourceRef != chunk.Ref {
|
if len(value.Scenes) != 1 || value.Scenes[0].SourceRef != chunk.Ref {
|
||||||
return dnd.SceneDescriptionList{}, fmt.Errorf("cached scene does not describe the current chunk range")
|
return dnd.SceneDescriptionList{}, fmt.Errorf("cached scene does not describe the current chunk range")
|
||||||
@@ -80,7 +84,7 @@ func (e *Extractor) PrepareExtraction(ctx context.Context, req contracts.Extract
|
|||||||
// Chunk ordinals can change without changing the semantic prompt.
|
// Chunk ordinals can change without changing the semantic prompt.
|
||||||
value.Scenes = append([]dnd.SceneDescription(nil), value.Scenes...)
|
value.Scenes = append([]dnd.SceneDescription(nil), value.Scenes...)
|
||||||
value.Scenes[0].ID = chunk.ID
|
value.Scenes[0].ID = chunk.ID
|
||||||
return sceneFallback(&value, chunk, index)
|
return sceneFallback(&value, chunk, *index)
|
||||||
}
|
}
|
||||||
materials := shared.PromptInputs(sourceInput, req.References)
|
materials := shared.PromptInputs(sourceInput, req.References)
|
||||||
inputs := make(map[string]promptkit.ArtifactRef, len(materials))
|
inputs := make(map[string]promptkit.ArtifactRef, len(materials))
|
||||||
@@ -103,7 +107,7 @@ func (e *Extractor) PrepareExtraction(ctx context.Context, req contracts.Extract
|
|||||||
if evaluation != nil {
|
if evaluation != nil {
|
||||||
final = evaluation.View().Candidate
|
final = evaluation.View().Candidate
|
||||||
}
|
}
|
||||||
return sceneFallback(final, chunk, index)
|
return sceneFallback(final, chunk, *index)
|
||||||
}}, nil
|
}}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ func TestExtractMapsExactlyOneSceneToTheChunk(t *testing.T) {
|
|||||||
Kind: dnd.SceneKindCombat, Title: " Fight at the Watchtower ", Summary: " Bandits attack the party. ",
|
Kind: dnd.SceneKindCombat, Title: " Fight at the Watchtower ", Summary: " Bandits attack the party. ",
|
||||||
}}
|
}}
|
||||||
request := extractionRequest()
|
request := extractionRequest()
|
||||||
|
index := source.NewDocumentIndex(request.Source)
|
||||||
|
request.SourceIndex = &index
|
||||||
result, err := runExtraction(newExtractor(t, client), context.Background(), request)
|
result, err := runExtraction(newExtractor(t, client), context.Background(), request)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Extract() error = %v, want nil", err)
|
t.Fatalf("Extract() error = %v, want nil", err)
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
package scenedescriptions
|
package scenedescriptions
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"gitea.maximumdirect.net/eric/notarius/internal/core/source"
|
"gitea.maximumdirect.net/eric/notarius/internal/core/source"
|
||||||
|
"gitea.maximumdirect.net/eric/notarius/internal/framework/contracts"
|
||||||
"gitea.maximumdirect.net/eric/notarius/internal/modules/dnd"
|
"gitea.maximumdirect.net/eric/notarius/internal/modules/dnd"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -59,3 +61,30 @@ func TestSceneFallbackRequiresOneUsableFinalSceneWithCurrentIdentity(t *testing.
|
|||||||
t.Fatal("fallback aliases the candidate or alters its classification/prose")
|
t.Fatal("fallback aliases the candidate or alters its classification/prose")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestPreparedSceneReuseChecksCurrentSourceWithOptionalIndex(t *testing.T) {
|
||||||
|
req := extractionRequest()
|
||||||
|
index := source.NewDocumentIndex(req.Source)
|
||||||
|
extractor, err := New(Options{})
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
value := dnd.SceneDescriptionList{Scenes: []dnd.SceneDescription{{ID: "old-chunk", SourceRef: req.Chunk.Ref, Kind: dnd.SceneKindNarrative, Title: "Arrival", Summary: "The party arrives."}}}
|
||||||
|
for _, supplied := range []*source.DocumentIndex{nil, &index} {
|
||||||
|
prepared, err := extractor.PrepareExtraction(context.Background(), contracts.ExtractionInput{Source: req.Source, SourceIndex: supplied, Chunk: req.Chunk, SourceInput: req.SourceInput})
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
native := prepared.(contracts.NativeOperation[dnd.SceneDescriptionList])
|
||||||
|
got, err := native.Reuse(value)
|
||||||
|
if err != nil || got.Scenes[0].ID != req.Chunk.ID {
|
||||||
|
t.Fatalf("Reuse() = %#v, %v", got, err)
|
||||||
|
}
|
||||||
|
invalid := value
|
||||||
|
invalid.Scenes = append([]dnd.SceneDescription(nil), value.Scenes...)
|
||||||
|
invalid.Scenes[0].SourceRef.EndUnitID = 999
|
||||||
|
if _, err := native.Reuse(invalid); err == nil {
|
||||||
|
t.Fatal("Reuse() accepted a different source range")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"gitea.maximumdirect.net/eric/notarius/internal/core/source"
|
||||||
"gitea.maximumdirect.net/eric/notarius/internal/framework/contracts"
|
"gitea.maximumdirect.net/eric/notarius/internal/framework/contracts"
|
||||||
"gitea.maximumdirect.net/eric/notarius/internal/modules/dnd"
|
"gitea.maximumdirect.net/eric/notarius/internal/modules/dnd"
|
||||||
scenecodec "gitea.maximumdirect.net/eric/notarius/internal/modules/dnd/codec/scenedescriptions"
|
scenecodec "gitea.maximumdirect.net/eric/notarius/internal/modules/dnd/codec/scenedescriptions"
|
||||||
@@ -105,6 +106,8 @@ func TestSceneCorrectionUsesRealNativeCombatJudgmentsAndPreservesSourceIdentity(
|
|||||||
|
|
||||||
func TestPermissiveSceneRetainsOnlyFinalUsableCandidateWithoutSemanticRevalidation(t *testing.T) {
|
func TestPermissiveSceneRetainsOnlyFinalUsableCandidateWithoutSemanticRevalidation(t *testing.T) {
|
||||||
request := extractionRequest()
|
request := extractionRequest()
|
||||||
|
index := source.NewDocumentIndex(request.Source)
|
||||||
|
request.SourceIndex = &index
|
||||||
request.Execution.Controls.Mode = contracts.ModePermissive
|
request.Execution.Controls.Mode = contracts.ModePermissive
|
||||||
request.Execution.Controls.MaxAdditionalTurns = 1
|
request.Execution.Controls.MaxAdditionalTurns = 1
|
||||||
// Both scenes remain non-combat, but the final title/summary must win.
|
// Both scenes remain non-combat, but the final title/summary must win.
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ func mismatchedSourceInputRequest(req extractionTestInput) extractionTestInput {
|
|||||||
|
|
||||||
type extractionTestInput struct {
|
type extractionTestInput struct {
|
||||||
Source *source.SourceDocument
|
Source *source.SourceDocument
|
||||||
|
SourceIndex *source.DocumentIndex
|
||||||
Chunk *source.Chunk
|
Chunk *source.Chunk
|
||||||
AmbientContext map[string]any
|
AmbientContext map[string]any
|
||||||
SourceInput contracts.LLMInputMaterial
|
SourceInput contracts.LLMInputMaterial
|
||||||
@@ -120,7 +121,7 @@ func runExtraction(fixture *extractionFixture, ctx context.Context, req extracti
|
|||||||
}
|
}
|
||||||
op := req.Execution
|
op := req.Execution
|
||||||
execution := pipeline.ExecutionContext[dnd.SceneDescriptionList]{Engine: engine, Controls: op.Controls, Assess: op.Assess, Execution: op.Execution, ReuseEligible: op.ReuseEligible, Cache: op.Cache}
|
execution := pipeline.ExecutionContext[dnd.SceneDescriptionList]{Engine: engine, Controls: op.Controls, Assess: op.Assess, Execution: op.Execution, ReuseEligible: op.ReuseEligible, Cache: op.Cache}
|
||||||
input := contracts.ExtractionInput{Source: req.Source, Chunk: req.Chunk, SourceInput: req.SourceInput, SessionID: req.SessionID, References: req.References, LLMProfile: req.LLMProfile, Metadata: req.Metadata, AmbientContext: req.AmbientContext}
|
input := contracts.ExtractionInput{Source: req.Source, SourceIndex: req.SourceIndex, Chunk: req.Chunk, SourceInput: req.SourceInput, SessionID: req.SessionID, References: req.References, LLMProfile: req.LLMProfile, Metadata: req.Metadata, AmbientContext: req.AmbientContext}
|
||||||
return pipeline.ExecuteOperation(ctx, execution, func(ctx context.Context) (contracts.PreparedOperation[dnd.SceneDescriptionList], error) {
|
return pipeline.ExecuteOperation(ctx, execution, func(ctx context.Context) (contracts.PreparedOperation[dnd.SceneDescriptionList], error) {
|
||||||
return extractor.PrepareExtraction(ctx, input)
|
return extractor.PrepareExtraction(ctx, input)
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ func (e *Extractor) PrepareExtraction(ctx context.Context, req contracts.Extract
|
|||||||
return nil, extractorErrorf("%w", err)
|
return nil, extractorErrorf("%w", err)
|
||||||
}
|
}
|
||||||
sourceID := req.Source.ID
|
sourceID := req.Source.ID
|
||||||
order := shared.NewSourceRefOrder(req.Source)
|
order := shared.NewSourceRefOrderForSource(req.Source, req.SourceIndex)
|
||||||
npcRegistry, err := e.npcResolver.Resolve(req.References)
|
npcRegistry, err := e.npcResolver.Resolve(req.References)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, extractorErrorf("resolve NPC registry: %w", err)
|
return nil, extractorErrorf("resolve NPC registry: %w", err)
|
||||||
|
|||||||
@@ -26,6 +26,8 @@ func TestExtractReturnsCanonicalSpellListFromPrivateResponse(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}}}
|
}}}
|
||||||
req := extractionRequest()
|
req := extractionRequest()
|
||||||
|
index := source.NewDocumentIndex(req.Source)
|
||||||
|
req.SourceIndex = &index
|
||||||
var prepared promptkit.PreparedRun
|
var prepared promptkit.PreparedRun
|
||||||
req.Execution.Execution.OnPrepared = func(_ context.Context, value promptkit.PreparedRun) { prepared = value }
|
req.Execution.Execution.OnPrepared = func(_ context.Context, value promptkit.PreparedRun) { prepared = value }
|
||||||
|
|
||||||
|
|||||||
@@ -115,6 +115,7 @@ func mismatchedSourceInputRequest(req extractionTestInput) extractionTestInput {
|
|||||||
|
|
||||||
type extractionTestInput struct {
|
type extractionTestInput struct {
|
||||||
Source *source.SourceDocument
|
Source *source.SourceDocument
|
||||||
|
SourceIndex *source.DocumentIndex
|
||||||
Chunk *source.Chunk
|
Chunk *source.Chunk
|
||||||
AmbientContext map[string]any
|
AmbientContext map[string]any
|
||||||
SourceInput contracts.LLMInputMaterial
|
SourceInput contracts.LLMInputMaterial
|
||||||
@@ -142,7 +143,7 @@ func newExtractor(t *testing.T, client promptkit.LLMClient, references ...contra
|
|||||||
func runExtraction(ctx context.Context, fixture *extractionFixture, req extractionTestInput) (pipeline.OperationResult[dnd.SpellList], error) {
|
func runExtraction(ctx context.Context, fixture *extractionFixture, req extractionTestInput) (pipeline.OperationResult[dnd.SpellList], error) {
|
||||||
operation := req.Execution
|
operation := req.Execution
|
||||||
execution := pipeline.ExecutionContext[dnd.SpellList]{Engine: fixture.engine, Controls: operation.Controls, Assess: operation.Assess, Execution: operation.Execution, ReuseEligible: operation.ReuseEligible, Cache: operation.Cache}
|
execution := pipeline.ExecutionContext[dnd.SpellList]{Engine: fixture.engine, Controls: operation.Controls, Assess: operation.Assess, Execution: operation.Execution, ReuseEligible: operation.ReuseEligible, Cache: operation.Cache}
|
||||||
input := contracts.ExtractionInput{Source: req.Source, Chunk: req.Chunk, SourceInput: req.SourceInput, SessionID: req.SessionID, References: req.References, LLMProfile: req.LLMProfile, Metadata: req.Metadata, AmbientContext: req.AmbientContext}
|
input := contracts.ExtractionInput{Source: req.Source, SourceIndex: req.SourceIndex, Chunk: req.Chunk, SourceInput: req.SourceInput, SessionID: req.SessionID, References: req.References, LLMProfile: req.LLMProfile, Metadata: req.Metadata, AmbientContext: req.AmbientContext}
|
||||||
return pipeline.ExecuteOperation(ctx, execution, func(ctx context.Context) (contracts.PreparedOperation[dnd.SpellList], error) {
|
return pipeline.ExecuteOperation(ctx, execution, func(ctx context.Context) (contracts.PreparedOperation[dnd.SpellList], error) {
|
||||||
return fixture.Extractor.PrepareExtraction(ctx, input)
|
return fixture.Extractor.PrepareExtraction(ctx, input)
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user