Skip to content

feat(events): keep the event stream across restarts, and berth why ID - #330

Merged
T-Crypt merged 1 commit into
nextfrom
T-Crypt/decision-log
Nov 14, 2026
Merged

T-Crypt merged 1 commit into
nextfrom
T-Crypt/decision-log

Conversation

@T-Crypt

@T-Crypt T-Crypt commented Nov 14, 2026

Copy link
Copy Markdown
Owner

What changes for users

  • berth why ID answers "why did my engine wait, get drained or get refused" in one command. It prints every
    event berthd kept about the lease, oldest first, in plain words. berth why ENGINE reads that engine's newest
    lease. A lease that still holds or waits ends with where it stands now. A lease a restart cut off names the
    lease its engine re-attached as.
  • The event stream survives a restart. berthd appends each event to events.jsonl in the state directory
    (--events, "" keeps the old memory-only ring), reads the last 1000 back at start, and goes on numbering
    after them. Lease numbers go on too, so a lease ID names one lease across deploys (before, every restart
    started again at -1). Each start is a node.started event that names the version.

This is the "persisted decision log and berth why" step of the Berth Next plan. The broker's existing reasons
are the decisions; this keeps them and reads them back per lease.

Proof

  • internal/eventlog: a restart keeps the events, Last and LastLease; a torn last line is skipped and the next
    event starts its own line; the file rotates at its cap and the rotated events still load; a missing state
    directory is created.
  • internal/cli: whyOf over a literal replay of the 2026-11-12 strata drain, including a restart and a
    re-attach; berth why against a real socket (holder story with the drain reason, a waiter's JSON with
    now.state = waiting, an unknown name refused).
  • Live, on the built binary with a throwaway berthd: a lease, a berthd stop mid-run, a second berthd, a second
    lease. berth events showed seq 1-10 with two node.started lines, and the second lease was demo-2, not a
    second demo-1. That run found the missing-directory bug, which now has its own test.
  • proof.sh full: build, gofmt, vet, tests, Windows build and vet, golangci-lint.

berthd appends each event to events.jsonl in the state directory and reads
the last 1000 back at start, so sequence numbers and lease numbers go on
after a restart and each start is a node.started event. berth why ID|ENGINE
prints one lease's events as a story: the waits, the grant, each drain and
who it was for, the release, and the restarts it lived through.
@T-Crypt
T-Crypt merged commit 53370a0 into next Nov 14, 2026
4 checks passed
@T-Crypt
T-Crypt deleted the T-Crypt/decision-log branch November 14, 2026 22:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant