feat(runtime): social layer (Phase 5) #16

Merged
halofourteen merged 1 commits from feat/survival-pivot-phase-5 into main 2026-05-25 22:30:48 +03:00
halofourteen commented 2026-05-25 22:30:37 +03:00 (Migrated from github.com)

Summary

Phase 5 of plans/autonomous-survival-bot-prd.md. The bot now feels
present in chat without ever becoming a command executor.

  • runtime/social/intent.jsclassifyIntent returns one of
    GREETING / STATUS_QUESTION / ADDRESSED_BANTER / COMMAND_LIKE
    / UNSAFE_REQUEST / AMBIENT. Unicode-aware word boundaries (so
    "Привет всем" → GREETING).
  • runtime/social/reply.js — templated short replies; status pulls
    from activeSkill, currentMilestone, hp/food/position,
    noProgressReason, last diary line. ADDRESSED_BANTER returns
    escalate: true (Pi is not actually called here — kept out of the
    hot path until Phase 6).
  • runtime/social/memory.js — per-speaker LRU buffer (default 8
    lines × 16 speakers); redacts password / api_key / JWT-shaped
    tokens before they ever leave the runtime.
  • runtime/state-store.js — adds readDiaryTail(n) and
    writeEscalation({…}) / listEscalations() writing to
    state/<host>/escalations.jsonl.
  • runtime/bot.jshandleChat() routes through the new social
    layer (replaces Phase-0 inline regexes), records every line into
    chat memory, and writes an escalation on UNSAFE_REQUEST. Phase-0
    dialog-only / command-like-ignored behaviour is preserved.
  • Tests — 12 new tests in runtime/social/social.test.js. npm test
    is now 40/40.

Test plan

  • npm test — 40/40
  • Cyrillic + latin greetings both classify correctly
  • Addressed banter does not auto-spawn Pi
  • Command-like chat still triggers dialog-only notice + diary
  • Unsafe chat writes to escalations.jsonl
  • Chat memory redacts secrets at append time, not at read time
  • Live-server: <bot> what are you doing? returns a real status
    line including current milestone + no-progress reason

🤖 Generated with Claude Code

## Summary Phase 5 of `plans/autonomous-survival-bot-prd.md`. The bot now feels present in chat without ever becoming a command executor. - **`runtime/social/intent.js`** — `classifyIntent` returns one of `GREETING` / `STATUS_QUESTION` / `ADDRESSED_BANTER` / `COMMAND_LIKE` / `UNSAFE_REQUEST` / `AMBIENT`. Unicode-aware word boundaries (so "Привет всем" → `GREETING`). - **`runtime/social/reply.js`** — templated short replies; status pulls from `activeSkill`, `currentMilestone`, hp/food/position, `noProgressReason`, last diary line. `ADDRESSED_BANTER` returns `escalate: true` (Pi is not actually called here — kept out of the hot path until Phase 6). - **`runtime/social/memory.js`** — per-speaker LRU buffer (default 8 lines × 16 speakers); redacts password / api_key / JWT-shaped tokens before they ever leave the runtime. - **`runtime/state-store.js`** — adds `readDiaryTail(n)` and `writeEscalation({…})` / `listEscalations()` writing to `state/<host>/escalations.jsonl`. - **`runtime/bot.js`** — `handleChat()` routes through the new social layer (replaces Phase-0 inline regexes), records every line into chat memory, and writes an escalation on UNSAFE_REQUEST. Phase-0 dialog-only / command-like-ignored behaviour is preserved. - **Tests** — 12 new tests in `runtime/social/social.test.js`. `npm test` is now 40/40. ## Test plan - [x] `npm test` — 40/40 - [x] Cyrillic + latin greetings both classify correctly - [x] Addressed banter does not auto-spawn Pi - [x] Command-like chat still triggers dialog-only notice + diary - [x] Unsafe chat writes to `escalations.jsonl` - [x] Chat memory redacts secrets at append time, not at read time - [ ] Live-server: `<bot> what are you doing?` returns a real status line including current milestone + no-progress reason 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign in to join this conversation.