feat(vibe): adapt sessions to context and exploration
Typecheck / typecheck (backend) (push) Has been cancelled
Typecheck / typecheck (workers) (push) Has been cancelled
Typecheck / typecheck (backend) (pull_request) Has been cancelled
Typecheck / typecheck (workers) (pull_request) Has been cancelled

This commit is contained in:
kami
2026-08-02 02:08:35 +04:00
parent fe13798c99
commit 61a1373ca9
14 changed files with 782 additions and 16 deletions
+39
View File
@@ -720,4 +720,43 @@ export const MIGRATIONS: Migration[] = [
);
`,
},
{
// Session-specific exploration, goals, and deliberately lossy session
// fingerprints are derived from the immutable Vibe ledger. Keeping them
// separate from listener_beliefs prevents a transient session from
// rewriting permanent taste.
id: '20260802_vibe_context_memory_exploration',
sql: `
CREATE TABLE IF NOT EXISTS vibe_session_profiles (
session_id UUID PRIMARY KEY REFERENCES vibe_sessions(id) ON DELETE CASCADE,
user_id UUID NOT NULL,
fingerprint JSONB NOT NULL DEFAULT '{}'::jsonb,
goals JSONB NOT NULL DEFAULT '{"type":"discovery","target":1,"progress":0}'::jsonb,
exploration_coefficient REAL NOT NULL DEFAULT 0.30
CHECK (exploration_coefficient >= 0 AND exploration_coefficient <= 1),
discovery_radius REAL NOT NULL DEFAULT 0.38
CHECK (discovery_radius >= 0 AND discovery_radius <= 1),
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);
CREATE INDEX IF NOT EXISTS idx_vibe_session_profiles_user_updated
ON vibe_session_profiles (user_id, updated_at DESC);
CREATE TABLE IF NOT EXISTS vibe_session_feedback_projections (
event_id UUID PRIMARY KEY REFERENCES vibe_events(id) ON DELETE CASCADE,
projected_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);
`,
},
{
// The profile table was introduced after durable sessions. Backfill every
// pre-existing session before feedback can claim its exactly-once marker;
// newly created sessions receive their context-derived initial goals in
// createVibeSession's transaction.
id: '20260802_vibe_session_profile_backfill',
sql: `
INSERT INTO vibe_session_profiles (session_id, user_id)
SELECT id, user_id FROM vibe_sessions
ON CONFLICT (session_id) DO NOTHING;
`,
},
];