Run processing from the prepared invocation
This commit is contained in:
@@ -13,6 +13,7 @@ import (
|
||||
"gitea.maximumdirect.net/eric/audita/v4/internal/core/schema"
|
||||
"gitea.maximumdirect.net/eric/audita/v4/internal/framework/contracts"
|
||||
"gitea.maximumdirect.net/eric/audita/v4/internal/framework/outcomes"
|
||||
"gitea.maximumdirect.net/eric/audita/v4/internal/framework/preflight"
|
||||
"gitea.maximumdirect.net/eric/audita/v4/internal/framework/proposals"
|
||||
"gitea.maximumdirect.net/eric/audita/v4/internal/framework/runner"
|
||||
"gitea.maximumdirect.net/eric/audita/v4/internal/framework/structuredoutput"
|
||||
@@ -74,8 +75,8 @@ func TestFatalBatchRetainsEarlierDecisionsInLedger(t *testing.T) {
|
||||
client := &interruptedValidationClient{cause: origin}
|
||||
cfg := config.Config{Chunking: config.Chunking{MaxSectionTokens: 8192, MinSectionTokens: 1}, Validation: config.Validation{MaxPromptTokens: 150}}
|
||||
result, err := runner.New(partialModule{validator}).Run(context.Background(), runner.RunInput{
|
||||
Sections: []chunking.Section{{Index: 0, StartSegmentID: 1, EndSegmentID: 1, Segments: []schema.Segment{{ID: 1, Text: "hello"}}}}, Transcript: &schema.Transcript{Segments: []schema.Segment{{ID: 1, Text: "hello"}}},
|
||||
ModuleSpecs: []contracts.ModuleRunSpec{{ModuleKey: "grammar", InstanceName: "grammar", ValidationClient: client, Settings: config.Stage{Validation: cfg.Validation}}}, Evidence: &runner.EvidenceSelection{Reports: true, Debug: true},
|
||||
Plan: &preflight.Plan{Sections: []chunking.Section{{Index: 0, StartSegmentID: 1, EndSegmentID: 1, Segments: []schema.Segment{{ID: 1, Text: "hello"}}}}, Transcript: &schema.Transcript{Segments: []schema.Segment{{ID: 1, Text: "hello"}}},
|
||||
Specs: []contracts.ModuleRunSpec{{ModuleKey: "grammar", InstanceName: "grammar", ValidationClient: client, Settings: config.Stage{Validation: cfg.Validation}}}}, Evidence: &runner.EvidenceSelection{Reports: true, Debug: true},
|
||||
})
|
||||
if !errors.Is(err, origin) || client.calls != 3 {
|
||||
t.Fatalf("fatal cause/calls: %v %d", err, client.calls)
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"gitea.maximumdirect.net/eric/audita/v4/internal/core/config"
|
||||
"gitea.maximumdirect.net/eric/audita/v4/internal/core/schema"
|
||||
"gitea.maximumdirect.net/eric/audita/v4/internal/framework/contracts"
|
||||
"gitea.maximumdirect.net/eric/audita/v4/internal/framework/preflight"
|
||||
"gitea.maximumdirect.net/eric/audita/v4/internal/framework/structuredoutput"
|
||||
)
|
||||
|
||||
@@ -26,5 +27,5 @@ func preparedTestInput(input testRunInput) RunInput {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return RunInput{Sections: sections, Transcript: input.Transcript, ModuleSpecs: input.ModuleSpecs, Interactions: input.Interactions, Evidence: input.Evidence, Progress: input.Progress}
|
||||
return RunInput{Plan: &preflight.Plan{Sections: sections, Transcript: input.Transcript, Specs: input.ModuleSpecs, Config: input.Config}, Interactions: input.Interactions, Evidence: input.Evidence, Progress: input.Progress}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ import (
|
||||
"gitea.maximumdirect.net/eric/audita/v4/internal/core/schema"
|
||||
"gitea.maximumdirect.net/eric/audita/v4/internal/framework/contracts"
|
||||
"gitea.maximumdirect.net/eric/audita/v4/internal/framework/outcomes"
|
||||
"gitea.maximumdirect.net/eric/audita/v4/internal/framework/preflight"
|
||||
"gitea.maximumdirect.net/eric/audita/v4/internal/framework/promptcontext"
|
||||
"gitea.maximumdirect.net/eric/audita/v4/internal/framework/proposals"
|
||||
"gitea.maximumdirect.net/eric/audita/v4/internal/framework/structuredoutput"
|
||||
@@ -113,9 +114,7 @@ func selectEvidence(selection *EvidenceSelection) evidenceNeeds {
|
||||
|
||||
// RunInput is the deterministic runner input.
|
||||
type RunInput struct {
|
||||
Sections []chunking.Section
|
||||
Transcript *schema.Transcript
|
||||
ModuleSpecs []contracts.ModuleRunSpec
|
||||
Plan *preflight.Plan
|
||||
Interactions structuredoutput.InteractionSink
|
||||
Evidence *EvidenceSelection
|
||||
Progress func(Progress)
|
||||
@@ -138,16 +137,16 @@ func New(factory ModuleFactory) *Runner {
|
||||
|
||||
func (r *Runner) Run(ctx context.Context, input RunInput) (RunOutput, error) {
|
||||
if err := ctx.Err(); err != nil {
|
||||
return RunOutput{FinalTranscript: input.Transcript.Clone()}, &ExecutionFailure{Phase: "processing", Cause: err}
|
||||
return RunOutput{FinalTranscript: input.Plan.Transcript.Clone()}, &ExecutionFailure{Phase: "processing", Cause: err}
|
||||
}
|
||||
if r == nil || r.factory == nil {
|
||||
return RunOutput{}, &ExecutionFailure{Phase: "setup", Cause: errors.New("runner module factory is required")}
|
||||
}
|
||||
|
||||
results := make([]ModuleResult, 0, len(input.ModuleSpecs))
|
||||
sections := input.Sections
|
||||
results := make([]ModuleResult, 0, len(input.Plan.Specs))
|
||||
sections := input.Plan.Sections
|
||||
evidence := selectEvidence(input.Evidence)
|
||||
totals := outcomes.WorkTotals{Total: len(input.ModuleSpecs) * len(sections)}
|
||||
totals := outcomes.WorkTotals{Total: len(input.Plan.Specs) * len(sections)}
|
||||
var inventory []contracts.SectionMetadata
|
||||
var workUnits []WorkUnitOutcome
|
||||
var candidates []proposals.EnrichedCorrectionProposal
|
||||
@@ -157,7 +156,7 @@ func (r *Runner) Run(ctx context.Context, input RunInput) (RunOutput, error) {
|
||||
inventory[i] = contracts.SectionMetadataFromSection(section)
|
||||
}
|
||||
workUnits = make([]WorkUnitOutcome, 0, totals.Total)
|
||||
for moduleIndex, spec := range input.ModuleSpecs {
|
||||
for moduleIndex, spec := range input.Plan.Specs {
|
||||
for _, section := range inventory {
|
||||
workUnits = append(workUnits, newWorkUnit(spec, section, moduleIndex))
|
||||
}
|
||||
@@ -170,7 +169,7 @@ func (r *Runner) Run(ctx context.Context, input RunInput) (RunOutput, error) {
|
||||
}
|
||||
}
|
||||
|
||||
for moduleIndex, spec := range input.ModuleSpecs {
|
||||
for moduleIndex, spec := range input.Plan.Specs {
|
||||
progress := Progress{ModuleIndex: spec.Index, ModuleKey: spec.ModuleKey, ModuleID: spec.ID}
|
||||
sectionCount := len(sections)
|
||||
progress.emit(input.Progress, "started", nil, §ionCount)
|
||||
|
||||
Reference in New Issue
Block a user