Skip to content

Support internacia-db contract 5 and the trade agreements registry (0.6.0) - #19

Merged
ivbeg merged 1 commit into
mainfrom
claude/contract-5-496354
Nov 22, 2026
Merged

ivbeg merged 1 commit into
mainfrom
claude/contract-5-496354

Conversation

@ivbeg

@ivbeg ivbeg commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

internacia-db 5.0.0 (contract 5.0, release PR datenoio/internacia-db#206) fails its "Run the internacia SDK contract suite" step because this SDK only accepts contracts 3.x and 4.x. This PR adds support for contract 5.

What contract 5 changed

  • New tables trade_agreements and trade_agreement_parties, and a new view country_trade_agreements.
  • 34 two-party FTA intblocks (USKR, CETA, EUJP, CHAFTA, …) moved out of intblocks/memberships into trade_agreements under the same id. intblocks_aliases gained a target_dataset column and the reason moved. USCR is merged into CAFTADR.
  • No table, column or type the SDK already reads changed.

Changes

  • internacia/contract.py: SUPPORTED_CONTRACT_MAJORS = (3, 4, 5), TESTED_CONTRACT = (5, 0). Error messages now say "3.x, 4.x or 5.x".
  • resolve_id / resolve_code return a new target_dataset field: the table that holds id. It is trade_agreements for moved ids, the queried table otherwise, and None when there is no id. On 3.x/4.x alias tables, which have no such column, status and id work as before.
  • New client.trade_agreements (internacia/trade_agreements.py):
    • get_by_id
    • get_parties(current_only=False)
    • get_by_country (reads the country_trade_agreements view)
    • New types: TradeAgreement, TradeAgreementParty, CountryTradeAgreement.
    • Every method returns None or [] on databases before 5.0.
  • Tools: internacia.tools and the MCP server make a tool from every client in TOOL_CLIENTS, so trade_agreements_* tools come for free. intblock_lookup now returns the trade agreement for a moved id.
  • Version 0.6.0, CHANGELOG, README (compatibility row, new Trade agreements section), API reference.

Tests

  • tests/contract: new checks for the registry and moved ids on 5.x databases, and for the empty accessor on older ones.
  • tests/test_trade_agreements.py: unit tests on small 5.0-shaped and 4.4-shaped DuckDB files (moved/merged/retired aliases, the accessor, intblock_lookup).
  • Tests that used 5 as the "unsupported" major now use 6.
  • CI still pins internacia-db 4.4.0 (tests/internacia-db.json). The data-bump workflow will move the pin to 5.0.0 once that release is published.

Ran locally (Python 3.13):

  • Full suite with the 4.4.0 pin and with the local 5.0.0 build, on both duckdb 2.0.1 and 1.5.4: 322 passed in each run.
  • INTERNACIA_CONTRACT_DB_PATH=<5.0.0 build> pytest tests/contract -q: 30 passed (also 30 passed on 4.4.0).
  • black, ruff and mypy are clean.

After this merges, or using this PR's head commit, internacia-db should point INTERNACIA_SDK_REF in validate.yml and release.yml at it.

🤖 Generated with Claude Code

….6.0).

internacia-db 5.0.0 adds trade_agreements, trade_agreement_parties and
the country_trade_agreements view, and moves 34 two-party FTA
intblocks (USKR, CETA, EUJP, ...) into the registry under the same id
(intblocks_aliases reason "moved", new column target_dataset). No
table, column or type the SDK reads changed, so SUPPORTED_CONTRACT_MAJORS
becomes (3, 4, 5) and TESTED_CONTRACT (5, 0).

- resolve_id/resolve_code report target_dataset, the table that holds
  the resolved id: trade_agreements for moved ids, otherwise the
  queried table (also on 3.x/4.x alias tables without the column).
- client.trade_agreements: get_by_id, get_parties and get_by_country;
  None or [] on databases before 5.0. Its methods become LLM and MCP
  tools like every other client, and intblock_lookup returns the
  agreement for a moved id.
- tests/contract checks the registry and moved ids on 5.x and the
  empty accessor on older databases.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ivbeg added a commit to datenoio/internacia-db that referenced this pull request Nov 22, 2026
INTERNACIA_SDK_REF moves to datenoio/internacia-python#19 head 527b391
(0.6.0, contracts 3 to 5), whose tests/contract suite passes against the
5.0.0 build; 74f9338 only accepts contracts 3 and 4.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ivbeg
ivbeg merged commit 39febb9 into main Nov 22, 2026
10 checks passed
ivbeg added a commit to datenoio/internacia-db that referenced this pull request Nov 22, 2026
The squash merge of datenoio/internacia-python#19 has the same tree as
the previously pinned PR head 527b391.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant