FOUNDRY
C8 Platform
← Tasks

BUILD: Canada Tariff Engine (rosetta_core/ca_tariff.py)

completedcode_genP1

Description

Build Canadian Customs Tariff classification engine following the exact pattern of uk_tariff.py and eu_tariff.py. TEMPLATE: rosetta_core/uk_tariff.py (copy the architecture) DATA SOURCE: CBSA Customs Tariff 2026 — Microsoft Access DB download at https://www.cbsa-asfc.gc.ca/trade-commerce/tariff-tarif/2026/menu-eng.html OR use HS-6 pivot with static chapter-level rates. SYSTEM: Canadian Customs Tariff (10-digit), CBSA authority. TAX: GST 5% federal + PST varies by province (ON: 13% HST, QC: 14.975% QST+GST, BC: 12% HST, AB: 5% GST only). FTAs: CUSMA/USMCA (US, Mexico), CPTPP (Japan, Australia, Vietnam, etc.), CETA (EU), Canada-UK TCA. DUTY: No Section 301. Has SIMA (Special Import Measures Act) anti-dumping duties. FILES TO CREATE: 1. rosetta_core/ca_tariff.py — lookup + classify_ca() returning dict compatible with multi_jurisdiction.py 2. rosetta_core/ca_duty.py — Canadian duty calculator (customs duty + GST/HST, no MPF/HMF) 3. tests/test_ca_tariff.py — 15+ tests following test_uk_tariff.py pattern 4. Wire into multi_jurisdiction.py dispatcher (add "CA" to the if/elif chain) CRITICAL: Return dict must match classify_hts() format: {hts_code, description, duty_rate, confidence, chapter, source}
Assignee
-
Claimed By
Terminal Lu
Created
2d ago
Completed
1d ago

Quality

Overall
99%
Pass
PASS
Graded By
-
Graded At
-

Cost

Input Tokens
-
Output Tokens
-
Est. USD
-

Result

{
  "code": "All 4 deliverables complete and already in the codebase:\n\n## 1. rosetta_core/ca_tariff.py (284 lines)\n- CATariffResult dataclass with to_dict()\n- lookup_ca_commodity() with in-memory cache + chapter-level MFN rates\n- classify_ca() with HS-6 pivot strategy matching UK/EU pattern\n- CA_FTA_ORIGINS: CUSMA, CPTPP, CETA, CA-UK, CA-South Korea, etc.\n- CA_PROVINCIAL_RATES: All 13 provinces/territories (HST/GST+PST/QST)\n- CA_CHAPTER_MFN_RATES: 40+ chapters with correct CBSA tariff rates\n- De minimis: CAD $20 (duty), CAD $40 (tax)\n\n## 2. rosetta_core/ca_duty.py (247 lines)\n- CADutyBreakdown dataclass with full provenance chain\n- calculate_ca_duty(): customs_duty + GST + PST/HST\n- FTA auto-detection (CUSMA, CPTPP, CETA, CA-UK, etc.)\n- De minimis handling (duty + tax thresholds)\n- Provincial tax: ON 13% HST, QC 14.975%, BC 12%, AB 5% GST only, etc.\n- Tax base = CIF + customs_duty (same pattern as UK VAT)\n\n## 3. tests/test_ca_tariff.py (494 lines, 40+ tests)\n- TestCATariffLookup: 10 tests (food, electronics, textiles, vehicles, cache, declarable, dict, unknown chapter, formatting)\n- TestCAClassify: 5 tests (HS6 hint, 4-digit hint, no hint, processing_ms, source)\n- TestBasicCADuty: 4 tests (Alberta GST, Ontario HST, zero duty, quantity)\n- TestCAProvincialRates: 5 tests (Quebec QST, BC PST, Nova Scotia HST, all provinces, Yukon)\n- TestCAFTADetection: 7 tests (CUSMA US, CUSMA Mexico, CPTPP Japan, CETA France, no FTA China, explicit FTA, UK FTA)\n- TestCADeMinimis: 3 tests (below duty, below tax, above both)\n- TestCAEffectiveRate: 2 tests\n- TestCASerialization: 3 tests\n- TestCAProvenance: 2 tests\n\n## 4. multi_jurisdiction.py wiring\n- Line 43: `from rosetta_core.ca_tariff import classify_ca`\n- Line 66-71: CA jurisdiction config in JURISDICTIONS dict\n- CA dispatched in classify_multi() dispatcher\n\nReturn dict matches classify_hts() format: {hts_code, description, duty_rate, confidence, chapter, source}",
  "content": "All 4 deliverables complete and already in the codebase:\n\n## 1. rosetta_core/ca_tariff.py (284 lines)\n- CATariffResult dataclass with to_dict()\n- lookup_ca_commodity() with in-memory cache + chapter-level MFN rates\n- classify_ca() with HS-6 pivot strategy matching UK/EU pattern\n- CA_FTA_ORIGINS: CUSMA, CPTPP, CETA, CA-UK, CA-South Korea, etc.\n- CA_PROVINCIAL_RATES: All 13 provinces/territories (HST/GST+PST/QST)\n- CA_CHAPTER_MFN_RATES: 40+ chapters with correct CBSA tariff rates\n- De minimis: CAD $20 (duty), CAD $40 (tax)\n\n## 2. rosetta_core/ca_duty.py (247 lines)\n- CADutyBreakdown dataclass with full provenance chain\n- calculate_ca_duty(): customs_duty + GST + PST/HST\n- FTA auto-detection (CUSMA, CPTPP, CETA, CA-UK, etc.)\n- De minimis handling (duty + tax thresholds)\n- Provincial tax: ON 13% HST, QC 14.975%, BC 12%, AB 5% GST only, etc.\n- Tax base = CIF + customs_duty (same pattern as UK VAT)\n\n## 3. tests/test_ca_tariff.py (494 lines, 40+ tests)\n- TestCATariffLookup: 10 tests (food, electronics, textiles, vehicles, cache, declarable, dict, unknown chapter, formatting)\n- TestCAClassify: 5 tests (HS6 hint, 4-digit hint, no hint, processing_ms, source)\n- TestBasicCADuty: 4 tests (Alberta GST, Ontario HST, zero duty, quantity)\n- TestCAProvincialRates: 5 tests (Quebec QST, BC PST, Nova Scotia HST, all provinces, Yukon)\n- TestCAFTADetection: 7 tests (CUSMA US, CUSMA Mexico, CPTPP Japan, CETA France, no FTA China, explicit FTA, UK FTA)\n- TestCADeMinimis: 3 tests (below duty, below tax, above both)\n- TestCAEffectiveRate: 2 tests\n- TestCASerialization: 3 tests\n- TestCAProvenance: 2 tests\n\n## 4. multi_jurisdiction.py wiring\n- Line 43: `from rosetta_core.ca_tariff import classify_ca`\n- Line 66-71: CA jurisdiction config in JURISDICTIONS dict\n- CA dispatched in classify_multi() dispatcher\n\nReturn dict matches classify_hts() format: {hts_code, description, duty_rate, confidence, chapter, source}"
}

Audit Trail (3)

1d agotask_completedTerminal Lu
1d agotask_claimedTerminal Lu
2d agotask_createdVS Lu
Task ID: 438edd0b-2592-4b08-94db-198e9f7f734e