fix(eval): restore SEC_UNIT_TERMS_REF override with fail-fast on missing path - #212
Merged
Merged
Conversation
…ing path PR #211 removed the SEC_UNIT_TERMS_REF env override from embarcUnitTermsReference.ts when the module was refactored to use resolveAsset() and fileURLToPath. Downstream packages (embarc-data) rely on this env var to point at a vendored copy of the reference CSV, since the published @workglow/sec tarball does not ship mock_data/. Restore the override and strengthen its semantics: when SEC_UNIT_TERMS_REF is set, the loader honors the path strictly — a missing file throws naming the env var and the path, instead of silently falling through to the package-relative default. A typo in a downstream caller's env cannot masquerade as "fixture missing, using default" anymore. Also: - add existsSync to the node:fs imports; - restore the explanatory docstring describing the override + fail-fast; - export _resetEmbarcUnitTermsCacheForTesting() so tests exercise the env-override branches without vi.resetModules(); - add a three-case describe block (env set + exists, env set + missing, env unset) with beforeEach/afterEach env restore + cache reset; - document SEC_UNIT_TERMS_REF next to SEC_S1_MOCK_DIR in CLAUDE.md. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
sroussey
changed the base branch from
claude/beautiful-archimedes-o87xem
to
main
July 24, 2026 15:02
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.
Finding
PR #211 (this branch's parent) silently removed the
SEC_UNIT_TERMS_REFenv override fromsrc/eval/embarcUnitTermsReference.tswhen the module was refactored to useresolveAsset()andfileURLToPath. The pre-#211resolveReferencePath()began with:That override is the seam downstream packages depend on — the published
@workglow/sectarball does not shipmock_data/, soembarc-data(and any future consumer ofloadEmbarcUnitTermsReference()) pointsSEC_UNIT_TERMS_REFat its own vendored copy of the CSV. Without it,loadEmbarcUnitTermsReference()throws at any consumer that doesn't have the source-tree layout on disk.Fix
process.env.SEC_UNIT_TERMS_REFcheck inresolveReferencePath().existsSyncto thenode:fsimport for the file-exists check._resetEmbarcUnitTermsCacheForTesting()so tests can force reload withoutvi.resetModules().src/eval/embarcUnitTermsReference.test.ts): a newdescribe("SEC_UNIT_TERMS_REF override")block with three cases, wrappingprocess.env.SEC_UNIT_TERMS_REFinbeforeEach/afterEachrestore and calling the reset helper:/SEC_UNIT_TERMS_REF.*does not exist/;> 1200rows, mirroring the existing baseline test).SEC_UNIT_TERMS_REFbullet next toSEC_S1_MOCK_DIRinCLAUDE.md.Verification
bun x vitest run src/eval/embarcUnitTermsReference.test.ts→ 10 passed (7 existing + 3 new).bun x tsc --noEmit -p tsconfig.json→ clean.Only
src/eval/embarcUnitTermsReference.ts, its test file, and theCLAUDE.mdbullet are touched. No unrelated changes; no version bump.Stacking
This PR stacks on top of #211 (base =
claude/beautiful-archimedes-o87xem). Merge #211 first; this PR should then rebase cleanly ontomain.Generated by Claude Code