Repository navigation
Closed
Description
Overview
Store AI-chat messages as ai-chat-message child nodes of ai-chat-native, instead of a nested messages[] property, with real edges for what each message wrote, resolved or proposed to delete (ADR-088 §3).
Problem Statement
- Rewrites and buffering. Messages live in one growing
messages[]property on the chat node (ADR-028). Every append rewrites the whole conversation, so ADR-028 adds write buffering, makes the frontend the source of truth during a chat, and sets a soft cap of 500 messages. - Mention edges are never derived. Message text is inside a property, so
sync_mentions(packages/core/src/services/node_service/crud.rs) never sees it. - The schema describes a design that was never built. The
messages[]item declaration describes a shape (tool_callrole,args,status, …) that was never built. The real shape (completedWrites,resolvedEntities,pendingDeletions,question/options,outcome) is undeclared and camelCase.
Proposed Solution
- A new core type
ai-chat-message: text incontent, plusrole(user | assistant | system),timestamp,reasoning(optional),outcome(acted | clarified | replied, assistant only) andoptions(a string list; a clarifying question is the message'scontent). - Structural rules (ADR-089):
parent: must_have_parent_of [ai-chat-native, ai-chat-acp],children: none, ordered byhas_childorder. - Edges declared on the message schema:
wrote/written_by, with edge fieldstool,summary,canonical_args;resolved/resolved_by, with edge fieldtool;pending_delete/pending_delete_of, with edge fieldversion. The descendant count is computed when shown; confirming or declining removes the edge.
"What a chat created" is a query over its messages'wroteedges.
- Mentions: a message's content goes through
sync_mentions, so a mention is a message → nodementionsedge. - Participation: not embedded; excluded from default queries, search, counts and the
@picker; no inbound references. - Frontend:
- The chat viewer loads its message children.
- A message is never shown standalone: backlinks, opening a message id, and a chat row in a page outline redirect to the chat, scrolled to the message.
- Indent, outdent and drag aren't offered inside a chat.
- Remove ADR-028's buffering, frontend-as-source-of-truth and soft cap.
- The agent loop and the cross-turn duplicate guard read and write messages and their edges.
- No migration: reset the database.
Architecture Impact
Implements decisions/088-ai-chat-subtypes-and-message-nodes.md §3 (nodespace-docs), which supersedes ADR-028. ADR-085's has_child-ancestry rule already keeps message nodes and their edges unsynced in Pro. Update architecture/ai-chat-node.md and components/typed-relationships.md in the same PR.
Acceptance Criteria
-
ai-chat-messageis a core type with the fields above;ai-chat-nativehas nomessages[](tests) - A message can't be created without an
ai-chat-nativeparent, can't be moved out of its chat, and can't have children (tests) -
wrote,resolvedandpending_deleteedges replacecompletedWrites,resolvedEntitiesandpendingDeletions; the cross-turn duplicate guard readscanonical_argsfromwroteedges (tests) - A
nodespace://link in a message creates a message → nodementionsedge (test) - Messages are absent from search, default queries, counts and the
@picker (tests) - The frontend redirects to the chat for backlinks and message ids; a chat row in an outline never unfolds messages (frontend tests)
- ADR-028's write buffering, soft cap and frontend-as-truth code are removed
- Prompt golden regenerated if the model-facing text changes; diff reviewed
- Follows
development/node-type-sequence.md; thenode-types.mdai-chat-messageandai-chat-nativesheets updated in the same PR -
bun run test:changedpasses;bun run quality:fixclean -
ai-chat.created_nodesis removed; "what this chat created" is a query over its messages'wroteedges (test)
Technical Specifications
Reference Files
packages/core/src/models/core_schemas.rs,packages/nodespace-types/src/ai_chat.rspackages/core/src/services/node_service/crud.rs(sync_mentions)packages/agent/src/local_agent/agent_loop.rs(message persistence, completed writes, the duplicate guard)packages/daemon/src/services/local_agent_service.rspackages/desktop-app/src/lib/components/viewers/ai-chat-node-viewer.svelte,packages/desktop-app/src/lib/stores/ai-chats.svelte.ts,packages/desktop-app/src/lib/services/shared-node-store.svelte.ts
Dependencies
- Split ai-chat into an abstract base with ai-chat-native and ai-chat-pty subtypes #3446 (AI-chat subtypes)
- Make one governance check decide whether an archived node participates anywhere #3443 (participation rules)
- Declare and enforce children and parent rules per node type #3447 (structural rules)
Non-Goals
- ACP messages
- Embedding chat summaries
Activity
malibio commentedon Oct 2, 2026
Baseline — Frontend: 303 test files passed, 5559 tests passed
Store AI chat messages as ai-chat-message child nodes with real edges (…
Store AI chat messages as ai-chat-message child nodes with real edges (…
Store AI chat messages as ai-chat-message child nodes with real edges (…