@cynodia/axiom-server 0.11.2-alpha.1 → 0.12.0-alpha.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.
Files changed (49) hide show
  1. package/conformance/distributed/cache-revision-visibility.json +50 -0
  2. package/conformance/distributed/effect-claiming.json +48 -0
  3. package/conformance/distributed/effect-completion.json +67 -0
  4. package/conformance/distributed/effect-reclaim.json +52 -0
  5. package/conformance/distributed/event-deduplication.json +55 -0
  6. package/conformance/distributed/lease-acquisition.json +40 -0
  7. package/conformance/distributed/lease-fencing.json +54 -0
  8. package/conformance/distributed/manifest.json +32 -0
  9. package/conformance/distributed/mixed-build-refusal.json +42 -0
  10. package/conformance/distributed/schedule-firing.json +55 -0
  11. package/conformance/distributed/schedule-reclaim.json +59 -0
  12. package/conformance/distributed/subscription-cursor-fencing.json +87 -0
  13. package/dist/authority-identity.d.ts +27 -0
  14. package/dist/authority-identity.js +81 -0
  15. package/dist/coordination-conformance.d.ts +170 -0
  16. package/dist/coordination-conformance.js +259 -0
  17. package/dist/coordination.d.ts +197 -0
  18. package/dist/coordination.js +228 -0
  19. package/dist/deps.d.ts +2 -2
  20. package/dist/deps.js +1 -1
  21. package/dist/distributed-effects.d.ts +135 -0
  22. package/dist/distributed-effects.js +234 -0
  23. package/dist/distributed-scheduler.d.ts +123 -0
  24. package/dist/distributed-scheduler.js +203 -0
  25. package/dist/durable-work.d.ts +260 -0
  26. package/dist/durable-work.js +321 -0
  27. package/dist/effects.d.ts +30 -0
  28. package/dist/effects.js +84 -41
  29. package/dist/external-event-dedup.d.ts +81 -0
  30. package/dist/external-event-dedup.js +0 -0
  31. package/dist/index.d.ts +17 -0
  32. package/dist/index.js +13 -0
  33. package/dist/revision-cache.d.ts +66 -0
  34. package/dist/revision-cache.js +77 -0
  35. package/dist/server.d.ts +56 -0
  36. package/dist/server.js +132 -3
  37. package/dist/sqlite-coordination.d.ts +18 -0
  38. package/dist/sqlite-coordination.js +150 -0
  39. package/dist/sqlite-durable-work.d.ts +27 -0
  40. package/dist/sqlite-durable-work.js +179 -0
  41. package/dist/sqlite-external-event-dedup.d.ts +23 -0
  42. package/dist/sqlite-external-event-dedup.js +98 -0
  43. package/dist/sqlite-subscription-cursor.d.ts +22 -0
  44. package/dist/sqlite-subscription-cursor.js +80 -0
  45. package/dist/subscription-cursor.d.ts +121 -0
  46. package/dist/subscription-cursor.js +138 -0
  47. package/dist/triggers.d.ts +9 -0
  48. package/dist/triggers.js +30 -2
  49. package/package.json +4 -4
@@ -0,0 +1,50 @@
1
+ {
2
+ "conformance": "axiom.conformance.v6",
3
+ "name": "cache-revision-visibility",
4
+ "covers": [
5
+ "cache revision visibility"
6
+ ],
7
+ "description": "A cached entry is served while the persisted revision is unchanged and dropped once it advances.",
8
+ "clockStart": 1000,
9
+ "steps": [
10
+ {
11
+ "op": "cache-set",
12
+ "key": "ownOrders",
13
+ "value": [
14
+ 1,
15
+ 2,
16
+ 3
17
+ ],
18
+ "observedRevision": 5
19
+ },
20
+ {
21
+ "op": "cache-get",
22
+ "key": "ownOrders",
23
+ "persistedRevision": 5,
24
+ "expect": {
25
+ "hit": true,
26
+ "value": [
27
+ 1,
28
+ 2,
29
+ 3
30
+ ]
31
+ }
32
+ },
33
+ {
34
+ "op": "cache-get",
35
+ "key": "ownOrders",
36
+ "persistedRevision": 6,
37
+ "expect": {
38
+ "hit": false
39
+ }
40
+ },
41
+ {
42
+ "op": "cache-get",
43
+ "key": "ownOrders",
44
+ "persistedRevision": 6,
45
+ "expect": {
46
+ "hit": false
47
+ }
48
+ }
49
+ ]
50
+ }
@@ -0,0 +1,48 @@
1
+ {
2
+ "conformance": "axiom.conformance.v6",
3
+ "name": "effect-claiming",
4
+ "covers": [
5
+ "effect claiming"
6
+ ],
7
+ "description": "One authority claims a pending effect work item exclusively; a second authority claims nothing.",
8
+ "clockStart": 1000,
9
+ "steps": [
10
+ {
11
+ "op": "enqueue",
12
+ "workClass": "effect",
13
+ "workId": "e1",
14
+ "expect": {
15
+ "created": true
16
+ }
17
+ },
18
+ {
19
+ "op": "claim",
20
+ "workClass": "effect",
21
+ "owner": "A",
22
+ "leaseMs": 5000,
23
+ "expect": {
24
+ "workIds": [
25
+ "e1"
26
+ ]
27
+ }
28
+ },
29
+ {
30
+ "op": "claim",
31
+ "workClass": "effect",
32
+ "owner": "B",
33
+ "leaseMs": 5000,
34
+ "expect": {
35
+ "workIds": []
36
+ }
37
+ },
38
+ {
39
+ "op": "work-state",
40
+ "workClass": "effect",
41
+ "workId": "e1",
42
+ "expect": {
43
+ "state": "claimed",
44
+ "attemptNumber": 1
45
+ }
46
+ }
47
+ ]
48
+ }
@@ -0,0 +1,67 @@
1
+ {
2
+ "conformance": "axiom.conformance.v6",
3
+ "name": "effect-completion",
4
+ "covers": [
5
+ "effect completion"
6
+ ],
7
+ "description": "The current owner settles the effect succeeded; a fenced prior owner's settle is rejected.",
8
+ "clockStart": 1000,
9
+ "steps": [
10
+ {
11
+ "op": "enqueue",
12
+ "workClass": "effect",
13
+ "workId": "e1"
14
+ },
15
+ {
16
+ "op": "claim",
17
+ "workClass": "effect",
18
+ "owner": "A",
19
+ "leaseMs": 1000,
20
+ "expect": {
21
+ "workIds": [
22
+ "e1"
23
+ ]
24
+ }
25
+ },
26
+ {
27
+ "op": "advance",
28
+ "ms": 1001
29
+ },
30
+ {
31
+ "op": "claim",
32
+ "workClass": "effect",
33
+ "owner": "B",
34
+ "leaseMs": 5000,
35
+ "expect": {
36
+ "workIds": [
37
+ "e1"
38
+ ]
39
+ }
40
+ },
41
+ {
42
+ "op": "settle",
43
+ "ref": "effect:e1:A",
44
+ "outcome": "succeeded",
45
+ "expect": {
46
+ "ok": false,
47
+ "reason": "fenced"
48
+ }
49
+ },
50
+ {
51
+ "op": "settle",
52
+ "ref": "effect:e1:B",
53
+ "outcome": "succeeded",
54
+ "expect": {
55
+ "ok": true
56
+ }
57
+ },
58
+ {
59
+ "op": "work-state",
60
+ "workClass": "effect",
61
+ "workId": "e1",
62
+ "expect": {
63
+ "state": "succeeded"
64
+ }
65
+ }
66
+ ]
67
+ }
@@ -0,0 +1,52 @@
1
+ {
2
+ "conformance": "axiom.conformance.v6",
3
+ "name": "effect-reclaim",
4
+ "covers": [
5
+ "effect reclaim"
6
+ ],
7
+ "description": "A crashed claimer's lease lapses; another authority reclaims the same work item, attempt 2, one uncertain prior attempt.",
8
+ "clockStart": 1000,
9
+ "steps": [
10
+ {
11
+ "op": "enqueue",
12
+ "workClass": "effect",
13
+ "workId": "e1"
14
+ },
15
+ {
16
+ "op": "claim",
17
+ "workClass": "effect",
18
+ "owner": "A",
19
+ "leaseMs": 1000,
20
+ "expect": {
21
+ "workIds": [
22
+ "e1"
23
+ ]
24
+ }
25
+ },
26
+ {
27
+ "op": "advance",
28
+ "ms": 1001
29
+ },
30
+ {
31
+ "op": "claim",
32
+ "workClass": "effect",
33
+ "owner": "B",
34
+ "leaseMs": 5000,
35
+ "expect": {
36
+ "workIds": [
37
+ "e1"
38
+ ]
39
+ }
40
+ },
41
+ {
42
+ "op": "work-state",
43
+ "workClass": "effect",
44
+ "workId": "e1",
45
+ "expect": {
46
+ "state": "claimed",
47
+ "attemptNumber": 2,
48
+ "uncertainAttempts": 1
49
+ }
50
+ }
51
+ ]
52
+ }
@@ -0,0 +1,55 @@
1
+ {
2
+ "conformance": "axiom.conformance.v6",
3
+ "name": "event-deduplication",
4
+ "covers": [
5
+ "event deduplication"
6
+ ],
7
+ "description": "A stable external id: first accepted, byte-equal repeat is a duplicate, divergent payload is EVENT_ID_CONFLICT.",
8
+ "clockStart": 1000,
9
+ "steps": [
10
+ {
11
+ "op": "dedup",
12
+ "source": "stripe",
13
+ "externalEventId": "evt_1",
14
+ "payload": {
15
+ "amount": 100
16
+ },
17
+ "expect": {
18
+ "status": "accepted"
19
+ }
20
+ },
21
+ {
22
+ "op": "dedup",
23
+ "source": "stripe",
24
+ "externalEventId": "evt_1",
25
+ "payload": {
26
+ "amount": 100
27
+ },
28
+ "expect": {
29
+ "status": "duplicate"
30
+ }
31
+ },
32
+ {
33
+ "op": "dedup",
34
+ "source": "stripe",
35
+ "externalEventId": "evt_1",
36
+ "payload": {
37
+ "amount": 999
38
+ },
39
+ "expect": {
40
+ "status": "conflict",
41
+ "code": "EVENT_ID_CONFLICT"
42
+ }
43
+ },
44
+ {
45
+ "op": "dedup",
46
+ "source": "stripe",
47
+ "payload": {
48
+ "amount": 5
49
+ },
50
+ "expect": {
51
+ "status": "unidentified"
52
+ }
53
+ }
54
+ ]
55
+ }
@@ -0,0 +1,40 @@
1
+ {
2
+ "conformance": "axiom.conformance.v6",
3
+ "name": "lease-acquisition",
4
+ "covers": [
5
+ "lease acquisition"
6
+ ],
7
+ "description": "A free resource is acquired at generation 1; a second live claimant is blocked and sees the holder.",
8
+ "clockStart": 1000,
9
+ "steps": [
10
+ {
11
+ "op": "acquire",
12
+ "resource": "effect:e1",
13
+ "owner": "A",
14
+ "leaseMs": 5000,
15
+ "expect": {
16
+ "ok": true,
17
+ "generation": 1
18
+ }
19
+ },
20
+ {
21
+ "op": "acquire",
22
+ "resource": "effect:e1",
23
+ "owner": "B",
24
+ "leaseMs": 5000,
25
+ "expect": {
26
+ "ok": false,
27
+ "heldBy": "A"
28
+ }
29
+ },
30
+ {
31
+ "op": "inspect",
32
+ "resource": "effect:e1",
33
+ "expect": {
34
+ "held": true,
35
+ "owner": "A",
36
+ "generation": 1
37
+ }
38
+ }
39
+ ]
40
+ }
@@ -0,0 +1,54 @@
1
+ {
2
+ "conformance": "axiom.conformance.v6",
3
+ "name": "lease-fencing",
4
+ "covers": [
5
+ "lease fencing"
6
+ ],
7
+ "description": "An expired lease is reclaimed at a higher generation; the prior owner is fenced, not merely expired.",
8
+ "clockStart": 1000,
9
+ "steps": [
10
+ {
11
+ "op": "acquire",
12
+ "resource": "effect:e1",
13
+ "owner": "A",
14
+ "leaseMs": 1000,
15
+ "expect": {
16
+ "ok": true,
17
+ "generation": 1
18
+ }
19
+ },
20
+ {
21
+ "op": "advance",
22
+ "ms": 1001
23
+ },
24
+ {
25
+ "op": "acquire",
26
+ "resource": "effect:e1",
27
+ "owner": "B",
28
+ "leaseMs": 5000,
29
+ "expect": {
30
+ "ok": true,
31
+ "generation": 2
32
+ }
33
+ },
34
+ {
35
+ "op": "checkOwnership",
36
+ "resource": "effect:e1",
37
+ "owner": "A",
38
+ "generation": 1,
39
+ "expect": {
40
+ "current": false,
41
+ "reason": "fenced"
42
+ }
43
+ },
44
+ {
45
+ "op": "renew",
46
+ "resource": "effect:e1",
47
+ "ownerRef": "effect:e1#A",
48
+ "leaseMs": 5000,
49
+ "expect": {
50
+ "ok": false
51
+ }
52
+ }
53
+ ]
54
+ }
@@ -0,0 +1,32 @@
1
+ {
2
+ "conformance": "axiom.conformance.v6",
3
+ "baseContract": "axiom.server.v7",
4
+ "release": "0.12.0-alpha.1",
5
+ "description": "Portable distributed-authority conformance fixtures (spec12 §59, §85). Each is a deterministic step list against the memory reference providers with a fixed clock and token sequence. Server IR is retained at axiom.server.v7 — 0.12 adds no IR vocabulary (spec12 §58).",
6
+ "covers": [
7
+ "lease acquisition",
8
+ "lease fencing",
9
+ "effect claiming",
10
+ "effect reclaim",
11
+ "effect completion",
12
+ "schedule firing",
13
+ "schedule reclaim",
14
+ "event deduplication",
15
+ "subscription cursor fencing",
16
+ "cache revision visibility",
17
+ "mixed-build refusal"
18
+ ],
19
+ "fixtures": [
20
+ "lease-acquisition",
21
+ "lease-fencing",
22
+ "effect-claiming",
23
+ "effect-reclaim",
24
+ "effect-completion",
25
+ "schedule-firing",
26
+ "schedule-reclaim",
27
+ "event-deduplication",
28
+ "subscription-cursor-fencing",
29
+ "cache-revision-visibility",
30
+ "mixed-build-refusal"
31
+ ]
32
+ }
@@ -0,0 +1,42 @@
1
+ {
2
+ "conformance": "axiom.conformance.v6",
3
+ "name": "mixed-build-refusal",
4
+ "covers": [
5
+ "mixed-build refusal"
6
+ ],
7
+ "description": "Work stamped with build A's key is not claimed by build B; build A claims it.",
8
+ "clockStart": 1000,
9
+ "steps": [
10
+ {
11
+ "op": "enqueue",
12
+ "workClass": "effect",
13
+ "workId": "e1",
14
+ "authorityKey": "buildA",
15
+ "expect": {
16
+ "created": true
17
+ }
18
+ },
19
+ {
20
+ "op": "claim",
21
+ "workClass": "effect",
22
+ "owner": "B",
23
+ "leaseMs": 5000,
24
+ "authorityKey": "buildB",
25
+ "expect": {
26
+ "workIds": []
27
+ }
28
+ },
29
+ {
30
+ "op": "claim",
31
+ "workClass": "effect",
32
+ "owner": "A",
33
+ "leaseMs": 5000,
34
+ "authorityKey": "buildA",
35
+ "expect": {
36
+ "workIds": [
37
+ "e1"
38
+ ]
39
+ }
40
+ }
41
+ ]
42
+ }
@@ -0,0 +1,55 @@
1
+ {
2
+ "conformance": "axiom.conformance.v6",
3
+ "name": "schedule-firing",
4
+ "covers": [
5
+ "schedule firing"
6
+ ],
7
+ "description": "One logical schedule firing (a durable work item) is claimed and completed by exactly one authority.",
8
+ "clockStart": 5000,
9
+ "steps": [
10
+ {
11
+ "op": "enqueue",
12
+ "workClass": "schedule-firing",
13
+ "workId": "trg@5000",
14
+ "expect": {
15
+ "created": true
16
+ }
17
+ },
18
+ {
19
+ "op": "enqueue",
20
+ "workClass": "schedule-firing",
21
+ "workId": "trg@5000",
22
+ "expect": {
23
+ "created": false
24
+ }
25
+ },
26
+ {
27
+ "op": "claim",
28
+ "workClass": "schedule-firing",
29
+ "owner": "A",
30
+ "leaseMs": 5000,
31
+ "expect": {
32
+ "workIds": [
33
+ "trg@5000"
34
+ ]
35
+ }
36
+ },
37
+ {
38
+ "op": "claim",
39
+ "workClass": "schedule-firing",
40
+ "owner": "B",
41
+ "leaseMs": 5000,
42
+ "expect": {
43
+ "workIds": []
44
+ }
45
+ },
46
+ {
47
+ "op": "settle",
48
+ "ref": "schedule-firing:trg@5000:A",
49
+ "outcome": "succeeded",
50
+ "expect": {
51
+ "ok": true
52
+ }
53
+ }
54
+ ]
55
+ }
@@ -0,0 +1,59 @@
1
+ {
2
+ "conformance": "axiom.conformance.v6",
3
+ "name": "schedule-reclaim",
4
+ "covers": [
5
+ "schedule reclaim"
6
+ ],
7
+ "description": "A crashed firing owner is reclaimed under the same work id — no second firing identity.",
8
+ "clockStart": 5000,
9
+ "steps": [
10
+ {
11
+ "op": "enqueue",
12
+ "workClass": "schedule-firing",
13
+ "workId": "trg@5000"
14
+ },
15
+ {
16
+ "op": "claim",
17
+ "workClass": "schedule-firing",
18
+ "owner": "A",
19
+ "leaseMs": 1000,
20
+ "expect": {
21
+ "workIds": [
22
+ "trg@5000"
23
+ ]
24
+ }
25
+ },
26
+ {
27
+ "op": "advance",
28
+ "ms": 1001
29
+ },
30
+ {
31
+ "op": "claim",
32
+ "workClass": "schedule-firing",
33
+ "owner": "B",
34
+ "leaseMs": 5000,
35
+ "expect": {
36
+ "workIds": [
37
+ "trg@5000"
38
+ ]
39
+ }
40
+ },
41
+ {
42
+ "op": "settle",
43
+ "ref": "schedule-firing:trg@5000:B",
44
+ "outcome": "succeeded",
45
+ "expect": {
46
+ "ok": true
47
+ }
48
+ },
49
+ {
50
+ "op": "work-state",
51
+ "workClass": "schedule-firing",
52
+ "workId": "trg@5000",
53
+ "expect": {
54
+ "state": "succeeded",
55
+ "attemptNumber": 2
56
+ }
57
+ }
58
+ ]
59
+ }
@@ -0,0 +1,87 @@
1
+ {
2
+ "conformance": "axiom.conformance.v6",
3
+ "name": "subscription-cursor-fencing",
4
+ "covers": [
5
+ "subscription cursor fencing"
6
+ ],
7
+ "description": "A stalled cursor owner cannot advance after another authority takes over; the cursor never regresses.",
8
+ "clockStart": 1000,
9
+ "steps": [
10
+ {
11
+ "op": "cursor-acquire",
12
+ "subscription": "sub",
13
+ "owner": "A",
14
+ "leaseMs": 1000,
15
+ "expect": {
16
+ "ok": true,
17
+ "generation": 1,
18
+ "resumeFrom": 0
19
+ }
20
+ },
21
+ {
22
+ "op": "cursor-advance",
23
+ "subscription": "sub",
24
+ "owner": "A",
25
+ "generation": 1,
26
+ "toSequence": 10,
27
+ "expect": {
28
+ "ok": true
29
+ }
30
+ },
31
+ {
32
+ "op": "advance",
33
+ "ms": 1001
34
+ },
35
+ {
36
+ "op": "cursor-acquire",
37
+ "subscription": "sub",
38
+ "owner": "B",
39
+ "leaseMs": 5000,
40
+ "expect": {
41
+ "ok": true,
42
+ "generation": 2,
43
+ "resumeFrom": 10
44
+ }
45
+ },
46
+ {
47
+ "op": "cursor-advance",
48
+ "subscription": "sub",
49
+ "owner": "B",
50
+ "generation": 2,
51
+ "toSequence": 25,
52
+ "expect": {
53
+ "ok": true
54
+ }
55
+ },
56
+ {
57
+ "op": "cursor-advance",
58
+ "subscription": "sub",
59
+ "owner": "A",
60
+ "generation": 1,
61
+ "toSequence": 999,
62
+ "expect": {
63
+ "ok": false,
64
+ "reason": "fenced"
65
+ }
66
+ },
67
+ {
68
+ "op": "cursor-advance",
69
+ "subscription": "sub",
70
+ "owner": "B",
71
+ "generation": 2,
72
+ "toSequence": 5,
73
+ "expect": {
74
+ "ok": false,
75
+ "reason": "stale-sequence"
76
+ }
77
+ },
78
+ {
79
+ "op": "cursor-read",
80
+ "subscription": "sub",
81
+ "expect": {
82
+ "sequence": 25,
83
+ "writerGeneration": 2
84
+ }
85
+ }
86
+ ]
87
+ }
@@ -0,0 +1,27 @@
1
+ /**
2
+ * This authority build's compatibility identity, computed from the Server IR (spec12 §43-§45).
3
+ *
4
+ * `packages/core`'s `semanticFingerprint` projects an `ApplicationGraph`; the authoritative
5
+ * runtime only ever sees the normalized `ServerIR`. This module is the ServerIR-side
6
+ * equivalent: the same idea (hash the executable meaning, exclude names / UI / annotation),
7
+ * applied to the slices a `ServerIR` actually carries. It is deterministic and versioned so
8
+ * a future non-JS runtime reconstructs the same bytes (spec12 §95, §96).
9
+ *
10
+ * The resulting {@link AuthorityCompatibilityKey} is what `createDurableWorkStore` stamps as
11
+ * its `authorityKey`: an incompatible / older build then refuses to claim work a newer build
12
+ * created (spec12 §44, §47).
13
+ */
14
+ import { type AuthorityCompatibilityKey, type ServerIR } from './deps.js';
15
+ /**
16
+ * The canonical executable-meaning projection of a Server IR: actions, constraints,
17
+ * transition constraints, expression defs, integrations + operations, triggers, events,
18
+ * subscriptions, storages, read policies, relationships, queries, plus the schema version.
19
+ * Everything a distributed worker executes; nothing a rename touches.
20
+ */
21
+ export declare function serverIrSemanticProjection(ir: ServerIR): Record<string, unknown>;
22
+ export declare function serverIrSemanticFingerprint(ir: ServerIR): string;
23
+ /** The full compatibility key for the authority executing this Server IR (spec12 §45). */
24
+ export declare function serverIrCompatibilityKey(ir: ServerIR): AuthorityCompatibilityKey;
25
+ /** The stable string form stamped onto durable work as `authorityKey`. */
26
+ export declare function serverIrCompatibilityKeyString(ir: ServerIR): string;
27
+ //# sourceMappingURL=authority-identity.d.ts.map