Repository navigation
fix(holdings): reject broken fresh holdings with the shared holdings guard - #83
Merged
Merged
Conversation
…guard Broken holdings (renamed Weight header, header-only sheet, non-numeric weights, bad weight sum, half the rows gone) no longer overwrite the published sheet: the fund fails and keeps its previous state (ETF-H1)
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.
What
holdingsGuardblock (.claude/tools/etfs/etf-std/holdings-guard.block.ts, applied withapply-holdings-guard.ts, not hand-edited) toscripts/update-data.tsHOLDINGS_GUARD_RELAXtable next toHOLDINGS_PAGE_SIZE_FALLBACK(every published SPDR fund passes today)processFundright after a freshly downloaded holdings workbook is parsed, before any other fetch or write of the fund. The previous count is the previousmeta.jsonholdings.totalRows, relax isHOLDINGS_GUARD_RELAX[ticker] ?? HOLDINGS_GUARD_RELAX['*'] ?? []. A rejection throwsholdings guard: <reason>, so the fund goes through the existing failed path: nothing of it is written, it keeps its published files and index row and is reportedfailedWhy
Same rollout as daggerok/Schwab#71 (ETF-H1): a renamed Weight header or a header-only workbook used to be written over the published sheet (for SPY: 505 rows replaced by an empty or weightless sheet)
Checks run
bun test: 38 pass, 0 fail, exit 0; same with the config values exported as env: 38 pass, exit 0bun build --target=bun scripts/update-data.ts --outfile=/dev/null: okgit diff --check: cleantc/check.sh: esnext 0 errors, ide 51 errors, both the same as on mainparsingguard test verbatim; apipelinetest where SPY gets a renamed Weight header and then a header-only workbook: SPY's files and index row stay byte-identical and its result line saysfailed ... reason=holdings guard: .... With the throw disabled the pipeline test fails for both cases (renamed sheet written with aWeightingcolumn; header-only sheet written astotalRows: 0,status: empty)api/spdr): SPY (505 rows), SPAB (8788), SPTL, BIL pass; SPY and SPAB with a renamed weight header or no rows are rejected; GLD and GLDM (0 rows, no headers) pass; all 187 published funds over all 13 header layouts (equity, fixed income, money market MMK, futures) pass