Defects in the generated C++ templates

Table of Contents

This page is a capture in the inbox bucket of the product backlog — a pre-sprint idea, not yet pulled into a sprint as a story.

1. What

The G04 review of the generated code in ores.marketdata found five defects that live in the shared templates, so every component carries them:

  1. A lost claim reports as an internal error. A service checks the claim in prepare_change, then writes. If another writer wins in between, the insert trigger raises Version conflict (P0002) and the repository throws. Every generated handler catches any exception as failed with code internal_error, so the caller sees a fault where it should see conflict.
  2. put_many reads back one row at a time. After its one-statement write, the service reads each written row back with its own query.
  3. Some archetypes have no generated test. Nothing tests the table, table_io or history_field_mapper output; only a live shell run reaches them.
  4. Generators fill foreign keys with random UUIDs. A generated junction or child row then fails its foreign-key check, so tests build such rows by hand.
  5. The eventing integration test assumes audit columns. It sets change_reason_code and change_commentary, so it does not compile for an entity without them, such as the time-series market_fixing and market_observation.

The same catch also hides bad input. On 2026-10-10 the synthetic BFF routes wrote an FX feed whose price_source broke a table check, and a feed whose config_id named no collection, which a validation trigger refuses. Both came back as failed with internal_error and the raw PostgreSQL text, so the BFF answers 502 where the person should read a 400 that names the field. A check violation (23514) or a validation trigger refusal (23503) is invalid, and the message should not carry SQL.

2. Why

G04 says a finding in generated code is a template defect and is fixed in the template. The first is a correctness defect under a race; the others are cost and coverage gaps that every generated entity inherits.

3. References

4. See also

Emacs 29.3 (Org mode 9.6.15)