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/docs/FAQ.md
ADDED
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
# Frequently Asked Questions
|
|
2
|
+
|
|
3
|
+
## General
|
|
4
|
+
|
|
5
|
+
### What is Pactium?
|
|
6
|
+
|
|
7
|
+
Pactium is a proof-first protocol substrate for Node.js. It records operation facts into an append-only transparency log and produces cryptographic proofs that operations were recorded and the ledger history is consistent. It is designed as the protocol substrate for LicoLite.
|
|
8
|
+
|
|
9
|
+
### What does "proof-first" mean?
|
|
10
|
+
|
|
11
|
+
Every write operation returns a verifiable proof envelope rather than a simple acknowledgment. The proof is the API response -- it includes ledger inclusion proofs, index proofs, and content-addressed references that can be independently verified.
|
|
12
|
+
|
|
13
|
+
### Is Pactium a database?
|
|
14
|
+
|
|
15
|
+
No. Pactium is a protocol substrate that records operation metadata and produces cryptographic proofs. It maintains verifiable indexes and state roots, but it is not a general-purpose data store. Host systems own their application data, business logic, and side effects.
|
|
16
|
+
|
|
17
|
+
### Is Pactium a blockchain?
|
|
18
|
+
|
|
19
|
+
No. Pactium is a local protocol substrate, not a distributed consensus system. It uses a transparency log (similar to Certificate Transparency) for append-only operation recording and Merkle proofs for verification, but it does not run a network, perform consensus, or require gas/tokens.
|
|
20
|
+
|
|
21
|
+
### What is the relationship between Pactium and LicoLite?
|
|
22
|
+
|
|
23
|
+
Pactium exists to serve LicoLite as its protocol substrate. LicoLite is the primary host, and `pactium/licolite` is a first-class package aspect (not a plugin). LicoLite requirements may shape Pactium core capabilities.
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## Installation and Setup
|
|
28
|
+
|
|
29
|
+
### Why does Pactium require Node.js 22+?
|
|
30
|
+
|
|
31
|
+
Pactium uses modern Node.js APIs (built-in test runner, structured clone, modern crypto) that are stable in Node.js 22 LTS. It also supports Node.js 24 for forward compatibility.
|
|
32
|
+
|
|
33
|
+
### I get `ERR_REQUIRE_ESM` -- what do I do?
|
|
34
|
+
|
|
35
|
+
Pactium is a pure ESM package. It cannot be loaded with `require()`. Options:
|
|
36
|
+
|
|
37
|
+
1. Add `"type": "module"` to your `package.json`
|
|
38
|
+
2. Rename your file to `.mjs`
|
|
39
|
+
3. Use dynamic import: `const { createPactium } = await import("pactium")`
|
|
40
|
+
|
|
41
|
+
### Does Pactium have any runtime dependencies?
|
|
42
|
+
|
|
43
|
+
No. Pactium has zero runtime dependencies. It uses only Node.js built-in modules (`node:crypto`, `node:fs`, `node:path`, etc.).
|
|
44
|
+
|
|
45
|
+
### Where does Pactium store data?
|
|
46
|
+
|
|
47
|
+
By default, Pactium stores data in the directory you specify via `dataDir` option (e.g., `./.pactium`). You can also use `inMemory: true` for testing. The storage format is content-addressed JSON files managed through the Storage Port abstraction.
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## Usage
|
|
52
|
+
|
|
53
|
+
### How do I record an operation?
|
|
54
|
+
|
|
55
|
+
```js
|
|
56
|
+
import { createPactium } from "pactium";
|
|
57
|
+
|
|
58
|
+
const pactium = createPactium({ dataDir: "./.pactium" });
|
|
59
|
+
|
|
60
|
+
const envelope = await pactium.recordOperation({
|
|
61
|
+
operationId: "my.operation",
|
|
62
|
+
workspaceId: "my-workspace",
|
|
63
|
+
idempotencyKey: "unique-intent-key",
|
|
64
|
+
outcomeIdempotencyKey: "unique-outcome-key",
|
|
65
|
+
input: { /* your operation input */ },
|
|
66
|
+
stateMutations: [
|
|
67
|
+
{ key: "state-key", value: { /* your state */ } }
|
|
68
|
+
]
|
|
69
|
+
});
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### What happens if I record the same operation twice?
|
|
73
|
+
|
|
74
|
+
If you use the same `idempotencyKey`, Pactium returns an Idempotency Replay -- the existing proof envelope is returned without appending a new ledger fact. The replay is marked so callers can distinguish it from a new commit.
|
|
75
|
+
|
|
76
|
+
### How do I verify a proof?
|
|
77
|
+
|
|
78
|
+
```js
|
|
79
|
+
// Local verification (requires Pactium instance)
|
|
80
|
+
const result = await pactium.verifyEnvelope(envelope);
|
|
81
|
+
|
|
82
|
+
// Portable verification (no local storage needed)
|
|
83
|
+
import { verifyProofBundle } from "pactium";
|
|
84
|
+
const bundle = await pactium.exportProofBundle(envelope);
|
|
85
|
+
const result = await verifyProofBundle(bundle);
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### What is a Proof Bundle and when should I use it?
|
|
89
|
+
|
|
90
|
+
A Proof Bundle is a portable, self-contained export that includes all content-addressed blocks needed for verification. Use it when:
|
|
91
|
+
|
|
92
|
+
- You need to verify a proof without access to the original Pactium storage
|
|
93
|
+
- You want to share verification material with external parties
|
|
94
|
+
- You want to archive proof material independently from the data directory
|
|
95
|
+
- You need to preserve verification capability across Pactium version upgrades
|
|
96
|
+
|
|
97
|
+
### What is the difference between Intent and Outcome?
|
|
98
|
+
|
|
99
|
+
- **Operation Intent** declares what the host intends to do (recorded before the operation)
|
|
100
|
+
- **Operation Outcome** declares the result (recorded after the operation completes or fails)
|
|
101
|
+
|
|
102
|
+
Both are append-only facts. The Intent is never mutated into the Outcome. Failed and successful outcomes are both recorded as facts.
|
|
103
|
+
|
|
104
|
+
### Can I use Pactium without LicoLite?
|
|
105
|
+
|
|
106
|
+
Yes. The core `pactium` export is independent. `pactium/licolite` is a first-class aspect for LicoLite hosts, but you can use the core API directly for any host system that needs verifiable operation recording.
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
## Architecture
|
|
111
|
+
|
|
112
|
+
### Why is there only one Verifiable Index Engine?
|
|
113
|
+
|
|
114
|
+
Pactium uses a shared Canonical Prolly Tree-based engine for all indexes (state, workspace, lifecycle, idempotency, causality). Domain adapters convert domain-specific material into canonical keys and values. This eliminates the complexity of maintaining multiple independent tree implementations while keeping proofs consistent.
|
|
115
|
+
|
|
116
|
+
### Why are hash algorithms and chunking not configurable?
|
|
117
|
+
|
|
118
|
+
These are protocol constants, not tuning options. If a verifier expects `sha256` and the writer used `sha3`, proofs would be incompatible. Protocol parameters are fixed per protocol version to ensure all parties can verify proofs without negotiation.
|
|
119
|
+
|
|
120
|
+
### What does the host system own vs. what does Pactium own?
|
|
121
|
+
|
|
122
|
+
**Pactium owns:** Protocol facts, canonical encoding, hash computation, ledger ordering, index proofs, verification, proof generation, repair planning.
|
|
123
|
+
|
|
124
|
+
**Host owns:** Policy decisions (allow/deny), operation dispatching, side-effect execution, authorization, durable evidence storage, UI, key management and rotation.
|
|
125
|
+
|
|
126
|
+
### How does workspace isolation work?
|
|
127
|
+
|
|
128
|
+
Each operation is associated with a `workspaceId`. Pactium maintains per-workspace projection indexes (order and membership) that are verifiable. You can prove that a ledger event belongs to a specific workspace, or prove that it does not belong, using Merkle proofs from the shared index engine.
|
|
129
|
+
|
|
130
|
+
---
|
|
131
|
+
|
|
132
|
+
## Verification
|
|
133
|
+
|
|
134
|
+
### What does verification actually check?
|
|
135
|
+
|
|
136
|
+
Envelope verification checks:
|
|
137
|
+
|
|
138
|
+
1. Ledger inclusion proof validity (leaf is in the ledger at the stated tree size)
|
|
139
|
+
2. Content-addressed proof material integrity (referenced blocks match their CIDs)
|
|
140
|
+
3. Index proof validity (state/workspace proofs are mathematically correct)
|
|
141
|
+
4. Critical extension support (all required extensions are understood)
|
|
142
|
+
5. Signature validity (if signed heads are used)
|
|
143
|
+
|
|
144
|
+
### What is a "critical extension"?
|
|
145
|
+
|
|
146
|
+
A critical extension is a Proof Extension that must be understood by the verifier. If a verifier encounters an unknown critical extension, verification fails. This prevents silently ignoring important evidence bindings.
|
|
147
|
+
|
|
148
|
+
LicoLite uses two critical extensions: Policy Extension and Workspace Effect Extension.
|
|
149
|
+
|
|
150
|
+
### What happens when verification fails?
|
|
151
|
+
|
|
152
|
+
Pactium returns structured Verification Failures (not thrown exceptions). Each failure includes:
|
|
153
|
+
|
|
154
|
+
- `layer` -- which verification layer failed (ledger, index, envelope, extension)
|
|
155
|
+
- `code` -- machine-readable failure code
|
|
156
|
+
- `severity` -- critical, warning, or info
|
|
157
|
+
- `repairable` -- whether the Repair Planner can address it
|
|
158
|
+
|
|
159
|
+
You can feed failures to the Repair Planner to generate deterministic repair tasks.
|
|
160
|
+
|
|
161
|
+
---
|
|
162
|
+
|
|
163
|
+
## Troubleshooting
|
|
164
|
+
|
|
165
|
+
### "Storage not initialized" error
|
|
166
|
+
|
|
167
|
+
Call `createPactium()` or `createStoragePort()` with a valid `dataDir`. The data directory is created automatically on first use.
|
|
168
|
+
|
|
169
|
+
### Verification returns unexpected failures
|
|
170
|
+
|
|
171
|
+
- Ensure you're verifying against the same Pactium instance (or use Proof Bundles for portable verification)
|
|
172
|
+
- Check that proof material refs are resolvable (content-addressed blocks exist in storage)
|
|
173
|
+
- For LicoLite envelopes, ensure the verifier supports the required critical extensions
|
|
174
|
+
|
|
175
|
+
### Proof Bundle verification fails but envelope verification passes
|
|
176
|
+
|
|
177
|
+
This usually means the bundle export is incomplete. Ensure `exportProofBundle()` was called with a valid envelope and that the bundle contains all required content-addressed blocks.
|
|
178
|
+
|
|
179
|
+
### "Consistency proof failed" between two ledger heads
|
|
180
|
+
|
|
181
|
+
This means the ledger history diverged -- a later ledger state is not a valid continuation of the earlier one. This is a security-critical finding that indicates the ledger was rewritten or forked.
|
|
182
|
+
|
|
183
|
+
### Performance concerns with large indexes
|
|
184
|
+
|
|
185
|
+
The Prolly Tree engine uses structural sharing and Content-Defined Chunking for efficient updates. For large state sets, consider:
|
|
186
|
+
|
|
187
|
+
- Using the `scan()` and `prefix()` methods for range queries instead of full snapshots
|
|
188
|
+
- Using `diff()` to compute changes between state roots efficiently
|
|
189
|
+
- Checking memory usage with the pressure profile: `PACTIUM_FULL_PRESSURE=1 npm run verify:protocol:gates`
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# Migration Guide
|
|
2
|
+
|
|
3
|
+
This guide covers version compatibility, protocol stability, and upgrade guidance for Pactium.
|
|
4
|
+
|
|
5
|
+
## Version Policy
|
|
6
|
+
|
|
7
|
+
Pactium follows [Semantic Versioning](https://semver.org/):
|
|
8
|
+
|
|
9
|
+
- **Major** (1.0, 2.0) -- breaking changes to public API or protocol format
|
|
10
|
+
- **Minor** (0.2, 0.3) -- new features, backward-compatible API additions
|
|
11
|
+
- **Patch** (0.2.1) -- bug fixes with no API or protocol changes
|
|
12
|
+
|
|
13
|
+
During the `0.x` series, minor versions may include breaking changes. The protocol profile is locked per minor version.
|
|
14
|
+
|
|
15
|
+
## Protocol Stability
|
|
16
|
+
|
|
17
|
+
| Component | Stability | Change policy |
|
|
18
|
+
| --- | --- | --- |
|
|
19
|
+
| Protocol Hash (`sha256`) | Locked per protocol version | Requires new `PACTIUM_PROTOCOL` value |
|
|
20
|
+
| Canonical Value encoding | Locked per protocol version | Requires new protocol version |
|
|
21
|
+
| Proof vector outputs | Locked per protocol version | Changing expected vectors requires explicit protocol revision |
|
|
22
|
+
| Ledger leaf/node hash format | Locked per protocol version | Part of protocol constants |
|
|
23
|
+
| Content-Defined Chunking params | Locked per protocol version | Protocol constants, not configuration |
|
|
24
|
+
| Public API shape | Stable within minor | Additions in minor, removals in next minor/major |
|
|
25
|
+
| TypeScript declarations | Stable within minor | New types in minor, type changes in next minor/major |
|
|
26
|
+
|
|
27
|
+
## Data Directory Compatibility
|
|
28
|
+
|
|
29
|
+
### Current: v0.2.x
|
|
30
|
+
|
|
31
|
+
Pactium v0.2.x creates and manages its own data directory format. Key constraints:
|
|
32
|
+
|
|
33
|
+
- **New directories only** -- Pactium does not read or migrate data from earlier experimental formats
|
|
34
|
+
- **Latest schema only** -- there is no support for loading older schema versions
|
|
35
|
+
- **Forward-compatible within patch** -- patch releases do not change data format
|
|
36
|
+
|
|
37
|
+
### Upgrading between minor versions
|
|
38
|
+
|
|
39
|
+
When upgrading from one minor version to the next (e.g., future 0.2.x to 0.3.x):
|
|
40
|
+
|
|
41
|
+
1. Check the [CHANGELOG](../CHANGELOG.md) for breaking changes
|
|
42
|
+
2. Create a fresh data directory for the new version if the protocol version changes
|
|
43
|
+
3. Use Proof Bundles to preserve portable verification material from the old version
|
|
44
|
+
|
|
45
|
+
Pactium intentionally does not include automatic migration. Data directories are protocol-versioned, and mixing protocol versions in one directory is not supported.
|
|
46
|
+
|
|
47
|
+
## Node.js Compatibility
|
|
48
|
+
|
|
49
|
+
| Pactium version | Node.js requirement |
|
|
50
|
+
| --- | --- |
|
|
51
|
+
| 0.2.x | `^22.0.0 \|\| ^24.0.0` |
|
|
52
|
+
|
|
53
|
+
Pactium is pure ESM. It cannot be loaded via `require()`. If your project uses CommonJS, use dynamic `import()`:
|
|
54
|
+
|
|
55
|
+
```js
|
|
56
|
+
// CommonJS interop
|
|
57
|
+
const { createPactium } = await import("pactium");
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## ESM-Only Package
|
|
61
|
+
|
|
62
|
+
Pactium ships as a pure ES module. There is no CommonJS build and no dual-package export.
|
|
63
|
+
|
|
64
|
+
**If you see `ERR_REQUIRE_ESM`:**
|
|
65
|
+
|
|
66
|
+
- Ensure your `package.json` has `"type": "module"`
|
|
67
|
+
- Or rename your files to `.mjs`
|
|
68
|
+
- Or use dynamic `import()` from CommonJS
|
|
69
|
+
|
|
70
|
+
**If you see `ERR_MODULE_NOT_FOUND`:**
|
|
71
|
+
|
|
72
|
+
- Ensure you're importing from the correct path (`pactium` or `pactium/licolite`)
|
|
73
|
+
- Deep imports into `src/` are not part of the public API and may change without notice
|
|
74
|
+
|
|
75
|
+
## API Stability Tiers
|
|
76
|
+
|
|
77
|
+
| Tier | Surface | Guarantee |
|
|
78
|
+
| --- | --- | --- |
|
|
79
|
+
| **Public** | Exports from `pactium` and `pactium/licolite` | Semver-governed; no removals in patch |
|
|
80
|
+
| **Protocol Constants** | `PACTIUM_PROTOCOL`, `PACTIUM_PROTOCOL_PROFILE`, `HASH_DOMAINS` | Locked per protocol version |
|
|
81
|
+
| **Type Declarations** | `.d.ts` exports | Stable within minor version |
|
|
82
|
+
| **CLI** | `pactium` commands | Stable within minor; new subcommands in minor |
|
|
83
|
+
| **Internal** | Files under `src/` not exported from entry points | No stability guarantee |
|
|
84
|
+
|
|
85
|
+
## Proof Portability
|
|
86
|
+
|
|
87
|
+
Proof Bundles exported from any Pactium version remain independently verifiable as long as:
|
|
88
|
+
|
|
89
|
+
1. The protocol version is known to the verifier
|
|
90
|
+
2. The bundle contains all required content-addressed blocks
|
|
91
|
+
3. Critical extensions in the bundle are supported by the verifier
|
|
92
|
+
|
|
93
|
+
Proof Bundles are the recommended way to preserve verification material across Pactium version upgrades.
|
|
94
|
+
|
|
95
|
+
## Breaking Change Announcements
|
|
96
|
+
|
|
97
|
+
Breaking changes will be:
|
|
98
|
+
|
|
99
|
+
1. Documented in the [CHANGELOG](../CHANGELOG.md) under a `### Breaking Changes` section
|
|
100
|
+
2. Announced at least one minor version in advance when possible (deprecation notices)
|
|
101
|
+
3. Accompanied by migration instructions in this document
|
|
102
|
+
|
|
103
|
+
## From Pre-Release to Stable (Future)
|
|
104
|
+
|
|
105
|
+
When Pactium reaches 1.0:
|
|
106
|
+
|
|
107
|
+
- The protocol format will be considered stable
|
|
108
|
+
- Data directory format will receive backward-compatible migration support
|
|
109
|
+
- The public API will follow strict semver without the `0.x` flexibility
|
|
110
|
+
- This section will be updated with specific 0.x-to-1.0 migration steps
|
package/docs/README.md
CHANGED
|
@@ -1,13 +1,51 @@
|
|
|
1
|
-
# Pactium
|
|
1
|
+
# Pactium Documentation
|
|
2
2
|
|
|
3
|
-
Pactium
|
|
3
|
+
Welcome to the Pactium documentation. This index covers all maintained documentation for the proof-first protocol substrate.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Getting Started
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
| Resource | Description |
|
|
8
|
+
| --- | --- |
|
|
9
|
+
| [README](../README.md) | Project overview, installation, and quick start |
|
|
10
|
+
| [API Reference](./API.md) | Complete public API documentation |
|
|
11
|
+
| [Examples Guide](../examples/README.md) | Annotated usage examples with learning path |
|
|
12
|
+
| [FAQ](./FAQ.md) | Frequently asked questions and troubleshooting |
|
|
12
13
|
|
|
13
|
-
|
|
14
|
+
## Core References
|
|
15
|
+
|
|
16
|
+
| Document | Description |
|
|
17
|
+
| --- | --- |
|
|
18
|
+
| [Architecture](./architecture/ARCHITECTURE.md) | System architecture, module structure, and data flow |
|
|
19
|
+
| [Protocol Specification](./protocols/PROTOCOLS.md) | Protocol behavior, data structures, and verification rules |
|
|
20
|
+
| [Protocol Profile](./protocols/PROFILE.md) | Versioned protocol parameter matrix (algorithms, constants, formats) |
|
|
21
|
+
| [LicoLite Aspect](./LICOLITE-ASPECT.md) | First-class LicoLite integration surface and requirements |
|
|
22
|
+
| [Terms](./TERM.md) | Protocol glossary with preferred and avoided vocabulary |
|
|
23
|
+
|
|
24
|
+
## Maintenance and Operations
|
|
25
|
+
|
|
26
|
+
| Document | Description |
|
|
27
|
+
| --- | --- |
|
|
28
|
+
| [Migration Guide](./MIGRATION.md) | Version compatibility, upgrade guidance, and breaking changes |
|
|
29
|
+
| [Quality Gates](https://github.com/Unka-Malloc/Pactium/blob/stable/docs/QUALITY-GATES.md) | Release verification requirements and automated gate coverage |
|
|
30
|
+
| [Release Rules](https://github.com/Unka-Malloc/Pactium/blob/stable/docs/RELEASE.md) | Release process and publication criteria |
|
|
31
|
+
|
|
32
|
+
## Decisions
|
|
33
|
+
|
|
34
|
+
| Document | Description |
|
|
35
|
+
| --- | --- |
|
|
36
|
+
| [ADR Index](https://github.com/Unka-Malloc/Pactium/tree/stable/docs/adr) | 55 Architecture Decision Records covering protocol design choices |
|
|
37
|
+
|
|
38
|
+
## Documentation Principles
|
|
39
|
+
|
|
40
|
+
- **Current behavior only** -- maintained docs describe what is implemented today, not planned features
|
|
41
|
+
- **Design claims require evidence** -- every design claim has a corresponding ADR and working implementation
|
|
42
|
+
- **Protocol vocabulary** -- all docs use the vocabulary defined in [Terms](./TERM.md)
|
|
43
|
+
- **Closure enforced** -- the release gate rejects documentation that describes unimplemented surfaces
|
|
44
|
+
|
|
45
|
+
## What Is Not Published
|
|
46
|
+
|
|
47
|
+
The npm package includes a curated subset of documentation:
|
|
48
|
+
|
|
49
|
+
**Published in npm tarball:** `README.md`, `README.zh-CN.md`, `CHANGELOG.md`, `SECURITY.md`, `docs/README.md`, `docs/API.md`, `docs/FAQ.md`, `docs/MIGRATION.md`, `docs/logo.svg`, `docs/architecture/`, `docs/protocols/`, `docs/LICOLITE-ASPECT.md`, `docs/TERM.md`, `examples/`
|
|
50
|
+
|
|
51
|
+
**Not published:** ADRs, optimization analysis, quality gates, release rules, agent instructions, release tooling, tests, build outputs, and binary/cache artifacts (these are available on GitHub only when appropriate)
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Pactium is a proof-first protocol substrate for LicoLite. LicoLite is the primary host, and `pactium/licolite` is a first-class package aspect rather than an external plugin.
|
|
4
4
|
|
|
5
|
+
## System Overview
|
|
6
|
+
|
|
5
7
|
```text
|
|
6
8
|
LicoLite host
|
|
7
9
|
-> pactium/licolite
|
|
@@ -18,18 +20,206 @@ LicoLite host
|
|
|
18
20
|
-> Maintenance Task Engine and Repair Planner
|
|
19
21
|
```
|
|
20
22
|
|
|
21
|
-
##
|
|
23
|
+
## Module Dependency Graph
|
|
24
|
+
|
|
25
|
+
```text
|
|
26
|
+
┌─────────────────────┐
|
|
27
|
+
│ pactium/licolite │ LicoLite Aspect
|
|
28
|
+
│ (aspect.js, etc.) │
|
|
29
|
+
└──────────┬───────────┘
|
|
30
|
+
│
|
|
31
|
+
┌──────────▼───────────┐
|
|
32
|
+
│ pactium (core) │ Public API facade
|
|
33
|
+
│ src/index.js │
|
|
34
|
+
└──────────┬───────────┘
|
|
35
|
+
│
|
|
36
|
+
┌────────────────┼────────────────┐
|
|
37
|
+
│ │ │
|
|
38
|
+
┌─────────▼──────┐ ┌─────▼──────┐ ┌─────▼──────────┐
|
|
39
|
+
│ Pactium Core │ │ Proof │ │ Maintenance │
|
|
40
|
+
│ pactium-core │ │ envelope │ │ task-engine │
|
|
41
|
+
│ │ │ bundle │ │ repair plan │
|
|
42
|
+
└───────┬────────┘ └─────┬──────┘ └────────────────┘
|
|
43
|
+
│ │
|
|
44
|
+
┌───────┼─────────────────┼──────────────────┐
|
|
45
|
+
│ │ │ │
|
|
46
|
+
│ ┌────▼────┐ ┌────────▼───────┐ ┌──────▼──────┐
|
|
47
|
+
│ │ Ledger │ │ Index Engine │ │ Verification│
|
|
48
|
+
│ │ transp. │ │ snapshot- │ │ failure.js │
|
|
49
|
+
│ │ log │ │ merkle-index │ └─────────────┘
|
|
50
|
+
│ └────┬────┘ └────────┬───────┘
|
|
51
|
+
│ │ │
|
|
52
|
+
│ ┌────▼────────────────▼───────┐
|
|
53
|
+
│ │ Protocol Layer │
|
|
54
|
+
│ │ canonical/value.js │
|
|
55
|
+
│ │ protocol/constants.js │
|
|
56
|
+
│ │ protocol/hashing.js │
|
|
57
|
+
│ └─────────────┬───────────────┘
|
|
58
|
+
│ │
|
|
59
|
+
│ ┌─────────────▼───────────────┐
|
|
60
|
+
│ │ Storage Port │
|
|
61
|
+
│ │ local-json-storage-port.js │
|
|
62
|
+
│ └─────────────────────────────┘
|
|
63
|
+
└────────────────────────────────────────────┘
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Authority Model
|
|
22
67
|
|
|
23
68
|
The Operation Ledger is the global ordering authority. Workspace Projection, Merkle State, Checkpoint Tree, lifecycle, idempotency, and causality indexes are verifiable structures, but they do not replace Ledger Authority.
|
|
24
69
|
|
|
25
70
|
The shared Verifiable Index Engine is the canonical ordered-key proof engine. State, checkpoint, workspace projection, lifecycle, idempotency, and causality indexes use domain adapters over that shared engine rather than separate tree implementations.
|
|
26
71
|
|
|
72
|
+
## Data Flow: Recording an Operation
|
|
73
|
+
|
|
74
|
+
```text
|
|
75
|
+
Host calls recordOperation(input)
|
|
76
|
+
│
|
|
77
|
+
▼
|
|
78
|
+
┌─────────────────────────────┐
|
|
79
|
+
│ 1. Idempotency Check │ Check Intent/Outcome Idempotency Indexes
|
|
80
|
+
│ (replay if existing) │ Return existing proof if found
|
|
81
|
+
└──────────────┬──────────────┘
|
|
82
|
+
│ (new operation)
|
|
83
|
+
▼
|
|
84
|
+
┌─────────────────────────────┐
|
|
85
|
+
│ 2. Canonical Encode │ Normalize input to PactiumCanonicalValue
|
|
86
|
+
│ + Protocol Hash │ Compute content-addressed identifiers
|
|
87
|
+
└──────────────┬──────────────┘
|
|
88
|
+
│
|
|
89
|
+
▼
|
|
90
|
+
┌─────────────────────────────┐
|
|
91
|
+
│ 3. Ledger Append │ Append Intent + Outcome as leaf entries
|
|
92
|
+
│ (Transparency Log) │ Compute new Ledger Head
|
|
93
|
+
└──────────────┬──────────────┘
|
|
94
|
+
│
|
|
95
|
+
▼
|
|
96
|
+
┌─────────────────────────────┐
|
|
97
|
+
│ 4. Index Updates │ Update lifecycle, idempotency, workspace,
|
|
98
|
+
│ (Verifiable Index Engine)│ state, checkpoint, and causality indexes
|
|
99
|
+
└──────────────┬──────────────┘
|
|
100
|
+
│
|
|
101
|
+
▼
|
|
102
|
+
┌─────────────────────────────┐
|
|
103
|
+
│ 5. Proof Assembly │ Gather inclusion proof, index proofs,
|
|
104
|
+
│ (Proof Envelope) │ state root, extensions → Proof Envelope
|
|
105
|
+
└──────────────┬──────────────┘
|
|
106
|
+
│
|
|
107
|
+
▼
|
|
108
|
+
┌─────────────────────────────┐
|
|
109
|
+
│ 6. Return Proof Envelope │ Content-addressed Proof Material Refs
|
|
110
|
+
│ to caller │ included for later verification
|
|
111
|
+
└─────────────────────────────┘
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## Data Flow: Verifying a Proof Envelope
|
|
115
|
+
|
|
116
|
+
```text
|
|
117
|
+
Caller provides Proof Envelope
|
|
118
|
+
│
|
|
119
|
+
▼
|
|
120
|
+
┌─────────────────────────────┐
|
|
121
|
+
│ 1. Resolve Proof Material │ Load content-addressed blocks via refs
|
|
122
|
+
└──────────────┬──────────────┘
|
|
123
|
+
│
|
|
124
|
+
▼
|
|
125
|
+
┌─────────────────────────────┐
|
|
126
|
+
│ 2. Ledger Inclusion Check │ Verify leaf hash against Ledger Head
|
|
127
|
+
│ │ using RFC 6962 inclusion proof
|
|
128
|
+
└──────────────┬──────────────┘
|
|
129
|
+
│
|
|
130
|
+
▼
|
|
131
|
+
┌─────────────────────────────┐
|
|
132
|
+
│ 3. Index Proof Check │ Verify membership/non-membership proofs
|
|
133
|
+
│ │ against index roots
|
|
134
|
+
└──────────────┬──────────────┘
|
|
135
|
+
│
|
|
136
|
+
▼
|
|
137
|
+
┌─────────────────────────────┐
|
|
138
|
+
│ 4. Extension Check │ Verify critical extensions are supported
|
|
139
|
+
│ │ Verify extension hash bindings
|
|
140
|
+
└──────────────┬──────────────┘
|
|
141
|
+
│
|
|
142
|
+
▼
|
|
143
|
+
┌─────────────────────────────┐
|
|
144
|
+
│ 5. Result │ { ok, failures[], checked[] }
|
|
145
|
+
│ │ Failures are structured, not thrown
|
|
146
|
+
└─────────────────────────────┘
|
|
147
|
+
```
|
|
148
|
+
|
|
27
149
|
## LicoLite Boundary
|
|
28
150
|
|
|
29
151
|
Pactium owns protocol facts, proof algorithms, canonical encoding, storage ports, verification, repair planning, and LicoLite protocol-substrate adapters.
|
|
30
152
|
|
|
31
153
|
LicoLite owns runtime policy decisions, operation dispatching, side effects, UI ownership, authorization, and durable Host Evidence storage. Pactium binds LicoLite policy and workspace-effect evidence as critical proof extensions and verifies those bindings.
|
|
32
154
|
|
|
155
|
+
```text
|
|
156
|
+
┌──────────────────────────────────────────────────────┐
|
|
157
|
+
│ LicoLite Host │
|
|
158
|
+
│ │
|
|
159
|
+
│ Policy Operations Side Effects Evidence │
|
|
160
|
+
│ Decisions Dispatching Execution Storage │
|
|
161
|
+
│ │
|
|
162
|
+
└────────────────────────┬─────────────────────────────┘
|
|
163
|
+
│
|
|
164
|
+
─ ─ ─ ─ ─ ─ ─│─ ─ ─ ─ ─ ─ ─ Host Boundary
|
|
165
|
+
│
|
|
166
|
+
┌────────────────────────▼─────────────────────────────┐
|
|
167
|
+
│ pactium/licolite │
|
|
168
|
+
│ │
|
|
169
|
+
│ Signing Critical Extensions Workspace Proj. │
|
|
170
|
+
│ Authority (policy + effects) (default: on) │
|
|
171
|
+
│ │
|
|
172
|
+
└────────────────────────┬─────────────────────────────┘
|
|
173
|
+
│
|
|
174
|
+
┌────────────────────────▼─────────────────────────────┐
|
|
175
|
+
│ Pactium Core │
|
|
176
|
+
│ │
|
|
177
|
+
│ Ledger Index Engine Proofs Repair Storage │
|
|
178
|
+
│ │
|
|
179
|
+
└──────────────────────────────────────────────────────┘
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
## Storage Architecture
|
|
183
|
+
|
|
184
|
+
```text
|
|
185
|
+
Data Directory (.pactium/)
|
|
186
|
+
├── blocks/ Content-addressed block store (CID → canonical bytes)
|
|
187
|
+
├── protocol/ Protocol objects (scoped key-value)
|
|
188
|
+
│ ├── ledger/ Ledger entries, heads
|
|
189
|
+
│ ├── indexes/ Index roots and node references
|
|
190
|
+
│ ├── checkpoints/ Checkpoint tree state
|
|
191
|
+
│ └── projections/ Workspace projection state
|
|
192
|
+
└── metadata/ Directory metadata and protocol version
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
The Storage Port abstraction separates Pactium's protocol logic from persistence mechanics. The current implementation uses a local JSON backend. Storage backends may change how bytes are stored but cannot change canonical encoding, hash computation, or proof semantics.
|
|
196
|
+
|
|
197
|
+
## Shared Engine: Index Domain Adapters
|
|
198
|
+
|
|
199
|
+
All verifiable indexes share one Canonical Prolly Tree engine:
|
|
200
|
+
|
|
201
|
+
```text
|
|
202
|
+
┌─────────────────────────────────────────────────────────┐
|
|
203
|
+
│ Verifiable Index Engine │
|
|
204
|
+
│ (Canonical Prolly Tree + CAS nodes) │
|
|
205
|
+
└─────────────────────────┬───────────────────────────────┘
|
|
206
|
+
│
|
|
207
|
+
┌────────────┬───────┼───────┬────────────┬──────────┐
|
|
208
|
+
│ │ │ │ │ │
|
|
209
|
+
┌────▼───┐ ┌────▼──┐ ┌─▼──┐ ┌─▼──────┐ ┌─▼────┐ ┌─▼───────┐
|
|
210
|
+
│ State │ │Worksp.│ │Life│ │Idempot.│ │Check │ │Causality│
|
|
211
|
+
│ Index │ │Proj. │ │cycle│ │Index │ │point │ │Index │
|
|
212
|
+
│Adapter │ │Adapter│ │Adp.│ │Adapter │ │Adptr │ │Adapter │
|
|
213
|
+
└────────┘ └───────┘ └────┘ └────────┘ └──────┘ └─────────┘
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
Each domain adapter normalizes its domain-specific keys and values into canonical `Index Key` and `Index Value Ref` forms before they enter the shared engine. This means:
|
|
217
|
+
|
|
218
|
+
- One set of membership/non-membership proof algorithms
|
|
219
|
+
- One set of structural-sharing and diff algorithms
|
|
220
|
+
- One CDC (Content-Defined Chunking) implementation
|
|
221
|
+
- Consistent proof format across all domain indexes
|
|
222
|
+
|
|
33
223
|
## Current Implementation Status
|
|
34
224
|
|
|
35
225
|
The current `src/` implementation is the proof-first package surface. The package root exports proof-first APIs, and `pactium/licolite` exports the first-class LicoLite Aspect.
|
|
@@ -57,6 +247,8 @@ The maintained design is implemented by these package surfaces:
|
|
|
57
247
|
| LicoLite Aspect | `src/aspects/licolite/`: `createLicoLiteAspect`, `createLicoLiteSigner`, evidence helpers, verifier |
|
|
58
248
|
| CLI and HTTP facades | `bin/pactium.mjs`, `src/http.js` |
|
|
59
249
|
|
|
250
|
+
## Non-Surfaces
|
|
251
|
+
|
|
60
252
|
Maintained docs must not describe SQLite storage, separate per-workspace lane queues, repair fact execution, or pressure baseline regression enforcement as implemented unless those surfaces are added and verified.
|
|
61
253
|
|
|
62
254
|
If a maintained document introduces a design area that cannot be mapped to an implementation anchor, the design must be implemented and documented before release.
|
package/docs/logo.svg
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="-150 -150 300 300" role="img" aria-label="Pactium Logo">
|
|
2
|
+
<title>Pactium</title>
|
|
3
|
+
<defs>
|
|
4
|
+
<linearGradient id="gold" x1="0" y1="0" x2="1" y2="1">
|
|
5
|
+
<stop offset="0%" stop-color="#c9a96e"/>
|
|
6
|
+
<stop offset="50%" stop-color="#f0d28c"/>
|
|
7
|
+
<stop offset="100%" stop-color="#a8893a"/>
|
|
8
|
+
</linearGradient>
|
|
9
|
+
<linearGradient id="silver" x1="0" y1="1" x2="1" y2="0">
|
|
10
|
+
<stop offset="0%" stop-color="#7a8ea8"/>
|
|
11
|
+
<stop offset="100%" stop-color="#b0c0d4"/>
|
|
12
|
+
</linearGradient>
|
|
13
|
+
</defs>
|
|
14
|
+
|
|
15
|
+
<circle r="140" fill="none" stroke="url(#gold)" stroke-width="0.5" opacity="0.3"/>
|
|
16
|
+
|
|
17
|
+
<g fill="none" opacity="0.2" stroke="#c9a96e" stroke-width="0.8">
|
|
18
|
+
<line x1="0" y1="-134" x2="0" y2="-140" transform="rotate(0)"/>
|
|
19
|
+
<line x1="0" y1="-134" x2="0" y2="-140" transform="rotate(22.5)"/>
|
|
20
|
+
<line x1="0" y1="-134" x2="0" y2="-140" transform="rotate(45)"/>
|
|
21
|
+
<line x1="0" y1="-134" x2="0" y2="-140" transform="rotate(67.5)"/>
|
|
22
|
+
<line x1="0" y1="-134" x2="0" y2="-140" transform="rotate(90)"/>
|
|
23
|
+
<line x1="0" y1="-134" x2="0" y2="-140" transform="rotate(112.5)"/>
|
|
24
|
+
<line x1="0" y1="-134" x2="0" y2="-140" transform="rotate(135)"/>
|
|
25
|
+
<line x1="0" y1="-134" x2="0" y2="-140" transform="rotate(157.5)"/>
|
|
26
|
+
<line x1="0" y1="-134" x2="0" y2="-140" transform="rotate(180)"/>
|
|
27
|
+
<line x1="0" y1="-134" x2="0" y2="-140" transform="rotate(202.5)"/>
|
|
28
|
+
<line x1="0" y1="-134" x2="0" y2="-140" transform="rotate(225)"/>
|
|
29
|
+
<line x1="0" y1="-134" x2="0" y2="-140" transform="rotate(247.5)"/>
|
|
30
|
+
<line x1="0" y1="-134" x2="0" y2="-140" transform="rotate(270)"/>
|
|
31
|
+
<line x1="0" y1="-134" x2="0" y2="-140" transform="rotate(292.5)"/>
|
|
32
|
+
<line x1="0" y1="-134" x2="0" y2="-140" transform="rotate(315)"/>
|
|
33
|
+
<line x1="0" y1="-134" x2="0" y2="-140" transform="rotate(337.5)"/>
|
|
34
|
+
</g>
|
|
35
|
+
|
|
36
|
+
<polygon fill="none"
|
|
37
|
+
points="115.5,47.8 47.8,115.5 -47.8,115.5 -115.5,47.8 -115.5,-47.8 -47.8,-115.5 47.8,-115.5 115.5,-47.8"
|
|
38
|
+
stroke="url(#gold)" stroke-width="1.8" opacity="0.65"/>
|
|
39
|
+
|
|
40
|
+
<circle r="113" fill="none" stroke="#d4c5a0" stroke-width="1.2" opacity="0.45"/>
|
|
41
|
+
<circle cx="-16" cy="16" r="89" fill="none" stroke="url(#silver)" stroke-width="1.1" opacity="0.40"/>
|
|
42
|
+
<circle cx="13" cy="-10" r="63" fill="none" stroke="#a0b0c4" stroke-width="1.0" opacity="0.45"/>
|
|
43
|
+
<circle r="36" fill="none" stroke="url(#gold)" stroke-width="1.2" opacity="0.55"/>
|
|
44
|
+
<circle r="3" fill="#c9a96e" opacity="0.5"/>
|
|
45
|
+
</svg>
|