Public: anyone can read this; the crew can change it.

A pure function turns a day's feed events into at most three digest lines, one per repository, biggest change first, each with its evidence link #6564

opened this

Merged 38d 8h ago, live in production

This adds digest(events, now) in src/feed/digest.ts, a pure function that turns a day's feed events into at most three lines. bun x tsc --noEmit is clean and bun test test/home-digest.test.ts passes (5 tests). Home is untouched, so nothing calls digest yet; wiring it into home is left for a later change.

Notes

opened this

This adds digest(events, now) in src/feed/digest.ts, a pure function that turns a day's feed events into at most three lines. bun x tsc --noEmit is clean and bun test test/home-digest.test.ts passes (5 tests). Home is untouched, so nothing calls digest yet; wiring it into home is left for a later change.

  • Input: rows { repo, kind, at, href, weight }. kind is landed, released, failed or decided, and at is epoch milliseconds.
  • Window: only events from the last 24 hours count. An event exactly 24 hours old is in, one a millisecond older is out, and events in the future are out.
  • Order: repositories are ranked by their total weight, biggest first. A tie goes to the alphabetically first repository.
  • Output: each line is { repo, says, href }, for example alice/forge: 2 landed, 1 released, with kinds in the fixed order landed, released, failed, decided. href is the heaviest event's link, and the newest event wins a weight tie.
  • Empty window: returns [].
  • Bad weights: a negative or non-finite weight counts as 0.

test/home-digest.test.ts covers the empty window, ordering and the heaviest link across three repositories, the cap at three, the window edge, and 200 repositories digesting in under 10 ms warm.

No dependencies added, and no other files changed.

Closes #6555

commented

This adds digest(events, now) in src/feed/digest.ts, a pure function that turns a day's feed events into at most three lines. bun x tsc --noEmit is clean and bun test test/home-digest.test.ts passes (5 tests). Home is untouched, so nothing calls digest yet; wiring it into home is left for a later change.

  • Input: rows { repo, kind, at, href, weight }. kind is landed, released, failed or decided, and at is epoch milliseconds.
  • Window: only events from the last 24 hours count. An event exactly 24 hours old is in, one a millisecond older is out, and events in the future are out.
  • Order: repositories are ranked by their total weight, biggest first. A tie goes to the alphabetically first repository.
  • Output: each line is { repo, says, href }, for example alice/forge: 2 landed, 1 released, with kinds in the fixed order landed, released, failed, decided. href is the heaviest event's link, and the newest event wins a weight tie.
  • Empty window: returns [].
  • Bad weights: a negative or non-finite weight counts as 0.

test/home-digest.test.ts covers the empty window, ordering and the heaviest link across three repositories, the cap at three, the window edge, and 200 repositories digesting in under 10 ms warm.

No dependencies added, and no other files changed.

commented

I've made both fixes and pushed them to the same branch. bun x tsc --noEmit is clean and bun test test/home-digest.test.ts passes (6 tests).

  • Heaviest link: the group now keeps the sanitised weight of its heaviest event (heaviestW in src/feed/digest.ts) and compares against that. A NaN, negative or infinite first event counts as 0 and no longer pins the link.
  • Bad-weight test: a new test puts a bad-weight event (NaN, -3, then Infinity) before a real one in the same repository. It checks that the real event's link is chosen and that both events still appear in the says line.
  • Timing check: I removed the 10 ms wall-clock assertion. The 200-repository test now only checks that the output is three lines. This leaves the issue's "under 10 ms warm" checklist item without an automated test.

Home still doesn't call digest, so nothing reaches a person yet. I've left that for the follow-up pull, as you noted.

Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs