Task: Implement Hotfix: the export joins on a trade id nobody mints

Table of Contents

This page documents a task in the Hotfix: the export joins on a trade id nobody mints story. It captures the goal, current status, acceptance, and any notes or results.

1. Goal

Give every trade in a payload built without the planner an id, and stamp the same id on its instrument, so the export's join resolves to the trade's own instrument.

2. Status

Field Value
State DONE
Parent story Hotfix: the export joins on a trade id nobody mints
Now Nothing.
Waiting on Nothing.
Next Nothing.
Last touched 2026-10-09

3. Acceptance

  • xml::roundtrip() mints one id per trade and stamps it onto the instrument.
  • The exporter tests build payloads through one shared helper that does the same.
  • Their assertions are unchanged, and the importer still leaves ids unset.

4. Plan

export_portfolio joins a trade to its instrument by item.anchor.id, and rebuild_instrument keys the batch by the instrument's identity trade_id. Two payload builders bypass the planner: xml::roundtrip() and the exporter tests. Both left every id nil and the uuid default, so the join matched the first row of whichever typed array was searched first.

The roundtrip walk now mints an id with boost::uuids::random_generator, stamps it on the instrument through trading::domain::stamp_ids, and carries it on the anchor – exactly what the planner does. The exporter tests share one make_export_payload helper that does the same, which replaces the duplicate nil ids they used to feed.

5. Measurements

What Value Command Commit
nightly failures this one bug explains 3 see the story description fa84f6e6f9
files changed 2 git show --stat fa84f6e6f9 fa84f6e6f9

6. Notes

The three nightly failures were a CapFloor resolving to another trade's swap, which threw std::get<cap_floor_instrument> and lost IR_DurAdjusted_CMS.xml and its ten trades; an Ascot resolving to a swap, which wrote a type and an envelope with no AscotData; and the exporter tests feeding duplicate nil ids.

The fix was written in another worktree against a prebuilt tree and not executed there. It is executed here.

7. Test Scenarios

Scenario State Notes
     

8. PRs

PR Title
   

9. Review

Comment summary File Decision Notes
       

10. Result

trading::domain::stamp_ids is applied per trade in the roundtrip walk, and the exporter tests build every payload through make_export_payload. The importer is untouched.

Emacs 29.3 (Org mode 9.6.15)