cs-image-system-contract 0.1.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- cs_image_system_contract-0.1.4/.gitignore +26 -0
- cs_image_system_contract-0.1.4/LICENSE +202 -0
- cs_image_system_contract-0.1.4/PKG-INFO +244 -0
- cs_image_system_contract-0.1.4/README.md +229 -0
- cs_image_system_contract-0.1.4/pyproject.toml +33 -0
- cs_image_system_contract-0.1.4/src/cs_image_system/contract/__init__.py +32 -0
- cs_image_system_contract-0.1.4/src/cs_image_system/contract/assets.py +230 -0
- cs_image_system_contract-0.1.4/src/cs_image_system/contract/constants.py +208 -0
- cs_image_system_contract-0.1.4/src/cs_image_system/contract/core.py +262 -0
- cs_image_system_contract-0.1.4/src/cs_image_system/contract/executables.py +55 -0
- cs_image_system_contract-0.1.4/src/cs_image_system/contract/field_kinds.py +96 -0
- cs_image_system_contract-0.1.4/src/cs_image_system/contract/fields.py +101 -0
- cs_image_system_contract-0.1.4/src/cs_image_system/contract/group.py +117 -0
- cs_image_system_contract-0.1.4/src/cs_image_system/contract/hcl.py +74 -0
- cs_image_system_contract-0.1.4/src/cs_image_system/contract/image.py +61 -0
- cs_image_system_contract-0.1.4/src/cs_image_system/contract/instance.py +23 -0
- cs_image_system_contract-0.1.4/src/cs_image_system/contract/lifecycle.py +71 -0
- cs_image_system_contract-0.1.4/src/cs_image_system/contract/lifecycles.py +86 -0
- cs_image_system_contract-0.1.4/src/cs_image_system/contract/metadata.py +54 -0
- cs_image_system_contract-0.1.4/src/cs_image_system/contract/model_config.py +23 -0
- cs_image_system_contract-0.1.4/src/cs_image_system/contract/modification.py +36 -0
- cs_image_system_contract-0.1.4/src/cs_image_system/contract/names.py +33 -0
- cs_image_system_contract-0.1.4/src/cs_image_system/contract/operating_system.py +104 -0
- cs_image_system_contract-0.1.4/src/cs_image_system/contract/runtime.py +155 -0
- cs_image_system_contract-0.1.4/src/cs_image_system/contract/state.py +136 -0
- cs_image_system_contract-0.1.4/src/cs_image_system/contract/storage.py +49 -0
- cs_image_system_contract-0.1.4/src/cs_image_system/contract/testing.py +175 -0
- cs_image_system_contract-0.1.4/src/cs_image_system/contract/user.py +59 -0
- cs_image_system_contract-0.1.4/src/cs_image_system/py.typed +0 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
.envrc
|
|
2
|
+
# Okta API-integration key material -- never commit
|
|
3
|
+
.private_key.pem
|
|
4
|
+
.private_key.json
|
|
5
|
+
.public_key.json
|
|
6
|
+
*.pem
|
|
7
|
+
__pycache__/
|
|
8
|
+
*.py[cod]
|
|
9
|
+
.pytest_cache/
|
|
10
|
+
*.egg-info/
|
|
11
|
+
dist/
|
|
12
|
+
build/
|
|
13
|
+
.venv/
|
|
14
|
+
.DS_Store
|
|
15
|
+
packages/**/*.code-workspace
|
|
16
|
+
trial
|
|
17
|
+
tfmodules/tftest
|
|
18
|
+
YAML_DUMP.yaml
|
|
19
|
+
.obsidian
|
|
20
|
+
.tofu-plugin-cache/
|
|
21
|
+
_uncommitted/
|
|
22
|
+
target/
|
|
23
|
+
# never publishable, whatever the root (stage 35 refuses them; stage 40's publish-tree checks the policy)
|
|
24
|
+
tfplan
|
|
25
|
+
*.tfstate
|
|
26
|
+
*.tfstate.backup
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: cs-image-system-contract
|
|
3
|
+
Version: 0.1.4
|
|
4
|
+
Summary: The plugin contract of cs-image-system: the protocols, constants and data carriers a plugin is written against, with no dependency on the core
|
|
5
|
+
Project-URL: Repository, https://github.com/infrastructurebuilder/cs-image-system-3
|
|
6
|
+
Project-URL: Documentation, https://github.com/infrastructurebuilder/cs-image-system-3/blob/develop/docs/OPERATIONS.md
|
|
7
|
+
Project-URL: Package README, https://github.com/infrastructurebuilder/cs-image-system-3/blob/develop/packages/contract/README.md
|
|
8
|
+
Author-email: Mykel Alvis <mykelalvis@infrastructurebuilder.org>
|
|
9
|
+
License-Expression: Apache-2.0
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Requires-Python: >=3.13
|
|
12
|
+
Requires-Dist: packaging>=26.2
|
|
13
|
+
Requires-Dist: pydantic>=2.13
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
|
|
16
|
+
# cs-image-system-contract
|
|
17
|
+
|
|
18
|
+
The plugin contract: the one package a plugin is written against. It
|
|
19
|
+
carries the protocols a model and a builder satisfy, the constants and
|
|
20
|
+
field helpers a model is declared with, the lifecycle phases a hook keys
|
|
21
|
+
on, and the data carriers a hook returns. It depends on no other package of
|
|
22
|
+
the system -- `pydantic` and `packaging` only -- and the core
|
|
23
|
+
([base](../base/README.md)) depends on it, never the reverse: the contract
|
|
24
|
+
is upstream, the core conforms to it, and a new hook is a contract change
|
|
25
|
+
first. The core's base classes are the convenient implementation of the
|
|
26
|
+
contract, not the contract itself; a class that satisfies the protocols
|
|
27
|
+
structurally is a first-class plugin, and
|
|
28
|
+
[`testing.assert_conforms`](src/cs_image_system/contract/testing.py) is the
|
|
29
|
+
check that says so. Stage 30 made the package (2026-10-29); until then the
|
|
30
|
+
protocols lived inside `base`, imported the registry, and a plugin's
|
|
31
|
+
`pyproject.toml` depended on the CLI host.
|
|
32
|
+
|
|
33
|
+
One module per kind of builder, over a shared core:
|
|
34
|
+
|
|
35
|
+
| Module | Carries |
|
|
36
|
+
| --- | --- |
|
|
37
|
+
| [`core`](src/cs_image_system/contract/core.py) | `PluginArtifactProtocol` (`csis_name`, `csis_classifier`), `NameTypedProtocol`, `PluginMetadataProtocol`, `BuilderModelProtocol` and `RuntimeEnabledBuilderModelProtocol` (what the core reads of any builder model), `BuilderProtocol` (the six universal hooks, the three finalize-phase hooks, `finalize`, the paths), and the three markers the orchestrator dispatches on: `SelfInjectedNameProtocol`, `SubItemOverrideProtocol`, `ParentPropertyHoldingProtocol`. |
|
|
38
|
+
| [`runtime`](src/cs_image_system/contract/runtime.py), [`operating_system`](src/cs_image_system/contract/operating_system.py), [`storage`](src/cs_image_system/contract/storage.py), [`image`](src/cs_image_system/contract/image.py), [`instance`](src/cs_image_system/contract/instance.py), [`modification`](src/cs_image_system/contract/modification.py), [`group`](src/cs_image_system/contract/group.py), [`user`](src/cs_image_system/contract/user.py), [`state`](src/cs_image_system/contract/state.py) | One `<Kind>BuilderModelProtocol` and one `<Kind>BuilderProtocol` per kind, with exactly the attributes and hooks the core reads. `state` also carries the backend seam: `StateLocation`, `BackendRegistration`, `BackendKindProtocol` and `StateBackendModelProtocol`. `image` carries the provider-specific image's two enums. |
|
|
39
|
+
| [`metadata`](src/cs_image_system/contract/metadata.py) | `PluginMetadata`, the record a plugin's entry point returns. |
|
|
40
|
+
| [`constants`](src/cs_image_system/contract/constants.py) | `VCT` (the classifications), the sentinels (`DEFAULT`, `SELF`, `NONE`, `OOPS_DEFAULTS`), the field metadata keys, `PLUGIN_TYPES` (the entry-point groups), the collection names, the file names a run writes. |
|
|
41
|
+
| [`model_config`](src/cs_image_system/contract/model_config.py) | `CSIS_MODEL_CONFIG`, the one pydantic configuration every model is declared under (unknown keys are refused). |
|
|
42
|
+
| [`fields`](src/cs_image_system/contract/fields.py), [`field_kinds`](src/cs_image_system/contract/field_kinds.py) | `fk_field`, `templated_field`, `deferred_list_field`, `deferred_list_fk_field`, `parent_field`; the open registry of field kinds a plugin may extend. |
|
|
43
|
+
| [`lifecycle`](src/cs_image_system/contract/lifecycle.py), [`lifecycles`](src/cs_image_system/contract/lifecycles.py) | `ExecutionLifecyclePhase`; `Lifecycle`, `LifecycleSpec` and the phases and builder classifications each built-in lifecycle owns. |
|
|
44
|
+
| [`assets`](src/cs_image_system/contract/assets.py), [`executables`](src/cs_image_system/contract/executables.py) | `Asset`, `AssetSet` (what `generate_items_*` returns); `ExecutableProtocol`, `CFExecutables` (what `get_commands_to_run_*` returns). |
|
|
45
|
+
| [`names`](src/cs_image_system/contract/names.py), [`hcl`](src/cs_image_system/contract/hcl.py) | `safe_name`, `super_safe_name`; `HclRaw`, `hcl_expr`, `render_module_call`. |
|
|
46
|
+
| [`testing`](src/cs_image_system/contract/testing.py) | `assert_conforms(cls, protocol)` and `conformance_problems`. |
|
|
47
|
+
|
|
48
|
+
### What moved where
|
|
49
|
+
|
|
50
|
+
Stage 30 moved these from the core into the package. Every old path but
|
|
51
|
+
`cs_image_system.base.protocols` still resolves: the module that held a
|
|
52
|
+
name re-exports it from here (the shims), kept on purpose while the
|
|
53
|
+
package is provisional. Removing the shims is the commitment to the
|
|
54
|
+
contract, and is done together with moving the package to a repository
|
|
55
|
+
of its own; until then an undo of the stage is a swap of which side
|
|
56
|
+
holds the bodies, with no import rewritten anywhere.
|
|
57
|
+
|
|
58
|
+
| Was | Is now |
|
|
59
|
+
| --- | --- |
|
|
60
|
+
| `base.constants` (all of it: `VCT`, the sentinels, the field metadata keys, `PLUGIN_TYPES`, the collection and file names) | `contract.constants` |
|
|
61
|
+
| `base.models.model_config.CSIS_MODEL_CONFIG` | `contract.model_config` |
|
|
62
|
+
| `base.helpers.field_helpers` (`fk_field`, `templated_field`, `deferred_list_field`, `deferred_list_fk_field`, `lookup_dataclass_field`) | `contract.fields`, plus the new `parent_field` |
|
|
63
|
+
| `base.helpers.field_kinds` (the field-kind registry) | `contract.field_kinds` |
|
|
64
|
+
| `base.lifecycle.ExecutionLifecyclePhase` | `contract.lifecycle` |
|
|
65
|
+
| `base.lifecycles`: `Lifecycle`, `LifecycleSpec`, `LifecycleLike`, `LIFECYCLE_ORDER`, `LIFECYCLE_PHASES`, `LIFECYCLE_BUILDER_VCTS` (the registry functions stay in `base`) | `contract.lifecycles` |
|
|
66
|
+
| `base.basic.asset`: `Asset`, `AssetSet` (`sort_and_write` now takes the generation path) | `contract.assets` |
|
|
67
|
+
| `base.models.executable_adds.CFExecutables` (now generic over `ExecutableProtocol`) | `contract.executables` |
|
|
68
|
+
| `base.protocols.plugin_metadata`: `PluginArtifactProtocol`, `PluginMetadataProtocol`; `base.protocols.name_typed_protocol`: `NameTypedProtocol`, `SelfInjectedNameProtocol`, `SubItemOverrideProtocol`; `base.protocols.builder_model_protocol`: `BuilderModelProtocol`; `base.protocols.parent_property_holding_protocol`: `ParentPropertyHoldingProtocol` (deleted, no shim; their default bodies are `base.models.mixins` and the base classes) | `contract.core` |
|
|
69
|
+
| `base.protocols.state_management.StateManagementRootProtocol` (zero implementers) | deleted |
|
|
70
|
+
| `base.utils.safe_name`, `super_safe_name` | `contract.names` |
|
|
71
|
+
| `base.utils.HclRaw`, `hcl_expr`, `render_module_call` | `contract.hcl` |
|
|
72
|
+
| `base.models.provider_specific_image.PSIState`, `PSISourceKind`, `psi_key` | `contract.image` |
|
|
73
|
+
| `hashicorp_utils.collector.StateLocation`, `BackendRegistration`, the `BackendKind` protocol (still importable from the collector) | `contract.state` (`BackendKindProtocol`; `BackendWithoutKind` is new) |
|
|
74
|
+
| nothing: new | `contract.metadata.PluginMetadata`, the kind protocols, `contract.testing` |
|
|
75
|
+
|
|
76
|
+
The protocols carry no implementation. Where a default body existed
|
|
77
|
+
(`global_id`, `get_classification`, `get_self_injected_name`, the parent
|
|
78
|
+
reference's registry lookup) it lives in the core's base classes and
|
|
79
|
+
mixins. The kind modules import `core` and only the kinds they declare they
|
|
80
|
+
read (`runtime` reads `image` for the provider-specific image's enums);
|
|
81
|
+
[tests/test_v2_contract.py](../../tests/test_v2_contract.py) holds that
|
|
82
|
+
direction, holds the package to importing nothing from the core, and runs
|
|
83
|
+
`assert_conforms` over every base class and every built-in plugin's models
|
|
84
|
+
and builders.
|
|
85
|
+
|
|
86
|
+
## Writing a plugin
|
|
87
|
+
|
|
88
|
+
A plugin is a Python distribution with an entry point in the group
|
|
89
|
+
`cs_image_system.plugins.<kind>` (`PLUGIN_TYPES` in `constants`: `runtime`,
|
|
90
|
+
`state`, `modification`, `storage`, `group`, `user`, `image`, `os`,
|
|
91
|
+
`instance`, `other`). The entry point loads to a zero-argument callable
|
|
92
|
+
that returns one `PluginMetadata` or a list of them.
|
|
93
|
+
|
|
94
|
+
1. **Depend on the contract.** In `pyproject.toml`, `dependencies =
|
|
95
|
+
["cs-image-system-contract>=X"]`, with `X` the first release that
|
|
96
|
+
carries the contract (0.1.3 and before do not): a floor, not a pin --
|
|
97
|
+
the workspace's own packages pin each other at `==` because they
|
|
98
|
+
release together, an external plugin does not. Add `cs-image-system-base` only
|
|
99
|
+
if the plugin subclasses the core's base classes (every built-in plugin
|
|
100
|
+
does; it is the convenient way, not the required one). Never depend on
|
|
101
|
+
`cs-image-system-system`, the CLI host.
|
|
102
|
+
2. **Write the model**: a pydantic dataclass, `@dataclass(kw_only=True,
|
|
103
|
+
config=CSIS_MODEL_CONFIG)`, that satisfies the kind's
|
|
104
|
+
`<Kind>BuilderModelProtocol`. The universal fields are `name`, `type`
|
|
105
|
+
(the field is `type_`, aliased `type`), `description`, `aliases`,
|
|
106
|
+
`executable`, `is_default`, `config`, `gitignore`, `tags`, with the
|
|
107
|
+
`get_*` readers and `finalize`; the kind's module says what more the
|
|
108
|
+
core reads. The class methods `csis_name()` (the value a YAML `type:`
|
|
109
|
+
names) and `csis_classifier()` (`VCT.<KIND>_BUILDER_MODEL`) are how the
|
|
110
|
+
registry resolves a `type:` to the class. A foreign key to another
|
|
111
|
+
builder is `fk_field(target=VCT....)`; a value the resolver renders is
|
|
112
|
+
`templated_field(...)`; an item that belongs to a builder declares
|
|
113
|
+
`_model_id = parent_field(VCT....)`.
|
|
114
|
+
3. **Write the builder**: a class that satisfies the kind's
|
|
115
|
+
`<Kind>BuilderProtocol`: the universal surface in `BuilderProtocol`
|
|
116
|
+
(`generate_items_{before,during,after}` return an `AssetSet`,
|
|
117
|
+
`get_commands_to_run_{before,during,after}` a `CFExecutables`,
|
|
118
|
+
`pre_finalize_phase`/`post_finalize_phase`/`post_failed_phase` fire
|
|
119
|
+
around a phase's deferred commands, `finalize` once the configuration
|
|
120
|
+
is complete) plus the kind's domain hooks, and the same two class
|
|
121
|
+
methods, `csis_classifier()` returning `VCT.<KIND>_BUILDER`. The core's
|
|
122
|
+
`BuilderBase` and `<Kind>BuilderBase` implement every hook with a
|
|
123
|
+
default; subclass them to override only what the plugin does.
|
|
124
|
+
4. **Return the metadata**: `PluginMetadata(services={KEY: [Model,
|
|
125
|
+
Builder]}, builders_for_models={Model: Builder})`, where `KEY` is the
|
|
126
|
+
`csis_name`. Item models a plugin injects under a classification go in
|
|
127
|
+
`injected_models`.
|
|
128
|
+
5. **Prove it.** In the plugin's tests, `assert_conforms(Model,
|
|
129
|
+
<Kind>BuilderModelProtocol)` and `assert_conforms(Builder,
|
|
130
|
+
<Kind>BuilderProtocol)`; then a dry `cs-image-system run --all` over a
|
|
131
|
+
tree that declares the plugin's `type:`.
|
|
132
|
+
|
|
133
|
+
A state backend is the smallest kind: a model that answers
|
|
134
|
+
`to_backend_registration()` with a `BackendRegistration` naming its type's
|
|
135
|
+
`BackendKindProtocol` (where a workspace's state lives, the settings the
|
|
136
|
+
workspace's backend file carries, the settings a consumer's remote-state
|
|
137
|
+
data source carries), and a builder that emits nothing; the core hands
|
|
138
|
+
the registration to the terraform collector once the state backends are
|
|
139
|
+
loaded. The [contract example plugin](../contract-example-plugin/README.md)
|
|
140
|
+
is exactly that, written against this package alone with nothing of the
|
|
141
|
+
core, and the proof the bar runs; the
|
|
142
|
+
[local state plugin](../local-state-plugin/README.md) is the same kind
|
|
143
|
+
written the convenient way on the base classes; the
|
|
144
|
+
[dummy plugin](../dummy-plugin/README.md) is the template for a group or
|
|
145
|
+
user builder and for a hook plugin.
|
|
146
|
+
|
|
147
|
+
Not in the contract yet, so a plugin that needs them depends on `base`:
|
|
148
|
+
the run context (`GlobalTypeContext`, reached today through a base
|
|
149
|
+
builder's `_get_context()`; its protocol is a later stage), the
|
|
150
|
+
`cs_image_system.plugins.hooks` entry point (`HookSet`, typed on the
|
|
151
|
+
context) and the `cs_image_system.bootstrap` entry point (the bootstrap's
|
|
152
|
+
sections).
|
|
153
|
+
|
|
154
|
+
## Prerequisites and integration
|
|
155
|
+
|
|
156
|
+
Nothing outside Python: the package needs Python 3.13 or later, `pydantic`
|
|
157
|
+
and `packaging`, and no account, tool, credential or network. A plugin
|
|
158
|
+
finds it by import (`cs_image_system.contract.<module>`); the core finds
|
|
159
|
+
it the same way and pins it at its own version.
|
|
160
|
+
|
|
161
|
+
## Configuration reference
|
|
162
|
+
|
|
163
|
+
The contract reads no YAML of its own. What it declares about every
|
|
164
|
+
builder's entry, read by the core through `BuilderModelProtocol`:
|
|
165
|
+
|
|
166
|
+
| Field | Type | Default | Meaning |
|
|
167
|
+
| --- | --- | --- | --- |
|
|
168
|
+
| `name` | str | required | The builder's name; `safe_name` normalises it, `display_name` keeps what was written. Not a word in `OOPS_DEFAULTS`. |
|
|
169
|
+
| `type` | str | required | The plugin's `csis_name`, which the registry resolves to the model class; an alias resolves to the canonical name. |
|
|
170
|
+
| `description` | str or null | null | Free text. |
|
|
171
|
+
| `aliases` | set of str | empty | Other names the builder answers to. |
|
|
172
|
+
| `executable` | str or null | null | The `executables:` entry the builder runs, version-checked at validation; null for none. |
|
|
173
|
+
| `is_default` | bool | false | The default builder of its classification; one per classification. |
|
|
174
|
+
| `config` | mapping | empty | The plugin's own settings. |
|
|
175
|
+
| `gitignore` | list of str | empty | Entries the builder adds to the emitted `.gitignore`. |
|
|
176
|
+
| `tags` | mapping of str | empty | Tags every resource the builder emits carries. |
|
|
177
|
+
|
|
178
|
+
The kind modules say what more each kind reads (a runtime's defaults and
|
|
179
|
+
credentials, an OS builder's family and query, a user builder's email
|
|
180
|
+
templates); the plugin's own README is the reference for the fields it
|
|
181
|
+
adds. Unknown keys are refused by `CSIS_MODEL_CONFIG` (`extra="forbid"`).
|
|
182
|
+
The sentinels `default`, `self`, `none`, the empty string and null
|
|
183
|
+
(`OOPS_DEFAULTS`) mean "not set" wherever a value is read, so nothing may
|
|
184
|
+
be named after one of them. Variations: none; the contract behaves the same
|
|
185
|
+
under a dry run and a real one, on every runtime.
|
|
186
|
+
|
|
187
|
+
## What it tests and verifies
|
|
188
|
+
|
|
189
|
+
- `assert_conforms(cls, protocol)` (`testing`): every member the protocol
|
|
190
|
+
declares exists on the class, every method takes the protocol's
|
|
191
|
+
parameters by name and kind in order (an implementation may add
|
|
192
|
+
parameters with defaults, or take `*args` and `**kwargs`), a property is
|
|
193
|
+
a property or a dataclass field, a class method a class method.
|
|
194
|
+
Annotations are not compared here; pyright does that where a class
|
|
195
|
+
lists its protocol as a base (its override check,
|
|
196
|
+
`reportIncompatibleMethodOverride`, is on as an error since hygiene XIX),
|
|
197
|
+
and a protocol a class lists as a base is the question, not an answer,
|
|
198
|
+
so its stubs never count. The core's
|
|
199
|
+
[tests/test_v2_contract.py](../../tests/test_v2_contract.py) runs it
|
|
200
|
+
over every base class and every built-in plugin's models and builders at
|
|
201
|
+
`just test`; a plugin's own tests should run it over theirs. The verdict
|
|
202
|
+
is an `AssertionError` naming every shortfall.
|
|
203
|
+
- The import direction, in the same test: the package's sources import
|
|
204
|
+
nothing from `cs_image_system.base`, `.system` or `.hashicorp_utils`,
|
|
205
|
+
and each kind module imports only `core` and the kinds it declares.
|
|
206
|
+
[tests/test_v2_package_metadata.py](../../tests/test_v2_package_metadata.py)
|
|
207
|
+
holds the same line from the manifest: the package declares exactly the
|
|
208
|
+
third-party distributions it imports and reaches no sibling.
|
|
209
|
+
- At load, the loader checks what an entry point returned with
|
|
210
|
+
`isinstance(..., PluginMetadataProtocol)` and logs an error for anything
|
|
211
|
+
else; the registry refuses a `csis_name` registered twice under one
|
|
212
|
+
classification (`Type Collision`).
|
|
213
|
+
|
|
214
|
+
## When it fails
|
|
215
|
+
|
|
216
|
+
- `AssertionError: <class> does not conform to <protocol>: <member>: ...`
|
|
217
|
+
from `assert_conforms`: the class lacks a member or a method's
|
|
218
|
+
parameters differ from the protocol's. Add the member or match the
|
|
219
|
+
signature; the protocol is the specification. If the shortfall is in a
|
|
220
|
+
core base class, the contract changed and the core did not follow: that
|
|
221
|
+
is the test doing its job, and the fix is in `base`.
|
|
222
|
+
- `Plugin <name> did not return a valid PluginMetadataProtocol instance`
|
|
223
|
+
in the log at load, and the plugin's types unknown to every `type:`: the
|
|
224
|
+
entry point returned something other than a `PluginMetadata` (or a list
|
|
225
|
+
of them) -- a class instead of an instance, a dict, nothing.
|
|
226
|
+
- `Type Collision: <name>` at load: two plugins register one `csis_name`
|
|
227
|
+
under one classification; rename one.
|
|
228
|
+
- `BackendWithoutKind` (`state`): a `BackendRegistration` was built without
|
|
229
|
+
its `kind`; the model's `to_backend_registration()` must name the type's
|
|
230
|
+
`BackendKindProtocol` object.
|
|
231
|
+
- `<Model> ... Extra inputs are not permitted` at load: a YAML key the
|
|
232
|
+
model does not declare (`CSIS_MODEL_CONFIG` refuses unknown keys); the
|
|
233
|
+
plugin's README names the fields it reads.
|
|
234
|
+
- `ModuleNotFoundError: No module named 'cs_image_system.base.protocols'`
|
|
235
|
+
from a plugin written before stage 30 running on this tree: the
|
|
236
|
+
protocols moved here, with no shim; import them from
|
|
237
|
+
`cs_image_system.contract.core`.
|
|
238
|
+
|
|
239
|
+
No failure of this package has happened in the field yet (2026-10-29).
|
|
240
|
+
|
|
241
|
+
## Related
|
|
242
|
+
|
|
243
|
+
- [docs/PLUGINS.md](../../docs/PLUGINS.md), the index of every package.
|
|
244
|
+
- [base](../base/README.md), the core that implements the contract.
|