fix(backend): restore the declared wire types in database.ts (closes #251) - #265
Open
dchaudhari7177 wants to merge 1 commit into
Open
fix(backend): restore the declared wire types in database.ts (closes #251)#265dchaudhari7177 wants to merge 1 commit into
dchaudhari7177 wants to merge 1 commit into
Conversation
…chutera#251) The two forEach callbacks in fetchAndAssemble re-annotated their elements as any, discarding the ApiDailyProgressResponse / ApiNestResponse types the same function had just declared. They were the only two ": any" in backend/src. That is the exact hole the chapter-11 "reading typo'd field names" incident went through: p.progess_id and p.hateched read undefined for the lifetime of the bug because nothing typed or tested the read. backend/tsconfig.json sets "strict": true, so deleting the annotations is enough for TS to infer DailyProgress and NestData; tsc --noEmit passes. Add the contract test that lesson prescribed and that was never written. backend/tests/database-progress-contract.test.ts stubs duckdb-service with known rows and asserts every field by value -- a typo'd read yields undefined, which a shape-only assertion accepts. It also pins the dailyProgress[length-1]-is-latest invariant the totalHatches roll-up depends on, per-nest grouping, and the empty-progress case. Re-introducing the hateched typo fails three of its six cases, so the guard is real rather than nominal. Chapter 11's entry is updated to record the remedy as done, and to note that CI still runs no tsc for backend/ (schutera#208), so the build-time half is only enforced locally. Scope: QUAL-3 only. The ModuleId canonicalisation divergence (ARCH-3) in the same issue is a separate change across contracts and both Python copies, and is not touched here. Verified: backend tsc --noEmit clean, vitest 298 passed across 32 files, make check-citations 7 OK / 0 problems.
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.
Scope: QUAL-3 only. The ModuleId canonicalisation divergence (ARCH-3) in the same issue spans
contractsand both Python copies and is deliberately not touched here.The defect
fetchAndAssembledeclaredApiDailyProgressResponse/ApiNestResponseand then threw them away:Those were the only two
: anyinbackend/src. Removing the annotations is sufficient —backend/tsconfig.jsonsets"strict": true, so TS infersDailyProgress/NestData.tsc --noEmitpasses.The contract test chapter 11 asked for
The chapter-11 entry "Backend
database.tsreading typod field names" prescribes "Add a contract test that reads a known row and checks the field values". That was never done.backend/tests/database-progress-contract.test.tsdoes it — 6 cases, stubbing duckdb-service with known rows and asserting by value, because a typod read yieldsundefinedand a shape-only assertion accepts that.It also pins three things the roll-up quietly depends on:
dailyProgress[length-1]-is-latest invariant behindtotalHatches(reading the wrong end gives1instead of7)[], notundefinedThe guard is real, not nominal. I re-introduced the historical
hatechedtypo and confirmed it fails 3 of the 6 cases, then reverted.Docs
Chapter 11s entry now records the remedy as Done, and notes what is Still open:
backend/has no eslint and CI runs notsc(#208), so the build-time half of the guard only fires when someone runs a local build.Verification
tsc --noEmit(backend)vitest run(backend)make check-citationsOne environment note worth having
scripts/check-duckdb-bind-claims.shpicks its interpreter withfor cand in python3 python py. On Windows Git Bashpython3does exist — as the Microsoft Store alias stub, which prints "Python was not found" and exits non-zero. The loop takes it on the first iteration, so the script fails on a machine that has a perfectly goodpython. The comment above the loop assumes the opposite ("neverpython3").The check passes once a real
python3is ahead onPATH(verified: "dev is LAN-reachable, prod is loopback-only"). Not fixed here since it is unrelated to this issue — happy to open a separate one, or addpy -3/ an executable probe to the loop if you would like it in this PR.