test: golden valuation fixture shared with recoupable/marketing#765
test: golden valuation fixture shared with recoupable/marketing#765sweetmantech wants to merge 1 commit into
Conversation
Guards the twin implementations of the catalog valuation model (computeValuationBand here, computeCatalogValuation in marketing) against silent divergence: a byte-identical fixture JSON is committed in both repos and each repo's CI asserts its implementation reproduces every case to the cent (chat#1850). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important Review skippedReview was skipped due to path filters ⛔ Files ignored due to path filters (2)
CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
No issues found across 2 files
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Architecture diagram
sequenceDiagram
participant Test as Test Runner
participant Fixture as valuation-golden.json
participant Compute as computeValuationBand()
participant MarketFixture as Marketing Twin Fixture
participant CI as CI Pipelines
Note over Test,Compute: NEW: Cross-repo divergence guard
Test->>Fixture: Load cases from JSON
loop For each case
Test->>Compute: computeValuationBand(input)
Compute-->>Test: { valuation, catalogAgeYears }
Test->>Test: Compare catalogAgeYears
Test->>Test: Compare low, mid, high (≤0.01)
end
alt All cases match
Test-->>CI: Test passes
else Any mismatch
Test-->>CI: Test fails → divergence detected
Note over CI,MarketFixture: Must update fixture in BOTH repos
end
Note over Fixture,MarketFixture: Byte-identical (SHA-1 check)
Auto-approved: Adds golden test fixture and test for valuation band calculation; no production code changed.
Re-trigger cubic
Part of recoupable/chat#1850 (video/experience parity, item 2 — valuation derivation guard).
Why
The catalog valuation model is intentionally implemented twice:
lib/catalog/computeValuationBand.tshere (server-side valuations) andcomputeCatalogValuation.tsin recoupable/marketing (the /valuation card computes its band client-side for the progressive in-card state). The constants are mirrored by comment-discipline only — nothing fails if one side drifts. This PR adds the guard.What
lib/catalog/__tests__/fixtures/valuation-golden.json— canonical inputs → expected band cases derived independently from the published formula ($0.0035/stream, gross-ups 1.25/1.4/1.6, NLS = gross x 0.85 x 0.75, multiples 10/13/16, age = round(ms/365.25d) clamped >= 1, default 5y). Cases: the real verified 16.3B-stream catalog (age fallback), zero streams, a 10y catalog aged from its release date, and the 1y age clamp.lib/catalog/__tests__/valuationGoldenFixture.test.ts— runscomputeValuationBandagainst every case, asserting to within one cent. GREEN on first run against the existing implementation (zero divergence today).Lockstep rule: this fixture's twin lives at
marketing/lib/valuation/__tests__/fixtures/valuation-golden.jsonand the two files must stay byte-identical (SHA-1a2c9737f167a25e3589b5d53fa4bf832d4f1e0bd). Any model change must update the fixture in BOTH repos in the same coordinated change, or one repo's CI goes red — which is the point.Follow-up (out of scope): extract a true shared package so the formula exists once; until then this fixture is the divergence tripwire.
Verification
pnpm test— 714 files / 3,944 tests pass (4 new)pnpm exec tsc --noEmit— 200 errors, identical to the pre-existing main baseline (none in touched files)Siblings
Note: branch is
tests/valuation-golden-fixture(nottest/...) because this repo's long-livedtestbranch occupies that ref namespace.🤖 Generated with Claude Code
Summary by cubic
Adds a shared “golden” valuation-band fixture and test to guard against drift between the server
computeValuationBandand marketing’s client implementation. The byte-identical JSON is committed in both repos and CI asserts each case to the cent.Written for commit 69ac021. Summary will update on new commits.