Task: Extend lookup_entity scaffolding to cover DQ's simple entities' variability

Table of Contents

This page documents a task in the Commission ores.qt.dq — full-stack codegen for the DQ component story. It captures the goal, current status, acceptance, and any notes or results.

Goal

compass add lookup_entity should be as safe against silent knob-omission as compass add entity_org --shape now is: parameterize has_coding_scheme=/=has_image_id=/=has_artefact_insert_fn via --entity-<knob> flags instead of the current hardcoded false.

Compound natural keys (needed by subject_area, keyed by name + domain_name) turned out to require a much bigger change – org_loader.py's primary_key parsing and sql_schema_table_create.mustache (shared with plain table models) are both single-column-oriented, with entity.primary_key.column referenced ~20+ times across the create table, GIST exclusion, unique indexes, insert-trigger version logic, delete rule, and a generated validate_<X>_exists function. Descoped out to its own task, Support compound natural keys in lookup_entity/table SQL templates; subject_area will model domain_name as a plain Column for now.

Status

Field Value
State DONE
Parent story Commission ores.qt.dq — full-stack codegen for the DQ component
Now Nothing.
Waiting on Nothing.
Next Nothing.
Last touched 2026-07-18

Acceptance

  • --entity-has-coding-scheme=/–entity-has-image-id=/=–entity-has-artefact-insert-fn= flags exist and are wired into the scaffold output, mirroring entity_org's --entity-<knob> convention.
  • A scratch scaffold with each flag set exercises the corresponding frontmatter keyword end to end.

Plan

(Implementation strategy. Written when work starts; key decisions are distilled into the parent story's * Decisions at close, but the plan itself stays — it is the historical record of what we did.)

Notes

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
   

Review

Comment summary File Decision Notes
       

Result

Added --entity-has-coding-scheme=/–entity-has-image-id=/ --entity-has-artefact-insert-fn to compass add lookup_entity, mirroring entity_org's --entity-<knob> convention; the three frontmatter keywords were previously hardcoded false in doc_lookup_entity.org.mustache with no way to set them at all. Verified end to end via the real CLI with flags set and unset.

Compound natural key support was discovered mid-task to be a much larger change (org_loader.py's primary_key parsing and sql_schema_table_create.mustache's ~20+ single-column references, shared with plain table models) and was descoped to Support compound natural keys in lookup_entity/table SQL templates. subject_area will model domain_name as a plain Column for now.

Emacs 29.3 (Org mode 9.6.15)