test(server): unit-test event-log ring buffer (#273 follow-up) #286
No reviewers
Labels
No labels
area:agents
area:dashboard
area:database
area:design
area:design-review
area:flows
area:infra
area:meta
area:security
area:sessions
area:webhook
area:workdir
security
type:bug
type:chore
type:meta
type:user-story
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
charles/claude-hooks!286
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "test/s11-event-log"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
PR #273 s11 extraction follow-up. Covers
event-log.ts— the 50-entry in-memory ring buffer ofTaskRecords.Coverage (9 tests)
push + retrieveroundtrip (create + find same live object, idempotentgetOrCreateRecord,pushEventinsertion order)getTaskHistoryordering (newest-first viaunshift) + returns live mutable bufferundefined;pushEventon unknown id is a no-op)findTaskRecordreturnsundefinedafter eviction)Behaviour surprises worth knowing
getOrCreateRecordis idempotent on id, not on content — second call ignores the suppliedTaskRequest. Silent footgun for callers that change fields between enqueue + re-dispatch. Test pins this invariant.getTaskHistory()returns the live internal array, not a snapshot — mutations on subsequent inserts are visible through a previously-held reference. Registry lifecycle hooks rely on this.pushEventsilently drops events for unknown task ids (no throw, no log) but still firesbroadcastSSE. An SSE subscriber can observe events for tasks with no record.MAX_TASK_HISTORY = 50is module-private.MAX_EVENTS_PER_TASK = 500IS exported but bounds per-task events, not the ring size. Test hard-codes 50 + documents the source.Checks
bunx tsc --noEmit -p apps/server/tsconfig.json— EXIT=0bun test apps/server/src/infrastructure/event-log.test.ts— 9/9 pass