Repository navigation
Conversation
* chore: regenerate protocols for the number pool range kind CoreNumberPool gains a ranges relationship and its start_range and end_range become optional; the new CoreNumberPoolRange kind is added. Generated from the Infrahub core models, not written by hand. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TgXERZQRu7W5V8zCyUEAVA * test(protocols): regenerate golden fixtures for the number pool range kind The generator builds its import line by introspecting infrahub_sdk.protocols, so regenerating that module in 100d6b3 to add CoreNumberPoolRange changed the output for every user schema. The golden fixtures still carried the previous import line, failing test_render_user_schema_matches_golden. Only line 9 changes in each fixture, gaining CoreNumberPoolRange and CoreNumberPoolRangeSync. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
…d schema models (#1402) * feat(schema): accept number pool ranges in the generated schema models NumberPool attribute parameters carry `ranges`, a list of start/end ranges with an optional weight, next to the `start_range`/`end_range` shorthand. The shorthand is optional and deprecated, so an attribute declared without any range no longer receives a default range. Bookkeeping fields on a range are reported as read-only like on every other value model. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * docs(schema): state the default of a missing number pool bound The generated descriptions of start_range and end_range now say that a missing start defaults to 1 and a missing end to the largest supported number when only the other bound is set. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat(schema): accept the number pool allocation_scope in the generated schema models Regenerate the schema models and protocols for Infrahub's new `allocation_scope` field: `NumberPoolParametersRead`/`Write` gain `allocation_scope: list[str] | None`, and `CoreNumberPool` gains the matching optional List attribute. Without it, a schema read from Infrahub and loaded back is rejected because the field is unknown. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * drop changelog --------- Co-authored-by: Pol Michel <polmichel29@gmail.com> Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## infrahub-develop #1412 +/- ##
====================================================
- Coverage 87.14% 86.82% -0.32%
====================================================
Files 153 152 -1
Lines 16493 14775 -1718
Branches 2417 1982 -435
====================================================
- Hits 14372 12829 -1543
+ Misses 1493 1382 -111
+ Partials 628 564 -64
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 15 files with indirect coverage changes 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Infrahub 1.12 lets a number pool allocate from several weighted ranges, and divide its space by an allocation scope. A user declares both in a schema file, so neither is usable until the generated write models accept them and the generated read models return them.
The four changed modules are generated from Infrahub's own core schema definitions by
invoke backend.generate, which writes into this submodule. The definitions they come from live on the Infrahub branchfeature-number-pools-1.12and are not on Infrahubdevelopyet.Non-goal: this branch adds no behaviour of its own. Allocation across ranges and the scope check are implemented in the Infrahub backend.
What changed
Behavioural changes:
parameters.rangeson a NumberPool attribute: a list ofstart/endranges with an optionalweight. Until now the schema load endpoint dropped the value, because the write models setextra="ignore".parameters.allocation_scope: the fields of the kind that divide the pool's space.start_rangeandend_rangebecome optional and carry no default. A NumberPool attribute declared without any range is submitted as such, instead of receiving 1 to 9223372036854775807. Both stay accepted, deprecated in favour ofranges.rangesandallocation_scope.infrahub_sdk.protocolsexposesCoreNumberPoolRangeandCoreNumberPoolRangeSync, andCoreNumberPoolcarriesrangesandallocation_scope.What stayed the same: no hand-written SDK module changed. The four changed modules are generated, and
infrahub_sdk/protocols_generator/is untouched.Commits:
How to review
Reviewing the generated modules on their own says little. The source of truth is
backend/infrahub/core/schema/definitions/core/resource_pool.pyandbackend/infrahub/core/schema/attribute_parameters.pyon the Infrahub branchfeature-number-pools-1.12.Three consumers in the Infrahub backend read these models directly:
backend/infrahub/api/schema.py—SchemaLoadAPIsubclassesInfrahubSchemaWrite.backend/infrahub/schema/read_schema.py—build_read_schemaprojects ontoBaseNodeSchemaRead.backend/infrahub/core/schema/write_json_schema.py— readsREAD_ONLY_FIELDSandInfrahubSchemaWrite.How to test
From an Infrahub checkout pinning this branch, the generated files must match what the branch's definitions produce:
Impact & rollout
start_rangeandend_rangeare still accepted. Dropping their defaults changes what reaches the server for a NumberPool attribute declared without any range.git ls-treeand thevalidate_generatedtask intasks/backend.py] This branch should be merged in the same window as the Infrahub branchfeature-number-pools-1.12, not before it. Infrahubdeveloppins SDK commit2ac1179explicitly, so merging here does not break it immediately; but the first bump of that pin to the newinfrahub-developtip would failvalidate_generated, becausedevelop's core models do not declare these fields.Checklist
Assisted-by: opsmill-dev-pr 0.2.0
🤖 Generated with Claude Code
Summary by cubic
The generated SDK models now accept
parameters.rangesandparameters.allocation_scopeon NumberPool attributes, so a schema file can declare several weighted ranges and divide a pool's space by kind fields.start_range/end_rangebecome optional and deprecated; a NumberPool declared without any range is submitted as such, instead of receiving a default 1 to 9223372036854775807.rangesandallocation_scope, andinfrahub_sdk.protocolsgainsCoreNumberPoolRange/CoreNumberPoolRangeSync.Rollout
feature-number-pools-1.12, not before it. A subsequent pin bump on Infrahubdevelopwould failvalidate_generatedbecausedevelop's core models do not declare these fields.Written for commit 1bd89c8. Summary will update on new commits.