Repository navigation
perf(workflows): append replay journal incrementally - #318
Merged
tt-a1i merged 1 commit intoAug 31, 2026
Merged
Conversation
tt-a1i
approved these changes
Aug 31, 2026
tt-a1i
left a comment
Collaborator
There was a problem hiding this comment.
Reviewed exact head 1e481d0. No blocking findings. The incremental accumulator avoids re-encoding retained entries while preserving canonical v2 JSON, oldest-first retention, replay ordering, and atomic persistence. Independent validation: focused 26/26, bun run check, full Node 1076 passed with one platform skip, Vitest 30/30; 6000 differential append checks matched the reference algorithm, and a 1024-append probe confirmed each payload was encoded once. Current Node 22.19.0, Node 24, and Windows CI passed. Non-blocking follow-ups: retain the encode-count probe as a regression test and clarify that benchmark flushMs measures JSON assembly rather than disk persistence.
agnitum2009
pushed a commit
to agnitum2009/openpi
that referenced
this pull request
Sep 3, 2026
Co-authored-by: testikun <[email protected]>
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.
Problem
Closes #184.
Workflow replay journals currently re-serialize the complete pretty-printed journal while trimming old entries. Near the 2 MiB cap, repeated
slice(1)and full JSON size recalculation make append/eviction cost grow close to quadratically for large runs.Value
Large read-only Workflows can retain hundreds of replayable agent results. Incremental accounting keeps journal admission and oldest-entry eviction proportional to the number of new entries, while preserving the exact replay artifact and its atomic write path.
Approach
WorkflowJournalAccumulatorwith cached per-entry JSON fragments, UTF-8 byte accounting, and a head-cursor queue.boundedJournal()as a compatibility adapter for array callers.benchmark:workflow-journalscript for 128/512/1024 entries.Validation
bun run check— passed (config contract, discipline, format, lint, typecheck).bun run testunder Node 24 — 1,076 passed, 1 skipped; Vitest 30/30 passed.node --experimental-strip-types --expose-gc benchmarks/workflow-journal.ts:Impact
journal.jsonschema and canonical pretty JSON; writes remain atomic.