# ADR-0002 — Accept Phase D import-line rewrites in `production_loop.py`

**Status:** Accepted
**Date:** 2026-05-03
**Deciders:** JT, Claude (in dialogue)
**Supersedes:** none
**Superseded by:** none

> *This ADR was drafted by AI during the post-Phase-D cleanup conversation.*

## Context

The `BUILD_SPEC_ENGINE_FIX_PHASE_D.md` spec required `production_loop.py` to be byte-untouched. The intent was twofold: (a) preserve a known-good hot-path file as a stability anchor through the engine-fix sprint; (b) make Phase D's diff easier to review by carving out the most consequential file.

During Phase D, Phase 4's proxy-removal work needed `production_loop.py`'s imports updated to find the new module homes. The spec's byte-untouched invariant became impossible to honor while still delivering Phase 4's deletions cleanly.

The Phase D build log surfaced this as a JT decision: accept the deviation (and tag), or rollback the production_loop edits and find another way to make the proxy deletions land (e.g., keep proxies as `sys.modules` redirects).

## Decision

Accept the deviation.

The 39-line diff (per `git diff` line count) is **6 changed source lines** wrapped in diff context — pure import-path renames driven by Phase D's module reorganization:

| Old import | New import |
|---|---|
| `lib.execution_store` | `execution.execution_store` |
| `orchestrator.step_runner` | `execution.step_runner` |
| `orchestrator.step_types` | `execution.step_types` |
| `lib.model_profiles` | `core.model_profiles` (appears twice) |

Zero semantic change. The same functions, classes, and modules are imported — just from their new homes after Phase D's reorganization.

## Consequences

**Spec invariant relaxed.** Phase D's "production_loop.py byte-untouched" guarantee is formally broken by these 6 lines. Phase E independently confirmed it didn't touch `production_loop.py` further, so Phase E's "byte-untouched" claim still holds for Phase E's scope.

**Stability anchor preserved.** All function signatures and runtime behavior in `production_loop.py` are unchanged. The file remains a known-good hot-path artifact; Phase D just rewrote where it looks for its dependencies.

**Tag applied.** `post-engine-fix-phase-D` exists at commit `56669ce9b6a786315361e9978d9379a55d0d4b6b` (locally and on `studio` remote). This ADR is the durable record of why the deviation was accepted.

**Rollback path exists.** Should this acceptance prove wrong, `pre-engine-fix-phase-D` tag still points at the pre-deviation state. Reverting would require a follow-on CP that finds another way to land Phase 4's proxy deletions.

**Out of scope:** the broader question of how strictly to enforce byte-untouched invariants in future engine-fix sprints. Phase D's spec didn't anticipate cascading import-rename consequences from proxy deletion. Future sprints with similar invariants should explicitly enumerate which files are byte-locked AND list the cascade-risk modules whose imports would change as side effects.

## Verification

The deviation has been live since Phase D Phase 3 (commit `5c6a8eab`). All subsequent Phase D and Phase E phases (and today's post-Phase-D `pass_naming.py` relocate) have run the full pytest suite (1280 passing, 11 skipped) without regression attributable to these import changes.
