adopt-cli 0.3.0__py3-none-any.whl

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.
@@ -0,0 +1,134 @@
1
+ """Opening the configured store, in one place.
2
+
3
+ Every command that touches a store resolves its path the same way -- flag, then
4
+ `ADOPT_STORE_PATH`, then the project file, then the user file, then the default
5
+ (`adopt_cli.config`). A second resolution order in a second command is a second
6
+ answer to "which store am I looking at", and an operator who gets that wrong
7
+ reads a healthy store while a different one is on fire.
8
+
9
+ **Read-only unless the command actually writes.** `adopt freshness resolve`
10
+ writes nothing by contract and `adopt coverage recompute` writes only under
11
+ `--rebuild`, so the default open is read-only and a write attempt raises
12
+ `STORE_READ_ONLY` rather than succeeding somewhere unexpected.
13
+
14
+ **This is the only `adopt_cli` module permitted to reach `adopt_store`** (CR-36),
15
+ so every other way a command needs a store arrives here rather than growing a
16
+ second exemption -- including `adopt import`'s explicitly-named target store and
17
+ the `written_by` provenance string an export bundle records.
18
+ """
19
+
20
+ from collections.abc import Iterator
21
+ from contextlib import contextmanager
22
+ from pathlib import Path
23
+
24
+ from adopt_cli.config import resolve_all
25
+ from adopt_obs import AdoptError, ErrorCode
26
+ from adopt_store import open_store
27
+ from adopt_store.annex import SqliteAnnexRecords, open_annex
28
+ from adopt_store.api import SqliteStoreHandle, writer_identity
29
+
30
+ __all__ = [
31
+ "SqliteStoreHandle",
32
+ "configured_annex",
33
+ "configured_store_path",
34
+ "open_configured_store",
35
+ "open_for_migration",
36
+ "open_named_store",
37
+ "open_or_create_store",
38
+ "writer_identity",
39
+ ]
40
+
41
+ _STORE_KEY = "ADOPT_STORE_PATH"
42
+ _RUNTIME_KEY = "ADOPT_RUNTIME_PATH"
43
+
44
+
45
+ def configured_store_path(override: Path | None = None) -> Path:
46
+ """The store path a command should use, with the registry's resolution order.
47
+
48
+ Raises:
49
+ AdoptError: ``ADOPT_CONFIG_UNRESOLVED`` when no layer supplies a value.
50
+ The key carries a default, so this is unreachable in a normal tree
51
+ and is raised rather than defaulted anyway: silently inventing a
52
+ store path is how a command creates an empty database beside the
53
+ real one.
54
+ """
55
+ if override is not None:
56
+ return override
57
+ for resolution in resolve_all():
58
+ if resolution.key == _STORE_KEY and resolution.value:
59
+ return Path(resolution.value)
60
+ raise AdoptError(
61
+ ErrorCode.ADOPT_CONFIG_UNRESOLVED,
62
+ message=f"{_STORE_KEY} has no value in any configuration source",
63
+ hint=f"Pass --store, or set {_STORE_KEY}.",
64
+ )
65
+
66
+
67
+ def open_configured_store(
68
+ override: Path | None = None, *, read_only: bool = True
69
+ ) -> SqliteStoreHandle:
70
+ """Open the configured store. The caller closes it."""
71
+ return open_store(configured_store_path(override), read_only=read_only)
72
+
73
+
74
+ def open_or_create_store(override: Path | None = None) -> SqliteStoreHandle:
75
+ """The configured store, created at the current schema version if absent.
76
+
77
+ `adopt init`'s door, and the only one that creates. Every other command opens
78
+ what is already there -- which is why the parent directory is created here
79
+ and nowhere else: `.adopt/` not existing is the normal state before `init`
80
+ runs, and any later command finding it absent is reporting a real problem
81
+ rather than one it should quietly fix.
82
+ """
83
+ target = configured_store_path(override)
84
+ target.parent.mkdir(parents=True, exist_ok=True)
85
+ return open_store(target, migrate=True)
86
+
87
+
88
+ def open_for_migration(override: Path | None = None) -> SqliteStoreHandle:
89
+ """The configured store, opened writable with pending migrations applied.
90
+
91
+ `adopt store migrate`'s door. Forward-only, always: implementation spec §7.4
92
+ states the schema has no rollback and recovery is older code against a newer
93
+ store.
94
+ """
95
+ return open_store(configured_store_path(override), migrate=True)
96
+
97
+
98
+ @contextmanager
99
+ def configured_annex() -> Iterator[SqliteAnnexRecords]:
100
+ """The runtime annex at `ADOPT_RUNTIME_PATH`, opened for one call.
101
+
102
+ **Here rather than in the command that needs it**, for the reason this whole
103
+ module exists (CR-36): `no-raw-sqlite` follows indirect chains into
104
+ `adopt_cli` and exempts only this module by name, so a command reaching
105
+ `adopt_store.annex` directly breaks the contract. The seam itself never sees a
106
+ driver either -- it is handed an `AnnexRecords`, which this satisfies
107
+ structurally.
108
+
109
+ The annex is a **second store, outside `schema_version`** (contracts §12,
110
+ CR-08), which is why it does not go through `configured_store_path`: pointing
111
+ both at one resolution order is the coupling the ratification exists to
112
+ prevent.
113
+ """
114
+ for resolution in resolve_all():
115
+ if resolution.key == _RUNTIME_KEY and resolution.value:
116
+ with open_annex(Path(resolution.value)) as records:
117
+ yield records
118
+ return
119
+ raise AdoptError(
120
+ ErrorCode.ADOPT_CONFIG_UNRESOLVED,
121
+ message=f"{_RUNTIME_KEY} has no value in any configuration source",
122
+ hint=f"Set {_RUNTIME_KEY}. It carries agent-run idempotency and in-client "
123
+ f"audit, and is never exported.",
124
+ )
125
+
126
+
127
+ def open_named_store(path: Path, *, migrate: bool = False) -> SqliteStoreHandle:
128
+ """Open a store the caller named outright, bypassing the resolution order.
129
+
130
+ For `adopt import --into`, where the path is an argument rather than
131
+ configuration: an import target resolved from `ADOPT_STORE_PATH` would
132
+ restore a bundle over whichever store the shell happened to be pointing at.
133
+ """
134
+ return open_store(path, migrate=migrate)
@@ -0,0 +1,27 @@
1
+ Metadata-Version: 2.5
2
+ Name: adopt-cli
3
+ Version: 0.3.0
4
+ Summary: The adopt command surface: config resolution, JSON mode, exit codes.
5
+ Project-URL: Homepage, https://github.com/onboardux/onboard-core
6
+ Project-URL: Source, https://github.com/onboardux/onboard-core
7
+ Project-URL: Issues, https://github.com/onboardux/onboard-core/issues
8
+ Author: The Adopt Authors
9
+ License-Expression: Apache-2.0
10
+ License-File: LICENSE
11
+ License-File: NOTICE
12
+ Requires-Python: >=3.12
13
+ Requires-Dist: adopt-agent
14
+ Requires-Dist: adopt-const
15
+ Requires-Dist: adopt-coverage
16
+ Requires-Dist: adopt-detect
17
+ Requires-Dist: adopt-export
18
+ Requires-Dist: adopt-freshness
19
+ Requires-Dist: adopt-identity
20
+ Requires-Dist: adopt-obs
21
+ Requires-Dist: adopt-policy
22
+ Requires-Dist: adopt-scope
23
+ Requires-Dist: adopt-store
24
+ Requires-Dist: click<9,>=8
25
+ Requires-Dist: pyyaml<7,>=6
26
+ Requires-Dist: rich<15,>=13
27
+ Requires-Dist: typer<1,>=0.12
@@ -0,0 +1,26 @@
1
+ adopt_cli/__init__.py,sha256=FWUE7dlFMxJlRUl8a9EqLqWPdsWjWxO2XvKi3QItheA,334
2
+ adopt_cli/_build_info.py,sha256=BFie7LRGWTLE9VKhaTEz8OGk9dx1gevIMrSTTLO9Zsk,324
3
+ adopt_cli/config.py,sha256=V0twCe0GRO6sHefoWnq3gOh0XpwBXgLRYVS_dqrygvQ,5941
4
+ adopt_cli/json_out.py,sha256=ttARjBkGeladJbC1DTDkMXTy6DZIA4v1igGCIcLreGw,2422
5
+ adopt_cli/main.py,sha256=6SHz4satbcY6K_5YiJzA9ebaqgkINWoMlRAbkkQpc08,6113
6
+ adopt_cli/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
+ adopt_cli/store_option.py,sha256=bbmG0dLRQ-x9p20W0JFI_D2LWJ2Dy-RLWsy109kYO6I,5615
8
+ adopt_cli/commands/__init__.py,sha256=hbby1E3ijzrXoGVYOql4sEDHEsriQGznNduSaCYE-60,82
9
+ adopt_cli/commands/agent.py,sha256=ZmCF3YXg4DSY2nbox7apCjlCHbFn_0Le99RsVhioaAo,8284
10
+ adopt_cli/commands/boundary.py,sha256=K3Qodiio-NPaat37Bn24McxgAW7RLu-TDnYRySCRQV0,6943
11
+ adopt_cli/commands/coverage.py,sha256=sDiO5F9DNtGkpLbdny-YRP1Kv7GpbXHlUoQv7ipNfpk,2920
12
+ adopt_cli/commands/detect.py,sha256=IZ9Y0PT_QT4nOtKxRKj8OKZ7fyR-3dFK5Nwk4u_PDTg,6258
13
+ adopt_cli/commands/doctor.py,sha256=tN2xvm8DmRRziT4KInEvItbHgu34H4FeVGxTxHt3a7U,3214
14
+ adopt_cli/commands/freshness.py,sha256=PMzJwlJdrk5VrVmQrasRIdWroO9tmEBtpxlyq85mctw,1981
15
+ adopt_cli/commands/identity.py,sha256=_G8cBsW-riKtvPodqLv-xg6kplqVWgPiFiE1OjyGpJo,3987
16
+ adopt_cli/commands/init.py,sha256=m5CY-kzjRg9Cjg6ZFkCZfUd9ugFTsKp5CI-6U59yHP8,11899
17
+ adopt_cli/commands/interchange.py,sha256=oo7iyhaBQUmwbC64YjXW87CgUpwYzlbpFi9uEdeIDbQ,3632
18
+ adopt_cli/commands/policy.py,sha256=bkyPGcI90w83NQfu6nVDmWtDJ2WSvNh-ywMd-tH9aLQ,6623
19
+ adopt_cli/commands/store.py,sha256=KBSiUFQvcFjC1N2KK9B6UYqslHkKDqiuoOz5P1YEGJw,3640
20
+ adopt_cli/commands/version.py,sha256=H94Pzi9t60ZBfBfe6g5rdSGU92-F9ZrmMobU_G6MsuQ,1158
21
+ adopt_cli-0.3.0.dist-info/METADATA,sha256=R5jfCz5jlKSfI6ylAsPy7B-ZbVIU5e_7ngO0hl-Wd4Y,874
22
+ adopt_cli-0.3.0.dist-info/WHEEL,sha256=zOwg4jB6zX2kU910N-cMawjivD6tO8NEWvE12je1bVk,87
23
+ adopt_cli-0.3.0.dist-info/entry_points.txt,sha256=PQ2EH1utX5xM9WtnRdEUp9BZ3uHdQf-yMNPCyaGIzDM,46
24
+ adopt_cli-0.3.0.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
25
+ adopt_cli-0.3.0.dist-info/licenses/NOTICE,sha256=2_mgo6v6IM9fAn52L5-wXFpISnC6PVU_geTutoRhbWk,1897
26
+ adopt_cli-0.3.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.32.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ adopt = adopt_cli.main:main
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,39 @@
1
+ Adopt — Adoption-Phase Platform, shared substrate (`adopt-core`)
2
+ Copyright 2026 The Adopt Authors
3
+
4
+ This product includes software developed by The Adopt Authors.
5
+
6
+ Licensed under the Apache License, Version 2.0 (the "License");
7
+ you may not use this file except in compliance with the License.
8
+ You may obtain a copy of the License at
9
+
10
+ http://www.apache.org/licenses/LICENSE-2.0
11
+
12
+ Unless required by applicable law or agreed to in writing, software
13
+ distributed under the License is distributed on an "AS IS" BASIS,
14
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ See the License for the specific language governing permissions and
16
+ limitations under the License.
17
+
18
+ --------------------------------------------------------------------------------
19
+ Attribution note
20
+ --------------------------------------------------------------------------------
21
+
22
+ The copyright holder is recorded here as "The Adopt Authors" pending the legal
23
+ entity name. The owner must settle that attribution before the 0.3.0 tag,
24
+ because published package metadata cannot be changed retroactively for a
25
+ release that has already left the machine. The product name itself is settled:
26
+ handoff-index CR-50 keeps `Adopt` distinct from the `onboard` URI namespace.
27
+
28
+ --------------------------------------------------------------------------------
29
+ Third-party dependencies
30
+ --------------------------------------------------------------------------------
31
+
32
+ Every third-party dependency linked into this distribution is permissively
33
+ licensed. The complete list, with licence hash, security status, usage mode,
34
+ owner and re-verification date, is maintained in `licence-verifications.md` and
35
+ enforced by `scripts/licence_gate.py`.
36
+
37
+ Copyleft-licensed tools are invoked as subprocesses only and are never linked
38
+ into this distribution. They are declared in `subprocess-deps.toml` together
39
+ with their invocation sites.