Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adr16 high level regime abstractions #512

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

kintisheff
Copy link
Contributor

@kintisheff kintisheff commented Mar 14, 2022

TP2000-170 ADR16 - High-Level Abstractions for Trade Policy Regimes

Why

As part of architectural discussions about the future design directions for TaMaTo, the TAP data team has agreed to open two related ADR-s for discussion - this one on high-level abstractions for trade policy regimes and the other for a new UK trade policy data specification for DIT

What

This PR contains the draft of ADR16.
Recommended to use this link for reading through the formatted ADR before commenting.

NB: Unfortunately, I got to my last day before I could ready this for PR. This means that likely I won't be able to respond to what I'm sure is going to be a wide range of questions and comments. However, I hope it provides a good enough basis for the direction I think this should be taking on! <3

@codecov-commenter
Copy link

Codecov Report

Merging #512 (e7945da) into master (1e18f40) will increase coverage by 0.01%.
The diff coverage is n/a.

❗ Current head e7945da differs from pull request most recent head fd2f212. Consider uploading reports for the commit fd2f212 to get more accurate results

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #512      +/-   ##
==========================================
+ Coverage   92.60%   92.61%   +0.01%     
==========================================
  Files         298      298              
  Lines       18441    18455      +14     
  Branches     1472     1472              
==========================================
+ Hits        17077    17092      +15     
  Misses       1088     1088              
+ Partials      276      275       -1     
Impacted Files Coverage Δ
common/views.py 79.79% <0.00%> (-0.11%) ⬇️
common/tests/test_views.py 100.00% <0.00%> (ø)
workbaskets/session_store.py 62.96% <0.00%> (+3.70%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1e18f40...fd2f212. Read the comment docs.

@kintisheff kintisheff requested a review from a team March 14, 2022 19:02

2. **Low-level tariff changes are not policy-friendly.** Customs rules are often subject to trade policy regimes such as free trade agreements (FTA-s) or most favored nation (MFN) treatment. Trade policies often span multiple commodities and multiple time periods. For example, staging rates in an FTA may define how the duty rate for a given range of commodities imported from the trade partner may decline gradually over the course of several years. This is one policy that needs to be reflected in multiple individual customs rules via individual measures, one for each combination of commodity and validity period.

- Importantly, this is not a *bulk entry* issue. TaMaTo does provide utilities (e.g. a TARIC envelope importer and a configurable excel importer), which enable bulk load of a large number of data entries at a time. But the source files for bulk entry still need to outline customs rules one measure at a time, and they provide no meta context around the policy regime
Copy link
Contributor

Choose a reason for hiding this comment

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

Well, it’s not just a bulk entry issue. Volume is a component of the problem.


- there is one of these entities for each measure type, responsible for handling all the peculiarities related to that specific measure type;
- all measure type entities share a common interface, ensuring the ability to automatically determine diffs vs current database state and apply changes accordingly
- measure types rarely change, so building up the library of measure type entities should be a one-off investment
Copy link
Contributor

Choose a reason for hiding this comment

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

Hm, this is true now but may not need to be true in the future. It’s only really because we don’t understand the steps necessary with CDS and have been warned it’s not trivial. If we knew more about those steps or could confirm it can be done, we could create more measure types ourselves.

@stuaxo
Copy link
Contributor

stuaxo commented Mar 22, 2022

Does anyone reading this PR know how much of this was already implemented in notebooks ?

~~~~~~~~~~~~~~~~~~~~~~~~~~
The low-level data entry approach for customs rules in TaMaTo imposes a range of costs and operational risks:

1. Lowe-level data entry can be *slow and tedious* via both the backend and the UI. This leads to delays in implementation of trade policies at the border (sometimes, these delays are significant and are measured in months).
Copy link
Contributor

Choose a reason for hiding this comment

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

s/Lowe/Low/g

The proposed solution centers on the use of two main abstractions:

1. **Measure Type Entities.** These are responsible for managing writes to low-level TARIC-3 model entities of a given measure type, with all the peculiarities that are specific to that measure type

Copy link
Contributor

@stuaxo stuaxo Mar 25, 2022

Choose a reason for hiding this comment

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

^ measure types are mentioned here for the first time - there should be a brief bit of text about them including examples of measure types.

Some of the info in the MeasureType class's docstring seems relevant -

"""
The measure type identifies a customs measure.

TARIC customs measures cover a wide range of information, including tariff
measures (such as levies and anti-dumping duties), and non-tariff measures
(such as quantitative restrictions and prohibitions).
"""

Copy link
Contributor

Choose a reason for hiding this comment

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

- the input data specifications can be literally any specification in any format (strings, json payloads, etc.)
- policy regime aggregates share a common interface, ensuring the ability to transcode inputs, to provide comprehensive previews of pending changes to validate policy implications, and to apply a policy
- policy regime aggregates are meant to be invoked directly when implementing tariff changes
- it is recommended that the aggregates are tested with fearues and scenarios under BDD
Copy link
Contributor

Choose a reason for hiding this comment

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

s/fearues/features/g

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.

4 participants