test(core): drive BidLabCore to 100% coverage of reachable code#9
Merged
Conversation
byPath looked values back up in per-key dictionaries after building them, leaving four nil-coalescing fallbacks that can never fire (an id is in `order` only because its track was seen, which sets every dict). Collapse the five dictionaries into one ordered accumulator so the lookups are total. PacedFlight computed winRate with `intervalOpportunities > 0 ? ... : 0`, but intervalOpportunities is `max(1, ...)`, so that guard is dead; divide directly. Behavior is unchanged; both simplify the code and remove unreachable branches. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Add boundary and parser coverage to the known-answer suite, taking BidLabCore from 79% to 99.5% region / 99.3% function / 99.9% line coverage (100% of all reachable code). New checks cover computed getters and their divide-by-zero branches; a boundary suite (EdgeCoverageTests) for every guard return and ternary fallback across Pricing, Scoring, Auction, ReachFrequency, Systems, Analytics, Attribution, BudgetAllocation, Probability (p==0/1, sd==0, quantile tails), Statistics, and Credential; and a parser suite (ParserCoverageTests) exercising Cohort transcripts, Exam parsing/grading, and the full LessonParser directive grammar. The suite is now 5,271 checks, all passing. The 4 remaining uncovered regions are unreachable defensive guards, documented in docs/COVERAGE.md. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Scripts/coverage.sh instruments the swiftc test build with llvm coverage and emits a per-file BidLabCore report (SwiftPM, and so swift test --enable-code- coverage, is broken on this machine). docs/COVERAGE.md records the result and the rationale for the unreachable defensive branches. Ignore the .build-cov dir. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Adds a `check` mode to Scripts/coverage.sh that parses the llvm-cov TOTAL row and fails if missed regions/functions/lines exceed the documented unreachable baseline (4/2/2 — the defensive guards in docs/COVERAGE.md). Any newly uncovered code raises a missed count and fails the build. Wired into ci.yml as a step after the known- answer suite, and documented in COVERAGE.md. A literal 100% gate is impossible without deleting safe defensive code (llvm-cov has no per-line ignore), so this guards against regression instead. Verified locally: passes at the current baseline, fails on a simulated 9/5/7 regression. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
scumunna
pushed a commit
that referenced
this pull request
Jun 23, 2026
…0 web) #9 raised the native suite to 5,271 checks and #10 the web suite to 180; update the README and ACCEPTANCE.md to match, and add the CI coverage-gate story (web 100%, native 100% of reachable code). ACCEPTANCE.md's web engine-suite row now includes the added boundary tests (47 -> 80). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Native app first: instruments the Swift engine and adds tests until
BidLabCoreis at 100% line/function/region coverage of all reachable code.How coverage is measured
SwiftPM is broken on this machine, so
swift test --enable-code-coveragecan't run. NewScripts/coverage.shinstruments the existingswiftctest build (-profile-generate -profile-coverage-mapping), force-loads the archive (so every object's map is included), runs the suite, and emits anllvm-covreport scoped toSources/BidLabCore.Result
se>0underbaselineRate∈(0,1); acolumnIndexalias guard; twoCredential?? fallbacksthat are non-nil for valid input). They are kept and documented indocs/COVERAGE.mdrather than removed, force-unwrapped, or covered with a contrived test.What's in here
refactor(core)— collapseCohort.byPath's five lookup dictionaries into one ordered accumulator (removes four dead fallbacks); drop a deadwinRateguard inPacedFlight(intervalOpportunitiesismax(1, ...)). Behavior unchanged.test(core)— getter/divide-by-zero tests across the domain suites, a boundary suite (EdgeCoverageTests), and a parser suite (ParserCoverageTests) covering Cohort transcripts, Exam parsing/grading, and the full LessonParser directive grammar.chore—Scripts/coverage.sh,docs/COVERAGE.md, gitignore the.build-covartifacts.Scope notes
Sources/BidLab) is not unit-coverable with this toolchain (no XCTest UI runner); the pure engine is where the logic and the coverage bar live.🤖 Generated with Claude Code