Skip to content

Generation pipeline

This page follows one look through its whole life, from the moment the SelectionEngine deals its recipe to the moment its garments are segmented and ready to grade. Every stage along the way records its successes and failures (with reasons) into pipeline_events — see Observability.

1. Selection

SelectionEngine deals a manifest per look: 1 designer × 1 colorway × 3 model outfits drawn from outfit templates (hero garment + fill slots). Diversity guards: last-200 outfit-hash dedup, daily stale-rotation, hero-category gate, per-item target_pct dials ("1 in N outfits") from the Strategist.

Prompt IDs are P-NNNN-YYYYMMDD, numbered continuously across the day (collision-proof: max-sequence seeding on the app's local clock).

2. Compose (gemini-2.5-flash)

The system prompt assembles, in order:

  1. Base rules (brand prompt, Shawn-editable via prompt_templates)
  2. Hero render hints — each hero garment's silhouette spliced VERBATIM (anti-fabrication); fabric/detail palette skipped on innovation slots
  3. Innovation block (see Innovation engine)
  4. Scoped intel — learned notes for THIS designer/colorway/garments
  5. Lab vocab splice (50% of prompts) — proven fragments with grade history
  6. Brand guardrails — the hard bans (banned-word→substitution law)

The LLM returns strict JSON (robust brace-balance parser — trailing prose tolerated). Output is scaffolded: fixed opening (scene), 3 per-model garment lines, fixed closing — so composition variance is ZERO outside the garments.

3. Scene lock + validation

The scene template (white seamless backdrop, three models, model-width spacing, ultrawide 16:9, full-length) is verbatim in every prompt. A scene-invariant validator checks each compose for backdrop/spacing/frame/length/model-count and flags SCENE DRIFT loudly. The brand validator catches banned vocabulary (forbidden_vocab:*), word-count bounds (150–250), and entity locks.

4. Negative prompt

Short concrete noun phrases only: the LLM's manifest-specific exclusions + learned kill phrases (trigger tokens, ≤5 words) filtered so they never negate the prompt's own designer/colorway/garments, deduped, capped, merged at render into a single Avoid: suffix cut at token boundaries.

5. Render

Replicate Imagen 4 Ultra (model from Control). The returned URL is version-stamped (?v=ts) so re-renders never collide with browser caches. S3 failures fall back to local disk and are recorded as s3_upload failures.

6. Segment

See Segmentation. Fire-and-forget after the batch, plus a 10-minute reconciliation sweep so no rendered image can stay unsegmented.