Complete the core operation execution cutover
This commit is contained in:
@@ -58,24 +58,6 @@ type InputAdapter interface {
|
||||
Parse(ctx context.Context, req ParseRequest) (*source.SourceDocument, error)
|
||||
}
|
||||
|
||||
type ChunkRequest struct {
|
||||
Operation ProducerOperation[source.ChunkPlan] `json:"-"`
|
||||
Source *source.SourceDocument `json:"-"`
|
||||
SourceInput LLMInputMaterial `json:"source_input,omitempty"`
|
||||
SessionID string `json:"session_id,omitempty"`
|
||||
References ReferenceSet `json:"references,omitempty"`
|
||||
LLMProfile string `json:"llm_profile,omitempty"`
|
||||
Metadata map[string]any `json:"metadata,omitempty"`
|
||||
}
|
||||
|
||||
type ChunkPlanResult struct {
|
||||
// Fallback is an optional module-owned algorithm for deterministic rejection.
|
||||
Fallback func(context.Context) (source.ChunkPlan, error) `json:"-"`
|
||||
Outcome ProducerOutcome `json:"outcome"`
|
||||
Plan source.ChunkPlan `json:"plan"`
|
||||
Diagnostics []ProducerDiagnostic `json:"diagnostics,omitempty"`
|
||||
}
|
||||
|
||||
type Chunker interface {
|
||||
Key() string
|
||||
ReferenceSlots() []ReferenceSlot
|
||||
|
||||
@@ -251,16 +251,15 @@ func (chunker fakeChunker) ReferenceSlots() []ReferenceSlot {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (chunker fakeChunker) Plan(ctx context.Context, req ChunkRequest) (ChunkPlanResult, error) {
|
||||
return ChunkPlanResult{
|
||||
Plan: source.ChunkPlan{
|
||||
SourceDigest: req.Source.Digest,
|
||||
Ranges: []source.ChunkRange{{
|
||||
StartUnitID: req.Source.Units[0].ID,
|
||||
EndUnitID: req.Source.Units[len(req.Source.Units)-1].ID,
|
||||
}},
|
||||
},
|
||||
}, nil
|
||||
func (chunker fakeChunker) PrepareChunk(ctx context.Context, req ChunkInput) (PreparedOperation[source.ChunkPlan], error) {
|
||||
plan := source.ChunkPlan{
|
||||
SourceDigest: req.Source.Digest,
|
||||
Ranges: []source.ChunkRange{{
|
||||
StartUnitID: req.Source.Units[0].ID,
|
||||
EndUnitID: req.Source.Units[len(req.Source.Units)-1].ID,
|
||||
}},
|
||||
}
|
||||
return DeterministicOperation[source.ChunkPlan]{Evaluation: CandidateEvaluation[source.ChunkPlan]{Result: EvaluationView[source.ChunkPlan]{Candidate: &plan}}}, nil
|
||||
}
|
||||
|
||||
type fakeExtractor struct {
|
||||
@@ -277,12 +276,13 @@ func (extractor fakeExtractor) ReferenceSlots() []ReferenceSlot {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (extractor fakeExtractor) Extract(ctx context.Context, req TypedExtractionRequest[fakeArtifact]) (TypedExtractionResult[fakeArtifact], error) {
|
||||
func (extractor fakeExtractor) PrepareExtraction(ctx context.Context, req ExtractionInput) (PreparedOperation[fakeArtifact], error) {
|
||||
value := "example"
|
||||
if req.AmbientContext["mode"] == "chunked" {
|
||||
value = "chunked"
|
||||
}
|
||||
return TypedExtractionResult[fakeArtifact]{Value: fakeArtifact{Value: value}}, nil
|
||||
result := fakeArtifact{Value: value}
|
||||
return DeterministicOperation[fakeArtifact]{Evaluation: CandidateEvaluation[fakeArtifact]{Result: EvaluationView[fakeArtifact]{Candidate: &result}}}, nil
|
||||
}
|
||||
|
||||
type fakeMerger struct {
|
||||
@@ -293,8 +293,9 @@ func (merger fakeMerger) Key() string {
|
||||
return merger.key
|
||||
}
|
||||
|
||||
func (merger fakeMerger) Merge(ctx context.Context, req TypedMergeRequest[fakeArtifact]) (TypedMergeResult[fakeArtifact], error) {
|
||||
return TypedMergeResult[fakeArtifact]{Value: req.ExtractOutputs[0].Value}, nil
|
||||
func (merger fakeMerger) PrepareMerge(ctx context.Context, req MergeInput[fakeArtifact]) (PreparedOperation[fakeArtifact], error) {
|
||||
value := req.ExtractOutputs[0].Value
|
||||
return DeterministicOperation[fakeArtifact]{Evaluation: CandidateEvaluation[fakeArtifact]{Result: EvaluationView[fakeArtifact]{Candidate: &value}}}, nil
|
||||
}
|
||||
|
||||
type fakeNormalizer struct {
|
||||
@@ -309,8 +310,9 @@ func (normalizer fakeNormalizer) ReferenceSlots() []ReferenceSlot {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (normalizer fakeNormalizer) Normalize(ctx context.Context, req TypedNormalizeRequest[fakeArtifact]) (TypedNormalizeResult[fakeArtifact], error) {
|
||||
return TypedNormalizeResult[fakeArtifact]{Value: req.MergeOutput.Value}, nil
|
||||
func (normalizer fakeNormalizer) PrepareNormalize(ctx context.Context, req NormalizeInput[fakeArtifact]) (PreparedOperation[fakeArtifact], error) {
|
||||
value := req.MergeOutput.Value
|
||||
return DeterministicOperation[fakeArtifact]{Evaluation: CandidateEvaluation[fakeArtifact]{Result: EvaluationView[fakeArtifact]{Candidate: &value}}}, nil
|
||||
}
|
||||
|
||||
type fakeOutputEncoder struct {
|
||||
|
||||
@@ -118,16 +118,6 @@ type CandidateAssessment struct {
|
||||
|
||||
type CandidateAssessor[T any] func(context.Context, T) (CandidateAssessment, error)
|
||||
|
||||
// ProducerOperation is supplied explicitly by the runner for one operation.
|
||||
// Validators receive ExecutionOptions, never a producer assessment callback.
|
||||
type ProducerOperation[T any] struct {
|
||||
Controls ProducerControls
|
||||
Assess CandidateAssessor[T] `json:"-"`
|
||||
Execution ExecutionOptions
|
||||
ReuseEligible bool
|
||||
Cache *ProducerCache[T] `json:"-"`
|
||||
}
|
||||
|
||||
type ProducerDisposition string
|
||||
|
||||
const (
|
||||
|
||||
@@ -33,75 +33,17 @@ type NormalizeArtifact[T any] struct {
|
||||
Value T
|
||||
}
|
||||
|
||||
type TypedExtractionRequest[T any] struct {
|
||||
Operation ProducerOperation[T]
|
||||
Source *source.SourceDocument
|
||||
Chunk *source.Chunk
|
||||
AmbientContext map[string]any
|
||||
SourceInput LLMInputMaterial
|
||||
SessionID string
|
||||
References ReferenceSet
|
||||
LLMProfile string
|
||||
Metadata map[string]any
|
||||
}
|
||||
|
||||
type TypedExtractionResult[T any] struct {
|
||||
// Fallback is an optional module-owned algorithm for deterministic rejection.
|
||||
Fallback func(context.Context) (T, error) `json:"-"`
|
||||
Outcome ProducerOutcome
|
||||
Value T
|
||||
Diagnostics []ProducerDiagnostic
|
||||
}
|
||||
|
||||
type Extractor[T any] interface {
|
||||
Key() string
|
||||
ReferenceSlots() []ReferenceSlot
|
||||
PrepareExtraction(context.Context, ExtractionInput) (PreparedOperation[T], error)
|
||||
}
|
||||
|
||||
type TypedMergeRequest[T any] struct {
|
||||
Operation ProducerOperation[T]
|
||||
Source *source.SourceDocument
|
||||
LaneID string
|
||||
ExtractOutputs []ExtractArtifact[T]
|
||||
SourceInput LLMInputMaterial
|
||||
SessionID string
|
||||
References ReferenceSet
|
||||
LLMProfile string
|
||||
Metadata map[string]any
|
||||
}
|
||||
|
||||
type TypedMergeResult[T any] struct {
|
||||
Fallback func(context.Context) (T, error) `json:"-"`
|
||||
Outcome ProducerOutcome
|
||||
Value T
|
||||
Diagnostics []ProducerDiagnostic
|
||||
}
|
||||
|
||||
type Merger[T any] interface {
|
||||
Key() string
|
||||
PrepareMerge(context.Context, MergeInput[T]) (PreparedOperation[T], error)
|
||||
}
|
||||
|
||||
type TypedNormalizeRequest[T any] struct {
|
||||
Operation ProducerOperation[T]
|
||||
Source *source.SourceDocument
|
||||
LaneID string
|
||||
MergeOutput MergeArtifact[T]
|
||||
SourceInput LLMInputMaterial
|
||||
SessionID string
|
||||
References ReferenceSet
|
||||
LLMProfile string
|
||||
Metadata map[string]any
|
||||
}
|
||||
|
||||
type TypedNormalizeResult[T any] struct {
|
||||
Fallback func(context.Context) (T, error) `json:"-"`
|
||||
Outcome ProducerOutcome
|
||||
Value T
|
||||
Diagnostics []ProducerDiagnostic
|
||||
}
|
||||
|
||||
type Normalizer[T any] interface {
|
||||
Key() string
|
||||
ReferenceSlots() []ReferenceSlot
|
||||
|
||||
Reference in New Issue
Block a user