munarium-matrix 1.0.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.
@@ -0,0 +1,164 @@
1
+ # Munarium — what this repository does not track.
2
+ #
3
+ # One section per component, because the reasons are specific and worth keeping.
4
+
5
+ # ---------------------------------------------------------------- shared ---
6
+ .DS_Store
7
+ Thumbs.db
8
+ *.swp
9
+ *~
10
+ .idea/
11
+ .vscode/
12
+
13
+ # Local agent guidance. Keep the two root copies identical and untracked.
14
+ /AGENTS.md
15
+ /CLAUDE.md
16
+
17
+ # Build output and tool residue wherever a toolchain leaves it. None of these
18
+ # names is a source directory in this tree (Rust `src/bin/` is not matched).
19
+ **/target/
20
+ **/__pycache__/
21
+ **/*.py[cod]
22
+ **/.venv/
23
+ **/venv/
24
+ **/*.egg-info/
25
+ **/.pytest_cache/
26
+ **/.mypy_cache/
27
+ **/.ruff_cache/
28
+ **/node_modules/
29
+ **/.gradle/
30
+ clients/*/build/
31
+ clients/*/bin/
32
+ clients/*/obj/
33
+ clients/*/src/*/bin/
34
+ clients/*/src/*/obj/
35
+ clients/*/tests/*/bin/
36
+ clients/*/tests/*/obj/
37
+
38
+
39
+ # ----------------------------------------------------------- server/ ---
40
+ server/target/
41
+ server/.env
42
+ server/*.local.toml
43
+ server/deploy/terraform/**/.terraform/
44
+ server/deploy/terraform/**/*.tfstate*
45
+ server/deploy/terraform/**/*.tfplan
46
+ # `*.tfplan` does NOT match an extensionless `terraform plan -out=tfplan`, and
47
+ # a suffixed name (`tfplan.datastore`) matches neither. A plan file embeds the
48
+ # FULL tfstate, generated passwords included, so every spelling is covered.
49
+ server/deploy/terraform/**/tfplan*
50
+ server/deploy/terraform/**/.terraform.lock.hcl
51
+ server/deploy/terraform/**/*.tfvars
52
+ !server/deploy/terraform/**/example.tfvars
53
+
54
+ # Python residue from the tree's own stdlib tools — check_license.py,
55
+ # tools/third_party_notices.py, contract/mmp/publish.py, docs/route-index.py.
56
+ server/__pycache__/
57
+ server/*.py[cod]
58
+ server/.venv/
59
+ server/venv/
60
+
61
+ # Local run artifacts: a database dump, a saved SBOM, a captured gate log. The
62
+ # notices file itself is COMMITTED; this is the scratch beside it.
63
+ server/*.sbom.json
64
+ server/*.cdx.json
65
+ server/scratch/
66
+
67
+ # Editors and operating systems. Committed editor settings would impose one
68
+ # person's toolchain on every contributor; per-clone settings are theirs.
69
+ server/.vscode/
70
+ server/.idea/
71
+ server/*.swp
72
+ server/.DS_Store
73
+ server/Thumbs.db
74
+
75
+ # ----------------------------------------------------------- matrix/ ---
76
+ matrix/target/
77
+ matrix/*.tfstate
78
+ matrix/*.tfstate.*
79
+ matrix/.terraform/
80
+ matrix/tfplan
81
+ matrix/.mxtest-current.json
82
+ # Conformance results files are committed (they are small and are the
83
+ # evidence), never gitignored. Run transcripts under artifacts/ are not.
84
+ matrix/artifacts/
85
+
86
+ # Python residue from the tree's own stdlib tools — check_license.py,
87
+ # scripts/third_party_notices.py, scripts/boundaries.py, scripts/doclint.py,
88
+ # contract/publish.py.
89
+ matrix/__pycache__/
90
+ matrix/*.py[cod]
91
+ matrix/.venv/
92
+ matrix/venv/
93
+
94
+ # Local run artifacts: a saved SBOM, a captured gate log. THIRD_PARTY_NOTICES.md
95
+ # itself is COMMITTED; this is the scratch beside it.
96
+ matrix/*.sbom.json
97
+ matrix/*.cdx.json
98
+ matrix/scratch/
99
+
100
+ # Editors and operating systems. Committed editor settings would impose one
101
+ # person's toolchain on every contributor; per-clone settings are theirs.
102
+ matrix/.vscode/
103
+ matrix/.idea/
104
+ matrix/*.swp
105
+ matrix/.DS_Store
106
+ matrix/Thumbs.db
107
+
108
+ # ----------------------------------------------------------- clients/ ---
109
+ # The Munarium client libraries: several language trees, so the rules are the
110
+ # union of what those toolchains leave behind.
111
+ #
112
+ # Each language directory keeps its own .gitignore for what only it produces
113
+ # (dotnet/, java/, python/); this file is the cross-cutting set.
114
+
115
+ # Rust: cargo build output. Cargo.lock IS committed — the conformance runner is
116
+ # an application and its resolved set is part of what CI proves.
117
+ clients/target/
118
+
119
+ # Python: virtual environments, caches, build output. The generated protobuf
120
+ # stubs under python/src/munarium_client/_proto/ are COMMITTED and drift-checked.
121
+ clients/__pycache__/
122
+ clients/*.py[cod]
123
+ clients/.venv/
124
+ clients/venv/
125
+ clients/*.egg-info/
126
+ clients/dist/
127
+ clients/build/
128
+ clients/.mypy_cache/
129
+ clients/.ruff_cache/
130
+ clients/.pytest_cache/
131
+
132
+ # .NET and Java build output (also covered by dotnet/.gitignore and
133
+ # java/.gitignore; kept here so a build from the repository root is clean).
134
+ clients/bin/
135
+ clients/obj/
136
+ clients/*.user
137
+ clients/.gradle/
138
+
139
+ # Local run artifacts: a saved SBOM, a packed wheel or nupkg under test.
140
+ # THIRD_PARTY_NOTICES.md itself is COMMITTED.
141
+ clients/*.sbom.json
142
+ clients/*.cdx.json
143
+ clients/*.nupkg
144
+ clients/*.whl
145
+ clients/scratch/
146
+
147
+ # Editors and operating systems. Committed editor settings would impose one
148
+ # maintainer's toolchain on every contributor.
149
+ clients/.vscode/
150
+ clients/.idea/
151
+ clients/*.swp
152
+ clients/.DS_Store
153
+ clients/Thumbs.db
154
+
155
+ # The release-time copy of server/proto that cargo package needs inside the
156
+ # crate; the normative protos stay at server/proto and this must never land.
157
+ server/src/munarium-proto/proto/
158
+
159
+ # ------------------------------------------------------------- docs/ ---
160
+ # The lab example's local secrets and the files a run writes beside them.
161
+ docs/lab/example/.env
162
+ docs/lab/example/ingest-manifest.json
163
+ docs/lab/example/results*.json
164
+ docs/lab/example/ledger-results.json
@@ -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,15 @@
1
+ Munarium client libraries
2
+ Copyright (c) 2026 Ioka LLC
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use
5
+ these files except in compliance with the License. A copy of the License is in
6
+ the LICENSE file beside this notice.
7
+
8
+ "Munarium" and "Ioka" are trademarks of Ioka LLC. The License grants no right
9
+ to use them beyond what is needed to describe the origin of these files.
10
+
11
+ These libraries speak to Munarium Server, a separate work licensed under its
12
+ own terms; nothing here grants any right to it, to Munarium Matrix, or to any
13
+ support from Ioka LLC.
14
+
15
+ The MMP contract bundle under contract/ carries its own NOTICE.
@@ -0,0 +1,157 @@
1
+ Metadata-Version: 2.5
2
+ Name: munarium-matrix
3
+ Version: 1.0.0
4
+ Summary: Python client for Munarium Matrix, the structured-evidence plane
5
+ Project-URL: Homepage, https://github.com/iokaio/munarium
6
+ Project-URL: Repository, https://github.com/iokaio/munarium
7
+ Project-URL: Changelog, https://github.com/iokaio/munarium/blob/main/clients/CHANGELOG.md
8
+ Author: Ioka
9
+ License-Expression: Apache-2.0
10
+ License-File: LICENSE
11
+ License-File: NOTICE
12
+ Requires-Python: >=3.10
13
+ Requires-Dist: httpx>=0.27
14
+ Provides-Extra: dev
15
+ Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
16
+ Requires-Dist: pytest>=8; extra == 'dev'
17
+ Description-Content-Type: text/markdown
18
+
19
+ # munarium-matrix (Python)
20
+
21
+ The Python client for **Munarium Matrix**, the structured-evidence plane. It
22
+ speaks Matrix's REST API and it is deliberately small: Matrix's whole surface
23
+ is *registering assets, running the three modes, and reading what happened*.
24
+
25
+ Install from the repository root with Python 3.10+:
26
+
27
+ ```console
28
+ python -m pip install ./clients/matrix-python
29
+ ```
30
+
31
+ The source version is 1.0.0; a PyPI release was not available at the
32
+ [publication check](../README.md#installation-and-publication).
33
+
34
+ One runtime dependency, `httpx` — the same choice the server's Python client
35
+ made, for the same reasons: one library for sync and async, a timeout that is
36
+ not optional, and no transitive surprise.
37
+
38
+ ## Use
39
+
40
+ ```python
41
+ from munarium_matrix import MatrixClient
42
+
43
+ with MatrixClient("https://matrix.example", token="...", uid="ops@example.com") as mx:
44
+ print(mx.version().lockstep_ok) # does Matrix agree with its server?
45
+
46
+ mx.apply(open("datasource.crm.yaml").read())
47
+ mx.apply(open("contract.pipeline.yaml").read())
48
+
49
+ outcome = mx.verify("open-pipeline-by-region")
50
+ if outcome.failed:
51
+ for q in outcome.questions:
52
+ if not q.ok:
53
+ print(q.question, q.failures)
54
+ raise SystemExit(3) # the exit discipline `mxctl` uses
55
+ ```
56
+
57
+ Async is the same surface:
58
+
59
+ ```python
60
+ from munarium_matrix import AsyncMatrixClient
61
+
62
+ async with AsyncMatrixClient("https://matrix.example", token="...") as mx:
63
+ await mx.sync("crm")
64
+ ```
65
+
66
+ ### Refusals are typed
67
+
68
+ Matrix answers a refusal as RFC 9457 problem+json carrying a `refusal` object
69
+ with the **class** and the **code** — the closed vocabulary the whole system
70
+ rests on. They arrive as attributes, not prose:
71
+
72
+ ```python
73
+ from munarium_matrix import MatrixError
74
+
75
+ try:
76
+ mx.verify("open-pipeline-by-region")
77
+ except MatrixError as e:
78
+ if e.retryable: # unavailable | exhausted
79
+ wait = e.retry_after # seconds, when the service said
80
+ elif e.code == "not_covered": # the collection cannot answer it
81
+ ...
82
+ ```
83
+
84
+ `retryable` is a property and not a guess: `unavailable` and `exhausted` are
85
+ states of the world, and every other class is a statement about the request or
86
+ the assets, where repeating it changes nothing. Retrying a `denied` is
87
+ hammering a door that is locked on purpose.
88
+
89
+ ### Lockstep
90
+
91
+ `version().lockstep_ok` is true only when the server reports `exact`. That is
92
+ the one state in which an evidence id minted by this Matrix is certain to
93
+ resolve on that server — which is what a citation like
94
+ `[evidence/<id>#r0003]` depends on.
95
+
96
+ ## What this client deliberately does NOT do
97
+
98
+ Three absences, each of them a design decision rather than a missing feature:
99
+
100
+ * **No sealing.** A manifest is a statement about work the *sealer* did. An SDK
101
+ offering `seal_evidence` would invite an application to assert provenance it
102
+ cannot vouch for. Sealing is Matrix's own act; evidence is *read* through the
103
+ **server's** client, resolving `[evidence/<id>#<row>]`.
104
+ * **No local validation.** `validate()` posts the YAML and returns Matrix's own
105
+ findings. A client carrying its own copy of the rules would drift from the
106
+ service that enforces them, and the drift would surface as an asset that
107
+ validates here and is refused there.
108
+ * **No SQL.** Nothing on this surface takes a statement. Queries are
109
+ pre-declared contracts and views, executed by name.
110
+
111
+ There is also no gRPC transport here. Matrix's gRPC plane serves `Execute`
112
+ alone, and `Execute` is service-to-service — the munarium-server calls it, not
113
+ an application. When that changes, this package grows a transport rather than a
114
+ second client.
115
+
116
+ ## Surface
117
+
118
+ | Area | Methods |
119
+ | --- | --- |
120
+ | meta | `version`, `healthz`, `healthdata` |
121
+ | registry | `apply`, `validate`, `list_assets`, `get_yaml` |
122
+ | sources | `introspect`, `probe`, `sync` |
123
+ | contracts and views | `verify`, `verify_view` |
124
+ | reconcile | `reconcile`, `promotion_status`, `gate_history`, `promote`, `demote`, `rollback` |
125
+ | audit | `journal` |
126
+
127
+ `verify_view` takes either a metric view or a native data view and tries the
128
+ metric-view route first — the caller names the view, not the route it happens
129
+ to live on. The fallback fires on a 404 **or** a `not_covered` 422, because a
130
+ missing metric view loads through the runtime and comes back as the latter; a
131
+ different 422, such as `metric_view_changed`, is a real answer about a view
132
+ that exists and is not retried as something else.
133
+
134
+ `validate` returns the service's own `valid` flag beside its findings, and not
135
+ `not findings`: three codes are advisory, so a valid asset can carry them.
136
+
137
+ `sync` and `reconcile` return a `JobAccepted`: Matrix queues them, so the call
138
+ returns an id rather than an outcome. Poll `journal()` or the run route for the
139
+ terminal state.
140
+
141
+ ## Versioning
142
+
143
+ This package targets Matrix `1.0.0`. A version bump on the wire surface bumps
144
+ them together.
145
+
146
+ ## Tests
147
+
148
+ ```bash
149
+ pip install -e ".[dev]"
150
+ pytest
151
+ ```
152
+
153
+ The offline tier drives a stub transport and asserts the response *shapes* this
154
+ client claims to understand, which is what catches a field rename. Setting
155
+ `MUNARIUM_MATRIX_TEST_URL` adds a live round-trip against a real Matrix; with
156
+ it unset that test **says it skipped**, because a skip that prints nothing is
157
+ indistinguishable from a pass.
@@ -0,0 +1,139 @@
1
+ # munarium-matrix (Python)
2
+
3
+ The Python client for **Munarium Matrix**, the structured-evidence plane. It
4
+ speaks Matrix's REST API and it is deliberately small: Matrix's whole surface
5
+ is *registering assets, running the three modes, and reading what happened*.
6
+
7
+ Install from the repository root with Python 3.10+:
8
+
9
+ ```console
10
+ python -m pip install ./clients/matrix-python
11
+ ```
12
+
13
+ The source version is 1.0.0; a PyPI release was not available at the
14
+ [publication check](../README.md#installation-and-publication).
15
+
16
+ One runtime dependency, `httpx` — the same choice the server's Python client
17
+ made, for the same reasons: one library for sync and async, a timeout that is
18
+ not optional, and no transitive surprise.
19
+
20
+ ## Use
21
+
22
+ ```python
23
+ from munarium_matrix import MatrixClient
24
+
25
+ with MatrixClient("https://matrix.example", token="...", uid="ops@example.com") as mx:
26
+ print(mx.version().lockstep_ok) # does Matrix agree with its server?
27
+
28
+ mx.apply(open("datasource.crm.yaml").read())
29
+ mx.apply(open("contract.pipeline.yaml").read())
30
+
31
+ outcome = mx.verify("open-pipeline-by-region")
32
+ if outcome.failed:
33
+ for q in outcome.questions:
34
+ if not q.ok:
35
+ print(q.question, q.failures)
36
+ raise SystemExit(3) # the exit discipline `mxctl` uses
37
+ ```
38
+
39
+ Async is the same surface:
40
+
41
+ ```python
42
+ from munarium_matrix import AsyncMatrixClient
43
+
44
+ async with AsyncMatrixClient("https://matrix.example", token="...") as mx:
45
+ await mx.sync("crm")
46
+ ```
47
+
48
+ ### Refusals are typed
49
+
50
+ Matrix answers a refusal as RFC 9457 problem+json carrying a `refusal` object
51
+ with the **class** and the **code** — the closed vocabulary the whole system
52
+ rests on. They arrive as attributes, not prose:
53
+
54
+ ```python
55
+ from munarium_matrix import MatrixError
56
+
57
+ try:
58
+ mx.verify("open-pipeline-by-region")
59
+ except MatrixError as e:
60
+ if e.retryable: # unavailable | exhausted
61
+ wait = e.retry_after # seconds, when the service said
62
+ elif e.code == "not_covered": # the collection cannot answer it
63
+ ...
64
+ ```
65
+
66
+ `retryable` is a property and not a guess: `unavailable` and `exhausted` are
67
+ states of the world, and every other class is a statement about the request or
68
+ the assets, where repeating it changes nothing. Retrying a `denied` is
69
+ hammering a door that is locked on purpose.
70
+
71
+ ### Lockstep
72
+
73
+ `version().lockstep_ok` is true only when the server reports `exact`. That is
74
+ the one state in which an evidence id minted by this Matrix is certain to
75
+ resolve on that server — which is what a citation like
76
+ `[evidence/<id>#r0003]` depends on.
77
+
78
+ ## What this client deliberately does NOT do
79
+
80
+ Three absences, each of them a design decision rather than a missing feature:
81
+
82
+ * **No sealing.** A manifest is a statement about work the *sealer* did. An SDK
83
+ offering `seal_evidence` would invite an application to assert provenance it
84
+ cannot vouch for. Sealing is Matrix's own act; evidence is *read* through the
85
+ **server's** client, resolving `[evidence/<id>#<row>]`.
86
+ * **No local validation.** `validate()` posts the YAML and returns Matrix's own
87
+ findings. A client carrying its own copy of the rules would drift from the
88
+ service that enforces them, and the drift would surface as an asset that
89
+ validates here and is refused there.
90
+ * **No SQL.** Nothing on this surface takes a statement. Queries are
91
+ pre-declared contracts and views, executed by name.
92
+
93
+ There is also no gRPC transport here. Matrix's gRPC plane serves `Execute`
94
+ alone, and `Execute` is service-to-service — the munarium-server calls it, not
95
+ an application. When that changes, this package grows a transport rather than a
96
+ second client.
97
+
98
+ ## Surface
99
+
100
+ | Area | Methods |
101
+ | --- | --- |
102
+ | meta | `version`, `healthz`, `healthdata` |
103
+ | registry | `apply`, `validate`, `list_assets`, `get_yaml` |
104
+ | sources | `introspect`, `probe`, `sync` |
105
+ | contracts and views | `verify`, `verify_view` |
106
+ | reconcile | `reconcile`, `promotion_status`, `gate_history`, `promote`, `demote`, `rollback` |
107
+ | audit | `journal` |
108
+
109
+ `verify_view` takes either a metric view or a native data view and tries the
110
+ metric-view route first — the caller names the view, not the route it happens
111
+ to live on. The fallback fires on a 404 **or** a `not_covered` 422, because a
112
+ missing metric view loads through the runtime and comes back as the latter; a
113
+ different 422, such as `metric_view_changed`, is a real answer about a view
114
+ that exists and is not retried as something else.
115
+
116
+ `validate` returns the service's own `valid` flag beside its findings, and not
117
+ `not findings`: three codes are advisory, so a valid asset can carry them.
118
+
119
+ `sync` and `reconcile` return a `JobAccepted`: Matrix queues them, so the call
120
+ returns an id rather than an outcome. Poll `journal()` or the run route for the
121
+ terminal state.
122
+
123
+ ## Versioning
124
+
125
+ This package targets Matrix `1.0.0`. A version bump on the wire surface bumps
126
+ them together.
127
+
128
+ ## Tests
129
+
130
+ ```bash
131
+ pip install -e ".[dev]"
132
+ pytest
133
+ ```
134
+
135
+ The offline tier drives a stub transport and asserts the response *shapes* this
136
+ client claims to understand, which is what catches a field rename. Setting
137
+ `MUNARIUM_MATRIX_TEST_URL` adds a live round-trip against a real Matrix; with
138
+ it unset that test **says it skipped**, because a skip that prints nothing is
139
+ indistinguishable from a pass.