mkctl 0.4.0__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.
- mkctl-0.4.0/.gitignore +43 -0
- mkctl-0.4.0/LICENSE +201 -0
- mkctl-0.4.0/PKG-INFO +10 -0
- mkctl-0.4.0/README.md +207 -0
- mkctl-0.4.0/pyproject.toml +60 -0
- mkctl-0.4.0/src/mkctl/__init__.py +8 -0
- mkctl-0.4.0/src/mkctl/cli.py +478 -0
- mkctl-0.4.0/src/mkctl/client.py +131 -0
- mkctl-0.4.0/src/mkctl/commands.py +527 -0
- mkctl-0.4.0/src/mkctl/config.py +59 -0
- mkctl-0.4.0/src/mkctl/oauth.py +398 -0
- mkctl-0.4.0/src/mkctl/py.typed +0 -0
- mkctl-0.4.0/src/mkctl/session.py +104 -0
- mkctl-0.4.0/src/mkctl/store.py +90 -0
- mkctl-0.4.0/tests/__init__.py +0 -0
- mkctl-0.4.0/tests/authserver.py +227 -0
- mkctl-0.4.0/tests/conftest.py +132 -0
- mkctl-0.4.0/tests/controlplane.py +401 -0
- mkctl-0.4.0/tests/test_commands.py +480 -0
- mkctl-0.4.0/tests/test_compat.py +75 -0
- mkctl-0.4.0/tests/test_config.py +95 -0
- mkctl-0.4.0/tests/test_device_flow.py +120 -0
- mkctl-0.4.0/tests/test_pkce_flow.py +172 -0
- mkctl-0.4.0/tests/test_session.py +143 -0
- mkctl-0.4.0/tests/test_version.py +21 -0
- mkctl-0.4.0/uv.lock +558 -0
mkctl-0.4.0/.gitignore
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
.venv/
|
|
5
|
+
venv/
|
|
6
|
+
*.egg-info/
|
|
7
|
+
dist/
|
|
8
|
+
build/
|
|
9
|
+
.mypy_cache/
|
|
10
|
+
.ruff_cache/
|
|
11
|
+
.pytest_cache/
|
|
12
|
+
.coverage
|
|
13
|
+
htmlcov/
|
|
14
|
+
|
|
15
|
+
# Node (web/)
|
|
16
|
+
node_modules/
|
|
17
|
+
.next/
|
|
18
|
+
.turbo/
|
|
19
|
+
|
|
20
|
+
# Local config and secrets — never tracked
|
|
21
|
+
.env
|
|
22
|
+
.env.*
|
|
23
|
+
!.env.example
|
|
24
|
+
deploy/.local/
|
|
25
|
+
deploy/secrets/
|
|
26
|
+
# Database dumps written by the pg-backup sidecar on the host
|
|
27
|
+
deploy/backups/
|
|
28
|
+
*.pem
|
|
29
|
+
*.key
|
|
30
|
+
!**/*.pub.key
|
|
31
|
+
# age identities generated for laptop bring-up
|
|
32
|
+
*.age
|
|
33
|
+
|
|
34
|
+
# Runtime state
|
|
35
|
+
.mklang-platform/
|
|
36
|
+
*.db
|
|
37
|
+
*.sqlite3
|
|
38
|
+
run-artifacts/
|
|
39
|
+
|
|
40
|
+
# Editors / OS
|
|
41
|
+
.DS_Store
|
|
42
|
+
.idea/
|
|
43
|
+
.vscode/
|
mkctl-0.4.0/LICENSE
ADDED
|
@@ -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 Derivative
|
|
95
|
+
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 2026 Gianluca
|
|
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.
|
mkctl-0.4.0/PKG-INFO
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: mkctl
|
|
3
|
+
Version: 0.4.0
|
|
4
|
+
Summary: The command line for the control plane (ADR 0004)
|
|
5
|
+
License-Expression: Apache-2.0
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
Requires-Python: <3.14,>=3.11
|
|
8
|
+
Requires-Dist: httpx>=0.27
|
|
9
|
+
Requires-Dist: keyring>=25.0
|
|
10
|
+
Requires-Dist: mkp-contracts>=0.2.0
|
mkctl-0.4.0/README.md
ADDED
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
# mkctl — the command line for the control plane
|
|
2
|
+
|
|
3
|
+
A human's terminal: it must not hold a password, and it must be revocable
|
|
4
|
+
independently of the account ([ADR 0004](../../docs/adr/0004-delegated-authentication-owned-authorization.md)).
|
|
5
|
+
It holds tokens the identity provider issued, and never a credential this platform
|
|
6
|
+
minted.
|
|
7
|
+
|
|
8
|
+
```
|
|
9
|
+
mkctl login browser, authorization code with PKCE
|
|
10
|
+
mkctl login --device no browser — SSH, containers, headless
|
|
11
|
+
mkctl whoami who the control plane thinks you are, and what you may do
|
|
12
|
+
mkctl logout revoke at the provider, then forget locally
|
|
13
|
+
mkctl upgrade print the procedure for the latest release (ADR 0014)
|
|
14
|
+
|
|
15
|
+
mkctl bundle push ARCHIVE register what `mkbundle build` produced, and upload it
|
|
16
|
+
mkctl deploy DIGEST point an environment at a bundle
|
|
17
|
+
mkctl run start WORKFLOW start a run; nothing executes in that request
|
|
18
|
+
mkctl run list runs (filters; --environment not --env)
|
|
19
|
+
mkctl run get RUN_ID status, attempts, and what it is waiting on
|
|
20
|
+
mkctl run reply RUN_ID reply to a waiting run — the same act as the queue's Reply
|
|
21
|
+
mkctl run abandon RUN_ID cancel a waiting run
|
|
22
|
+
|
|
23
|
+
mkctl project list|create projects
|
|
24
|
+
mkctl env list|create|get environments, and what is deployed to one
|
|
25
|
+
mkctl user list|create who is in this tenant
|
|
26
|
+
mkctl role grant|revoke what they may do, and where
|
|
27
|
+
mkctl tenant list|create needs the platform grant, not a role
|
|
28
|
+
mkctl connection list credentials, by label (no values)
|
|
29
|
+
mkctl connection create static material, or authless when --material omitted (D10)
|
|
30
|
+
mkctl connection bind NAME what a workflow connection: name means in one env
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Configured by `MKCTL_CONTROL_PLANE`, `MKCTL_OIDC_ISSUER`, `MKCTL_CLIENT_ID`, or the
|
|
34
|
+
matching options. Endpoints are read from the provider's discovery document rather than
|
|
35
|
+
configured: hard-coding paths would make an IdP change a code change, which is the
|
|
36
|
+
coupling ADR 0004 spent an adapter to avoid.
|
|
37
|
+
|
|
38
|
+
`--project` and `--env` (on deploy, run start, …) fall back to `MKCTL_PROJECT` and
|
|
39
|
+
`MKCTL_ENVIRONMENT`, because a person works in one project all day. **`run list` takes
|
|
40
|
+
`--environment`**, not `--env`. **A role's scope does not** default from those variables:
|
|
41
|
+
`mkctl role grant ada@… owner` with no scope means the tenant, and an environment variable
|
|
42
|
+
that quietly narrowed it to one project would make the same command grant different power
|
|
43
|
+
on two machines.
|
|
44
|
+
|
|
45
|
+
### On a laptop
|
|
46
|
+
|
|
47
|
+
Prefer the wrapper so `MKCTL_*` come from `deploy/.local/env`:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
./deploy/scripts/local mkctl login
|
|
51
|
+
./deploy/scripts/local mkctl whoami
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
**Authless connections (`D10`):** omit every `--material` flag. The control plane still
|
|
55
|
+
writes a vault envelope over an empty map — there is no plaintext path — and the runner
|
|
56
|
+
never resolves material for `auth: kind: none`.
|
|
57
|
+
|
|
58
|
+
Full laptop path (setup, demo, first_run, vendor):
|
|
59
|
+
[`deploy/runbooks/local.md`](../../deploy/runbooks/local.md).
|
|
60
|
+
|
|
61
|
+
`--json` on any command prints the control plane's own answer, for scripts. Everything
|
|
62
|
+
else is formatted for a person, which mostly means saying what a state implies: a started
|
|
63
|
+
run says nothing has executed yet, a created user says it has no roles, and a pushed
|
|
64
|
+
bundle that is unsigned says a runner will refuse it (`D2`).
|
|
65
|
+
|
|
66
|
+
## What this deliberately does not do
|
|
67
|
+
|
|
68
|
+
**It does not build.** `mkbundle build` produces the archive and `mkctl bundle push`
|
|
69
|
+
uploads it. Folding them together would make one command that fails for eight unrelated
|
|
70
|
+
reasons — a missing connector catalog, `mklang check` on a machine, an expired login —
|
|
71
|
+
and would put a signing key in the same process as a login token.
|
|
72
|
+
|
|
73
|
+
**It does not compute a bundle's digest.** `POST /bundles` recomputes it from the manifest
|
|
74
|
+
and returns it, and the archive is uploaded under the name the server gave back. A second
|
|
75
|
+
opinion here would be a second definition of a bundle's identity, which is the thing
|
|
76
|
+
`packages/mkp-contracts` exists to prevent. The one thing read locally is the manifest
|
|
77
|
+
inside the archive, and that is read with `mkp_contracts.archive.manifest_of` for the same
|
|
78
|
+
reason.
|
|
79
|
+
|
|
80
|
+
**It does not guess a type.** `--input thread_id=t-1` sends a string, always;
|
|
81
|
+
`--input-json '{"count": 2}'` is how anything else is expressed. A shell word carries no
|
|
82
|
+
type, and inferring one would make `count=2` a number here and a string in the next tool
|
|
83
|
+
that had the same idea slightly differently.
|
|
84
|
+
|
|
85
|
+
## Two flows, and where PKCE actually applies
|
|
86
|
+
|
|
87
|
+
**Authorization code with PKCE over a loopback redirect** (RFC 8252 §7.3, RFC 7636) is
|
|
88
|
+
the default. The client holds no secret, and the `code_verifier` binds the code to the
|
|
89
|
+
process that asked for it, so a code intercepted on its way back is useless. `state` is
|
|
90
|
+
checked because a redirect is a request that anything on this machine could make.
|
|
91
|
+
|
|
92
|
+
**The device authorization grant** (RFC 8628) is `--device`. It exists for the case the
|
|
93
|
+
default cannot serve — a terminal over SSH, a container, a machine with no browser —
|
|
94
|
+
which is every terminal that operates a remote runner, so it is not an edge case.
|
|
95
|
+
|
|
96
|
+
ADR 0004 originally asked for "the device authorization flow with PKCE". That is two
|
|
97
|
+
protections conflated: PKCE guards a redirect from interception, and the device grant
|
|
98
|
+
has no redirect. Amendment 2 records the correction; the implementation does both flows
|
|
99
|
+
and applies PKCE to the one that has something for it to protect.
|
|
100
|
+
|
|
101
|
+
Neither flow uses a client secret. A secret shipped inside a CLI is a public value with
|
|
102
|
+
a misleading name (RFC 8252 §8.5).
|
|
103
|
+
|
|
104
|
+
## The rules the tests hold
|
|
105
|
+
|
|
106
|
+
**`slow_down` lengthens the interval, it is not a retry.** RFC 8628 §3.5 says add at
|
|
107
|
+
least five seconds. Treating it as "try again now" is how a client gets rate-limited
|
|
108
|
+
into failing a flow that would otherwise have worked, and the symptom looks like the
|
|
109
|
+
provider being flaky.
|
|
110
|
+
|
|
111
|
+
**Whatever a refresh returns is what gets stored.** Providers rotate refresh tokens and
|
|
112
|
+
enforce single use; a client that keeps the token it just sent turns that enforcement
|
|
113
|
+
into a login loop on the day it is switched on. When a provider returns no new refresh
|
|
114
|
+
token, the old one is kept rather than dropped — dropping it logs the user out on the
|
|
115
|
+
first refresh.
|
|
116
|
+
|
|
117
|
+
**Logout revokes before it forgets.** Deleting only the local copy leaves a live refresh
|
|
118
|
+
token on a machine somebody may have just handed back, which is the opposite of
|
|
119
|
+
"revocable per device".
|
|
120
|
+
|
|
121
|
+
**Tokens go in the OS keyring, and nowhere else.** Where no keyring is available,
|
|
122
|
+
`mkctl` refuses and says what to install. A CLI that degrades to a plaintext file when
|
|
123
|
+
the keyring is missing is `nate`'s `TOKEN_ENCRYPTION_KEY` again: the safe path must not
|
|
124
|
+
be the one that happens to be configured.
|
|
125
|
+
|
|
126
|
+
One keyring entry per control plane, keyed by URL, so a laptop that talks to production
|
|
127
|
+
and to a local stack does not have one login overwrite the other.
|
|
128
|
+
|
|
129
|
+
## Known gap
|
|
130
|
+
|
|
131
|
+
The device grant exists for machines without a browser, and those are also the machines
|
|
132
|
+
least likely to have a Secret Service keyring — an SSH session on a bare server has
|
|
133
|
+
neither. Today that combination cannot store a login, and `mkctl` says so rather than
|
|
134
|
+
writing a file. The honest options are a keyring backend that works headless, or an ADR
|
|
135
|
+
that widens where a token may live. It is in `ops/STATUS.md` as an open question rather
|
|
136
|
+
than settled by whichever fallback was easiest.
|
|
137
|
+
|
|
138
|
+
## Install
|
|
139
|
+
|
|
140
|
+
Python 3.11 to 3.13.
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
pipx install mkctl
|
|
144
|
+
mkctl --version
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
`mkp-contracts` comes with it from the same index. `mkctl upgrade` prints the upgrade
|
|
148
|
+
command for whatever version the control plane currently declares.
|
|
149
|
+
|
|
150
|
+
Before `0.4.0` there was no index, and those versions are still where they were — wheels
|
|
151
|
+
attached to a `cli-v*` release of a **private** repository, so that path needs an account
|
|
152
|
+
with access to it:
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
gh release download cli-v0.3.0 --repo gianlucamazza/mklang-platform -D /tmp/mkp-wheels
|
|
156
|
+
pipx install /tmp/mkp-wheels/mkctl-*.whl --pip-args '--find-links /tmp/mkp-wheels'
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
`--repo` is not optional there: `gh release download` reads the repository from the
|
|
160
|
+
current directory's git remote, so without it the command works only inside a checkout —
|
|
161
|
+
the one place you do not need to install anything, because `./deploy/scripts/local mkctl …`
|
|
162
|
+
already runs from there.
|
|
163
|
+
|
|
164
|
+
## Configure
|
|
165
|
+
|
|
166
|
+
One value: the control plane URL. `login` discovers the issuer and client id from
|
|
167
|
+
`GET /v1/cli-config` and caches them in `~/.config/mkctl/config.toml` — a cache of
|
|
168
|
+
what the platform declared, safe to delete, re-learned at the next login:
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
mkctl login --control-plane https://api.mklang.dev
|
|
172
|
+
mkctl whoami
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
Flags beat environment variables (`MKCTL_*`), the environment beats the cached file,
|
|
176
|
+
and the file beats asking again. Set `MKCTL_PROJECT` / `MKCTL_ENVIRONMENT` for the
|
|
177
|
+
per-command defaults if you want them.
|
|
178
|
+
|
|
179
|
+
## Development
|
|
180
|
+
|
|
181
|
+
```
|
|
182
|
+
uv sync
|
|
183
|
+
uv run pytest
|
|
184
|
+
uv run --with ruff ruff check .
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
The tests run against a conformant authorization server over real HTTP
|
|
188
|
+
(`tests/authserver.py`) and a control plane over real HTTP (`tests/controlplane.py`) —
|
|
189
|
+
not a mocked `httpx`. A mock would assert that we call the library the way we think we
|
|
190
|
+
do, which is the belief under test, and the interesting failures here are protocol
|
|
191
|
+
failures: a `slow_down` ignored, a `code_verifier` never sent, a rotated token not
|
|
192
|
+
stored, a bearer that never reaches the request, an archive sent as a form field. Both
|
|
193
|
+
fakes refuse what the real thing refuses — PKCE and single-use refresh on one side, a 401
|
|
194
|
+
without a bearer and a 404 for an archive nobody registered on the other.
|
|
195
|
+
|
|
196
|
+
The commands are driven through `main()` rather than called as functions, because the
|
|
197
|
+
parser and the dispatch table are half of the feature: a command that works only from
|
|
198
|
+
Python is the gap `C14` describes, one layer down.
|
|
199
|
+
`test_every_command_the_parser_accepts_has_something_to_run` walks both and asserts it
|
|
200
|
+
found something, which is `D6`'s lesson.
|
|
201
|
+
|
|
202
|
+
Two things the tests here do not cover. A real browser and a real human: `mkctl login`
|
|
203
|
+
against a running Zitadel is a manual check, and the discovery document that drives it was
|
|
204
|
+
verified against one. And whether these commands drive the _real_ API — that is
|
|
205
|
+
`tests/e2e`, where `test_the_cli_drives_the_platform_it_logs_into` pushes a signed bundle,
|
|
206
|
+
deploys it, starts a run, and answers the escalation it parks on, against a real control
|
|
207
|
+
plane with a real runner behind it.
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "mkctl"
|
|
3
|
+
version = "0.4.0"
|
|
4
|
+
description = "The command line for the control plane (ADR 0004)"
|
|
5
|
+
license = "Apache-2.0"
|
|
6
|
+
license-files = ["LICENSE"]
|
|
7
|
+
requires-python = ">=3.11,<3.14"
|
|
8
|
+
# `mkp-contracts` for one function: reading the manifest out of an archive
|
|
9
|
+
# (`archive.manifest_of`). A CLI that unpacked a tar itself would be a second opinion
|
|
10
|
+
# about what a bundle is, which is the thing that package exists to prevent.
|
|
11
|
+
dependencies = ["httpx>=0.27", "keyring>=25.0", "mkp-contracts>=0.2.0"]
|
|
12
|
+
|
|
13
|
+
[project.scripts]
|
|
14
|
+
mkctl = "mkctl.cli:main"
|
|
15
|
+
|
|
16
|
+
[dependency-groups]
|
|
17
|
+
dev = ["pytest>=8.0", "types-PyYAML"]
|
|
18
|
+
|
|
19
|
+
[tool.uv.sources]
|
|
20
|
+
mkp-contracts = { path = "../../packages/mkp-contracts", editable = true }
|
|
21
|
+
|
|
22
|
+
[build-system]
|
|
23
|
+
requires = ["hatchling"]
|
|
24
|
+
build-backend = "hatchling.build"
|
|
25
|
+
|
|
26
|
+
[tool.hatch.build.targets.wheel]
|
|
27
|
+
packages = ["src/mkctl"]
|
|
28
|
+
|
|
29
|
+
[tool.ruff]
|
|
30
|
+
line-length = 100
|
|
31
|
+
|
|
32
|
+
[tool.ruff.lint]
|
|
33
|
+
select = ["E", "F", "I", "UP", "B", "SIM", "RUF", "S"]
|
|
34
|
+
|
|
35
|
+
[tool.ruff.lint.per-file-ignores]
|
|
36
|
+
# `S` reads production code. In a test the same rules are noise with a cost: a test that
|
|
37
|
+
# asserts is doing its job (S101), a fixture's fake credential is a literal on purpose
|
|
38
|
+
# (S105-S107), and a query built to set up a fixture is not a query an attacker reaches
|
|
39
|
+
# (S608). Ignored by path rather than by line, because there would be one line per test.
|
|
40
|
+
"tests/**" = ["S101", "S105", "S106", "S107", "S608"]
|
|
41
|
+
|
|
42
|
+
[tool.pytest.ini_options]
|
|
43
|
+
testpaths = ["tests"]
|
|
44
|
+
|
|
45
|
+
[tool.mypy]
|
|
46
|
+
# Same settings as `mklang` and `packages/mkp-contracts` — see the note there on why
|
|
47
|
+
# `warn_unused_ignores` is the one that earns its place first. Scope matches mklang too:
|
|
48
|
+
# what ships. Extending it over the test suites is a separate, larger piece of work.
|
|
49
|
+
files = ["src"]
|
|
50
|
+
python_version = "3.11"
|
|
51
|
+
check_untyped_defs = true
|
|
52
|
+
disallow_incomplete_defs = true
|
|
53
|
+
strict_equality = true
|
|
54
|
+
no_implicit_reexport = true
|
|
55
|
+
warn_redundant_casts = true
|
|
56
|
+
warn_unused_ignores = true
|
|
57
|
+
|
|
58
|
+
[tool.pyright]
|
|
59
|
+
typeCheckingMode = "basic"
|
|
60
|
+
exclude = [".venv"]
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"""mkctl — the command line for the control plane.
|
|
2
|
+
|
|
3
|
+
A human's terminal, which must not hold a password and must be revocable
|
|
4
|
+
independently of the account (ADR 0004). It holds tokens the identity provider
|
|
5
|
+
issued, in the OS keyring, and never a credential this platform minted.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
__version__ = "0.1.0"
|