Motion Studio SDLC Execution Playbook
When tasked with implementing a feature or bugfix in this repository, execute these exact steps in order:
Step 1: Contract Synchronization (Spec Gate)
- Inspect
engine/schemas.pyandremotion/src/types.ts. - Add or modify fields to satisfy the feature requirements.
- Validate that Pydantic models compile:
(Note: If a project virtualenv exists, invoke viapython3 -c "import engine.schemas as s; print('Schemas OK')".venv/bin/python3). - Never proceed to implementation code until contracts in both languages are aligned.
Step 2: Red Phase (Author Failing Tests)
- Write a new test file or test case under
tests/(Pytest) orremotion/src/__tests__/(Vitest/Jest). - Assert schema validation, edge cases, and expected serialized output.
- Run the test and confirm failure:
pytest tests/ # If frontend test runner is configured in remotion/package.json: npm --prefix remotion test -- --run - Record the failure trace. If the test passes immediately, rewrite it to test the actual new capability. The Red phase is satisfied only when tests fail with expected assertions.
Step 3: Green Phase (Minimal Implementation)
- Write the minimal code in
engine/orremotion/src/to satisfy the failing test. - In Remotion, strictly adhere to the Deterministic Frame Law:
- Derivation must come strictly from
useCurrentFrame()anduseVideoConfig(). - Never use
Date.now(),Math.random(), or unboundedrequestAnimationFrame().
- Derivation must come strictly from
- Preserve existing architectural patterns (
<Series>,<Sequence>,<ThreeScene>,<KineticScene>). - Ensure vector assets preserve IDs and classes per
remotion/svgo.config.mjsfor GSAP targeting.
Step 4: Quality Gate & Automated Self-Healing Loop
Track the loop iteration counter (ATTEMPT ∈ {1, 2, 3}). Run each gate sequentially without masking exit codes (do not append || true):
# Tier 1: Static Type Analysis
python3 -m mypy engine/schemas.py engine/api.py
npm --prefix remotion run build -- --bundle-cache=false
# Tier 2: Automated Test Suites
pytest tests/
# If frontend test runner is configured in remotion/package.json:
npm --prefix remotion test -- --run
# Tier 3: Headless Chromium Frame Rasterization
(cd remotion && npx remotion still src/index.ts MainComposition /tmp/smoke.png \
--props='{"scenes":[],"theme":{}}' \
--gl=angle \
--overwrite)
Self-Healing & Rollback Policy
-
On Failure (Attempt 1 or 2):
- Capture the exact file path, failing line number, and stderr/traceback.
- Implement a minimal, targeted patch strictly addressing the reported error.
- Increment
ATTEMPTand restart Tier 1.
-
On Failure (Attempt 3 - Budget Exhausted): Halt speculative modifications immediately and revert only the changed and created feature files (never perform a blanket global clean):
# Tier 4 Exhaustion Fallback: Target only feature code scopes git restore --staged --worktree engine/ remotion/ tests/ git clean -fd engine/ remotion/ tests/ rm -f /tmp/smoke.png echo "Quality gate failed after 3 attempts. Target code paths restored to clean baseline." exit 1(Alternative to preserve work for post-mortem analysis:
git stash push -u -m "sdlc-failed-attempt-$(date +%s)" -- engine/ remotion/ tests/) -
On Success (All Tiers Exit 0): Remove transient artifacts and create the verified commit:
rm -f /tmp/smoke.png git add engine/ remotion/ tests/ git commit -m "feat(motion-sdlc): implement verified feature with green test gate"