Hand checked processing selections to execution

This commit is contained in:
2026-11-16 14:18:38 +00:00
parent b1d1b8302c
commit e98e525b5c
19 changed files with 268 additions and 102 deletions

View File

@@ -19,6 +19,8 @@ import (
type StructuredLLMClient = structuredoutput.Client
// TranscriptModule is the minimal contract for framework-integrated modules.
// Propose may run concurrently on an instance across sections. Request data
// is borrowed for the call. Copy it before retaining it or modifying it.
type TranscriptModule interface {
Key() string
ReplacementPolicy() proposals.ReplacementPolicy
@@ -31,18 +33,35 @@ type StructuredCompletionResponse = structuredoutput.Response
// ModuleRunSpec identifies one resolved module instance in a pipeline.
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:"-"`
CaptureProposalExchange bool `json:"-"`
ProposalClient StructuredLLMClient `json:"-"`
ValidationClient StructuredLLMClient `json:"-"`
RepairClient StructuredLLMClient `json:"-"`
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:"-"`
GlossaryView *validators.GlossaryView `json:"-"`
GlossaryVariables *promptcontext.GlossaryVariables `json:"-"`
CaptureProposalExchange bool `json:"-"`
ProposalClient StructuredLLMClient `json:"-"`
ValidationClient StructuredLLMClient `json:"-"`
RepairClient StructuredLLMClient `json:"-"`
}
// PrepareGlossary constructs the read-only views used by proposal and validation.
func (s *ModuleRunSpec) PrepareGlossary() error {
if s.GlossaryVariables == nil {
variables, err := promptcontext.PrepareGlossaryVariables(s.Glossary, s.ProtectedTerms)
if err != nil {
return err
}
s.GlossaryVariables = &variables
}
if s.GlossaryView == nil {
s.GlossaryView = validators.PrepareGlossaryView(s.Glossary, s.ProtectedTerms)
}
return nil
}
// SectionMetadata captures chunk-level metadata without embedding full segment payloads.

View File

@@ -118,10 +118,7 @@ func (c *RoleClient) prepareCall(parent context.Context, req structuredoutput.Re
if contractErr != nil {
return fail(&structuredoutput.Failure{Class: structuredoutput.FailureFatal, Reason: outcomes.ReasonSetupFailure, Message: "unknown structured response schema", Cause: contractErr})
}
vars := prompts.WithSharedVariables(req.Variables)
for name, value := range prompts.SharedVariables() {
vars[name] = value
}
vars := prompts.ProcessingVariables(req.Variables)
var exchange *pk.Exchange
if req.ContinueFrom != nil {
var ok bool

View File

@@ -1,136 +0,0 @@
package modules
import (
"context"
"fmt"
"strings"
"gitea.maximumdirect.net/eric/audita/v3/internal/core/modulecatalog"
"gitea.maximumdirect.net/eric/audita/v3/internal/framework/contracts"
glossarymodule "gitea.maximumdirect.net/eric/audita/v3/internal/modules/glossary"
grammarmodule "gitea.maximumdirect.net/eric/audita/v3/internal/modules/grammar"
homophonesmodule "gitea.maximumdirect.net/eric/audita/v3/internal/modules/homophones"
spokenwordmodule "gitea.maximumdirect.net/eric/audita/v3/internal/modules/spoken_word"
)
const (
ModuleKeyGlossary = modulecatalog.KeyGlossary
ModuleKeyHomophones = modulecatalog.KeyHomophones
ModuleKeySpokenWord = modulecatalog.KeySpokenWord
ModuleKeyGrammar = modulecatalog.KeyGrammar
)
const (
ReasonUnsupportedModule = "unsupported_module"
)
// IsKnownModuleKey reports whether a module key is recognized by the production
// registry scaffold.
func IsKnownModuleKey(key string) bool {
return modulecatalog.IsSupported(key)
}
// ConstructRequest identifies the module to construct.
type ConstructRequest struct {
RunSpec contracts.ModuleRunSpec
}
// Constructor builds one module instance from a run spec and explicit deps.
type Constructor func(ctx context.Context, req ConstructRequest) (contracts.TranscriptModule, error)
// Factory resolves configured module specs into module instances.
type Factory struct {
constructors map[string]Constructor
}
// NewFactory creates a production module registry.
func NewFactory() *Factory {
factory := &Factory{
constructors: make(map[string]Constructor, len(modulecatalog.SupportedKeys())),
}
_ = factory.RegisterConstructor(ModuleKeyGlossary, constructGlossaryModule)
_ = factory.RegisterConstructor(ModuleKeyHomophones, constructHomophonesModule)
_ = factory.RegisterConstructor(ModuleKeySpokenWord, constructSpokenWordModule)
_ = factory.RegisterConstructor(ModuleKeyGrammar, constructGrammarModule)
return factory
}
// RegisterConstructor registers a constructor for a known module key.
func (f *Factory) RegisterConstructor(moduleKey string, constructor Constructor) error {
if f == nil {
return fmt.Errorf("module factory is nil")
}
key := strings.TrimSpace(moduleKey)
if !IsKnownModuleKey(key) {
return &UnsupportedModuleError{ModuleKey: key}
}
if constructor == nil {
return fmt.Errorf("constructor for module %q must not be nil", key)
}
f.constructors[key] = constructor
return nil
}
func constructGrammarModule(ctx context.Context, req ConstructRequest) (contracts.TranscriptModule, error) {
_ = ctx
_ = req
return grammarmodule.New()
}
func constructGlossaryModule(ctx context.Context, req ConstructRequest) (contracts.TranscriptModule, error) {
_ = ctx
_ = req
return glossarymodule.New()
}
func constructHomophonesModule(ctx context.Context, req ConstructRequest) (contracts.TranscriptModule, error) {
_ = ctx
_ = req
return homophonesmodule.New()
}
func constructSpokenWordModule(ctx context.Context, req ConstructRequest) (contracts.TranscriptModule, error) {
_ = ctx
_ = req
return spokenwordmodule.New()
}
// ModuleForSpec resolves one configured run spec into a module instance.
func (f *Factory) ModuleForSpec(spec contracts.ModuleRunSpec) (contracts.TranscriptModule, error) {
if f == nil {
return nil, fmt.Errorf("module factory is nil")
}
key := strings.TrimSpace(spec.ModuleKey)
if !IsKnownModuleKey(key) {
return nil, &UnsupportedModuleError{ModuleKey: key}
}
constructor, ok := f.constructors[key]
if !ok || constructor == nil {
return nil, fmt.Errorf("internal module registry error: constructor for module %q is not configured", key)
}
module, err := constructor(context.Background(), ConstructRequest{RunSpec: spec})
if err != nil {
return nil, fmt.Errorf("construct module %q: %w", spec.InstanceName, err)
}
if module == nil {
return nil, fmt.Errorf("constructor for module %q returned nil module", key)
}
return module, nil
}
// UnsupportedModuleError indicates a configured module key is unknown.
type UnsupportedModuleError struct {
ModuleKey string
}
func (e *UnsupportedModuleError) Error() string {
return fmt.Sprintf("unsupported module key %q", strings.TrimSpace(e.ModuleKey))
}
// ReasonCode returns a stable reason code suitable for reporting.
func (e *UnsupportedModuleError) ReasonCode() string {
return ReasonUnsupportedModule
}

View File

@@ -1,164 +0,0 @@
package modules
import (
"context"
"errors"
frameworkvalidators "gitea.maximumdirect.net/eric/audita/v3/internal/framework/validators"
"strings"
"testing"
"gitea.maximumdirect.net/eric/audita/v3/internal/core/config"
"gitea.maximumdirect.net/eric/audita/v3/internal/core/modulecatalog"
"gitea.maximumdirect.net/eric/audita/v3/internal/framework/contracts"
"gitea.maximumdirect.net/eric/audita/v3/internal/framework/proposals"
)
type noopModule struct {
key string
}
func (m noopModule) Key() string { return m.key }
func (m noopModule) ReplacementPolicy() proposals.ReplacementPolicy {
return proposals.ReplacementPolicyRequireUnique
}
func (m noopModule) Validators() []frameworkvalidators.Validator { return nil }
func (m noopModule) Propose(ctx context.Context, req contracts.ProposalRequest) (contracts.ProposalResult, error) {
_ = ctx
_ = req
return contracts.ProposalResult{}, nil
}
func TestKnownModuleKeyRecognition(t *testing.T) {
for _, key := range modulecatalog.SupportedKeys() {
if !IsKnownModuleKey(key) {
t.Fatalf("expected key %q to be recognized", key)
}
}
}
func TestUnknownModuleKeyNotRecognized(t *testing.T) {
if IsKnownModuleKey("made_up") {
t.Fatal("expected unknown key to be unrecognized")
}
}
func TestRepeatedRunSpecNamingRemainsDeterministic(t *testing.T) {
specs := contracts.ResolveModuleRunSpecs(&config.Config{Pipeline: config.Pipeline{Stages: []config.Stage{{Module: "glossary"}, {Module: "glossary"}, {Module: "grammar"}}}})
if specs[0].InstanceName != "glossary_1" || specs[1].InstanceName != "glossary_2" || specs[2].InstanceName != "grammar_3" {
t.Fatalf("unexpected instance names: %+v", specs)
}
}
func TestUnsupportedUnknownModuleKeyFailsCleanly(t *testing.T) {
factory := NewFactory()
_, err := factory.ModuleForSpec(contracts.ModuleRunSpec{ModuleKey: "unknown", InstanceName: "unknown"})
if err == nil {
t.Fatal("expected unsupported-module error")
}
var unsupported *UnsupportedModuleError
if !errors.As(err, &unsupported) {
t.Fatalf("expected UnsupportedModuleError, got %T (%v)", err, err)
}
if unsupported.ReasonCode() != ReasonUnsupportedModule {
t.Fatalf("unexpected reason code: %q", unsupported.ReasonCode())
}
}
func TestRecognizedButMissingConstructorFailsWithInternalRegistryError(t *testing.T) {
factory := NewFactory()
// Force a missing constructor state for a known key.
factory.constructors[ModuleKeySpokenWord] = nil
_, err := factory.ModuleForSpec(contracts.ModuleRunSpec{ModuleKey: ModuleKeySpokenWord, InstanceName: ModuleKeySpokenWord})
if err == nil {
t.Fatal("expected constructor-missing error")
}
if !strings.Contains(err.Error(), "internal module registry error") {
t.Fatalf("expected internal registry error, got %v", err)
}
}
func TestGrammarIsRegisteredAndConstructibleByDefault(t *testing.T) {
factory := NewFactory()
module, err := factory.ModuleForSpec(contracts.ModuleRunSpec{ModuleKey: ModuleKeyGrammar, InstanceName: ModuleKeyGrammar})
if err != nil {
t.Fatalf("ModuleForSpec error: %v", err)
}
if module.Key() != ModuleKeyGrammar {
t.Fatalf("expected grammar module key, got %q", module.Key())
}
}
func TestGlossaryIsRegisteredAndConstructibleByDefault(t *testing.T) {
factory := NewFactory()
module, err := factory.ModuleForSpec(contracts.ModuleRunSpec{ModuleKey: ModuleKeyGlossary, InstanceName: ModuleKeyGlossary})
if err != nil {
t.Fatalf("ModuleForSpec error: %v", err)
}
if module.Key() != ModuleKeyGlossary {
t.Fatalf("expected glossary module key, got %q", module.Key())
}
}
func TestHomophonesIsRegisteredAndConstructibleByDefault(t *testing.T) {
factory := NewFactory()
module, err := factory.ModuleForSpec(contracts.ModuleRunSpec{ModuleKey: ModuleKeyHomophones, InstanceName: ModuleKeyHomophones})
if err != nil {
t.Fatalf("ModuleForSpec error: %v", err)
}
if module.Key() != ModuleKeyHomophones {
t.Fatalf("expected homophones module key, got %q", module.Key())
}
}
func TestSpokenWordIsRegisteredAndConstructibleByDefault(t *testing.T) {
factory := NewFactory()
module, err := factory.ModuleForSpec(contracts.ModuleRunSpec{ModuleKey: ModuleKeySpokenWord, InstanceName: ModuleKeySpokenWord})
if err != nil {
t.Fatalf("ModuleForSpec error: %v", err)
}
if module.Key() != ModuleKeySpokenWord {
t.Fatalf("expected spoken_word module key, got %q", module.Key())
}
}
func TestRegisterConstructorAndConstruct(t *testing.T) {
factory := NewFactory()
if err := factory.RegisterConstructor(ModuleKeyGlossary, func(ctx context.Context, req ConstructRequest) (contracts.TranscriptModule, error) {
_ = ctx
if req.RunSpec.InstanceName != "glossary_1" {
t.Fatalf("expected run spec instance name, got %q", req.RunSpec.InstanceName)
}
return noopModule{key: req.RunSpec.ModuleKey}, nil
}); err != nil {
t.Fatalf("RegisterConstructor error: %v", err)
}
module, err := factory.ModuleForSpec(contracts.ModuleRunSpec{
ModuleKey: ModuleKeyGlossary,
InstanceName: "glossary_1",
})
if err != nil {
t.Fatalf("ModuleForSpec error: %v", err)
}
if module.Key() != ModuleKeyGlossary {
t.Fatalf("unexpected module key %q", module.Key())
}
}
func TestRegisterConstructorRejectsUnknownModuleKey(t *testing.T) {
factory := NewFactory()
err := factory.RegisterConstructor("unknown", func(ctx context.Context, req ConstructRequest) (contracts.TranscriptModule, error) {
_ = ctx
_ = req
return noopModule{key: "unknown"}, nil
})
if err == nil {
t.Fatal("expected register failure for unknown key")
}
var unsupported *UnsupportedModuleError
if !errors.As(err, &unsupported) {
t.Fatalf("expected UnsupportedModuleError, got %T (%v)", err, err)
}
}

View File

@@ -11,6 +11,7 @@ import (
"gitea.maximumdirect.net/eric/audita/v3/internal/core/diagnostics"
"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/contracts"
)
// Input contains already acquired application and transcript inputs.
@@ -32,6 +33,7 @@ type DebugInput struct {
}
type Prepared struct {
Specs []contracts.ModuleRunSpec
Output *diagnostics.OutputSession
Debug *diagnostics.RunDirectory
Warnings []error
@@ -48,7 +50,8 @@ func Prepare(ctx context.Context, input Input) (*Prepared, error) {
if input.Transcript == nil {
return nil, fmt.Errorf("transcript is required")
}
if err := CheckReadiness(ctx, input.Config, input.InspectProfile); err != nil {
specs, err := ProcessingPlan(ctx, input.Config, input.InspectProfile)
if err != nil {
return nil, err
}
session, err := diagnostics.SelectOutput(input.Output)
@@ -73,7 +76,7 @@ func Prepare(ctx context.Context, input Input) (*Prepared, error) {
if err := ctx.Err(); err != nil {
return nil, cancelOutput(err)
}
result := &Prepared{Output: session}
result := &Prepared{Specs: specs, Output: session}
if input.Debug != nil {
result.Debug, result.Warnings = diagnostics.PrepareDebug(input.Debug.WorkDir, input.Debug.RunID, input.Debug.Metadata, input.Debug.EffectiveConfig)
}
@@ -83,10 +86,19 @@ func Prepare(ctx context.Context, input Input) (*Prepared, error) {
return result, nil
}
// CheckReadiness checks all resolved processing selections before output preparation.
func CheckReadiness(ctx context.Context, cfg *config.Config, inspectProfile func(context.Context, string) error) error {
// SelectionError indicates that resolved operator settings cannot be used for processing.
type SelectionError struct{ Cause error }
func (e *SelectionError) Error() string { return e.Cause.Error() }
func (e *SelectionError) Unwrap() error { return e.Cause }
// ProcessingPlan checks all resolved selections before acquiring outputs.
func ProcessingPlan(ctx context.Context, cfg *config.Config, inspectProfile func(context.Context, string) error) ([]contracts.ModuleRunSpec, error) {
if err := ctx.Err(); err != nil {
return nil, err
}
if cfg == nil {
return fmt.Errorf("application configuration is required")
return nil, fmt.Errorf("application configuration is required")
}
label := func(index int, item config.Stage) string {
if item.ID != nil {
@@ -102,9 +114,10 @@ func CheckReadiness(ctx context.Context, cfg *config.Config, inspectProfile func
return len(cfg.GlossaryCollections[name].Entries) > 0
})
if !hasEntries {
return fmt.Errorf("%s has no glossary entries in selected collections %q", label(index, item), item.Glossaries)
return nil, &SelectionError{Cause: fmt.Errorf("%s has no glossary entries in selected collections %q", label(index, item), item.Glossaries)}
}
}
checkedProfiles := make(map[string]struct{})
for index, item := range cfg.Pipeline.Stages {
selections := []struct {
role string
@@ -118,15 +131,49 @@ func CheckReadiness(ctx context.Context, cfg *config.Config, inspectProfile func
}
for _, selection := range selections {
if selection.profile == nil || *selection.profile == "" {
return fmt.Errorf("%s requires a %s profile", label(index, item), selection.role)
return nil, &SelectionError{Cause: fmt.Errorf("%s requires a %s profile", label(index, item), selection.role)}
}
if inspectProfile == nil {
return fmt.Errorf("profile inspection is required")
return nil, fmt.Errorf("profile inspection is required")
}
if err := inspectProfile(ctx, *selection.profile); err != nil {
return fmt.Errorf("%s %s profile %q: %w", label(index, item), selection.role, *selection.profile, err)
if err := ctx.Err(); err != nil {
return nil, err
}
id := *selection.profile
if _, ok := checkedProfiles[id]; ok {
continue
}
if err := inspectProfile(ctx, id); err != nil {
return nil, fmt.Errorf("%s %s profile %q: %w", label(index, item), selection.role, id, err)
}
checkedProfiles[id] = struct{}{}
}
}
return ctx.Err()
specs := contracts.ResolveModuleRunSpecs(cfg)
type glossarySelection struct {
context, protected string
exempt bool
}
glossaryViews := make(map[glossarySelection]int)
for i := range specs {
if err := ctx.Err(); err != nil {
return nil, err
}
spec := &specs[i]
key := glossarySelection{
context: fmt.Sprintf("%q", spec.Settings.Glossaries),
protected: fmt.Sprintf("%q", spec.Settings.ProtectedTerms),
exempt: spec.ModuleKey == modulecatalog.KeyGlossary,
}
if prior, ok := glossaryViews[key]; ok {
spec.GlossaryVariables = specs[prior].GlossaryVariables
spec.GlossaryView = specs[prior].GlossaryView
continue
}
if err := spec.PrepareGlossary(); err != nil {
return nil, fmt.Errorf("%s glossary preparation: %w", label(i, spec.Settings), err)
}
glossaryViews[key] = i
}
return specs, ctx.Err()
}

View File

@@ -2,9 +2,11 @@ package preflight
import (
"context"
"errors"
"fmt"
"os"
"path/filepath"
"slices"
"strings"
"testing"
@@ -34,7 +36,7 @@ func TestLaterEmptyGlossaryFailsBeforeOutputPreparation(t *testing.T) {
}
func TestEmptyPipelineNeedsNoProfile(t *testing.T) {
if err := CheckReadiness(context.Background(), &config.Config{}, nil); err != nil {
if _, err := ProcessingPlan(context.Background(), &config.Config{}, nil); err != nil {
t.Fatal(err)
}
}
@@ -48,7 +50,7 @@ func TestCorrectionRepairReadinessDependsOnBudget(t *testing.T) {
}
return nil
}
if err := CheckReadiness(context.Background(), cfg, inspect); err != nil {
if _, err := ProcessingPlan(context.Background(), cfg, inspect); err != nil {
t.Fatal(err)
}
cfg.Pipeline.Stages[0].LLM.CorrectionRepairAttempts = 1
@@ -61,3 +63,55 @@ func TestCorrectionRepairReadinessDependsOnBudget(t *testing.T) {
t.Fatalf("output exists: %v", err)
}
}
func TestProcessingPlanReusesOnlyMatchingGlossaryViews(t *testing.T) {
profile := "selected"
item := config.Stage{Module: "grammar", Glossaries: []string{"a", "b"}, ProtectedTerms: []string{"a"},
LLM: config.LLM{ProposalProfile: &profile, ValidationProfile: &profile}}
reversed := item
reversed.Glossaries = []string{"b", "a"}
exempt := item
exempt.Module = "glossary"
cfg := &config.Config{
GlossaryCollections: map[string]config.GlossaryCollection{
"a": {Entries: []config.GlossaryEntry{{ID: "a", Name: "A"}}},
"b": {Entries: []config.GlossaryEntry{{ID: "b", Name: "B"}}},
},
Pipeline: config.Pipeline{Stages: []config.Stage{item, item, reversed, exempt}},
}
var inspected []string
plan, err := ProcessingPlan(context.Background(), cfg, func(_ context.Context, id string) error {
inspected = append(inspected, id)
return nil
})
if err != nil || len(plan) != 4 || !slices.Equal(inspected, []string{profile}) {
t.Fatalf("plan=%+v inspections=%v error=%v", plan, inspected, err)
}
if plan[0].GlossaryView != plan[1].GlossaryView || plan[0].GlossaryVariables != plan[1].GlossaryVariables ||
plan[0].GlossaryView == plan[2].GlossaryView || plan[0].GlossaryView == plan[3].GlossaryView ||
plan[2].Glossary[0].ID != "b" || plan[3].GlossaryVariables.ProtectionJSON != "[]" {
t.Fatalf("incorrect glossary reuse or exemptions: %+v", plan)
}
}
func TestProcessingPlanPreservesFirstInspectionFailureAndCause(t *testing.T) {
proposal, validation := "proposal", "bad"
cfg := &config.Config{Pipeline: config.Pipeline{Stages: []config.Stage{
{Module: "grammar", LLM: config.LLM{ProposalProfile: &proposal, ValidationProfile: &validation}},
{Module: "grammar"},
}}}
runtimeErr := errors.New("inspection failed")
var checked []string
_, err := ProcessingPlan(context.Background(), cfg, func(_ context.Context, id string) error {
checked = append(checked, id)
if id == validation {
return runtimeErr
}
return nil
})
var selection *SelectionError
if !errors.Is(err, runtimeErr) || errors.As(err, &selection) || !strings.Contains(err.Error(), "stage 1 (grammar) validation") ||
!slices.Equal(checked, []string{proposal, validation}) {
t.Fatalf("inspected %v, error %v", checked, err)
}
}

View File

@@ -163,11 +163,9 @@ func (r *Runner) Run(ctx context.Context, input RunInput) (RunOutput, error) {
}
policy := module.ReplacementPolicy()
glossaryVariables, err := promptcontext.PrepareGlossaryVariables(spec.Glossary, spec.ProtectedTerms)
if err != nil {
if err := spec.PrepareGlossary(); err != nil {
return snapshot(), fmt.Errorf("module %q glossary preparation: %w", spec.InstanceName, err)
}
glossaryView := validators.PrepareGlossaryView(spec.Glossary, spec.ProtectedTerms)
pipelineResult, pipelineErr := runModulePipeline(ctx, collectSectionProposalsInput{
Module: module,
Spec: spec,
@@ -176,8 +174,8 @@ func (r *Runner) Run(ctx context.Context, input RunInput) (RunOutput, error) {
ProposalClient: spec.ProposalClient,
Interactions: input.Interactions,
ValidationClient: spec.ValidationClient,
GlossaryVariables: &glossaryVariables,
GlossaryView: glossaryView,
GlossaryVariables: spec.GlossaryVariables,
GlossaryView: spec.GlossaryView,
})
if input.CaptureCandidates {
candidates = append(candidates, pipelineResult.Candidates...)
@@ -213,7 +211,7 @@ func (r *Runner) Run(ctx context.Context, input RunInput) (RunOutput, error) {
return snapshot(), fmt.Errorf("module %q failed: %w", spec.InstanceName, pipelineErr)
}
updated, applied, skipped, appliedBySection, applyErr := applyWithinSections(sections, pipelineResult.Approved, policy, glossaryView.Protection, spec.ModuleKey == modulecatalog.KeySpokenWord)
updated, applied, skipped, appliedBySection, applyErr := applyWithinSections(sections, pipelineResult.Approved, policy, spec.GlossaryView.Protection, spec.ModuleKey == modulecatalog.KeySpokenWord)
if applyErr != nil {
for i := range pipelineResult.WorkUnits {
unit := &pipelineResult.WorkUnits[i]