# PR-06 Doctor, Diagnostics, and Safe-Fix Baseline

Domain Owner: `docs/packer`

## Briefing

Implement the baseline doctor and diagnostics model for the production packer.

This PR is responsible for making the packer operationally useful beyond navigation and mutation flows.

## Objective

Deliver structured doctor execution with managed-world validation, expanded workspace hygiene scanning, and safe-fix preview/apply where baseline-safe.

## Dependencies

- [`./PR-05-sensitive-mutations-preview-apply-and-studio-write-adapter.md`](./PR-05-sensitive-mutations-preview-apply-and-studio-write-adapter.md)
- [`../specs/5. Diagnostics, Operations, and Studio Integration Specification.md`](../specs/5.%20Diagnostics,%20Operations,%20and%20Studio%20Integration%20Specification.md)
- [`../specs/6. Versioning, Migration, and Trust Model Specification.md`](../specs/6.%20Versioning,%20Migration,%20and%20Trust%20Model%20Specification.md)

## Scope

- implement managed-world structural validation
- implement expanded workspace hygiene scanning
- classify diagnostics by severity and blocking behavior
- implement safe mechanical fix flows for baseline-safe cases only
- expose doctor responses in structured form for Studio and CI consumption
- define evidence and summaries suitable for Activity and inline diagnostics

## Non-Goals

- no silent destructive repair
- no speculative auto-healing of relocational or delete scenarios
- no final watch mode yet

## Execution Method

1. Implement diagnostic producers for registry, declaration, and workspace hygiene findings.
2. Implement doctor request modes and safe-fix eligibility checks.
3. Model doctor output as structured responses instead of terminal-only text.
4. Connect safe-fix preview/apply behavior to the same safety rules used by mutation flows.

## Acceptance Criteria

- blocking and non-blocking diagnostics are clearly separated
- doctor can report on both managed-world validity and broader hygiene issues
- safe fixes only exist where the operation is explicitly low-risk
- Studio and CI can consume the same doctor response model

## Validation

- fixture tests for structural errors and hygiene findings
- tests for safe-fix eligibility and refusal paths
- adapter tests for Studio diagnostic mapping

## Affected Artifacts

- `prometeu-packer/**`
- cross-domain reference: Studio diagnostics and activity consumers
- doctor fixtures and expected reports
