mandatia 0.1.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.
Files changed (90) hide show
  1. mandatia-0.1.0/.gitignore +18 -0
  2. mandatia-0.1.0/AGENTS.md +73 -0
  3. mandatia-0.1.0/LICENSE +194 -0
  4. mandatia-0.1.0/PKG-INFO +1006 -0
  5. mandatia-0.1.0/README.md +982 -0
  6. mandatia-0.1.0/docs/action-contest-spec.md +105 -0
  7. mandatia-0.1.0/docs/insurer-dossier-spec.md +81 -0
  8. mandatia-0.1.0/docs/mandate-attestation-spec.md +187 -0
  9. mandatia-0.1.0/docs/principal-signature-spec.md +238 -0
  10. mandatia-0.1.0/docs/public-registry-spec.md +163 -0
  11. mandatia-0.1.0/docs/release.md +86 -0
  12. mandatia-0.1.0/docs/report-issue-spec.md +88 -0
  13. mandatia-0.1.0/docs/revocation-spec.md +120 -0
  14. mandatia-0.1.0/docs/templates/agent-sante-rgpd.md +203 -0
  15. mandatia-0.1.0/docs/token-issuance-prompt.md +1119 -0
  16. mandatia-0.1.0/docs/token-issuance-spec.md +208 -0
  17. mandatia-0.1.0/examples/quickstart_agent.py +134 -0
  18. mandatia-0.1.0/llms.txt +28 -0
  19. mandatia-0.1.0/pyproject.toml +69 -0
  20. mandatia-0.1.0/server.json +44 -0
  21. mandatia-0.1.0/src/amr/__init__.py +1 -0
  22. mandatia-0.1.0/src/amr/attestation.py +369 -0
  23. mandatia-0.1.0/src/amr/config.py +60 -0
  24. mandatia-0.1.0/src/amr/crypto/__init__.py +1 -0
  25. mandatia-0.1.0/src/amr/crypto/chain.py +59 -0
  26. mandatia-0.1.0/src/amr/crypto/principal.py +161 -0
  27. mandatia-0.1.0/src/amr/crypto/signing.py +80 -0
  28. mandatia-0.1.0/src/amr/db/__init__.py +1 -0
  29. mandatia-0.1.0/src/amr/db/engine.py +548 -0
  30. mandatia-0.1.0/src/amr/delegation.py +74 -0
  31. mandatia-0.1.0/src/amr/did_web.py +379 -0
  32. mandatia-0.1.0/src/amr/models/__init__.py +4 -0
  33. mandatia-0.1.0/src/amr/models/attestation.py +17 -0
  34. mandatia-0.1.0/src/amr/models/dossier.py +51 -0
  35. mandatia-0.1.0/src/amr/models/mandate.py +81 -0
  36. mandatia-0.1.0/src/amr/models/organ_decision.py +147 -0
  37. mandatia-0.1.0/src/amr/models/perimeter.py +438 -0
  38. mandatia-0.1.0/src/amr/models/token.py +57 -0
  39. mandatia-0.1.0/src/amr/proof/__init__.py +1 -0
  40. mandatia-0.1.0/src/amr/proof/insurer_dossier.py +321 -0
  41. mandatia-0.1.0/src/amr/public_registry.py +656 -0
  42. mandatia-0.1.0/src/amr/server.py +57 -0
  43. mandatia-0.1.0/src/amr/templates/__init__.py +51 -0
  44. mandatia-0.1.0/src/amr/templates/agent_sante_rgpd.py +112 -0
  45. mandatia-0.1.0/src/amr/templates/base.py +205 -0
  46. mandatia-0.1.0/src/amr/tools/__init__.py +1 -0
  47. mandatia-0.1.0/src/amr/tools/check_action_token.py +228 -0
  48. mandatia-0.1.0/src/amr/tools/contest_action.py +698 -0
  49. mandatia-0.1.0/src/amr/tools/create_mandate.py +567 -0
  50. mandatia-0.1.0/src/amr/tools/export_insurer_dossier.py +312 -0
  51. mandatia-0.1.0/src/amr/tools/get_proof.py +529 -0
  52. mandatia-0.1.0/src/amr/tools/issue_action_token.py +389 -0
  53. mandatia-0.1.0/src/amr/tools/issue_mandate_attestation.py +323 -0
  54. mandatia-0.1.0/src/amr/tools/log_action.py +162 -0
  55. mandatia-0.1.0/src/amr/tools/principal_keys.py +323 -0
  56. mandatia-0.1.0/src/amr/tools/report_issue.py +220 -0
  57. mandatia-0.1.0/src/amr/tools/revoke_mandate.py +422 -0
  58. mandatia-0.1.0/src/amr/tools/verify_mandate.py +117 -0
  59. mandatia-0.1.0/src/amr/verify_attestation.py +73 -0
  60. mandatia-0.1.0/tests/__init__.py +1 -0
  61. mandatia-0.1.0/tests/_helpers.py +63 -0
  62. mandatia-0.1.0/tests/conftest.py +26 -0
  63. mandatia-0.1.0/tests/test_agent_onboarding.py +68 -0
  64. mandatia-0.1.0/tests/test_check_action_token.py +705 -0
  65. mandatia-0.1.0/tests/test_contest_action.py +896 -0
  66. mandatia-0.1.0/tests/test_create_mandate.py +91 -0
  67. mandatia-0.1.0/tests/test_crypto.py +83 -0
  68. mandatia-0.1.0/tests/test_delegation_depth.py +297 -0
  69. mandatia-0.1.0/tests/test_did_web.py +1046 -0
  70. mandatia-0.1.0/tests/test_insurer_dossier.py +633 -0
  71. mandatia-0.1.0/tests/test_integration_token_flow.py +152 -0
  72. mandatia-0.1.0/tests/test_issue_action_token.py +281 -0
  73. mandatia-0.1.0/tests/test_issued_tokens_db.py +195 -0
  74. mandatia-0.1.0/tests/test_log_and_proof.py +101 -0
  75. mandatia-0.1.0/tests/test_mandate_attestation.py +775 -0
  76. mandatia-0.1.0/tests/test_organ_decision.py +490 -0
  77. mandatia-0.1.0/tests/test_perimeter.py +586 -0
  78. mandatia-0.1.0/tests/test_period_ceiling.py +581 -0
  79. mandatia-0.1.0/tests/test_principal_signature.py +596 -0
  80. mandatia-0.1.0/tests/test_public_registry.py +666 -0
  81. mandatia-0.1.0/tests/test_release_packaging.py +272 -0
  82. mandatia-0.1.0/tests/test_report_issue.py +470 -0
  83. mandatia-0.1.0/tests/test_revocation_branch.py +265 -0
  84. mandatia-0.1.0/tests/test_revoke_mandate.py +765 -0
  85. mandatia-0.1.0/tests/test_risk_classes.py +608 -0
  86. mandatia-0.1.0/tests/test_signing.py +103 -0
  87. mandatia-0.1.0/tests/test_templates.py +387 -0
  88. mandatia-0.1.0/tests/test_token_lifetime_bound.py +204 -0
  89. mandatia-0.1.0/tests/test_token_models.py +77 -0
  90. mandatia-0.1.0/tests/test_verify_mandate.py +75 -0
@@ -0,0 +1,18 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ *.egg-info/
4
+ dist/
5
+ build/
6
+ .venv/
7
+ .env
8
+ amr_signing_key.pem
9
+ amr_signing_key.pub
10
+ *.db
11
+ *.db-wal
12
+ *.db-shm
13
+ .vscode/
14
+ .cursor/
15
+ .idea/
16
+ .DS_Store
17
+ Thumbs.db
18
+ amr_public_registry.jws
@@ -0,0 +1,73 @@
1
+ # AMR for agents
2
+
3
+ AMR (Agent Mandate Registry) is an MCP server that records which person or organization
4
+ (the principal) authorized which AI agent to do what, for how long, and keeps a
5
+ hash-chained, append-only journal of what the agent then did. Repository:
6
+ https://github.com/JC7333/amr (Apache-2.0). Human-readable guide: `README.md`.
7
+
8
+ ## Install and run
9
+
10
+ ```bash
11
+ uvx mandatia
12
+ ```
13
+
14
+ - Transport: stdio. Needs uv and Python 3.12 or later.
15
+ - The PyPI package is `mandatia`. `uvx amr` installs a different project.
16
+ - To run the latest code of the repository instead (keep `--with "mcp<2"` as a safety net:
17
+ AMR does not support version 2 of the MCP Python SDK yet):
18
+
19
+ ```bash
20
+ uvx --from git+https://github.com/JC7333/amr --with "mcp<2" amr
21
+ ```
22
+ - Set `AMR_DB_PATH`, `AMR_SIGNING_KEY_PATH`, `AMR_PUBLIC_KEY_PATH` to absolute paths,
23
+ or AMR writes them in the client's current directory. Never commit the `.pem` file.
24
+ - Runnable end-to-end example: `examples/quickstart_agent.py`.
25
+
26
+ ## What it does
27
+
28
+ | Tool | Use it to |
29
+ |---|---|
30
+ | `create_mandate` | Register a mandate (principal, agent, scope, legal basis, duration, optional perimeter) |
31
+ | `verify_mandate` | Ask whether an agent has an active, unexpired mandate (does not check the action against the perimeter) |
32
+ | `log_action` | Append an action to the chained journal of a mandate |
33
+ | `get_proof` | Export the full audit bundle of a mandate |
34
+ | `issue_action_token` | Get a signed token only if the mandate and its perimeter allow the action (this is where the perimeter is enforced) |
35
+ | `check_action_token` | For the receiver: re-check a token with the registry at the moment of acting (mandate and whole chain still active, not revoked, not expired) |
36
+ | `register_principal_key` | Register the principal's Ed25519 public key |
37
+ | `prepare_mandate_signature` | Build the exact bytes a principal signs for a mandate |
38
+ | `issue_mandate_attestation` | Issue a signed document a third party verifies offline |
39
+ | `get_registry_public_key` | Get the registry's public key to verify attestations and tokens |
40
+ | `export_insurer_dossier` | Export a signed, printable dossier of a mandate |
41
+ | `revoke_mandate` | Cut a mandate and every sub-mandate below it, immediately |
42
+ | `prepare_revocation_signature` | Build the exact bytes a principal signs to revoke |
43
+ | `contest_action` | Record that a principal disputes an act already logged, with a response deadline the operator chooses |
44
+ | `prepare_contest_signature` | Build the exact bytes a principal signs to contest an act |
45
+ | `list_action_contests` | The reminder: contested acts with the days left before their response deadline |
46
+ | `report_issue` | Report a problem with AMR itself (pre-filled link, or the issue filed when the operator set `AMR_ISSUE_TOKEN`) |
47
+
48
+ ## What it does not do
49
+
50
+ - It does not give legal advice and does not make anyone compliant with any
51
+ regulation; that stays with the operator.
52
+ - It does not check who a principal is, unless that principal registered a key and signs
53
+ its mandates (`register_principal_key`). For a `did:web:<domain>` principal, it checks
54
+ that the domain publishes the key; it never checks a qualified signature.
55
+ - It does not host anything: there is no hosted service. The registry runs where you
56
+ start it and trusts its own database file; protect that file.
57
+ - It makes no network call, except `report_issue` when the operator set `AMR_ISSUE_TOKEN`
58
+ (one HTTPS request to the GitHub API), and `register_principal_key` for a `did:web`
59
+ principal when the operator set `AMR_DID_WEB_RESOLVE=1` (one HTTPS request to that
60
+ domain's DID document). Tokens and attestations already issued stay valid until
61
+ their expiry after a revocation (the revocation response counts the tokens), unless the
62
+ receiver re-checks the token with `check_action_token` when it acts.
63
+ - Existing rows are never edited or deleted: status changes are new chained rows.
64
+
65
+ ## Reporting a problem
66
+
67
+ Call `report_issue(title, description, version, context)`. Without `AMR_ISSUE_TOKEN` it
68
+ returns `new_issue_url`, a pre-filled link to open; with it, it files the issue and
69
+ returns its link. PEM blocks, JWS-shaped tokens, GitHub tokens and bare Ed25519 private
70
+ keys are refused; other secrets and personal data are not detected, so never write them.
71
+ Or open an issue at https://github.com/JC7333/amr/issues with the version, the tool name,
72
+ the arguments you sent and the error returned. Do not include real mandate contents,
73
+ personal data, keys or tokens.
mandatia-0.1.0/LICENSE ADDED
@@ -0,0 +1,194 @@
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 made available under
36
+ the License, as indicated by a copyright notice that is included in
37
+ or attached to the work (an example is provided in the Appendix below).
38
+
39
+ "Derivative Works" shall mean any work, whether in Source or Object
40
+ form, that is based on (or derived from) the Work and for which the
41
+ editorial revisions, annotations, elaborations, or other modifications
42
+ represent, as a whole, an original work of authorship. For the purposes
43
+ of this License, Derivative Works shall not include works that remain
44
+ separable from, or merely link (or bind by name) to the interfaces of,
45
+ the Work and Derivative Works thereof.
46
+
47
+ "Contribution" shall mean, as submitted to the Licensor for inclusion
48
+ in the Work by the copyright owner or by an individual or Legal Entity
49
+ authorized to submit on behalf of the copyright owner. For the purposes
50
+ of this definition, "submitted" means any form of electronic, verbal,
51
+ or written communication sent to the Licensor or its representatives,
52
+ including but not limited to communication on electronic mailing lists,
53
+ source code control systems, and issue tracking systems that are managed
54
+ by, or on behalf of, the Licensor for the purpose of discussing and
55
+ improving the Work, but excluding communication that is conspicuously
56
+ marked or otherwise designated in writing by the copyright owner as
57
+ "Not a Contribution."
58
+
59
+ "Contributor" shall mean Licensor and any Legal Entity on behalf of
60
+ whom a Contribution has been received by the Licensor and subsequently
61
+ incorporated within the Work.
62
+
63
+ 2. Grant of Copyright License. Subject to the terms and conditions of
64
+ this License, each Contributor hereby grants to You a perpetual,
65
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
66
+ copyright license to reproduce, prepare Derivative Works of,
67
+ publicly display, publicly perform, sublicense, and distribute the
68
+ Work and such Derivative Works in Source or Object form.
69
+
70
+ 3. Grant of Patent License. Subject to the terms and conditions of
71
+ this License, each Contributor hereby grants to You a perpetual,
72
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
73
+ (except as stated in this section) patent license to make, have made,
74
+ use, offer to sell, sell, import, and otherwise transfer the Work,
75
+ where such license applies only to those patent claims licensable
76
+ by such Contributor that are necessarily infringed by their
77
+ Contribution(s) alone or by combination of their Contribution(s)
78
+ with the Work to which such Contribution(s) was submitted. If You
79
+ institute patent litigation against any entity (including a
80
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
81
+ or a Contribution incorporated within the Work constitutes direct
82
+ or contributory patent infringement, then any patent licenses
83
+ granted to You under this License for that Work shall terminate
84
+ as of the date such litigation is filed.
85
+
86
+ 4. Redistribution. You may reproduce and distribute copies of the
87
+ Work or Derivative Works thereof in any medium, with or without
88
+ modifications, and in Source or Object form, provided that You
89
+ meet the following conditions:
90
+
91
+ (a) You must give any other recipients of the Work or
92
+ Derivative Works a copy of this License; and
93
+
94
+ (b) You must cause any modified files to carry prominent notices
95
+ stating that You changed the files; and
96
+
97
+ (c) You must retain, in the Source form of any Derivative Works
98
+ that You distribute, all copyright, patent, trademark, and
99
+ attribution notices from the Source form of the Work,
100
+ excluding those notices that do not pertain to any part of
101
+ the Derivative Works; and
102
+
103
+ (d) If the Work includes a "NOTICE" text file as part of its
104
+ distribution, You must include a readable copy of the
105
+ attribution notices contained within such NOTICE file, in
106
+ at least one of the following places: within a NOTICE text
107
+ file distributed as part of the Derivative Works; within
108
+ the Source form or documentation, if provided along with the
109
+ Derivative Works; or, within a display generated by the
110
+ Derivative Works, if and wherever such third-party notices
111
+ normally appear. The contents of the NOTICE file are for
112
+ informational purposes only and do not modify the License.
113
+ You may add Your own attribution notices within Derivative
114
+ Works that You distribute, alongside or as an addendum to
115
+ the NOTICE text from the Work, provided that such additional
116
+ attribution notices cannot be construed as modifying the License.
117
+
118
+ You may add Your own license statement for Your modifications and
119
+ may provide additional grant of rights to use, copy, modify, merge,
120
+ publish, distribute, sublicense, and/or sell copies of the
121
+ Derivative Works, and to permit persons to whom the Derivative Works
122
+ is furnished to do so.
123
+
124
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
125
+ any Contribution intentionally submitted for inclusion in the Work
126
+ by You to the Licensor shall be under the terms and conditions of
127
+ this License, without any additional terms or conditions.
128
+ Notwithstanding the above, nothing herein shall supersede or modify
129
+ the terms of any separate license agreement you may have executed
130
+ with Licensor regarding such Contributions.
131
+
132
+ 6. Trademarks. This License does not grant permission to use the trade
133
+ names, trademarks, service marks, or product names of the Licensor,
134
+ except as required for reasonable and customary use in describing the
135
+ origin of the Work and reproducing the content of the NOTICE file.
136
+
137
+ 7. Disclaimer of Warranty. Unless required by applicable law or
138
+ agreed to in writing, Licensor provides the Work (and each
139
+ Contributor provides its Contributions) on an "AS IS" BASIS,
140
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
141
+ implied, including, without limitation, any warranties or conditions
142
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
143
+ PARTICULAR PURPOSE. You are solely responsible for determining the
144
+ appropriateness of using or reproducing the Work and assume any
145
+ risks associated with Your exercise of permissions under this License.
146
+
147
+ 8. Limitation of Liability. In no event and under no legal theory,
148
+ whether in tort (including negligence), contract, or otherwise,
149
+ unless required by applicable law (such as deliberate and grossly
150
+ negligent acts) or agreed to in writing, shall any Contributor be
151
+ liable to You for damages, including any direct, indirect, special,
152
+ incidental, or exemplary damages of any character arising as a
153
+ result of this License or out of the use or inability to use the
154
+ Work (including but not limited to damages for loss of goodwill,
155
+ work stoppage, computer failure or malfunction, or all other
156
+ commercial damages or losses), even if such Contributor has been
157
+ advised of the possibility of such damages.
158
+
159
+ 9. Accepting Warranty or Additional Liability. While redistributing
160
+ the Work or Derivative Works thereof, You may choose to offer,
161
+ and charge a fee for, acceptance of support, warranty, indemnity,
162
+ or other liability obligations and/or rights consistent with this
163
+ License. However, in accepting such obligations, You may act only
164
+ on Your own behalf and on Your sole responsibility, not on behalf
165
+ of any other Contributor, and only if You agree to indemnify,
166
+ defend, and hold each Contributor harmless for any liability
167
+ incurred by, or claims asserted against, such Contributor by reason
168
+ of your accepting any such warranty or additional liability.
169
+
170
+ END OF TERMS AND CONDITIONS
171
+
172
+ APPENDIX: How to apply the Apache License to your work.
173
+
174
+ To apply the Apache License to your work, attach the following
175
+ boilerplate notice, with the fields enclosed by brackets "[]"
176
+ replaced with your own identifying information. (Don't include
177
+ the brackets!) The text should be enclosed in the appropriate
178
+ comment syntax for the file format. Please also include a
179
+ "NOTICE" file describing any modifications you have made to the
180
+ original software. To do so, attach the following:
181
+
182
+ Copyright 2026 Audric Bugnard
183
+
184
+ Licensed under the Apache License, Version 2.0 (the "License");
185
+ you may not use this file except in compliance with the License.
186
+ You may obtain a copy of the License at
187
+
188
+ http://www.apache.org/licenses/LICENSE-2.0
189
+
190
+ Unless required by applicable law or agreed to in writing, software
191
+ distributed under the License is distributed on an "AS IS" BASIS,
192
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
193
+ See the License for the specific language governing permissions and
194
+ limitations under the License.