diff --git a/docs/roadmap/remediation.md b/docs/roadmap/remediation.md index d82e2091..0dcbc548 100644 --- a/docs/roadmap/remediation.md +++ b/docs/roadmap/remediation.md @@ -288,16 +288,20 @@ contracts to work around the framework's own unbounded sample. ## Finding 5: Remove The Disconnected Legacy LLM Error Contract +**Status: Complete.** Removed the unused legacy error taxonomy and its self-test; +current execution retains native PromptKit errors and application assessment/ +capture errors. Contracts, pipeline, CLI, and module integration tests pass. + Priority: P3. Relevant stages: 8, 24, 35, and 44. ### Evidence And Impact -[`contracts/errors.go`](../../internal/framework/contracts/errors.go) still +At the reviewed baseline, `internal/framework/contracts/errors.go` still defines the pre-migration `ErrInvalidStructuredOutput`, `ErrLLMCapacityExceeded`, `ErrLLMGeneration`, `LLMGenerationError`, constructors, and copied failure/attempt metadata. Current producers and validators retain native PromptKit errors instead. Graph/code searches find this old taxonomy only in that file and its -[self-test](../../internal/framework/contracts/errors_test.go), not in an active +self-test (`internal/framework/contracts/errors_test.go`), not in an active application consumer. This is leftover contract surface from the removed adapter, not a second active diff --git a/internal/framework/contracts/errors.go b/internal/framework/contracts/errors.go deleted file mode 100644 index 166b7505..00000000 --- a/internal/framework/contracts/errors.go +++ /dev/null @@ -1,83 +0,0 @@ -package contracts - -import "errors" - -// ErrInvalidStructuredOutput identifies a provider response that cannot satisfy -// the caller's declared structured-output contract. -var ErrInvalidStructuredOutput = errors.New("invalid structured output") - -// ErrLLMCapacityExceeded identifies backend admission exhaustion before model -// generation begins. -var ErrLLMCapacityExceeded = errors.New("LLM capacity exceeded") - -// ErrLLMGeneration identifies a provider generation failure. -var ErrLLMGeneration = errors.New("LLM generation failed") - -type LLMGenerationFailureKind string - -const ( - LLMGenerationFailureGeneration LLMGenerationFailureKind = "generation" - LLMGenerationFailureTransport LLMGenerationFailureKind = "transport" - LLMGenerationFailureProviderStatus LLMGenerationFailureKind = "provider_status" - LLMGenerationFailureMalformedResponse LLMGenerationFailureKind = "malformed_response" -) - -type LLMGenerationMetadata struct { - FailureKind LLMGenerationFailureKind - RetriesExhausted bool - Attempts uint64 -} - -type LLMGenerationError struct { - status int - diagnostic string - failureKind LLMGenerationFailureKind - exhausted bool - attempts uint64 -} - -func NewLLMGenerationError(status int, diagnostic string) *LLMGenerationError { - return NewLLMGenerationErrorWithMetadata(status, diagnostic, LLMGenerationMetadata{}) -} - -func NewLLMGenerationErrorWithMetadata(status int, diagnostic string, metadata LLMGenerationMetadata) *LLMGenerationError { - if status < 0 { - status = 0 - } - kind := metadata.FailureKind - if kind == "" { - kind = LLMGenerationFailureGeneration - } - return &LLMGenerationError{status: status, diagnostic: diagnostic, failureKind: kind, exhausted: metadata.RetriesExhausted, attempts: metadata.Attempts} -} -func (e *LLMGenerationError) Error() string { - if e == nil || e.diagnostic == "" { - return ErrLLMGeneration.Error() - } - return e.diagnostic -} -func (e *LLMGenerationError) Unwrap() error { return ErrLLMGeneration } -func (e *LLMGenerationError) StatusCode() int { - if e == nil { - return 0 - } - return e.status -} - -func (e *LLMGenerationError) FailureKind() LLMGenerationFailureKind { - if e == nil || e.failureKind == "" { - return LLMGenerationFailureGeneration - } - return e.failureKind -} - -func (e *LLMGenerationError) RetriesExhausted() bool { - return e != nil && e.exhausted -} - -func (e *LLMGenerationError) Attempts() uint64 { - if e == nil { - return 0 - } - return e.attempts -} diff --git a/internal/framework/contracts/errors_test.go b/internal/framework/contracts/errors_test.go deleted file mode 100644 index 24b656db..00000000 --- a/internal/framework/contracts/errors_test.go +++ /dev/null @@ -1,22 +0,0 @@ -package contracts - -import ( - "errors" - "testing" -) - -func TestLLMGenerationErrorPreservesApplicationMetadata(t *testing.T) { - legacy := NewLLMGenerationError(503, "provider failure") - if !errors.Is(legacy, ErrLLMGeneration) || legacy.StatusCode() != 503 || legacy.FailureKind() != LLMGenerationFailureGeneration || legacy.RetriesExhausted() || legacy.Attempts() != 0 { - t.Fatalf("legacy generation error = %#v", legacy) - } - - err := NewLLMGenerationErrorWithMetadata(429, "provider failure", LLMGenerationMetadata{ - FailureKind: LLMGenerationFailureProviderStatus, - RetriesExhausted: true, - Attempts: 3, - }) - if !errors.Is(err, ErrLLMGeneration) || err.StatusCode() != 429 || err.FailureKind() != LLMGenerationFailureProviderStatus || !err.RetriesExhausted() || err.Attempts() != 3 { - t.Fatalf("generation error = %#v", err) - } -}