Skip to content

perf(core): tail-read the journal for the latest outcome - #157

Merged
ElbertePlinio merged 3 commits into
mainfrom
feat/147-outcome-tail-lookup
Sep 10, 2026
Merged

ElbertePlinio merged 3 commits into
mainfrom
feat/147-outcome-tail-lookup

Conversation

@ElbertePlinio

Copy link
Copy Markdown
Member

Listing artifact runs parsed every line of every lab run's actions.jsonl to
find the last outcome record. Scan the journal backwards in bounded chunks
instead, through the verified run directory, keeping the torn-tail, corrupt
journal and non-evidence rules of a full read. The write path and the journal
format are unchanged.

Run listings (artifacts list, artifact_list, the pickforge://runs resource) no longer parse each run's whole actions.jsonl to find the latest outcome. findLastActionIn walks the journal backwards in 64 KiB chunks through the run's path-confined DirHandle, reusing parseJournalSegment for validation, with a 1 MiB budget (16 times the per-record cap). A torn last line is ignored as before; a complete invalid line stops the scan and the listing reports no outcome, preserving the corrupt-journal rule; runs without evidence still return null. Documented divergence: an outcome more than 1 MiB before the end of the journal is not seen by listings (the journal stays authoritative for reports).

Validation on this branch: targeted vitest files (core evidence and outcome, mcp-server, cli commands: 370 tests), oxlint, complexity-gate, typecheck; the near-cap test asserts the lookup finishes under 500 ms.

Author: Opus worker. Reviewer: separate Astra review.

Closes #147

Listing artifact runs parsed every line of every lab run's actions.jsonl to
find the last outcome record. Scan the journal backwards in bounded chunks
instead, through the verified run directory, keeping the torn-tail, corrupt
journal and non-evidence rules of a full read. The write path and the journal
format are unchanged.

Refs #147
Open the journal with O_NONBLOCK so a FIFO left in its place cannot make the
open wait for a writer and hang every listing; the descriptor type check still
rejects it. Validate every line of each scanned window instead of returning at
the first match, so corruption before an outcome inside the byte budget keeps
reporting nothing, as a full read does. Open the run directory through a new
catalog operation that checks the root and run identities recorded at listing
time, so a directory replaced afterwards cannot attach its outcome to another
run's manifest.

Tests cover a writerless FIFO, corruption before the outcome, the byte budget
as a deterministic bound on how far the scan reads, and the outcome lookup in
the existing directory-replacement regression. The wall-clock assertion in the
near-cap test is gone in favour of that byte bound.

Refs #147
@ElbertePlinio
ElbertePlinio merged commit 1aa8a82 into main Sep 10, 2026
10 checks passed
@ElbertePlinio
ElbertePlinio deleted the feat/147-outcome-tail-lookup branch September 10, 2026 14:49
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.

artifacts: cheaper latest-outcome lookup for run listings

1 participant