<?xml version="1.0" encoding="UTF-8"?>
<spec xmlns="https://vibevm.org/spec/1">
  <title id="root">BROWNFIELD — Terraforming unfinished projects, v0.1</title>
  <status stage="spec" state="done"/>
  <p p="1"><fact id="status-line" status="impl/done">**Status.** Beta.</fact></p>
  <p p="2"><fact id="CLOSES-THE-HEALTHY-BASELINE-GAP" status="impl/done">Closes the package's most serious v0.1 gap: the playbook assumed a healthy baseline ("all gates green") on a project that — like every real project mid-flight — has failing tests, unimplemented specs, unfulfilled plans, and contradictory statements.</fact></p>
  <p p="3"><fact id="UNFINISHEDNESS-IS-A-MODELED-STATE" status="impl/done">This document makes unfinishedness a *modeled state*, not an exception.</fact></p>
  <p p="4"><fact id="mars-was-empty-real-codebases-are-inhabited" status="spec/done">Mars was empty; real codebases are inhabited — terraforming an inhabited world needs relocation protocols, not bulldozers.</fact></p>
  <p p="5"><fact id="amendments-carried-lead" status="impl/done">**Amendments carried by this document:**</fact></p>
  <list ordered="false" p="6">
    <item><fact id="AMENDMENT-CHARTER-GAINS-A6" status="impl/done">Charter gains axiom **A6**;</fact></item>
    <item><fact id="AMENDMENT-GUIDE-SPEC-AUTHORING-LIFECYCLE" status="impl/done">GUIDE-SPEC-AUTHORING gains lifecycle statuses;</fact></item>
    <item><fact id="AMENDMENT-PROP-014-STATUS-AND-CONFLICTS" status="impl/done">PROP-014 gains unit status + `conflicts_with` edges;</fact></item>
    <item><fact id="AMENDMENT-PLAYBOOK-REVISED-TO-V0-2" status="impl/done">the Playbook is revised to v0.2.</fact></item>
  </list>
  <section id="problem" title="1. The problem, stated precisely">
    <p p="7"><fact id="on-an-unfinished-project-lead" status="impl/done">On an unfinished project:</fact></p>
    <list ordered="false" p="8">
      <item><fact id="problem-a-tests-fail-and-have-failed" status="spec/done">(a) some tests fail and have failed for a while;</fact></item>
      <item><fact id="problem-b-ratified-units-unimplemented-by-plan" status="spec/done">(b) some ratified spec units have no implementation *by plan*;</fact></item>
      <item><fact id="problem-c-intentions-must-survive-migration" status="spec/done">(c) the WAL/TASKS/ROADMAP carry intentions that must survive migration;</fact></item>
      <item><fact id="problem-d-drift-and-mutually-exclusive-statements" status="spec/done">(d) the spec corpus contains drift and mutually exclusive statements.</fact></item>
    </list>
    <p p="9"><fact id="demanding-global-health-never-starts" status="spec/done">A migration discipline that demands global health before starting will never start; one that ignores these states will entrench or lose them silently.</fact></p>
    <p p="10"><fact id="BOTH-FAILURE-MODES-ARE-A1-VIOLATIONS" status="impl/done">Both failure modes are A1 violations.</fact></p>
  </section>
  <section id="principles" title="2. Principles">
    <list ordered="false" p="11">
      <item><fact id="PRINCIPLE-B1-INVENTORY-NOT-GATE" status="impl/done">**B1 — Inventory, not gate.** The only absolute precondition is "the workspace compiles." Everything else is recorded with a status at Phase −1; thereafter every gate means **monotone non-regression against the inventory**, in both directions (see §4, xfail-strict).</fact></item>
      <item><fact id="PRINCIPLE-B2-ASPIRATION-LEGAL-ONLY-WHEN-LABELED" status="impl/done">**B2 — Aspiration is legal only when labeled.** Unimplemented intent is a first-class tracked object (`planned` spec units, intent records), never ambient knowledge. The migration carries a **carry-over guarantee**: at exit, every harvested intention is `done | rescoped | rejected(reason)` — zero unaccounted.</fact></item>
      <item><fact id="PRINCIPLE-B3-CONTRADICTION-IS-DATA" status="impl/done">**B3 — Contradiction is data.** Conflicting spec units are recorded (`conflicts_with` + `disputed` status) with evidence; normalization **never resolves conflicts inline**. Adjudication is an explicit owner act.</fact></item>
      <item><fact id="PRINCIPLE-B4-CHARACTERIZATION-IS-THE-TRUTH-OF-RECORD" status="impl/done">**B4 — Characterization is the truth-of-record where truth is uncertain.** Golden transcripts of currently-passing observable behavior pin "don't break it" independently of whether tests or specs are trustworthy.</fact></item>
      <item><fact id="PRINCIPLE-B5-MONOTONE-UTILITY" status="impl/done">**B5 — Monotone utility.** Every tool yields useful output at 0% migration and improves continuously to 100%. No cliffs: queries outside the migrated frontier degrade to best-effort facts with an explicit "outside frontier" mark, never to errors.</fact></item>
    </list>
    <p p="12"><fact id="principles-mechanize-what-vibevm-does-socially" status="impl/done">These mechanize what vibevm's own AUDIT.md / PROP-013 already do socially: dated findings, severities, dispositions (`fixed / filed / accepted / open`), carry-forward.</fact></p>
    <p p="13"><fact id="DEBT-REGISTRY-IS-MACHINE-READABLE-AUDIT" status="impl/done">The debt registry below **is** machine-readable AUDIT.</fact></p>
  </section>
  <section id="registries" title="3. The registries">
    <p p="14"><fact id="registries-are-committed-human-diffable-lead" status="impl/done">Committed, human-diffable ground truth under `discipline/registry/` (the shipped tools' default path — override by flag; distinct from the intent *ledger*, which is uncommitted derived cache):</fact></p>
    <p p="15"><fact id="REGISTRY-TESTS-BASELINE" status="impl/done">**`tests-baseline.json`** — exact-match input for the test gate:</fact></p>
    <fence lang="json" p="16">{ "test": "vibe_registry::git_backend::shell::clone_over_ssh",
  "status": "failing-known",            // passing | failing-known | flaky | obsolete
  "since": "2026-05-23", "debt": "DBT-0007" }</fence>
    <p p="17"><fact id="REGISTRY-DEBT-JSON" status="impl/done">**`debt.json`** (+ generated human view `DEBT.md`) — unified deficiency record:</fact></p>
    <fence lang="json" p="18">{ "id": "DBT-0007", "kind": "failing-test",   // failing-test | unimplemented-req |
                                              // disputed-spec | orphan-code | stale-doc
  "severity": "P2",                           // PROP-013 scale
  "evidence": ["tests-baseline:…", "spec://org.vibevm.core/vibevm/...#req-...~r1"],
  "disposition": "filed",                     // fixed | filed | accepted | open
  "tripwires": ["touch:crates/vibe-registry/src/git_backend/**", "rev:spec://…#req-…"],
  "sunset": "evidence window 60d — re-disposition at next audit" }</fence>
    <p p="19"><fact id="REGISTRY-INTENT-JSON" status="impl/done">**`intent.json`** (+ `INTENT.md`) — the aspiration inventory, harvested from WAL "Next"/"Known issues", `TASKS.md`, ROADMAP open milestones, `&lt;!-- REVIEW --&gt;` markers, TODO/FIXME:</fact></p>
    <fence lang="json" p="20">{ "id": "INT-0031", "source": "vibevm/vibespecs/WAL.xml#next 2026-05-23",
  "text": "first full PROP-013 audit run", "links": ["spec://org.vibevm.core/vibevm/common/PROP-013"],
  "state": "open" }                           // open | done | rescoped | rejected</fence>
    <p p="21"><fact id="TRIPWIRES-ARE-CHEAP-AND-MECHANICAL" status="impl/done">Tripwires are cheap and mechanical: a check that warns when a change touches a debt's watched paths or revs a watched unit — debt resurfaces exactly when it becomes relevant, instead of rotting in a file nobody reopens.</fact></p>
  </section>
  <section id="test-gate" title="4. The test gate — xfail-strict semantics">
    <p p="22"><fact id="test-gate-diffs-the-run-against-the-baseline-lead" status="impl/done">`xtask test-gate` (runner: cargo-nextest, MIT/Apache-2.0; fallback: libtest stdout parsing) diffs the run against `tests-baseline.json` and fails on either of:</fact></p>
    <list ordered="true" p="23">
      <item><fact id="GATE-FAILS-ON-NEWLY-FAILING" status="impl/done">**Newly failing** — a `passing` test failed: regression, fix or revert.</fact></item>
      <item><fact id="GATE-FAILS-ON-UNEXPECTEDLY-PASSING-UNPROMOTED" status="impl/done">**Unexpectedly passing, unpromoted** — a `failing-known` test passed: the baseline is stale. Promote it (remove the entry, close/annotate the linked debt) in an explicit commit. Silence here is how baselines become graveyards; the strict mode makes the registry shrink truthfully.</fact></item>
    </list>
    <p p="24"><fact id="FLAKY-ENTRIES-ARE-QUARANTINED" status="impl/done">`flaky` entries are quarantined (run, reported, never gating) with a debt record and a sunset — flakiness is debt, not weather.</fact></p>
    <p p="25"><fact id="DRIVE-BY-FIXES-ARE-PROHIBITED" status="impl/done">Drive-by fixes of known-failing tests outside a phase's scope are prohibited: either pull the debt into scope explicitly or leave it; "while I was here" repairs destroy the experiment's accounting.</fact></p>
  </section>
  <section id="spec-lifecycle" title="5. Spec lifecycle and the conflict protocol">
    <p p="26"><fact id="UNIT-STATUSES-ARE-KIND-LINE-GRAMMAR" status="impl/done">Unit statuses (kind line grammar, see GUIDE-SPEC-AUTHORING amendment): `req r2` (default: ratified) · `req r1 planned` · `req r2 disputed(#other-anchor)` · retired (tombstone).</fact></p>
    <list ordered="false" p="27">
      <item><fact id="STATUS-PLANNED" status="impl/done">`planned`: zero coverage is *expected*; coverage reports count planned scope separately; gaining a first `implements` edge prompts a status flip in the same PR.</fact></item>
      <item><fact id="STATUS-DISPUTED" status="impl/done">`disputed`: recorded pair with `conflicts_with` edge + a `disputed-spec` debt entry holding the evidence quotes. Detection: a crude heuristic pass (duplicate anchors; MUST/MUST-NOT keyword collisions on a shared subject window) plus LLM-proposed semantic conflicts — proposals only, interpretations class in the ledger. **No inline resolution during normalization** — a silent semantic merge is worse than an honest contradiction.</fact></item>
      <item><fact id="ADJUDICATION-HAS-THREE-OUTCOMES" status="impl/done">Adjudication (owner act), three outcomes: **supersede** (loser retired with tombstone → winner), **scope-split** (both refined with explicit applicability contexts), **stay open** (rare; the dispute itself becomes load-bearing documentation).</fact></item>
      <item><fact id="WHILE-DISPUTED-EDGES-ARE-FROZEN" status="impl/done">While disputed: edges into the pair are **frozen** — exempt from suspect-clearing and from coverage penalties; implementations carry the dispute's debt id in commit bodies. Presumption (not resolution): the more specific, more recently revised unit is *presumed* current for read purposes, displayed with the presumption label.</fact></item>
    </list>
  </section>
  <section id="characterization" title="6. Characterization of record">
    <p p="28"><fact id="CAPTURE-GOLDEN-TRANSCRIPTS-AT-INVENTORY-TIME" status="impl/done">At inventory time, capture golden transcripts for currently-passing observable flows (the `manual-tests/` scenarios + fixture-driven e2e): exact CLI output, exit codes, written-file trees, normalized for volatile fields.</fact></p>
    <p p="29"><fact id="CHARACTERIZATION-IS-A-STABILITY-ORACLE-NOT-A-CORRECTNESS-CLAIM" status="impl/done">These are stability oracles, not correctness claims — they may pin bugs, and that is the point (a pinned bug is a visible debt; an unpinned bug is a landmine).</fact></p>
    <p p="30"><fact id="PHASE-GATES-NOW-MEAN-SNAPSHOTS-UNCHANGED" status="impl/done">Phase gates that previously said "behavior unchanged" now mean "characterization snapshots unchanged, except where a debt/intent record says we changed it deliberately."</fact></p>
  </section>
  <section id="frontier" title="7. Frontier and monotone utility">
    <p p="31"><fact id="RATCHET-FILE-IS-THE-FRONTIER" status="impl/done">The ratchet file is the frontier.</fact></p>
    <p p="32"><fact id="contract-per-tool-lead" status="impl/done">Contract per tool:</fact></p>
    <list ordered="false" p="33">
      <item><fact id="CONTRACT-SPECMAP-AND-TRACE" status="impl/done">`specmap`/`trace` on untagged items → facts + "outside frontier";</fact></item>
      <item><fact id="CONTRACT-CONFORM" status="impl/done">`conform` → findings only within scope, baseline frozen elsewhere;</fact></item>
      <item><fact id="CONTRACT-EXPLAIN" status="impl/done">`explain` → degrades from full chain to best-effort facts, provenance line says which.</fact></item>
    </list>
    <p p="34"><fact id="A-TOOL-THAT-ERRORS-OUTSIDE-THE-FRONTIER-IS-FORBIDDEN" status="impl/done">A tool that errors on the unmigrated 90% of the repo would make the discipline hostage to its own completion — B5 forbids it.</fact></p>
  </section>
  <section id="carry-over" title="8. Carry-over guarantee and exit accounting">
    <p p="35"><fact id="PHASE-6-CLOSES-WITH-ASPIRATION-RECONCILIATION" status="impl/done">Phase 6 (playbook v0.2) closes with **aspiration reconciliation**: every `intent.json` item reaches `done | rescoped (→ new spec URI or debt id) | rejected (reason recorded)`.</fact></p>
    <p p="36"><fact id="REPORT-PUBLISHES-THE-EXIT-NUMBERS" status="impl/done">The REPORT publishes: debt burn-down slope, disputed half-life, baseline shrinkage, and `intent unaccounted = 0` as a hard exit criterion.</fact></p>
    <p p="37"><fact id="EVERYTHING-PLANNED-LANDS-OR-IS-LET-GO" status="impl/done">"Everything planned eventually lands or is consciously let go" is thereby a checkable property of the migration, not a hope.</fact></p>
  </section>
  <section id="governance" title="9. Governance">
    <list ordered="false" p="38">
      <item><fact id="DEBT-ENTRIES-CARRY-SUNSETS" status="impl/done">Debt entries carry sunsets and are re-dispositioned at audit runs — symmetric with rule sunsets (Charter R-050): debt that nobody re-reads is wish-ratio's evil twin.</fact></item>
      <item><fact id="ANTI-ENTRENCHMENT-CLOSE-QUOTA" status="spec/done">**Anti-entrenchment escape:** if the debt count flatlines while the frontier advances for two consecutive phases, a per-phase close-quota activates (each subsequent phase must close K debts, K set by the owner). Ratchets guard against regression; quotas guard against the ratchet becoming a museum. *Specified, not built: nothing detects a flatline and nothing activates a quota — no flatline comparison across phases, no per-phase quota counter and no value for K exists in any engine crate, stack CLI or host registry. What ships is the input the rule would read: `debt.json` carries a count and a disposition per entry, and the phase-to-phase debt totals are published by hand in the terraform REPORT. K itself is still an open question in §11.*</fact></item>
      <item><fact id="ACCEPTED-DEBT-BUDGET-PER-CRATE" status="impl/done">Accepted-debt budget per crate (error-budget idea, SRE lineage — concepts only): exceeding the budget blocks new `accepted` dispositions in that crate until something burns down.</fact></item>
    </list>
  </section>
  <section id="prior-art" title="10. Prior art">
    <list ordered="false" p="39">
      <item><fact id="PRIOR-ART-PYTEST-XFAIL-STRICT" status="spec/done">pytest `xfail(strict=True)` (the unexpectedly-passing signal — idea),</fact></item>
      <item><fact id="PRIOR-ART-BASELINES-AND-RATCHETS" status="spec/done">lint/violation baselines and ratchet patterns from large-repo practice (idea),</fact></item>
      <item><fact id="PRIOR-ART-SRE-ERROR-BUDGETS" status="spec/done">SRE error budgets (idea),</fact></item>
      <item><fact id="PRIOR-ART-VIBEVM-AUDIT-AND-PROP-013" status="impl/done">vibevm's own AUDIT.md + PROP-013 (direct ancestor — this document is its mechanization),</fact></item>
      <item><fact id="PRIOR-ART-FEATHERS-CHARACTERIZATION-TESTS" status="spec/done">Feathers' characterization tests (B4's foundation).</fact></item>
    </list>
  </section>
  <section id="open" title="11. Open questions">
    <list ordered="true" p="40">
      <item><fact id="OPEN-CONFLICT-HEURISTIC-PRECISION" status="spec/done">Conflict-heuristic precision: the MUST/MUST-NOT window match will false-positive; tune on the real corpus, report precision in Phase −1 findings.</fact></item>
      <item><fact id="OPEN-QUOTA-K-AND-DEBT-BUDGETS" status="spec/done">Quota K and per-crate debt budgets: numbers from REPORT data, not taste.</fact></item>
      <item><fact id="OPEN-INTENT-AUTO-LINK-TO-ROADMAP" status="spec/done">Should `intent.json` auto-link ROADMAP milestone anchors once ROADMAP is unit-ified? (Lean yes; cheap; after Phase 1.)</fact></item>
      <item><fact id="OPEN-INDEX-ABSORPTION" status="spec/done">Index absorption: registries stay as files in v0.x for diff-reviewability; folding statuses/conflicts into `specmap.json` as the single store is a PROP-014 v0.2 decision.</fact></item>
    </list>
    <p p="41"><fact id="UNEXERCISED-FIELD-STATUS-OR-POLICY-IS-REMOVED" status="impl/done">*Any registry field, status, or policy here not exercised by Playbook (v0.2) Phase 2 is either removed or annotated in place as **specified, not built** — never carried as unmarked aspiration; yes, the brownfield document eats its own rule.*</fact></p>
  </section>
</spec>
