agentcapsule 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 (72) hide show
  1. agentcapsule-0.1.0/LICENSE +201 -0
  2. agentcapsule-0.1.0/PKG-INFO +421 -0
  3. agentcapsule-0.1.0/README.md +395 -0
  4. agentcapsule-0.1.0/pyproject.toml +50 -0
  5. agentcapsule-0.1.0/setup.cfg +4 -0
  6. agentcapsule-0.1.0/src/agentcapsule/__init__.py +11 -0
  7. agentcapsule-0.1.0/src/agentcapsule/audit.py +73 -0
  8. agentcapsule-0.1.0/src/agentcapsule/backends.py +157 -0
  9. agentcapsule-0.1.0/src/agentcapsule/cli.py +727 -0
  10. agentcapsule-0.1.0/src/agentcapsule/envelope.py +242 -0
  11. agentcapsule-0.1.0/src/agentcapsule/errors.py +23 -0
  12. agentcapsule-0.1.0/src/agentcapsule/manifest.py +273 -0
  13. agentcapsule-0.1.0/src/agentcapsule/policy.py +158 -0
  14. agentcapsule-0.1.0/src/agentcapsule/registry.py +54 -0
  15. agentcapsule-0.1.0/src/agentcapsule/scanner.py +197 -0
  16. agentcapsule-0.1.0/src/agentcapsule/signing.py +219 -0
  17. agentcapsule-0.1.0/src/agentcapsule/trust.py +174 -0
  18. agentcapsule-0.1.0/src/agentcapsule.egg-info/PKG-INFO +421 -0
  19. agentcapsule-0.1.0/src/agentcapsule.egg-info/SOURCES.txt +70 -0
  20. agentcapsule-0.1.0/src/agentcapsule.egg-info/dependency_links.txt +1 -0
  21. agentcapsule-0.1.0/src/agentcapsule.egg-info/entry_points.txt +3 -0
  22. agentcapsule-0.1.0/src/agentcapsule.egg-info/requires.txt +3 -0
  23. agentcapsule-0.1.0/src/agentcapsule.egg-info/top_level.txt +2 -0
  24. agentcapsule-0.1.0/src/lmcodec/__init__.py +18 -0
  25. agentcapsule-0.1.0/src/lmcodec/armour.py +117 -0
  26. agentcapsule-0.1.0/src/lmcodec/benchmarking.py +154 -0
  27. agentcapsule-0.1.0/src/lmcodec/bitstream.py +65 -0
  28. agentcapsule-0.1.0/src/lmcodec/carrier_quality.py +79 -0
  29. agentcapsule-0.1.0/src/lmcodec/cli.py +177 -0
  30. agentcapsule-0.1.0/src/lmcodec/codec.py +159 -0
  31. agentcapsule-0.1.0/src/lmcodec/errors.py +6 -0
  32. agentcapsule-0.1.0/src/lmcodec/experiments.py +184 -0
  33. agentcapsule-0.1.0/src/lmcodec/framing.py +62 -0
  34. agentcapsule-0.1.0/src/lmcodec/lm.py +219 -0
  35. agentcapsule-0.1.0/src/lmcodec/probability.py +109 -0
  36. agentcapsule-0.1.0/src/lmcodec/quantizer.py +75 -0
  37. agentcapsule-0.1.0/src/lmcodec/range_coder.py +186 -0
  38. agentcapsule-0.1.0/src/lmcodec/transformer.py +367 -0
  39. agentcapsule-0.1.0/tests/test_agent_handoff_dashboard.py +77 -0
  40. agentcapsule-0.1.0/tests/test_agent_handoff_demo.py +64 -0
  41. agentcapsule-0.1.0/tests/test_agent_handoff_evaluator.py +110 -0
  42. agentcapsule-0.1.0/tests/test_agent_handoff_policy_matrix.py +49 -0
  43. agentcapsule-0.1.0/tests/test_agentcapsule_audit.py +89 -0
  44. agentcapsule-0.1.0/tests/test_agentcapsule_backends.py +76 -0
  45. agentcapsule-0.1.0/tests/test_agentcapsule_cli.py +414 -0
  46. agentcapsule-0.1.0/tests/test_agentcapsule_design_docs.py +50 -0
  47. agentcapsule-0.1.0/tests/test_agentcapsule_ed25519.py +204 -0
  48. agentcapsule-0.1.0/tests/test_agentcapsule_envelope.py +97 -0
  49. agentcapsule-0.1.0/tests/test_agentcapsule_policy.py +124 -0
  50. agentcapsule-0.1.0/tests/test_agentcapsule_registry.py +318 -0
  51. agentcapsule-0.1.0/tests/test_agentcapsule_scan.py +52 -0
  52. agentcapsule-0.1.0/tests/test_benchmark_json.py +107 -0
  53. agentcapsule-0.1.0/tests/test_benchmark_schema.py +47 -0
  54. agentcapsule-0.1.0/tests/test_build_carrier_corpus.py +32 -0
  55. agentcapsule-0.1.0/tests/test_carrier_quality.py +31 -0
  56. agentcapsule-0.1.0/tests/test_codec.py +74 -0
  57. agentcapsule-0.1.0/tests/test_compare_results.py +92 -0
  58. agentcapsule-0.1.0/tests/test_experiments.py +54 -0
  59. agentcapsule-0.1.0/tests/test_framing_armour.py +41 -0
  60. agentcapsule-0.1.0/tests/test_golden.py +78 -0
  61. agentcapsule-0.1.0/tests/test_lm.py +122 -0
  62. agentcapsule-0.1.0/tests/test_probability.py +39 -0
  63. agentcapsule-0.1.0/tests/test_profile_experiment.py +44 -0
  64. agentcapsule-0.1.0/tests/test_property_roundtrip.py +66 -0
  65. agentcapsule-0.1.0/tests/test_quantizer.py +31 -0
  66. agentcapsule-0.1.0/tests/test_quantizer_stress.py +49 -0
  67. agentcapsule-0.1.0/tests/test_range_coder.py +89 -0
  68. agentcapsule-0.1.0/tests/test_range_coder_stress.py +97 -0
  69. agentcapsule-0.1.0/tests/test_run_experiment.py +91 -0
  70. agentcapsule-0.1.0/tests/test_run_matrix.py +162 -0
  71. agentcapsule-0.1.0/tests/test_split_corpus.py +71 -0
  72. agentcapsule-0.1.0/tests/test_sweep_shaping.py +15 -0
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,421 @@
1
+ Metadata-Version: 2.4
2
+ Name: agentcapsule
3
+ Version: 0.1.0
4
+ Summary: Agent Capsule Protocol for inspectable text-native artifact transfer
5
+ License-Expression: Apache-2.0
6
+ Project-URL: Homepage, https://github.com/arikyp/agentcapsule
7
+ Project-URL: Repository, https://github.com/arikyp/agentcapsule
8
+ Project-URL: Issues, https://github.com/arikyp/agentcapsule/issues
9
+ Project-URL: Documentation, https://github.com/arikyp/agentcapsule/tree/main/docs
10
+ Keywords: agents,ai-agents,artifact-transfer,protocol,security,provenance,signatures,base64,governance
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Programming Language :: Python :: 3.13
17
+ Classifier: Topic :: Communications
18
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
19
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
20
+ Requires-Python: >=3.11
21
+ Description-Content-Type: text/markdown
22
+ License-File: LICENSE
23
+ Provides-Extra: signing
24
+ Requires-Dist: cryptography<47,>=46; extra == "signing"
25
+ Dynamic: license-file
26
+
27
+ # Agent Capsule
28
+
29
+ [![CI](https://github.com/arikyp/agentcapsule/actions/workflows/ci.yml/badge.svg)](https://github.com/arikyp/agentcapsule/actions/workflows/ci.yml)
30
+
31
+ Agent Capsule Protocol V0 is an inspectable, verifiable artifact format for
32
+ moving exact machine-readable payloads through agent and text-native channels:
33
+ chat, tickets, prompts, email, GitHub issues, A2A messages, MIME attachments,
34
+ and agent traces.
35
+
36
+ The default capsule path is plain Base64 plus metadata, SHA256 verification,
37
+ optional signatures, local policy checks, and sandbox unpacking. An experimental
38
+ carrier-shaping backend exists for research, but it is not required for normal
39
+ capsule use.
40
+
41
+ ## Current Status
42
+
43
+ Agent Capsule V0 is the product-facing layer in this repository.
44
+
45
+ - Base64 capsules are the primary stable path.
46
+ - Capsules can be delivered inline, as attachments, or by reference descriptor.
47
+ - Directory bundles are deterministic JSON with per-file SHA256 and byte
48
+ counts.
49
+ - HMAC-SHA256 and optional Ed25519 signatures are supported for authenticity
50
+ experiments.
51
+ - Local policy, scan, audit, and trust-registry flows are implemented.
52
+ - Runtime Base64 capsule encode/decode is dependency-free Python.
53
+
54
+ ## What Works
55
+
56
+ - Base64 capsule pack, inspect, verify, scan, and unpack flows.
57
+ - Signed capsule verification with HMAC and optional Ed25519.
58
+ - Agent handoff manifests with file inventory, requested capabilities, policy
59
+ hints, and delivery mode.
60
+ - Inline, attachment, and reference delivery metadata.
61
+ - Byte-perfect encode/decode roundtrip for the tested payload sizes and demos.
62
+ - Deterministic output for identical payload, model, and settings.
63
+ - Model fingerprint checks before decode.
64
+ - Copy/paste armour with version, model fingerprint, and settings.
65
+ - CLI file encode/decode.
66
+ - CRC32 corruption detection inside the payload frame.
67
+ - Unit, stress, golden, and end-to-end verification tests.
68
+
69
+ ## What Does Not Yet Work
70
+
71
+ - Production identity, central trust registry, or remote policy service.
72
+ - Encryption or privacy.
73
+ - Large-file distribution as an inline capsule.
74
+ - Semantically meaningful prose generation.
75
+ - Steganography-grade secrecy.
76
+ - Compression superiority over base64.
77
+ - Large-file archival confidence.
78
+ - GPU-scale model training in the runtime path.
79
+
80
+ ## Agent Capsule Quickstart
81
+
82
+ Use a virtual environment for local development:
83
+
84
+ ```bash
85
+ python3 -m venv .venv
86
+ .venv/bin/python -m pip install -e .
87
+ ```
88
+
89
+ This exposes the `agentcapsule` and `capsule` commands for Agent Capsules.
90
+
91
+ Create, inspect, verify, and unpack a Base64 capsule:
92
+
93
+ ```bash
94
+ printf 'agent handoff state\n' > payload.txt
95
+ agentcapsule pack payload.txt --out capsule.txt
96
+ agentcapsule inspect capsule.txt
97
+ agentcapsule verify capsule.txt
98
+ agentcapsule unpack capsule.txt --out decoded
99
+ cmp payload.txt decoded/payload.txt
100
+ ```
101
+
102
+ Create a signed handoff capsule with explicit manifest metadata:
103
+
104
+ ```bash
105
+ CAPSULE_HMAC_KEY='shared secret' agentcapsule pack payload.txt \
106
+ --out capsule.txt \
107
+ --created-by agent-a \
108
+ --task-id abc123 \
109
+ --requested-capability read_files \
110
+ --requested-capability run_tests \
111
+ --delivery-mode inline \
112
+ --sign-key-env CAPSULE_HMAC_KEY
113
+ CAPSULE_HMAC_KEY='shared secret' agentcapsule verify capsule.txt --key-env CAPSULE_HMAC_KEY
114
+ ```
115
+
116
+ Emit a reference descriptor when the capsule will be stored out of band:
117
+
118
+ ```bash
119
+ agentcapsule reference capsule.txt \
120
+ --uri https://example.test/capsules/capsule.txt \
121
+ --json
122
+ ```
123
+
124
+ For a shorter developer path, see [docs/QUICKSTART.md](docs/QUICKSTART.md).
125
+ For installation packaging, see [docs/INSTALL.md](docs/INSTALL.md).
126
+ For release and distribution planning, see
127
+ [docs/RELEASE_DISTRIBUTION.md](docs/RELEASE_DISTRIBUTION.md).
128
+
129
+ ## Agent Capsule Commands
130
+
131
+ Capsules are inspectable text artifacts that wrap exact machine-readable
132
+ payloads with plaintext metadata, SHA256 verification, and safe unpack flows.
133
+ The command examples below use Base64 unless a different backend is selected
134
+ explicitly. `capsule` remains an alias for `agentcapsule`.
135
+
136
+ ```bash
137
+ agentcapsule pack examples/agent_capsule_demo/handoff --out capsule.txt
138
+ agentcapsule inspect capsule.txt
139
+ agentcapsule verify capsule.txt
140
+ agentcapsule unpack capsule.txt --out decoded
141
+ agentcapsule scan capsule.txt
142
+ agentcapsule codecs
143
+ agentcapsule inspect capsule.txt --json
144
+ CAPSULE_HMAC_KEY='shared secret' agentcapsule pack payload.bin --out capsule.txt --sign-key-env CAPSULE_HMAC_KEY
145
+ agentcapsule keys generate --private-key publisher.key --public-key publisher.pub
146
+ agentcapsule pack payload.bin --out capsule.txt --sign-ed25519-key publisher.key --signature-key-id publisher
147
+ agentcapsule verify capsule.txt --ed25519-public-key publisher.pub
148
+ agentcapsule verify capsule.txt --signature-registry trusted-keys.json
149
+ agentcapsule verify capsule.txt --audit-json
150
+ ```
151
+
152
+ Core capsule, HMAC, and base64 workflows work with the default
153
+ dependency-free install. Ed25519 demos/tests require the optional signing extra:
154
+
155
+ ```bash
156
+ python3 -m pip install -e ".[signing]"
157
+ ```
158
+
159
+ For Ed25519, distinguish validity from trust: `signature_verification: ok`
160
+ means the capsule was signed by the matching key; `signature_trust.status:
161
+ trusted` means the key also passed local registry and policy checks.
162
+
163
+ `capsule scan --json` emits typed findings with source locations for governance
164
+ logs and agent traces. `--audit-json` on `inspect`, `verify`, `unpack`, and
165
+ `scan` emits a consistent allow/review/block governance event.
166
+
167
+ See [docs/AGENT_CAPSULE_PROTOCOL_V0.md](docs/AGENT_CAPSULE_PROTOCOL_V0.md) and
168
+ [docs/AGENT_CAPSULE_PRODUCT_BRIEF.md](docs/AGENT_CAPSULE_PRODUCT_BRIEF.md).
169
+ For security assumptions, HMAC limits, and governance policy examples, see
170
+ [docs/AGENT_CAPSULE_THREAT_MODEL.md](docs/AGENT_CAPSULE_THREAT_MODEL.md).
171
+ For the public-key signing proposal, see
172
+ [docs/AGENT_CAPSULE_ED25519_DESIGN.md](docs/AGENT_CAPSULE_ED25519_DESIGN.md).
173
+ For structured governance events, see
174
+ [docs/AGENT_CAPSULE_AUDIT_LOG_V0.md](docs/AGENT_CAPSULE_AUDIT_LOG_V0.md).
175
+ For an observable agent-to-agent handoff experiment, see
176
+ [docs/AGENT_TO_AGENT_HANDOFF_DEMO.md](docs/AGENT_TO_AGENT_HANDOFF_DEMO.md).
177
+ The handoff demo writes `events.jsonl` plus an evaluator report that checks the
178
+ summary, capsule, registry-trusted signature, sandbox unpack, and artifact
179
+ comparison evidence.
180
+ For enterprise policy tiers, see
181
+ [docs/AGENT_HANDOFF_POLICY_MATRIX_V0.md](docs/AGENT_HANDOFF_POLICY_MATRIX_V0.md).
182
+ For a static observability view over handoff evidence, see
183
+ [docs/AGENT_HANDOFF_OBSERVABILITY_DASHBOARD_V0.md](docs/AGENT_HANDOFF_OBSERVABILITY_DASHBOARD_V0.md).
184
+ For the central trust registry direction, see
185
+ [docs/AGENT_CAPSULE_CENTRAL_TRUST_REGISTRY.md](docs/AGENT_CAPSULE_CENTRAL_TRUST_REGISTRY.md).
186
+
187
+ ## Research Backends
188
+
189
+ The repository also contains experimental carrier-shaping backends used for
190
+ research and regression coverage.
191
+
192
+ The research path has five core layers:
193
+
194
+ - Frame: wraps the payload as `magic || payload_len || crc32 || payload`.
195
+ - Range coder: provides the reversible bit-to-symbol mapping.
196
+ - LM probabilities: provide the next-token carrier distribution.
197
+ - Quantizer: converts floating-point probabilities into deterministic integer
198
+ CDFs for range coding.
199
+ - Armour: stores carrier text with version, model fingerprint, and settings in
200
+ a copy/paste-safe text block.
201
+
202
+ Encoding:
203
+
204
+ ```text
205
+ payload bytes
206
+ -> binary frame
207
+ -> framed bits
208
+ -> source RangeDecoder over framed bits
209
+ -> LM probabilities + shaping + quantization
210
+ -> carrier token choices
211
+ -> mirror RangeEncoder stopping check
212
+ -> armoured text
213
+ ```
214
+
215
+ Decoding:
216
+
217
+ ```text
218
+ armoured text
219
+ -> parse and check model fingerprint
220
+ -> carrier tokens
221
+ -> same LM probabilities + shaping + quantization
222
+ -> RangeEncoder reconstructs framed bits
223
+ -> frame parser validates magic, length, and CRC32
224
+ -> payload bytes
225
+ ```
226
+
227
+ The stopping condition is intentionally conservative. Range decoders use
228
+ lookahead, so encode does not stop based on a naive "all bits consumed" rule.
229
+ Instead, the research carrier keeps a mirror range encoder and stops only when
230
+ its finalized preview has the framed payload bits as a prefix.
231
+
232
+ ## Verification
233
+
234
+ ```bash
235
+ PYTHONPATH=src python3 -m unittest discover -s tests
236
+ ```
237
+
238
+ Full V1 verification:
239
+
240
+ ```bash
241
+ sh scripts/verify_v1.sh
242
+ ```
243
+
244
+ Installed CLI release check:
245
+
246
+ ```bash
247
+ sh scripts/release_check.sh
248
+ ```
249
+
250
+ ## Demo And Experiment Scripts
251
+
252
+ ```bash
253
+ sh scripts/demo_roundtrip.sh
254
+ ```
255
+
256
+ Compare the fixed carrier against the trained order-1 n-gram carrier:
257
+
258
+ ```bash
259
+ sh scripts/demo_compare.sh
260
+ ```
261
+
262
+ Run the pinned Transformer carrier demo:
263
+
264
+ ```bash
265
+ sh scripts/demo_transformer.sh
266
+ ```
267
+
268
+ Create deterministic carrier corpora and train/held-out splits:
269
+
270
+ ```bash
271
+ scripts/build_carrier_corpus.py \
272
+ --out examples/carrier_corpus_v2.txt \
273
+ --lines 5000 \
274
+ --seed 42 \
275
+ --domain mixed
276
+ scripts/split_corpus.py \
277
+ --input examples/carrier_corpus_v2.txt \
278
+ --train-out examples/carrier_train_v2.txt \
279
+ --heldout-out examples/carrier_heldout_v2.txt \
280
+ --heldout-ratio 0.20 \
281
+ --filter-vocab
282
+ ```
283
+
284
+ Compare models with optional benchmark JSON:
285
+
286
+ ```bash
287
+ scripts/compare_models.py \
288
+ --payload payload.bin \
289
+ --corpus examples/carrier_train_v2.txt \
290
+ --quality-text examples/carrier_heldout_v2.txt \
291
+ --json-out benchmark.json
292
+ ```
293
+
294
+ Run a bounded V2 experiment config:
295
+
296
+ ```bash
297
+ scripts/run_experiment.py experiments/configs/example_fixed.json
298
+ ```
299
+
300
+ Optional PyTorch training/export is available in
301
+ `scripts/train_transformer_torch.py`. PyTorch is only needed for that exporter;
302
+ the exported JSON model loads through the dependency-free `TransformerLM`
303
+ runtime.
304
+
305
+ ## Research Notes
306
+
307
+ Probability shaping is intentionally separate from the models. Defaults are a
308
+ no-op, while non-default shaping settings are written into the armour so decode
309
+ can reproduce the same distribution. Uniform mixing and temperature are
310
+ guardrails for keeping model distributions usable by the range coder; they are
311
+ not a claim of natural language quality.
312
+
313
+ Greedy previews are useful diagnostics, but they are not representative of
314
+ encoded carrier text. The actual carrier is selected by payload bits
315
+ through the range coder under the model distribution.
316
+
317
+ Current demo metrics for `bytes(range(256))`:
318
+
319
+ - Payload bytes: `256`
320
+ - Carrier chars: `358`
321
+ - Bits per carrier char: `5.989`
322
+ - Base64 baseline chars: `344`
323
+
324
+ Pinned Transformer fixture metrics for `bytes(range(256))` with
325
+ `--shape-uniform-mix 0.80 --temperature 1.25`:
326
+
327
+ - Payload bytes: `256`
328
+ - Carrier chars: `362`
329
+ - Bits per carrier char: `5.923`
330
+
331
+ ## Documentation
332
+
333
+ - [docs/ALGORITHM.md](docs/ALGORITHM.md): core reversible mapping.
334
+ - [docs/IMPLEMENTATION_PLAN.md](docs/IMPLEMENTATION_PLAN.md): implementation
335
+ milestones and design notes.
336
+ - [docs/V1_RELEASE.md](docs/V1_RELEASE.md): V1 checkpoint and pinned artifact
337
+ details.
338
+ - [docs/LIMITATIONS.md](docs/LIMITATIONS.md): current boundaries and non-goals.
339
+ - [docs/QUICKSTART.md](docs/QUICKSTART.md): installed CLI usage.
340
+ - [docs/BENCHMARKING.md](docs/BENCHMARKING.md): structured benchmark JSON.
341
+ - [docs/EXPERIMENTS.md](docs/EXPERIMENTS.md): bounded V2 experiment runner.
342
+ - [docs/AGENT_CAPSULE_PROTOCOL_V0.md](docs/AGENT_CAPSULE_PROTOCOL_V0.md):
343
+ Agent Capsule V0 envelope, backends, verification, and scan flow.
344
+ - [docs/AGENT_CAPSULE_PRODUCT_BRIEF.md](docs/AGENT_CAPSULE_PRODUCT_BRIEF.md):
345
+ product pivot brief and governance roadmap.
346
+ - [docs/V2_BASELINE.md](docs/V2_BASELINE.md): V2 baseline metrics and first
347
+ candidate runs.
348
+ - [docs/V2_EXPERIMENT_PROTOCOL.md](docs/V2_EXPERIMENT_PROTOCOL.md): V2
349
+ promotion gates and experiment rules.
350
+ - [docs/V2_AUTOAGENT.md](docs/V2_AUTOAGENT.md): autoagent role and guardrails
351
+ for bounded V2 research.
352
+ - [docs/V2_CANDIDATE_REPORT_TEMPLATE.md](docs/V2_CANDIDATE_REPORT_TEMPLATE.md):
353
+ report shape for reviewed V2 candidates.
354
+ - [docs/V2_CHECKPOINT.md](docs/V2_CHECKPOINT.md): V2 research checkpoint,
355
+ matrix ranking, and merge recommendation.
356
+ - [docs/V2_LARGE_PAYLOAD_REAL_CORPUS_STRESS.md](docs/V2_LARGE_PAYLOAD_REAL_CORPUS_STRESS.md):
357
+ next stress lane for larger payloads and real-ish corpora.
358
+ - [docs/V2_LARGE_PAYLOAD_STRESS_RESULTS.md](docs/V2_LARGE_PAYLOAD_STRESS_RESULTS.md):
359
+ capped large-payload stress results and runtime finding.
360
+ - [docs/V2_SIZE_LADDER.md](docs/V2_SIZE_LADDER.md): scaled payload ladder for
361
+ locating the current runtime knee.
362
+ - [docs/V2_SIZE_LADDER_RESULTS.md](docs/V2_SIZE_LADDER_RESULTS.md): observed
363
+ 32KB/64KB runtime boundary.
364
+ - [docs/V2_SPRINT_1.md](docs/V2_SPRINT_1.md): first V2 candidate stress
365
+ sprint.
366
+ - [docs/V2_SPRINT_2.md](docs/V2_SPRINT_2.md): first autoagent-safe
367
+ comparison sprint.
368
+ - [docs/V2_SPRINT_3.md](docs/V2_SPRINT_3.md): order-3 candidate stress
369
+ sprint.
370
+ - [docs/V2_CANDIDATE_ORDER3.md](docs/V2_CANDIDATE_ORDER3.md): current order-3
371
+ candidate report.
372
+ - [docs/V2_CANDIDATE_ORDER3_SHAPED.md](docs/V2_CANDIDATE_ORDER3_SHAPED.md):
373
+ shaped order-3 candidate report.
374
+ - [docs/V2_CANDIDATE_ORDER2_SAFETY.md](docs/V2_CANDIDATE_ORDER2_SAFETY.md):
375
+ order-2 safety fallback report.
376
+ - [docs/V2_CANDIDATE_TRANSFORMER_FIXTURE.md](docs/V2_CANDIDATE_TRANSFORMER_FIXTURE.md):
377
+ Transformer fixture candidate report.
378
+ - [docs/CARRIER_QUALITY.md](docs/CARRIER_QUALITY.md): carrier quality metrics
379
+ and trade-offs.
380
+ - [docs/TESTING.md](docs/TESTING.md): stress/property test strategy.
381
+ - [schemas/benchmark_result_v1.json](schemas/benchmark_result_v1.json):
382
+ benchmark JSON schema contract.
383
+ - [CHANGELOG.md](CHANGELOG.md): release notes.
384
+ - [LICENSE](LICENSE): current license status.
385
+
386
+ ## Golden V1 Fixtures
387
+
388
+ All golden fixtures use payload `bytes(range(256))`.
389
+
390
+ Payload SHA256:
391
+
392
+ ```text
393
+ 40aff2e9d2d8922e47afd4648e6967497158785fbd1da870e7110266bf944880
394
+ ```
395
+
396
+ Fixed carrier:
397
+
398
+ - Message fixture: [tests/fixtures/golden_message_v1.txt](tests/fixtures/golden_message_v1.txt)
399
+ - Model fingerprint: `d60583f4d741e42cb713b11c78b8ffc89cda1ee05eca522929bec8cbdb423be8`
400
+ - Message SHA256: `f53ec3604a378788b20cf6e0aadbfe441a063aa7ce1cea0bef9b1427cbd21e35`
401
+
402
+ Order-1 n-gram carrier fixture:
403
+
404
+ - Model fixture: [tests/fixtures/ngram_model_v1.json](tests/fixtures/ngram_model_v1.json)
405
+ - Message fixture: [tests/fixtures/ngram_golden_message_v1.txt](tests/fixtures/ngram_golden_message_v1.txt)
406
+ - Model fingerprint: `b1cd62a9019b67e0a42913dac1dca09852b4931f09afa87bb8e62089fe184a3a`
407
+ - Message SHA256: `53c062a238764c72caa9dd338d37682ab350d7ace4251e9778ba13ae97d99512`
408
+
409
+ Transformer carrier fixture:
410
+
411
+ - Model fixture: [tests/fixtures/transformer_model_v1.json](tests/fixtures/transformer_model_v1.json)
412
+ - Message fixture: [tests/fixtures/transformer_golden_message_v1.txt](tests/fixtures/transformer_golden_message_v1.txt)
413
+ - Settings: `SHAPE_UNIFORM_MIX=0.80; TEMPERATURE=1.25`
414
+ - Model fingerprint: `cfc75d7b54524f7a09a90454d89768aa4eb75b17546607c376760e2fc9d8f851`
415
+ - Message SHA256: `7713a0b7208462485f854ab58e5423f16c16360aeff524f1597ba49c840ad96b`
416
+
417
+ Regenerate golden fixtures only after intentional codec changes:
418
+
419
+ ```bash
420
+ python3 scripts/generate_golden.py
421
+ ```