@synapsor/runner 1.5.4 → 1.6.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 (42) hide show
  1. package/CHANGELOG.md +40 -2
  2. package/README.md +117 -124
  3. package/dist/authoring.mjs +405 -9
  4. package/dist/cli.d.ts.map +1 -1
  5. package/dist/local-ui.d.ts +2 -0
  6. package/dist/local-ui.d.ts.map +1 -1
  7. package/dist/runner.mjs +31036 -27581
  8. package/dist/runtime.mjs +10264 -8543
  9. package/docs/README.md +14 -6
  10. package/docs/aggregate-reads.md +22 -0
  11. package/docs/auto-boundary-and-scoped-explore.md +338 -0
  12. package/docs/capability-authoring.md +30 -0
  13. package/docs/conformance.md +16 -0
  14. package/docs/current-scope.md +55 -28
  15. package/docs/cursor-plugin.md +20 -3
  16. package/docs/dsl-reference.md +78 -0
  17. package/docs/getting-started-own-database.md +39 -35
  18. package/docs/limitations.md +24 -7
  19. package/docs/release-notes.md +37 -4
  20. package/docs/schema-api-candidates.md +28 -1
  21. package/docs/troubleshooting-first-run.md +98 -0
  22. package/examples/auto-boundary-churn/README.md +23 -0
  23. package/examples/auto-boundary-churn/app/page.tsx +8 -0
  24. package/examples/auto-boundary-churn/docker-compose.yml +16 -0
  25. package/examples/auto-boundary-churn/package.json +18 -0
  26. package/examples/auto-boundary-churn/prisma/schema.prisma +36 -0
  27. package/examples/auto-boundary-churn/seed/postgres.sql +126 -0
  28. package/fixtures/compatibility/published-1.5.4/manifest.json +76 -0
  29. package/fixtures/compatibility/published-1.5.4/sources/packages/dsl/examples/aggregate-read.synapsor.sql +21 -0
  30. package/fixtures/compatibility/published-1.5.4/sources/packages/dsl/examples/billing-late-fee.synapsor.sql +56 -0
  31. package/fixtures/compatibility/published-1.5.4/sources/packages/dsl/examples/bounded-set-multi-term.synapsor.sql +30 -0
  32. package/fixtures/compatibility/published-1.5.4/sources/packages/dsl/examples/principal-row-scope.synapsor.sql +23 -0
  33. package/fixtures/compatibility/published-1.5.4/sources/packages/spec/fixtures/conformance/aggregate-read/contract.json +119 -0
  34. package/fixtures/compatibility/published-1.5.4/sources/packages/spec/fixtures/conformance/approval-quorum/contract.json +44 -0
  35. package/fixtures/compatibility/published-1.5.4/sources/packages/spec/fixtures/conformance/bounded-set-threats/contract.json +115 -0
  36. package/fixtures/compatibility/published-1.5.4/sources/packages/spec/fixtures/conformance/principal-row-scope/contract.json +78 -0
  37. package/fixtures/compatibility/published-1.5.4/sources/packages/spec/fixtures/conformance/proposal-capability/contract.json +101 -0
  38. package/fixtures/compatibility/published-1.5.4/sources/packages/spec/fixtures/conformance/reversible-change-sets/contract.json +98 -0
  39. package/fixtures/compatibility/published-1.5.4/sources/packages/spec/fixtures/valid/basic-read.contract.json +60 -0
  40. package/llms.txt +37 -0
  41. package/package.json +7 -4
  42. package/schemas/synapsor.runner.schema.json +18 -1
@@ -0,0 +1,78 @@
1
+ {
2
+ "spec_version": "0.1",
3
+ "kind": "SynapsorContract",
4
+ "metadata": {
5
+ "name": "trusted principal row scope",
6
+ "description": "Tenant-additive row authority for two case managers in one hospital."
7
+ },
8
+ "contexts": [
9
+ {
10
+ "name": "care_session",
11
+ "bindings": [
12
+ {
13
+ "name": "hospital_id",
14
+ "source": "http_claim",
15
+ "key": "hospital_id",
16
+ "required": true
17
+ },
18
+ {
19
+ "name": "principal",
20
+ "source": "http_claim",
21
+ "key": "sub",
22
+ "required": true
23
+ }
24
+ ],
25
+ "tenant_binding": "hospital_id",
26
+ "principal_binding": "principal"
27
+ }
28
+ ],
29
+ "resources": [],
30
+ "capabilities": [
31
+ {
32
+ "name": "care.inspect_assigned_patient",
33
+ "description": "Inspect one patient assigned to the authenticated case manager within the trusted hospital.",
34
+ "returns_hint": "Returns reviewed patient fields and evidence only when both tenant and assignee locks match.",
35
+ "kind": "read",
36
+ "context": "care_session",
37
+ "source": "local_postgres",
38
+ "subject": {
39
+ "schema": "public",
40
+ "table": "patients",
41
+ "primary_key": "id",
42
+ "tenant_key": "hospital_id",
43
+ "principal_scope_key": "assigned_to",
44
+ "conflict_key": "updated_at"
45
+ },
46
+ "args": {
47
+ "patient_id": {
48
+ "type": "string",
49
+ "required": true,
50
+ "description": "Reviewed patient identifier.",
51
+ "max_length": 128
52
+ }
53
+ },
54
+ "lookup": {
55
+ "id_from_arg": "patient_id"
56
+ },
57
+ "visible_fields": [
58
+ "id",
59
+ "hospital_id",
60
+ "display_name",
61
+ "care_status",
62
+ "updated_at"
63
+ ],
64
+ "kept_out_fields": [
65
+ "assigned_to",
66
+ "diagnosis_notes",
67
+ "insurance_member_id"
68
+ ],
69
+ "evidence": {
70
+ "required": true,
71
+ "query_audit": true
72
+ },
73
+ "max_rows": 1
74
+ }
75
+ ],
76
+ "workflows": [],
77
+ "policies": []
78
+ }
@@ -0,0 +1,101 @@
1
+ {
2
+ "spec_version": "0.1",
3
+ "kind": "SynapsorContract",
4
+ "metadata": {
5
+ "name": "proposal capability conformance"
6
+ },
7
+ "resources": [
8
+ {
9
+ "name": "billing_invoices",
10
+ "engine": "postgres",
11
+ "schema": "public",
12
+ "table": "invoices",
13
+ "primary_key": "id",
14
+ "tenant_key": "tenant_id",
15
+ "conflict_key": "updated_at"
16
+ }
17
+ ],
18
+ "contexts": [
19
+ {
20
+ "name": "local_operator",
21
+ "bindings": [
22
+ {
23
+ "name": "tenant_id",
24
+ "source": "environment",
25
+ "key": "SYNAPSOR_TENANT_ID"
26
+ },
27
+ {
28
+ "name": "principal",
29
+ "source": "environment",
30
+ "key": "SYNAPSOR_PRINCIPAL"
31
+ }
32
+ ],
33
+ "tenant_binding": "tenant_id",
34
+ "principal_binding": "principal"
35
+ }
36
+ ],
37
+ "capabilities": [
38
+ {
39
+ "name": "billing.propose_late_fee_waiver",
40
+ "kind": "proposal",
41
+ "context": "local_operator",
42
+ "source": "local_postgres",
43
+ "subject": {
44
+ "resource": "billing_invoices"
45
+ },
46
+ "args": {
47
+ "invoice_id": {
48
+ "type": "string",
49
+ "required": true
50
+ },
51
+ "waiver_reason": {
52
+ "type": "string",
53
+ "required": true
54
+ }
55
+ },
56
+ "lookup": {
57
+ "id_from_arg": "invoice_id"
58
+ },
59
+ "visible_fields": [
60
+ "id",
61
+ "tenant_id",
62
+ "late_fee_cents",
63
+ "waiver_reason",
64
+ "updated_at"
65
+ ],
66
+ "kept_out_fields": [
67
+ "card_token"
68
+ ],
69
+ "evidence": {
70
+ "required": true,
71
+ "query_audit": true
72
+ },
73
+ "max_rows": 1,
74
+ "proposal": {
75
+ "action": "billing.waive_late_fee",
76
+ "allowed_fields": [
77
+ "late_fee_cents",
78
+ "waiver_reason"
79
+ ],
80
+ "patch": {
81
+ "late_fee_cents": {
82
+ "fixed": 0
83
+ },
84
+ "waiver_reason": {
85
+ "from_arg": "waiver_reason"
86
+ }
87
+ },
88
+ "conflict_guard": {
89
+ "column": "updated_at"
90
+ },
91
+ "approval": {
92
+ "mode": "human",
93
+ "required_role": "billing_lead"
94
+ },
95
+ "writeback": {
96
+ "mode": "direct_sql"
97
+ }
98
+ }
99
+ }
100
+ ]
101
+ }
@@ -0,0 +1,98 @@
1
+ {
2
+ "spec_version": "0.1",
3
+ "kind": "SynapsorContract",
4
+ "metadata": {
5
+ "name": "reviewed-reversible-change-sets",
6
+ "version": "1.4.0"
7
+ },
8
+ "contexts": [
9
+ {
10
+ "name": "trusted_operator",
11
+ "bindings": [
12
+ { "name": "tenant_id", "source": "environment", "key": "SYNAPSOR_TENANT_ID", "required": true },
13
+ { "name": "principal", "source": "environment", "key": "SYNAPSOR_PRINCIPAL", "required": true }
14
+ ],
15
+ "tenant_binding": "tenant_id",
16
+ "principal_binding": "principal"
17
+ }
18
+ ],
19
+ "capabilities": [
20
+ {
21
+ "name": "billing.adjust_credit",
22
+ "kind": "proposal",
23
+ "context": "trusted_operator",
24
+ "source": "local_postgres",
25
+ "subject": {
26
+ "schema": "public",
27
+ "table": "account_credits",
28
+ "primary_key": "id",
29
+ "tenant_key": "tenant_id",
30
+ "conflict_key": "version"
31
+ },
32
+ "args": {
33
+ "credit_id": { "type": "string", "required": true, "max_length": 128 },
34
+ "amount_cents": { "type": "number", "required": true, "minimum": 0, "maximum": 2500 }
35
+ },
36
+ "lookup": { "id_from_arg": "credit_id" },
37
+ "visible_fields": ["id", "tenant_id", "amount_cents", "version"],
38
+ "kept_out_fields": ["internal_note"],
39
+ "evidence": { "required": true, "query_audit": true },
40
+ "proposal": {
41
+ "action": "adjust_credit",
42
+ "operation": {
43
+ "kind": "update",
44
+ "cardinality": "single",
45
+ "version_advance": { "column": "version", "strategy": "integer_increment" }
46
+ },
47
+ "allowed_fields": ["amount_cents"],
48
+ "patch": { "amount_cents": { "from_arg": "amount_cents" } },
49
+ "numeric_bounds": { "amount_cents": { "minimum": 0, "maximum": 2500 } },
50
+ "reversibility": { "mode": "reviewed_inverse" },
51
+ "conflict_guard": { "column": "version" },
52
+ "approval": { "mode": "human", "required_role": "billing_reviewer", "required_approvals": 2 },
53
+ "writeback": { "mode": "direct_sql" }
54
+ }
55
+ },
56
+ {
57
+ "name": "billing.create_credit",
58
+ "kind": "proposal",
59
+ "context": "trusted_operator",
60
+ "source": "local_postgres",
61
+ "subject": {
62
+ "schema": "public",
63
+ "table": "account_credits",
64
+ "primary_key": "id",
65
+ "tenant_key": "tenant_id"
66
+ },
67
+ "args": {
68
+ "amount_cents": { "type": "number", "required": true, "minimum": 1, "maximum": 2500 },
69
+ "reason": { "type": "string", "required": true, "max_length": 500 }
70
+ },
71
+ "visible_fields": ["id", "tenant_id", "amount_cents", "reason"],
72
+ "kept_out_fields": ["internal_note"],
73
+ "evidence": { "required": true, "query_audit": true },
74
+ "proposal": {
75
+ "action": "create_credit",
76
+ "operation": {
77
+ "kind": "insert",
78
+ "cardinality": "single",
79
+ "deduplication": {
80
+ "components": [
81
+ { "column": "tenant_id", "source": "trusted_tenant" },
82
+ { "column": "id", "source": "proposal_id" }
83
+ ]
84
+ }
85
+ },
86
+ "allowed_fields": ["amount_cents", "reason"],
87
+ "patch": {
88
+ "amount_cents": { "from_arg": "amount_cents" },
89
+ "reason": { "from_arg": "reason" }
90
+ },
91
+ "numeric_bounds": { "amount_cents": { "minimum": 1, "maximum": 2500 } },
92
+ "reversibility": { "mode": "reviewed_inverse" },
93
+ "approval": { "mode": "human", "required_role": "billing_reviewer" },
94
+ "writeback": { "mode": "direct_sql" }
95
+ }
96
+ }
97
+ ]
98
+ }
@@ -0,0 +1,60 @@
1
+ {
2
+ "spec_version": "0.1",
3
+ "kind": "SynapsorContract",
4
+ "contexts": [
5
+ {
6
+ "name": "local_operator",
7
+ "bindings": [
8
+ {
9
+ "name": "tenant_id",
10
+ "source": "environment",
11
+ "key": "SYNAPSOR_TENANT_ID"
12
+ },
13
+ {
14
+ "name": "principal",
15
+ "source": "environment",
16
+ "key": "SYNAPSOR_PRINCIPAL"
17
+ }
18
+ ],
19
+ "tenant_binding": "tenant_id",
20
+ "principal_binding": "principal"
21
+ }
22
+ ],
23
+ "capabilities": [
24
+ {
25
+ "name": "billing.inspect_invoice",
26
+ "kind": "read",
27
+ "context": "local_operator",
28
+ "subject": {
29
+ "schema": "public",
30
+ "table": "invoices",
31
+ "primary_key": "id",
32
+ "tenant_key": "tenant_id",
33
+ "conflict_key": "updated_at"
34
+ },
35
+ "args": {
36
+ "invoice_id": {
37
+ "type": "string",
38
+ "required": true
39
+ }
40
+ },
41
+ "lookup": {
42
+ "id_from_arg": "invoice_id"
43
+ },
44
+ "visible_fields": [
45
+ "id",
46
+ "tenant_id",
47
+ "late_fee_cents",
48
+ "updated_at"
49
+ ],
50
+ "kept_out_fields": [
51
+ "card_token"
52
+ ],
53
+ "evidence": {
54
+ "required": true,
55
+ "query_audit": true
56
+ },
57
+ "max_rows": 1
58
+ }
59
+ ]
60
+ }
package/llms.txt ADDED
@@ -0,0 +1,37 @@
1
+ # Synapsor Runner
2
+
3
+ Synapsor Runner is the Apache-2.0 MCP runtime that gives AI agents reviewed
4
+ Postgres/MySQL business capabilities instead of raw SQL. Credentials, trusted
5
+ tenant/principal identity, activation, approval, and commit stay outside the
6
+ model-facing tool surface.
7
+
8
+ Start here:
9
+ - README: https://github.com/Synapsor/Synapsor-Runner
10
+ - Auto Boundary, Scoped Explore, and Protect: https://github.com/Synapsor/Synapsor-Runner/blob/main/docs/auto-boundary-and-scoped-explore.md
11
+ - Connect a staging database: https://github.com/Synapsor/Synapsor-Runner/blob/main/docs/getting-started-own-database.md
12
+ - Security boundary: https://github.com/Synapsor/Synapsor-Runner/blob/main/docs/security-boundary.md
13
+ - Current scope: https://github.com/Synapsor/Synapsor-Runner/blob/main/docs/current-scope.md
14
+ - Current limitations: https://github.com/Synapsor/Synapsor-Runner/blob/main/docs/limitations.md
15
+ - DSL reference: https://github.com/Synapsor/Synapsor-Runner/blob/main/docs/dsl-reference.md
16
+ - MCP audit: https://github.com/Synapsor/Synapsor-Runner/blob/main/docs/mcp-audit.md
17
+
18
+ Current adoption loop:
19
+ Connect staging -> deterministic whole-schema draft -> human boundary review ->
20
+ bounded row or PM-style aggregate Explore in local Cursor -> Protect This Query
21
+ -> digest-bound human activation -> named production capability -> proposal ->
22
+ external approval -> guarded commit -> receipt and replay.
23
+
24
+ Important boundaries:
25
+ - No raw SQL or SQL-string tool argument.
26
+ - Scoped Explore is disabled by default and is local development/staging
27
+ authoring only. Production and shared/remote HTTP never advertise it.
28
+ - Aggregate Explore is a reviewed analytical cube: approved measures,
29
+ dimensions, time buckets, filters, at most one proven many-to-one path,
30
+ suppression, and extraction/differencing budgets.
31
+ - Auto Boundary and Protect are deterministic and use no LLM.
32
+ - Generated authority starts disabled. The model cannot activate, approve,
33
+ apply, commit, or widen it.
34
+ - Existing hand-authored 1.x contracts and established CLI routes do not
35
+ require Auto Boundary, Workbench, rescanning, or generation locks.
36
+ - Rich multi-table transactions and external side effects remain app-owned
37
+ executor work after approval.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synapsor/runner",
3
- "version": "1.5.4",
3
+ "version": "1.6.0",
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",
@@ -40,6 +40,7 @@
40
40
  "docs/**/*.md",
41
41
  "examples/dangerous-mcp-tools.json",
42
42
  "examples/app-owned-writeback/**",
43
+ "examples/auto-boundary-churn/**",
43
44
  "examples/claude-desktop-postgres/**",
44
45
  "examples/cursor-postgres/**",
45
46
  "examples/mcp-postgres-billing-app-handler/**",
@@ -62,7 +63,8 @@
62
63
  "LICENSE",
63
64
  "NOTICE",
64
65
  "THREAT_MODEL.md",
65
- "TRADEMARKS.md"
66
+ "TRADEMARKS.md",
67
+ "llms.txt"
66
68
  ],
67
69
  "keywords": [
68
70
  "mcp",
@@ -83,7 +85,6 @@
83
85
  },
84
86
  "dependencies": {
85
87
  "@modelcontextprotocol/sdk": "1.29.0",
86
- "@synapsor/spec": "^1.4.2",
87
88
  "jose": "6.2.3",
88
89
  "mysql2": "^3.11.0",
89
90
  "pdf-lib": "1.17.1",
@@ -92,9 +93,11 @@
92
93
  "vscode-languageserver": "9.0.1",
93
94
  "vscode-languageserver-textdocument": "1.0.12",
94
95
  "yaml": "2.8.3",
95
- "zod": "^3.25.0"
96
+ "zod": "^3.25.0",
97
+ "@synapsor/spec": "^1.5.0"
96
98
  },
97
99
  "devDependencies": {
100
+ "@types/pg": "^8.11.0",
98
101
  "ajv": "^8.17.1",
99
102
  "vitest": "^3.2.0"
100
103
  },
@@ -132,6 +132,23 @@
132
132
  "minLength": 1
133
133
  }
134
134
  },
135
+ "generated_authority": {
136
+ "description": "Opt-in fail-closed drift enforcement for Auto Boundary and Protect This Query output. Legacy/manual projects omit this object and are not scanned.",
137
+ "type": "object",
138
+ "additionalProperties": false,
139
+ "required": ["generation_lock_path", "enforcement"],
140
+ "properties": {
141
+ "generation_lock_path": {
142
+ "description": "Local generation-lock file. Relative paths resolve from this config file's directory.",
143
+ "type": "string",
144
+ "minLength": 1,
145
+ "not": { "pattern": "://" }
146
+ },
147
+ "enforcement": {
148
+ "const": "required"
149
+ }
150
+ }
151
+ },
135
152
  "capabilities": {
136
153
  "description": "Embedded compatibility capabilities. May be empty when contracts supplies the capability catalog.",
137
154
  "type": "array",
@@ -488,7 +505,7 @@
488
505
  {
489
506
  "type": "object",
490
507
  "additionalProperties": false,
491
- "required": ["mode", "tenant_setting", "principal_setting"],
508
+ "required": ["mode", "tenant_setting"],
492
509
  "properties": {
493
510
  "mode": { "const": "postgres_rls" },
494
511
  "tenant_setting": {