Repository navigation
mig: add team memory tables and chat summary flags - #8302
simplesagar wants to merge 7 commits into
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011XLiZ9Pjyud5BdXQtZfFVY
|
|
|
||||||||||||||||
|
|
||||||||||||||||
There was a problem hiding this comment.
7 issues found across 3 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="server/database/schema.sql">
<violation number="1" location="server/database/schema.sql:6180">
P2: Regenerating a summary in place does not reset `summary_redacted`. Once the background job sets it true, an on-demand summary from the unmasked transcript would still count as redacted and could enter team memory. `UpdateChatSummary` should set `summary_redacted = false`, or the write should be made atomic with the flag, before the background job starts writing it.</violation>
<violation number="2" location="server/database/schema.sql:16516">
P2: `memory_memos.author_agent_id` has no foreign key, so an arbitrary or cross-tenant UUID can be stored. Add a composite FK to `agents (organization_id, id)`, matching the other agent references in this file.</violation>
<violation number="3" location="server/database/schema.sql:16525">
P1: The memory tables duplicate `organization_id`, but their foreign keys validate only `project_id`; the database therefore accepts mismatched organization/project tenants. Use `(organization_id, project_id) REFERENCES projects (organization_id, id)` for both tables.</violation>
<violation number="4" location="server/database/schema.sql:16526">
P1: The memo chat FK does not bind the source chat to the memo's project, so project A can store a memo citing project B's chat. Enforce the chat/project relationship and validate or normalize digest source references before using them for project-scoped memory.</violation>
<violation number="5" location="server/database/schema.sql:16527">
P2: The author contract is not enforced: a memo can have both `author_user_id` and `author_agent_id` set. Add `CHECK (num_nonnulls(author_user_id, author_agent_id) <= 1)` so system memos remain allowed while authored memos have one principal.</violation>
<violation number="6" location="server/database/schema.sql:16573">
P2: Digest token usage accepts negative values, producing invalid model-usage metadata. Add nonnegative checks for both nullable token columns.</violation>
<violation number="7" location="server/database/schema.sql:16583">
P2: The period check permits lengths unrelated to `level`, so an invalid interval can become the unique day, week, or month digest. Enforce each level's canonical UTC boundary and interval shape in the database or a dedicated validation constraint.</violation>
</file>
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
This comment has been minimized.
This comment has been minimized.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011XLiZ9Pjyud5BdXQtZfFVY
…eriods Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011XLiZ9Pjyud5BdXQtZfFVY
… clear them Atlas drops the SET NULL column list, which would null project_id or organization_id on a chat or agent delete. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011XLiZ9Pjyud5BdXQtZfFVY
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011XLiZ9Pjyud5BdXQtZfFVY
This comment has been minimized.
This comment has been minimized.
|
One check is red: Generated by Claude Code |
This comment has been minimized.
This comment has been minimized.
Same change as #8306, ported so this PR's CI can go green; it no-ops once main carries it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011XLiZ9Pjyud5BdXQtZfFVY
…y TTL" Migration PRs must not carry other server changes (migration isolation check). The fix lands on main via #8306. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011XLiZ9Pjyud5BdXQtZfFVY
|
Found 1 test failure on Blacksmith runners: Failure
|
![Fix with [code]smith](https://pr-comments-assets.blacksmith.sh/codesmith/fix-with-codesmith-light-3x.png)
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.chatsgains two fields).No index on
chats.summaryyet. 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):
memory:read/memory:writestay out of every system role by default, likechat:read.The migration file and
atlas.sumare pending: they will be generated byatlas migrate diffand 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
chats.summary_redactedandchats.memory_excluded_at; memory readers only consume summaries marked redacted (from the upcoming background summary job) and skip excluded chats.memory_memosfor facts saved via theremembertool — project-scoped, optional source chat, redacted content, generated Englishtsvectorwith GIN index.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.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).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.atlas.sumare generated and committed.Written for commit 3b6d3b0. Summary will update on new commits.