Skip to content

PQA029 — Natural-id entity must not declare owner

An entity keyed by id: also declares owner:.

Ownership steers identity resolution: for a person-owned entity the framework resolves which allocated slot belongs to which person, for a shared entity it resolves one row used by many.

An entity keyed by id: needs none of that. Its natural key is the pairing — a card number is the same card number regardless of who holds it, and the differ matches on the value itself.

- entity: Card
  id: card_number
  owner: person           # nothing to resolve

Why the build refuses this

The declaration has no effect and reads as though it does. Someone maintaining the model later takes owner: person as a statement about how the entity is paired, and it is not.

It usually hides a real question. owner: on a natural-id entity is often written because per-person behaviour was expected. If that behaviour matters, the entity is allocated, not natural-keyed — and the addressing needs revisiting, not the ownership.

How to fix it

Delete the owner: line. Pairing by the natural key is already what the entity does.

If per-person slot resolution is genuinely needed, change the addressing to address: uint with a range and let ownership apply to the allocated slot.

If you disagree with a report

Do not suppress it. A wrong report is a bug in the check — report it with the YAML that triggered it.