@synapsor/runner 1.6.0 → 1.6.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 (55) hide show
  1. package/CHANGELOG.md +32 -4
  2. package/README.md +16 -2
  3. package/dist/cli.d.ts.map +1 -1
  4. package/dist/local-ui.d.ts +4 -1
  5. package/dist/local-ui.d.ts.map +1 -1
  6. package/dist/runner.mjs +1624 -42
  7. package/dist/runtime.mjs +1011 -25
  8. package/dist/shadow.mjs +408 -15
  9. package/docs/app-owned-executors.md +8 -0
  10. package/docs/capability-authoring.md +45 -0
  11. package/docs/current-scope.md +5 -0
  12. package/docs/cursor-plugin.md +2 -2
  13. package/docs/limitations.md +15 -2
  14. package/docs/local-mode.md +22 -3
  15. package/docs/production.md +19 -0
  16. package/docs/proposal-evidence-freshness.md +334 -0
  17. package/docs/release-notes.md +30 -4
  18. package/docs/runner-config-reference.md +46 -0
  19. package/docs/security-boundary.md +17 -0
  20. package/docs/store-lifecycle.md +8 -0
  21. package/docs/troubleshooting-first-run.md +76 -0
  22. package/docs/writeback-executors.md +8 -0
  23. package/examples/app-owned-writeback/command-handler.mjs +0 -0
  24. package/examples/mcp-postgres-billing-app-handler/scripts/run-demo.sh +0 -0
  25. package/examples/reference-support-billing-app/scripts/run-demo.sh +0 -0
  26. package/examples/support-billing-agent/scripts/run-demo.sh +0 -0
  27. package/examples/support-billing-agent/scripts/run-evaluation.sh +0 -0
  28. package/fixtures/compatibility/published-1.6.0/manifest.json +76 -0
  29. package/fixtures/compatibility/published-1.6.0/sources/packages/dsl/examples/aggregate-read.synapsor.sql +21 -0
  30. package/fixtures/compatibility/published-1.6.0/sources/packages/dsl/examples/billing-late-fee.synapsor.sql +56 -0
  31. package/fixtures/compatibility/published-1.6.0/sources/packages/dsl/examples/bounded-set-multi-term.synapsor.sql +30 -0
  32. package/fixtures/compatibility/published-1.6.0/sources/packages/dsl/examples/principal-row-scope.synapsor.sql +23 -0
  33. package/fixtures/compatibility/published-1.6.0/sources/packages/spec/fixtures/conformance/aggregate-read/contract.json +119 -0
  34. package/fixtures/compatibility/published-1.6.0/sources/packages/spec/fixtures/conformance/approval-quorum/contract.json +44 -0
  35. package/fixtures/compatibility/published-1.6.0/sources/packages/spec/fixtures/conformance/bounded-set-threats/contract.json +115 -0
  36. package/fixtures/compatibility/published-1.6.0/sources/packages/spec/fixtures/conformance/principal-row-scope/contract.json +78 -0
  37. package/fixtures/compatibility/published-1.6.0/sources/packages/spec/fixtures/conformance/proposal-capability/contract.json +101 -0
  38. package/fixtures/compatibility/published-1.6.0/sources/packages/spec/fixtures/conformance/reversible-change-sets/contract.json +98 -0
  39. package/fixtures/compatibility/published-1.6.0/sources/packages/spec/fixtures/valid/basic-read.contract.json +60 -0
  40. package/fixtures/protocol/MANIFEST.json +37 -7
  41. package/fixtures/protocol/change-set.freshness-update.v2.json +58 -0
  42. package/fixtures/protocol/freshness-authority.invoice.v1.json +35 -0
  43. package/fixtures/protocol/freshness-proof.fresh.v1.json +38 -0
  44. package/fixtures/protocol/writeback-job.freshness-update.v2.json +50 -0
  45. package/llms.txt +1 -0
  46. package/package.json +9 -8
  47. package/schemas/change-set.v1.schema.json +1 -0
  48. package/schemas/change-set.v2.schema.json +1 -0
  49. package/schemas/change-set.v3.schema.json +1 -0
  50. package/schemas/freshness-authority.v1.schema.json +89 -0
  51. package/schemas/freshness-proof.v1.schema.json +73 -0
  52. package/schemas/synapsor.runner.schema.json +32 -0
  53. package/schemas/writeback-job.v1.schema.json +1 -0
  54. package/schemas/writeback-job.v2.schema.json +1 -0
  55. package/schemas/writeback-job.v3.schema.json +1 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synapsor/runner",
3
- "version": "1.6.0",
3
+ "version": "1.6.1",
4
4
  "description": "Stop giving AI agents execute_sql; expose reviewed Postgres/MySQL MCP actions with proposals, approval, writeback, and replay.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -83,8 +83,14 @@
83
83
  "engines": {
84
84
  "node": ">=22.13.0"
85
85
  },
86
+ "scripts": {
87
+ "build": "tsc -b && node ../../scripts/build-runner-package.mjs",
88
+ "prepack": "cd ../.. && corepack pnpm build:runner-package",
89
+ "test": "vitest run"
90
+ },
86
91
  "dependencies": {
87
92
  "@modelcontextprotocol/sdk": "1.29.0",
93
+ "@synapsor/spec": "workspace:^",
88
94
  "jose": "6.2.3",
89
95
  "mysql2": "^3.11.0",
90
96
  "pdf-lib": "1.17.1",
@@ -93,8 +99,7 @@
93
99
  "vscode-languageserver": "9.0.1",
94
100
  "vscode-languageserver-textdocument": "1.0.12",
95
101
  "yaml": "2.8.3",
96
- "zod": "^3.25.0",
97
- "@synapsor/spec": "^1.5.0"
102
+ "zod": "^3.25.0"
98
103
  },
99
104
  "devDependencies": {
100
105
  "@types/pg": "^8.11.0",
@@ -111,9 +116,5 @@
111
116
  },
112
117
  "publishConfig": {
113
118
  "access": "public"
114
- },
115
- "scripts": {
116
- "build": "tsc -b && node ../../scripts/build-runner-package.mjs",
117
- "test": "vitest run"
118
119
  }
119
- }
120
+ }
@@ -80,6 +80,7 @@
80
80
  "expected_version": { "$ref": "#/$defs/columnValue" }
81
81
  }
82
82
  },
83
+ "freshness": { "$ref": "https://schemas.synapsor.ai/synapsor.freshness-authority.v1.schema.json" },
83
84
  "evidence": {
84
85
  "type": "object",
85
86
  "additionalProperties": true,
@@ -92,6 +92,7 @@
92
92
  "deduplication": { "$ref": "#/$defs/deduplication" }
93
93
  }
94
94
  },
95
+ "freshness": { "$ref": "https://schemas.synapsor.ai/synapsor.freshness-authority.v1.schema.json" },
95
96
  "evidence": {
96
97
  "type": "object",
97
98
  "additionalProperties": true,
@@ -42,6 +42,7 @@
42
42
  "version_advance": { "$ref": "#/$defs/versionAdvance" }
43
43
  }
44
44
  },
45
+ "freshness": { "$ref": "https://schemas.synapsor.ai/synapsor.freshness-authority.v1.schema.json" },
45
46
  "frozen_set": { "$ref": "#/$defs/frozenSet" },
46
47
  "evidence": {
47
48
  "type": "object", "additionalProperties": true, "required": ["bundle_id", "query_fingerprint", "items"],
@@ -0,0 +1,89 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://schemas.synapsor.ai/synapsor.freshness-authority.v1.schema.json",
4
+ "title": "Synapsor Freshness Authority v1",
5
+ "description": "Reviewed, immutable authority for target and supporting-row freshness checks. Digests are validated by the protocol runtime.",
6
+ "type": "object",
7
+ "additionalProperties": false,
8
+ "required": ["schema_version", "required", "target", "dependencies", "dependency_set_digest"],
9
+ "properties": {
10
+ "schema_version": { "const": "synapsor.freshness-authority.v1" },
11
+ "required": { "const": true },
12
+ "target": {
13
+ "type": "object",
14
+ "additionalProperties": false,
15
+ "required": ["mode", "member_count"],
16
+ "properties": {
17
+ "mode": { "enum": ["exact_guard", "frozen_set", "not_applicable"] },
18
+ "member_count": { "type": "integer", "minimum": 0, "maximum": 100 }
19
+ }
20
+ },
21
+ "dependencies": {
22
+ "type": "array",
23
+ "maxItems": 16,
24
+ "items": { "$ref": "#/$defs/dependency" }
25
+ },
26
+ "dependency_set_digest": { "$ref": "#/$defs/sha256" }
27
+ },
28
+ "$defs": {
29
+ "safeIdentifier": { "type": "string", "pattern": "^[A-Za-z_][A-Za-z0-9_]*$" },
30
+ "capabilityName": {
31
+ "type": "string",
32
+ "pattern": "^[A-Za-z_][A-Za-z0-9_.-]*\\.[A-Za-z_][A-Za-z0-9_.-]*$"
33
+ },
34
+ "sha256": { "type": "string", "pattern": "^sha256:.+" },
35
+ "scalar": { "type": ["string", "number", "boolean", "null"] },
36
+ "columnValue": {
37
+ "type": "object",
38
+ "additionalProperties": false,
39
+ "required": ["column", "value"],
40
+ "properties": {
41
+ "column": { "$ref": "#/$defs/safeIdentifier" },
42
+ "value": { "$ref": "#/$defs/scalar" }
43
+ }
44
+ },
45
+ "dependency": {
46
+ "type": "object",
47
+ "additionalProperties": false,
48
+ "required": [
49
+ "id",
50
+ "capability",
51
+ "source_id",
52
+ "engine",
53
+ "target",
54
+ "expected_version",
55
+ "evidence",
56
+ "descriptor_digest"
57
+ ],
58
+ "properties": {
59
+ "id": { "$ref": "#/$defs/safeIdentifier" },
60
+ "capability": { "$ref": "#/$defs/capabilityName" },
61
+ "source_id": { "type": "string", "minLength": 1, "maxLength": 160 },
62
+ "engine": { "enum": ["postgres", "mysql"] },
63
+ "target": {
64
+ "type": "object",
65
+ "additionalProperties": false,
66
+ "required": ["schema", "table", "primary_key", "tenant_column"],
67
+ "properties": {
68
+ "schema": { "$ref": "#/$defs/safeIdentifier" },
69
+ "table": { "$ref": "#/$defs/safeIdentifier" },
70
+ "primary_key": { "$ref": "#/$defs/columnValue" },
71
+ "tenant_column": { "$ref": "#/$defs/safeIdentifier" },
72
+ "principal_column": { "$ref": "#/$defs/safeIdentifier" }
73
+ }
74
+ },
75
+ "expected_version": { "$ref": "#/$defs/columnValue" },
76
+ "evidence": {
77
+ "type": "object",
78
+ "additionalProperties": false,
79
+ "required": ["bundle_id", "query_fingerprint"],
80
+ "properties": {
81
+ "bundle_id": { "type": "string", "minLength": 1, "maxLength": 200 },
82
+ "query_fingerprint": { "$ref": "#/$defs/sha256" }
83
+ }
84
+ },
85
+ "descriptor_digest": { "$ref": "#/$defs/sha256" }
86
+ }
87
+ }
88
+ }
89
+ }
@@ -0,0 +1,73 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://schemas.synapsor.ai/synapsor.freshness-proof.v1.schema.json",
4
+ "title": "Synapsor Freshness Proof v1",
5
+ "description": "Bounded immutable result of a live freshness preflight. Digest and cross-field integrity are validated by the protocol runtime.",
6
+ "type": "object",
7
+ "additionalProperties": false,
8
+ "required": [
9
+ "schema_version",
10
+ "proposal_id",
11
+ "proposal_hash",
12
+ "proposal_version",
13
+ "dependency_set_digest",
14
+ "checked_at",
15
+ "valid_until",
16
+ "source_adapters",
17
+ "result",
18
+ "safe_code",
19
+ "target_count",
20
+ "supporting_count",
21
+ "checks",
22
+ "proof_digest"
23
+ ],
24
+ "properties": {
25
+ "schema_version": { "const": "synapsor.freshness-proof.v1" },
26
+ "proposal_id": { "type": "string", "minLength": 1 },
27
+ "proposal_hash": { "$ref": "#/$defs/sha256" },
28
+ "proposal_version": { "type": "integer", "minimum": 1 },
29
+ "dependency_set_digest": { "$ref": "#/$defs/sha256" },
30
+ "checked_at": { "type": "string", "format": "date-time" },
31
+ "valid_until": { "type": "string", "format": "date-time" },
32
+ "source_adapters": {
33
+ "type": "array",
34
+ "minItems": 1,
35
+ "maxItems": 8,
36
+ "items": {
37
+ "type": "object",
38
+ "additionalProperties": false,
39
+ "required": ["source_id", "engine"],
40
+ "properties": {
41
+ "source_id": { "type": "string", "minLength": 1, "maxLength": 160 },
42
+ "engine": { "enum": ["postgres", "mysql"] }
43
+ }
44
+ }
45
+ },
46
+ "result": { "enum": ["fresh", "stale", "unavailable", "invalid", "unsupported"] },
47
+ "safe_code": { "$ref": "#/$defs/safeCode" },
48
+ "target_count": { "type": "integer", "minimum": 0, "maximum": 100 },
49
+ "supporting_count": { "type": "integer", "minimum": 0, "maximum": 16 },
50
+ "checks": {
51
+ "type": "array",
52
+ "maxItems": 116,
53
+ "items": {
54
+ "type": "object",
55
+ "additionalProperties": false,
56
+ "required": ["id", "kind", "status", "safe_code"],
57
+ "properties": {
58
+ "id": { "type": "string", "minLength": 1, "maxLength": 160 },
59
+ "kind": { "enum": ["target", "supporting"] },
60
+ "status": { "enum": ["fresh", "stale", "not_applicable", "unavailable", "invalid", "unsupported"] },
61
+ "safe_code": { "$ref": "#/$defs/safeCode" },
62
+ "expected_version_digest": { "$ref": "#/$defs/sha256" },
63
+ "observed_version_digest": { "$ref": "#/$defs/sha256" }
64
+ }
65
+ }
66
+ },
67
+ "proof_digest": { "$ref": "#/$defs/sha256" }
68
+ },
69
+ "$defs": {
70
+ "sha256": { "type": "string", "pattern": "^sha256:.+" },
71
+ "safeCode": { "type": "string", "pattern": "^[A-Z][A-Z0-9_]*$" }
72
+ }
73
+ }
@@ -162,6 +162,38 @@
162
162
  "type": "array",
163
163
  "items": { "$ref": "#/$defs/policy" }
164
164
  },
165
+ "proposal_freshness": {
166
+ "description": "Optional fail-closed live freshness policy for reviewed proposal capabilities. The model cannot configure or widen these dependencies.",
167
+ "type": "object",
168
+ "propertyNames": { "$ref": "#/$defs/qualified_name" },
169
+ "additionalProperties": {
170
+ "type": "object",
171
+ "additionalProperties": false,
172
+ "required": ["approval"],
173
+ "properties": {
174
+ "approval": {
175
+ "description": "Require a live source freshness proof immediately before every approval decision.",
176
+ "const": "required"
177
+ },
178
+ "dependencies": {
179
+ "description": "Reviewed same-source single-row reads whose exact versions must still match at approval and apply.",
180
+ "type": "array",
181
+ "maxItems": 16,
182
+ "items": {
183
+ "type": "object",
184
+ "additionalProperties": false,
185
+ "required": ["id", "capability", "identity_from_arg", "version_column"],
186
+ "properties": {
187
+ "id": { "$ref": "#/$defs/identifier" },
188
+ "capability": { "$ref": "#/$defs/qualified_name" },
189
+ "identity_from_arg": { "$ref": "#/$defs/identifier" },
190
+ "version_column": { "$ref": "#/$defs/identifier" }
191
+ }
192
+ }
193
+ }
194
+ }
195
+ }
196
+ },
165
197
  "approvals": {
166
198
  "description": "Local approval behavior overrides.",
167
199
  "type": "object",
@@ -88,6 +88,7 @@
88
88
  }
89
89
  ]
90
90
  },
91
+ "freshness": { "$ref": "https://schemas.synapsor.ai/synapsor.freshness-authority.v1.schema.json" },
91
92
  "idempotency_key": { "type": "string", "minLength": 1 },
92
93
  "lease": {
93
94
  "type": "object",
@@ -118,6 +118,7 @@
118
118
  }
119
119
  ]
120
120
  },
121
+ "freshness": { "$ref": "https://schemas.synapsor.ai/synapsor.freshness-authority.v1.schema.json" },
121
122
  "idempotency_key": { "type": "string", "minLength": 1 },
122
123
  "lease": {
123
124
  "type": "object",
@@ -21,6 +21,7 @@
21
21
  "patch": { "$ref": "#/$defs/scalarRecord" },
22
22
  "version_advance": { "$ref": "#/$defs/versionAdvance" },
23
23
  "frozen_set": { "$ref": "#/$defs/frozenSet" },
24
+ "freshness": { "$ref": "https://schemas.synapsor.ai/synapsor.freshness-authority.v1.schema.json" },
24
25
  "idempotency_key": { "type": "string", "minLength": 1 },
25
26
  "lease": { "type": "object", "additionalProperties": false, "required": ["lease_id", "attempt", "expires_at"], "properties": { "lease_id": { "type": "string", "minLength": 1 }, "attempt": { "type": "integer", "minimum": 1 }, "expires_at": { "type": "string", "format": "date-time" } } }
26
27
  },