Repository navigation
test(generate): kill 8 surviving mutants, gate workflows cancel, fix 2 doc claims - #218
Merged
Merged
Conversation
…x 2 doc claims Every gap below was verified-correct code with a missing or merely-spelled guard. Each mutation named was applied, confirmed to fail the new test WITH THAT GUARD'S OWN MESSAGE, and reverted. Coverage gaps closed (mutant -> KILLED): - confirmGenerate default-deny: `case "y","yes"` -> `case "n","no"` inverted, which silently turns [y/N] into [Y/n]. The suite only ever fed "y"/"n", and neither can see it. Table of 11 non-committal answers, all 0 submits. - generate + cancel non-TTY refusal: `!stdinIsTTY()` removed. Empty stdin could not discriminate (the prompt aborts on EOF anyway), so the guard was pinned by its wording; a piped "y" makes the SUBMIT COUNTER the discriminator. - pendingPath: `filepath.Base` dropped, letting --external-id ../../evil steer the write out of the pending dir. Containment asserted on the resolved parent dir plus an on-disk canary. - cost-vs-balance: `>` -> `>=`, refusing a job the user can exactly afford. - 401-replay: `status == 401` -> `status != 200`, replaying every 500/502/403. - degenerate dimensions: `<= 0` -> `< 0`. Measured: jpeg.Encode of a 16x0 image round-trips through image.DecodeConfig with err == nil, so a zero dimension really does reach the server (png.Encode refuses, hence jpeg fixtures). - response-body leaks in resolveRemoteImage and UploadImageBlob: `defer Close()` deleted. Observed by a recorder on the side the test owns, so there is no server-side race; 10/10 identical runs. Two mutants SURVIVE by design, and that is the finding: - The unsupported-format branch in decodeImageHeader is UNREACHABLE (only png and jpeg have decoders, both are map keys, everything else fails earlier with ErrFormat). No test can kill it without registering a third decoder, which gifBytes() documents as the thing that would destroy the real unsupported-format test. Labelled defensive-only in a comment, and the invariant that MAKES it unreachable is now pinned instead. - `req.ContentLength` in UploadPresigned is redundant: NewRequestWithContext already sizes a *bytes.Reader. Kept as documented belt-and-braces rather than deleted, and the existing Content-Length assertion is re-labelled as pinning the outcome, not our line. Behaviour change: `civitai workflows cancel` now confirms. It is the only irreversible action here and it destroys a job already paid for, while every other destructive path gates. --yes/-y proceeds, a TTY prompts (default no), a non-TTY without --yes refuses. The gate runs before the seam, so a refusal cannot have cancelled anything. Existing help text is unchanged: cancelling still does NOT refund. Doc corrections: - AGENTS.md item 17 named `orchestration.civitai.com`; the host observed in a real upload reply is `orchestration-new.civitai.com`. Both match `*.civitai.com`, so isTrustedDownloadHost attaches the token either way and the credential-free seam is required regardless — the wildcard is the load-bearing fact, so both items now say so explicitly instead of naming a hostname a rename can invalidate. (Item 19(e) already used the generic form; it gains the observed host and the same caveat.) - pendingGeneration.PayloadHash claimed a re-attach could tell "the same job" from "a different job that reused the key". Nothing reads the field back — the only reader, recordPendingWorkflowID, rewrites it. Reworded honestly; the field is kept, since the value is only obtainable at submit time. Verification: full suite COUNTED at 2076 RUN / 2072 PASS / 0 FAIL / 4 SKIP (the four by-design skips), 0 timeout panics; gofmt -s -l . flags 0 of 258 files; golangci-lint 2.12.2 reports 0 issues (validated against a known-bad state — a planted misspelling in a new file was caught, so the verdict covers them); go vet clean; -race clean. No test touches a live server and no mutation call was ever issued.
ZacxDev
added a commit
that referenced
this pull request
Aug 7, 2026
* docs(handoff): capture the civitai generate session state Records what shipped (#210/#215/#218/#221), the three platform issues and their outcomes, and the live diagnosis state for the two open follow-ups so the next session does not re-run probes that already have answers. Also captures the traps that cost real time here: make ci runs neither gofmt nor golangci-lint, zsh does not word-split unquoted parameters, a test hang prints FAIL with no --- FAIL line, and the img2img promotion detector that must never be re-added because three edit-capable ecosystems price identically with and without images. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * docs(handoff): retract a wrong diagnosis before anyone acts on it Investigation 1 described a hazard that does not exist on main. The finding was real but against PR #222 -- a competing implementation of the same feature that DID resolve version ids to names in the render path. #222 was closed as a duplicate and #221 merged instead; I carried the finding across without re-reading the merged code. Verified at ba3136c: reportModelSubstitutions takes (io.Writer, []ModelSubstitution, substitutionPhase), does zero I/O, and prints raw ids. resolveVersion is called only in buildGenerateGraph pre-estimate. A handoff carrying a wrong diagnosis is worse than one carrying none -- it is the first thing the next session acts on. Retracted in place, with where the false premise came from, so it cannot be re-derived. Also records both follow-ups as resolved by #237. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * docs(handoff): #3667 is a CONFIRMED audit gap, and the "no bypass" note was wrong The #3667 section said "Ruled out - IMPORTANT, do not re-derive: there is no known bypass". That is false, and it is the shape of note that gets a security gate lifted, so it is retracted in place with the reasoning that failed: some graphs composing a shared promptGraph says nothing about graphs that opt out of the shared node names, and two do. Hunyuan3D declares no `prompt` node at all (hunyuan3d-graph.ts:71), so the audit at orchestration-new.service.ts:1460 never runs, and the handler then maps `hunyuanPrompt` back to `prompt` for the generator (handler:58). PolyGen`s `texturePrompt` is covered by no audit block and is the only text in an img2model3d request. Verified at a7e0bcd668 across all 79 declared node keys; escalated on civitai/civitai#3667. Consequently: DECIDED to keep `--input` pinned to txt2img (next-steps item 3), since the gate`s stated lift condition is now answered in the negative. Also records the independent re-verification of PR #237 (2377 PASS / 0 FAIL, 10/10 call-site-weighted mutants killed, with a positive control proving the harness can report a survivor), and warns that the base clone is currently on another session`s branch with uncommitted work. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes a set of test-coverage gaps in
civitai generate(PRs #210 and #215), adds a confirmation toworkflows cancel, and fixes two doc claims that were factually wrong.No test in this PR touches a live server, and no mutation call was ever issued. Everything runs on
httptest+t.TempDir().Part 1 — two doc corrections (measured)
The blob host. AGENTS.md item 17 named
orchestration.civitai.com. The host observed in a real upload reply isorchestration-new.civitai.com. Both match*.civitai.com, soisTrustedDownloadHostattaches the bearer token either way and the credential-free seam is required regardless — the wildcard is the load-bearing fact and the subdomain is incidental. Both items now say that explicitly rather than naming a hostname a server-side rename can invalidate. Item 19(e) already used the generic form (the task brief expected it to be wrong; it wasn't) — it gains the observed host and the same caveat. A code comment ingenerate.gomaking the same claim is corrected too.PayloadHash. The comment claimed the field lets a re-attach tell "the same job" from "a different job that reused the key". Nothing reads it back — the only reader of a written record isrecordPendingWorkflowID, which rewrites it. Reworded honestly; the field is kept, because the value is only obtainable at submit time, so recording it is what keeps that future comparison possible.Part 2 — eight coverage gaps
Each was verified-correct code with a missing or merely-spelled guard. Every named mutant was applied, confirmed to fail with that guard's own message, and reverted.
confirmGeneratedefault-denycase "y","yes"→case "n","no"(turns[y/N]into[Y/n])pendingPathtraversalfilepath.Base>→>=status == 401→status != 200<= 0→< 0ifgenerate_image.go+blobs.godefer …Close()req.ContentLengthTwo findings worth calling out:
jpeg.Encodeof a 16x0 image produces 591 bytes thatimage.DecodeConfigreads back asw=16, h=0, err=nil.png.Encoderefuses outright, which is why every fixture is a JPEG. So a zero dimension genuinely reachesGraphImageand then the server, where item 19(d) records it as a hard 400 after the graph is priced.!stdinIsTTY()still aborts (the prompt reads EOF), so the submit counter never discriminated and the mutant was killed only by message assertions — a guard killed by a different guard's error. Piping"y"is the real hazard shape (a CI job answering the prompt instead of passing--yes), and it makes the counter the discriminator. Added for bothgenerateandcancel.Decisions on items 6 and 8
Item 6 — labelled defensive-only (option b). The branch is genuinely unreachable: only png and jpeg have registered decoders, both are keys of
supportedImageFormats, so everything else fails earlier withimage.ErrFormat. No test can kill a mutation in unreachable code, and claiming otherwise would be a vacuous guard. Forcing it reachable means registering a third decoder — exactly whatgifBytes()'s comment documents as the thing that would silently destroy the real unsupported-format test. So the branch is commented as defensive-only with the reason, and the invariant that makes it unreachable is pinned instead (TestSupportedImageFormats_DecoderRegistrationIsInLockstep): every advertised format must actually decode under its map key, the content-type values are asserted, and a negative control confirms gif still fails via theErrFormatarm. That test goes red the moment a decoder is added without a map entry — i.e. the moment the branch does become reachable.Item 8 — kept with an honest comment.
http.NewRequestWithContextalready setsContentLength(andGetBody) for a*bytes.Reader, so deleting the line changes nothing today — measured, the mutant survives. Kept because the requirement is the endpoint's, not the reader type's: the orchestrator's signed URL rejects a chunked body, and if the body type is ever swapped for something the stdlib cannot size, that guarantee would vanish with no test able to see it. The comment says plainly that it is belt-and-braces, and the existingContent-Lengthassertion is re-labelled as pinning the outcome, not our line.Part 3 —
workflows cancelnow confirmsIt is the only irreversible action in this feature and it destroys a job the user has already paid for, while every other destructive path here gates. Matches the house pattern (
confirmSubmit/confirmGenerate):--yes/-yproceeds;--yesrefuses — including when"y"is piped, because the claim is "a terminal is attached", not "somebody typed something".The gate runs before the mutation seam, so a refusal cannot have cancelled anything. The existing honest help text is unchanged: cancelling still does not refund. README updated.
Verification
panic: test timed out. The 4 skips are the four by-design ones (TestScanDirFromEnv,TestScaffoldPinsSatisfyPublished,TestSubmissionsCapDriftAgainstLiveAPI,TestScaffoldedReadyAckActuallyFires). Baseline before this PR was 1989/1985 — +87 tests.gofmt -s -l .→ 0 files flagged, with 258.gofiles present as a positive control that it looked at anything.golangci-lint2.12.2 → 0 issues. Run separately frommake ci(which does not run it) and frommake lint(which silently falls back togo vetwhen it is absent). Validated against a known-bad state: a planted misspelling in one of the new files was caught, so the clean verdict demonstrably covers them.go vetclean;-raceclean on all three affected packages.🤖 Generated with Claude Code