Cleanup pass to remove refactoring-related artifacts and references

This commit is contained in:
2026-05-12 15:19:50 -05:00
parent af84249da0
commit 390daa8b84
24 changed files with 138 additions and 173 deletions

View File

@@ -22,8 +22,7 @@ const (
)
const (
ReasonUnsupportedModule = "unsupported_module"
ReasonUnimplementedModule = "unimplemented_module"
ReasonUnsupportedModule = "unsupported_module"
)
var knownModuleKeys = map[string]struct{}{
@@ -66,8 +65,7 @@ type Factory struct {
constructors map[string]Constructor
}
// NewFactory creates a production registry scaffold with known module keys but
// no real module constructors registered yet.
// NewFactory creates a production module registry.
func NewFactory(deps Dependencies) *Factory {
factory := &Factory{
deps: deps,
@@ -133,7 +131,7 @@ func (f *Factory) ModuleForSpec(spec contracts.ModuleRunSpec) (contracts.Transcr
constructor, ok := f.constructors[key]
if !ok || constructor == nil {
return nil, &UnimplementedModuleError{ModuleKey: key}
return nil, fmt.Errorf("internal module registry error: constructor for module %q is not configured", key)
}
module, err := constructor(context.Background(), ConstructRequest{
@@ -170,17 +168,3 @@ func (e *UnsupportedModuleError) Error() string {
func (e *UnsupportedModuleError) ReasonCode() string {
return ReasonUnsupportedModule
}
// UnimplementedModuleError indicates a known module key without constructor.
type UnimplementedModuleError struct {
ModuleKey string
}
func (e *UnimplementedModuleError) Error() string {
return fmt.Sprintf("module %q is recognized but not implemented", strings.TrimSpace(e.ModuleKey))
}
// ReasonCode returns a stable reason code suitable for reporting.
func (e *UnimplementedModuleError) ReasonCode() string {
return ReasonUnimplementedModule
}

View File

@@ -3,6 +3,7 @@ package modules
import (
"context"
"errors"
"strings"
"testing"
"gitea.maximumdirect.net/eric/audita/internal/framework/contracts"
@@ -64,22 +65,17 @@ func TestUnsupportedUnknownModuleKeyFailsCleanly(t *testing.T) {
}
}
func TestRecognizedButUnimplementedModuleKeyFailsCleanly(t *testing.T) {
func TestRecognizedButMissingConstructorFailsWithInternalRegistryError(t *testing.T) {
factory := NewFactory(Dependencies{})
// Force an unimplemented state for a known key to keep reason-code behavior tested.
// 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 unimplemented-module error")
t.Fatal("expected constructor-missing error")
}
var unimplemented *UnimplementedModuleError
if !errors.As(err, &unimplemented) {
t.Fatalf("expected UnimplementedModuleError, got %T (%v)", err, err)
}
if unimplemented.ReasonCode() != ReasonUnimplementedModule {
t.Fatalf("unexpected reason code: %q", unimplemented.ReasonCode())
if !strings.Contains(err.Error(), "internal module registry error") {
t.Fatalf("expected internal registry error, got %v", err)
}
}