[GH-ISSUE #2751] [Issue]: Image prompt compiler drops subjects, mis-genders (forced 1girl), and inverts negative instructions on the compact path #1389

Closed
opened 2026-10-21 05:32:51 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @kolacheee on GitHub (Jun 21, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2751

Originally assigned to: @SpicyMarinara on GitHub.

Summary

The shared image-prompt compiler's compact/distill path (used for portrait/avatar/selfie/sprite and tagged/danbooru profiles) corrupts prompts in several reinforcing ways: it discards the actual subject description, forces a hardcoded gender tag, mis-infers gender from incidental pronouns, injects contradictory cues from independent source parts, and loses/inverts user exclusions. Combined, an NPC portrait or in-chat illustration can render a generic anime woman with none of the requested species/features and with excluded content present. All confirmed by executing the compiled compiler against real inputs.

Sub-bug 1: Subject silently dropped (#24)

  • How it breaks: For portrait/avatar/selfie/sprite, compactVisualPrompt forces compactPrompt, so the prompt is run through distillTaggedPromptSource (shouldDistill=true). Only short comma-tags, a few hardcoded visual regexes, or a fixed Western-human whitelist survive; natural-language or non-human subjects fail all three and are discarded. With a built-in profile (non-empty subjectTags), the fallbackPositiveFragments rescue never fires.
  • Repro: Game NPC portrait, danbooru profile, prompt 'A snarling goblin with green warty skin, pointed ears, and a crooked nose.' compiles to '...1girl, solo, upper body, portrait, looking at viewer, anime screencap, ...' — zero subject tokens.
  • Trace: image-prompt-compiler.ts:45-47 force compact -> 82 splitPromptFragments shouldDistill -> 212-264/328-407 distill drops the sentence -> only profile + subjectTags remain.

Sub-bug 2: '1girl' forced (#25)

  • How it breaks: profileSubjectTags = profile.subjectTags[kind] is appended unconditionally (lines 42/64/70). Danbooru portrait subjectTags = '1girl, solo, portrait, upper body, looking at viewer' (image-style-profiles.ts:68) with no gender reconciliation. On Illustrious/Pony/NovelAI/SDXL-danbooru checkpoints '1girl' is a top-weight tag that overrides a textual 'male'.
  • Repro: 'A grizzled male warrior with a thick beard...' (danbooru, portrait) -> '...male, ..., 1girl, solo, upper body, portrait, ...' — both 'male' and '1girl' present; renders a woman. A dragon -> '1girl' is the only subject token.

Sub-bug 3: Gender mis-inference via else-if (#55)

  • How it breaks: deriveTaggedSourceCues (266-282) tests female (she|her|hers|woman|female|girl|lady) before male via else-if, scanning the whole source. Any female pronoun referring to a different person forces 'female' (priority-0, never budget-dropped) and the male branch never runs.
  • Repro: 'A tall knight. His armor is dented; her majesty knighted him.' -> cue 'female' for a male knight.

Sub-bug 4: Contradictory per-part cues (#56)

  • How it breaks: deriveTaggedSourceCues runs independently for generatedStyle, input.prompt, and userPositive; dedupe only removes exact duplicates, so 'female' and 'male' (distinct keys, both priority 0) both survive into the tag prompt. The game NPC path passes art-style separately from the per-NPC prompt, so a gendered word in the style conflicts with the subject.
  • Repro: generatedStyle 'soft anime portrait of her' + prompt 'portrait of the old man' -> 'female, male, ...'.

Sub-bug 5: Negatives dropped / inverted (#26)

  • How it breaks: In the positive loop, avoid/exclude/do not include X whose content isn't in the narrow negative whitelist is pushed only to diagnostics (movedNegativeFragments) and never to negativeFragments (dropped). no X / without X aren't matched by hasAvoidInstructionPrefix and fail the whitelist, so they fall through to the POSITIVE prompt — inverting intent.
  • Repro: illustration/realistic prompt 'A peaceful garden party. No weapons. Without any modern technology.' -> positive contains 'No weapons. Without any modern technology' (model instructed to INCLUDE them); 'Avoid clutter.' -> dropped from negative entirely.

Suggested Fix

  • When distillation yields zero fragments from a source-prompt part, keep the lightly-cleaned original text instead of discarding it; or replace the fixed hasVisualCue allowlist with a small deny-list so unknown/fantasy/non-human nouns are kept by default.
  • Make profile subjectTags gender-neutral, or rewrite/suppress '1girl'/'1boy' based on a derived gender cue.
  • Replace the else-if gender chain with weighted/scored inference (prefer explicit subject words over loose pronouns); derive cues once over combined source text and reconcile before the per-part loop.
  • Route any avoid/no/without X content into negativeFragments regardless of whitelist; add no/without to the avoid-prefix matcher; consider scoping the prompt-text scan to the scene prompt.

Verification checklist (all manual)

  • Generate a goblin/dragon/android NPC portrait under the danbooru and realistic built-in profiles and confirm the subject appears
  • Generate a male-subject portrait under danbooru and confirm it is not rendered as female / no '1girl'
  • Confirm a bio mentioning an other-gendered person no longer flips the subject's gender
  • Confirm 'no X' / 'avoid X' phrasing suppresses X in the output
  • Re-run the compiled-compiler reproductions for #24/#25/#55/#56/#26 and confirm corrected output
  • Run pnpm check

Affected files

  • packages/shared/src/utils/image-prompt-compiler.ts
  • packages/shared/src/constants/image-style-profiles.ts
  • packages/server/src/services/game/game-asset-generation.ts

Audit provenance

Found by a multi-agent static audit of the TTS/voice + image-generation subsystems (Round 1 + round-2 gap sweep + completeness critic, each finding adversarially verified) against the merged staging tree. Severity: HIGH.

AI-drafted from a static read; validation/test-plan boxes intentionally left UNCHECKED for a human to verify before close.

Originally created by @kolacheee on GitHub (Jun 21, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2751 Originally assigned to: @SpicyMarinara on GitHub. ## Summary The shared image-prompt compiler's compact/distill path (used for portrait/avatar/selfie/sprite and tagged/danbooru profiles) corrupts prompts in several reinforcing ways: it discards the actual subject description, forces a hardcoded gender tag, mis-infers gender from incidental pronouns, injects contradictory cues from independent source parts, and loses/inverts user exclusions. Combined, an NPC portrait or in-chat illustration can render a generic anime woman with none of the requested species/features and with excluded content present. All confirmed by executing the compiled compiler against real inputs. ## Sub-bug 1: Subject silently dropped (#24) - **How it breaks:** For portrait/avatar/selfie/sprite, `compactVisualPrompt` forces `compactPrompt`, so the prompt is run through `distillTaggedPromptSource` (shouldDistill=true). Only short comma-tags, a few hardcoded visual regexes, or a fixed Western-human whitelist survive; natural-language or non-human subjects fail all three and are discarded. With a built-in profile (non-empty subjectTags), the `fallbackPositiveFragments` rescue never fires. - **Repro:** Game NPC portrait, danbooru profile, prompt 'A snarling goblin with green warty skin, pointed ears, and a crooked nose.' compiles to '...1girl, solo, upper body, portrait, looking at viewer, anime screencap, ...' — zero subject tokens. - **Trace:** image-prompt-compiler.ts:45-47 force compact -> 82 splitPromptFragments shouldDistill -> 212-264/328-407 distill drops the sentence -> only profile + subjectTags remain. ## Sub-bug 2: '1girl' forced (#25) - **How it breaks:** `profileSubjectTags = profile.subjectTags[kind]` is appended unconditionally (lines 42/64/70). Danbooru portrait subjectTags = '1girl, solo, portrait, upper body, looking at viewer' (image-style-profiles.ts:68) with no gender reconciliation. On Illustrious/Pony/NovelAI/SDXL-danbooru checkpoints '1girl' is a top-weight tag that overrides a textual 'male'. - **Repro:** 'A grizzled male warrior with a thick beard...' (danbooru, portrait) -> '...male, ..., 1girl, solo, upper body, portrait, ...' — both 'male' and '1girl' present; renders a woman. A dragon -> '1girl' is the only subject token. ## Sub-bug 3: Gender mis-inference via else-if (#55) - **How it breaks:** `deriveTaggedSourceCues` (266-282) tests female (`she|her|hers|woman|female|girl|lady`) before male via else-if, scanning the whole source. Any female pronoun referring to a different person forces 'female' (priority-0, never budget-dropped) and the male branch never runs. - **Repro:** 'A tall knight. His armor is dented; her majesty knighted him.' -> cue 'female' for a male knight. ## Sub-bug 4: Contradictory per-part cues (#56) - **How it breaks:** `deriveTaggedSourceCues` runs independently for generatedStyle, input.prompt, and userPositive; dedupe only removes exact duplicates, so 'female' and 'male' (distinct keys, both priority 0) both survive into the tag prompt. The game NPC path passes art-style separately from the per-NPC prompt, so a gendered word in the style conflicts with the subject. - **Repro:** generatedStyle 'soft anime portrait of her' + prompt 'portrait of the old man' -> 'female, male, ...'. ## Sub-bug 5: Negatives dropped / inverted (#26) - **How it breaks:** In the positive loop, `avoid/exclude/do not include X` whose content isn't in the narrow negative whitelist is pushed only to diagnostics (movedNegativeFragments) and never to `negativeFragments` (dropped). `no X` / `without X` aren't matched by `hasAvoidInstructionPrefix` and fail the whitelist, so they fall through to the POSITIVE prompt — inverting intent. - **Repro:** illustration/realistic prompt 'A peaceful garden party. No weapons. Without any modern technology.' -> positive contains 'No weapons. Without any modern technology' (model instructed to INCLUDE them); 'Avoid clutter.' -> dropped from negative entirely. ## Suggested Fix - When distillation yields zero fragments from a source-prompt part, keep the lightly-cleaned original text instead of discarding it; or replace the fixed `hasVisualCue` allowlist with a small deny-list so unknown/fantasy/non-human nouns are kept by default. - Make profile subjectTags gender-neutral, or rewrite/suppress '1girl'/'1boy' based on a derived gender cue. - Replace the else-if gender chain with weighted/scored inference (prefer explicit subject words over loose pronouns); derive cues once over combined source text and reconcile before the per-part loop. - Route any `avoid/no/without X` content into `negativeFragments` regardless of whitelist; add `no`/`without` to the avoid-prefix matcher; consider scoping the prompt-text scan to the scene prompt. ## Verification checklist (all manual) - [ ] Generate a goblin/dragon/android NPC portrait under the danbooru and realistic built-in profiles and confirm the subject appears - [ ] Generate a male-subject portrait under danbooru and confirm it is not rendered as female / no '1girl' - [ ] Confirm a bio mentioning an other-gendered person no longer flips the subject's gender - [ ] Confirm 'no X' / 'avoid X' phrasing suppresses X in the output - [ ] Re-run the compiled-compiler reproductions for #24/#25/#55/#56/#26 and confirm corrected output - [ ] Run `pnpm check` --- ### Affected files - `packages/shared/src/utils/image-prompt-compiler.ts` - `packages/shared/src/constants/image-style-profiles.ts` - `packages/server/src/services/game/game-asset-generation.ts` ### Audit provenance Found by a multi-agent static audit of the TTS/voice + image-generation subsystems (Round 1 + round-2 gap sweep + completeness critic, each finding adversarially verified) against the merged `staging` tree. Severity: **HIGH**. > AI-drafted from a static read; validation/test-plan boxes intentionally left UNCHECKED for a human to verify before close.
Author
Owner

@SpicyMarinara commented on GitHub (Jun 21, 2026):

Addressed on PR #2747. The shared image-prompt compiler now keeps fallback source fragments when compact distillation would drop the subject, derives subject cues once from the actual prompt/user-positive text, reconciles gendered profile subject tags against that cue, makes the built-in danbooru portrait tag gender-neutral, and routes avoid/no/without/exclude instructions into the negative prompt instead of positive text. Validated with git diff --check for the touched files; full pnpm validation is deferred until the end of the issue sweep per maintainer request.

<!-- gh-comment-id:4763272771 --> @SpicyMarinara commented on GitHub (Jun 21, 2026): Addressed on PR #2747. The shared image-prompt compiler now keeps fallback source fragments when compact distillation would drop the subject, derives subject cues once from the actual prompt/user-positive text, reconciles gendered profile subject tags against that cue, makes the built-in danbooru portrait tag gender-neutral, and routes avoid/no/without/exclude instructions into the negative prompt instead of positive text. Validated with git diff --check for the touched files; full pnpm validation is deferred until the end of the issue sweep per maintainer request.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#1389
No description provided.