# Furoshiki Phase 2: Full Independence

_Status: **COMPLETE** as of 2026-03-24_

Phase 2 goal was achieved: Furoshiki's entire self-awareness system runs standalone with no dependency on any external agent-hosting framework.

---

## What Was Done

### Infrastructure
- [x] `scripts/db.py` — shared DB/path constants
- [x] `scripts/llm.py` — shared LLM caller with budget enforcement and token tracking
- [x] `scripts/add_system_event.py` — universal event writer
- [x] `scripts/soul_engine.py` — core logic daemon (every 15 min via system cron)
- [x] Optional HTTP health cron via plugins (`cron` hook, `furoshiki plugins reload`)
- [x] `scripts/outreach_pulse.py` + `scripts/voice_dispatcher.py` — cron every 5 min invokes pulse → gated Telegram send (≤1 per pulse)
- [x] `scripts/telegram_listener.py` — long-polling Telegram daemon, primary harness
- [x] `furoshiki-listener.service` — systemd user service, auto-restart, boot-persistent
- [x] `cron/crontab` — system crontab installed and running
- [x] `bin/furoshiki` — full-featured CLI (status, logs, cron, nudge, health, service, config)

### Loop scripts (all complete)
- [x] `run_emotional_read.py` — reads session logs, records emotional weights
- [x] `run_inner_monologue.py` — nightly journal + curiosity/self-question/anticipation generation
- [x] `run_morning_reflection.py` — morning orient, brief mood note
- [x] `run_afternoon_processing.py` — post-session reflection
- [x] `run_question_processing.py` — attempts to answer pending self-questions
- [x] `run_deep_reflection.py` — weekly self-assessment, updates SELF.md
- [x] `run_optimization_check.py` — weekly workspace health review

### External framework decoupling (complete)
- [x] All session paths under `FUROSHIKI_DATA` (default `~/.furoshiki/`)
- [x] Identity files under `FUROSHIKI_DATA/config/`
- [x] No third-party agent-hosting stack required for scheduling, memory, or delivery

### Cost controls
- [x] `llm_call_log` table — every LLM call logged with model, tokens, estimated cost
- [x] Budget caps in `llm.py` — hard stop at daily/monthly limits
- [x] Alert at 80% of daily cap via `system_event: budget_warning`
- [x] `furoshiki config` CLI — show/set all config keys, model shortcuts with cost estimates

### Model switching
- [x] 12 model shortcuts in `scripts/llm.py` — single source of truth
- [x] `/model` Telegram command — switch model mid-conversation without restart
- [x] Natural language: "switch to haiku", "use sonnet"

---

## Current Architecture

```
Telegram (user)
     │
     ▼
telegram_listener.py  ←─── systemd daemon (furoshiki-listener.service)
     │  builds system prompt from identity_shell.py + session-context.json + learned profile / user_facts
     │  calls llm.py (budget-gated)
     │  writes memory/YYYY-MM-DD.md
     │  writes system_events
     │
     ▼
system_events table  ←─── universal input bus
     │
     ▼
soul_engine.py  (every 15 min via cron)
     │  decays needs → heartbeat-state.json
     │  fills mind_queue from curiosity_queue, self_questions, user_anticipations
     │
     ▼
outreach_pulse.py → voice_dispatcher.py  (cron */5 * * * *)
     │  checks cooldown (3h) + daily cap (4/day)
     │  reads mind_queue → LLM prose → Telegram
     │
     ▼
Telegram (the user)
```

Loop scripts run independently via cron and feed data into the pipeline tables above.
