# v0.4.12 — Autonomous Quality Convergence

v0.4.12 replaces the bounded reviewer-remediation loop with an autonomous quality convergence engine. Review remediation no longer succeeds or fails because a fixed number of rounds has elapsed. It continues until the Final Quality Gate passes or a genuine human-on-exception condition is discovered.

## Final Quality Gate

The default policy uses integer DebtPoints so the configured ratios are exact:

| Severity | DebtPoints | DebtScore equivalent | Final maximum |
| --- | ---: | ---: | ---: |
| critical | 300 | 100 | 0 |
| high | 75 | 25 | 0 |
| medium | 24 | 8 | 0 |
| low | 3 | 1 | 3 |
| note | 1 | 1/3 | governed by aggregate score |

Three notes equal one low exactly. `DebtScore = DebtPoints / 3`. The default final gate requires `critical=0`, `high=0`, `medium=0`, `low<=3`, and `DebtPoints<=9` (`DebtScore<=3`). Thus nine notes can pass, ten notes cannot, and three lows plus one note cannot pass.

## Convergence states

Each reviewer round is normalized and deduplicated, then fingerprinted and compared with accepted prior states. The engine records `INITIAL`, `IMPROVING`, `STABLE`, `STAGNATING`, `REGRESSING`, `CYCLING`, or `CONVERGED`, plus resolved, persistent, and introduced finding fingerprints.

No remediation-round maximum is used by this engine. Legacy `maxRemediationRounds` configuration is accepted for compatibility but ignored.

## Regression rollback

Immediately before a remediation the Harness snapshots the current modified paths. If the remediation breaks deterministic validation or increases review debt, only paths affected by that remediation are restored to the checkpoint. The implementation state that existed before the rejected remediation remains intact. The Harness never uses a blanket `git reset --hard` or `git clean` for this rollback.

## Automatic escalation

The default escalation ladder is:

1. `normal` — current implementation worker / workhorse.
2. `quality` — focused `quality-implementer` / workhorse.
3. `senior` — `senior-implementer` / `@brain`.
4. `diagnosis` — read-only `oracle` / `@brain`.
5. `replan` — read-only `planner` / `@brain`, producing an advisory implementation plan without changing the sealed contract.

Critical findings can enter at the senior stage immediately. Improving quality de-escalates toward cheaper workers; stagnation, regression, and cycles escalate. After replanning, remediation resumes at the stronger implementation tier. Projects can replace stage agent names and model aliases in `project.yaml`.

## Autonomous replanning

Replanning is implementation-only. The TaskContract, SDD artifacts and executable acceptance remain sealed normative truth. The planner receives the current quality state and normalized findings and emits the normal structured planner output. The result is persisted under the findings directory and supplied to subsequent remediation agents as advisory strategy.

## Exception detection and human-on-exception

Review findings can explicitly classify exceptional conditions. The Harness also recognizes canonical exception categories. Routine implementation defects and `SYSTEM_FAILURE` remain autonomous. Human intervention is reserved for:

- `SPEC_CONTRADICTION` — authoritative requirements cannot simultaneously be satisfied.
- `REQUIRES_PRODUCT_DECISION` — the repository and sealed artifacts do not contain the required product/business decision.
- `BLOCKED_EXTERNAL` — required credentials, account permissions, secrets, or external resources are unavailable.

Run records persist `finalState`, `humanRequired`, remediation count, final DebtScore/DebtPoints, severity counts, convergence state and reviewer/diagnostic session count.

## Default configuration

```yaml
workflow:
  reviews:
    quality:
      severityPoints:
        critical: 300
        high: 75
        medium: 24
        low: 3
        note: 1
    convergence:
      minimumDebtPointImprovement: 3
      stagnationWindow: 2
      cycleDetection: true
      regressionDetection: true
    finalQualityGate:
      maxBySeverity:
        critical: 0
        high: 0
        medium: 0
        low: 3
      maxDebtPoints: 9
    escalation:
      criticalStartStage: 2
      replanResumeStage: 2
      stages:
        - { name: normal, action: remediate }
        - { name: quality, action: remediate, agent: quality-implementer }
        - { name: senior, action: remediate, agent: senior-implementer, model: "@brain" }
        - { name: diagnosis, action: diagnose, agent: oracle, model: "@brain" }
        - { name: replan, action: replan, agent: planner, model: "@brain" }
```
