Skip to content

feat(phase5): sentiment tagging + adaptive sleep intelligence#136

Merged
salishforge merged 1 commit into
mainfrom
feat/phase5-sentiment-and-adaptive-sleep
May 21, 2026
Merged

feat(phase5): sentiment tagging + adaptive sleep intelligence#136
salishforge merged 1 commit into
mainfrom
feat/phase5-sentiment-and-adaptive-sleep

Conversation

@salishforge
Copy link
Copy Markdown
Owner

Summary

First of six PRs splitting #129 into per-feature units. Ships two independent additive features from Phase 5:

  • Feature 6 — Memory Sentiment Tagging — heuristic inference of urgency, sentiment, session_type from content at write time. New context_signals JSONB column on hot_tier and warm_tier. Signals merge during consolidation (urgency = max, sentiment/session_type = majority vote).
  • Feature 5 — Adaptive Sleep Intelligence (analytics infrastructure) — new sleep_phase_analytics table + two public helpers on SleepCycleEngine: recordPhaseAnalytics() and shouldSkipPhase(). Helpers are NOT yet wired into the run() loop — that's a deliberate follow-up so this PR delivers a stable, tested API surface first.

Migration: schema/migration-v3.8.sql.

What this is part of

Splitting #129 (Phase 5 mega-PR, 1,348 LOC, no integration tests) into 6 reviewable units. Order:

  • PR-A (this) — Sentiment + Adaptive Sleep infrastructure
  • PR-B — Epistemic Confidence Model
  • PR-C — Explainable Memory Ops
  • PR-D — Hierarchical Abstraction
  • PR-E — Causal Memory Graph
  • PR-F — Transfer Learning

#129 will be closed as superseded after all six merge.

Test plan

  • npm run type-check — 0 errors
  • npm run build — clean
  • npm run lint — clean
  • npm run test:sentiment-tagging29/29 pass (18 unit + 4 integration + 2 e2e + 5 migration)
  • npm run test:adaptive-sleep18/18 pass (10 unit + 2 integration + 6 migration)
  • npm audit --omit=dev — 0 vulnerabilities
  • CI green on push

Known follow-ups

  • Wire shouldSkipPhase() + recordPhaseAnalytics() into the run() loop (tracked separately).

🤖 Generated with Claude Code

- Memory Sentiment Tagging (F6): infer urgency/sentiment/session_type
  from content at add and consolidation time. New context_signals
  JSONB column on hot_tier and warm_tier. During consolidation,
  signals from all contributing hot rows are merged: urgency = max,
  sentiment = majority, session_type = majority. query() returns
  context_signals on each QueryResult. New types UrgencyLevel,
  SentimentTag, SessionType, ContextSignals.

- Adaptive Sleep Intelligence (F5): per-phase telemetry in new
  sleep_phase_analytics table. Two new methods on SleepCycleEngine:
  recordPhaseAnalytics() and shouldSkipPhase() (skips phases whose
  last 3 runs had zero changes_made). Index + RLS policy included.

Migration: schema/migration-v3.8.sql (idempotent ADD COLUMN IF NOT EXISTS)
Tests: 29 sentiment + 18 adaptive-sleep (unit/integration/migration)
Split from #129 (PR-A).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@salishforge salishforge merged commit a088b46 into main May 21, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant