Task: Repair the rates trade-type routing

Table of Contents

This page documents a task in the Rework the rates instruments to the instrument table rule story. It captures the goal, current status, acceptance, and any notes or results.

1. Goal

Make the generated trade-type routing, the ORE importer and the instrument tables agree, and make every rates model generate a code the catalogue holds.

2. Status

Field Value
State DONE
Parent story Rework the rates instruments to the instrument table rule
Now Nothing.
Waiting on Nothing.
Next Nothing.
Last touched 2026-10-08

3. Acceptance

  • RiskParticipationAgreement routes to credit_instrument, its product_type is credit, and the credit table's generated check accepts the code, so an RPA document imports.
  • fra_instrument, swaption_instrument and inflation_swap_instrument generate trade type codes the catalogue and the seed hold.
  • The tree regenerates drift-clean and builds, and the codegen suite passes.
  • The unproduced rpa_instruments table is recorded with its disposition.

4. Plan

Three repairs, all at the catalogue and the models, then regenerate:

  1. RiskParticipationAgreement's catalogue row becomes product_type credit and instrument credit_instrument. The generated routing follows, the credit table's check gains the code, and the trade-types seed carries the class the domain note, the refdata instrument codes and the importer already state.
  2. The three generator defaults that name a code the seed does not hold are corrected to the catalogue's code.
  3. The unproduced rpa_instruments table is recorded with its disposition rather than retired here: retiring a generated entity touches five components and no tool prunes the files it leaves behind, so it is its own unit.

Removing the route empties the generated instrument_table enum of rpa_instrument, so the hand-written export switch that read it is migrated in the same change rather than left to fail to compile.

5. Measurements

Every number this task claims about a tree, with the command that produced it and the commit it was measured at.

What Value Command Commit
Catalogue codes routed to rpa_instrument, before 1 =grep ' rpa_instrument' ores.trading.trade_type_catalogue.org= 0e38c2a6fe
Catalogue codes routed to rpa_instrument, after 0 the same working tree
Codes in the credit_instruments trade-type check, before 7 grep -o "'[A-Za-z]*'" trading_credit_instruments_create.sql 0e38c2a6fe
Codes in the credit_instruments trade-type check, after 8 the same working tree
Models generating a code absent from the seed, before 3 (FRA, EuropeanSwaption, ZeroCouponInflationSwap) grep "'<code>'" trading_trade_types_populate.sql 0e38c2a6fe
Models generating a code absent from the seed, after 0 the same working tree
Generated files the route change touches 6 check_component_drift.py --component trading-cpp --dry-run working tree

6. Notes

The hand-written export switch is migrated in this change: the switch now has no rpa_instrument case, and the rpa_ids vector, its legs batch entry and its service dispatch are deleted with it. RPA flows through the credit path, which the file already had.

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
#2790 [trading] Classify RPA as credit and fix three rate codes

9. Review

Comment summary File Decision Notes
       

10. Result

The generated routing, the ORE importer and the instrument tables now agree, and every rates model generates a code the catalogue holds.

  • RiskParticipationAgreement leaves the rates family. Its catalogue row is product_type credit and instrument credit_instrument. The generated credit_instruments check gains the code (eight codes now, seven before), the trade-types seed classifies it credit, and the generated instrument_table_for returns credit_instrument. That is the table the ORE importer has always written, so the import no longer contradicts its own check. Three independent sources already said credit: the rpa.org domain note, the refdata instrument codes (refdata_instrument_codes_populate.sql:76) and the importer itself.
  • The three generator defaults name real codes. fra_instrument, swaption_instrument and inflation_swap_instrument generated FRA, EuropeanSwaption and ZeroCouponInflationSwap; they now generate ForwardRateAgreement, Swaption and InflationSwap, which are the codes the seed and the per-table checks carry. The FRA string was the refdata market-data short code for the same product, not a trade type.
  • rpa_instrument left the generated enum, since nothing routes to it any more. The hand-written export switch that had a case for it is migrated in the same change: the case, the rpa_ids vector, its legs batch entry and its service dispatch are deleted, and RPA flows through the credit path the file already had.
  • The unproduced rpa_instruments table is recorded, not retired here: capture Retire the unproduced rpa_instruments table, because retiring a generated entity touches five components and no tool prunes the files it leaves behind.

Verification: the component regenerates with no drift; the codegen suite is 1276 passed; the full preset build exits 0 with no errors and no warnings.

Rebased onto the refusal-catalogue merge (PR #2786, b9268cc7c5), which rewrote the SQL and C++ templates for the whole component. The rebase merged the one shared generated file without a conflict — the credit table's check is generated from the catalogue, so the two changes sit on different lines — and the component is still drift-clean after it, so no regeneration was needed.

Not verified live: that an RPA document imports and round trips. The database and the service fleet are down in this environment, and recreating the database is shared work across eleven worktrees. The import path is proven statically instead: the catalogue routes the code to credit_instrument, that table's generated check now lists it, and the importer writes that table.

Emacs 29.3 (Org mode 9.6.15)