B2: Nest message log + replay #9

Closed
opened 2026-10-28 05:27:25 +00:00 by jacisjake · 0 comments
jacisjake commented 2026-10-28 05:27:25 +00:00 (Migrated from github.com)

Epic: #2. Depends on: #8

Goal

An append-only message log per nest with durable storage and ordered replay, mirroring how Hub replays list history. This is the data structure the conversation runs on.

Context a stranger needs

Follow NestStore.save() (nests.go:133, atomic tmp+rename) for persistence and Hub.listStream/Subscribe (hub.go:17, hub.go:121) for the in-memory ordered history + numbered replay. IDs should be monotonically increasing per nest so Last-Event-ID works.

Acceptance criteria — falsifiable tests

  1. TestMessageLogAppendOrder — Given a fresh log, when appending 3 messages, then reading returns them in append order with ids 1,2,3. Red now (type doesn't exist), green after.
  2. TestMessageLogReplayFrom — Given 5 appended, when replaying after id 2, then returns messages 3,4,5 only. Red now, green after.
  3. TestMessageLogPersists — Given messages appended, when the store reloads from its file path, then all messages are present (round-trip through the on-disk format). Red now, green after.

Test command

go test -race -run 'TestMessageLog' ./...

Blockers / unknowns

Storage location: extend .crows/ (add messages.jsonl or per-nest file). Decide during implementation; must survive server restart.

Epic: #2. Depends on: #8 ## Goal An append-only message log per nest with durable storage and ordered replay, mirroring how `Hub` replays list history. This is the data structure the conversation runs on. ## Context a stranger needs Follow `NestStore.save()` (`nests.go:133`, atomic tmp+rename) for persistence and `Hub.listStream`/`Subscribe` (`hub.go:17`, `hub.go:121`) for the in-memory ordered history + numbered replay. IDs should be monotonically increasing per nest so `Last-Event-ID` works. ## Acceptance criteria — falsifiable tests 1. `TestMessageLogAppendOrder` — Given a fresh log, when appending 3 messages, then reading returns them in append order with ids 1,2,3. Red now (type doesn't exist), green after. 2. `TestMessageLogReplayFrom` — Given 5 appended, when replaying after id 2, then returns messages 3,4,5 only. Red now, green after. 3. `TestMessageLogPersists` — Given messages appended, when the store reloads from its file path, then all messages are present (round-trip through the on-disk format). Red now, green after. ## Test command `go test -race -run 'TestMessageLog' ./...` ## Blockers / unknowns Storage location: extend `.crows/` (add `messages.jsonl` or per-nest file). Decide during implementation; must survive server restart.
Sign in to join this conversation.