Repository navigation
test(legal-status): 17-case rule-coverage scenario (live + offline); handle US reissues - #18
Merged
Merged
Conversation
… handle reissues Small, scenario-based test data instead of a full corpus load: 17 real public patents, each chosen to exercise one rule. Expected values were derived by hand from the raw ODP / EPO OPS records, not by running the code under test, and each case records its basis in fixtures/scenarios/legal-status-coverage.json. Cases: US lapsed; term start from a DIV parent and from PCT national stage (expired and in force); provisional parent excluded; terminal disclaimer flagged; PTA unknown; largest PTA (1,220 days); continuation with a large PTA; reissue; not found. EP lapsed in all designated states; reinstated then lapsed; a state with no reports flagged; fees paid near term end; unitary effect; B2 after opposition, expired (B1 and B2 share one INPADOC record). - Offline: test_legal_status_coverage.py checks all 16 fixture cases plus the manifest itself. - Live: scripts/run-legal-status-scenario.py runs the manifest against the sources (17 API calls, no BigQuery) and reports any drift; --record stores the results through LegalStatusRefresher. Live run on 2026-10-04: 17/17 match. Gap found and fixed: a US reissue runs for the remaining term of the original patent (35 U.S.C. 251), but its term was computed from the reissue's own later filing date, overstating it. Reissues (applicationTypeCategory REISSUE) are now undetermined with that reason until the original is looked up, and the refresher accepts US-RE... numbers (ODP format RE49000 confirmed). The extract keeps applicationTypeCategory; RULES_VERSION becomes legal-status-rules/2. Existing US fixtures were regenerated with the current extract (diff: the new field only). Co-Authored-By: Claude Opus 5.5 <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.
Why
Per your direction: small, scenario-based test data instead of a full corpus load. No BigQuery: BigQuery bills by columns scanned, so even a 20-patent query would scan about 59 GB. The data comes from the USPTO/EPO APIs instead.
The coverage set
fixtures/scenarios/legal-status-coverage.json: 17 real public patents, one per rule. Expected values were derived by hand from the raw source records, not by running the code under test, and each case records its basis.test_legal_status_coverage.pychecks the 16 fixture cases plus the manifest itself (it requires a basis for every case).scripts/run-legal-status-scenario.pyruns the manifest against the real APIs (17 calls) and reports drift instead of hiding it. Run on 2026-10-04: 17/17 match.--recordalso stores the results throughLegalStatusRefresher.Gap found and fixed: US reissues
A reissued patent runs for the remaining term of the original patent (35 U.S.C. §251). The code computed the term from the reissue's own later filing date, which overstated it. Now:
applicationTypeCategory: REISSUE, confirmed in ODP) areundeterminedwith that reason until the original patent is looked up. ODP gives it as parent codeREI.US-RE…numbers (ODP formatRE49000confirmed).RULES_VERSION→legal-status-rules/2. The extract keepsapplicationTypeCategory, and the existing US fixtures were regenerated (diff: the new field only).A mutation check confirmed the reissue case fails without the fix.
Notes
RE49000) isn't in H01M/H02J; it was chosen to test the rule, not the field. ODP stops paging after 1,100 results, and none of those reissues were in scope.--recordwasn't run live: no PatentEvidence database is running on this machine. Its write path is covered by the Postgres integration tests.Validation
.venv/bin/pytest apps/api/tests/unit/: 399 passed (17 new)./scripts/test-postgres.sh: 103 passedpnpm test:web: 62 passed;pnpm build:web: okverify-source-lock,verify-scaffold,verify-p0-02,verify-p0-e2e,docker compose config: ok🤖 Generated with Claude Code