# Oscar Platform — Anti-Drift Doctrine (per FVW v8 §08)

**This document applies FVW v8 v0.10.0 §08 (25 rules + 20 gates + 12 failure modes) to Oscar.**

**Date:** 2026-06-29
**Status:** Constitutional (ratified per FVW v8 §08, §02.1.1)

---

## 1. The 7 Refactoring Rules (FWV v8 §08.1)

### Rule 1 (Verification-before-refactor)
Extract existing structure, behaviour, UI BEFORE any refactor. Extraction lives in `pact/extraction/` and is frozen at start. **Applied to Oscar:** `pact/extraction/baseline-snapshot.md` (2026-06-29 11:20 UTC).

### Rule 2 (Safe Diff Protocol)
Every refactor uses: extract → echo → micro-diff → verify → commit. Micro-diff is at most: one function moved, one function renamed, one state variable moved, one event handler extracted, one fragment extracted, one import re-pointed. **Applied to Oscar:** every change in phases B2, C1-C10 follows micro-diff.

### Rule 3 (No invention)
Do not invent new components, modules, handlers, state. Everything must come from existing code. **Applied to Oscar:** runtime changes are limited to what existing code does; doctrine changes (Recipe Books, codex, C8 shape matrix) are EXTRACTIONS per Rule 1.

### Rule 4 (Explicit binary verification)
Every refactor step has binary PASS/FAIL checks: syntax, behaviour, DOM (if UI), integration. **Applied to Oscar:** App-VP test suite (~70 invariants; 8 adversarial probes).

### Rule 5 (DOM hierarchy verification)
Extract DOM hierarchy; compare modularised DOM to extracted. Allowed differences: whitespace, attribute order, framework keys. Disallowed: missing/extra nodes, changed tags, changed classes, lost handlers, changed text. **Applied to Oscar:** views/* views are kept verbatim.

### Rule 6 (Behaviour/state verification)
Extract all behaviours, handlers, state transitions. Verify modularised behaviour matches. **Applied to Oscar:** runtime-inventory.md captures all behaviour; Recipe Books document the same.

### Rule 7 (Drift detection)
After each phase, compare modularised app to extracted original. Detect and report drift. Drift log appended to `pact/extraction/drift-log.md`. **Applied to Oscar:** new `pact/extraction/drift-log.md` (Phase A2 deliverable).

---

## 2. The 4 Cross-Cutting Verifiers (FWV v8 §08.2)

### Verifier 1 (Spec-Conformance Gate)
Validators that pass can still be wrong. Spec-conformance asks "does the modularised app have [thing the SPEC says]?" not "does it have [thing it already has]?". **Applied to Oscar:** every Recipe Book's coverage-matrix.md has a "Source-line evidence" column. Validator checks each feature against source.

### Verifier 2 (No-Values-In-Plan)
Plans are containers of verification protocols, not data. Plans reference source lines; they don't paraphrase. **Applied to Oscar:** plan.md files per module contain steps + verification protocols, not paraphrased source values.

### Verifier 3 (Coverage Matrix)
Every spec'd thing has 5 columns: source feature, source-line evidence, recipe/codex claim, implementation status, test status. **Applied to Oscar:** every module has coverage-matrix.md with this 5-column structure.

### Verifier 4 (Approval Gate Rigor)
Confirmation requires explicit "proceed" / "go ahead" / "execute". "ok" / "makes sense" / "I see" is NOT confirmation. **Applied to Oscar:** operator's "begin alignment" directive at 2026-06-29 13:20 UTC is the approval gate for this alignment run.

---

## 3. The 8 Workflow Sections (FWV v8 §08.3 — for rules.md)

### Workflow 1 (Capability Declaration)
Implementer MUST declare what they CAN and CANNOT. Format: I CAN / I CANNOT / External validation. **Applied to Oscar:** every module's rules.md has §1 Capability Declaration including the Reconstruction Mode Declaration per §33.

### Workflow 2 (Do-Not-Proceed Rule)
If fidelity, behaviour, or contract compliance fails verification, implementer MUST stop. **Applied to Oscar:** every module's rules.md has §2 Do-Not-Proceed.

### Workflow 3 (Contract Primacy)
Contract = recipe.md (3 sections) + codex.md (C1-C8 + C9). Scaffolding is NOT the contract. **Applied to Oscar:** every module's rules.md has §3 Contract Primacy.

### Workflow 4 (Anti-Drift Enforcement — 4 numbered checks)
Per-module: Recipe→Source, Visual Diff, Behavioural, Contract. **Applied to Oscar:** every module's rules.md has §4 Anti-Drift Enforcement with 4 checks instantiated for that module.

### Workflow 5 (Plan-as-Law)
Atomic plan steps in `plan.md`. **Applied to Oscar:** every module has plan.md.

### Workflow 6 (Fallback Behaviour)
What happens when generation fails. **Applied to Oscar:** every module's rules.md has §6 Fallback Behaviour.

### Workflow 7 (User-Simulator Requirement)
C6 user simulations must be runnable. **Applied to Oscar:** every module's codex.md has C6 list + App-VP tests verify them.

### Workflow 8 (Re-anchor Cadence)
When to re-read the contract. **Applied to Oscar:** every module's rules.md has §8 Re-anchor Cadence.

### Workflow 9 (Coverage Matrix)
`coverage-matrix.md` with the 5-column verification grid. **Applied to Oscar:** every module has coverage-matrix.md.

---

## 4. The 6 Enhancements (FWV v8 §08.4)

(Rules 20-25 — extracted from operator's v8 RFC; per §08.4)

- **Enhancement 1 (Production Rules Form):** every rule has verifiable form
- **Enhancement 2 (Failure Triggers):** every rule has explicit failure triggers
- **Enhancement 3 (Escalation Paths):** when rules fail, escalation is defined
- **Enhancement 4 (Audit Trail):** every check has audit trail
- **Enhancement 5 (Rollback Capability):** every change is reversible
- **Enhancement 6 (Reasoning Records):** AI implementation records reasoning

**Applied to Oscar:** §1-6 of every rules.md references this anti-drift doctrine.

---

## 5. The 20 Hard Gates (FWV v8 §08.27)

(Adapted from `plan-rules.md` §2; 13 gates in v7 → 20 in v8)

| # | Gate | Oscar Status |
|---|---|---|
| G-01 | Recipe Book has all 10 items | enforced by `vp/recipe-book-structure.test.ts` |
| G-02 | codex.md has C1-C9 | enforced by `vp/c1-c9-codex-checks.test.ts` |
| G-03 | rules.md has all 9 universal things | enforced by `vp/rules-md-checks.test.ts` |
| G-04 | DNA file is well-formed | enforced by `vp/dna-checks.test.ts` |
| G-05 | Trace atlas is well-formed | enforced by `vp/atlas-checks.test.ts` |
| G-06 | Module-Pact Registration present | enforced by `vp/constitutional-fragments.test.ts` |
| G-07 | Sovereignty invariants pass | enforced by `vp/sovereignty.test.ts` |
| G-08 | All 5 adapters registered | enforced by `vp/intelligence.test.ts` |
| G-09 | IDB schema v2 stable | enforced by `vp/data.test.ts` |
| G-10 | 4-state dock states declared | enforced by `vp/runtime.test.ts` |
| G-11 | 4 canonical anchor types | enforced by `vp/runtime.test.ts` |
| G-12 | BackStack 1000/999 invariant | enforced by `vp/runtime.test.ts` |
| G-13 | 6 standards library complete | enforced by `vp/intelligence.test.ts` |
| G-14 | localStorage `oscar:` prefix | enforced by `vp/data.test.ts` |
| G-15 | `oscar-arboriculture-provider` ID | enforced by `vp/intelligence.test.ts` |
| G-16 | Sovereign SPA Mode declared (no Mantine) | enforced by `vp/sovereignty.test.ts` extension |
| G-17 | 14 Smart-X toggles declared | enforced by `vp/smart-features-checks.test.ts` |
| G-18 | C8 Shape Matrix per module | enforced by `vp/c8-shape-matrix-checks.test.ts` |
| G-19 | C9 State Shape Inventory per module | enforced by `vp/c9-state-shape-checks.test.ts` |
| G-20 | §08.4 enhancements referenced | enforced by `vp/rules-md-checks.test.ts` |

---

## 6. The 12 Failure Modes (FWV v8 §08.28)

| FM | Failure | Resolution |
|---|---|---|
| FM-01 | Recipe Book incomplete | Block; require all 10 items |
| FM-02 | C1-C9 missing in codex | Block; require all 9 contract items |
| FM-03 | rules.md missing 9-things | Block; require all 9 universal things |
| FM-04 | Module not Module-Pact Registered | Block; require `constitutional_fragments` |
| FM-05 | Sovereignty violation (forbidden import) | Block; require fix + rerun |
| FM-06 | Adapter not registered | Block; require 5-adapter registration |
| FM-07 | IDB schema drift | Block; require DB_VERSION migration test |
| FM-08 | Anchor type drift | Block; require 4 canonical types |
| FM-09 | BackStack corruption | Block; require 1000/999 invariant |
| FM-10 | Standards library incomplete | Block; require 6 standards |
| FM-11 | localStorage prefix lost | Block; require `oscar:` prefix |
| FM-12 | Smart-X toggle missing | Block; require 6 JSON files |

---

## 7. Anti-Drift Audit-to-Invariant Mapping

| FVW v8 §08 rule | Oscar invariant / test |
|---|---|
| Rule 1 | baseline-snapshot.md |
| Rule 2-6 | App-VP test suite (~70 invariants) |
| Rule 7 | drift-log.md (NEW Phase A2) |
| Verifier 1-4 | coverage-matrix.md per module |
| Workflow 1-9 | 9-things in rules.md (§11.9) |
| Enhancement 1-6 | §1-6 of every rules.md |
| G-01 to G-20 | 20 gate checks |
| FM-01 to FM-12 | 12 failure mode blockers |

**Score:** Oscar's anti-drift doctrine is fully aligned with FVW v8 §08. All 25 rules, 20 gates, 12 failure modes are mapped to Oscar invariants.

---

## END OF ANTI-DRIFT.MD

*Anti-drift doctrine for Oscar Platform. Per FVW v8 v0.10.0 §08 + §02.1.1.*
