# Task Classification and Routing

## Purpose

Use this guide before any image-generation or image-editing run. The first job is to classify the request correctly so production-bible style is only enforced when it should be.

## Canonical task modes

### `scene_generation`
Use when a brand new image or keyframe is being created from a storyboard, scene brief, concept, or script-derived shot.

Signals:
- no source image is being directly edited
- user wants a new composition or fresh keyframe
- task depends on project look from `production_bible.json`

### `continuity_generation`
Use when a new image must match an already approved scene, location, character, wardrobe, lighting setup, or prior shot.

Signals:
- user wants the next shot or a matching shot
- references are used to preserve continuity, not to surgically edit an existing image
- the project look must stay aligned with approved material

### `image_editing`
Use when the user wants to modify provided image files.

Signals:
- retouching, cleanup, replacement, inpainting, outpainting, compositing, local correction, or the same explicit change applied across multiple source images
- user expects the source composition, lighting, framing, identity, and style to remain mostly unchanged
- a mask, red box, bounding area, or highlighted region defines the edit scope

## Routing rules

1. If the user wants a direct edit to existing image files, route to `image-generation` with `task_mode=image_editing` even if multiple reference images are attached.
2. Do not route to `reference-grounded-narrative-sequence-skill` just because there are multiple references.
3. Route to `reference-grounded-narrative-sequence-skill` only when the output itself is a narrative sequence, storyboard-style collage, next-scene continuation sequence, or clean extraction from such a sequence.
4. If the task is ambiguous between continuity generation and image editing, prefer `image_editing` when the user is asking to change an existing image rather than create a new one.

## Style policy

Resolve a `style_policy` before prompt construction:

- `enforce_bible_style` -> use for `scene_generation`
- `enforce_bible_style` -> use for `continuity_generation`
- `preserve_source_style` -> default for `image_editing`
- `user_requested_restyle` -> use only when the user explicitly asks the edit to match or borrow the production-bible / project style

## Required handoff to prompt construction

Always carry forward:
- `task_mode`
- `style_policy`
- `prompt`
- `reference_images`
- `output_path`
- `edit_scope` when present
- any explicit preservation constraints from the user
