haiman-protocol 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.
- haiman_protocol-0.1.0/.gitignore +22 -0
- haiman_protocol-0.1.0/CHANGELOG.md +23 -0
- haiman_protocol-0.1.0/LICENSE +201 -0
- haiman_protocol-0.1.0/LICENSE-SCHEMAS +16 -0
- haiman_protocol-0.1.0/PKG-INFO +118 -0
- haiman_protocol-0.1.0/README.md +97 -0
- haiman_protocol-0.1.0/pyproject.toml +54 -0
- haiman_protocol-0.1.0/schemas/common/envelope.schema.json +53 -0
- haiman_protocol-0.1.0/schemas/common/error.schema.json +43 -0
- haiman_protocol-0.1.0/schemas/common/tone.v1.schema.json +18 -0
- haiman_protocol-0.1.0/schemas/common/topic.v1.schema.json +13 -0
- haiman_protocol-0.1.0/schemas/handoffs/engagement-flag-to-sdr.v1.schema.json +35 -0
- haiman_protocol-0.1.0/schemas/handoffs/positive-reply-to-crm.v1.schema.json +50 -0
- haiman_protocol-0.1.0/schemas/handoffs/stalled-deal-reactivate.v1.schema.json +31 -0
- haiman_protocol-0.1.0/schemas/ops/accept.v1.schema.json +16 -0
- haiman_protocol-0.1.0/schemas/ops/contribute-signal.v1.schema.json +77 -0
- haiman_protocol-0.1.0/schemas/ops/edit.v1.schema.json +26 -0
- haiman_protocol-0.1.0/schemas/ops/handoff.v1.schema.json +23 -0
- haiman_protocol-0.1.0/schemas/ops/handshake.v1.schema.json +31 -0
- haiman_protocol-0.1.0/schemas/ops/notify.v1.schema.json +29 -0
- haiman_protocol-0.1.0/schemas/ops/propose.v1.schema.json +35 -0
- haiman_protocol-0.1.0/schemas/ops/query.v1.schema.json +19 -0
- haiman_protocol-0.1.0/schemas/ops/reject.v1.schema.json +31 -0
- haiman_protocol-0.1.0/src/haiman_protocol/__init__.py +99 -0
- haiman_protocol-0.1.0/src/haiman_protocol/envelope.py +70 -0
- haiman_protocol-0.1.0/src/haiman_protocol/errors.py +120 -0
- haiman_protocol-0.1.0/src/haiman_protocol/optypes.py +93 -0
- haiman_protocol-0.1.0/src/haiman_protocol/py.typed +0 -0
- haiman_protocol-0.1.0/src/haiman_protocol/store.py +108 -0
- haiman_protocol-0.1.0/src/haiman_protocol/validate.py +83 -0
- haiman_protocol-0.1.0/src/haiman_protocol/version.py +10 -0
- haiman_protocol-0.1.0/tests/test_envelope.py +87 -0
- haiman_protocol-0.1.0/tests/test_errors.py +76 -0
- haiman_protocol-0.1.0/tests/test_examples_valid.py +221 -0
- haiman_protocol-0.1.0/tests/test_invalid_payloads.py +88 -0
- haiman_protocol-0.1.0/tests/test_optypes_match_schemas.py +55 -0
- haiman_protocol-0.1.0/tests/test_schemas_load.py +41 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*.egg-info/
|
|
5
|
+
.eggs/
|
|
6
|
+
build/
|
|
7
|
+
dist/
|
|
8
|
+
.venv/
|
|
9
|
+
venv/
|
|
10
|
+
.env
|
|
11
|
+
|
|
12
|
+
# Tooling caches
|
|
13
|
+
.pytest_cache/
|
|
14
|
+
.mypy_cache/
|
|
15
|
+
.ruff_cache/
|
|
16
|
+
.coverage
|
|
17
|
+
htmlcov/
|
|
18
|
+
|
|
19
|
+
# OS / editor
|
|
20
|
+
.DS_Store
|
|
21
|
+
.idea/
|
|
22
|
+
.vscode/
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.1.0 (unreleased)
|
|
4
|
+
|
|
5
|
+
Initial standalone extraction of the Haiman protocol from the monorepo's
|
|
6
|
+
in-process implementation.
|
|
7
|
+
|
|
8
|
+
- `schemas/` — JSON Schema (Draft 2020-12) files for the v1 wire format:
|
|
9
|
+
common envelope + error + value schemas (tone.v1, topic.v1); the nine op
|
|
10
|
+
request payloads (handshake, propose, edit, accept, reject,
|
|
11
|
+
contribute-signal, query, handoff, notify); the three v1 typed handoff inner
|
|
12
|
+
payloads (engagement-flag-to-sdr, positive-reply-to-crm,
|
|
13
|
+
stalled-deal-reactivate).
|
|
14
|
+
- `haiman_protocol` Python SDK — schema store/loader, payload/envelope/message
|
|
15
|
+
validation, the section 1.5 error taxonomy, vocabularies, and the canonical
|
|
16
|
+
cross-vendor `WireEnvelope`.
|
|
17
|
+
- Tests: schema validity, golden positive examples, negative cases, an
|
|
18
|
+
anti-drift check that the Python vocabularies match the schema enums, and
|
|
19
|
+
envelope round-tripping.
|
|
20
|
+
|
|
21
|
+
Not yet done (next): refactor the Haiman monorepo's `app/protocol.py` to import
|
|
22
|
+
this package instead of carrying validation inline; formal conformance test
|
|
23
|
+
suite; `did:web` hosting profile and VC schemas.
|
|
@@ -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 Haiman
|
|
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,16 @@
|
|
|
1
|
+
Haiman protocol schemas — license notice
|
|
2
|
+
========================================
|
|
3
|
+
|
|
4
|
+
The JSON Schema files under `schemas/` are licensed under the
|
|
5
|
+
Creative Commons Attribution 4.0 International License (CC-BY-4.0).
|
|
6
|
+
|
|
7
|
+
SPDX-License-Identifier: CC-BY-4.0
|
|
8
|
+
|
|
9
|
+
You are free to share and adapt the schemas for any purpose, including
|
|
10
|
+
commercially, provided you give appropriate credit. Full license text:
|
|
11
|
+
https://creativecommons.org/licenses/by/4.0/legalcode
|
|
12
|
+
|
|
13
|
+
The reference SDK (everything under `src/`) is licensed separately under
|
|
14
|
+
Apache-2.0; see the LICENSE file.
|
|
15
|
+
|
|
16
|
+
Attribution: "Haiman protocol schemas, https://haiman.ai".
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: haiman-protocol
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Open reference SDK and JSON Schemas for the Haiman personal-AI substrate protocol.
|
|
5
|
+
Project-URL: Homepage, https://haiman.ai
|
|
6
|
+
Project-URL: Source, https://github.com/haiman-ai/haiman-protocol
|
|
7
|
+
Author-email: Haiman <carl@haiman.ai>
|
|
8
|
+
License-Expression: Apache-2.0
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
License-File: LICENSE-SCHEMAS
|
|
11
|
+
Keywords: agent,did,haiman,personal-ai,protocol,verifiable-credentials
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
16
|
+
Requires-Python: >=3.10
|
|
17
|
+
Requires-Dist: jsonschema>=4.18
|
|
18
|
+
Provides-Extra: dev
|
|
19
|
+
Requires-Dist: pytest>=7; extra == 'dev'
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
|
|
22
|
+
# haiman-protocol
|
|
23
|
+
|
|
24
|
+
Open schemas and reference SDK for the **Haiman protocol**: the contract that
|
|
25
|
+
lets a person's AI and a service interoperate under scoped, revocable, audited
|
|
26
|
+
grants.
|
|
27
|
+
|
|
28
|
+
Haiman is the personal-AI substrate layer (the user owns the model; services
|
|
29
|
+
are clients of it), sitting above MCP (AI consumes tools) and alongside A2A
|
|
30
|
+
(agents coordinate). This repository is the **connective tissue**: the
|
|
31
|
+
wire-format schemas and a Python binding for them.
|
|
32
|
+
|
|
33
|
+
## Posture
|
|
34
|
+
|
|
35
|
+
Open schema, open reference implementation, paid conformance authority:
|
|
36
|
+
|
|
37
|
+
- **Schemas** (`schemas/`) are the open artifact, licensed **CC-BY-4.0**.
|
|
38
|
+
Anyone can read and implement against them.
|
|
39
|
+
- **Reference SDK** (`src/haiman_protocol/`) is licensed **Apache-2.0**.
|
|
40
|
+
- The certification mark, conformance test suite, and production grant-token
|
|
41
|
+
issuer infrastructure are operated by Haiman as the neutral conformance
|
|
42
|
+
authority. They are not in this repository.
|
|
43
|
+
|
|
44
|
+
This is the OpenID Foundation / Bluetooth SIG / Khronos playbook: open the wire
|
|
45
|
+
format, charge for the conformance authority. A schema-donation path to a
|
|
46
|
+
neutral standards body is committed in the Haiman platform model.
|
|
47
|
+
|
|
48
|
+
## What's here
|
|
49
|
+
|
|
50
|
+
```
|
|
51
|
+
schemas/
|
|
52
|
+
common/ envelope, error, and shared value schemas (tone.v1, topic.v1)
|
|
53
|
+
ops/ the nine v1 operations (request payloads)
|
|
54
|
+
handoffs/ typed inter-service handoff inner payloads
|
|
55
|
+
src/haiman_protocol/
|
|
56
|
+
validate.py validate payloads / envelopes / whole messages against the schemas
|
|
57
|
+
errors.py the section 1.5 error taxonomy (9 semantic types)
|
|
58
|
+
optypes.py vocabularies (op types, handoff types, notify events, enums)
|
|
59
|
+
envelope.py the canonical cross-vendor wire envelope (DID + VC fields)
|
|
60
|
+
store.py locates and loads the bundled schema files
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
The nine operations: `handshake`, `propose`, `edit`, `accept`, `reject`,
|
|
64
|
+
`contribute-signal`, `query`, `handoff`, `notify`.
|
|
65
|
+
|
|
66
|
+
## Install
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
pip install -e ".[dev]" # editable, with test deps
|
|
70
|
+
pytest
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Requires Python 3.10+. The only runtime dependency is `jsonschema`.
|
|
74
|
+
|
|
75
|
+
## Use
|
|
76
|
+
|
|
77
|
+
```python
|
|
78
|
+
from haiman_protocol import (
|
|
79
|
+
WireEnvelope, validate_payload, validate_message, SchemaInvalid,
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
# Validate just a payload by op type
|
|
83
|
+
validate_payload("propose.v1", {
|
|
84
|
+
"instruction": "Draft a follow-up email.",
|
|
85
|
+
"structured_context": {"channel": "email"},
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
# Build and validate a whole message (envelope + payload, and for handoffs the
|
|
89
|
+
# inner payload too)
|
|
90
|
+
env = WireEnvelope(
|
|
91
|
+
op_type="propose.v1",
|
|
92
|
+
subject="did:web:user.haiman.ai:u:0193abcd",
|
|
93
|
+
scope_ref="scp_0193def",
|
|
94
|
+
service_certification="urn:haiman:vc:cert:0193sdr",
|
|
95
|
+
grant_credential="eyJhbGc...",
|
|
96
|
+
payload={"instruction": "Draft a follow-up email.",
|
|
97
|
+
"structured_context": {"channel": "email"}},
|
|
98
|
+
).to_dict()
|
|
99
|
+
validate_message(env) # raises SchemaInvalid on a bad message
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Validation failures raise `haiman_protocol.SchemaInvalid` (an error type in the
|
|
103
|
+
section 1.5 taxonomy) with a readable message and a JSON Pointer to the
|
|
104
|
+
offending node.
|
|
105
|
+
|
|
106
|
+
## Versioning
|
|
107
|
+
|
|
108
|
+
Schemas are named `op.vN`. Within a major version, adding optional fields is
|
|
109
|
+
non-breaking and receivers ignore unknown fields. Breaking changes bump the
|
|
110
|
+
version; N-1 is supported for 12 months after N ships. The SDK package version
|
|
111
|
+
(`haiman_protocol.__version__`) is independent of the protocol schema
|
|
112
|
+
generation (`haiman_protocol.PROTOCOL_VERSION`).
|
|
113
|
+
|
|
114
|
+
## Status
|
|
115
|
+
|
|
116
|
+
`v1` schemas, alpha. This is the standalone extraction of the protocol from the
|
|
117
|
+
Haiman monorepo's in-process implementation; the design of record is the Haiman
|
|
118
|
+
protocol specification.
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
# haiman-protocol
|
|
2
|
+
|
|
3
|
+
Open schemas and reference SDK for the **Haiman protocol**: the contract that
|
|
4
|
+
lets a person's AI and a service interoperate under scoped, revocable, audited
|
|
5
|
+
grants.
|
|
6
|
+
|
|
7
|
+
Haiman is the personal-AI substrate layer (the user owns the model; services
|
|
8
|
+
are clients of it), sitting above MCP (AI consumes tools) and alongside A2A
|
|
9
|
+
(agents coordinate). This repository is the **connective tissue**: the
|
|
10
|
+
wire-format schemas and a Python binding for them.
|
|
11
|
+
|
|
12
|
+
## Posture
|
|
13
|
+
|
|
14
|
+
Open schema, open reference implementation, paid conformance authority:
|
|
15
|
+
|
|
16
|
+
- **Schemas** (`schemas/`) are the open artifact, licensed **CC-BY-4.0**.
|
|
17
|
+
Anyone can read and implement against them.
|
|
18
|
+
- **Reference SDK** (`src/haiman_protocol/`) is licensed **Apache-2.0**.
|
|
19
|
+
- The certification mark, conformance test suite, and production grant-token
|
|
20
|
+
issuer infrastructure are operated by Haiman as the neutral conformance
|
|
21
|
+
authority. They are not in this repository.
|
|
22
|
+
|
|
23
|
+
This is the OpenID Foundation / Bluetooth SIG / Khronos playbook: open the wire
|
|
24
|
+
format, charge for the conformance authority. A schema-donation path to a
|
|
25
|
+
neutral standards body is committed in the Haiman platform model.
|
|
26
|
+
|
|
27
|
+
## What's here
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
schemas/
|
|
31
|
+
common/ envelope, error, and shared value schemas (tone.v1, topic.v1)
|
|
32
|
+
ops/ the nine v1 operations (request payloads)
|
|
33
|
+
handoffs/ typed inter-service handoff inner payloads
|
|
34
|
+
src/haiman_protocol/
|
|
35
|
+
validate.py validate payloads / envelopes / whole messages against the schemas
|
|
36
|
+
errors.py the section 1.5 error taxonomy (9 semantic types)
|
|
37
|
+
optypes.py vocabularies (op types, handoff types, notify events, enums)
|
|
38
|
+
envelope.py the canonical cross-vendor wire envelope (DID + VC fields)
|
|
39
|
+
store.py locates and loads the bundled schema files
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
The nine operations: `handshake`, `propose`, `edit`, `accept`, `reject`,
|
|
43
|
+
`contribute-signal`, `query`, `handoff`, `notify`.
|
|
44
|
+
|
|
45
|
+
## Install
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
pip install -e ".[dev]" # editable, with test deps
|
|
49
|
+
pytest
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Requires Python 3.10+. The only runtime dependency is `jsonschema`.
|
|
53
|
+
|
|
54
|
+
## Use
|
|
55
|
+
|
|
56
|
+
```python
|
|
57
|
+
from haiman_protocol import (
|
|
58
|
+
WireEnvelope, validate_payload, validate_message, SchemaInvalid,
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
# Validate just a payload by op type
|
|
62
|
+
validate_payload("propose.v1", {
|
|
63
|
+
"instruction": "Draft a follow-up email.",
|
|
64
|
+
"structured_context": {"channel": "email"},
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
# Build and validate a whole message (envelope + payload, and for handoffs the
|
|
68
|
+
# inner payload too)
|
|
69
|
+
env = WireEnvelope(
|
|
70
|
+
op_type="propose.v1",
|
|
71
|
+
subject="did:web:user.haiman.ai:u:0193abcd",
|
|
72
|
+
scope_ref="scp_0193def",
|
|
73
|
+
service_certification="urn:haiman:vc:cert:0193sdr",
|
|
74
|
+
grant_credential="eyJhbGc...",
|
|
75
|
+
payload={"instruction": "Draft a follow-up email.",
|
|
76
|
+
"structured_context": {"channel": "email"}},
|
|
77
|
+
).to_dict()
|
|
78
|
+
validate_message(env) # raises SchemaInvalid on a bad message
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Validation failures raise `haiman_protocol.SchemaInvalid` (an error type in the
|
|
82
|
+
section 1.5 taxonomy) with a readable message and a JSON Pointer to the
|
|
83
|
+
offending node.
|
|
84
|
+
|
|
85
|
+
## Versioning
|
|
86
|
+
|
|
87
|
+
Schemas are named `op.vN`. Within a major version, adding optional fields is
|
|
88
|
+
non-breaking and receivers ignore unknown fields. Breaking changes bump the
|
|
89
|
+
version; N-1 is supported for 12 months after N ships. The SDK package version
|
|
90
|
+
(`haiman_protocol.__version__`) is independent of the protocol schema
|
|
91
|
+
generation (`haiman_protocol.PROTOCOL_VERSION`).
|
|
92
|
+
|
|
93
|
+
## Status
|
|
94
|
+
|
|
95
|
+
`v1` schemas, alpha. This is the standalone extraction of the protocol from the
|
|
96
|
+
Haiman monorepo's in-process implementation; the design of record is the Haiman
|
|
97
|
+
protocol specification.
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "haiman-protocol"
|
|
7
|
+
description = "Open reference SDK and JSON Schemas for the Haiman personal-AI substrate protocol."
|
|
8
|
+
readme = "README.md"
|
|
9
|
+
requires-python = ">=3.10"
|
|
10
|
+
license = "Apache-2.0"
|
|
11
|
+
license-files = ["LICENSE", "LICENSE-SCHEMAS"]
|
|
12
|
+
authors = [{ name = "Haiman", email = "carl@haiman.ai" }]
|
|
13
|
+
keywords = ["haiman", "personal-ai", "protocol", "did", "verifiable-credentials", "agent"]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Development Status :: 3 - Alpha",
|
|
16
|
+
"Intended Audience :: Developers",
|
|
17
|
+
"Programming Language :: Python :: 3",
|
|
18
|
+
"Topic :: Software Development :: Libraries",
|
|
19
|
+
]
|
|
20
|
+
dependencies = ["jsonschema>=4.18"]
|
|
21
|
+
dynamic = ["version"]
|
|
22
|
+
|
|
23
|
+
[project.optional-dependencies]
|
|
24
|
+
dev = ["pytest>=7"]
|
|
25
|
+
|
|
26
|
+
[project.urls]
|
|
27
|
+
Homepage = "https://haiman.ai"
|
|
28
|
+
Source = "https://github.com/haiman-ai/haiman-protocol"
|
|
29
|
+
|
|
30
|
+
[tool.hatch.version]
|
|
31
|
+
path = "src/haiman_protocol/version.py"
|
|
32
|
+
|
|
33
|
+
[tool.hatch.build.targets.wheel]
|
|
34
|
+
packages = ["src/haiman_protocol"]
|
|
35
|
+
|
|
36
|
+
# Ship the open schemas inside the wheel so importlib.resources can find them
|
|
37
|
+
# at runtime when pip-installed. In editable / source checkouts the loader
|
|
38
|
+
# falls back to the repo-root schemas/ dir (see store.schema_root()).
|
|
39
|
+
[tool.hatch.build.targets.wheel.force-include]
|
|
40
|
+
"schemas" = "haiman_protocol/schemas"
|
|
41
|
+
|
|
42
|
+
[tool.hatch.build.targets.sdist]
|
|
43
|
+
include = [
|
|
44
|
+
"src/haiman_protocol",
|
|
45
|
+
"schemas",
|
|
46
|
+
"tests",
|
|
47
|
+
"README.md",
|
|
48
|
+
"CHANGELOG.md",
|
|
49
|
+
"LICENSE",
|
|
50
|
+
"LICENSE-SCHEMAS",
|
|
51
|
+
]
|
|
52
|
+
|
|
53
|
+
[tool.pytest.ini_options]
|
|
54
|
+
testpaths = ["tests"]
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://haiman.ai/protocol/schemas/common/envelope.schema.json",
|
|
4
|
+
"title": "Haiman protocol common envelope (v1, cross-vendor wire form)",
|
|
5
|
+
"description": "Fixed envelope wrapping every protocol message. Identity is W3C-native: subject is a W3C DID; service_certification and grant_credential are W3C Verifiable Credentials. See the Haiman protocol specification section 1.3. Async result envelopes drop grant_credential and add a status field; the handshake op is the one op where scope_ref may be omitted. Unknown fields are ignored by receivers (forward-compatible), so additionalProperties stays permissive.",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"required": ["op_id", "op_type", "timestamp", "subject", "payload"],
|
|
8
|
+
"properties": {
|
|
9
|
+
"op_id": {
|
|
10
|
+
"type": "string",
|
|
11
|
+
"description": "Idempotency key. UUID v7 in production; any UUID string accepted at the schema layer. Retries with the same op_id are no-ops at the receiver.",
|
|
12
|
+
"minLength": 1
|
|
13
|
+
},
|
|
14
|
+
"op_type": {
|
|
15
|
+
"type": "string",
|
|
16
|
+
"description": "op.vN format, e.g. propose.v1.",
|
|
17
|
+
"pattern": "^[a-z][a-z-]*\\.v[0-9]+$"
|
|
18
|
+
},
|
|
19
|
+
"timestamp": {
|
|
20
|
+
"type": "string",
|
|
21
|
+
"format": "date-time",
|
|
22
|
+
"description": "Sender's clock, ISO 8601. Receivers should not reject on skew alone."
|
|
23
|
+
},
|
|
24
|
+
"service_certification": {
|
|
25
|
+
"type": "string",
|
|
26
|
+
"description": "Compact reference (URN) to a W3C VC of type HaimanServiceCertificationCredential issued by Haiman as conformance authority. Required on requests; omitted on async results.",
|
|
27
|
+
"minLength": 1
|
|
28
|
+
},
|
|
29
|
+
"grant_credential": {
|
|
30
|
+
"type": "string",
|
|
31
|
+
"description": "User-issued, Haiman-signed W3C VC (JWT-VC compact form) proving this user authorised this service for these scopes. Present on requests; dropped on async result envelopes.",
|
|
32
|
+
"minLength": 1
|
|
33
|
+
},
|
|
34
|
+
"subject": {
|
|
35
|
+
"type": "string",
|
|
36
|
+
"description": "The user identifier as a W3C DID. v1 uses did:web; did:haiman reserved.",
|
|
37
|
+
"pattern": "^did:[a-z0-9]+:.+"
|
|
38
|
+
},
|
|
39
|
+
"scope_ref": {
|
|
40
|
+
"type": "string",
|
|
41
|
+
"description": "The specific granted scope this op operates within. Optional only for handshake."
|
|
42
|
+
},
|
|
43
|
+
"status": {
|
|
44
|
+
"type": "string",
|
|
45
|
+
"description": "Present on async result envelopes only.",
|
|
46
|
+
"enum": ["pending", "complete", "error"]
|
|
47
|
+
},
|
|
48
|
+
"payload": {
|
|
49
|
+
"type": "object",
|
|
50
|
+
"description": "Op-specific payload; validate against the matching ops/<op_type>.schema.json."
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://haiman.ai/protocol/schemas/common/error.schema.json",
|
|
4
|
+
"title": "Haiman protocol error envelope (v1)",
|
|
5
|
+
"description": "Returned in place of a result when an op fails. See the Haiman protocol specification section 1.5. The error.type taxonomy maps one-to-one to an HTTP code and a retry posture.",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"required": ["op_id", "op_type", "status", "error"],
|
|
8
|
+
"properties": {
|
|
9
|
+
"op_id": { "type": "string", "minLength": 1 },
|
|
10
|
+
"op_type": { "type": "string", "pattern": "^[a-z][a-z-]*\\.v[0-9]+$" },
|
|
11
|
+
"status": { "const": "error" },
|
|
12
|
+
"error": {
|
|
13
|
+
"type": "object",
|
|
14
|
+
"required": ["code", "type", "message"],
|
|
15
|
+
"properties": {
|
|
16
|
+
"code": {
|
|
17
|
+
"type": "integer",
|
|
18
|
+
"description": "HTTP status code for the semantic type."
|
|
19
|
+
},
|
|
20
|
+
"type": {
|
|
21
|
+
"type": "string",
|
|
22
|
+
"description": "Semantic error type. Drives retry behaviour.",
|
|
23
|
+
"enum": [
|
|
24
|
+
"uncertified",
|
|
25
|
+
"ungranted",
|
|
26
|
+
"scope_violation",
|
|
27
|
+
"schema_invalid",
|
|
28
|
+
"idempotency_conflict",
|
|
29
|
+
"not_found",
|
|
30
|
+
"rate_limited",
|
|
31
|
+
"unavailable",
|
|
32
|
+
"internal_error"
|
|
33
|
+
]
|
|
34
|
+
},
|
|
35
|
+
"message": { "type": "string" },
|
|
36
|
+
"retry_after": {
|
|
37
|
+
"type": "integer",
|
|
38
|
+
"description": "Seconds; populated for rate_limited (and may be set for unavailable)."
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://haiman.ai/protocol/schemas/common/tone.v1.schema.json",
|
|
4
|
+
"title": "tone.v1 value schema",
|
|
5
|
+
"description": "Common value schema for a tone result (e.g. query.v1 user.preferences.tone.default). See the Haiman protocol specification section 3.5. primary is drawn from a published vocabulary; modifiers are free-form short tags, unknown ones ignored gracefully.",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"required": ["primary"],
|
|
8
|
+
"properties": {
|
|
9
|
+
"primary": {
|
|
10
|
+
"type": "string",
|
|
11
|
+
"description": "Enum from a published vocabulary (warm-direct, formal-precise, casual-friendly, ...). Not hard-enumed here: the vocabulary grows under minor revisions and receivers ignore unknown values."
|
|
12
|
+
},
|
|
13
|
+
"modifiers": {
|
|
14
|
+
"type": "array",
|
|
15
|
+
"items": { "type": "string" }
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://haiman.ai/protocol/schemas/common/topic.v1.schema.json",
|
|
4
|
+
"title": "topic.v1 value schema",
|
|
5
|
+
"description": "Common value schema for an engaged topic (e.g. query.v1 user.context.recent_topics). See the Haiman protocol specification section 3.5.",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"required": ["label"],
|
|
8
|
+
"properties": {
|
|
9
|
+
"label": { "type": "string" },
|
|
10
|
+
"weight": { "type": "number", "minimum": 0, "maximum": 1 },
|
|
11
|
+
"last_engaged_at": { "type": "string", "format": "date-time" }
|
|
12
|
+
}
|
|
13
|
+
}
|