feat: make the two-step reflection observable (draft -> revised -> critique)

You couldn't see her actually correct herself — /self showed only the result.
Now:
- reflect() logs the draft, the revised/committed version, and the self-critique
  to the live log as an expandable "view details" block
- POST /self/reflect runs a reflection in the web process so it lands in /logs
  live (reflections normally run in the dream process, whose logs only go to
  journald); "↻ Reflect now" button on /self triggers it, with a logs ↗ link
- log viewers relabel the expander "view full prompt" -> "view details" (it now
  carries prompts and reflection diffs)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-17 04:53:38 +00:00
parent 3df060a1cd
commit 4c8f7202da
5 changed files with 54 additions and 6 deletions
+7
View File
@@ -125,6 +125,13 @@ def create_app() -> FastAPI:
"""Lyra's current interiority + when it last changed."""
return {"state": self_state.load(), "updated_at": memory.self_state_updated_at()}
@app.post("/self/reflect")
async def self_reflect() -> dict:
"""Run one two-step reflection now, in this process, so the draft ->
revised -> critique lands in the live log (/logs)."""
state = await asyncio.to_thread(self_state.reflect)
return {"ok": True, "mood": state.get("mood")}
@app.get("/stream/logs")
async def stream_logs(request: Request) -> StreamingResponse:
"""Live activity feed: replay the recent buffer, then stream new events."""