Skip to content

Store a chat message with its edges or not at all: remove the fallback that stores it without them #4239

Closed

Description

@malibio

Overview

A chat message is stored together with the record of what its turn wrote, looked up and asked to delete. When that record cannot be written, the daemon stores the message without it and carries on. The decision is that a reply never exists without the record of its writes, because that record is what keeps the next turn from repeating them.

Problem Statement

In packages/daemon/src/services/chat_messages.rs, when create_node_with_relationships fails, the code logs a warning ("storing it without them, so the record of what its turn did is lost") and calls create_node_with_parent with the same params. The message then exists with no wrote, resolved-entity or delete edges. The next turn cannot see what the turn did and can repeat the writes. The decision (AI chats are core subtypes, and messages are nodes) states that the message and its edges are written in one transaction.

Proposed Solution

  • Remove the fallback: when the message cannot be stored with its edges, the store fails and the caller sees the error, so nothing is written.
  • A skipped edge whose target no longer exists stays as it is (the message is stored, and the edge is not recorded).

Documentation

None to change: the decision already states the intended behaviour. Update the node-types reference only if a type's rules change; this issue changes none.

Architecture Impact

Daemon only (chat_messages.rs). No wire type, schema or seed changes, so no shape record entry.

Acceptance Criteria

  • A message whose edges cannot be written is not stored, and the error reaches the caller
  • A skipped edge to a deleted node still stores the message
  • A test fails with the current fallback and passes without it
  • The caller of the store handles the error without losing the user's turn
  • Code passes bun run quality:fix; bun run test:changed passes

Technical Specifications

Reference Files

  • packages/daemon/src/services/chat_messages.rs - the fallback in the store function
  • packages/core/tests/it/ai_chat_message_test.rs - existing message tests

Implementation Details

Delete the fallback; do not add a retry or a flag.

Non-Goals

  • Changing which edges a message records

Activity

  1. self-assigned this
    on Nov 5, 2026
  2. mstomar125 commented on Nov 5, 2026

    @mstomar125
    Contributor

    Picking this up (sweep drain).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions