# Requirements: Autonomous Self-Healing

This file is the explicit capability and coverage contract for the project.

## Active

### R001 — Idle Halt Detection
- Class: failure-visibility
- Status: active
- Description: The autonomous loop must detect when it is in a `stop` state that has persisted beyond a configurable time threshold.
- Why it matters: Prevents the loop from sitting idle without the operator knowing.
- Source: spec
- Primary owning slice: M003/S01
- Supporting slices: none
- Validation: unmapped
- Notes: Requires a watchdog timer in `auto/loop.js`.

### R002 — Multi-Channel Notification
- Class: failure-visibility
- Status: active
- Description: Persistent and transient notifications must fire when a halt is detected.
- Why it matters: Ensures the operator sees the "stuck" signal across different surfaces (TUI, terminal, push).
- Source: spec
- Primary owning slice: M003/S02
- Supporting slices: none
- Validation: unmapped
- Notes: Should use `ctx.ui.notify` and a durable log like `.sf/notifications.jsonl`.

### R003 — Halt Self-Feedback
- Class: quality-attribute
- Status: active
- Description: Every autonomous halt must produce a structured self-feedback entry capturing the stuck state and reason.
- Why it matters: Provides a durable audit trail and allows for future "triage" units to address the cause.
- Source: spec
- Primary owning slice: M003/S03
- Supporting slices: none
- Validation: unmapped
- Notes: Filed with severity `high` if blocking.

### R004 — Auto-Remediation Dispatch
- Class: differentiator
- Status: active
- Description: When a milestone is stuck on `needs-attention`, SF should autonomously dispatch a remediation unit if a clear plan exists.
- Why it matters: Reduces human intervention for common validation failures.
- Source: spec
- Primary owning slice: M003/S04
- Supporting slices: none
- Validation: unmapped
- Notes: Leverages existing `replan-slice` or a new `remediation-slice`.

### R005 — Auto-Defer Confidence Policy
- Class: constraint
- Status: active
- Description: High-confidence findings that match specific categories can be auto-deferred to unblock completion.
- Why it matters: Prevents trivial findings from stopping the pipeline.
- Source: spec
- Primary owning slice: M003/S05
- Supporting slices: none
- Validation: unmapped
- Notes: Requires a threshold check (e.g., confidence < 0.3).

### R006 — Fail-Open Safety
- Class: quality-attribute
- Status: active
- Description: Failure of the self-heal logic itself must not crash the autonomous loop or worsen the halt.
- Why it matters: System robustness.
- Source: spec
- Primary owning slice: M003/S06
- Supporting slices: none
- Validation: unmapped
- Notes: Standard try/catch protection.

## Traceability

| ID | Class | Status | Primary owner | Supporting | Proof |
|---|---|---|---|---|---|
| R001 | failure-visibility | active | M003/S01 | none | unmapped |
| R002 | failure-visibility | active | M003/S02 | none | unmapped |
| R003 | quality-attribute | active | M003/S03 | none | unmapped |
| R004 | differentiator | active | M003/S04 | none | unmapped |
| R005 | constraint | active | M003/S05 | none | unmapped |
| R006 | quality-attribute | active | M003/S06 | none | unmapped |

## Coverage Summary

- Active requirements: 6
- Mapped to slices: 6
- Validated: 0
- Unmapped active requirements: 0
