You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Brain health follow-ups: vocabulary reconstruction wiring + soul plan + growth anomaly collector (#20)
* feat(health): wire reconstruct_vocabulary_from_memories into vocabulary heal flow (F1)
When emotion_vocabulary.json corrupts and no .bak is recoverable, the
heal flow used to reset to empty `{"version":1,"emotions":[]}` — losing
all persona-extension emotions the brain has been operating with.
Now: if the loader has store access (caller passed `store=...`), the
reset_to_default path is replaced with reconstruct_from_memories. The
brain re-learns its own vocabulary from how it has been using emotions.
Framework baseline (21 entries) + persona-extension entries detected in
memories.db (with `(reconstructed from memory)` placeholder description
and conservative 1.0-day decay).
The anomaly's action field reflects the actual outcome: when reconstruction
fires, action becomes `reconstructed_from_memories` (not `reset_to_default`).
The forensic quarantine of the original corrupt file is preserved.
Falls back to bare reset when no store is provided (some callers don't
have one — that's fine, they'll get the empty default).
Closes followup #1 from brain-health-module-design.md §9.
* docs(health): concrete soul module health plan (F2)
Spec §9.1 expanded from a one-line deferral into a concrete plan the
next engineer can implement directly when soul module lands. Covers:
- file classification (atomic-rewrite identity, same tier as
emotion_vocabulary.json)
- reconstruct_soul_from_memories(store) following F37's self-claims-
from-experience pattern
- schema validator shape
- acceptance criteria for the soul-module PR
Inline comments in walker.py (_DEFAULTS) and alarm.py (_IDENTITY_FILES)
point at spec §9.1 so the plan is visible during code-reading too.
Closes followup #2 from brain-health-module-design.md §9.
* feat(health): thread anomaly collector through run_growth_tick (F3)
When run_growth_tick reads a corrupt emotion_vocabulary.json via
_read_current_vocabulary_names, the anomaly produced by the heal flow
is now appended to an optional caller-provided collector instead of
being silently dropped after a local warning.
Wiring:
- _read_current_vocabulary_names returns (set[str], BrainAnomaly | None)
- run_growth_tick accepts anomalies_collector: list[BrainAnomaly] | None
- HeartbeatEngine._try_run_growth forwards tick_anomalies as the collector
when calling run_growth_tick
After this lands, vocabulary corruption discovered inside the weekly
growth tick surfaces in the heartbeat audit log + HeartbeatResult.anomalies
+ compact CLI 🩹/banner exactly like config/state corruption discovered at
the top of the tick. No more silent loss.
Calling run_growth_tick standalone (e.g., from tests, or in the future
from a scheduled job runner) without a collector still works — the
parameter is opt-in.
Closes followup #3 from brain-health-module-design.md §9.
---------
Co-authored-by: Hana <hana@nanoclaw.local>
Copy file name to clipboardExpand all lines: docs/superpowers/specs/2026-04-25-brain-health-module-design.md
+21-1Lines changed: 21 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -347,7 +347,27 @@ The full health module ships when:
347
347
348
348
## 9. Open / Deferred
349
349
350
-
-**Soul reconstruction.** When the soul module lands as a Phase 2a-extension, its `soul.json` healing strategy needs design. Soul crystallizations might be partially reconstructable from memories (F37 was self-claims-from-experience), but defer that until soul exists.
350
+
### 9.1 Soul module health (concrete plan for when soul lands)
351
+
352
+
When the Phase 2a-extension brings the soul module online, `soul.json` (or whatever its filename ends up being) joins the persona's identity-critical files. The heal strategy is already partially specified by the architecture; this section makes it concrete so the engineer building the soul module doesn't have to rediscover the plan.
353
+
354
+
**File classification:**`soul.json` is an **atomic-rewrite identity file** — same tier as `emotion_vocabulary.json`, `interests.json`, `reflex_arcs.json`. Use `attempt_heal` + `save_with_backup`. Add it to:
355
+
356
+
-`brain/health/walker.py:_DEFAULTS` with empty default `{"version": 1, "crystallizations": []}` (or whatever the schema settles on).
357
+
-`brain/health/alarm.py:_IDENTITY_FILES` so `reset_to_default` on `soul.json` raises an alarm.
358
+
359
+
**Reconstruction strategy:** F37 in OG NellBrain was *self-claims-from-experience* — the brain's soul names were derived from autobiographical patterns in memories. The same heuristic applies here: when all backups corrupt and reset would otherwise fire, scan `memories.db` for soul-claim patterns the brain has expressed and rebuild a partial `soul.json`. Implement as `brain/health/reconstruct.py:reconstruct_soul_from_memories(store) -> dict` mirroring `reconstruct_vocabulary_from_memories`. Wire it into the soul loader's heal flow the same way vocabulary does in `load_persona_vocabulary_with_anomaly` (Followup F1, 2026-04-26).
360
+
361
+
**Schema validator:** mirror the vocabulary validator pattern — minimal type check (`isinstance(data, dict) and isinstance(data.get("crystallizations"), list)`) — so corrupt-but-parseable files trigger heal.
362
+
363
+
**Acceptance:** when soul module lands, the soul module's PR must include:
364
+
1.`soul.json` in `walker.py:_DEFAULTS` and `alarm.py:_IDENTITY_FILES`
3. Soul loader's `*_with_anomaly` variant routes through `attempt_heal` and triggers reconstruction on `reset_to_default` when a store is provided
367
+
4. Sandbox smoke: corrupt soul.json + run heartbeat tick → soul heals or reconstructs without user intervention
368
+
369
+
### 9.2 Other deferred items
370
+
351
371
-**Automatic .bak repair when a backup is detected corrupt mid-rotation.** v1 skips the corrupt backup and walks to the next; doesn't try to repair the backup itself. If real-world telemetry shows backups frequently corrupt mid-chain, revisit.
352
372
-**GUI surface for "the brain self-healed."** Not a framework concern; future Tauri/NellFace work consumes the audit log directly.
0 commit comments