Skip to content

Delivery can attach another Squadron's message references #421

Closed

Description

@Jacksondr5

Problem

When a delivery to a local agent is sent, DeliveryWorker re-reads the message's message.sent event to recover its canonical references (attachments). It looks the event up by sequence number alone:

// apps/server/src/j5/a2a/DeliveryWorker.ts (delivery to a local agent)
SELECT kind, payload FROM j5_a2a_comm_event WHERE seq = ${row.sent_seq}

seq is numbered per ledger: the table's key is (squadron_id, seq), and every Squadron counts from 1. On a server with more than one Squadron, the query can match another Squadron's event at the same number.

  • If that event is a message.sent: the delivery carries the other message's attachments, or loses its own.
  • If it is another kind: the attachments are silently dropped.

Which row SQLite returns is unspecified.

A real install with three Squadrons has overlapping sequence ranges (1–84 exist in two of them), so this can happen today.

Fix

Scope the lookup to the delivery's own ledger (squadron_id = row.squadron_id AND seq = row.sent_seq). That pair is the table's primary key. Add a focused test with two ledgers whose message.sent events share a seq and carry different attachments, and assert that each delivery gets its own.

Introduced in #176 (2026-09-30).

🤖 Generated with Claude Code

Activity

  1. added
    bug
    on Oct 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions