fix(llm): forbid year hallucination in comic identify prompt (bookshelf-3493) #985
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "bd-bookshelf-3493"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
comicIdentifyPromptininternal/metadata/llm/llm.goto FORBID the vision model from guessing or inferring the cover year from prior knowledgepackage llm_test) that capture the outgoing request body and assert: (a) new emphatic instructions are present, (b) old weak phrasing is absentcomicIssueRealready handles absent year → empty string)Test plan
make testpassesDescribe("Identify — comic prompt body")specs assert the request body contains "Do NOT guess", "LEGIBLY PRINTED", "better to omit", and does NOT contain the old weak sentencesIdentifyspecs continue to pass (output contract unchanged)golangci-lint run ./internal/metadata/llm/...— 0 issuesCloses bead bookshelf-3493 on merge.
Security Review — bookshelf-3493
Diff scope: prompt-string edit in
internal/metadata/llm/llm.go+ accompanying test inllm_test.go. No new endpoint, HTTP surface, external call, or dependency introduced.Checks performed:
llm.Config{BaseURL: server.URL, Model: "test-model"}(synthetic, httptest-local values only).httptest.NewServerserves a hard-coded synthetic JSON blob; no real endpoint URL, no real API key, no PII.package llm_test; all referenced symbols use thellm.prefix. Black-box convention satisfied.No findings.
REVIEW VERDICT: 0 blocker, 0 major, 0 minor
CODE REVIEW: APPROVED
Phase 0: DEMO Verification
No DEMO block - this PR is a prompt-text + test change with no runnable CLI command. CI is green and the diff is self-verifying via the new test. Proceeding.
Phase 1: Spec Compliance
Diff: internal/metadata/llm/llm.go and internal/metadata/llm/llm_test.go only.
Prompt strengthening (llm.go:245-252):
Output contract unchanged:
Domain boundary clean: No go-workflows/wfengine import in internal/metadata/llm.
Coverage exclusions: git diff origin/main -- scripts/check-coverage.sh is empty.
Phase 2: Code Quality
Test is black-box (llm_test.go:1): package llm_test confirmed. makeTestJPEG() comes from image_test.go (also package llm_test).
LLM mocked at httptest boundary: httptest.NewServer at llm_test.go:602 captures the outgoing request body. Assertions inspect capturedBody (actual serialized JSON sent over the wire), not the local const directly - would catch a bug where const is updated but not wired into the request.
Prompt assertions are non-vacuous:
Ordered + BeforeAll pattern: appropriate for run-once/assert-multiple - JustBeforeEach would re-fire per It and is not applicable here.
No bugs, no security issues, no convention violations found.
REVIEW VERDICT: 0 blocker, 0 major, 0 minor