Skip to content

Commit a1b92a4

Browse files
Add invalid capsule conformance vectors and tests
15 negative test vectors across 5 error categories: - missing_field: no id, type, trigger, reasoning, empty object - wrong_type: string sequence, string confidence, null trigger.type, array trigger - invalid_value: negative sequence, confidence >1.0, unknown CapsuleType - chain_violation: genesis with previous_hash, non-genesis without - integrity_violation: tampered content with original hash 33 Python tests validate all vectors including hash mismatch detection via compute_hash(). Coverage guard ensures no fixture goes untested. Also updates CHANGELOG [Unreleased] and conformance README.
1 parent 0829eba commit a1b92a4

5 files changed

Lines changed: 547 additions & 1 deletion

File tree

CHANGELOG.md

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

1010
## [Unreleased]
1111

12+
### Added
13+
14+
- **Go verifier library** (`capsule-go`) -- canonical JSON serialization, SHA3-256 hashing, Ed25519 signature verification, and structural/full/signature chain verification in Go. Passes all 16 golden conformance vectors. Uses `crypto/ed25519` (stdlib) and `golang.org/x/crypto/sha3`. Verification-only (no capsule creation).
15+
- **LiteLLM integration** (`capsule-litellm`) -- `CapsuleLogger` callback that seals every LLM call into a Capsule. Sync and async support. Captures prompt hash (SHA3-256), token metrics, latency, model identity, and error tracking. Install: `pip install capsule-litellm`.
16+
- **Invalid capsule fixtures** (`conformance/invalid-fixtures.json`) -- 15 negative test vectors across 5 error categories: missing required fields, wrong types, invalid values, chain violations, and content tampering. Verifiers SHOULD reject all of these.
17+
- **Python tests for invalid fixtures** (`test_invalid_fixtures.py`) -- 27 tests validating the invalid fixture suite: structure, missing fields, wrong types, invalid values, chain violations, integrity violation via `compute_hash()`, and coverage guard.
18+
1219
---
1320

1421
## [1.3.0] - 2026-03-09

conformance/README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,38 @@ The URI spec is at [`spec/uri-scheme.md`](../spec/uri-scheme.md).
9999

100100
---
101101

102+
## Invalid Capsule Fixtures
103+
104+
The `invalid-fixtures.json` file provides 15 test vectors for **malformed or structurally invalid** capsules. A conformant verifier SHOULD reject each of these.
105+
106+
Each entry contains:
107+
108+
| Field | Type | Description |
109+
|---|---|---|
110+
| `capsule_dict` | object | A malformed capsule |
111+
| `expected_error` | string | Error category: `missing_field`, `wrong_type`, `invalid_value`, `chain_violation`, `integrity_violation` |
112+
| `error_field` | string | Which field caused the error |
113+
114+
### Error categories
115+
116+
| Category | Description | Example |
117+
|---|---|---|
118+
| `missing_field` | A required field is absent | No `id`, no `trigger` section, empty object |
119+
| `wrong_type` | A field has the wrong JSON type | `sequence` is a string, `trigger` is an array |
120+
| `invalid_value` | A field has an invalid value | Negative sequence, confidence > 1.0, unknown CapsuleType |
121+
| `chain_violation` | Chain rules (CPS Section 4) are violated | Genesis with previous_hash, non-genesis without it |
122+
| `integrity_violation` | Stored hash does not match content | Tampered domain with original hash |
123+
124+
### Invalid capsule conformance check
125+
126+
For every fixture:
127+
128+
1. Attempt to validate the capsule
129+
2. Confirm the validator rejects it with an appropriate error
130+
3. For `integrity_violation` fixtures, verify that `VerifyHash(capsule_dict, claimed_hash)` returns false
131+
132+
---
133+
102134
## Adding New Fixtures
103135

104136
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:

0 commit comments

Comments
 (0)