The event log promises duplicate-envelope rejection for (session_id, message_id), but SQLite treats NULL values in a unique constraint as distinct. The schema at lib/src/main/resources/arcp/store/schema.sql:22 declares UNIQUE (session_id, message_id), and EventLog.bindEnvelope at lib/src/main/kotlin/dev/arcp/store/EventLog.kt:71 writes null for envelopes that do not yet have a session id. That means duplicate pre-session envelopes such as repeated session.open messages with the same MessageId can be appended multiple times, contradicting the KDoc at lib/src/main/kotlin/dev/arcp/store/EventLog.kt:25 and the schema comment at lib/src/main/resources/arcp/store/schema.sql:3. The existing duplicate test at lib/src/test/kotlin/dev/arcp/store/EventLogTest.kt:35 only covers non-null session ids.
Fix prompt: Decide how null-session envelopes should be scoped, then encode that decision in the schema and tests. The narrow fix is a unique index over COALESCE(session_id, '') and message_id, or storing a sentinel session id for pre-session envelopes before insertion. Add a regression test that appends two envelopes with the same MessageId and sessionId = null and expects ARCPException.AlreadyExists, and keep the existing non-null session duplicate test.
The event log promises duplicate-envelope rejection for
(session_id, message_id), but SQLite treatsNULLvalues in a unique constraint as distinct. The schema atlib/src/main/resources/arcp/store/schema.sql:22declaresUNIQUE (session_id, message_id), andEventLog.bindEnvelopeatlib/src/main/kotlin/dev/arcp/store/EventLog.kt:71writesnullfor envelopes that do not yet have a session id. That means duplicate pre-session envelopes such as repeatedsession.openmessages with the sameMessageIdcan be appended multiple times, contradicting the KDoc atlib/src/main/kotlin/dev/arcp/store/EventLog.kt:25and the schema comment atlib/src/main/resources/arcp/store/schema.sql:3. The existing duplicate test atlib/src/test/kotlin/dev/arcp/store/EventLogTest.kt:35only covers non-null session ids.Fix prompt: Decide how null-session envelopes should be scoped, then encode that decision in the schema and tests. The narrow fix is a unique index over
COALESCE(session_id, '')andmessage_id, or storing a sentinel session id for pre-session envelopes before insertion. Add a regression test that appends two envelopes with the sameMessageIdandsessionId = nulland expectsARCPException.AlreadyExists, and keep the existing non-null session duplicate test.