archctx-contracts 0.11.4 → 0.13.0

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 (45) hide show
  1. package/fixtures/invalid/hook-debt-checkpoint-failed-read.json +6 -1
  2. package/fixtures/valid/archctx-capabilities.json +1 -1
  3. package/fixtures/valid/architecture-state-machine.json +158 -0
  4. package/fixtures/valid/hook-debt-checkpoint.json +6 -1
  5. package/fixtures/valid/product-version-manifest.json +5 -9
  6. package/fixtures/valid/state-machine-check.json +76 -0
  7. package/package.json +1 -1
  8. package/schemas/repo/architecture-state-machine.schema.json +153 -0
  9. package/schemas/runtime/architecture-debt.schema.json +6 -3
  10. package/schemas/runtime/product-version-manifest.schema.json +2 -6
  11. package/schemas/runtime/state-machine-check.schema.json +163 -0
  12. package/src/architecture-debt.ts +2 -2
  13. package/src/failure.ts +17 -11
  14. package/src/index.ts +2 -2
  15. package/src/ports.ts +0 -35
  16. package/src/product-version.ts +1 -9
  17. package/src/review-guards.ts +90 -0
  18. package/src/schema.ts +0 -2
  19. package/src/state-machine.ts +275 -0
  20. package/src/validator.ts +7 -0
  21. package/fixtures/boundary/attestation-v2-error.json +0 -43
  22. package/fixtures/boundary/check-delivery-dead-letter.json +0 -14
  23. package/fixtures/boundary/review-challenge-v2-organization.json +0 -15
  24. package/fixtures/boundary/runner-identity-organization-scope.json +0 -16
  25. package/fixtures/invalid/attestation-v2-finding-field.json +0 -39
  26. package/fixtures/invalid/check-delivery-legacy-check-name.json +0 -14
  27. package/fixtures/invalid/review-challenge-v2-private-field.json +0 -16
  28. package/fixtures/valid/attestation-v2.json +0 -38
  29. package/fixtures/valid/attestation.json +0 -25
  30. package/fixtures/valid/check-delivery.json +0 -14
  31. package/fixtures/valid/device-identity.json +0 -10
  32. package/fixtures/valid/governance-key-status.json +0 -11
  33. package/fixtures/valid/org-runner-identity.json +0 -10
  34. package/fixtures/valid/review-challenge-v2.json +0 -15
  35. package/fixtures/valid/runner-identity.json +0 -13
  36. package/schemas/cloud/attestation-v2.schema.json +0 -85
  37. package/schemas/cloud/attestation.schema.json +0 -49
  38. package/schemas/cloud/check-delivery.schema.json +0 -25
  39. package/schemas/cloud/device-identity.schema.json +0 -18
  40. package/schemas/cloud/governance-key-status.schema.json +0 -19
  41. package/schemas/cloud/org-runner-identity.schema.json +0 -21
  42. package/schemas/cloud/review-challenge-v2.schema.json +0 -23
  43. package/schemas/cloud/runner-identity.schema.json +0 -42
  44. package/src/control-plane-routes.ts +0 -35
  45. package/src/github-governance.ts +0 -850
@@ -30,6 +30,11 @@
30
30
  "coverage": "complete",
31
31
  "reasonCodes": []
32
32
  },
33
+ {
34
+ "check": "state-machines",
35
+ "coverage": "complete",
36
+ "reasonCodes": []
37
+ },
33
38
  {
34
39
  "check": "practices",
35
40
  "coverage": "complete",
@@ -38,7 +43,7 @@
38
43
  ],
39
44
  "items": [],
40
45
  "actionsRequired": [],
41
- "digest": "sha256:1d40d5a0b5f92e61241f310b1f0c26b342210533455707a93f524d306db88b4e"
46
+ "digest": "sha256:ceaaaf214aff4c0b05abe367cad2b58e52b25d2aeeb4809ebc0e101d34e66d09"
42
47
  },
43
48
  "hookLog": {
44
49
  "schemaVersion": "archcontext.hook-log/v1",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "schemaVersion": "archcontext.capabilities/v1",
3
- "package": { "name": "archctx", "version": "0.11.4" },
3
+ "package": { "name": "archctx", "version": "0.13.0" },
4
4
  "protocols": {
5
5
  "projectionRequest": "archcontext.projection-request/v1",
6
6
  "projectionResult": "archcontext.projection-result/v2",
@@ -0,0 +1,158 @@
1
+ {
2
+ "schemaVersion": "archcontext.state-machine/v1",
3
+ "id": "state-machine.checkout.order",
4
+ "capabilityId": "capability.checkout",
5
+ "name": "Order and payment",
6
+ "regions": [
7
+ {
8
+ "id": "order",
9
+ "label": "Order",
10
+ "initial": "open",
11
+ "states": [
12
+ {
13
+ "id": "open",
14
+ "label": "Open"
15
+ },
16
+ {
17
+ "id": "shipped",
18
+ "label": "Shipped",
19
+ "terminal": true
20
+ },
21
+ {
22
+ "id": "cancelled",
23
+ "label": "Cancelled",
24
+ "terminal": true
25
+ }
26
+ ]
27
+ },
28
+ {
29
+ "id": "payment",
30
+ "label": "Payment",
31
+ "initial": "unpaid",
32
+ "states": [
33
+ {
34
+ "id": "unpaid",
35
+ "label": "Unpaid"
36
+ },
37
+ {
38
+ "id": "captured",
39
+ "label": "Captured"
40
+ },
41
+ {
42
+ "id": "refunded",
43
+ "label": "Refunded"
44
+ }
45
+ ]
46
+ }
47
+ ],
48
+ "events": [
49
+ {
50
+ "id": "capture",
51
+ "label": "Capture the payment",
52
+ "source": {
53
+ "kind": "code",
54
+ "path": "src/payment.ts",
55
+ "symbol": "PaymentService.capture"
56
+ },
57
+ "steps": [
58
+ {
59
+ "when": {
60
+ "order": [
61
+ "open"
62
+ ],
63
+ "payment": [
64
+ "unpaid"
65
+ ]
66
+ },
67
+ "then": {
68
+ "payment": "captured"
69
+ }
70
+ }
71
+ ]
72
+ },
73
+ {
74
+ "id": "ship",
75
+ "label": "Ship the order",
76
+ "source": {
77
+ "kind": "code",
78
+ "path": "src/order.ts",
79
+ "symbol": "shipOrder"
80
+ },
81
+ "steps": [
82
+ {
83
+ "when": {
84
+ "order": [
85
+ "open"
86
+ ]
87
+ },
88
+ "then": {
89
+ "order": "shipped"
90
+ }
91
+ }
92
+ ]
93
+ },
94
+ {
95
+ "id": "cancel",
96
+ "label": "Cancel the order",
97
+ "source": {
98
+ "kind": "code",
99
+ "path": "src/order.ts",
100
+ "symbol": "cancelOrder"
101
+ },
102
+ "steps": [
103
+ {
104
+ "when": {
105
+ "order": [
106
+ "open"
107
+ ],
108
+ "payment": [
109
+ "unpaid"
110
+ ]
111
+ },
112
+ "then": {
113
+ "order": "cancelled"
114
+ }
115
+ },
116
+ {
117
+ "when": {
118
+ "order": [
119
+ "open"
120
+ ],
121
+ "payment": [
122
+ "captured"
123
+ ]
124
+ },
125
+ "then": {
126
+ "order": "cancelled",
127
+ "payment": "refunded"
128
+ }
129
+ }
130
+ ]
131
+ }
132
+ ],
133
+ "rules": [
134
+ {
135
+ "id": "paid-before-shipped",
136
+ "label": "An order never ships without a captured payment",
137
+ "never": {
138
+ "order": [
139
+ "shipped"
140
+ ],
141
+ "payment": [
142
+ "unpaid",
143
+ "refunded"
144
+ ]
145
+ }
146
+ },
147
+ {
148
+ "id": "closed-order-stays-closed",
149
+ "label": "A shipped or cancelled order never changes",
150
+ "final": {
151
+ "order": [
152
+ "shipped",
153
+ "cancelled"
154
+ ]
155
+ }
156
+ }
157
+ ]
158
+ }
@@ -30,6 +30,11 @@
30
30
  "coverage": "complete",
31
31
  "reasonCodes": []
32
32
  },
33
+ {
34
+ "check": "state-machines",
35
+ "coverage": "complete",
36
+ "reasonCodes": []
37
+ },
33
38
  {
34
39
  "check": "practices",
35
40
  "coverage": "complete",
@@ -38,7 +43,7 @@
38
43
  ],
39
44
  "items": [],
40
45
  "actionsRequired": [],
41
- "digest": "sha256:1d40d5a0b5f92e61241f310b1f0c26b342210533455707a93f524d306db88b4e"
46
+ "digest": "sha256:ceaaaf214aff4c0b05abe367cad2b58e52b25d2aeeb4809ebc0e101d34e66d09"
42
47
  },
43
48
  "hookLog": {
44
49
  "schemaVersion": "archcontext.hook-log/v1",
@@ -2,7 +2,7 @@
2
2
  "schemaVersion": "archcontext.product-version-manifest/v1",
3
3
  "product": {
4
4
  "name": "archctx",
5
- "version": "0.11.4",
5
+ "version": "0.13.0",
6
6
  "distribution": "one-package"
7
7
  },
8
8
  "packageManager": "bun@1.4.3",
@@ -12,29 +12,25 @@
12
12
  "surfaces": {
13
13
  "cli": {
14
14
  "packageName": "@archcontext/surfaces",
15
- "version": "0.11.4",
15
+ "version": "0.13.0",
16
16
  "entrypoint": "archctx"
17
17
  },
18
18
  "daemon": {
19
19
  "packageName": "@archcontext/local-runtime",
20
- "version": "0.11.4",
20
+ "version": "0.13.0",
21
21
  "entrypoint": "archctx daemon start",
22
22
  "rpcSchemaVersion": "archcontext.runtime-rpc/v2"
23
23
  },
24
24
  "mcp": {
25
25
  "packageName": "@archcontext/surfaces",
26
- "version": "0.11.4",
26
+ "version": "0.13.0",
27
27
  "entrypoint": "archctx mcp",
28
28
  "transport": "stdio"
29
29
  }
30
30
  },
31
31
  "schemas": {
32
32
  "schemaSetVersion": "2026-06-25.al0-ledger",
33
- "contractsPackageVersion": "0.11.4",
34
- "reviewChallenge": "archcontext.review-challenge/v2",
35
- "attestation": "archcontext.attestation/v2",
36
- "deviceIdentity": "archcontext.device-identity/v1",
37
- "runnerIdentity": "archcontext.runner-identity/v1"
33
+ "contractsPackageVersion": "0.13.0"
38
34
  },
39
35
  "runtime": {
40
36
  "localRpc": {
@@ -0,0 +1,76 @@
1
+ {
2
+ "schemaVersion": "archcontext.state-machine-check/v1",
3
+ "machines": [
4
+ {
5
+ "id": "state-machine.checkout.order",
6
+ "capabilityId": "capability.checkout",
7
+ "reachableStates": 6,
8
+ "transitions": 5,
9
+ "rules": [
10
+ {
11
+ "id": "paid-before-shipped",
12
+ "kind": "never",
13
+ "status": "broken",
14
+ "state": {
15
+ "order": "shipped",
16
+ "payment": "unpaid"
17
+ },
18
+ "path": [
19
+ {
20
+ "event": "ship",
21
+ "step": 1
22
+ }
23
+ ]
24
+ },
25
+ {
26
+ "id": "closed-order-stays-closed",
27
+ "kind": "final",
28
+ "status": "holds",
29
+ "protectedBy": [
30
+ {
31
+ "event": "ship",
32
+ "step": 1,
33
+ "region": "order"
34
+ },
35
+ {
36
+ "event": "cancel",
37
+ "step": 1,
38
+ "region": "order"
39
+ },
40
+ {
41
+ "event": "cancel",
42
+ "step": 2,
43
+ "region": "order"
44
+ }
45
+ ]
46
+ }
47
+ ],
48
+ "breaks": [],
49
+ "anchors": [
50
+ {
51
+ "owner": "event",
52
+ "ownerId": "capture",
53
+ "path": "src/payment.ts",
54
+ "symbol": "PaymentService.capture",
55
+ "status": "anchor-unconfirmed",
56
+ "digest": "sha256:1111111111111111111111111111111111111111111111111111111111111111"
57
+ },
58
+ {
59
+ "owner": "event",
60
+ "ownerId": "ship",
61
+ "path": "src/order.ts",
62
+ "symbol": "shipOrder",
63
+ "status": "anchor-unconfirmed",
64
+ "digest": "sha256:2222222222222222222222222222222222222222222222222222222222222222"
65
+ },
66
+ {
67
+ "owner": "event",
68
+ "ownerId": "cancel",
69
+ "path": "src/order.ts",
70
+ "symbol": "cancelOrder",
71
+ "status": "anchor-missing-symbol"
72
+ }
73
+ ]
74
+ }
75
+ ]
76
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "archctx-contracts",
3
- "version": "0.11.4",
3
+ "version": "0.13.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
@@ -0,0 +1,153 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://archctx.repoharness.com/schemas/repo/architecture-state-machine.schema.json",
4
+ "title": "ArchitectureStateMachineV1",
5
+ "description": "One state machine of a capability: parallel regions of states, events whose steps move them, and the rules that no reachable global state may break. Cross-entity rules (unknown regions and states, duplicate ids, the 100000 global state limit) are checked by stateMachineModelIssues.",
6
+ "type": "object",
7
+ "additionalProperties": false,
8
+ "required": ["schemaVersion", "id", "capabilityId", "name", "regions", "events", "rules"],
9
+ "properties": {
10
+ "schemaVersion": { "const": "archcontext.state-machine/v1" },
11
+ "id": { "type": "string", "pattern": "^state-machine\\.[a-z][a-z0-9-]*(\\.[a-z0-9][a-z0-9-]*)*$" },
12
+ "capabilityId": { "type": "string", "pattern": "^capability\\.[a-z][a-z0-9-]*(\\.[a-z0-9][a-z0-9-]*)*$" },
13
+ "name": { "$ref": "#/$defs/label" },
14
+ "regions": {
15
+ "type": "array",
16
+ "minItems": 1,
17
+ "items": {
18
+ "type": "object",
19
+ "additionalProperties": false,
20
+ "required": ["id", "label", "initial", "states"],
21
+ "properties": {
22
+ "id": { "$ref": "#/$defs/localId" },
23
+ "label": { "$ref": "#/$defs/label" },
24
+ "initial": { "$ref": "#/$defs/localId" },
25
+ "states": {
26
+ "type": "array",
27
+ "minItems": 1,
28
+ "items": {
29
+ "type": "object",
30
+ "additionalProperties": false,
31
+ "required": ["id", "label"],
32
+ "properties": {
33
+ "id": { "$ref": "#/$defs/localId" },
34
+ "label": { "$ref": "#/$defs/label" },
35
+ "terminal": { "type": "boolean" }
36
+ }
37
+ }
38
+ },
39
+ "source": { "$ref": "#/$defs/codeSource" }
40
+ }
41
+ }
42
+ },
43
+ "events": {
44
+ "type": "array",
45
+ "minItems": 1,
46
+ "items": {
47
+ "type": "object",
48
+ "additionalProperties": false,
49
+ "required": ["id", "label", "source", "steps"],
50
+ "properties": {
51
+ "id": { "$ref": "#/$defs/localId" },
52
+ "label": { "$ref": "#/$defs/label" },
53
+ "source": {
54
+ "if": { "required": ["kind"], "properties": { "kind": { "const": "code" } } },
55
+ "then": { "$ref": "#/$defs/codeSource" },
56
+ "else": { "$ref": "#/$defs/environmentSource" }
57
+ },
58
+ "steps": {
59
+ "type": "array",
60
+ "minItems": 1,
61
+ "items": {
62
+ "type": "object",
63
+ "additionalProperties": false,
64
+ "required": ["when", "then"],
65
+ "properties": {
66
+ "when": {
67
+ "type": "object",
68
+ "minProperties": 1,
69
+ "propertyNames": { "$ref": "#/$defs/localId" },
70
+ "additionalProperties": { "type": "array", "minItems": 1, "uniqueItems": true, "items": { "$ref": "#/$defs/localId" } }
71
+ },
72
+ "then": {
73
+ "type": "object",
74
+ "minProperties": 1,
75
+ "propertyNames": { "$ref": "#/$defs/localId" },
76
+ "additionalProperties": { "$ref": "#/$defs/localId" }
77
+ }
78
+ }
79
+ }
80
+ }
81
+ }
82
+ }
83
+ },
84
+ "rules": {
85
+ "type": "array",
86
+ "items": {
87
+ "type": "object",
88
+ "additionalProperties": false,
89
+ "required": ["id", "label"],
90
+ "oneOf": [{ "required": ["never"] }, { "required": ["final"] }],
91
+ "properties": {
92
+ "id": { "$ref": "#/$defs/localId" },
93
+ "label": { "$ref": "#/$defs/label" },
94
+ "never": {
95
+ "type": "object",
96
+ "minProperties": 2,
97
+ "propertyNames": { "$ref": "#/$defs/localId" },
98
+ "additionalProperties": { "$ref": "#/$defs/stateList" }
99
+ },
100
+ "final": {
101
+ "type": "object",
102
+ "minProperties": 1,
103
+ "maxProperties": 1,
104
+ "propertyNames": { "$ref": "#/$defs/localId" },
105
+ "additionalProperties": { "$ref": "#/$defs/stateList" }
106
+ },
107
+ "finding": {
108
+ "type": "object",
109
+ "additionalProperties": false,
110
+ "required": ["tracking"],
111
+ "properties": {
112
+ "tracking": { "type": "string", "pattern": "^https://[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?(?:\\.[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?)*(?::[0-9]{1,5})?(?:[/?#][^\\s|`]*)?$" }
113
+ }
114
+ }
115
+ }
116
+ }
117
+ }
118
+ },
119
+ "$defs": {
120
+ "localId": { "type": "string", "pattern": "^[a-z][a-z0-9]*(-[a-z0-9]+)*$" },
121
+ "label": {
122
+ "description": "One line of 1 to 80 characters with none of the characters that a statechart label would need to escape.",
123
+ "type": "string",
124
+ "minLength": 1,
125
+ "maxLength": 80,
126
+ "pattern": "^[^\"#;:<>\\\\|\\r\\n]+$"
127
+ },
128
+ "stateList": { "type": "array", "minItems": 1, "items": { "$ref": "#/$defs/localId" } },
129
+ "codeSource": {
130
+ "type": "object",
131
+ "additionalProperties": false,
132
+ "required": ["kind", "path"],
133
+ "properties": {
134
+ "kind": { "const": "code" },
135
+ "path": {
136
+ "description": "A canonical repository-relative POSIX path: no leading slash, backslash, empty, `.` or `..` segment, and no `|`, backtick or line break.",
137
+ "type": "string",
138
+ "pattern": "^(?!(?:.*/)?\\.\\.?(?:/|$))[^/\\\\|`\\r\\n]+(?:/[^/\\\\|`\\r\\n]+)*$"
139
+ },
140
+ "symbol": { "description": "One line with no `|` or backtick.", "type": "string", "pattern": "^[^|`\\r\\n]+$" },
141
+ "confirmedDigest": { "type": "string", "pattern": "^sha256:[0-9a-f]{64}$" }
142
+ }
143
+ },
144
+ "environmentSource": {
145
+ "type": "object",
146
+ "additionalProperties": false,
147
+ "required": ["kind"],
148
+ "properties": {
149
+ "kind": { "const": "environment" }
150
+ }
151
+ }
152
+ }
153
+ }
@@ -71,8 +71,8 @@
71
71
  },
72
72
  "checks": {
73
73
  "type": "array",
74
- "minItems": 5,
75
- "maxItems": 5,
74
+ "minItems": 6,
75
+ "maxItems": 6,
76
76
  "items": {
77
77
  "type": "object",
78
78
  "additionalProperties": false,
@@ -88,6 +88,7 @@
88
88
  "anchors",
89
89
  "dependencies",
90
90
  "flows",
91
+ "state-machines",
91
92
  "practices"
92
93
  ]
93
94
  },
@@ -137,7 +138,9 @@
137
138
  "undeclared-dependency",
138
139
  "flow-proof-failed",
139
140
  "stale-anchor",
140
- "practice-regression"
141
+ "practice-regression",
142
+ "state-machine-rule",
143
+ "state-machine-stale"
141
144
  ]
142
145
  },
143
146
  "nodeIds": {
@@ -58,14 +58,10 @@
58
58
  "schemas": {
59
59
  "type": "object",
60
60
  "additionalProperties": false,
61
- "required": ["schemaSetVersion", "contractsPackageVersion", "reviewChallenge", "attestation", "deviceIdentity", "runnerIdentity"],
61
+ "required": ["schemaSetVersion", "contractsPackageVersion"],
62
62
  "properties": {
63
63
  "schemaSetVersion": { "type": "string", "minLength": 1 },
64
- "contractsPackageVersion": { "$ref": "#/$defs/semver" },
65
- "reviewChallenge": { "const": "archcontext.review-challenge/v2" },
66
- "attestation": { "const": "archcontext.attestation/v2" },
67
- "deviceIdentity": { "const": "archcontext.device-identity/v1" },
68
- "runnerIdentity": { "const": "archcontext.runner-identity/v1" }
64
+ "contractsPackageVersion": { "$ref": "#/$defs/semver" }
69
65
  }
70
66
  },
71
67
  "runtime": {