Story: Codegen SQL variability for hypertable, bi-temporal and GIST patterns; model ores.marketdata entities

Table of Contents

This page documents a story in Sprint 22. It captures the goal, current status, acceptance criteria, and the tasks that compose it.

Goal

Extend the codegen SQL template with three variability flags needed to model ores.marketdata entities: (1) TimescaleDB hypertable creation, (2) soft-update/soft-delete bi-temporal triggers, (3) GIST exclusion constraints. Then write .org models for market_series, market_observation and market_fixing, wire them into the marketdata component catalogue entry, and regenerate all three entities to zero-diff.

Status

Field Value
State DONE
Parent sprint Sprint 22
Now All four tasks complete; PR pending.
Waiting on Nothing.
Next Merge PR; return to marketdata story.
Last touched 2026-06-30

Acceptance

Tasks

Task State Start End Description
SQL variability: TimescaleDB hypertable support DONE 2026-06-30 2026-06-30 Add #+hypertable: true, #+hypertable_partition_column and #+hypertable_chunk_interval frontmatter flags to the entity org schema; extend org_loader.py and core.py to populate sql.hypertable dict; extend the SQL DDL template to emit SELECT create_hypertable(…) when the flag is set.
SQL variability: soft-update/soft-delete bi-temporal triggers DONE   2026-06-30 Add a #+bitemporal_trigger: soft_update_delete flag; extend org_loader.py and core.py; extend the SQL DDL template to emit the soft-update insert trigger (closes previous row, creates fresh) and the soft-delete trigger (returns NULL to suppress physical delete) when the flag is set, instead of the standard version-conflict trigger.
SQL variability: GIST exclusion constraint DONE   2026-06-30 Add #+gist_exclusion: true flag; extend org_loader.py, core.py and the SQL DDL template to emit EXCLUDE USING gist(…) on the natural-key columns with tstzrange(valid_from, valid_to) for temporal uniqueness, replacing the standard partial unique index when the flag is set.
Write .org models for market_series, market_observation, market_fixing and regenerate DONE 2026-06-30 2026-06-30 Create ores.marketdata.market_series.org, ores.marketdata.market_observation.org and ores.marketdata.market_fixing.org entity models using the new SQL variability flags; register them in the marketdata component catalogue entry; run codegen across all profiles (sql, domain, repository, service, nats) and verify zero-diff against the hand-written files.

Decisions

Out of scope

Emacs 29.3 (Org mode 9.6.15)