Skip to content

Consume typed daily Product Facts contract - #3

Draft
karlwaldman wants to merge 4 commits into
mainfrom
codex/public-contract-truth-20260810
Draft

Consume typed daily Product Facts contract#3
karlwaldman wants to merge 4 commits into
mainfrom
codex/public-contract-truth-20260810

Conversation

@karlwaldman

@karlwaldman karlwaldman commented Aug 10, 2026

Copy link
Copy Markdown
Member

Summary

  • consume only the exact released Product Facts v2 shape and reject legacy v1 freeRequestsPerMonth, unknown fields/versions, wrong first-party identities, future or mismatched provenance, duplicate JSON keys, oversized payloads, and canonical redirects
  • render and recursively guard the typed Free allowance as 50 requests/day while leaving paid monthly plan claims independent
  • update the resilient client to use canonical X-RateLimit-* response headers, distinguish daily exhaustion from retryable hourly throttling, cap backoff, and remain import-safe
  • retain the exact reviewed as_of route/raw-interval/coverage boundary and verify both separate and batched watchlist math
  • pin CI actions, use read-only permissions, and disable checkout credential persistence

Red / green

  • RED: 23 contract tests produced 37 failures and 4 errors against the v1/monthly parser and dashboard recovery path
  • RED: nested and wrapped claims were not scanned; 2/2 negatives failed
  • RED: the recipe exited on import and treated hourly exhaustion as daily quota exhaustion
  • RED: 721 batched calls passed; duplicate JSON keys passed; mutable workflow tags passed
  • GREEN: python3 -m unittest discover -s tests -v -> 32 runs, all green
  • GREEN: python3 scripts/check_public_claims.py --product-facts tests/fixtures/product-facts-50.json -> v2 50/day, contract/review 2026-08-11
  • GREEN: python3 -m compileall -q recipes scripts tests; actionlint; git diff --check; line-length audit

Release hold

Draft and sequencing-held. Exact head is 10f9c2f79d8df8128cd3098076fb5be0c437b48e on current main 181fee6fdc57c90f5fc3cd0d6770b933aead036d. 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.

@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The change reconciles public cookbook claims with canonical product facts. It narrows as_of documentation, corrects watchlist call-count examples, adds a standard-library validator with tests, and runs validation in pull-request smoke CI.

Changes

Public claim validation

Layer / File(s) Summary
Canonical product facts
scripts/check_public_claims.py, tests/fixtures/product-facts-*.json
Loads and validates canonical product facts, including the free monthly request allowance.
Public claim rules
scripts/check_public_claims.py
Checks allowance claims, as_of scope, raw intervals, correction coverage, prohibited well-data claims, and watchlist arithmetic.
Reconciled public documentation
README.md, recipes/01_first_price_no_key.py, recipes/02_backtest_without_lookahead.py, recipes/08_batch_watchlist_dataframe.py, recipes/10_resilient_client.py
Updates the allowance to 50 requests per month, narrows as_of claims, and corrects six-code watchlist calculations.
Automated validation and CI wiring
tests/test_public_claims.py, .github/workflows/smoke.yml
Tests valid and stale claims, forbidden wording, and calculation drift. Pull-request smoke CI runs the tests and claim checker.

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
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 6.90% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes address issue #2 by correcting allowance, as_of scope, coverage dates, watchlist math, claim checks, tests, and CI integration.
Out of Scope Changes check ✅ Passed The changes are limited to the linked issue objectives, including documentation, validation tooling, fixtures, tests, and CI integration.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the new claim checker consuming the canonical Product Facts contract, which is a central change in the pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/public-contract-truth-20260810

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@karlwaldman

Copy link
Copy Markdown
Member Author

Hardening proof for commit 193da2a:

  • Free allowance extraction now recognizes requests per month, API calls/month, monthly-prefix wording, and fully or partially hyphenated forms.
  • Markdown plan tables are parsed by header and plan row, so an isolated stale Free value fails while Developer/Professional limits remain valid.
  • Regression coverage includes five stale prose variants, a stale Free | 200 table row, and valid Free plus paid-plan limits.

Verification:

  • python3 -m unittest discover -s tests -v -> 9 tests passed (including 5 wording subtests)
  • python3 scripts/check_public_claims.py -> live contract OK at freeRequestsPerMonth=50
  • .venv/bin/python recipes/01_first_price_no_key.py -> live keyless response succeeded
  • python3 -m compileall -q scripts tests recipes and git diff --check -> passed

No deployment or customer action was performed.

@karlwaldman
karlwaldman marked this pull request as ready for review August 11, 2026 11:15

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 181fee6 and 193da2a.

📒 Files selected for processing (10)
  • .github/workflows/smoke.yml
  • README.md
  • recipes/01_first_price_no_key.py
  • recipes/02_backtest_without_lookahead.py
  • recipes/08_batch_watchlist_dataframe.py
  • recipes/10_resilient_client.py
  • scripts/check_public_claims.py
  • tests/fixtures/product-facts-50.json
  • tests/fixtures/product-facts-51.json
  • tests/test_public_claims.py

Comment on lines +307 to +324
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"
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ 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.

@karlwaldman
karlwaldman marked this pull request as draft August 12, 2026 08:22
@karlwaldman karlwaldman changed the title Guard cookbook public contract claims Consume typed daily Product Facts contract Aug 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Public truth] Reconcile plan allowance and as_of scope

1 participant