Repository navigation
Serve a job's journal from its newest entries (#51) - #63
Merged
Merged
Conversation
GET /v1/jobs/{job}/events and GET /v1/events accept tail=true (the newest
page) and before=<sequence> (the page immediately before it), answering
the entries in the journal's order with more for older entries and a
before cursor for the next older page. Requests that send neither
parameter are answered byte for byte as before. GET /v1/status lists the
capability journal-backward.
Signed-off-by: kikashy <35789537+kikashy@users.noreply.github.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Signed-off-by: kikashy <35789537+kikashy@users.noreply.github.com>
This was referenced Oct 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #51
What changes for a reader
GET /v1/jobs/{job}/eventsandGET /v1/eventstake two new query parameters.tail=trueanswers the newest page (the last up to 50 entries).before=<sequence>answers the up to 50 entries immediately before that sequence. Entries stay in the journal's order within a page,journalBeganis answered as always, andGET /v1/statuslists the capabilityjournal-backwardto test first. A reader that wants the latest activity no longer reads the whole journal.Design
more(older entries exist before the page), a new memberbefore(the sequence of the page's first entry: the cursor for the next older page) andnextas today (the page's last entry, to turn around and follow the journal forward). An empty backward page hasmorefalse,beforeas given (0 fortail) andnext0.tail=truewithbefore, either withafter, a repeated parameter, or atailother thantrue/falseis 400 (invalid_paging,invalid_tailorinvalid_cursor) with one sentence.tail=falseis the same as notail.before=0answers an empty page; abeforebeyond the end answers the newest page.beforemember.openapi.json(parameters,beforemember,more/nextdescriptions, the capability on/status),docs/design/activity-journal.md(a paragraph on reading from the end),docs/releases/v0.8.0.md(one section).Tests
internal/runner/events_backward_test.go, on a journal of 2,100 entries written through the journal's own writer:TestOlderClientsGetTheAnswersTheyAlwaysGot);openapi.json(TestTheNewestPageIsOneRequest);morefalse exactly on the last page, on both routes (TestWalkingBackReachesTheFirstEntryOnceEach);nextreaches the end without a gap (TestForwardPagingContinuesFromABackwardPage);TestBackwardPagingBounds); whole-page journals (TestAJournalOfWholePagesEndsOnTheLastPage); the capability (TestTheStatusListsTheBackwardCapability).Mutation tally
Seven mutants in a scratch copy, all compiled, all caught: overlap at the page boundary (
<=) by the walk and bounds tests; a skipped entry and an overlapping cursor by the walk and newest-page tests; a short page by the newest-page and bounds tests; a wrongnextby the newest-page and forward-continuation tests;moretrue on a whole last page byTestAJournalOfWholePagesEndsOnTheLastPage(the first version of the tests missed it, so that test was added); the droppedbefore+afterandtail+afterconflicts by the bounds test.Checks
gofmt -l .: clean.go vet ./...: clean.Not in this PR
Desk's side (desk #235), and any change to the journal's contents, order or storage.
Review
A read-only paging change with a golden test for the old answers; no review round.
🤖 Generated with Claude Code