Skip to content

PQA026 — Type identity requires a singleton child

A type keyed by identity: type is not declared as the only child of its parent.

identity: type says: there is exactly one of these under its parent, so its type alone identifies it. A door that always accompanies its module, a single output on a controller — nothing else is needed to re-pair them across discoveries.

That claim holds only if the parent really permits one. max_siblings: 1 is where it is stated.

- type_id: Door
  identity: type
  parents:
    Module:
      max_siblings: 4        # four doors, one type-only key
      required: true

Why the build refuses this

A type-only key collides with itself. Four doors under one module all carry the identical key. Re-pairing cannot tell them apart, so discovery either overwrites one Thing repeatedly or creates duplicates.

Every parent relationship has to hold the claim. The check reports each parent whose max_siblings is not 1 — a type may be a singleton under one parent and not under another, and only the second is a defect.

How to fix it

Declare the singleton where it is true.

parents:
  Module:
    max_siblings: 1

Or key the type by a property instead. When several instances genuinely coexist, they differ in something the hardware determines — an address, a port, a channel. That property is the identity:

identity: [address]

What is not reported

A property-keyed type. identity: [address] is scoped by its properties, and this rule does not apply.

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.