# Project: SF Autonomous Self-Healing ## What This Is This project implements self-healing capabilities for the Singularity Forge (SF) autonomous execution loop. It addresses the issue of the loop halting silently when encountering blocking states, such as "needs-attention" validation verdicts, by introducing graduated escalation (notifications, self-feedback) and automated recovery (auto-remediation, auto-deferral). ## Core Value The autonomous loop should never sit silently stuck. Every halt must be communicated to the operator and, where safe, attempts should be made to resolve the blockage autonomously. ## Current State - S01 complete: HaltWatchdog detects forced 'stop' state and emits 'stuck' signal after threshold. - S02 complete: Durable BLOCKING_NOTICE persists to .sf/notifications.jsonl with defensive initialization hardened. - Remaining: S03 (self-feedback), S04 (remediation dispatcher), S05 (auto-defer confidence), S06 (E2E integration). ## Architecture / Key Patterns - **Auto-Loop**: `src/resources/extensions/sf/auto/loop.js` manages iteration and phase dispatch. - **Dispatch Rules**: `src/resources/extensions/sf/uok/auto-dispatch.js` determines the next action based on milestone/slice state. - **Self-Feedback**: `src/resources/extensions/sf/self-feedback.js` provides the registry for anomalous behavior. - **Notification Store**: `src/resources/extensions/sf/notification-store.js` persists notifications to `.sf/notifications.jsonl` (fail-open, idempotent init). ## Capability Contract See `.sf/REQUIREMENTS.md` for the explicit capability contract, requirement status, and coverage mapping. ## Milestone Sequence - [x] M003/S01: Idle Halt Detection — Loop watchdog detects persistent stop states. - [x] M003/S02: Escalation Plumbing — Durable notifications land in `.sf/notifications.jsonl`. - [ ] M003/S03: Halt Self-Feedback — Structured SELF-FEEDBACK.md entries after halt. - [ ] M003/S04: Remediation Dispatcher — Auto-dispatch remediation slices on needs-attention. - [ ] M003/S05: Auto-Defer Confidence — Low-confidence findings auto-deferred. - [ ] M003/S06: End-to-End Integration — Full self-healing flow in headless run.