pactium 0.2.0 → 0.2.1
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.
- package/CHANGELOG.md +150 -0
- package/README.md +362 -39
- package/README.zh-CN.md +296 -34
- package/SECURITY.md +87 -4
- package/docs/API.md +698 -0
- package/docs/FAQ.md +189 -0
- package/docs/MIGRATION.md +110 -0
- package/docs/README.md +47 -9
- package/docs/architecture/ARCHITECTURE.md +193 -1
- package/docs/logo.svg +45 -0
- package/examples/README.md +106 -0
- package/examples/export-proof-bundle.mjs +40 -0
- package/examples/licolite-signed-operation.mjs +62 -0
- package/examples/verify-envelope.mjs +41 -0
- package/examples/workspace-projection.mjs +55 -0
- package/package.json +33 -5
- package/src/index.d.ts +1 -1
- package/src/protocol/constants.js +1 -1
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/), and this project adheres to [Semantic Versioning](https://semver.org/).
|
|
6
|
+
|
|
7
|
+
## [0.2.1] - 2026-06-20
|
|
8
|
+
|
|
9
|
+
This patch release expands the published documentation set and tightens release gates. It does not change the protocol format or public API behavior.
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- Published API, FAQ, migration, examples, changelog, and logo documentation in the npm package.
|
|
14
|
+
- Package-content gate coverage for the expanded documentation set and runnable examples.
|
|
15
|
+
- Published-document link verification so npm package docs cannot point to unpublished relative files.
|
|
16
|
+
|
|
17
|
+
### Changed
|
|
18
|
+
|
|
19
|
+
- Updated README documentation indexes to keep process documents on GitHub while package-facing docs stay self-contained.
|
|
20
|
+
- Synchronized package metadata, version constants, and TypeScript declarations for the patch release.
|
|
21
|
+
|
|
22
|
+
## [0.2.0] - 2026-06-19
|
|
23
|
+
|
|
24
|
+
This is the first public release of Pactium as a proof-first protocol substrate. The package surface is built around verifiable operation facts, append-only recovery history, and cryptographic state verification.
|
|
25
|
+
|
|
26
|
+
### Added
|
|
27
|
+
|
|
28
|
+
#### Core Protocol
|
|
29
|
+
|
|
30
|
+
- Canonical Value encoding (restricted IPLD/DAG-CBOR-style data model) for deterministic serialization
|
|
31
|
+
- Protocol Hash with domain separation (`sha256` with fixed domain prefixes per object class)
|
|
32
|
+
- Content-addressed Identifiers (`cid:sha256:<hex>` format)
|
|
33
|
+
- Storage Port abstraction with local JSON backend and content-addressed block store
|
|
34
|
+
|
|
35
|
+
#### Operation Ledger
|
|
36
|
+
|
|
37
|
+
- RFC 6962-style Ledger Transparency Log with append-only guarantees
|
|
38
|
+
- Ledger inclusion proofs (verify a leaf exists at a given tree size)
|
|
39
|
+
- Ledger consistency proofs (verify a smaller ledger is a prefix of a larger one)
|
|
40
|
+
- Ledger Head as verifiable ledger state summary
|
|
41
|
+
- Single Ledger Append Lane for global ordering
|
|
42
|
+
- Signed Ledger Head support (Ed25519) with verifier manifests
|
|
43
|
+
- Last Trusted Head advancement with consistency verification
|
|
44
|
+
|
|
45
|
+
#### Operation Lifecycle
|
|
46
|
+
|
|
47
|
+
- Operation Intent and Operation Outcome as append-only facts
|
|
48
|
+
- Terminal Outcome semantics (one outcome per intent)
|
|
49
|
+
- Canceled Outcome for explicit cancellation recording
|
|
50
|
+
- Open Intent recovery through verifiable Open Intent Index
|
|
51
|
+
- Intent Idempotency Index and Outcome Idempotency Index
|
|
52
|
+
- Idempotency Replay detection (returns existing proof without new append)
|
|
53
|
+
- Causality References for linking retries, repairs, and compensations
|
|
54
|
+
- Operation Causality Index for verifiable relationship queries
|
|
55
|
+
|
|
56
|
+
#### Verifiable Index Engine
|
|
57
|
+
|
|
58
|
+
- Canonical Prolly Tree with Content-Defined Chunking (protocol constants)
|
|
59
|
+
- Membership proofs and non-membership proofs
|
|
60
|
+
- Efficient structural-sharing diffs between index roots
|
|
61
|
+
- Index Domain Adapters for domain-independent proof engine
|
|
62
|
+
- Shared engine reused by state, workspace, lifecycle, idempotency, and causality indexes
|
|
63
|
+
|
|
64
|
+
#### Workspace Projection
|
|
65
|
+
|
|
66
|
+
- Workspace Order Index (workspace-local order to ledger event references)
|
|
67
|
+
- Workspace Membership Index (ledger event ID to workspace membership material)
|
|
68
|
+
- Synchronous projection updates during protocol commits
|
|
69
|
+
- Verifiable workspace-scoped ordering and pagination
|
|
70
|
+
- Default-enabled for LicoLite Aspect
|
|
71
|
+
|
|
72
|
+
#### Merkle State
|
|
73
|
+
|
|
74
|
+
- State Commits bound to Operation Outcomes (not Intents)
|
|
75
|
+
- Content-addressed state roots through shared Verifiable Index Engine
|
|
76
|
+
- Key membership and non-membership proofs
|
|
77
|
+
- Efficient state diffs via Prolly Tree shared-node traversal
|
|
78
|
+
|
|
79
|
+
#### Checkpoint Tree
|
|
80
|
+
|
|
81
|
+
- Intent Checkpoints for lifecycle start and recoverable progress
|
|
82
|
+
- Outcome Checkpoints for results, effect evidence, and state transitions
|
|
83
|
+
- Verifiable node membership through shared Index Engine
|
|
84
|
+
- Checkpoint Tree Head for recovery structure summary
|
|
85
|
+
|
|
86
|
+
#### Proof System
|
|
87
|
+
|
|
88
|
+
- Pactium Proof Envelope: cross-proof receipt binding ledger, index, state, and checkpoint evidence
|
|
89
|
+
- Proof Material Refs: content-addressed references to stored proof material
|
|
90
|
+
- Proof Bundles: portable CAR-like exports for offline verification
|
|
91
|
+
- Proof Extensions: hash-bound host extensions (critical and non-critical)
|
|
92
|
+
- Default Proof Verifier Registry for extensible verification
|
|
93
|
+
- Standalone `verifyProofEnvelope()` and `verifyProofBundle()` functions
|
|
94
|
+
|
|
95
|
+
#### LicoLite Aspect (`pactium/licolite`)
|
|
96
|
+
|
|
97
|
+
- `createLicoLiteAspect()` with default Workspace Projection and signing
|
|
98
|
+
- `createLicoLiteSigner()` for Ed25519 signing authority
|
|
99
|
+
- LicoLite Policy Extension (critical, hash-bound)
|
|
100
|
+
- LicoLite Workspace Effect Extension (critical, hash-bound)
|
|
101
|
+
- LicoLite Verifier with structured Verification Failures
|
|
102
|
+
- Evidence policy modes: `production` (fail-closed) and `opportunistic`
|
|
103
|
+
- LicoLite-level Proof Bundle verification
|
|
104
|
+
|
|
105
|
+
#### Maintenance and Repair
|
|
106
|
+
|
|
107
|
+
- Structured Verification Failures with layer, code, severity, and evidence
|
|
108
|
+
- Repair Planner: deterministic repair task generation from verification failures
|
|
109
|
+
- Maintenance Task Engine with `doctor` health check
|
|
110
|
+
- Repair proposals without automatic execution (host decides)
|
|
111
|
+
|
|
112
|
+
#### CLI and HTTP
|
|
113
|
+
|
|
114
|
+
- `pactium doctor` -- data directory health check
|
|
115
|
+
- `pactium serve` -- local HTTP verification server
|
|
116
|
+
- `pactium operation record` -- record operations from JSON
|
|
117
|
+
- `pactium envelope verify` -- verify proof envelopes
|
|
118
|
+
- `pactium bundle verify` -- verify proof bundles
|
|
119
|
+
- `pactium licolite record` / `pactium licolite verify` -- LicoLite operations
|
|
120
|
+
- JSON input from `--body`, `--body-file`, or stdin
|
|
121
|
+
|
|
122
|
+
#### Quality and Release
|
|
123
|
+
|
|
124
|
+
- Coverage-enforced tests (95% lines/functions, 90% branches)
|
|
125
|
+
- Deterministic proof-vector fixtures (protocol-revision-locked)
|
|
126
|
+
- Public API regression snapshots
|
|
127
|
+
- Seeded property tests for encoding determinism and Prolly Tree soundness
|
|
128
|
+
- Public API pressure profiles (scaled for CI, full-count for release review)
|
|
129
|
+
- Release-readiness enforcement script
|
|
130
|
+
- Package contents verification (excludes process docs, tests, build outputs)
|
|
131
|
+
- Node.js 22 and Node.js 24 release gating
|
|
132
|
+
|
|
133
|
+
### Changed
|
|
134
|
+
|
|
135
|
+
- Package surface is proof-first: write operations return verifiable proof envelopes
|
|
136
|
+
- Root export limited to latest proof-first API only (no historical/experimental APIs)
|
|
137
|
+
- Project tooling limited to current development, operation, maintenance, and release needs
|
|
138
|
+
- Durable project decisions maintained as docs and ADRs (not development scratch)
|
|
139
|
+
|
|
140
|
+
### Security
|
|
141
|
+
|
|
142
|
+
- Content-addressed proof material integrity checks for envelopes and bundles
|
|
143
|
+
- Critical extension model: unknown critical extensions fail verification
|
|
144
|
+
- LicoLite Policy Extension binding prevents proof/policy mis-association
|
|
145
|
+
- LicoLite Workspace Effect Extension binding prevents proof/effect mis-association
|
|
146
|
+
- Ed25519 signing support for Ledger Heads and LicoLite envelopes
|
|
147
|
+
- Signed head verification with verifier manifest validation
|
|
148
|
+
|
|
149
|
+
[0.2.1]: https://github.com/Unka-Malloc/Pactium/releases/tag/v0.2.1
|
|
150
|
+
[0.2.0]: https://github.com/Unka-Malloc/Pactium/releases/tag/v0.2.0
|
package/README.md
CHANGED
|
@@ -1,92 +1,415 @@
|
|
|
1
1
|
<p align="center">
|
|
2
|
-
<
|
|
2
|
+
<img src="docs/logo.svg" alt="Pactium" width="120" />
|
|
3
3
|
</p>
|
|
4
4
|
|
|
5
|
-
Pactium
|
|
5
|
+
<h1 align="center">Pactium</h1>
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
<p align="center">
|
|
8
|
+
Proof-first protocol substrate for verifiable operation facts, append-only recovery history, and cryptographic state verification.
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
<p align="center">
|
|
12
|
+
<a href="https://github.com/Unka-Malloc/Pactium/actions/workflows/ci.yml"><img src="https://github.com/Unka-Malloc/Pactium/actions/workflows/ci.yml/badge.svg" alt="CI" /></a>
|
|
13
|
+
<a href="https://www.npmjs.com/package/pactium"><img src="https://img.shields.io/npm/v/pactium.svg" alt="npm version" /></a>
|
|
14
|
+
<a href="https://www.npmjs.com/package/pactium"><img src="https://img.shields.io/npm/dm/pactium.svg" alt="npm downloads" /></a>
|
|
15
|
+
<a href="https://github.com/Unka-Malloc/Pactium/blob/stable/LICENSE"><img src="https://img.shields.io/npm/l/pactium.svg" alt="license" /></a>
|
|
16
|
+
<a href="https://img.shields.io/node/v/pactium"><img src="https://img.shields.io/node/v/pactium.svg" alt="node version" /></a>
|
|
17
|
+
<img src="https://img.shields.io/badge/types-included-blue.svg" alt="TypeScript types" />
|
|
18
|
+
</p>
|
|
19
|
+
|
|
20
|
+
<p align="center">
|
|
21
|
+
<a href="./README.zh-CN.md">中文文档</a> |
|
|
22
|
+
<a href="./docs/API.md">API Reference</a> |
|
|
23
|
+
<a href="./docs/protocols/PROTOCOLS.md">Protocol Spec</a> |
|
|
24
|
+
<a href="https://github.com/Unka-Malloc/Pactium/blob/stable/CONTRIBUTING.md">Contributing</a>
|
|
25
|
+
</p>
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## Table of Contents
|
|
30
|
+
|
|
31
|
+
- [Why Pactium](#why-pactium)
|
|
32
|
+
- [Design Philosophy](#design-philosophy)
|
|
33
|
+
- [Features](#features)
|
|
34
|
+
- [Installation](#installation)
|
|
35
|
+
- [Quick Start](#quick-start)
|
|
36
|
+
- [API Overview](#api-overview)
|
|
37
|
+
- [CLI](#cli)
|
|
38
|
+
- [Architecture](#architecture)
|
|
39
|
+
- [When to Use Pactium](#when-to-use-pactium)
|
|
40
|
+
- [Documentation](#documentation)
|
|
41
|
+
- [Requirements](#requirements)
|
|
42
|
+
- [Verification](#verification)
|
|
43
|
+
- [Contributing](#contributing)
|
|
44
|
+
- [License](#license)
|
|
45
|
+
|
|
46
|
+
## Why Pactium
|
|
47
|
+
|
|
48
|
+
Most systems record operations into mutable databases and hope the data stays consistent. When something goes wrong -- a crash mid-write, a silent corruption, a disputed operation -- there is no cryptographic proof of what happened or didn't happen.
|
|
8
49
|
|
|
9
|
-
|
|
50
|
+
Pactium solves this by making **every operation a verifiable fact**:
|
|
10
51
|
|
|
11
|
-
- **
|
|
12
|
-
- **
|
|
13
|
-
- **
|
|
14
|
-
- **
|
|
15
|
-
- **Proof Envelopes** bind Ledger, Workspace Projection, Checkpoint, State, and LicoLite evidence into one receipt shape.
|
|
16
|
-
- **Proof Bundles** export portable CAR-like proof material for offline verification.
|
|
17
|
-
- **LicoLite Aspect** is a first-class package surface under `pactium/licolite`.
|
|
52
|
+
- **Append-only ledger** -- operations cannot be silently rewritten or deleted
|
|
53
|
+
- **Cryptographic proofs** -- every write returns a proof envelope that can be independently verified
|
|
54
|
+
- **Portable verification** -- proof bundles can be verified offline without access to the original storage
|
|
55
|
+
- **Workspace isolation** -- workspace-scoped projections with verifiable membership proofs
|
|
18
56
|
|
|
19
|
-
|
|
57
|
+
Pactium is a zero-dependency, pure-ESM Node.js package that provides a cryptographically verifiable protocol substrate. It records operation facts into an append-only transparency log, maintains verifiable indexes over workspace-scoped projections, and produces portable proof envelopes and bundles that can be independently verified without access to the original storage.
|
|
58
|
+
|
|
59
|
+
Pactium is designed as the protocol substrate for [LicoLite](https://github.com/Unka-Malloc) and exposes a first-class integration surface at `pactium/licolite`.
|
|
60
|
+
|
|
61
|
+
## Design Philosophy
|
|
62
|
+
|
|
63
|
+
| Principle | Meaning |
|
|
64
|
+
| --- | --- |
|
|
65
|
+
| **Proof-first** | Write operations return verifiable proof envelopes, not storage acknowledgments. The proof is the API response. |
|
|
66
|
+
| **Append-only facts** | Operations are recorded as immutable Intent and Outcome facts. Corrections create new facts with causality references rather than mutating history. |
|
|
67
|
+
| **Single ordering authority** | The Operation Ledger is the only global ordering authority. All other structures derive their ordering from it. |
|
|
68
|
+
| **Verifiable indexes** | Every index (state, workspace, lifecycle) uses the same Canonical Prolly Tree engine with membership and non-membership proofs. |
|
|
69
|
+
| **Host boundary** | Pactium owns protocol facts and proofs. Host systems own policy decisions, side effects, authorization, and durable evidence storage. |
|
|
70
|
+
| **Zero dependencies** | No runtime dependencies. Ships source directly. Predictable supply chain. |
|
|
71
|
+
| **Protocol, not configuration** | Hash algorithms, encoding formats, and chunking parameters are protocol constants, not host options. Changes require a new protocol version. |
|
|
72
|
+
|
|
73
|
+
## Features
|
|
74
|
+
|
|
75
|
+
| Capability | Description |
|
|
76
|
+
| --- | --- |
|
|
77
|
+
| **Operation Ledger** | RFC 6962-style transparency log with inclusion and consistency proofs |
|
|
78
|
+
| **Append-Only Lifecycle** | Operation Intent / Outcome facts with idempotency replay |
|
|
79
|
+
| **Verifiable Index Engine** | Canonical Prolly Tree with membership, non-membership proofs, and efficient diffs |
|
|
80
|
+
| **Workspace Projection** | Verifiable workspace-scoped order and membership indexes |
|
|
81
|
+
| **Merkle State** | Content-addressed state commits bound to operation outcomes |
|
|
82
|
+
| **Checkpoint Tree** | Verifiable recovery and progress structure |
|
|
83
|
+
| **Proof Envelopes** | Cross-proof receipts binding ledger, index, state, and checkpoint evidence |
|
|
84
|
+
| **Proof Bundles** | Portable CAR-like exports for offline verification |
|
|
85
|
+
| **Signed Heads** | Optional Ed25519 ledger head signing with verifier manifests |
|
|
86
|
+
| **LicoLite Aspect** | First-class integration surface with default workspace projection and signing |
|
|
87
|
+
| **Repair Planning** | Deterministic repair task generation from structured verification failures |
|
|
88
|
+
| **Zero Dependencies** | Pure ESM, no runtime dependencies, ships source directly |
|
|
89
|
+
|
|
90
|
+
## Installation
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
npm install pactium
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
pnpm add pactium
|
|
98
|
+
```
|
|
20
99
|
|
|
21
|
-
|
|
100
|
+
```bash
|
|
101
|
+
yarn add pactium
|
|
102
|
+
```
|
|
22
103
|
|
|
23
|
-
|
|
104
|
+
### Requirements
|
|
24
105
|
|
|
25
|
-
|
|
106
|
+
- Node.js 22+ or Node.js 24+
|
|
107
|
+
- ESM-only (`"type": "module"` in your `package.json`)
|
|
26
108
|
|
|
27
|
-
|
|
109
|
+
## Quick Start
|
|
28
110
|
|
|
29
|
-
|
|
111
|
+
### Record an operation with full proof
|
|
30
112
|
|
|
31
113
|
```js
|
|
32
114
|
import { createPactium } from "pactium";
|
|
33
115
|
|
|
34
116
|
const pactium = createPactium({ dataDir: "./.pactium" });
|
|
35
117
|
|
|
118
|
+
// Record an operation and receive a verifiable proof envelope
|
|
36
119
|
const envelope = await pactium.recordOperation({
|
|
37
120
|
operationId: "workspace.file.write",
|
|
38
121
|
workspaceId: "workspace-a",
|
|
39
|
-
idempotencyKey: "intent-
|
|
40
|
-
outcomeIdempotencyKey: "outcome-
|
|
41
|
-
input: { path: "docs/
|
|
122
|
+
idempotencyKey: "intent-001",
|
|
123
|
+
outcomeIdempotencyKey: "outcome-001",
|
|
124
|
+
input: { path: "docs/readme.md" },
|
|
42
125
|
stateMutations: [
|
|
43
|
-
{ key: "docs/
|
|
126
|
+
{ key: "docs/readme.md", value: { content: "hello world" } }
|
|
44
127
|
]
|
|
45
128
|
});
|
|
46
129
|
|
|
47
|
-
|
|
130
|
+
// Verify the envelope against local proof material
|
|
131
|
+
const result = await pactium.verifyEnvelope(envelope);
|
|
132
|
+
console.log(result.ok); // true
|
|
48
133
|
```
|
|
49
134
|
|
|
135
|
+
### Use the LicoLite Aspect
|
|
136
|
+
|
|
50
137
|
```js
|
|
51
138
|
import { createLicoLiteAspect, createLicoLiteSigner } from "pactium/licolite";
|
|
52
139
|
|
|
53
|
-
const signingSecret = process.env.LICOLITE_SIGNING_SECRET;
|
|
54
|
-
if (!signingSecret) throw new Error("LICOLITE_SIGNING_SECRET is required.");
|
|
55
|
-
|
|
56
140
|
const licolite = createLicoLiteAspect({
|
|
57
141
|
evidencePolicy: "production",
|
|
58
142
|
signer: createLicoLiteSigner({
|
|
59
|
-
signerId: "host-
|
|
60
|
-
secret:
|
|
143
|
+
signerId: "host-signer",
|
|
144
|
+
secret: process.env.LICOLITE_SIGNING_SECRET
|
|
61
145
|
})
|
|
62
146
|
});
|
|
63
147
|
|
|
64
148
|
const envelope = await licolite.recordWorkspaceOperation({
|
|
65
|
-
operationId: "workspace.
|
|
149
|
+
operationId: "workspace.asset.upload",
|
|
66
150
|
workspaceId: "workspace-a",
|
|
67
|
-
policyEvidence: { decision: "allow" },
|
|
68
|
-
workspaceEffectEvidence: { durableRef: "host:asset:
|
|
151
|
+
policyEvidence: { decision: "allow", rule: "upload-permitted" },
|
|
152
|
+
workspaceEffectEvidence: { durableRef: "host:asset:image-001" }
|
|
69
153
|
});
|
|
70
154
|
|
|
71
|
-
|
|
155
|
+
// LicoLite-level verification checks signing + critical extensions
|
|
156
|
+
const result = await licolite.verifyEnvelope(envelope);
|
|
157
|
+
console.log(result.ok); // true
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### Export and verify a portable proof bundle
|
|
161
|
+
|
|
162
|
+
```js
|
|
163
|
+
import { createPactium, verifyProofBundle } from "pactium";
|
|
164
|
+
|
|
165
|
+
const pactium = createPactium({ dataDir: "./.pactium" });
|
|
166
|
+
|
|
167
|
+
// Export envelope as a portable bundle
|
|
168
|
+
const bundle = await pactium.exportProofBundle(envelope);
|
|
169
|
+
|
|
170
|
+
// Verify without access to local storage
|
|
171
|
+
const result = await verifyProofBundle(bundle);
|
|
172
|
+
console.log(result.ok); // true
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
## API Overview
|
|
176
|
+
|
|
177
|
+
Pactium exposes two package entry points:
|
|
178
|
+
|
|
179
|
+
| Export | Entry | Description |
|
|
180
|
+
| --- | --- | --- |
|
|
181
|
+
| `pactium` | `./src/index.js` | Core proof-first protocol API |
|
|
182
|
+
| `pactium/licolite` | `./src/aspects/licolite/index.js` | LicoLite integration aspect |
|
|
183
|
+
|
|
184
|
+
### Core API (`pactium`)
|
|
185
|
+
|
|
186
|
+
```js
|
|
187
|
+
import {
|
|
188
|
+
// Instance
|
|
189
|
+
createPactium,
|
|
190
|
+
|
|
191
|
+
// Protocol constants
|
|
192
|
+
PACTIUM_PROTOCOL,
|
|
193
|
+
PACTIUM_SCHEMA_VERSION,
|
|
194
|
+
PACTIUM_PROTOCOL_PROFILE,
|
|
195
|
+
|
|
196
|
+
// Canonical encoding
|
|
197
|
+
canonicalEncode,
|
|
198
|
+
canonicalDecode,
|
|
199
|
+
normalizeCanonicalValue,
|
|
200
|
+
|
|
201
|
+
// Protocol hashing
|
|
202
|
+
protocolHash,
|
|
203
|
+
protocolHashHex,
|
|
204
|
+
cidForBytes,
|
|
205
|
+
cidForCanonical,
|
|
206
|
+
|
|
207
|
+
// Storage
|
|
208
|
+
createStoragePort,
|
|
209
|
+
resolveDataDir,
|
|
210
|
+
|
|
211
|
+
// Ledger
|
|
212
|
+
createLedgerTransparencyLog,
|
|
213
|
+
createLedgerInclusionProof,
|
|
214
|
+
verifyLedgerInclusionProof,
|
|
215
|
+
createLedgerConsistencyProof,
|
|
216
|
+
verifyLedgerConsistencyProof,
|
|
217
|
+
|
|
218
|
+
// Verifiable Index Engine
|
|
219
|
+
createVerifiableIndexEngine,
|
|
220
|
+
verifyIndexProof,
|
|
221
|
+
|
|
222
|
+
// Proof verification
|
|
223
|
+
verifyProofEnvelope,
|
|
224
|
+
verifyProofBundle,
|
|
225
|
+
createDefaultProofVerifierRegistry,
|
|
226
|
+
|
|
227
|
+
// Maintenance and repair
|
|
228
|
+
createRepairPlanner,
|
|
229
|
+
createMaintenanceTaskEngine
|
|
230
|
+
} from "pactium";
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
### LicoLite Aspect (`pactium/licolite`)
|
|
234
|
+
|
|
235
|
+
```js
|
|
236
|
+
import {
|
|
237
|
+
createLicoLiteAspect,
|
|
238
|
+
createLicoLiteSigner,
|
|
239
|
+
recordLicoLiteWorkspaceOperation,
|
|
240
|
+
verifyLicoLiteEnvelope,
|
|
241
|
+
verifyLicoLiteBundle,
|
|
242
|
+
LICOLITE_ASPECT_PROTOCOL,
|
|
243
|
+
LICOLITE_CRITICAL_EXTENSIONS
|
|
244
|
+
} from "pactium/licolite";
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
### TypeScript
|
|
248
|
+
|
|
249
|
+
Pactium ships hand-written TypeScript declarations. All public types are available from the package entry points:
|
|
250
|
+
|
|
251
|
+
```ts
|
|
252
|
+
import type {
|
|
253
|
+
PactiumCore,
|
|
254
|
+
PactiumProofEnvelope,
|
|
255
|
+
PactiumVerificationResult,
|
|
256
|
+
PactiumProofBundle,
|
|
257
|
+
PactiumLedgerHead,
|
|
258
|
+
PactiumVerificationFailure
|
|
259
|
+
} from "pactium";
|
|
260
|
+
|
|
261
|
+
import type {
|
|
262
|
+
LicoLiteAspect,
|
|
263
|
+
LicoLiteSigner
|
|
264
|
+
} from "pactium/licolite";
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
For the complete API reference, see [docs/API.md](./docs/API.md).
|
|
268
|
+
|
|
269
|
+
## CLI
|
|
270
|
+
|
|
271
|
+
Pactium ships a CLI for local operation recording and verification:
|
|
272
|
+
|
|
273
|
+
```bash
|
|
274
|
+
# Check data directory health
|
|
275
|
+
pactium doctor --data-dir ./.pactium
|
|
276
|
+
|
|
277
|
+
# Start the HTTP verification server
|
|
278
|
+
pactium serve --port 7288
|
|
279
|
+
|
|
280
|
+
# Record an operation
|
|
281
|
+
pactium operation record --body '{"operationId":"test","workspaceId":"ws"}'
|
|
282
|
+
|
|
283
|
+
# Verify a proof envelope
|
|
284
|
+
pactium envelope verify --body-file ./envelope.json
|
|
285
|
+
|
|
286
|
+
# Verify a proof bundle
|
|
287
|
+
pactium bundle verify --body-file ./bundle.json
|
|
288
|
+
|
|
289
|
+
# LicoLite workspace operations
|
|
290
|
+
pactium licolite record --body '{"operationId":"ws.op","workspaceId":"ws"}'
|
|
291
|
+
pactium licolite verify --body-file ./licolite-envelope.json
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
The CLI reads JSON from `--body`, `--body-file`, or stdin.
|
|
295
|
+
|
|
296
|
+
## Architecture
|
|
297
|
+
|
|
298
|
+
```
|
|
299
|
+
Host System (LicoLite)
|
|
300
|
+
|
|
|
301
|
+
pactium/licolite
|
|
302
|
+
|
|
|
303
|
+
+--------------+---------------+
|
|
304
|
+
| Pactium Core |
|
|
305
|
+
| |
|
|
306
|
+
| +------------------------+ |
|
|
307
|
+
| | Canonical Value + Hash | |
|
|
308
|
+
| +------------------------+ |
|
|
309
|
+
| | Storage Port (CAS) | |
|
|
310
|
+
| +------------------------+ |
|
|
311
|
+
| | Operation Ledger | | <- Global ordering authority
|
|
312
|
+
| | (Transparency Log) | |
|
|
313
|
+
| +------------------------+ |
|
|
314
|
+
| | Verifiable Index Engine| | <- Shared Prolly Tree
|
|
315
|
+
| +------------------------+ |
|
|
316
|
+
| | Workspace Projection | |
|
|
317
|
+
| | Merkle State | |
|
|
318
|
+
| | Checkpoint Tree | |
|
|
319
|
+
| | Lifecycle Indexes | |
|
|
320
|
+
| +------------------------+ |
|
|
321
|
+
| | Proof Envelopes | |
|
|
322
|
+
| | Proof Bundles | |
|
|
323
|
+
| +------------------------+ |
|
|
324
|
+
| | Repair Planner | |
|
|
325
|
+
| | Maintenance Engine | |
|
|
326
|
+
| +------------------------+ |
|
|
327
|
+
+------------------------------+
|
|
72
328
|
```
|
|
73
329
|
|
|
330
|
+
**Key design principles:**
|
|
331
|
+
|
|
332
|
+
- The Operation Ledger is the single global ordering authority
|
|
333
|
+
- All indexes share one Verifiable Index Engine (Canonical Prolly Tree)
|
|
334
|
+
- Write operations return verifiable proof envelopes, not storage records
|
|
335
|
+
- Proof Bundles enable verification without access to original storage
|
|
336
|
+
- Host systems own policy, side effects, and durable evidence storage
|
|
337
|
+
|
|
338
|
+
For detailed architecture documentation, see [docs/architecture/ARCHITECTURE.md](./docs/architecture/ARCHITECTURE.md).
|
|
339
|
+
|
|
340
|
+
## When to Use Pactium
|
|
341
|
+
|
|
342
|
+
**Use Pactium when you need:**
|
|
343
|
+
|
|
344
|
+
- Cryptographic proof that an operation was recorded and the ledger is consistent
|
|
345
|
+
- Portable proof bundles that can be verified without the original system
|
|
346
|
+
- Workspace-scoped operation isolation with verifiable membership
|
|
347
|
+
- Append-only operation history with deterministic recovery
|
|
348
|
+
- Idempotent operation recording with replay detection
|
|
349
|
+
- Verifiable state roots with efficient diffs
|
|
350
|
+
|
|
351
|
+
**Pactium is not for:**
|
|
352
|
+
|
|
353
|
+
- General-purpose database storage (use a database)
|
|
354
|
+
- Network consensus between distributed nodes (Pactium is a local protocol substrate)
|
|
355
|
+
- Authorization or access control (host systems own policy)
|
|
356
|
+
- File storage or blob management (Pactium stores operation metadata and proofs)
|
|
357
|
+
|
|
358
|
+
## Documentation
|
|
359
|
+
|
|
360
|
+
| Document | Description |
|
|
361
|
+
| --- | --- |
|
|
362
|
+
| [API Reference](./docs/API.md) | Complete public API documentation |
|
|
363
|
+
| [Architecture](./docs/architecture/ARCHITECTURE.md) | System architecture and module structure |
|
|
364
|
+
| [Protocol Specification](./docs/protocols/PROTOCOLS.md) | Protocol behavior and data flow |
|
|
365
|
+
| [Protocol Profile](./docs/protocols/PROFILE.md) | Protocol parameter matrix |
|
|
366
|
+
| [LicoLite Aspect](./docs/LICOLITE-ASPECT.md) | LicoLite integration surface |
|
|
367
|
+
| [Terms](./docs/TERM.md) | Protocol glossary and vocabulary |
|
|
368
|
+
| [FAQ](./docs/FAQ.md) | Frequently asked questions |
|
|
369
|
+
| [Migration Guide](./docs/MIGRATION.md) | Version compatibility and upgrade guidance |
|
|
370
|
+
| [Examples Guide](./examples/README.md) | Annotated usage examples |
|
|
371
|
+
| [Quality Gates](https://github.com/Unka-Malloc/Pactium/blob/stable/docs/QUALITY-GATES.md) | Release verification requirements |
|
|
372
|
+
| [ADRs](https://github.com/Unka-Malloc/Pactium/tree/stable/docs/adr) | Architecture Decision Records (55 decisions) |
|
|
373
|
+
|
|
374
|
+
## Requirements
|
|
375
|
+
|
|
376
|
+
| Requirement | Version |
|
|
377
|
+
| --- | --- |
|
|
378
|
+
| Node.js | `^22.0.0 \|\| ^24.0.0` |
|
|
379
|
+
| Module system | ESM only (`"type": "module"`) |
|
|
380
|
+
| Runtime dependencies | None |
|
|
381
|
+
|
|
382
|
+
Pactium is a pure ESM package. It cannot be `require()`'d from CommonJS modules. If you need CJS interop, use dynamic `import()`.
|
|
383
|
+
|
|
74
384
|
## Verification
|
|
75
385
|
|
|
386
|
+
Run the full release gate locally:
|
|
387
|
+
|
|
76
388
|
```bash
|
|
77
389
|
npm run verify:release
|
|
78
390
|
```
|
|
79
391
|
|
|
80
|
-
|
|
392
|
+
This runs coverage-enforced tests, protocol proof vectors, regression snapshots, seeded property tests, scaled public API pressure profiles, hygiene checks, package-content checks, package dry run, and publish dry run.
|
|
81
393
|
|
|
82
|
-
|
|
394
|
+
For full-count pressure profiles (explicit release review):
|
|
395
|
+
|
|
396
|
+
```bash
|
|
397
|
+
PACTIUM_FULL_PRESSURE=1 npm run verify:protocol:gates
|
|
398
|
+
```
|
|
399
|
+
|
|
400
|
+
## Ecosystem
|
|
401
|
+
|
|
402
|
+
| Package | Description |
|
|
403
|
+
| --- | --- |
|
|
404
|
+
| [`pactium`](https://www.npmjs.com/package/pactium) | Core protocol substrate (this package) |
|
|
405
|
+
| `pactium/licolite` | First-class LicoLite integration aspect (included) |
|
|
406
|
+
|
|
407
|
+
Pactium is the protocol substrate for [LicoLite](https://github.com/Unka-Malloc). The `pactium/licolite` aspect is a first-class package export, not an external plugin.
|
|
408
|
+
|
|
409
|
+
## Contributing
|
|
83
410
|
|
|
84
|
-
|
|
85
|
-
- [Protocol Overview](./docs/protocols/PROTOCOLS.md)
|
|
86
|
-
- [Protocol Profile](./docs/protocols/PROFILE.md)
|
|
87
|
-
- [Architecture](./docs/architecture/ARCHITECTURE.md)
|
|
88
|
-
- [LicoLite Aspect](./docs/LICOLITE-ASPECT.md)
|
|
411
|
+
See [CONTRIBUTING.md](https://github.com/Unka-Malloc/Pactium/blob/stable/CONTRIBUTING.md) for development setup, coding standards, and submission guidelines.
|
|
89
412
|
|
|
90
413
|
## License
|
|
91
414
|
|
|
92
|
-
|
|
415
|
+
[GPL-3.0-or-later](./LICENSE) -- Copyright (c) Unka Y.Y.
|