Run ordered processing with independent settings

This commit is contained in:
2026-11-10 17:33:30 +00:00
parent 89de2a7014
commit 7efa07ee9d
21 changed files with 447 additions and 335 deletions

View File

@@ -7,6 +7,7 @@ import (
"gitea.maximumdirect.net/eric/audita/v3/internal/core/chunking"
"gitea.maximumdirect.net/eric/audita/v3/internal/core/config"
"gitea.maximumdirect.net/eric/audita/v3/internal/core/glossary"
"gitea.maximumdirect.net/eric/audita/v3/internal/core/modulecatalog"
"gitea.maximumdirect.net/eric/audita/v3/internal/core/schema"
"gitea.maximumdirect.net/eric/audita/v3/internal/framework/outcomes"
"gitea.maximumdirect.net/eric/audita/v3/internal/framework/proposals"
@@ -38,6 +39,13 @@ type ModuleRunSpec struct {
ModuleKey string `json:"module_key"`
InstanceName string `json:"instance_name"`
ReplacementPolicy proposals.ReplacementPolicy `json:"replacement_policy"`
Index int `json:"-"`
ID *string `json:"-"`
Settings config.Stage `json:"-"`
Glossary []glossary.Entry `json:"-"`
ProtectedTerms []glossary.Term `json:"-"`
ProposalClient StructuredLLMClient `json:"-"`
ValidationClient StructuredLLMClient `json:"-"`
}
// SectionMetadata captures chunk-level metadata without embedding full segment payloads.
@@ -64,7 +72,7 @@ func SectionMetadataFromSection(section chunking.Section) SectionMetadata {
type ExecutionContext struct {
// ReportDiagnosticError may be called concurrently; it must not affect processing.
ReportDiagnosticError func(error) `json:"-"`
Config *config.Config `json:"-"`
Settings config.Stage `json:"-"`
WorkingTranscript *schema.Transcript `json:"-"`
Glossary []glossary.Entry `json:"-"`
ProtectedTerms []glossary.Term `json:"-"`
@@ -87,32 +95,20 @@ type ProposalResult struct {
// ValidationRequest is the input to validator execution.
type ValidationRequest = validators.Request
// ResolveModuleRunSpecs deterministically resolves instance names from logical keys.
// Repeated keys are suffixed with _<n> (1-based), while singleton keys keep their raw key.
func ResolveModuleRunSpecs(moduleKeys []string) ([]ModuleRunSpec, error) {
totals := make(map[string]int, len(moduleKeys))
for i, key := range moduleKeys {
if key == "" {
return nil, fmt.Errorf("module key at index %d must not be empty", i)
}
totals[key]++
// ResolveModuleRunSpecs derives isolated consumer views from resolved settings.
func ResolveModuleRunSpecs(cfg *config.Config) []ModuleRunSpec {
if cfg == nil {
return nil
}
seen := make(map[string]int, len(totals))
specs := make([]ModuleRunSpec, len(moduleKeys))
for i, key := range moduleKeys {
seen[key]++
name := key
if totals[key] > 1 {
name = fmt.Sprintf("%s_%d", key, seen[key])
}
specs[i] = ModuleRunSpec{
ModuleKey: key,
InstanceName: name,
specs := make([]ModuleRunSpec, len(cfg.Pipeline.Stages))
for i, item := range cfg.Pipeline.Stages {
selected := glossary.Select(cfg.GlossaryCollections, item.Glossaries)
protected := glossary.Select(cfg.GlossaryCollections, item.ProtectedTerms)
var excluded []glossary.Entry
if item.Module == modulecatalog.KeyGlossary {
excluded = selected
}
specs[i] = ModuleRunSpec{ModuleKey: item.Module, InstanceName: fmt.Sprintf("%s_%d", item.Module, i+1), Index: i, ID: item.ID, Settings: item, Glossary: selected, ProtectedTerms: glossary.Vocabulary(protected, excluded)}
}
return specs, nil
return specs
}