diff --git a/docs/roadmap/remediation.md b/docs/roadmap/remediation.md index 5f7bf1d..7a7c7b1 100644 --- a/docs/roadmap/remediation.md +++ b/docs/roadmap/remediation.md @@ -3,14 +3,20 @@ Reviewed 2026-11-25 at `a949f23a87dc581e6beff400f440e09afcb23969`, against the nine stages in [implementation.md](implementation.md) and the accepted [remediation target](audit-remediation.md). Changes reviewed begin after -`6beddde`. Both findings below remain open; no fixes were implemented by this -review. +`6beddde`. The review itself implemented no fixes; subsequent remediation is +recorded by the completion markers below. ## 1. Non-Generation HTTP Errors Still Pin Noncontractual Sentences (P3) +**Status: complete.** Removed complete-sentence expectations from the HTTP error +mapping table while retaining status/code/precedence, usable-message, and +private-cause checks. Normal and race-enabled full suites, vet, build, formatting, +and whitespace checks passed. The harmless artifact-error rewording overlay now +passes the full mapping table. Runtime messages are unchanged. + **Type:** incomplete stage 5 test cleanup; unnecessary test-level contract. -**Location:** `TestHandlerPublicErrorMapping`, especially the conditional at -[handler_test.go:1747](../../internal/adapter/http/handler_test.go#L1747). +**Location:** `TestHandlerPublicErrorMapping` in +[handler_test.go](../../internal/adapter/http/handler_test.go). The revised table exempts only `llm_failed` from exact message comparison. Artifact, profile, prompt, capacity, and other rows still require complete diff --git a/internal/adapter/http/handler_test.go b/internal/adapter/http/handler_test.go index 883f91e..3ce9cb6 100644 --- a/internal/adapter/http/handler_test.go +++ b/internal/adapter/http/handler_test.go @@ -1696,29 +1696,28 @@ func TestHandlerPublicErrorMapping(t *testing.T) { err error status int code string - message string avoidCause string }{ - {name: "prompt not found", err: promptkit.ErrPromptNotFound, status: http.StatusNotFound, code: "prompt_not_found", message: "prompt definition not found"}, - {name: "prompt load", err: wrap(promptkit.ErrPromptLoad, fmt.Errorf("read failed")), status: http.StatusBadRequest, code: "prompt_load_failed", message: "failed to load prompt definition", avoidCause: "read failed"}, - {name: "missing profile/default", err: wrap(promptkit.ErrProfileRequired, promptkit.ErrInvalidRequest), status: http.StatusBadRequest, code: "profile_required", message: "profile_id is required when prompt default_profile is not set"}, - {name: "profile not found", err: promptkit.ErrProfileNotFound, status: http.StatusNotFound, code: "profile_not_found", message: "execution profile not found"}, - {name: "profile load", err: wrap(promptkit.ErrProfileLoad, fmt.Errorf("read failed")), status: http.StatusBadRequest, code: "profile_load_failed", message: "failed to load execution profile", avoidCause: "read failed"}, - {name: "api key env missing", err: wrap(promptkit.ErrAPIKeyEnvMissing, promptkit.ErrInvalidRequest), status: http.StatusBadRequest, code: "api_key_env_missing", message: "api_key_env is set but the environment variable is missing"}, - {name: "invalid request", err: promptkit.ErrInvalidRequest, status: http.StatusBadRequest, code: "invalid_request", message: "invalid run request"}, - {name: "file denied", err: ErrFileNotAllowed, status: http.StatusBadRequest, code: "artifact_not_allowed", message: "file input artifact is not allowed"}, - {name: "file outside root", err: ErrFileOutsideRoot, status: http.StatusBadRequest, code: "artifact_not_allowed", message: "file input artifact is not allowed"}, - {name: "file too large", err: ErrFileTooLarge, status: http.StatusRequestEntityTooLarge, code: "artifact_too_large", message: "file input artifact is too large"}, - {name: "file too large with broad category", err: errors.Join(ErrFileTooLarge, promptkit.ErrInvalidRequest, promptkit.ErrArtifactLoad), status: http.StatusRequestEntityTooLarge, code: "artifact_too_large", message: "file input artifact is too large"}, - {name: "artifact", err: wrap(promptkit.ErrArtifactLoad, fmt.Errorf("read failed")), status: http.StatusBadRequest, code: "artifact_read_failed", message: "failed to read input artifact", avoidCause: "read failed"}, - {name: "prompt render", err: wrap(promptkit.ErrPromptRender, fmt.Errorf("render failed")), status: http.StatusBadRequest, code: "prompt_render_failed", message: "failed to render prompt", avoidCause: "render failed"}, - {name: "capacity", err: &promptkit.CapacityError{BackendID: "private-backend"}, status: http.StatusServiceUnavailable, code: "capacity_exceeded", message: "model backend capacity is exhausted", avoidCause: "private-backend"}, + {name: "prompt not found", err: promptkit.ErrPromptNotFound, status: http.StatusNotFound, code: "prompt_not_found"}, + {name: "prompt load", err: wrap(promptkit.ErrPromptLoad, fmt.Errorf("read failed")), status: http.StatusBadRequest, code: "prompt_load_failed", avoidCause: "read failed"}, + {name: "missing profile/default", err: wrap(promptkit.ErrProfileRequired, promptkit.ErrInvalidRequest), status: http.StatusBadRequest, code: "profile_required"}, + {name: "profile not found", err: promptkit.ErrProfileNotFound, status: http.StatusNotFound, code: "profile_not_found"}, + {name: "profile load", err: wrap(promptkit.ErrProfileLoad, fmt.Errorf("read failed")), status: http.StatusBadRequest, code: "profile_load_failed", avoidCause: "read failed"}, + {name: "api key env missing", err: wrap(promptkit.ErrAPIKeyEnvMissing, promptkit.ErrInvalidRequest), status: http.StatusBadRequest, code: "api_key_env_missing"}, + {name: "invalid request", err: promptkit.ErrInvalidRequest, status: http.StatusBadRequest, code: "invalid_request"}, + {name: "file denied", err: ErrFileNotAllowed, status: http.StatusBadRequest, code: "artifact_not_allowed"}, + {name: "file outside root", err: ErrFileOutsideRoot, status: http.StatusBadRequest, code: "artifact_not_allowed"}, + {name: "file too large", err: ErrFileTooLarge, status: http.StatusRequestEntityTooLarge, code: "artifact_too_large"}, + {name: "file too large with broad category", err: errors.Join(ErrFileTooLarge, promptkit.ErrInvalidRequest, promptkit.ErrArtifactLoad), status: http.StatusRequestEntityTooLarge, code: "artifact_too_large"}, + {name: "artifact", err: wrap(promptkit.ErrArtifactLoad, fmt.Errorf("read failed")), status: http.StatusBadRequest, code: "artifact_read_failed", avoidCause: "read failed"}, + {name: "prompt render", err: wrap(promptkit.ErrPromptRender, fmt.Errorf("render failed")), status: http.StatusBadRequest, code: "prompt_render_failed", avoidCause: "render failed"}, + {name: "capacity", err: &promptkit.CapacityError{BackendID: "private-backend"}, status: http.StatusServiceUnavailable, code: "capacity_exceeded", avoidCause: "private-backend"}, {name: "llm", err: wrap(promptkit.ErrLLMGenerate, fmt.Errorf("llm failed")), status: http.StatusBadGateway, code: "llm_failed", avoidCause: "llm failed"}, {name: "transport", err: wrap(promptkit.ErrTransport, fmt.Errorf("private transport detail")), status: http.StatusBadGateway, code: "llm_failed", avoidCause: "private transport detail"}, {name: "malformed response", err: wrap(promptkit.ErrMalformedResponse, fmt.Errorf("private response detail")), status: http.StatusBadGateway, code: "llm_failed", avoidCause: "private response detail"}, {name: "retry exhaustion", err: wrap(promptkit.ErrRetriesExhausted, fmt.Errorf("private provider detail")), status: http.StatusBadGateway, code: "llm_failed", avoidCause: "private provider detail"}, {name: "retry exhaustion value", err: fmt.Errorf("generation: %w", &promptkit.RetryExhaustedError{}), status: http.StatusBadGateway, code: "llm_failed"}, - {name: "validation runtime", err: wrap(promptkit.ErrValidation, fmt.Errorf("validator broke")), status: http.StatusInternalServerError, code: "validation_runtime_failed", message: "validation runtime failed", avoidCause: "validator broke"}, + {name: "validation runtime", err: wrap(promptkit.ErrValidation, fmt.Errorf("validator broke")), status: http.StatusInternalServerError, code: "validation_runtime_failed", avoidCause: "validator broke"}, } for _, tc := range tests { @@ -1744,9 +1743,6 @@ func TestHandlerPublicErrorMapping(t *testing.T) { if !ok || strings.TrimSpace(message) == "" { t.Fatalf("expected a usable message, got %#v", errBody["message"]) } - if tc.code != "llm_failed" && message != tc.message { - t.Fatalf("expected message %q, got %#v", tc.message, errBody["message"]) - } if tc.avoidCause != "" && strings.Contains(w.Body.String(), tc.avoidCause) { t.Fatalf("expected response to avoid leaking cause details, got %s", w.Body.String()) }