Skip to content

Commit 84b98b1

Browse files
Release v1.2.0: Protocol-first restructure, TypeScript implementation, URI scheme, full CapsuleType conformance
1 parent e896d9d commit 84b98b1

29 files changed

Lines changed: 739 additions & 45 deletions

.github/ISSUE_TEMPLATE/new-implementation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Link to the repository (or note if it will be a PR to this repo).
2323
- [ ] `seal()` — hash + Ed25519 signature
2424
- [ ] `verify()` — recompute hash and verify signature
2525
- [ ] `from_dict()` — deserialize from dictionary/map
26-
- [ ] Pass all 15 golden test vectors from `conformance/fixtures.json`
26+
- [ ] Pass all 16 golden test vectors from `conformance/fixtures.json`
2727
- [ ] Chain verification (sequence + hash linkage)
2828

2929
## Crypto Libraries Used

.github/workflows/python-release.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
2525
with:
2626
python-version: ${{ matrix.python-version }}
27-
- run: pip install -e ".[storage,dev]"
27+
- run: pip install -e ".[storage,fastapi,dev]"
2828
- run: pytest tests/ -v --tb=short
2929
- run: pytest tests/test_golden_fixtures.py -v
3030

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: TypeScript Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
permissions:
9+
contents: read
10+
11+
defaults:
12+
run:
13+
working-directory: reference/typescript
14+
15+
jobs:
16+
test:
17+
name: Test
18+
runs-on: ubuntu-latest
19+
strategy:
20+
matrix:
21+
node-version: ["20", "22"]
22+
steps:
23+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
24+
- uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0
25+
with:
26+
node-version: ${{ matrix.node-version }}
27+
- run: npm ci
28+
- run: npx vitest run
29+
30+
conformance:
31+
name: Conformance
32+
runs-on: ubuntu-latest
33+
steps:
34+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
35+
- uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0
36+
with:
37+
node-version: "22"
38+
- run: npm ci
39+
- run: npx vitest run __tests__/conformance.test.ts
40+
41+
build:
42+
name: Build Package
43+
runs-on: ubuntu-latest
44+
needs: [test, conformance]
45+
steps:
46+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
47+
- uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0
48+
with:
49+
node-version: "22"
50+
registry-url: "https://registry.npmjs.org"
51+
- run: npm ci
52+
- run: npx tsc
53+
54+
publish:
55+
name: Publish to npm
56+
runs-on: ubuntu-latest
57+
needs: build
58+
permissions:
59+
id-token: write
60+
steps:
61+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
62+
- uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0
63+
with:
64+
node-version: "22"
65+
registry-url: "https://registry.npmjs.org"
66+
- run: npm ci
67+
- run: npx tsc
68+
- name: Extract version from tag
69+
id: version
70+
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
71+
- name: Set package version
72+
run: npm version ${{ steps.version.outputs.VERSION }} --no-git-tag-version
73+
- run: npm publish --provenance --access public
74+
env:
75+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

CHANGELOG.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ Versioning follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
99

1010
## [Unreleased]
1111

12+
---
13+
14+
## [1.2.0] - 2026-03-08
15+
16+
Protocol-first restructure, TypeScript implementation, finalized URI scheme, and full CapsuleType conformance.
17+
1218
### Changed
1319

1420
- **Protocol-first repository restructure** — the repo now presents as an open protocol specification, not a Python package:
@@ -21,11 +27,13 @@ Versioning follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
2127

2228
### Added
2329

24-
- **`capsule://` URI scheme** — content-addressable references to Capsule records via their SHA3-256 hash. Spec at `spec/uri-scheme.md`. Supports hash references (`capsule://sha3_<hash>`), chain references (`capsule://chain/42`), ID references, and fragment syntax into the 6 sections.
25-
- **TypeScript reference implementation** — full CPS-conformant implementation at `reference/typescript/`: Capsule model with factories, canonical JSON serializer (CPS Section 2 with float-path handling), SHA3-256 hashing, Ed25519 seal/verify, and chain verification. Passes all 15 golden fixtures. 101 tests, 100% coverage (v8). Uses `@noble/hashes` ^2.0.1, `@noble/ed25519` ^3.0.0, vitest ^4.0.0, TypeScript ^5.9.0. Node.js >= 20.19.0.
30+
- **`capsule://` URI scheme (Active)** — content-addressable references to Capsule records via their SHA3-256 hash. Spec at `spec/uri-scheme.md`, finalized from Draft to Active. Supports hash references (`capsule://sha3_<hash>`), chain references (`capsule://chain/42`), ID references, and fragment syntax into the 6 sections. Includes URI conformance vectors at `conformance/uri-fixtures.json`.
31+
- **TypeScript reference implementation** — full CPS-conformant implementation at `reference/typescript/`: Capsule model with factories, canonical JSON serializer (CPS Section 2 with float-path handling), SHA3-256 hashing, Ed25519 seal/verify, and chain verification. Passes all 16 golden fixtures. 101 tests, 100% coverage (v8). Uses `@noble/hashes` ^2.0.1, `@noble/ed25519` ^3.0.0, vitest ^4.0.0, TypeScript ^5.9.0. Node.js >= 20.19.0.
2632
- **Implementor's Guide** (`docs/implementors-guide.md`) — step-by-step instructions for building a conformant CPS implementation in any language, with language-specific pitfalls for TypeScript, Go, and Rust.
2733
- **Why Capsules** (`docs/why-capsules.md`) — the case for cryptographic AI memory, aimed at decision-makers and architects.
28-
- **URI scheme security considerations**`spec/uri-scheme.md` now includes: URI injection validation, resolution trust model, denial-of-service mitigations, fragment path traversal safety, no ambient authority principle.
34+
- **URI scheme security considerations**`spec/uri-scheme.md` includes: URI injection validation, resolution trust model, denial-of-service mitigations, fragment path traversal safety, no ambient authority principle.
35+
- **URI conformance vectors** (`conformance/uri-fixtures.json`) — 10 valid and 11 invalid URI parsing test vectors for cross-language URI parser verification.
36+
- **`vault` golden fixture** — conformance suite now covers all 8 CapsuleTypes (16 total fixtures, up from 15). The `vault_secret` fixture tests secret rotation with policy-based authority.
2937
- **Protocol structure tests** (`reference/python/tests/test_protocol_structure.py`) — guards the protocol-first layout, spec completeness, conformance suite integrity, TypeScript type alignment with spec, markdown link resolution, CI configuration, and root-level file requirements.
3038
- **Dependabot for TypeScript** — npm dependency updates for `reference/typescript/`.
3139

@@ -92,5 +100,6 @@ Initial public release of the Capsule Protocol Specification (CPS) v1.0 referenc
92100

93101
---
94102

103+
[1.2.0]: https://github.com/quantumpipes/capsule/releases/tag/v1.2.0
95104
[1.1.0]: https://github.com/quantumpipes/capsule/releases/tag/v1.1.0
96105
[1.0.0]: https://github.com/quantumpipes/capsule/releases/tag/v1.0.0

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ We welcome reference implementations in new languages. To add one:
4646

4747
1. Open a [new implementation issue](https://github.com/quantumpipes/capsule/issues/new?template=new-implementation.md)
4848
2. Create `reference/<language>/` with the implementation
49-
3. The implementation must pass all 15 golden test vectors in `conformance/fixtures.json`
49+
3. The implementation must pass all 16 golden test vectors in `conformance/fixtures.json`
5050
4. Include a README with installation, quickstart, and API overview
5151

5252
A conformant implementation must provide:

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Every AI action produces a Capsule — a tamper-evident, content-addressable rec
88

99
[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
1010
[![CPS](https://img.shields.io/badge/CPS-v1.0-orange.svg)](./spec/)
11-
[![Conformance](https://img.shields.io/badge/Conformance-15_vectors-brightgreen.svg)](./conformance/)
11+
[![Conformance](https://img.shields.io/badge/Conformance-16_vectors-brightgreen.svg)](./conformance/)
1212
[![FIPS](https://img.shields.io/badge/Crypto-FIPS_202%20·%20186--5%20·%20204-purple.svg)](#cryptographic-seal)
1313
[![Coverage](https://img.shields.io/badge/Coverage-100%25-brightgreen.svg)](./reference/python/)
1414

@@ -58,7 +58,7 @@ Section 3 (Reasoning) records the AI's analysis, the options it considered, the
5858
Every Capsule is hashed and signed at the moment of creation. If anyone modifies the content after the fact, the hash changes, the signature fails, and the chain breaks. This is a property of every individual record, not the storage layer.
5959

6060
**3. Cross-language interoperability.**
61-
The Capsule Protocol Specification defines byte-level serialization rules. A Capsule sealed in Python can be verified in TypeScript, Go, or Rust. All implementations produce identical canonical JSON for the same input, validated by 15 golden test vectors.
61+
The Capsule Protocol Specification defines byte-level serialization rules. A Capsule sealed in Python can be verified in TypeScript, Go, or Rust. All implementations produce identical canonical JSON for the same input, validated by 16 golden test vectors.
6262

6363
---
6464

@@ -121,7 +121,7 @@ The **Capsule Protocol Specification (CPS)** defines the complete protocol:
121121
|---|---|
122122
| [CPS v1.0](./spec/) | Record structure, canonical serialization, sealing algorithm, hash chain rules |
123123
| [URI Scheme](./spec/uri-scheme.md) | `capsule://` content-addressable references |
124-
| [Conformance Suite](./conformance/) | 15 golden test vectors for cross-language verification |
124+
| [Conformance Suite](./conformance/) | 16 golden test vectors for cross-language verification |
125125

126126
The specification is language-agnostic. Any implementation that passes the conformance suite can seal and verify Capsules produced by any other.
127127

@@ -169,7 +169,7 @@ See more examples in [`examples/`](./examples/).
169169
| Language | Status | Install | Source |
170170
|---|---|---|---|
171171
| **Python** | v1.1.0 (stable) | `pip install qp-capsule` | [`reference/python/`](./reference/python/) |
172-
| **TypeScript** | v0.0.1 (conformant, 15/15 fixtures) | `npm install @quantumpipes/capsule` | [`reference/typescript/`](./reference/typescript/) |
172+
| **TypeScript** | v0.0.1 (conformant, 16/16 fixtures) | `npm install @quantumpipes/capsule` | [`reference/typescript/`](./reference/typescript/) |
173173
| Go | Separate repo (planned) || [quantumpipes/capsule-go](https://github.com/quantumpipes/capsule-go) |
174174
| Rust | Separate repo (planned) || [quantumpipes/capsule-rust](https://github.com/quantumpipes/capsule-rust) |
175175

conformance/README.md

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Conformance Test Suite
22

3-
**15 golden test vectors for cross-language interoperability.**
3+
**16 golden test vectors for cross-language interoperability.**
44

5-
Any implementation of the Capsule Protocol Specification (CPS) must produce byte-identical output for these test vectors. If your implementation passes all 15 fixtures, it can seal and verify Capsules interchangeably with every other conformant implementation.
5+
Any implementation of the Capsule Protocol Specification (CPS) must produce byte-identical output for these test vectors. If your implementation passes all 16 fixtures, it can seal and verify Capsules interchangeably with every other conformant implementation.
66

77
---
88

@@ -25,7 +25,7 @@ For every fixture:
2525
3. Compute SHA3-256 of the canonical JSON bytes (UTF-8 encoded)
2626
4. Compare the hash against `sha3_256_hash`
2727

28-
If all 15 pass, your implementation is conformant.
28+
If all 16 pass, your implementation is conformant.
2929

3030
---
3131

@@ -48,6 +48,7 @@ If all 15 pass, your implementation is conformant.
4848
| **chain_linked** | Second Capsule with previous_hash set |
4949
| **failure_with_error** | Failed tool call with error details |
5050
| **auth_escalated** | Auth-type with MFA escalation chain |
51+
| **vault_secret** | Vault-type with secret rotation and policy authority |
5152

5253
---
5354

@@ -64,6 +65,40 @@ This regenerates `fixtures.json` from the reference implementation. The generato
6465

6566
---
6667

68+
## URI Conformance Vectors
69+
70+
The `uri-fixtures.json` file provides test vectors for `capsule://` URI parsing. Implementations that include a URI parser should validate against these vectors.
71+
72+
Each entry in the `valid` array contains:
73+
74+
| Field | Type | Description |
75+
|---|---|---|
76+
| `uri` | string | The `capsule://` URI to parse |
77+
| `expected` | object | The expected parse result with `scheme`, `chain`, `reference_type`, `hash_algorithm`, `hash_value`, `sequence`, `id`, and `fragment` |
78+
79+
Each entry in the `invalid` array contains:
80+
81+
| Field | Type | Description |
82+
|---|---|---|
83+
| `uri` | string | A malformed or invalid URI |
84+
| `reason` | string | Why this URI must be rejected |
85+
86+
### URI conformance check
87+
88+
For every valid fixture:
89+
90+
1. Parse the URI
91+
2. Compare every field in the parse result against `expected`
92+
93+
For every invalid fixture:
94+
95+
1. Attempt to parse the URI
96+
2. Confirm the parser rejects it (returns an error or null)
97+
98+
The URI spec is at [`spec/uri-scheme.md`](../spec/uri-scheme.md).
99+
100+
---
101+
67102
## Adding New Fixtures
68103

69104
New fixtures must be added through the [protocol change proposal](https://github.com/quantumpipes/capsule/issues/new?template=spec-change.md) process. Every new fixture must:

conformance/fixtures.json

Lines changed: 83 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"version": "1.0",
33
"specification": "Capsule Protocol Specification v1.0",
44
"generated_by": "Python reference implementation (qp-capsule)",
5-
"generated_at": "2026-03-07T18:11:36.964652+00:00",
5+
"generated_at": "2026-03-08T15:09:35.637607+00:00",
66
"description": "Golden test vectors for cross-language Capsule verification. Each fixture contains a capsule_dict, the expected canonical_json, and the expected sha3_256_hash. A conformant implementation must produce byte-identical canonical_json and matching hash for each fixture.",
77
"fixtures": [
88
{
@@ -1084,6 +1084,88 @@
10841084
},
10851085
"canonical_json": "{\"authority\":{\"approver\":\"admin@example.com\",\"chain\":[{\"level\":1,\"method\":\"password\",\"result\":\"passed\"},{\"level\":2,\"method\":\"totp\",\"result\":\"passed\"}],\"escalation_reason\":\"Admin action requires MFA\",\"policy_reference\":null,\"type\":\"escalated\"},\"context\":{\"agent_id\":\"\",\"environment\":{},\"session_id\":null},\"domain\":\"auth\",\"execution\":{\"duration_ms\":0,\"resources_used\":{},\"tool_calls\":[]},\"id\":\"c5d6e7f8-a9b0-1234-cdef-3456789abcde\",\"outcome\":{\"error\":null,\"metrics\":{},\"result\":null,\"side_effects\":[],\"status\":\"success\",\"summary\":\"MFA verified, admin access granted\"},\"parent_id\":null,\"previous_hash\":null,\"reasoning\":{\"analysis\":\"\",\"confidence\":0.0,\"model\":null,\"options\":[],\"options_considered\":[],\"prompt_hash\":null,\"reasoning\":\"\",\"selected_option\":\"\"},\"sequence\":0,\"trigger\":{\"correlation_id\":null,\"request\":\"MFA challenge for admin action\",\"source\":\"auth_service\",\"timestamp\":\"2026-01-15T12:00:00+00:00\",\"type\":\"system\",\"user_id\":\"admin@example.com\"},\"type\":\"auth\"}",
10861086
"sha3_256_hash": "336e52623385149110d295881629e517f0ed16740410ac0ec308fced730d49fa"
1087+
},
1088+
{
1089+
"name": "vault_secret",
1090+
"description": "Vault-type capsule for secret storage/rotation. Tests CapsuleType.VAULT with tool call for secret rotation and policy-based authority.",
1091+
"capsule_dict": {
1092+
"id": "d6e7f8a9-b0c1-2345-defa-456789abcdef",
1093+
"type": "vault",
1094+
"domain": "secrets",
1095+
"parent_id": null,
1096+
"sequence": 0,
1097+
"previous_hash": null,
1098+
"trigger": {
1099+
"type": "scheduled",
1100+
"source": "secret_rotator",
1101+
"timestamp": "2026-01-15T12:00:00+00:00",
1102+
"request": "Rotate database credentials for production",
1103+
"correlation_id": null,
1104+
"user_id": null
1105+
},
1106+
"context": {
1107+
"agent_id": "vault-agent",
1108+
"session_id": null,
1109+
"environment": {
1110+
"vault_backend": "hashicorp",
1111+
"region": "us-east-1"
1112+
}
1113+
},
1114+
"reasoning": {
1115+
"analysis": "",
1116+
"options": [],
1117+
"options_considered": [],
1118+
"selected_option": "",
1119+
"reasoning": "",
1120+
"confidence": 0.0,
1121+
"model": null,
1122+
"prompt_hash": null
1123+
},
1124+
"authority": {
1125+
"type": "policy",
1126+
"approver": null,
1127+
"policy_reference": "POLICY-SECRET-ROTATION-90D",
1128+
"chain": [],
1129+
"escalation_reason": null
1130+
},
1131+
"execution": {
1132+
"tool_calls": [
1133+
{
1134+
"tool": "vault_rotate",
1135+
"arguments": {
1136+
"secret": "db/prod/credentials",
1137+
"ttl": "90d"
1138+
},
1139+
"result": {
1140+
"rotated": true,
1141+
"version": 7
1142+
},
1143+
"success": true,
1144+
"duration_ms": 320,
1145+
"error": null
1146+
}
1147+
],
1148+
"duration_ms": 320,
1149+
"resources_used": {
1150+
"api_calls": 2
1151+
}
1152+
},
1153+
"outcome": {
1154+
"status": "success",
1155+
"result": {
1156+
"secret_path": "db/prod/credentials",
1157+
"new_version": 7
1158+
},
1159+
"summary": "Rotated database credentials, version 7",
1160+
"error": null,
1161+
"side_effects": [
1162+
"Old credentials revoked after 5m grace period"
1163+
],
1164+
"metrics": {}
1165+
}
1166+
},
1167+
"canonical_json": "{\"authority\":{\"approver\":null,\"chain\":[],\"escalation_reason\":null,\"policy_reference\":\"POLICY-SECRET-ROTATION-90D\",\"type\":\"policy\"},\"context\":{\"agent_id\":\"vault-agent\",\"environment\":{\"region\":\"us-east-1\",\"vault_backend\":\"hashicorp\"},\"session_id\":null},\"domain\":\"secrets\",\"execution\":{\"duration_ms\":320,\"resources_used\":{\"api_calls\":2},\"tool_calls\":[{\"arguments\":{\"secret\":\"db/prod/credentials\",\"ttl\":\"90d\"},\"duration_ms\":320,\"error\":null,\"result\":{\"rotated\":true,\"version\":7},\"success\":true,\"tool\":\"vault_rotate\"}]},\"id\":\"d6e7f8a9-b0c1-2345-defa-456789abcdef\",\"outcome\":{\"error\":null,\"metrics\":{},\"result\":{\"new_version\":7,\"secret_path\":\"db/prod/credentials\"},\"side_effects\":[\"Old credentials revoked after 5m grace period\"],\"status\":\"success\",\"summary\":\"Rotated database credentials, version 7\"},\"parent_id\":null,\"previous_hash\":null,\"reasoning\":{\"analysis\":\"\",\"confidence\":0.0,\"model\":null,\"options\":[],\"options_considered\":[],\"prompt_hash\":null,\"reasoning\":\"\",\"selected_option\":\"\"},\"sequence\":0,\"trigger\":{\"correlation_id\":null,\"request\":\"Rotate database credentials for production\",\"source\":\"secret_rotator\",\"timestamp\":\"2026-01-15T12:00:00+00:00\",\"type\":\"scheduled\",\"user_id\":null},\"type\":\"vault\"}",
1168+
"sha3_256_hash": "af88f095652eefeb8b6aeaca64860ac4ffc0476f3f274157387dd633ab6c9396"
10871169
}
10881170
]
10891171
}

0 commit comments

Comments
 (0)