@totemsdk/proofgraph 1.1.0 → 1.1.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/README.md +30 -9
- package/dist/cjs/query.js +2 -2
- package/dist/query.js +2 -2
- package/package.json +8 -5
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Local deterministic proof relationship graph for Totem Edge — indexes proofs, identities, manifests, anchors, and subjects into a queryable, content-addressed DAG.
|
|
4
4
|
|
|
5
|
-
No network.
|
|
5
|
+
No network. The graph is in-memory by default; a CAS-backed durable store and a replicated evidence adapter ship with the package. SHA3-256 content addressing throughout.
|
|
6
6
|
|
|
7
7
|
## Installation
|
|
8
8
|
|
|
@@ -19,7 +19,8 @@ Key properties:
|
|
|
19
19
|
- **Immutable** — every add/mutation returns a new `ProofGraph`; originals are never modified
|
|
20
20
|
- **Idempotent** — adding the same node or edge twice has no effect (deduplication by content ID)
|
|
21
21
|
- **Content-deterministic** — `graphId` excludes `createdAt` timestamps so identical content always hashes identically
|
|
22
|
-
- **
|
|
22
|
+
- **Optional durability** — `createDurableProofGraphStore` persists graphs over any CAS-capable adapter, with restart recovery and concurrent-save serialization
|
|
23
|
+
- **Replicated evidence** — `createReplicatedProofGraphEvidenceStore` binds evidence nodes to content-addressed artifacts
|
|
23
24
|
|
|
24
25
|
## All exports
|
|
25
26
|
|
|
@@ -221,19 +222,34 @@ console.assert(restored.graphId === graph.graphId);
|
|
|
221
222
|
|
|
222
223
|
Every function that modifies a graph (`addProof`, `addEdge`, etc.) returns a new `ProofGraph` with a recomputed `graphId`. Calling the same add function twice with the same arguments returns a graph identical to calling it once — duplicate nodes and edges are silently ignored.
|
|
223
224
|
|
|
224
|
-
###
|
|
225
|
+
### Durable storage
|
|
225
226
|
|
|
226
|
-
|
|
227
|
+
`createDurableProofGraphStore(adapter)` persists graphs over a CAS-capable
|
|
228
|
+
storage adapter (`@totemsdk/storage`). It maintains a head pointer and a
|
|
229
|
+
per-node reverse index, serializes concurrent saves per adapter, and refuses an
|
|
230
|
+
adapter that does not acknowledge durable, atomic, conditional writes — there is
|
|
231
|
+
no silent downgrade.
|
|
227
232
|
|
|
228
233
|
```typescript
|
|
229
|
-
import
|
|
234
|
+
import { createDurableProofGraphStore } from '@totemsdk/proofgraph';
|
|
235
|
+
import { SqliteStore } from '@totemsdk/storage/sqlite';
|
|
230
236
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
237
|
+
const store = createDurableProofGraphStore(new SqliteStore('./proofgraph.sqlite'));
|
|
238
|
+
await store.save(graph);
|
|
239
|
+
const latest = await store.latest(); // most recently saved graph
|
|
240
|
+
const report = await store.recover(); // reconcile head + index after a crash
|
|
235
241
|
```
|
|
236
242
|
|
|
243
|
+
`ProofGraphStoragePort` remains available if a deployment wants its own adapter
|
|
244
|
+
(`save`/`load` only).
|
|
245
|
+
|
|
246
|
+
### Replicated evidence
|
|
247
|
+
|
|
248
|
+
`createReplicatedProofGraphEvidenceStore({ artifacts, index })` writes evidence
|
|
249
|
+
nodes to an `ArtifactStore` and indexes their content-addressed refs. Reads
|
|
250
|
+
distinguish `ok`, `not-found`, `corrupt` and `unavailable`, and a claim
|
|
251
|
+
commitment that does not match the stored bytes is rejected before indexing.
|
|
252
|
+
|
|
237
253
|
## Related packages
|
|
238
254
|
|
|
239
255
|
- [`@totemsdk/proof`](https://www.npmjs.com/package/@totemsdk/proof) — signed proof creation and verification
|
|
@@ -244,3 +260,8 @@ class MyStorage implements ProofGraphStoragePort {
|
|
|
244
260
|
## License
|
|
245
261
|
|
|
246
262
|
Apache-2.0 — see [LICENSE](./LICENSE) and [NOTICE](./NOTICE).
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
## Testing
|
|
266
|
+
|
|
267
|
+
Tests live outside the published package in `tests/unit/proofgraph/`. Package `test:*` scripts are repository delegates.
|
package/dist/cjs/query.js
CHANGED
|
@@ -37,7 +37,7 @@ function getEdgesFrom(graph, nodeIdOrRefId) {
|
|
|
37
37
|
const node = findNode(graph, nodeIdOrRefId);
|
|
38
38
|
if (!node)
|
|
39
39
|
return [];
|
|
40
|
-
return graph.edges.filter((e) => e.from === node.refId);
|
|
40
|
+
return graph.edges.filter((e) => e.from === node.refId || e.from === node.id);
|
|
41
41
|
}
|
|
42
42
|
/**
|
|
43
43
|
* Return all incoming edges to a node (identified by node ID or refId).
|
|
@@ -46,7 +46,7 @@ function getEdgesTo(graph, nodeIdOrRefId) {
|
|
|
46
46
|
const node = findNode(graph, nodeIdOrRefId);
|
|
47
47
|
if (!node)
|
|
48
48
|
return [];
|
|
49
|
-
return graph.edges.filter((e) => e.to === node.refId);
|
|
49
|
+
return graph.edges.filter((e) => e.to === node.refId || e.to === node.id);
|
|
50
50
|
}
|
|
51
51
|
/**
|
|
52
52
|
* Return all edges of a given type.
|
package/dist/query.js
CHANGED
|
@@ -17,7 +17,7 @@ export function getEdgesFrom(graph, nodeIdOrRefId) {
|
|
|
17
17
|
const node = findNode(graph, nodeIdOrRefId);
|
|
18
18
|
if (!node)
|
|
19
19
|
return [];
|
|
20
|
-
return graph.edges.filter((e) => e.from === node.refId);
|
|
20
|
+
return graph.edges.filter((e) => e.from === node.refId || e.from === node.id);
|
|
21
21
|
}
|
|
22
22
|
/**
|
|
23
23
|
* Return all incoming edges to a node (identified by node ID or refId).
|
|
@@ -26,7 +26,7 @@ export function getEdgesTo(graph, nodeIdOrRefId) {
|
|
|
26
26
|
const node = findNode(graph, nodeIdOrRefId);
|
|
27
27
|
if (!node)
|
|
28
28
|
return [];
|
|
29
|
-
return graph.edges.filter((e) => e.to === node.refId);
|
|
29
|
+
return graph.edges.filter((e) => e.to === node.refId || e.to === node.id);
|
|
30
30
|
}
|
|
31
31
|
/**
|
|
32
32
|
* Return all edges of a given type.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@totemsdk/proofgraph",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "Local deterministic proof relationship graph for Totem Edge — indexes proofs, identities, manifests, and subjects into a queryable content-addressed DAG",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"types": "dist/cjs/index.d.ts",
|
|
@@ -26,10 +26,10 @@
|
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@totemsdk/core": "^1.4.2",
|
|
29
|
-
"@totemsdk/proof": "^1.0.
|
|
30
|
-
"@totemsdk/
|
|
29
|
+
"@totemsdk/proof": "^1.0.3",
|
|
30
|
+
"@totemsdk/manifest": "^2.1.0",
|
|
31
31
|
"@totemsdk/identity": "^1.1.0",
|
|
32
|
-
"@totemsdk/
|
|
32
|
+
"@totemsdk/storage": "^0.2.2"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@types/jest": "^30.0.0",
|
|
@@ -76,6 +76,9 @@
|
|
|
76
76
|
"build": "tsc && tsc -p tsconfig.cjs.json && node -e \"require('fs').writeFileSync('dist/cjs/package.json', JSON.stringify({type:'commonjs'})+'\\n')\"",
|
|
77
77
|
"build:wasm": "cd rust && wasm-pack build --target bundler --out-dir pkg && wasm-pack build --target nodejs --out-dir pkg-node",
|
|
78
78
|
"clean": "rm -rf dist rust/pkg rust/pkg-node rust/target",
|
|
79
|
-
"test": "jest"
|
|
79
|
+
"test": "jest --config ../../tests/jest/proofgraph.cjs",
|
|
80
|
+
"test:integration": "node --test ../../tests/qualification/proofgraph/integration.test.mjs",
|
|
81
|
+
"test:conformance": "node --test ../../tests/qualification/proofgraph/conformance.test.mjs",
|
|
82
|
+
"test:recovery": "node --test ../../tests/qualification/proofgraph/recovery.test.mjs"
|
|
80
83
|
}
|
|
81
84
|
}
|