test(producer): extract frameDirMaxIndexCache to its own module and pin cross-job isolation#381
Open
vanceingalls wants to merge 1 commit intovance/streaming-encoder-lifecycle-testsfrom
Conversation
This was referenced Apr 21, 2026
Collaborator
Author
This was referenced Apr 21, 2026
perf(producer): hdr benchmark harness — --tags filter, peak heap/RSS tracking, bench:hdr script
#382
Open
91f129b to
fe8fd9b
Compare
ae2d4a7 to
5f4e626
Compare
fe8fd9b to
253cf29
Compare
253cf29 to
faa7890
Compare
5f4e626 to
cbdf78d
Compare
faa7890 to
e4eb138
Compare
cbdf78d to
ca75d84
Compare
04f1932 to
d62dbc2
Compare
76b62e3 to
f47ae00
Compare
b171d31 to
aefd2fc
Compare
1d25da7 to
18845b3
Compare
aefd2fc to
3be90e5
Compare
18845b3 to
dcd6817
Compare
3be90e5 to
ede0291
Compare
dcd6817 to
adc776e
Compare
a4717db to
c76bbb2
Compare
143a1db to
6ece916
Compare
c76bbb2 to
1cb6854
Compare
6ece916 to
e638a99
Compare
1cb6854 to
adfcf6f
Compare
e638a99 to
5fb85c5
Compare
adfcf6f to
56d9997
Compare
5fb85c5 to
d84c3ea
Compare
56d9997 to
b8fa66f
Compare
d84c3ea to
4b68ca4
Compare
b8fa66f to
d9a7c43
Compare
4b68ca4 to
4be516a
Compare
d9a7c43 to
dc034ec
Compare
4be516a to
5a225bf
Compare
dc034ec to
39201e6
Compare
5a225bf to
c7fcca8
Compare
…in cross-job isolation
Chunk 9E. The frame-directory max-index cache lived as a private
module-scoped Map inside renderOrchestrator.ts, which made the cross-job
isolation contract added in Chunk 5B impossible to unit-test directly.
Extract the cache into packages/producer/src/services/frameDirCache.ts
behind getMaxFrameIndex / clearMaxFrameIndex / getMaxFrameIndexCacheSize
(plus a test-only __resetMaxFrameIndexCacheForTests helper). Behavior is
unchanged: callers still get the same module-scoped sharing inside a
job, and renderOrchestrator's outer finally still clears every entry it
registered so the cache cannot grow monotonically across renders.
renderOrchestrator now imports the new helpers, drops the unused
readdirSync import, and updates the inline comments to point at the new
module. Two cleanup sites that previously called
frameDirMaxIndexCache.delete now call clearMaxFrameIndex.
Add frameDirCache.test.ts (bun:test) with 11 tests covering:
- reading the max index from a populated directory
- ignoring filenames that do not match frame_NNNN.png (wrong ext,
wrong prefix, wrong case, double extension, empty index group, and
a same-named subdirectory)
- empty- and missing-directory paths returning 0 and being cached
- the intra-job invariant that subsequent readdir mutations are not
observed once a directory has been cached
- clearMaxFrameIndex forcing a re-read and returning false for paths
that were never cached
- per-directory isolation when multiple directories are registered
- the cross-job contract from Chunk 5B: the cache is empty between
well-behaved jobs, does not grow monotonically across 20 simulated
renders with 3 HDR videos each (steady-state cache size stays at 3),
and a buggy job that forgets to clear leaks exactly its own entries
rather than affecting unrelated jobs.
Made-with: Cursor
39201e6 to
cdb1508
Compare
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.

Summary
Extract the
frameDirMaxIndexCachefrom a private module-scoped Map insiderenderOrchestrator.tsinto its ownframeDirCache.tsmodule, then add a 11-test bun:test suite that pins the cross-job isolation contract added in Chunk 5B.Why
Chunk 9Eofplans/hdr-followups.md. The cache lived as a private Map insiderenderOrchestrator.ts, which made the cross-job isolation contract from Chunk 5B impossible to unit-test directly. Extracting it both makes the contract testable and reduces orchestrator complexity slightly.What changed
packages/producer/src/services/frameDirCache.tsexposesgetMaxFrameIndex/clearMaxFrameIndex/getMaxFrameIndexCacheSize(plus a test-only__resetMaxFrameIndexCacheForTestshelper). Behavior is unchanged: callers still get the same module-scoped sharing inside a job, andrenderOrchestrator's outerfinallystill clears every entry it registered so the cache cannot grow monotonically across renders.renderOrchestrator.ts: imports the new helpers, drops the unusedreaddirSyncimport, updates inline comments, and replaces twoframeDirMaxIndexCache.deletesites withclearMaxFrameIndex.frameDirCache.test.ts(bun:test, 11 tests) covering:frame_NNNN.png(wrong ext, wrong prefix, wrong case, double extension, empty index group, same-named subdirectory).0and being cached.clearMaxFrameIndexforcing a re-read; returnsfalsefor paths that were never cached.Test plan
frameDirCache.test.ts11/11 pass.finallyeviction.Stack
Chunk 9E of
plans/hdr-followups.md. Test-driven extraction; complements Chunk 5B.