Task: Migrate remaining ores.qt.refdata entities without a codegen model onto the generic HistoryDialog

Table of Contents

This page documents a task in the Migrate ores.qt.refdata onto the generic HistoryDialog story. It captures the goal, current status, acceptance, and any notes or results.

Goal

Retire the last 2 hand-rolled per-entity *HistoryDialog classes left in projects/ores.qt/refdata once the codegen-model-backed batch closed: floating_index_type and leg_type. Both had a codegen model under ores.trading while their Qt controller (and all hand-written NATS wiring) lived under ores.qt/refdata — the same organizational mismatch Book/BusinessCentre had before their own moves. Resolved by moving the backend to match, not the other way round: reassigned #+component: to refdata in both models, relocated their domain/repository/service/protocol/generator/eventing layers and SQL table/schema from ores.trading to ores.refdata, then migrated via the exact same full-regeneration process as every other entity in this story.

2026-07-17 re-scope: this task was originally scoped to 17 entities (this description said 5 model-backed + 12 model-less). Investigation on pickup found that 15 of those 17 — payment_frequency_type (a naming error; the actual entity, payment_frequency, already migrated on 2026-07-15, before this task even existed) and all 14 DQ-owned entities (code_domain, dataset_bundle, and the 12 "model-less" ones) — are not ores.qt.refdata work at all. The 14 DQ entities were already moved out of RefdataPlugin into ores.qt.data_management by a prior task in this same story, which this task's original scoping missed. See Notes for where that work now lives. That leaves exactly floating_index_type and leg_type as this task's actual scope.

Status

Field Value
State DONE
Parent story Migrate ores.qt.refdata onto the generic HistoryDialog
Now Nothing.
Waiting on Nothing.
Next Nothing.
Last touched 2026-07-17

Acceptance

  • floating_index_type and leg_type's backend moved from ores.trading to ores.refdata (model, domain, repository, service, protocol, generator, eventing, SQL create/drop/populate/RLS scripts) and migrated onto the generic HistoryDialog via full codegen regeneration, following the same process as task 9605CFDB. ✅
  • Zero remaining *HistoryDialog.{hpp,cpp,ui} files in projects/ores.qt/refdata for these two entities. ✅
  • Full build green; ores.refdata.*, ores.trading.*, and ores.cli.tests all pass; validate_schemas.sh zero warnings; DB recreates clean with both entities' seed data. ✅

Plan

Per entity (floating_index_type, then leg_type):

  1. Author a new ores.refdata.modeling/ores.refdata.<entity>.org model (#+component: refdata, all Qt-section request/response classes and includes renamed from trading:: to refdata::), git rm the old ores.trading model file.
  2. Add an explicit Detail fields table (code, description only) — without one, a pre-existing codegen default-fields bug (core.py, Auto-generate default detail_fields if not provided) unconditionally injects a name field even when the entity has no name column, breaking the build. Worked around at the model level rather than touching the shared codegen driver.
  3. compass codegen entity generate <entity>; git rm the legacy per-entity *HistoryDialog.{hpp,cpp,ui} files (regeneration confirmed the controller wires the generic HistoryDialog directly).
  4. git rm the now-superseded ores.trading backend files (domain/repository/service/protocol/generator/eventing) and SQL create/drop/populate scripts; wire the freshly generated SQL into refdata_create.sql=/=refdata_drop.sql=/=refdata_populate.sql (codegen doesn't auto-wire new entities into the schema manifests).
  5. Wire the generated per-entity registrar/event-registrar/history provider into ores.refdata.core's shared registrar.cpp and ores.refdata.service's event_registrar.cpp (the same manual step every other refdata entity's own registration required — not automatic from entity generate).
  6. Fix ores.trading's hand-written instrument_ref_handler.hpp=/ =registrar_trades.cpp, which also served trade_type (staying in trading) — removed only the two entities' methods/subscriptions, left trade_type's untouched.
  7. Fix ores.cli/src/app/application.cpp's hand-written trading::domain=/=trading::repository includes and namespace usages (CLI support isn't part of the automatic codegen sweep).
  8. Hand-patch ores.trading.swap_leg's create SQL: its trigger calls ores_trading_validate_{leg_type,floating_index_type}_fn by name (a hand-authored FK-validator, not part of the standard codegen template output) — renamed to the new ores_refdata_validate_*_fn names rather than regenerating swap_leg itself (explicit decision to avoid snowballing into an unrelated trading-entity regen). Moved/renamed the two validator create/drop files themselves from ores.sql/{create,drop}/trading/ to .../refdata/, and removed the now-stale RLS_001 ignore entries for the old trading table names from validation_ignore.txt (replaced with real RLS policies in refdata_rls_policies_create.sql, not another ignore entry — the "no exceptions" policy applies to RLS too).
  9. Full rebuild (required a cmake --preset reconfigure first — the file-glob-based CMakeLists.txt don't use CONFIGURE_DEPENDS, so a deleted source file needs an explicit reconfigure, not just a rebuild), db recreate, validate_schemas.sh, and the ores.refdata=/=ores.trading=/ =ores.cli test suites.

Notes

Re-scope: 15 of the original 17 entities are not ores.qt.refdata work

Discovered on pickup (2026-07-17), before any migration work started:

  • payment_frequency_type doesn't exist under that name — the actual entity is payment_frequency, owned by ores.refdata itself (ores.refdata.payment_frequency.org, created 2026-07-15). It already constructs the generic HistoryDialog directly in PaymentFrequencyController::showHistoryWindow — already migrated, nothing to do. (The original task description's "ores.trading" attribution for this one was simply wrong.)
  • code_domain, dataset_bundle, and all 12 "no codegen model" entities (catalog, change_reason, change_reason_category, coding_scheme, coding_scheme_authority_type, data_domain, dataset, methodology, nature_dimension, origin_dimension, subject_area, treatment_dimension) — all 14 DQ-owned entities — no longer have a Qt controller anywhere under ores.qt/refdata at all. This story's own D5DF4CFA task already moved every one of them into the new ores.qt.data_management plugin; this task's original scoping was written without noticing that move had already happened. Verified directly: find projects/ores.qt/data_management -iname "*Controller.cpp" lists all 14; none remain under ores.qt/refdata.

That work isn't abandoned, just relocated: filed as Migrate ores.qt.data_management's history dialogs to the generic HistoryDialog under Commission ores.qt.dq — full-stack codegen for the DQ component — the story already standing up ores.qt.dq as the proper plugin ores.qt.data_management is a stepping stone toward. The "every entity gets a real codegen model, no exceptions" policy (including how change_reason=/=change_reason_category's self-referential change-reason-cache wrinkle doesn't warrant an exemption — same category of problem business_unit_type solved for a different self-referential FK validator in task D4A868F5, via a backward-compatible trailing paste-block template extension) carries over to that task, not this one.

That leaves this task's actual, final scope: floating_index_type and leg_type only — both confirmed still on a legacy per-entity *HistoryDialog (FloatingIndexTypeHistoryDialog, LegTypeHistoryDialog), both with an existing ores.trading codegen model.

Test Scenarios

Manual QA scenarios (scaffolded via compass add test_scenario, run through the QA Validation Runner panel) 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
     

PRs

PR Title
#1619 [refdata,trading,qt,cli,sql] Migrate floating_index_type/leg_type to refdata + generic HistoryDialog

Review

Comment summary File Decision Notes
       

Result

Re-scoped on pickup from 17 entities to 2 (floating_index_type, leg_type) — the other 15 turned out to already be out of ores.qt.refdata entirely (a naming error for one already-migrated entity, and 14 DQ-owned entities already relocated to ores.qt.data_management by a prior task); that work is now tracked under a new task on the DQ commissioning story instead.

Both entities' full backend (domain, repository, service, protocol, generator, NATS eventing/history) moved from ores.trading to ores.refdata to match where their Qt UI already lived — mirroring Book/BusinessCentre's precedent, matching direction rather than copying it verbatim (their mismatch ran the other way). This surfaced and fixed a real pre-existing gap along the way: neither entity's NATS handler/registrar/event-registrar/history-field-mapper had ever actually been wired anywhere — the only NATS support that existed was a hand-written combined handler (instrument_ref_handler.hpp) shared with trade_type, with no history support at all. Both now have complete, codegen-generated stacks wired through ores.refdata's standard shared registrar pattern.

Also fixed along the way (pre-existing, surfaced only once these tables were actually exercised through the standard pipeline for the first time): missing RLS policies for both tables (previously masked by stale RLS_001 ignore-list entries under the old trading table names, now replaced with real tenant-isolation policies), and a codegen default-fields bug that unconditionally injects a name field even for entities with no name column (worked around via an explicit Detail fields model table rather than touching the shared codegen driver).

Verification: full build green (linux-clang-debug-make, after a cmake reconfigure to pick up deleted source files); validate_schemas.sh 0 warnings (was 2); db recreate clean with both entities' seed data (13 floating index types, 10 leg types); ores.refdata.{api,client,core,service}.tests, ores.trading.{api,core,service}.tests, and ores.cli.tests all pass (8/8 suites, 0 failures).

Emacs 29.3 (Org mode 9.6.15)