@substrat-run/engine-protocol 0.3.0 → 0.3.2

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.
Files changed (2) hide show
  1. package/README.md +22 -19
  2. 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
- **Full documentation: https://substrat.ahlstrand.es/engines/protocol**
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** — an *additional* signature on the same frozen content (the hash
20
- is recomputed and must match; a principal never counter-signs their own signature).
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** — templates version immutably; an instance pins
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
- ## Composing from a vertical
23
+ ## Install
28
24
 
29
- Operations (`protocol/define-template`, `instantiate`, `fill`, `sign`, `countersign`,
30
- `void`, `get`, `list-for-entity`) are default bindings over exported in-scope
31
- functions your own operations can call — same transaction, your permission check:
25
+ ```sh
26
+ pnpm add @substrat-run/engine-protocol
27
+ ```
32
28
 
33
29
  ```ts
34
- import { instantiateProtocol, requireSigned, PROTOCOL_PERM } from '@substrat-run/engine-protocol';
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
- vertical can refuse to close its own entity until the protocol on it is signed.
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
- Signing records the authenticated principal with an `in-app` method; connector-backed
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.0",
3
+ "version": "0.3.2",
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.3.0",
30
- "@substrat-run/kernel": "^0.3.0"
29
+ "@substrat-run/contracts": "^0.5.0",
30
+ "@substrat-run/kernel": "^0.5.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.3"
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
  }