Task: Model the credit support annex
Table of Contents
This page documents a task in the Model netting agreements, netting sets and CSAs story. It captures the goal, current status, acceptance, and any notes or results.
1. Goal
Hold the collateral terms of a netting set as their own entity, so a CSA can be added, changed or switched off without touching the set's trades.
2. Status
| Field | Value |
|---|---|
| State | DONE |
| Parent story | Model netting agreements, netting sets and CSAs |
| Now | Nothing. |
| Waiting on | Nothing. |
| Next | Nothing. |
| Last touched | 2026-10-03 |
3. Acceptance
- csa and csa_eligible_currency are generated in ores.refdata across every layer the codegen covers.
- A CSA carries every field of ORE's CSA details.
- A netting set has at most one active CSA, enforced by the database.
4. Plan
- Survey ORE's examples first: 99 files hold 191 netting sets; 189 carry CSA details and 83 of those are switched off. A CSA therefore exists on its own, and the active flag is the CSA's, not the set's.
csa: the netting set (required), the active flag, and every field of ORE'sCSADetailsas a nullable column, so a round trip keeps what ORE leaves out. Checks: the two Bilateral-type columns against ORE's three values, the independent amount type against FIXED, thresholds and minimum transfer amounts not negative.csa_eligible_currency: one row per eligible currency, with its position in ORE's list so an export keeps the order.- One active CSA per set: a unique index on the set over current, active rows.
- Wire by hand as for the netting entities, including tenant row-level security; neither table has a legal entity column, so no party policy.
5. Measurements
Every number this task claims about a tree, with the command that produced it
and the commit it was measured at. A number without both is not a measurement,
because a clean-up record describes a tree and trunk moves under a branch: a
consumer count, a gate's component count and a suite's size all change with no
code changing, and the reader of a bare number cannot tell which tree it came
from. Where the raw output matters, put it in an evidence/ file beside the
task and name that file in the Command column.
| What | Value | Command | Commit |
|---|---|---|---|
6. Notes
7. Test Scenarios
Manual QA scenarios (scaffolded via compass add test_scenario)
that verify this task. Link
new ones here as they're created; the scenario doc itself links back
via its "Verifies task" field.
| Scenario | State | Notes |
|---|---|---|
8. PRs
| PR | Title |
|---|---|
| #2538 | [refdata] Model the credit support annex |
9. Review
| # | Comment summary | File | Decision | Notes |
|---|---|---|---|---|
| 1 | Currency codes not validated | csa, csa_eligible_currency | Document | Kept as plain text, like the instrument models' currency columns; the models say so. |
| 2 | Closing a set leaves its CSA | csa | Decline | Every soft foreign key in the schema behaves this way, as the agreement model states. |
| 3 | 23505 on reactivation needs a readable error | service | Decline | The generated services map every unique violation the same way; nothing CSA-specific. |
| 4 | FIXED check may be too narrow | csa | Decline | It is the whole of ORE's independentAmountType enumeration. |
| 5 | No checked-in test of the rules | codegen tests | Accept | test_csa_rules.py renders the real models and asserts both unique indexes. |
| 6 | Two currencies can share a position | csa_eligible_currency | Accept | Unique index on (csa_id, position) over current rows. |
10. Result
csaandcsa_eligible_currencyare generated inores.refdataacross every layer, and wired by hand into the SQL lists, permission seeds, core registrar, shell menu, CMake lists and tenant row-level security.csacarries the netting set, the active flag and every field of ORE'sCSADetailsas a nullable column. Checks hold the Bilateral-type columns to ORE's three values, the independent amount type to FIXED, and thresholds and minimum transfer amounts to zero and above.- A unique index on the set over current, active rows allows at most one active CSA per set.
- A second unique index keeps each position of a CSA's currency list
once;
test_csa_rules.pyguards both indexes against the models. - In Postgres, in a transaction that rolled back: a second active CSA on a
set was refused (23505,
csas_active_set_idx); an inactive CSA beside it was accepted; an unknown Bilateral value and a negative threshold were refused (23514); a currency listed twice for one CSA was refused (23505). After review: a second currency at a taken position was refused (23505,csa_eligible_currencies_csa_position_idx); at the next position it was accepted. - Build: linux-clang-debug-make clean after making the eligible currency
generator use its counter for
position, which the warning gate caught. ctest: 89 of 89 binaries passed on a recreated database, including the two generated CSA eventing integration tests.