# Area #7a W0 Inventory + Baseline Memo

**Date**: 2026-05-19 UTC
**Phase**: W0 (read-only verify + deferred decision)
**Outcome**: 9 step (S1-S10) verify 완료, S8 deferred decision = "prompt_version 신설 안함" (Codex APPROVED)
**Commit**: 0 (W0 doctrine; W3c closure 시 본 memo 흡수 또는 별도 stage)
**Plan ref**: `docs/superpowers/plans/2026-05-18-area-7a-visual-world-rules-sot-v1-implementation.md` (HEAD `44346c3` → amend 3 narrow 예정)

---

## 1. Production runtime path (S1 + S2)

### VWR
- Module: `backend/app/modules/pipeline/visual_world_rules.py`
- Entry: `extract_visual_rules()` line 14; `load_prompt(_MODULE, "system")` line 35; `load_schema(_MODULE, "rules_schema")` line 36; → `call_structured(schema_name="visual_world_rules")` → `llm_client._validate_local_schema`.
- STEP_MANIFEST entry: `step_manifest.py:130-141` — 10 fields (`label / category / order / default_model / provider / depends_on / fan_out / applicability / step_type / lifecycle`). `schema_version` + `prompt_version` **absent** (Codex iter 3 F-2 evidence confirmed).

### scene_director
- Module: `backend/app/modules/pipeline/scene_director_v2.py`
- Entry: `direct_scenes()` line 15; `load_prompt(_MODULE, "system")` line 27; `load_schema(_MODULE, "analyze_schema")` line 28.
- Caller (production): `backend/app/core/steps/director_steps.py:158` imports + invokes `direct_scenes`. (Legacy `analysis_steps_legacy.py:763` deprecated.)
- STEP_MANIFEST entry: `step_manifest.py:417-428` — 11 fields (10 base + `requires_projection_sync_before_run` W1-F12). `schema_version` + `prompt_version` **absent**.

## 2. version_registry / prompt_version pin (S3 + S8.1)

- `version_registry.py:1-40` MODULE_VERSIONS dict. `grep -E "visual_world_rules|scene_director"` → **0 hit**. 본 area scope version_registry sync 의무 0.
- `grep -rn "prompt_version" backend/app/ --include="*.py"` → 32+ hit.
  - STEP_MANIFEST entry-level prompt_version field 사용 site = **0 hit** (`grep prompt_version step_manifest.py` = 0).
  - step file 다수 (shot_director_step.py:45 / detail_steps.py:988 / background_*_step.py / location_floor_plan_step.py) cp metadata 안 `"prompt_version": PROMPT_VERSION` 키 emit (step-local constant).
  - DB schema `database.py:77` `prompt_version text` column 존재 (cp 테이블).
  - `step_runner.py:1517` `_check_cp_mismatch`: `current_schema = self.manifest.get("schema_version", 1)` — **schema_version 만** 비교, prompt_version 비교 0.
  - `shot_director_step.py:40` docstring "schema_version + prompt_version 조합 hash" — step-local 차원의 cp hash 보조, manifest-level pin 아님.

## 3. _validate_local_schema (S4) + prompt_loader (S5)

- `llm_client.py:43-77` `_validate_local_schema`: line 63 `jsonschema.validate(instance=payload, schema=response_schema)` raw call. schema 안 `$schema` 명시 없으면 library default validator. `enum` keyword reject 행위 Draft 4+ 공통이므로 W3b C1 canary deterministic verify 가설 영향 0.
  - typed error: `SchemaValidationError` (validation fail) / `InvalidSchemaError` (schema spec 자체 invalid).
- `prompt_loader.py:167-180` `_list_module_versions`: `sorted(...key=_version_sort_key, reverse=True)` — **numeric desc** sort.
- `prompt_loader.py:219-235` `_resolve_stem_in_pack`: latest = `versions[0]` (numeric desc 최상위) 부터 순회.
- 결과: `7.20260518HHMM/` (VWR) / `9.20260518HHMM/` (scene_director) 신설 시 numeric desc latest 자동 활성. step_manifest.prompt_version pin 영향 0.

### Plan literal wording drift (Finding 1 + 2)
- Plan body 원문 "jsonschema.Draft7Validator 사용" / "Draft7 use" → 실제 `jsonschema.validate` wrapper. Plan amend 3 narrow boundary.
- Plan body 원문 "lexicographic latest" / "lexicographic order" → 실제 numeric desc (`_version_sort_key`). Plan amend 3 narrow boundary.
- 둘 다 functional 영향 0; plan literal drift only.

## 4. Audit A047/A096-A100 mapping (S6)

- A047 = `scene_director/8.../system.md:5-10, 23-25, 32-34` (3 site: line 5 + 7-10 / line 23-25 / line 32-34 — actual file verified) — audit row heading `7-24` single range, plan body 3 site 분해. ✓
- A096 = `visual_world_rules/6.../rules_schema.json:9-9` (rule_type description "possession, transformation, ghost, time_period, costume, technology 등") ✓
- A097 = `visual_world_rules/6.../rules_schema.json:20-20` (director_notes scenario-specific "예: A의 영혼이 B의 몸에 전이된 경우...") ✓
- A098 = `visual_world_rules/6.../system.md:51-51` (canonical 10-token list verbatim) ✓
- A099 = `visual_world_rules/6.../system.md:57-73` (director_notes prose section — **Carry**) ✓
- A100 = `visual_world_rules/6.../system.md:98-98` (t2i_context demonym — **Carry**) ✓

spec §2.2 정합 confirmed. drift 0.

## 5. Baseline pytest (S7)

- Scope (S7.1): `test_visual_world_rules.py` + `test_scene_director_v2.py` + `test_step_manifest_v3.py` + `tests/services/test_step_manifest_model_routing.py` 등 -k 매치. cp_mismatch named file 없음 (`_check_cp_mismatch` = `step_runner.py:1502-1545` method).
- Run (S7.2): `.venv/bin/pytest tests/ -k "visual_world_rules or scene_director or step_manifest" -v` → **80 PASS, 4 SKIP, 3816 deselected** in 2.75s. **0 FAIL**.
- 4 SKIP (known baseline): `test_scene_director_v2.py::TestDirectScenes::test_calls_call_structured_with_correct_step` / `::test_enum_injection_with_entities` + `TestSceneDirectorStep::test_execute_calls_direct_scenes` / `::test_execute_empty_entities`.

W1/W2 commit 직전 smoke pytest 비교 baseline 확보.

## 6. prompt_version deferred decision verdict (S8)

### Decision: **신설 안함** (Codex APPROVED 2026-05-19)

**Reason (1-line)**: STEP_MANIFEST entry-level prompt_version field 사용 site 0, cp invalidation = manifest.schema_version only (`_check_cp_mismatch` line 1517), `prompt_loader` file fallback numeric desc latest 자동 활성으로 prompt 변경 = file system 운영, manifest pin 영향 0.

### Implication for W1 + W2
- **W1 step_manifest 변경**: `visual_world_rules.schema_version: 1` 신설만 (1 new key + inline comment). prompt_version 추가 0.
- **W2 step_manifest 변경**: **0** (W2 commit content = `prompts/_base/scene_director/9.20260518HHMM/system.md` 단일 file). VWR + scene_director entry 모두 unchanged in W2.
- step file 안 PROMPT_VERSION constants 신설 0 (별도 layer).
- prompt_loader file fallback numeric desc latest 자동 활성으로 충분.

## 7. S9 archive (rollback path)

- VWR archive 6: `1.202603231200, 2.202603231200, 3.202604161200, 4.202604300936, 5.202605011300, 6.202605021400` ✓
- scene_director archive 3: `6.202603251200, 7.202604031800, 8.202604081200` ✓
- W3a residue gate archive-excluded scope (latest-only) 정합 보존.

## 8. Session continuity

- Codex verdict (W0 S8 의논 closure): "Current session can CONTINUE through W0 closure + amend and likely W1 entry; re-check 50% before W1 if context grows. NO VLM."
- 다음 step: (a) plan amend 3 (narrow S4/S5 wording fix + S8 decision marker) → (b) commit plan amend 3 → (c) Codex narrow re-review → (d) session 50% pre-W1 의논 → (e) W1 entry (HHMM 결정 + atomic single commit).
