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
salishforge added a commit that referenced this pull request Jul 25, 2026
Resolves two months of drift: features 1 (epistemic confidence),
5 (adaptive sleep intelligence), and 6 (sentiment tagging) from this
PR were re-landed on main via #136-#138 with instrumented, tested
implementations, so main wins everywhere both sides implement the
same feature. This PR keeps only its unique features: 2 (explainable
memory ops), 3 (causal memory graph), 4 (hierarchical abstraction),
7 (transfer learning), plus sleep phases 5.11 and 6.1.

Resolution notes:
- PR's omnibus migration-v3.8.sql replaced by main's v3.8; the
  PR-unique DDL (causal_edges, abstractions + RLS + grants) moved to
  new migration-v3.10.sql; schema.sql synced.
- Removed duplicates the auto-merge produced: second /epistemic
  route, second inferContextSignals(), second mergedSignals block,
  duplicated type declarations in types.ts.
- memforge_certainty MCP executor takes main's version (the PR built
  an epistemicOpts object it never passed; main forwards the
  epistemic filter correctly).
- Phases 5.11/6.1 wrapped in runPhase() following main's
  drift-snapshot convention so they record sleep_phase_analytics.
- Query cache key now includes the explain flag alongside epistemic.

Verified: type-check and build clean; full test suite matches the
origin/main baseline exactly (190/219 pass, same 29 pre-existing
environment failures); smoke-tested all new endpoints against a
fresh schema load.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EWrtbDnaYoDtJKEG49ACkG
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