mig: add team memory tables and chat summary flags
Requested by Sagar · project thread
Summary
Schema for team chat memory in the Platform MCP. DDL only; nothing reads or writes these yet.
chats.summary_redacted(bool, default false): set whensummarycame from the risk-redacted transcript via the upcoming background summary job. Memory only reads summaries where this is true, so older on-demand summaries (built from unmasked transcripts) never reach it.chats.memory_excluded_at(nullable timestamptz): per-chat opt-out from team memory.memory_memos: facts an agent saves on purpose (remembertool). Org + project scoped, optional source chat, author user or agent, redacted content (1 to 4000 chars), generated englishtsvectorwith a GIN index.memory_digests: day, week and month rollups. Half-open[period_start, period_end), typed source arrays (chat_ids,memo_ids,child_digest_ids), model + token counts for cost tracking, generatedtsvectorwith a GIN index, unique on(project_id, level, period_start), and a GIN index onchat_idsso digests citing a chat can be rebuilt.- Regenerated sqlc models (
chatsgains two fields).
No index on chats.summary yet. That would be a concurrent index on a hot table and force a non-transactional migration, so search computes the vector on the fly inside its project + time filter for now.
Motivation
Agents on the Platform MCP lose all context between sessions. This lays the storage for shared, masked team memory: background chat summaries, saved memos, and period digests. The feature lands in later PRs behind a flag.
Open questions (defaults picked, not blocking this schema):
- Team boundary = project.
memory:read/memory:writestay out of every system role by default, likechat:read.- Opt-out is per chat; individual memos can be soft-deleted.
The migration file and atlas.sum are pending: they will be generated by atlas migrate diff and committed before this leaves draft.
Generated by Claude Code
Summary by cubic
Adds the database schema for shared, masked team memory in the Platform MCP so agents retain context across sessions. DDL only — nothing reads or writes these tables yet.
Schema
- Adds
chats.summary_redactedandchats.memory_excluded_at; memory readers only consume summaries marked redacted (from the upcoming background summary job) and skip excluded chats. - Adds
memory_memosfor facts saved via theremembertool — project-scoped, optional source chat, redacted content, generated Englishtsvectorwith GIN index. - Adds
memory_digests, day/week/month rollups with half-open[period_start, period_end)periods, typed source arrays (chat_ids,memo_ids,child_digest_ids), and model/token counts for cost tracking. - Memo chat and agent foreign keys are single-column so a hard delete can
SET NULLjust that column; a composite key would also null the NOT NULLproject_idororganization_id(Atlas doesn't model Postgres 15's column-listSET NULL). - Checks constrain author cardinality, digest levels, canonical UTC periods, and non-negative tokens.
- Regenerated sqlc models pick up the two new
chatsfields. chats.summarygets no index yet — a concurrent index on that hot table would force a non-transactional migration, so search computes the vector on the fly.- Migration file and
atlas.sumare generated and committed.