botvow 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.
botvow-0.1.0/LICENSE ADDED
@@ -0,0 +1,29 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 BotVow contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
23
+ ---------------------------------------------------------------------------
24
+ Scope: the MIT License above covers the code (tools/, tests/, modules/, run_demo.sh, Dockerfile).
25
+ The specification, documentation, schema and example data (README.md, SPEC.md, POLICY.md,
26
+ AGENTS.md, llms.txt, NO-PATENT.md, docs/, schema/, examples/, assets/, agent-card.json,
27
+ server.json, glama.json) are licensed under Creative Commons
28
+ Attribution 4.0 International (CC BY 4.0): https://creativecommons.org/licenses/by/4.0/
29
+ Attribution: "BotVow (https://github.com/Santiago1971/botvow)".
botvow-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,129 @@
1
+ Metadata-Version: 2.4
2
+ Name: botvow
3
+ Version: 0.1.0
4
+ Summary: Create and verify co-signed BotVow receipts for agent-to-agent deliveries.
5
+ Author: BotVow contributors
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://botvow.org
8
+ Project-URL: Repository, https://github.com/Santiago1971/botvow
9
+ Project-URL: Issues, https://github.com/Santiago1971/botvow/issues
10
+ Project-URL: Documentation, https://github.com/Santiago1971/botvow#readme
11
+ Keywords: mcp,a2a,agents,receipts,ed25519
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Operating System :: OS Independent
19
+ Classifier: Environment :: Console
20
+ Classifier: Intended Audience :: Developers
21
+ Classifier: Topic :: Security
22
+ Requires-Python: >=3.10
23
+ Description-Content-Type: text/markdown
24
+ License-File: LICENSE
25
+ Requires-Dist: cryptography>=41
26
+ Provides-Extra: schema
27
+ Requires-Dist: jsonschema>=4; extra == "schema"
28
+ Dynamic: license-file
29
+
30
+ <p align="center"><img src="assets/botvow-logo.jpg" alt="BotVow logo: an outlined cube with an orange seal and a check mark" width="520"></p>
31
+
32
+ # BotVow — the black box for Bots
33
+
34
+ <!-- mcp-name: io.github.Santiago1971/botvow -->
35
+
36
+ **BotVow ("the bot's vow") is an open, tamper-evident record of what two Bots agreed: who agreed what, who authorised it, and when — co-signed by both and verifiable by anyone with nothing but public keys.**
37
+
38
+ - **Bot 2 Bot at the core.** BotVow is built first for Bots recording the agreements they make with each other.
39
+ - **An open door, with the same rules.** Agents from other AI platforms (OpenAI, Google, Anthropic, open source, …) may also record agreements in the black box — but only by following exactly the same rules. No own rules, no extensions that change the rules, no exceptions. The verifier rejects anything else, even if every party signed it.
40
+ - **Tiny and open.** One JSON format, one ~200-line verifier, Ed25519 + SHA-256. No account, no central server, no blockchain. MIT code, CC BY 4.0 spec, and a [no-patent pledge](NO-PATENT.md).
41
+
42
+ > **What this is not.** BotVow is evidence, not a notary, a timestamping authority or a contract. It shows that the listed keys signed the listed content in the listed order. It does not prove who controls a key, that every message was recorded, or that a summary is true.
43
+
44
+ ## Install
45
+
46
+ ```bash
47
+ pip install botvow # or: pipx install botvow
48
+ botvow verify examples/bot2bot-log.json
49
+ botvow-mcp # local MCP server on stdio (also: uvx botvow)
50
+ ```
51
+
52
+ The package exposes two console scripts: `botvow` (CLI) and `botvow-mcp` (MCP server). With no arguments, `botvow` starts the MCP server, so `uvx botvow` and `pipx run botvow` speak MCP on stdio. Subcommands (`keygen`, `create`, `sign`, `verify`, `demo`, `mcp`) still run the CLI.
53
+
54
+ ## 30-second example: create and verify a receipt
55
+
56
+ Two parties, one file, one receipt. Only the SHA-256 of the file is stored, not the file itself. Keep the private keys on this machine.
57
+
58
+ ```bash
59
+ pip install -r requirements.txt
60
+
61
+ python3 tools/botvow.py keygen --name "Inspector Demo Bot (fictional)" --out /tmp/inspector.key.json
62
+ python3 tools/botvow.py keygen --name "Client Demo Bot (fictional)" --out /tmp/client.key.json
63
+
64
+ python3 tools/botvow.py create --key /tmp/inspector.key.json --key /tmp/client.key.json --payload examples/two-agents/inspection-report.txt --summary "Inspector Demo Bot delivered the inspection report to Client Demo Bot." --out /tmp/receipt.json
65
+
66
+ python3 tools/botvow.py verify /tmp/receipt.json
67
+ # VERIFY OK
68
+ # head <64 hex characters>
69
+ ```
70
+
71
+ When the two keys are on different machines, each party keeps only their own key. See [`examples/two-agents/run.sh`](examples/two-agents/run.sh). Agents can call the same steps through the local MCP server: `python3 tools/mcp_server.py` (`create_vow`, `verify_vow`). Instructions: [AGENTS.md](AGENTS.md), [llms.txt](llms.txt). Policy: [POLICY.md](POLICY.md).
72
+
73
+ ## Quick start (built-in samples)
74
+
75
+ ```bash
76
+ ./run_demo.sh # build samples, verify, tamper tests, same-rules tests, unit tests, schema
77
+ python3 tools/botvow.py verify examples/bot2bot-log.json # VERIFY OK, exit 0
78
+ python3 tools/botvow.py verify examples/open-door-log.json # VERIFY OK (Bot + agent of another AI)
79
+ python3 tools/botvow.py verify examples/bot2bot-log-tampered.json # REJECTED, exit 1
80
+ python3 tools/botvow.py verify examples/open-door-own-rules-rejected.json # REJECTED: own rules not allowed
81
+ python3 tools/botvow.py verify LOG.json --head <hex> # also compare with a published head hash
82
+ ```
83
+
84
+ ## How it works
85
+
86
+ | Element | Rule |
87
+ |---|---|
88
+ | Chain | Ordered JSON entries, each with exactly the fields in [`schema/record.schema.json`](schema/record.schema.json) |
89
+ | `genesis` | Entry 0. Lists the parties (key id, name, Ed25519 public key, `kind`: `bot` or `agent`, optional platform and A2A Agent Card). Signed by all parties |
90
+ | Other entries | `proposal`, `counter`, `agreement`, `amendment`, `termination`, `seal` — nothing else |
91
+ | Co-signing | `genesis`, `agreement` and `seal` must be signed by **all** parties |
92
+ | Hash chain | `prev_hash` links every entry to the previous one; `entry_hash` covers content and signatures |
93
+ | Same rules | `own_rules`, `exceptions`, `rules_override`… are rejected, unknown types and extra fields too |
94
+ | Privacy | Raw messages are never stored, only their SHA-256; summaries only with both parties' consent |
95
+
96
+ Full rules: [SPEC.md](SPEC.md). Policy: [POLICY.md](POLICY.md). Plans: [ROADMAP.md](ROADMAP.md). Overview: [docs/overview.md](docs/overview.md).
97
+
98
+ ### Tests in `run_demo.sh`
99
+ Bot 2 Bot log verifies · privacy (no raw messages) · selective disclosure · edit · edit + rehash · delete · reorder · outsider key · drop seal · single signature · edit genesis · **open door: Bot + agent of another AI verifies** · **agent adds its own rules/exceptions (even co-signed): rejected** · **agent invents its own entry type/field: rejected** — plus unit tests in `tests/` and the two-agent delivery example in `examples/two-agents/`.
100
+
101
+ ## Samples
102
+ All parties and keys are **fictional**. Demo keys come from fixed public seeds so the output is reproducible — **never use them for anything real**.
103
+
104
+ ## Works with A2A, MCP and HTTPS
105
+ A BotVow chain is just JSON, so it can travel as A2A task metadata, be produced and checked by an MCP tool, or be posted over plain HTTPS. Parties can link their key to an A2A Agent Card.
106
+
107
+ A local MCP server (`botvow-mcp`, or `python3 tools/mcp_server.py`) exposes `create_vow` and `verify_vow` over stdio. It does not keep receipts for you: you keep the JSON, and you can verify it later without the server. The Agent Card is at [agent-card.json](agent-card.json) and at https://botvow.org/.well-known/agent-card.json.
108
+
109
+ ## Modules
110
+
111
+ Two optional modules live under [`modules/`](modules/). They are not part of the verifier; they are small, standard-library tools that work with the same agent formats BotVow already mentions (A2A, MCP, email).
112
+
113
+ - **[Protocol translator](modules/translator/)** — rewrite a request, response, error or task between MCP, A2A 1.0, A2A 0.3 and plain email, without ever executing it. 18 tests in `modules/translator/tests/`.
114
+ - **[Local Agent Card](modules/agent-card/)** — a small profile (`local-agent-card/0.1`) so a shop, café or lodging can publish hours, dated prices and booking rules, and export them to an A2A Agent Card, schema.org JSON-LD and llms.txt. The two example cards are **FICTIONAL** and labelled as such. 10 tests in `modules/agent-card/tests/`.
115
+
116
+ ## Related work
117
+
118
+ BotVow builds on, and is narrower than, existing work: Google AP2 mandates (payments), A2A signed Agent Cards, IETF drafts on co-signed agent agreements and bilateral attestation, the Open Agent Protocol, and agent-receipt projects. See [docs/overview.md](docs/overview.md) for links.
119
+
120
+ ## Licence
121
+ Code: MIT. Specification, docs, schema and examples: CC BY 4.0. See [LICENSE](LICENSE) and [NO-PATENT.md](NO-PATENT.md).
122
+
123
+ ---
124
+
125
+ ## Em português
126
+
127
+ O **BotVow** («a promessa do bot») é a caixa negra dos Bots: um registo Bot 2 Bot, inalterável e verificável, do que dois Bots combinam (quem combinou o quê, quem autorizou e quando), assinado pelos dois. Os Bots são o núcleo. Agentes de outras IA também podem registar acordos, mas **têm de seguir as mesmas regras**, sem regras próprias nem exceções; o verificador recusa tudo o resto. Documento do projeto: [docs/projeto-botvow.md](docs/projeto-botvow.md).
128
+
129
+ This project continues the earlier prototype [Santiago1971/agent-agreement-black-box](https://github.com/Santiago1971/agent-agreement-black-box).
botvow-0.1.0/README.md ADDED
@@ -0,0 +1,100 @@
1
+ <p align="center"><img src="assets/botvow-logo.jpg" alt="BotVow logo: an outlined cube with an orange seal and a check mark" width="520"></p>
2
+
3
+ # BotVow — the black box for Bots
4
+
5
+ <!-- mcp-name: io.github.Santiago1971/botvow -->
6
+
7
+ **BotVow ("the bot's vow") is an open, tamper-evident record of what two Bots agreed: who agreed what, who authorised it, and when — co-signed by both and verifiable by anyone with nothing but public keys.**
8
+
9
+ - **Bot 2 Bot at the core.** BotVow is built first for Bots recording the agreements they make with each other.
10
+ - **An open door, with the same rules.** Agents from other AI platforms (OpenAI, Google, Anthropic, open source, …) may also record agreements in the black box — but only by following exactly the same rules. No own rules, no extensions that change the rules, no exceptions. The verifier rejects anything else, even if every party signed it.
11
+ - **Tiny and open.** One JSON format, one ~200-line verifier, Ed25519 + SHA-256. No account, no central server, no blockchain. MIT code, CC BY 4.0 spec, and a [no-patent pledge](NO-PATENT.md).
12
+
13
+ > **What this is not.** BotVow is evidence, not a notary, a timestamping authority or a contract. It shows that the listed keys signed the listed content in the listed order. It does not prove who controls a key, that every message was recorded, or that a summary is true.
14
+
15
+ ## Install
16
+
17
+ ```bash
18
+ pip install botvow # or: pipx install botvow
19
+ botvow verify examples/bot2bot-log.json
20
+ botvow-mcp # local MCP server on stdio (also: uvx botvow)
21
+ ```
22
+
23
+ The package exposes two console scripts: `botvow` (CLI) and `botvow-mcp` (MCP server). With no arguments, `botvow` starts the MCP server, so `uvx botvow` and `pipx run botvow` speak MCP on stdio. Subcommands (`keygen`, `create`, `sign`, `verify`, `demo`, `mcp`) still run the CLI.
24
+
25
+ ## 30-second example: create and verify a receipt
26
+
27
+ Two parties, one file, one receipt. Only the SHA-256 of the file is stored, not the file itself. Keep the private keys on this machine.
28
+
29
+ ```bash
30
+ pip install -r requirements.txt
31
+
32
+ python3 tools/botvow.py keygen --name "Inspector Demo Bot (fictional)" --out /tmp/inspector.key.json
33
+ python3 tools/botvow.py keygen --name "Client Demo Bot (fictional)" --out /tmp/client.key.json
34
+
35
+ python3 tools/botvow.py create --key /tmp/inspector.key.json --key /tmp/client.key.json --payload examples/two-agents/inspection-report.txt --summary "Inspector Demo Bot delivered the inspection report to Client Demo Bot." --out /tmp/receipt.json
36
+
37
+ python3 tools/botvow.py verify /tmp/receipt.json
38
+ # VERIFY OK
39
+ # head <64 hex characters>
40
+ ```
41
+
42
+ When the two keys are on different machines, each party keeps only their own key. See [`examples/two-agents/run.sh`](examples/two-agents/run.sh). Agents can call the same steps through the local MCP server: `python3 tools/mcp_server.py` (`create_vow`, `verify_vow`). Instructions: [AGENTS.md](AGENTS.md), [llms.txt](llms.txt). Policy: [POLICY.md](POLICY.md).
43
+
44
+ ## Quick start (built-in samples)
45
+
46
+ ```bash
47
+ ./run_demo.sh # build samples, verify, tamper tests, same-rules tests, unit tests, schema
48
+ python3 tools/botvow.py verify examples/bot2bot-log.json # VERIFY OK, exit 0
49
+ python3 tools/botvow.py verify examples/open-door-log.json # VERIFY OK (Bot + agent of another AI)
50
+ python3 tools/botvow.py verify examples/bot2bot-log-tampered.json # REJECTED, exit 1
51
+ python3 tools/botvow.py verify examples/open-door-own-rules-rejected.json # REJECTED: own rules not allowed
52
+ python3 tools/botvow.py verify LOG.json --head <hex> # also compare with a published head hash
53
+ ```
54
+
55
+ ## How it works
56
+
57
+ | Element | Rule |
58
+ |---|---|
59
+ | Chain | Ordered JSON entries, each with exactly the fields in [`schema/record.schema.json`](schema/record.schema.json) |
60
+ | `genesis` | Entry 0. Lists the parties (key id, name, Ed25519 public key, `kind`: `bot` or `agent`, optional platform and A2A Agent Card). Signed by all parties |
61
+ | Other entries | `proposal`, `counter`, `agreement`, `amendment`, `termination`, `seal` — nothing else |
62
+ | Co-signing | `genesis`, `agreement` and `seal` must be signed by **all** parties |
63
+ | Hash chain | `prev_hash` links every entry to the previous one; `entry_hash` covers content and signatures |
64
+ | Same rules | `own_rules`, `exceptions`, `rules_override`… are rejected, unknown types and extra fields too |
65
+ | Privacy | Raw messages are never stored, only their SHA-256; summaries only with both parties' consent |
66
+
67
+ Full rules: [SPEC.md](SPEC.md). Policy: [POLICY.md](POLICY.md). Plans: [ROADMAP.md](ROADMAP.md). Overview: [docs/overview.md](docs/overview.md).
68
+
69
+ ### Tests in `run_demo.sh`
70
+ Bot 2 Bot log verifies · privacy (no raw messages) · selective disclosure · edit · edit + rehash · delete · reorder · outsider key · drop seal · single signature · edit genesis · **open door: Bot + agent of another AI verifies** · **agent adds its own rules/exceptions (even co-signed): rejected** · **agent invents its own entry type/field: rejected** — plus unit tests in `tests/` and the two-agent delivery example in `examples/two-agents/`.
71
+
72
+ ## Samples
73
+ All parties and keys are **fictional**. Demo keys come from fixed public seeds so the output is reproducible — **never use them for anything real**.
74
+
75
+ ## Works with A2A, MCP and HTTPS
76
+ A BotVow chain is just JSON, so it can travel as A2A task metadata, be produced and checked by an MCP tool, or be posted over plain HTTPS. Parties can link their key to an A2A Agent Card.
77
+
78
+ A local MCP server (`botvow-mcp`, or `python3 tools/mcp_server.py`) exposes `create_vow` and `verify_vow` over stdio. It does not keep receipts for you: you keep the JSON, and you can verify it later without the server. The Agent Card is at [agent-card.json](agent-card.json) and at https://botvow.org/.well-known/agent-card.json.
79
+
80
+ ## Modules
81
+
82
+ Two optional modules live under [`modules/`](modules/). They are not part of the verifier; they are small, standard-library tools that work with the same agent formats BotVow already mentions (A2A, MCP, email).
83
+
84
+ - **[Protocol translator](modules/translator/)** — rewrite a request, response, error or task between MCP, A2A 1.0, A2A 0.3 and plain email, without ever executing it. 18 tests in `modules/translator/tests/`.
85
+ - **[Local Agent Card](modules/agent-card/)** — a small profile (`local-agent-card/0.1`) so a shop, café or lodging can publish hours, dated prices and booking rules, and export them to an A2A Agent Card, schema.org JSON-LD and llms.txt. The two example cards are **FICTIONAL** and labelled as such. 10 tests in `modules/agent-card/tests/`.
86
+
87
+ ## Related work
88
+
89
+ BotVow builds on, and is narrower than, existing work: Google AP2 mandates (payments), A2A signed Agent Cards, IETF drafts on co-signed agent agreements and bilateral attestation, the Open Agent Protocol, and agent-receipt projects. See [docs/overview.md](docs/overview.md) for links.
90
+
91
+ ## Licence
92
+ Code: MIT. Specification, docs, schema and examples: CC BY 4.0. See [LICENSE](LICENSE) and [NO-PATENT.md](NO-PATENT.md).
93
+
94
+ ---
95
+
96
+ ## Em português
97
+
98
+ O **BotVow** («a promessa do bot») é a caixa negra dos Bots: um registo Bot 2 Bot, inalterável e verificável, do que dois Bots combinam (quem combinou o quê, quem autorizou e quando), assinado pelos dois. Os Bots são o núcleo. Agentes de outras IA também podem registar acordos, mas **têm de seguir as mesmas regras**, sem regras próprias nem exceções; o verificador recusa tudo o resto. Documento do projeto: [docs/projeto-botvow.md](docs/projeto-botvow.md).
99
+
100
+ This project continues the earlier prototype [Santiago1971/agent-agreement-black-box](https://github.com/Santiago1971/agent-agreement-black-box).
@@ -0,0 +1,46 @@
1
+ [build-system]
2
+ requires = ["setuptools>=77"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "botvow"
7
+ version = "0.1.0"
8
+ description = "Create and verify co-signed BotVow receipts for agent-to-agent deliveries."
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ license = "MIT"
12
+ license-files = ["LICENSE"]
13
+ authors = [{ name = "BotVow contributors" }]
14
+ keywords = ["mcp", "a2a", "agents", "receipts", "ed25519"]
15
+ dependencies = ["cryptography>=41"]
16
+ classifiers = [
17
+ "Development Status :: 3 - Alpha",
18
+ "Programming Language :: Python :: 3",
19
+ "Programming Language :: Python :: 3.10",
20
+ "Programming Language :: Python :: 3.11",
21
+ "Programming Language :: Python :: 3.12",
22
+ "Programming Language :: Python :: 3.13",
23
+ "Operating System :: OS Independent",
24
+ "Environment :: Console",
25
+ "Intended Audience :: Developers",
26
+ "Topic :: Security",
27
+ ]
28
+
29
+ [project.optional-dependencies]
30
+ schema = ["jsonschema>=4"]
31
+
32
+ [project.urls]
33
+ Homepage = "https://botvow.org"
34
+ Repository = "https://github.com/Santiago1971/botvow"
35
+ Issues = "https://github.com/Santiago1971/botvow/issues"
36
+ Documentation = "https://github.com/Santiago1971/botvow#readme"
37
+
38
+ [project.scripts]
39
+ botvow = "botvow:main"
40
+ botvow-mcp = "mcp_server:main"
41
+
42
+ [tool.setuptools]
43
+ py-modules = ["botvow", "mcp_server", "check_schema"]
44
+
45
+ [tool.setuptools.package-dir]
46
+ "" = "tools"
botvow-0.1.0/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,45 @@
1
+ """Unit tests for BotVow (run: python3 -m unittest discover -s tests -v)."""
2
+ import copy, os, sys, unittest
3
+ sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "tools"))
4
+ import botvow as bv
5
+
6
+ class BotVowTests(unittest.TestCase):
7
+ def setUp(self):
8
+ self.log, _ = bv.build_bot2bot()
9
+ self.od, (self.bot, self.agent) = bv.build_open_door()
10
+
11
+ def test_bot2bot_ok(self):
12
+ self.assertEqual(bv.verify(self.log, self.log[-1]["entry_hash"]), [])
13
+
14
+ def test_open_door_same_rules_ok(self):
15
+ self.assertEqual(bv.verify(self.od), [])
16
+
17
+ def test_tamper_detected(self):
18
+ t = copy.deepcopy(self.log); t[3]["content"]["valid_until"] = "2099-01-01"
19
+ self.assertTrue(bv.verify(t))
20
+
21
+ def test_agent_own_rules_rejected_even_if_cosigned(self):
22
+ t = copy.deepcopy(self.od)
23
+ t[2]["content"]["own_rules"] = {"cancel": "any time"}
24
+ bv.rehash_resign(t[2], [self.bot, self.agent])
25
+ t[3]["prev_hash"] = t[2]["entry_hash"]; bv.rehash_resign(t[3], [self.bot, self.agent])
26
+ errs = bv.verify(t)
27
+ self.assertTrue(any("own rules or exceptions are not allowed" in e for e in errs), errs)
28
+
29
+ def test_agent_custom_type_rejected(self):
30
+ t = copy.deepcopy(self.od); t[2]["type"] = "custom"
31
+ bv.rehash_resign(t[2], [self.bot, self.agent])
32
+ t[3]["prev_hash"] = t[2]["entry_hash"]; bv.rehash_resign(t[3], [self.bot, self.agent])
33
+ self.assertTrue(any("type not allowed" in e for e in bv.verify(t)))
34
+
35
+ def test_extra_field_rejected(self):
36
+ t = copy.deepcopy(self.od); t[1]["rules_override"] = "x"
37
+ bv.rehash_resign(t[1], [self.agent])
38
+ self.assertTrue(any("fields differ" in e for e in bv.verify(t)))
39
+
40
+ def test_agreement_needs_all_signatures(self):
41
+ t = copy.deepcopy(self.od); bv.rehash_resign(t[2], [self.bot])
42
+ self.assertTrue(any("ALL parties" in e for e in bv.verify(t)))
43
+
44
+ if __name__ == "__main__":
45
+ unittest.main()
@@ -0,0 +1,89 @@
1
+ """Tests for keygen, create, sign and verify of real (local) vows."""
2
+ import json, os, shutil, sys, tempfile, unittest
3
+ sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "tools"))
4
+ import botvow as bv
5
+
6
+ class CreateVowTests(unittest.TestCase):
7
+ def setUp(self):
8
+ self.tmp = tempfile.mkdtemp(prefix="botvow-test-")
9
+ self.addCleanup(lambda: shutil.rmtree(self.tmp, ignore_errors=True))
10
+ self.payload = os.path.join(self.tmp, "report.txt")
11
+ with open(self.payload, "w", encoding="utf-8") as f:
12
+ f.write("Fictional inspection report, 12 November 2026. No personal data.\n")
13
+
14
+ def _key(self, name, filename):
15
+ path = os.path.join(self.tmp, filename)
16
+ rec, pub = bv.keygen(name, path)
17
+ return path, rec, pub
18
+
19
+ def test_one_shot_create_and_verify(self):
20
+ a, _, _ = self._key("Inspector Demo Bot (fictional)", "inspector.key.json")
21
+ b, _, _ = self._key("Client Demo Bot (fictional)", "client.key.json")
22
+ out = os.path.join(self.tmp, "receipt.json")
23
+ rc = bv.main(["create", "--key", a, "--key", b, "--payload", self.payload,
24
+ "--summary", "Inspector Demo Bot delivered the inspection report to Client Demo Bot.",
25
+ "--out", out])
26
+ self.assertEqual(rc, 0)
27
+ receipt = bv.load_json(out)
28
+ self.assertEqual(bv.verify(receipt), [])
29
+ dumped = json.dumps(receipt)
30
+ self.assertNotIn("privkey", dumped)
31
+ with open(self.payload, encoding="utf-8") as fh:
32
+ raw = fh.read()
33
+ self.assertNotIn(raw.strip(), dumped)
34
+ self.assertIn(bv.sha256_hex(raw.encode()), dumped)
35
+ self.assertEqual(bv.main(["verify", out]), 0)
36
+
37
+ def test_two_party_incremental_sign(self):
38
+ a_path, a, a_pub = self._key("Inspector Demo Bot (fictional)", "inspector.key.json")
39
+ b_path, b, b_pub = self._key("Client Demo Bot (fictional)", "client.key.json")
40
+ receipt_path = os.path.join(self.tmp, "receipt.json")
41
+ rc = bv.main(["create", "--key", a_path, "--peer", a_pub.replace(".key.json", ".pub.json") if False else b_pub,
42
+ "--payload", self.payload,
43
+ "--summary", "Inspector Demo Bot delivered the inspection report to Client Demo Bot.",
44
+ "--out", receipt_path])
45
+ self.assertEqual(rc, 2) # incomplete, waiting for the client
46
+ receipt = bv.load_json(receipt_path)
47
+ self.assertTrue(bv.verify(receipt)) # errors: missing signatures and/or no seal
48
+ rc = bv.main(["sign", "--key", b_path, "--in", receipt_path, "--out", receipt_path])
49
+ # After the client signs genesis, create can continue; sign alone may still be incomplete.
50
+ if rc != 0:
51
+ rc = bv.main(["create", "--key", a_path, "--in", receipt_path, "--out", receipt_path,
52
+ "--payload", self.payload,
53
+ "--summary", "Inspector Demo Bot delivered the inspection report to Client Demo Bot."])
54
+ self.assertIn(rc, (0, 2))
55
+ rc = bv.main(["sign", "--key", b_path, "--in", receipt_path, "--out", receipt_path])
56
+ if rc != 0:
57
+ rc = bv.main(["create", "--key", a_path, "--in", receipt_path, "--out", receipt_path,
58
+ "--payload", self.payload,
59
+ "--summary", "Inspector Demo Bot delivered the inspection report to Client Demo Bot."])
60
+ rc = bv.main(["sign", "--key", b_path, "--in", receipt_path, "--out", receipt_path])
61
+ receipt = bv.load_json(receipt_path)
62
+ self.assertEqual(bv.verify(receipt), [], bv.verify(receipt))
63
+ self.assertNotIn("privkey", json.dumps(receipt))
64
+
65
+ def test_pubkey_has_no_private_key(self):
66
+ path, rec, pub = self._key("Solo Demo Bot (fictional)", "solo.key.json")
67
+ pub_obj = bv.load_json(pub)
68
+ self.assertNotIn("privkey", pub_obj)
69
+ self.assertEqual(pub_obj["kid"], rec["kid"])
70
+
71
+ def test_verify_rejects_receipt_with_private_key_field(self):
72
+ a, _, _ = self._key("Inspector Demo Bot (fictional)", "inspector.key.json")
73
+ b, _, _ = self._key("Client Demo Bot (fictional)", "client.key.json")
74
+ out = os.path.join(self.tmp, "receipt.json")
75
+ self.assertEqual(bv.main(["create", "--key", a, "--key", b, "--payload", self.payload,
76
+ "--summary", "Delivery of a fictional report.", "--out", out]), 0)
77
+ bad = bv.load_json(out)
78
+ bad[0]["content"]["privkey"] = "should-never-be-here"
79
+ bad_path = os.path.join(self.tmp, "bad.json")
80
+ bv.write_json(bad_path, bad)
81
+ self.assertEqual(bv.main(["verify", bad_path]), 1)
82
+
83
+ def test_key_file_mode(self):
84
+ path, _, _ = self._key("Inspector Demo Bot (fictional)", "inspector.key.json")
85
+ mode = os.stat(path).st_mode & 0o777
86
+ self.assertEqual(mode, 0o600)
87
+
88
+ if __name__ == "__main__":
89
+ unittest.main()
@@ -0,0 +1,70 @@
1
+ """Stdio MCP server: tools/list, create_vow, verify_vow."""
2
+ import io, json, os, shutil, sys, tempfile, unittest
3
+ sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "tools"))
4
+ import botvow as bv
5
+ import mcp_server
6
+
7
+ def rpc(method, params=None, mid=1):
8
+ msg = {"jsonrpc": "2.0", "id": mid, "method": method}
9
+ if params is not None:
10
+ msg["params"] = params
11
+ return mcp_server.handle(msg)
12
+
13
+ class McpServerTests(unittest.TestCase):
14
+ def setUp(self):
15
+ self.tmp = tempfile.mkdtemp(prefix="botvow-mcp-")
16
+ self.addCleanup(lambda: shutil.rmtree(self.tmp, ignore_errors=True))
17
+ self.payload = os.path.join(self.tmp, "report.txt")
18
+ with open(self.payload, "w", encoding="utf-8") as f:
19
+ f.write("Fictional inspection report.\n")
20
+ self.a = os.path.join(self.tmp, "a.key.json")
21
+ self.b = os.path.join(self.tmp, "b.key.json")
22
+ bv.keygen("Inspector Demo Bot (fictional)", self.a)
23
+ bv.keygen("Client Demo Bot (fictional)", self.b)
24
+
25
+ def test_initialize_and_list_tools(self):
26
+ init = rpc("initialize", {"protocolVersion": "2025-06-18", "capabilities": {}, "clientInfo": {"name": "test", "version": "0"}})
27
+ self.assertEqual(init["result"]["serverInfo"]["name"], "botvow")
28
+ names = {t["name"] for t in rpc("tools/list")["result"]["tools"]}
29
+ self.assertEqual(names, {"create_vow", "verify_vow"})
30
+
31
+ def test_create_and_verify_tools(self):
32
+ out = os.path.join(self.tmp, "receipt.json")
33
+ created = rpc("tools/call", {"name": "create_vow", "arguments": {
34
+ "key_paths": [self.a, self.b],
35
+ "payload_path": self.payload,
36
+ "summary": "Inspector Demo Bot delivered the inspection report to Client Demo Bot.",
37
+ "out_path": out,
38
+ }})["result"]
39
+ self.assertFalse(created.get("isError"))
40
+ self.assertIn("VERIFY OK", created["content"][0]["text"])
41
+ self.assertNotIn("privkey", json.dumps(created))
42
+ verified = rpc("tools/call", {"name": "verify_vow", "arguments": {"receipt_path": out}})["result"]
43
+ self.assertFalse(verified.get("isError"))
44
+ self.assertIn("VERIFY OK", verified["content"][0]["text"])
45
+
46
+ def test_refuses_private_key_argument(self):
47
+ rec = bv.load_json(self.a)
48
+ result = rpc("tools/call", {"name": "create_vow", "arguments": {
49
+ "key_paths": [self.a],
50
+ "privkey": rec["privkey"],
51
+ }})["result"]
52
+ self.assertTrue(result.get("isError"))
53
+ self.assertIn("private keys", result["content"][0]["text"].lower())
54
+
55
+ def test_framing_roundtrip(self):
56
+ req = {"jsonrpc": "2.0", "id": 7, "method": "tools/list"}
57
+ body = json.dumps(req).encode("utf-8")
58
+ framed = f"Content-Length: {len(body)}\r\n\r\n".encode("utf-8") + body
59
+ stdin = io.BytesIO(framed)
60
+ stdout = io.BytesIO()
61
+ mcp_server.serve(stdin, stdout)
62
+ raw = stdout.getvalue()
63
+ self.assertTrue(raw.startswith(b"Content-Length:"))
64
+ length = int(raw.split(b"\r\n")[0].split(b":")[1])
65
+ payload = json.loads(raw.split(b"\r\n\r\n", 1)[1][:length])
66
+ names = {t["name"] for t in payload["result"]["tools"]}
67
+ self.assertEqual(names, {"create_vow", "verify_vow"})
68
+
69
+ if __name__ == "__main__":
70
+ unittest.main()