feat(schema): declare allow_prefix on IPHost attributes and publish it [INFP-551]
This PR is much smaller than the line count. ~80% of the lines are generated changes to frontend and openapi schemas
spec documents are on the base branch infp-551-bare-ip-attribute if you want to read 20,000 words of planning documentation
Stack position: 1 of 5. Base is the feature branch infp-551-bare-ip-attribute, which carries only the
specification documents. See dev/specs/infp-551-bare-ip-attribute/pr-split-plan.md for the full split.
Companion SDK pull request: opsmill/infrahub-sdk-python#1220 — this PR pins its commit, and it must
merge first. See Submodule dependency below for why the dependency is load-bearing rather than cosmetic.
Why
Declare that an IPHost attribute holds a bare address, and publish that declaration through every
generated contract. This PR establishes the vocabulary; it deliberately changes no behaviour. How a
value is stored, returned, or looked up is untouched here and arrives in PRs 2 and 3.
What changed
IPHostAttributeParameters.allow_prefix(defaultTrue, so existing attributes are unaffected),
registered per-kind so the field is unreachable on other kinds by construction rather than merely
validated away. ClassifiedUpdateSupport.NOT_SUPPORTED— it cannot be toggled once the attribute
exists, because that would reinterpret stored data.IPHostAttributeSchema, registered inattribute_schema_class_by_kind. That registration is
load-bearing:basenode_schema.pyupgrades every attribute to its per-kind class, which is what makes
parameters.allow_prefixreachable from the attribute at all.- A reverse guard so
IPHostAttributeParametersattached to a non-IPHostkind is refused. reject_prefixed_default_value: adefault_valuecarrying a prefix on a declared attribute is
rejected, not rewritten. Schema authoring is deliberate and low-volume, so reporting the mismatch
beats silently normalising it — deliberately unlike a node value, where a redundant host mask is
accepted and normalised because bulk data entry is where leniency earns its keep. Rejecting during
attribute validation also means a subnet prefix is reported once rather than by both the attribute model
and the default-value validation.- The shared test fixture, as typed schema models, with the payload dict derived from the model so one
definition of the kind serves both shapes. - Regenerated contracts:
schema/openapi.json, the frontend REST types, and the generated schema module.
Why these pieces cannot be split further
Three couplings make this one atomic unit — any subset leaves CI red:
- The submodule bump needs the generator formatting fix.
backend.generateemits the SDK's
AttributeSchemaRead/Writeunion on one line; the committed SDK file is ruff-wrapped. Below 120
characters they agree — addingIPHostAttributeWritepushes it over, sobackend-validate-generated
sees a formatting-only diff. Hence the thirdruff formatpass intasks/backend.py. - Regenerating the REST types needs the frontend mirror fix.
IPHostAttributeReadjoins the attribute
discriminated union intypes.generated.ts, andentities/schema/domain/model/schema.tshand-mirrors
that union. Without the new member: 46 new TypeScript errors andbetterer cifails. - The schema-type unit tests need the fixture, which is why it lands here rather than with the
behavioural tests in PR 2.
Submodule dependency
Points python_sdk at 89e406a on SDK branch infp-551-bare-ip-attribute, the head of
opsmill/infrahub-sdk-python#1220 — pushed, and a pure fast-forward from the 681b458c that
release-1.11 currently pins, so it reverts nothing.
The dependency is load-bearing rather than cosmetic: SchemaLoadAPI inherits the SDK's generated write
models, so without IPHostAttributeWrite an IPHost attribute matches GenericAttributeWrite, whose
parameters is field-less with extra="ignore" — allow_prefix would be silently dropped from every
schema-load payload.
The pointer is provisional until the SDK PR merges, at which point it must be re-pinned to the merged
commit and confirmed an ancestor of origin/infrahub-develop.
How to review
Four hand-written files carry the whole change:
core/schema/attribute_parameters.py, core/schema/attribute_schema.py,
core/schema/definitions/internal.py, and tasks/backend.py. Everything else is registration, the
fixture, tests, or generated output.
The question worth your attention: is allow_prefix modelled in the right place? Per-kind parameters
keep the schema contract properly typed — the alternative, a field on AttributeSchema, would be reachable
on every kind. The generated diff should be confined to the parameters type union; anything wider is a
mistake upstream of it.
Known limitation, deliberate for v1
Changing an attribute's kind away from IPHost silently drops the declaration. Accepted for this
release and pinned by a test in PR 2, so that a future change to it is a decision rather than an accident.