Consume typed daily Product Facts contract - #3
Conversation
📝 WalkthroughWalkthroughThe change reconciles public cookbook claims with canonical product facts. It narrows ChangesPublic claim validation
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant SmokeWorkflow
participant ClaimChecker
participant ProductFacts
participant Repository
SmokeWorkflow->>ClaimChecker: Run claim validation
ClaimChecker->>ProductFacts: Load canonical facts
ProductFacts-->>ClaimChecker: Return contract data
ClaimChecker->>Repository: Scan claims and recipe values
Repository-->>ClaimChecker: Return repository content
ClaimChecker-->>SmokeWorkflow: Return validation status
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 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 |
|
Hardening proof for commit
Verification:
No deployment or customer action was performed. |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@scripts/check_public_claims.py`:
- Around line 307-324: The _check_watchlist_math function currently validates
only the separate-call count; update its claim parsing to capture the batch-call
value from WATCHLIST_MATH_PATTERN and verify it equals 24 * 30. Extend the
mismatch error to report an incorrect batch total, and add a regression test
that changes the claimed 720 batch calls and confirms validation fails.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: e434bdd3-21e5-4d1c-b661-dd68d731c7e4
📒 Files selected for processing (10)
.github/workflows/smoke.ymlREADME.mdrecipes/01_first_price_no_key.pyrecipes/02_backtest_without_lookahead.pyrecipes/08_batch_watchlist_dataframe.pyrecipes/10_resilient_client.pyscripts/check_public_claims.pytests/fixtures/product-facts-50.jsontests/fixtures/product-facts-51.jsontests/test_public_claims.py
| def _check_watchlist_math(root: Path, errors: list[str]) -> None: | ||
| relative_path = Path("recipes/08_batch_watchlist_dataframe.py") | ||
| recipe = _read(root / relative_path) | ||
| actual_codes = _watchlist_size(recipe, relative_path) | ||
| match = WATCHLIST_MATH_PATTERN.search(recipe) | ||
| if not match: | ||
| errors.append(f"{relative_path}: missing checkable 30-day watchlist math claim") | ||
| return | ||
|
|
||
| claimed_codes = _parse_count(match.group("codes")) | ||
| claimed_calls = _parse_count(match.group("calls")) | ||
| expected_calls = actual_codes * 24 * 30 | ||
| if claimed_codes != actual_codes or claimed_calls != expected_calls: | ||
| errors.append( | ||
| f"{relative_path}: watchlist math claims {claimed_codes} codes and " | ||
| f"{claimed_calls:,} calls; literal WATCHLIST has {actual_codes} codes and " | ||
| f"implies {expected_calls:,} calls" | ||
| ) |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
Validate the batch-call total.
Lines 311-324 only validate the separate-call total. If the recipe changes 720 batch calls to another value, the claim check still passes.
Capture the batch-call value. Compare it with 24 * 30. Add a regression test that changes 720.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@scripts/check_public_claims.py` around lines 307 - 324, The
_check_watchlist_math function currently validates only the separate-call count;
update its claim parsing to capture the batch-call value from
WATCHLIST_MATH_PATTERN and verify it equals 24 * 30. Extend the mismatch error
to report an incorrect batch total, and add a regression test that changes the
claimed 720 batch calls and confirms validation fails.
Summary
freeRequestsPerMonth, unknown fields/versions, wrong first-party identities, future or mismatched provenance, duplicate JSON keys, oversized payloads, and canonical redirectsX-RateLimit-*response headers, distinguish daily exhaustion from retryable hourly throttling, cap backoff, and remain import-safeas_ofroute/raw-interval/coverage boundary and verify both separate and batched watchlist mathRed / green
python3 -m unittest discover -s tests -v-> 32 runs, all greenpython3 scripts/check_public_claims.py --product-facts tests/fixtures/product-facts-50.json-> v2 50/day, contract/review 2026-08-11python3 -m compileall -q recipes scripts tests;actionlint;git diff --check; line-length auditRelease hold
Draft and sequencing-held. Exact head is
10f9c2f79d8df8128cd3098076fb5be0c437b48eon current main181fee6fdc57c90f5fc3cd0d6770b933aead036d. The live canonical endpoint still serves legacy v1, so hosted live-contract CI must fail closed until API Product Facts v2 is deployed. After that dependency is production-green, re-run hosted tests plus keyless production recipe smoke before merge.No API behavior, pricing decision, write-path recipe, customer contact, provider/customer/DB mutation, merge, or deployment is included. Issue #1 remains separately gated on a disposable write-path account and signed webhook fixture.
Closes #2.