audience: AI coding agents first.

# Factory resolution UI — request

**Goal:** expose incident Defaults, durable run supervision/resolution, and owner-gated task-contract rewrites through real Astryx traces and approved diff UI.

**Execution authority:** factory-owned UI work. MUST NOT modify supervisor, coordinator, policy enforcement, canaries, signing, or execution ledgers.

**Canonical design:** `docs/specs/2026-08-09-factory-supervision-and-resolution-design.md`.

## Prerequisites

- Astryx factory transcript implementation and React 19 land.
- Approved `@overdeck/deck-ui` `DiffView` lands with unified + side-by-side modes, barrel export, gallery registration, accessibility, both-theme tests.
- Incident selector options, Defaults API, supervisor trace seams, and proposal decision API land.

## Files

- Create `apps/web/src/components/incidents/IncidentDefaultsPanel.tsx` — global/per-type resolver policy editor.
- Create `apps/web/src/components/incidents/IncidentDefaultsPanel.test.tsx`.
- Create `apps/web/src/components/factory/TaskContractProposalDrawer.tsx` — before/after Markdown and diff decision flow.
- Create `apps/web/src/components/factory/TaskContractProposalDrawer.test.tsx`.
- Modify `apps/web/src/components/incidents/IncidentsContent.tsx` and `IncidentDetailDrawer.tsx` — Defaults entry and linked proposal only when incident-linked.
- Modify `apps/web/src/components/factory/FactoryRunContent.tsx` and `FactoryStepDrawer.tsx` — ownership/checkpoint/resolver/incident/proposal transcript rows and drawers.
- Modify `apps/web/src/lib/incident-types.ts` and factory trace client types — exact wire contracts.
- Modify same-origin API client modules for Defaults and proposal decisions.
- Modify relevant Astro exact-path proxy handlers.
- Modify `/design-system` registration only if landed `DiffView` prerequisite is not already registered; never create another diff primitive.

## Contract

Defaults editor consumes authoritative `GET/PUT /incidents/defaults` plus `/incidents/options`.

Proposal decision values:

```text
Approve and continue
Reject and fail run
Reject with feedback
```

Decision mutation sends owner-authenticated proposal revision, base digest, selected action, and feedback only for reject-with-feedback.

## Behavior

### Defaults

- Show global resolver rows: Harness, Model, Effort, Account.
- Add/remove/reorder rungs with existing shared controls.
- Show finite Attempts, Wall, Input tokens, Output tokens, Cost, Same fingerprint, Unsafe, Auto repair.
- Per incident type supports inherit/override and resolved-policy preview.
- Invalid/stale capability remains visible and blocks save/dispatch; no substitution.
- Preserve edits on conflict/error; show server revision conflict and refresh action.
- Use `DataTable` and existing deck-ui primitives; no hand-rolled table/chip/menu/tooltip.

### Task-contract proposal

- Factory transcript always exposes linked proposal. Incident detail exposes only explicit linked incident proposal.
- `DiffView` supports `Unified` and `Side by side`; before and after visible together, line numbers/context/add/delete.
- Show formatted Markdown previews beside raw contract diff.
- Show real resolver harness/model/effort/account, host, timing, source failure, contract revision, and base digest.
- Sticky owner actions. Reject-feedback requires text and launches one bounded proposal iteration through API.
- Approval does not fabricate resume; render authoritative returned run state.
- Stale proposal action returns conflict and refreshes current proposal.

### Transcript

- Render clickable rows for lease acquire/expire/takeover, worker admission/exit, checkpoint verify/diverge, classification, policy/budget, resolver attempt/progress/tree restore, incident, proposal, resume, and terminal outcome.
- Drawers show real prompts, commands/output, files/diffs, gates, timing, host, requested/observed identity, account, raw trace.
- `needs-attention` names stop reason and owner action. No fabricated summaries.

## Out of scope

- New UI primitives.
- Backend execution or policy changes.
- `/plans` revival.
- Browser-local defaults persistence.

## Acceptance

- Run `pnpm --filter @overdeck/deck-ui test && pnpm --filter @overdeck/deck-ui typecheck`.
- Run `pnpm --filter web test && pnpm --filter web typecheck && pnpm --filter web build`.
- Expected clean PASS with no warnings/hints for Defaults inherit/override/reorder/conflict/invalid capability, proposal three actions/stale conflict, unified/side-by-side diff, and honest transcript fields.
- Use `e2e-remote` for browser+dev-server verification.
- Live proof on `/incidents` and `/factory/<adwId>` in both themes: save/reload Defaults; inspect real failed run; review real before/after proposal; reject with feedback; approve later revision; observe same run resume.
