@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
package/CHANGELOG.md CHANGED
@@ -1,6 +1,44 @@
1
1
  # Changelog
2
2
 
3
- ## 1.5.4 (prepared, not published)
3
+ ## 1.6.0 (prepared, not published)
4
+
5
+ ### Connect, Explore, Protect
6
+
7
+ - Adds deterministic whole-schema Auto Boundary drafting from database
8
+ metadata, statically parsed Prisma/Drizzle schemas, OpenAPI documents, and
9
+ existing Synapsor definitions. It executes no adopter code, samples no source
10
+ rows before activation, uses no LLM, and emits only disabled public DSL,
11
+ canonical JSON, tests, review evidence, and a generation lock.
12
+ - Adds a secured local Workbench review for trusted tenant/principal scope,
13
+ visible and kept-out fields, typed filters, aggregate-safe measures,
14
+ `count_distinct`, reviewed dimensions and time buckets, one-hop
15
+ relationships, cohort suppression, privacy/query budgets, and exact
16
+ role/grant/RLS posture. Activation binds every decision to one immutable
17
+ digest.
18
+ - Adds authoring-only Scoped Explore through exactly `app.describe_data` and
19
+ `app.explore_data`. Row and PM-style aggregate plans contain no SQL or
20
+ arbitrary identifiers, run with verified read-only credentials and enforced
21
+ read-only transactions, and retain only normalized redacted audit metadata.
22
+ - Adds a deliberately small aggregate grammar for counts, reviewed distinct
23
+ identifiers, sums/averages, categorical dimensions, day/week/month buckets,
24
+ bounded comparisons and top-N, optional proven many-to-one relationships,
25
+ cohort suppression, and durable extraction/differencing/rate budgets.
26
+ - Adds Protect This Query. Workbench freezes a successful plan into public
27
+ `.synapsor.sql`, canonical `protected_read` authority, positive/deny/scope/
28
+ suppression/drift tests, and a disabled named capability. Human exact-digest
29
+ activation removes broad Explore while preserving the named production tool.
30
+ - Adds lock-bound schema/role/grant/ownership/RLS/compiler/Spec drift checks.
31
+ Additive schema fields receive no authority; breaking generated-authority
32
+ drift fails closed until regeneration and review.
33
+ - Preserves published 1.x contracts, exact legacy normalization/digests,
34
+ established CLI selectors and automation, active tools, TypeScript authoring,
35
+ manual/headless operation, guarded writes, Data PRs, app-owned executors, and
36
+ deployments without generation locks through packed compatibility fixtures.
37
+ - Prepares `@synapsor/runner@1.6.0`, `@synapsor/dsl@1.5.0`, and
38
+ `@synapsor/spec@1.5.0`. Nothing is published, tagged, pushed, or released by
39
+ this change.
40
+
41
+ ## 1.5.4 (published 2026-07-22)
4
42
 
5
43
  ### Networked MCP authentication hardening
6
44
 
@@ -39,7 +77,7 @@
39
77
  boundary while making Runner fail closed with
40
78
  `SESSION_BINDING_UNSUPPORTED`. Runner-targeted DSL validation, contract load,
41
79
  lint/explain, and runtime no longer allow an environment fallback.
42
- - Prepares `@synapsor/runner@1.5.4` and `@synapsor/dsl@1.4.4`;
80
+ - Published `@synapsor/runner@1.5.4` and `@synapsor/dsl@1.4.4`;
43
81
  `@synapsor/spec@1.4.2` and the Cloud CLI remain unchanged.
44
82
 
45
83
  ## 1.5.3 (published 2026-07-21)
package/README.md CHANGED
@@ -37,118 +37,148 @@ Review happens outside model-facing tools. State is stored under
37
37
  `./.synapsor/try/`; this proves the boundary, not your database connection.
38
38
  `demo --quick` remains a noninteractive compatibility alias.
39
39
 
40
- ## Protect One Action In Your Application
40
+ ## Audit An Existing MCP Server
41
+
42
+ Audit a typical raw-SQL MCP server without launching or calling one:
43
+
44
+ ```bash
45
+ npx -y @synapsor/runner audit --example dangerous-db-mcp
46
+ ```
47
+
48
+ Audit your own tool manifest, remote `tools/list`, or stdio server:
49
+
50
+ ```bash
51
+ npx -y @synapsor/runner audit ./tools-list.json
52
+ ```
53
+
54
+ It flags raw SQL, arbitrary identifiers, model-controlled authority, and
55
+ model-facing writeback without calling business tools. See [MCP Database Risk
56
+ Review](docs/mcp-audit.md) and the [alternatives
57
+ guide](docs/alternatives.md).
41
58
 
42
- Start with a staging database and a read-only credential. Runner inspects
43
- metadata, creates one reviewed read boundary, and opens the secured localhost
44
- Workbench:
59
+ ## Connect Your Staging Application
60
+
61
+ Use a dedicated SELECT-only, non-owner staging credential. Runner combines the
62
+ whole database schema with statically parsed Prisma, Drizzle, OpenAPI, and
63
+ existing Synapsor definitions. It does not execute adopter code, sample source
64
+ rows, or use an LLM:
45
65
 
46
66
  ```bash
47
67
  npm install -g @synapsor/runner
48
68
  export DATABASE_URL="postgresql://runner_reader:REPLACE_ME@db.example.com:5432/app?sslmode=require"
69
+ export SYNAPSOR_TENANT_ID="acme"
70
+ export SYNAPSOR_PRINCIPAL="developer-1"
49
71
  synapsor-runner start --from-env DATABASE_URL --schema public
50
72
  ```
51
73
 
52
- Describe one business action. This creates an inert TypeScript draft; it does
53
- not add a tool or change the active contract:
74
+ A fresh project opens the secured localhost Workbench and emits disabled DSL,
75
+ canonical JSON, tests, review evidence, and a generation lock. Review scope,
76
+ fields, aggregate members, relationships, privacy budgets, profile, and exact
77
+ role/RLS posture, then activate the exact digest. Existing tools stay unchanged.
78
+
79
+ ## Ask Your First Real Question In Cursor
80
+
81
+ After activation, let Runner add only the local authoring entry to this Cursor
82
+ project:
54
83
 
55
84
  ```bash
56
- synapsor-runner start \
57
- --action plan_credit \
58
- --description "Propose one reviewed customer plan credit" \
59
- --based-on support.inspect_customer
85
+ synapsor-runner mcp install cursor \
86
+ --project \
87
+ --authoring \
88
+ --project-root . \
89
+ --yes
60
90
  ```
61
91
 
62
- Add the reviewed tools to the current Cursor project:
92
+ Cursor sees exactly two temporary tools:
63
93
 
64
- ```bash
65
- synapsor-runner mcp install cursor --project \
66
- --config ./synapsor.runner.json \
67
- --store ./.synapsor/local.db
94
+ ```text
95
+ app.describe_data
96
+ app.explore_data
68
97
  ```
69
98
 
70
- In Cursor, use the Workbench's exact prompt. The checked-in project
71
- instructions require the coding agent to draft and validate the action while
72
- leaving effect review and activation to you. Once activated, a request such as
73
- "give CUS-3001 a $25 plan credit" can only create a semantic proposal:
99
+ Ask a bounded question such as:
74
100
 
75
101
  ```text
76
- Data PR wrp_...
77
- Action support.propose_plan_credit on CUS-3001
78
- Effect plan_credit_cents: 0 -> 2500
79
- Source unchanged before approval: Yes
102
+ Which reviewed regions and reason categories contributed most to the increase
103
+ in churned accounts by week?
80
104
  ```
81
105
 
82
- Review the exact effect in the secured Workbench, select **Approve outside
83
- MCP**, then run the displayed guarded apply command from a trusted terminal.
84
- The agent has no approval or commit tool. Runner rechecks scope, policy, row
85
- version, bounds, and idempotency before returning a receipt; a retry cannot
86
- duplicate the mutation and a stale proposal conflicts.
106
+ Runner accepts a typed plan, not SQL. It validates every member against the
107
+ activated digest, injects trusted scope, and runs a read-only transaction.
108
+ Small cohorts are suppressed and durable budgets limit repeated differencing.
109
+ This is descriptive analysis, not proof of causation.
87
110
 
88
- Inspect the latest lifecycle without copying an id:
111
+ Scoped Explore is local authoring only. Missing/unknown/production profiles,
112
+ write-capable or owner credentials, stale generation locks, remote/shared HTTP,
113
+ and non-loopback runtimes never advertise these tools.
114
+
115
+ ## Protect This Query
116
+
117
+ Choose the useful result in Workbench. No opaque ID needs to be copied. Runner
118
+ freezes the reviewed shape into public DSL, canonical JSON, and tests under
119
+ `synapsor/protected/drafts/`. The named capability starts disabled and requires
120
+ exact-digest human activation outside MCP.
121
+
122
+ After activation, Scoped Explore is disabled. Update Cursor to the production
123
+ config:
89
124
 
90
125
  ```bash
91
- synapsor-runner lifecycle --details --store ./.synapsor/local.db
126
+ synapsor-runner mcp install cursor \
127
+ --project \
128
+ --config ./synapsor.runner.json \
129
+ --store ./.synapsor/local.db \
130
+ --yes
92
131
  ```
93
132
 
94
- See the [own-database guide](docs/getting-started-own-database.md),
95
- [Cursor plugin guide](docs/cursor-plugin.md), and
96
- [store lifecycle guide](docs/store-lifecycle.md) for the complete paths.
133
+ Production exposes the protected named capability, not `app.explore_data`.
134
+ Read the complete [Auto Boundary, Scoped Explore, And Protect
135
+ guide](docs/auto-boundary-and-scoped-explore.md).
97
136
 
98
- ## Audit An Existing MCP Server
137
+ ## Create An Exact Data PR
99
138
 
100
- Audit a typical raw-SQL MCP server without launching or calling one:
139
+ For a write, describe one business action. This creates an inert TypeScript
140
+ draft; it does not add a tool or change the active contract:
101
141
 
102
142
  ```bash
103
- npx -y @synapsor/runner audit --example dangerous-db-mcp
143
+ synapsor-runner start \
144
+ --action plan_credit \
145
+ --description "Propose one reviewed customer plan credit" \
146
+ --based-on support.inspect_customer
104
147
  ```
105
148
 
106
- Audit your own tool manifest, remote `tools/list`, or stdio server:
149
+ Once a human activates that exact action digest, an agent request can create
150
+ only a semantic proposal:
107
151
 
108
- ```bash
109
- npx -y @synapsor/runner audit ./tools-list.json
152
+ ```text
153
+ Data PR wrp_...
154
+ Action support.propose_plan_credit on CUS-3001
155
+ Effect plan_credit_cents: 0 -> 2500
156
+ Source unchanged before approval: Yes
110
157
  ```
111
158
 
112
- It flags raw SQL, arbitrary identifiers, model-controlled authority,
113
- model-facing approval/writeback, and missing conflict or idempotency signals.
114
- It does not call business tools. See [MCP Database Risk
115
- Review](docs/mcp-audit.md) for local manifests, selected-server checks, CI,
116
- SARIF, evidence labels, and limits. You may not need Runner: use the
117
- [alternatives guide](docs/alternatives.md) to compare direct read-only access,
118
- hand-built tools, and this reviewed boundary.
159
+ Approve in Workbench outside MCP; a trusted operator or worker commits. Runner
160
+ supports guarded single-row INSERT/UPDATE/DELETE, fixed-predicate bounded
161
+ UPDATE/DELETE, and exact-review batch INSERT. Rich transactions and external
162
+ effects use app-owned executors.
119
163
 
120
- ## Safety Model
164
+ Runner rechecks scope, policy, row version, bounds, idempotency, and affected
165
+ rows before returning a receipt. A retry cannot duplicate the mutation and a
166
+ stale proposal conflicts. Inspect the latest lifecycle without copying an ID:
121
167
 
122
- ```text
123
- AI agent or MCP client
124
- |
125
- | reviewed semantic tool
126
- v
127
- +--------------------------------+
128
- | Synapsor Runner MCP |
129
- | trusted tenant/principal scope |
130
- | evidence + query audit |
131
- | proposals, not direct writes |
132
- +--------------------------------+
133
- |
134
- | scoped read / approved guarded writeback
135
- v
136
- +--------------------------------+
137
- | Your Postgres or MySQL |
138
- | source of truth |
139
- +--------------------------------+
140
-
141
- Local SQLite ledger:
142
- evidence -> proposal -> approval -> receipt -> replay
168
+ ```bash
169
+ synapsor-runner lifecycle --details --store ./.synapsor/local.db
143
170
  ```
144
171
 
145
- The model can inspect scoped data and propose an exact change. It cannot call
146
- approval, apply, or revert tools. A human or trusted operator approves outside
147
- MCP, then Runner performs a guarded write or routes the proposal to an
148
- app-owned executor.
172
+ See the [own-database guide](docs/getting-started-own-database.md),
173
+ [Cursor plugin guide](docs/cursor-plugin.md), and
174
+ [store lifecycle guide](docs/store-lifecycle.md) for the complete paths.
175
+
176
+ ## Safety Model
149
177
 
150
- Contracts fix trusted context, fields, bounds, transitions, and approvals;
151
- evidence, query audit, receipts, and replay preserve the lifecycle. Runner does
178
+ Contracts fix trusted context, fields, bounds, transitions, and approval.
179
+ Model-facing tools can inspect scoped data and propose exact changes, but cannot
180
+ approve, apply, or revert. A trusted operator/worker performs guarded writeback;
181
+ the ledger links evidence, proposal, decision, receipt, and replay. Runner does
152
182
  not make raw SQL or prompt-injection-prone clients safe.
153
183
 
154
184
  ## Choose An Isolation Mode
@@ -168,54 +198,23 @@ MySQL has no native RLS; use restricted views or tenant credentials. See
168
198
  [Database scope] and the
169
199
  [build-vs-adopt guide](docs/why-synapsor-vs-app-guardrails.md).
170
200
 
171
- ## Connect A Staging Database
172
-
173
- The setup above stores environment-variable names, not connection strings, and
174
- never falls back to synthetic data if inspection fails. Keep staging, database
175
- permissions, restricted views, and RLS underneath Runner. Bind trusted tenant
176
- and principal values in the launching process, then review the exact field and
177
- tool surface before connecting Cursor.
178
-
179
- The [complete own-database guide](docs/getting-started-own-database.md) covers
180
- validation, scoped reads, disabled Prisma/Drizzle/OpenAPI candidates, guarded
181
- single-row writes, and app-owned executors. Use the [host compatibility
182
- matrix](docs/host-compatibility.md) for accurately tested client behavior.
183
-
184
201
  ## Review And Prove Your Contract
185
202
 
186
- Before serving, use `contract explain`, `contract lint --strict`, and `contract
187
- test` for reviewer-readable boundaries and allow/deny/redaction cases. The
188
- built-in language server supplies diagnostics, completion, hover, and formatting for
189
- `.synapsor.sql` and legacy `.synapsor` files. See [Contract
190
- Review](docs/contract-review.md) and [Contract
191
- Testing](docs/contract-testing.md).
192
-
193
- Runner also supports reviewed [aggregate reads](docs/aggregate-reads.md),
194
- tenant-scoped tamper-evident [ledger reports](docs/compliance-reports.md), and
195
- opt-in [graduated-trust recommendations](docs/graduated-trust.md). Aggregate
196
- tools return one scalar and no source rows. Graduated trust is disabled by
197
- default, remains operator-only, and can export a reviewable artifact but never
198
- activate it.
203
+ Use `contract explain`, `contract lint --strict`, and `contract test`; the
204
+ language server handles `.synapsor.sql` and legacy `.synapsor`. See [Contract
205
+ Review](docs/contract-review.md), [Contract Testing](docs/contract-testing.md),
206
+ and the [own-database guide](docs/getting-started-own-database.md).
199
207
 
200
208
  ## Trust And Verification
201
209
 
202
210
  Start with the **[Threat Model](THREAT_MODEL.md)**. It defines protected assets,
203
211
  trust boundaries, covered threats, non-goals, and required operator controls.
204
212
 
205
- - [Conformance fixtures](docs/conformance.md) prove trusted context, scoped
206
- reads, kept-out fields, proposal boundaries, approval, receipts, and replay
207
- behavior rather than only validating JSON shape.
208
- - `contract test` lets adopters encode the same boundary checks for their own
209
- synthetic fixtures; it never invokes an LLM and refuses remote live targets
210
- by default.
211
- - MCP proposal, evidence, and replay handles are references rather than bearer
212
- authority: resource reads re-check the owning tenant and principal against
213
- the current trusted session.
214
- - `test:principal-scope`, `test:live-apply`, `test:guarded-crud`,
215
- `test:bounded-set`, and `test:reversible` prove cross-principal denial,
216
- no pre-approval mutation, guarded writes, idempotent retry, conflicts,
217
- bounded atomic sets, receipts, and reviewed compensation on disposable
218
- PostgreSQL/MySQL fixtures.
213
+ [Conformance fixtures](docs/conformance.md) and `contract test` cover trusted
214
+ scope, kept-out fields, proposals, approval, receipts, and replay. Resource
215
+ handles re-check tenant/principal rather than acting as bearer authority. Live
216
+ gates cover principal denial, no pre-approval mutation, idempotency, conflict,
217
+ bounded sets, and compensation on disposable databases.
219
218
 
220
219
  Runner is a narrow agent/database safety boundary, not a replacement for
221
220
  least-privilege database access, host security, or application authorization.
@@ -250,16 +249,10 @@ and the [Runner Config Reference](docs/runner-config-reference.md).
250
249
 
251
250
  ## OSS And Cloud
252
251
 
253
- Synapsor Runner works by itself for local, single-node, and bounded small-fleet
254
- deployments: your database remains the source of truth and Runner stores review
255
- artifacts in the default local SQLite ledger or an opt-in shared Postgres
256
- runtime store.
257
- Synapsor Cloud adds a shared contract registry, immutable versions,
258
- source-scoped Runner connections, downloadable bundles, a human approval
259
- inbox, durable leased writeback jobs, and a redacted shared activity/receipt
260
- chronology. Database credentials and guarded execution remain local. See [Cloud
261
- Mode](docs/cloud-mode.md) for the design-partner path and [OSS Runner vs
262
- Synapsor Cloud](docs/oss-vs-cloud.md) for the detailed boundary.
252
+ Runner works alone with local SQLite or an opt-in shared Postgres ledger.
253
+ Synapsor Cloud adds shared registry, approval, leased jobs, and redacted
254
+ activity/receipt chronology; credentials and guarded execution stay local. See
255
+ [Cloud Mode](docs/cloud-mode.md) and [OSS vs Cloud](docs/oss-vs-cloud.md).
263
256
 
264
257
  `synapsor-runner` owns the local MCP/database boundary. `synapsor` from
265
258
  `@synapsor/cli` manages Cloud review and audit. Both Cloud push commands use