@substrat-run/engine-protocol 0.3.0 → 0.3.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 +22 -19
- package/package.json +8 -5
package/README.md
CHANGED
|
@@ -9,29 +9,27 @@ The engine owns only the invariants. Template *content* — which protocols exis
|
|
|
9
9
|
what they contain — is 100% vertical-owned, and an instance binds to any `EntityRef`
|
|
10
10
|
(a work order today, anything tomorrow).
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
## Invariants the engine owns
|
|
12
|
+
## What it owns
|
|
15
13
|
|
|
16
14
|
1. **Sign freezes** — any write to a signed instance's responses fails.
|
|
17
15
|
2. **Content hash** — SHA-256 over template content + latest responses at sign time,
|
|
18
16
|
verifiable against replayed state.
|
|
19
|
-
3. **Counter-sign** —
|
|
20
|
-
|
|
21
|
-
Exactly one primary signature per instance.
|
|
17
|
+
3. **Counter-sign** — a second signature on the *same* frozen content; the hash is
|
|
18
|
+
recomputed and must match.
|
|
22
19
|
4. **Append-only responses** — an edit is a new row; history is audit material.
|
|
23
|
-
5. **Version-pinned templates** —
|
|
24
|
-
`(key, version)` at instantiation forever.
|
|
20
|
+
5. **Version-pinned templates** — an instance pins `(key, version)` at instantiation forever.
|
|
25
21
|
6. **Void, not delete** — a protocol is superseded, never mutated or removed.
|
|
26
22
|
|
|
27
|
-
##
|
|
23
|
+
## Install
|
|
28
24
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
25
|
+
```sh
|
|
26
|
+
pnpm add @substrat-run/engine-protocol
|
|
27
|
+
```
|
|
32
28
|
|
|
33
29
|
```ts
|
|
34
|
-
import { instantiateProtocol,
|
|
30
|
+
import { instantiateProtocol, PROTOCOL_PERM, protocolModule } from '@substrat-run/engine-protocol';
|
|
31
|
+
|
|
32
|
+
host.registerModule(protocolModule);
|
|
35
33
|
|
|
36
34
|
host.defineOperation('acme/start-inspection', async (ctx, input) => {
|
|
37
35
|
assertAllowed(await ctx.check(PROTOCOL_PERM.create));
|
|
@@ -42,13 +40,18 @@ host.defineOperation('acme/start-inspection', async (ctx, input) => {
|
|
|
42
40
|
});
|
|
43
41
|
```
|
|
44
42
|
|
|
45
|
-
`requireSigned(ctx, entity, templateKey)` is the completion-guard building block: a
|
|
46
|
-
|
|
43
|
+
`requireSigned(ctx, entity, templateKey)` is the completion-guard building block: a vertical
|
|
44
|
+
can refuse to close its own entity until the protocol on it is signed. The engine also
|
|
45
|
+
contributes a `protocol/all-signed` guard predicate, so the same rule can be **declared** in a
|
|
46
|
+
vertical's manifest instead — where dropping it shows up in a reviewable diff.
|
|
47
|
+
|
|
48
|
+
## Documentation
|
|
49
|
+
|
|
50
|
+
**https://substrat.ahlstrand.es/engines/protocol/** — the domain model and invariants, the
|
|
51
|
+
signature/evidence model, the full operation and permission surface, event contracts, and how
|
|
52
|
+
to compose or extend it.
|
|
47
53
|
|
|
48
|
-
|
|
49
|
-
methods (BankID/Scrive-class) arrive later through the same operation shape with
|
|
50
|
-
upgraded evidence. Signed/countersigned events carry the frozen answers in the
|
|
51
|
-
payload — consumers never query back.
|
|
54
|
+
The docs site is the single source of truth; this README deliberately doesn't restate it.
|
|
52
55
|
|
|
53
56
|
## Related packages
|
|
54
57
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@substrat-run/engine-protocol",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Substrat engine: protocols/checklists with the sign → immutable invariant — versioned templates, append-only responses, verifiable content hash, counter-signatures on frozen content",
|
|
5
5
|
"license": "AGPL-3.0-only",
|
|
6
6
|
"repository": {
|
|
@@ -26,14 +26,17 @@
|
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"zod": "^4.4.3",
|
|
29
|
-
"@substrat-run/contracts": "^0.
|
|
30
|
-
"@substrat-run/kernel": "^0.
|
|
29
|
+
"@substrat-run/contracts": "^0.4.0",
|
|
30
|
+
"@substrat-run/kernel": "^0.4.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"typescript": "^5.6.0"
|
|
33
|
+
"typescript": "^5.6.0",
|
|
34
|
+
"vitest": "^3.0.0",
|
|
35
|
+
"@substrat-run/engine-test-kit": "^0.0.2"
|
|
34
36
|
},
|
|
35
37
|
"scripts": {
|
|
36
38
|
"build": "tsc -p tsconfig.json",
|
|
37
|
-
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
39
|
+
"typecheck": "tsc -p tsconfig.json --noEmit && tsc -p tsconfig.test.json --noEmit",
|
|
40
|
+
"test": "vitest run"
|
|
38
41
|
}
|
|
39
42
|
}
|