@synapsor/runner 1.4.123 → 1.5.3

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 (98) hide show
  1. package/CHANGELOG.md +144 -19
  2. package/README.md +132 -135
  3. package/dist/authoring.d.ts +23 -0
  4. package/dist/authoring.d.ts.map +1 -0
  5. package/dist/authoring.mjs +1318 -0
  6. package/dist/cli.d.ts.map +1 -1
  7. package/dist/cli.js +4 -5
  8. package/dist/local-ui.d.ts +14 -0
  9. package/dist/local-ui.d.ts.map +1 -1
  10. package/dist/runner.mjs +18427 -7084
  11. package/dist/runtime.d.ts +50 -0
  12. package/dist/runtime.d.ts.map +1 -0
  13. package/dist/runtime.mjs +15094 -0
  14. package/dist/shadow.d.ts +36 -0
  15. package/dist/shadow.d.ts.map +1 -0
  16. package/dist/shadow.mjs +5262 -0
  17. package/docs/README.md +44 -5
  18. package/docs/alternatives.md +122 -0
  19. package/docs/capability-authoring.md +44 -1
  20. package/docs/client-recipes.md +218 -0
  21. package/docs/contract-testing.md +9 -7
  22. package/docs/cursor-plugin.md +78 -0
  23. package/docs/database-enforced-scope.md +273 -0
  24. package/docs/dependency-license-inventory.md +6 -2
  25. package/docs/doctor.md +17 -0
  26. package/docs/effect-regression.md +179 -0
  27. package/docs/fresh-developer-usability.md +110 -0
  28. package/docs/getting-started-own-database.md +103 -2
  29. package/docs/host-compatibility.md +59 -0
  30. package/docs/local-mode.md +12 -7
  31. package/docs/mcp-apps.md +188 -0
  32. package/docs/mcp-audit.md +220 -2
  33. package/docs/mcp-client-setup.md +20 -4
  34. package/docs/mcp-clients.md +41 -4
  35. package/docs/oss-vs-cloud.md +3 -0
  36. package/docs/production.md +8 -0
  37. package/docs/release-notes.md +138 -14
  38. package/docs/release-policy.md +9 -5
  39. package/docs/runner-config-reference.md +25 -0
  40. package/docs/schema-api-candidates.md +68 -0
  41. package/docs/security-boundary.md +30 -5
  42. package/docs/shadow-studies.md +241 -0
  43. package/docs/troubleshooting-first-run.md +46 -0
  44. package/examples/mcp-postgres-billing-app-handler/app-handler.mjs +9 -1
  45. package/examples/mcp-postgres-billing-app-handler/schema.sql +11 -0
  46. package/examples/mcp-postgres-billing-app-handler/synapsor-handler.mjs +3 -0
  47. package/examples/raw-sql-vs-synapsor/Makefile +2 -2
  48. package/examples/raw-sql-vs-synapsor/README.md +6 -4
  49. package/examples/support-billing-agent/Makefile +5 -1
  50. package/examples/support-billing-agent/README.md +57 -5
  51. package/examples/support-billing-agent/app/README.md +6 -0
  52. package/examples/support-billing-agent/app/contract.ts +28 -0
  53. package/examples/support-billing-agent/app/effect-adapter.mjs +23 -0
  54. package/examples/support-billing-agent/app/record-shadow-outcomes.mjs +44 -0
  55. package/examples/support-billing-agent/db/schema.sql +88 -1
  56. package/examples/support-billing-agent/db/seed.sql +15 -15
  57. package/examples/support-billing-agent/scripts/run-demo.sh +4 -0
  58. package/examples/support-billing-agent/scripts/run-evaluation.sh +63 -0
  59. package/examples/support-billing-agent/shadow-study/cases.jsonl +6 -0
  60. package/examples/support-billing-agent/shadow-study/outcomes.jsonl +2 -0
  61. package/examples/support-billing-agent/synapsor.runner.json +17 -5
  62. package/examples/support-plan-credit/README.md +48 -2
  63. package/examples/support-plan-credit/mcp-client-examples/README.md +23 -0
  64. package/examples/support-plan-credit/mcp-client-examples/claude-code.sh +34 -0
  65. package/examples/support-plan-credit/mcp-client-examples/codex.config.toml +24 -0
  66. package/examples/support-plan-credit/mcp-client-examples/generic-stdio.mjs +35 -0
  67. package/examples/support-plan-credit/mcp-client-examples/generic-streamable-http.mjs +31 -0
  68. package/examples/support-plan-credit/mcp-client-examples/google-adk.py +40 -0
  69. package/examples/support-plan-credit/mcp-client-examples/langchain.mjs +29 -0
  70. package/examples/support-plan-credit/mcp-client-examples/llamaindex.py +36 -0
  71. package/examples/support-plan-credit/mcp-client-examples/openai-agents-stdio.ts +1 -1
  72. package/examples/support-plan-credit/mcp-client-examples/openai-agents-streamable-http.ts +1 -1
  73. package/examples/support-plan-credit/mcp-client-examples/vscode.mcp.json +20 -0
  74. package/examples/support-plan-credit/synapsor/actions/support.propose_plan_credit.contract-tests.generated.json +221 -0
  75. package/examples/support-plan-credit/synapsor/actions/support.propose_plan_credit.ts +34 -0
  76. package/fixtures/effects/changed/eff_support_late_fee_v1.result.json +58 -0
  77. package/fixtures/effects/dataset.json +8 -0
  78. package/fixtures/effects/results/eff_support_late_fee_v1.result.json +59 -0
  79. package/fixtures/effects/support-late-fee.effect.json +71 -0
  80. package/fixtures/generators/drizzle/malicious.ts +11 -0
  81. package/fixtures/generators/drizzle/schema.ts +12 -0
  82. package/fixtures/generators/openapi/external-ref.yaml +15 -0
  83. package/fixtures/generators/openapi/openapi.yaml +81 -0
  84. package/fixtures/generators/prisma/schema.prisma +34 -0
  85. package/fixtures/mcp-audit/README.md +14 -0
  86. package/fixtures/mcp-audit/cursor-bypass-config.json +38 -0
  87. package/fixtures/mcp-audit/dangerous-tools-list.json +33 -0
  88. package/fixtures/mcp-audit/reviewed-proposal-tools-list.json +60 -0
  89. package/package.json +29 -3
  90. package/schemas/effect-dataset.schema.json +19 -0
  91. package/schemas/effect-fixture.schema.json +191 -0
  92. package/schemas/effect-result.schema.json +52 -0
  93. package/schemas/mcp-audit-candidates.schema.json +41 -0
  94. package/schemas/mcp-audit-report.schema.json +203 -0
  95. package/schemas/schema-candidate-review.schema.json +167 -0
  96. package/schemas/schema-candidates.schema.json +49 -0
  97. package/schemas/synapsor.contract-tests.schema.json +1 -1
  98. package/schemas/synapsor.runner.schema.json +51 -0
package/CHANGELOG.md CHANGED
@@ -1,6 +1,130 @@
1
1
  # Changelog
2
2
 
3
- ## 1.4.123 (prepared, not published)
3
+ ## 1.5.3 (prepared, not published)
4
+
5
+ ### Intent to Safe Action
6
+
7
+ - Adds one code-first Safe Action Composer from a reviewed read boundary to a
8
+ restricted TypeScript draft, canonical contract, plain-language explanation,
9
+ and deterministic allow/deny/effect tests. Runner statically parses the file
10
+ and never imports or executes adopter code while deciding authority.
11
+ - Keeps every generated action disabled until a human reviews a real staging
12
+ Data PR in the secured Workbench and explicitly activates the complete
13
+ digest. Editing, validating, or watching a draft cannot change active MCP
14
+ tools; proposals remain pinned to their active contract digest.
15
+ - Adds current Cursor project/plugin packaging, `/synapsor-protect`, live Safe
16
+ Action diagnostics, owned install/uninstall, and an honest host matrix.
17
+ Activation, approval, apply, credentials, and trusted identity stay outside
18
+ the model-facing surface.
19
+ - Extends MCP audit with evidence-labeled authority maps, explicitly consented
20
+ selected-server bypass checks, text/JSON/Markdown/SARIF output, fixtures, and
21
+ a non-mutating GitHub Actions workflow.
22
+ - Adds a checked-in Safe Action CI workflow plus verified proposal-only recipes
23
+ for Claude Code, Codex, VS Code, OpenAI Agents, LangChain/LangGraph, Google
24
+ ADK, LlamaIndex, and generic MCP clients.
25
+ - Reframes the README and website around one existing-application Data PR,
26
+ publishes an honest alternatives guide, and adds a deterministic 36-second
27
+ support-plan-credit cut backed by real PostgreSQL proposal, receipt, retry,
28
+ and stale-conflict evidence.
29
+ - Prepares only `@synapsor/runner@1.5.3`; `@synapsor/spec@1.4.2`,
30
+ `@synapsor/dsl@1.4.3`, and the Cloud CLI remain unchanged.
31
+
32
+ ## 1.5.2 (prepared, not published)
33
+
34
+ ### First safe action in an existing application
35
+
36
+ - Establishes one canonical path from an existing application and staging
37
+ Postgres/MySQL database to a reviewed semantic action, scoped evidence, exact
38
+ proposal/Data PR, external human review, guarded apply, receipt, and replay.
39
+ Own-data failures stop honestly and never fall back to synthetic data.
40
+ - Generates a canonical contract and local Runner wiring from read-only schema
41
+ inspection while detecting Prisma, Drizzle, OpenAPI, known database
42
+ environment names, and existing Synapsor files without executing adopter
43
+ code. The happy path requires no hand-written JSON or DSL.
44
+ - Adds a focused localhost workbench for Project, Data source, Trust scope,
45
+ Action, Agent, Test, and Review. Configuration validation alone no longer
46
+ marks Test complete; a scoped read must create query-audit evidence first.
47
+ - Adds safe project-scoped Cursor install, status, and uninstall with preview,
48
+ merge, backup, ownership/integrity checks, exact-version launch, and
49
+ preservation of unrelated MCP entries. Approval, apply, revert, credentials,
50
+ and trusted identity remain outside the model-facing MCP surface.
51
+ - Adds local-only activation reports for proof, own-data onboarding, Cursor,
52
+ first read, and first proposal. Product timing explicitly excludes initial
53
+ package download; separately reported cold `npx` timing is environment-
54
+ specific. No activation telemetry or business identifiers are transmitted.
55
+ - Adds optional `@synapsor/runner/authoring` and
56
+ `@synapsor/runner/shadow` exports. TypeScript authoring emits the same
57
+ canonical public contract, while shadow progression and provider-neutral
58
+ effect regression remain non-activating and label deterministic versus
59
+ external-model evidence.
60
+ - Connects MCP audit candidates directly to the secured workbench and keeps
61
+ audit prominent in the README and docs. Adds an explicit host-compatibility
62
+ matrix and a packaged support/billing first-action reference workflow.
63
+ - Corrects the supported runtime floor to Node 22.13.0, where `node:sqlite` is
64
+ available without an experimental flag, and fails earlier runtimes before
65
+ loading the Runner bundle.
66
+ - Prepares only `@synapsor/runner@1.5.2`; `@synapsor/spec@1.4.2`,
67
+ `@synapsor/dsl@1.4.3`, and the Cloud CLI remain unchanged.
68
+
69
+ ## 1.5.1 (prepared, not published)
70
+
71
+ ### Safe ownership for disposable try state
72
+
73
+ - Stops `try` from recursively deleting a caller-provided `--state-dir`.
74
+ Custom paths are now unowned containers; Runner writes into a marked managed
75
+ child and removes only its known direct state files.
76
+ - Rejects filesystem roots, home/cwd/repository paths and their ancestors,
77
+ parent traversal, symlinked path components, unmarked lookalike directories,
78
+ and managed files replaced by links. Unrelated caller files are preserved.
79
+ - Adds an atomic per-state lease. Concurrent runs fail clearly, while a valid
80
+ lease left by a dead process can recover without broad cleanup.
81
+ - Keeps `demo inspect --state-dir` aligned with the managed-child layout and
82
+ safely adopts only the known legacy default `.synapsor/try` file set.
83
+ - Hardens explicit `--force` replacement for generated schema and MCP-audit
84
+ candidate directories against protected paths, symlinked ancestors, and
85
+ linked or invalid ownership markers.
86
+ - Consistently identifies the embedded `try` source as synthetic.
87
+ - Updates the packaged YAML parser to `2.8.3`, which includes the upstream
88
+ deeply nested collection denial-of-service fix.
89
+ - Corrects the repository's stale publication wording for the live `1.5.0`
90
+ release. Only `@synapsor/runner` is staged at `1.5.1`; Spec, DSL, and Cloud
91
+ CLI versions remain unchanged.
92
+
93
+ ## 1.5.0 (2026-07-20)
94
+
95
+ ### Complete guarded-action developer proof
96
+
97
+ - Adds `synapsor-runner try` as a no-account, no-database, no-Docker proof of
98
+ scoped evidence, an exact business-data proposal, external approval, guarded
99
+ commit, restart-safe retry, stale-state refusal, receipt, and non-mutating
100
+ replay. `try --prove` also verifies changed-intent collision rejection.
101
+ - Adds explicit `application_scope`, `postgres_rls`, and `tenant_bound`
102
+ assurance modes. PostgreSQL hardened mode binds tenant/principal
103
+ transaction-locally, checks RLS and role prerequisites, and fails closed
104
+ rather than silently downgrading.
105
+ - Productizes strict local shadow studies, authoritative human-outcome
106
+ comparison, deterministic readiness reports, and effect-level JSON/JUnit
107
+ regression fixtures without activating policy or mutating source data.
108
+ - Adds a standard display-only MCP App proposal resource with exact effect,
109
+ evidence, scope, policy, and review-state presentation. Approval and apply
110
+ remain absent from MCP, with terminal and standalone local-UI fallbacks.
111
+ - Extends static MCP risk audit into disabled review candidates, and adds
112
+ review-only Prisma, Drizzle, and OpenAPI generators that emit canonical
113
+ contracts without importing or executing adopter code.
114
+ - Promotes `examples/support-billing-agent` as a disposable PostgreSQL/RLS
115
+ proof covering tenant and principal scope, kept-out fields, exact $55
116
+ proposal, approval/apply, idempotent retry, stale conflict, replay, strict
117
+ shadow, human comparison, and effect regression.
118
+ - Keeps app-owned handler writers least-privileged when their receipt table is
119
+ pre-provisioned: the helper checks for the table before attempting DDL, and
120
+ the live source and packed examples verify transactional apply and retry.
121
+ - Rewrites the README around the complete `try --prove` outcome, keeps MCP
122
+ audit immediately second, names each isolation boundary precisely, and
123
+ reconciles release documentation with the live npm registry.
124
+ - Published only `@synapsor/runner@1.5.0`; `@synapsor/spec@1.4.2`,
125
+ `@synapsor/dsl@1.4.3`, and `@synapsor/cli@0.1.0-beta.1` remain unchanged.
126
+
127
+ ## 1.4.123 (2026-07-17)
4
128
 
5
129
  ### Advisory capability-surface fitness lint
6
130
 
@@ -13,10 +137,10 @@
13
137
  - Adds stable structured details and surface metrics to JSON/SARIF output, plus
14
138
  a concise text summary. No database connection, environment value, source
15
139
  row, or probabilistic classifier is involved.
16
- - Stages only `@synapsor/runner@1.4.123`; `@synapsor/spec@1.4.2`,
140
+ - Published only `@synapsor/runner@1.4.123`; `@synapsor/spec@1.4.2`,
17
141
  `@synapsor/dsl@1.4.3`, and `@synapsor/cli@0.1.0-beta.1` are unchanged.
18
142
 
19
- ## 1.4.122 (2026-07-16)
143
+ ## 1.4.122 (2026-07-17)
20
144
 
21
145
  ### Trusted principal row scope and Cloud-linked governance
22
146
 
@@ -42,7 +166,7 @@
42
166
  - Published `@synapsor/spec@1.4.2`, `@synapsor/dsl@1.4.3`, and
43
167
  `@synapsor/runner@1.4.122`.
44
168
 
45
- ## 1.4.121 (prepared, not published)
169
+ ## 1.4.121 (2026-07-15)
46
170
 
47
171
  ### Contract trust surface and bounded-set parser correctness
48
172
 
@@ -78,10 +202,10 @@
78
202
  - Proves additive Spec/DSL/Runner/C++ aggregate and enum parity, shared Postgres
79
203
  recommendation durability, and transient PostgreSQL/MySQL timeout
80
204
  classification.
81
- - Stages `@synapsor/spec@1.4.1`, `@synapsor/dsl@1.4.2`, and
82
- `@synapsor/runner@1.4.121`. Nothing is published by this change.
205
+ - Published `@synapsor/spec@1.4.1`, `@synapsor/dsl@1.4.2`, and
206
+ `@synapsor/runner@1.4.121`.
83
207
 
84
- ## 1.4.12 (prepared, not published)
208
+ ## 1.4.12 (2026-07-14)
85
209
 
86
210
  ### Runtime-store smoke-call consistency
87
211
 
@@ -97,10 +221,10 @@
97
221
  - Adds focused no-fallback coverage and a disposable two-process fleet proof
98
222
  covering ownership, approval/apply, one source receipt, replay, and safe
99
223
  ledger unavailability.
100
- - Stages only `@synapsor/runner@1.4.12`; `@synapsor/dsl` remains `1.4.1` and
101
- `@synapsor/spec` remains `1.4.0`. Nothing is published by this change.
224
+ - Published only `@synapsor/runner@1.4.12`; `@synapsor/dsl` remains `1.4.1`
225
+ and `@synapsor/spec` remains `1.4.0`.
102
226
 
103
- ## 1.4.1 (prepared, not published)
227
+ ## 1.4.1 (2026-07-14)
104
228
 
105
229
  ### Canonical Bounded-Set Digest Verification
106
230
 
@@ -127,11 +251,11 @@
127
251
  structural authorization, explains where SQL authority lives, and documents
128
252
  the approval, receipt, replay, and compensation layer without claiming
129
253
  prompt-injection prevention or compliance certification.
130
- - Stages `@synapsor/runner@1.4.1` and `@synapsor/dsl@1.4.1`;
254
+ - Published `@synapsor/runner@1.4.1` and `@synapsor/dsl@1.4.1`;
131
255
  `@synapsor/spec` remains `1.4.0` because the public contract schema did not
132
- change. Nothing is published by this change.
256
+ change.
133
257
 
134
- ## 1.4.0 (prepared, not published)
258
+ ## 1.4.0 (2026-07-14)
135
259
 
136
260
  ### Reviewed Reversible Change Sets
137
261
 
@@ -155,8 +279,8 @@
155
279
  conformance fixtures, owner-authorized resources, local UI/doctor/preview
156
280
  state, bounded metrics, crash-reconciliation tests, and the disposable
157
281
  `corepack pnpm test:reversible` gate.
158
- - Stages `@synapsor/spec@1.4.0`, `@synapsor/dsl@1.4.0`, and
159
- `@synapsor/runner@1.4.0`. No npm package is published by this change.
282
+ - Published `@synapsor/spec@1.4.0`, `@synapsor/dsl@1.4.0`, and
283
+ `@synapsor/runner@1.4.0`.
160
284
 
161
285
  ## 1.3.0 (prepared, not published)
162
286
 
@@ -233,7 +357,8 @@
233
357
  metadata so a leaked handle does not become bearer authority.
234
358
  - Adds shared-store and Streamable HTTP regressions proving owner access still
235
359
  works while cross-session resource reads fail closed.
236
- - Stages only `@synapsor/runner@1.1.1`; canonical Spec and DSL remain `1.1.0`.
360
+ - Published only `@synapsor/runner@1.1.1`; canonical Spec and DSL remain
361
+ `1.1.0`.
237
362
 
238
363
  ## 1.1.0
239
364
 
@@ -257,8 +382,8 @@
257
382
  - Adds verified dead-letter list/show/requeue/discard, shared-ledger
258
383
  backup/digest/restore, archive-before-retention, and a repeatable two-Runner
259
384
  kill/recovery test over synthetic Postgres/MySQL.
260
- - Stages `@synapsor/spec@1.1.0`, `@synapsor/dsl@1.1.0`, and
261
- `@synapsor/runner@1.1.0`. Nothing is published by this change.
385
+ - Published `@synapsor/spec@1.1.0`, `@synapsor/dsl@1.1.0`, and
386
+ `@synapsor/runner@1.1.0`.
262
387
 
263
388
  ## 1.0.0
264
389
 
@@ -280,7 +405,7 @@
280
405
  and Streamable HTTP mTLS.
281
406
  - Declares the first semver contract for the documented CLI, schema, contract,
282
407
  MCP result, writeback, approval, metrics, and replay surfaces.
283
- - Stages `@synapsor/spec@1.0.0`, `@synapsor/dsl@1.0.0`, and
408
+ - Published `@synapsor/spec@1.0.0`, `@synapsor/dsl@1.0.0`, and
284
409
  `@synapsor/runner@1.0.0`.
285
410
 
286
411
  ## 0.1.16
package/README.md CHANGED
@@ -4,21 +4,95 @@
4
4
  [![license: Apache-2.0](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](LICENSE)
5
5
  [![ci](https://github.com/Synapsor/Synapsor-Runner/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/Synapsor/Synapsor-Runner/actions/workflows/ci.yml?query=branch%3Amain)
6
6
 
7
- Stop giving AI agents `execute_sql`. Give them reviewed business actions.
7
+ **Let AI agents change real application data without giving the model SQL.**
8
8
 
9
- Synapsor Runner is an open-source, local-first MCP runtime for Postgres and
10
- MySQL. It exposes semantic tools such as `billing.inspect_invoice` and
11
- `billing.propose_late_fee_waiver`, saves risky changes as proposals, and keeps
12
- database credentials, approval, and writeback outside the model-facing tool
13
- surface.
9
+ **MCP connects the agent. Synapsor controls the commit.**
14
10
 
15
- ## Prove It In 60 Seconds
11
+ Synapsor Runner is an open-source MCP runtime for Postgres and MySQL. It gives
12
+ agents reviewed business actions, records proposed changes as exact Data PRs,
13
+ and keeps credentials, activation, approval, and commit authority outside the
14
+ model-facing surface.
16
15
 
17
- Path: **audit** MCP risk, **demo** the boundary, then **connect** staging. The
18
- first two commands touch only a local fixture.
16
+ ## Prove The Boundary In Four Seconds
19
17
 
20
- First, inspect the risk in a typical raw-SQL database MCP server. This works
21
- even if you never adopt Runner:
18
+ No database, Docker, config, MCP client, LLM, or account is required:
19
+
20
+ ```bash
21
+ npx -y @synapsor/runner try --prove
22
+ ```
23
+
24
+ The four-second product measurement begins after package resolution. A cold
25
+ `npx` download is recorded separately because registry and network time vary.
26
+
27
+ The embedded synthetic source requests a $55 waiver and proves:
28
+
29
+ ```text
30
+ Proposed effect: late_fee_cents: 5500 -> 0
31
+ Source changed before approval: No
32
+ Guarded commit: 1 row, receipt recorded
33
+ Restart-safe retry: yes; duplicate mutations: 0
34
+ Stale apply refused: yes
35
+ ```
36
+
37
+ Review happens outside the model-facing tools. The command stores inspectable
38
+ state under `./.synapsor/try/`; it teaches the boundary and does not claim to
39
+ test your database connection. `demo --quick` remains a noninteractive compatibility alias.
40
+
41
+ ## Protect One Action In Your Application
42
+
43
+ Start with a staging database and a read-only credential. Runner inspects
44
+ metadata, creates one reviewed read boundary, and opens the secured localhost
45
+ Workbench:
46
+
47
+ ```bash
48
+ npm install -g @synapsor/runner
49
+ export DATABASE_URL="postgresql://runner_reader:REPLACE_ME@db.example.com:5432/app?sslmode=require"
50
+ synapsor-runner start --from-env DATABASE_URL --schema public
51
+ ```
52
+
53
+ Describe one business action. This creates an inert TypeScript draft; it does
54
+ not add a tool or change the active contract:
55
+
56
+ ```bash
57
+ synapsor-runner start \
58
+ --action plan_credit \
59
+ --description "Propose one reviewed customer plan credit" \
60
+ --based-on support.inspect_customer
61
+ ```
62
+
63
+ Add the reviewed tools to the current Cursor project:
64
+
65
+ ```bash
66
+ synapsor-runner mcp install cursor --project \
67
+ --config ./synapsor.runner.json \
68
+ --store ./.synapsor/local.db
69
+ ```
70
+
71
+ In Cursor, use the Workbench's exact prompt. The checked-in project
72
+ instructions require the coding agent to draft and validate the action while
73
+ leaving effect review and activation to you. Once activated, a request such as
74
+ "give CUS-3001 a $25 plan credit" can only create a semantic proposal:
75
+
76
+ ```text
77
+ Data PR wrp_...
78
+ Action support.propose_plan_credit on CUS-3001
79
+ Effect plan_credit_cents: 0 -> 2500
80
+ Source unchanged before approval: Yes
81
+ ```
82
+
83
+ Review the exact effect in the secured Workbench, select **Approve outside
84
+ MCP**, then run the displayed guarded apply command from a trusted terminal.
85
+ The agent has no approval or commit tool. Runner rechecks scope, policy, row
86
+ version, bounds, and idempotency before returning a receipt; a retry cannot
87
+ duplicate the mutation and a stale proposal conflicts.
88
+
89
+ See the [own-database guide](docs/getting-started-own-database.md) for the full
90
+ staging path and [Cursor plugin guide](docs/cursor-plugin.md) for
91
+ `/synapsor-protect` and the plugin boundary.
92
+
93
+ ## Audit An Existing MCP Server
94
+
95
+ Audit a typical raw-SQL MCP server without launching or calling one:
22
96
 
23
97
  ```bash
24
98
  npx -y @synapsor/runner audit --example dangerous-db-mcp
@@ -33,17 +107,10 @@ npx -y @synapsor/runner audit ./tools-list.json
33
107
  It flags raw SQL, arbitrary identifiers, model-controlled authority,
34
108
  model-facing approval/writeback, and missing conflict or idempotency signals.
35
109
  It does not call business tools. See [MCP Database Risk
36
- Review](docs/mcp-audit.md) for supported workflows and limits.
37
-
38
- Then see the proposal, approval boundary, evidence, and replay loop. It needs no
39
- database, Docker, config file, MCP client, or Synapsor account:
40
-
41
- ```bash
42
- npx -y @synapsor/runner demo --quick
43
- ```
44
-
45
- The quick demo creates a fixture ledger at `./.synapsor/quick-demo.db`. It
46
- teaches the boundary; it does not claim to test your database connection.
110
+ Review](docs/mcp-audit.md) for local manifests, selected-server checks, CI,
111
+ SARIF, evidence labels, and limits. You may not need Runner: use the
112
+ [alternatives guide](docs/alternatives.md) to compare direct read-only access,
113
+ hand-built tools, and this reviewed boundary.
47
114
 
48
115
  ## Safety Model
49
116
 
@@ -75,100 +142,43 @@ approval, apply, or revert tools. A human or trusted operator approves outside
75
142
  MCP, then Runner performs a guarded write or routes the proposal to an
76
143
  app-owned executor.
77
144
 
78
- Contracts constrain tools, trusted context, visible and writable columns,
79
- bounds, transitions, and approvals. Proposals separate model intent from commit
80
- authority; evidence, query audit, receipts, and replay preserve the reviewed
81
- lifecycle. Runner does not make raw SQL tools, hosts, or
82
- prompt-injection-prone clients safe.
145
+ Contracts fix trusted context, fields, bounds, transitions, and approvals;
146
+ evidence, query audit, receipts, and replay preserve the lifecycle. Runner does
147
+ not make raw SQL or prompt-injection-prone clients safe.
83
148
 
84
- ## Why Not Just Use A Prompt And App Code?
149
+ ## Choose An Isolation Mode
85
150
 
86
- Prompts are not an authorization boundary. First ask who produces the SQL:
87
-
88
- - **The model produces SQL:** validation must understand arbitrary queries,
89
- scope, and side effects. That is `execute_sql` behind a parser.
90
- - **Trusted app code produces fixed, parameterized SQL:** good. You have built
91
- a semantic tool, and that may be enough for a small read-only application.
151
+ | Mode | Boundary |
152
+ | --- | --- |
153
+ | Embedded `try` | Synthetic source; proves the lifecycle, not your database. |
154
+ | `application_scope` | Shared role plus Runner predicates. A Runner bug or compromised process can cross scope; retain database controls. |
155
+ | `postgres_rls` | PostgreSQL also checks transaction-bound tenant/principal scope. Arbitrary trusted-context or credential control remains outside this guarantee. |
156
+ | `tenant_bound` | Authenticated context selects a restricted per-tenant credential or process. |
92
157
 
93
- Runner adds one reviewed contract for trusted scope, field controls, evidence,
94
- approval outside MCP, guarded writeback, receipts, replay, and compensation.
95
- Use your own code when you do not need that lifecycle. See the [build-vs-adopt
96
- guide](docs/why-synapsor-vs-app-guardrails.md).
158
+ Stdio commonly trusts process environment; shared HTTP must use verified signed
159
+ claims. Model arguments, query parameters, and arbitrary tenant headers are
160
+ never trusted. MySQL has no native RLS; use restricted views or tenant
161
+ credentials. See [Database scope] and the
162
+ [build-vs-adopt guide](docs/why-synapsor-vs-app-guardrails.md).
97
163
 
98
164
  ## Connect A Staging Database
99
165
 
100
- Start with a staging or disposable database and a read-only credential. Keep
101
- database permissions, restricted views, and row-level security in place.
166
+ The setup above stores environment-variable names, not connection strings, and
167
+ never falls back to synthetic data if inspection fails. Keep staging, database
168
+ permissions, restricted views, and RLS underneath Runner. Bind trusted tenant
169
+ and principal values in the launching process, then review the exact field and
170
+ tool surface before connecting Cursor.
102
171
 
103
- ```bash
104
- npm install -g @synapsor/runner
105
- export DATABASE_URL="postgresql://runner_reader:REPLACE_ME@db.example.com:5432/app?sslmode=require"
106
- synapsor-runner start --from-env DATABASE_URL --schema public
107
- ```
108
-
109
- The guided command inspects metadata, asks you to choose one table or view,
110
- creates trusted context, generates reviewed capabilities, previews the MCP tool
111
- surface, and prints the next smoke and serve commands. It stores environment
112
- variable names, not connection strings.
113
-
114
- The generated capability is a tenant-scoped read with an explicit column
115
- allowlist and required evidence. See the [own-database
116
- guide](docs/getting-started-own-database.md) for the full configuration.
117
-
118
- ```json
119
- {
120
- "name": "billing.inspect_invoice",
121
- "kind": "read",
122
- "source": "app_postgres",
123
- "target": {
124
- "schema": "public",
125
- "table": "invoices",
126
- "primary_key": "id",
127
- "tenant_key": "tenant_id"
128
- },
129
- "args": {
130
- "invoice_id": { "type": "string", "required": true, "max_length": 128 }
131
- },
132
- "lookup": { "id_from_arg": "invoice_id" },
133
- "visible_columns": ["id", "tenant_id", "status", "late_fee_cents", "updated_at"],
134
- "evidence": "required",
135
- "max_rows": 1
136
- }
137
- ```
138
-
139
- Set the trusted values in the process that launches Runner, then validate and
140
- preview the exact model-facing boundary before connecting an MCP client:
141
-
142
- ```bash
143
- export SYNAPSOR_TENANT_ID="acme"
144
- export SYNAPSOR_PRINCIPAL="local-developer"
145
- synapsor-runner config validate --config ./synapsor.runner.json
146
- synapsor-runner tools preview --config ./synapsor.runner.json --store ./.synapsor/local.db
147
- synapsor-runner mcp serve --config ./synapsor.runner.json --store ./.synapsor/local.db
148
- ```
149
-
150
- For proposal capabilities and writes, follow the
151
- [complete own-database guide](docs/getting-started-own-database.md). Reviewed
152
- single-row INSERT, UPDATE, and DELETE can use Runner's guarded direct
153
- writeback. Runner also supports tightly [bounded set
154
- writes](docs/bounded-set-writeback.md): fixed-predicate UPDATE/DELETE and
155
- exact-review batch INSERT, with human approval, a hard 100-row ceiling, atomic
156
- apply, and exact receipts. Free-form predicates, unbounded or cross-table work,
157
- and external effects go through an [app-owned
158
- executor](docs/writeback-executors.md) after approval.
159
-
160
- Direct writes can use [reviewed
161
- compensation](docs/reversible-change-sets.md). Receipts capture a
162
- bounded inverse; `synapsor-runner revert <proposal_id>` creates a separately
163
- approved proposal. This is not rollback, time travel, or app-owned
164
- compensation.
172
+ The [complete own-database guide](docs/getting-started-own-database.md) covers
173
+ validation, scoped reads, disabled Prisma/Drizzle/OpenAPI candidates, guarded
174
+ single-row writes, and app-owned executors. Use the [host compatibility
175
+ matrix](docs/host-compatibility.md) for accurately tested client behavior.
165
176
 
166
177
  ## Review And Prove Your Contract
167
178
 
168
- Before serving a contract, use `contract explain` for a reviewer-readable
169
- boundary, `contract lint --strict` for deterministic surface-fitness CI checks,
170
- and `contract test` for adopter-owned allow/deny/redaction cases. The built-in language
171
- server supplies diagnostics, completion, hover, and formatting for
179
+ Before serving, use `contract explain`, `contract lint --strict`, and `contract
180
+ test` for reviewer-readable boundaries and allow/deny/redaction cases. The
181
+ built-in language server supplies diagnostics, completion, hover, and formatting for
172
182
  `.synapsor.sql` and legacy `.synapsor` files. See [Contract
173
183
  Review](docs/contract-review.md) and [Contract
174
184
  Testing](docs/contract-testing.md).
@@ -194,32 +204,24 @@ trust boundaries, covered threats, non-goals, and required operator controls.
194
204
  - MCP proposal, evidence, and replay handles are references rather than bearer
195
205
  authority: resource reads re-check the owning tenant and principal against
196
206
  the current trusted session.
197
- - Same-tenant owner/assignee isolation uses a reviewed
198
- [`PRINCIPAL SCOPE KEY`](docs/capability-authoring.md#same-tenant-principal-row-scope)
199
- composed with mandatory tenant scope; `test:principal-scope` proves generic
200
- cross-principal denial and evidence-handle isolation on Postgres and MySQL.
201
- - `test:live-apply`, `test:guarded-crud`, `test:bounded-set`, and
202
- `test:reversible` run disposable PostgreSQL/MySQL scenarios. They prove no
203
- pre-approval mutation, guarded single-row CRUD, idempotent retry,
204
- fail-closed conflicts, bounded atomic sets, exact receipts, and reviewed
205
- compensation.
206
- - The C++/Cloud round-trip verifier exports normalized contracts, validates
207
- them with `@synapsor/spec`, and loads them in Runner. The shared contract and
208
- verification commands are documented in [Conformance](docs/conformance.md).
207
+ - `test:principal-scope`, `test:live-apply`, `test:guarded-crud`,
208
+ `test:bounded-set`, and `test:reversible` prove cross-principal denial,
209
+ no pre-approval mutation, guarded writes, idempotent retry, conflicts,
210
+ bounded atomic sets, receipts, and reviewed compensation on disposable
211
+ PostgreSQL/MySQL fixtures.
209
212
 
210
213
  Runner is a narrow agent/database safety boundary, not a replacement for
211
214
  least-privilege database access, host security, or application authorization.
212
215
  See [Security Boundary](docs/security-boundary.md) and
213
216
  [Current Limitations](docs/limitations.md).
214
217
 
218
+ [Database scope]: docs/database-enforced-scope.md
219
+
215
220
  ## Operate The Approval Loop
216
221
 
217
- Policies combine per-proposal and daily ceilings; exceeding one routes to human
218
- review. Operators get batch apply, metrics, structured logs, and optional
219
- signed roles. Local SQLite is the default; bounded fleets can use verified HTTP
220
- claims, asymmetric JWT sessions, and a shared Postgres `runtime_store`.
221
- `smoke call` follows that store and never falls back to SQLite. Use `/healthz`
222
- for liveness and `/readyz` for dependency readiness. See
222
+ Policies can combine per-proposal and aggregate ceilings; exceeding one routes
223
+ to human review. Local SQLite is the default, while bounded fleets can use
224
+ verified HTTP claims and a shared Postgres runtime store. See
223
225
  [Production](docs/production.md), [Runner Config](docs/runner-config-reference.md),
224
226
  and [Small Runner Fleets](docs/running-a-runner-fleet.md).
225
227
 
@@ -232,16 +234,11 @@ and [Small Runner Fleets](docs/running-a-runner-fleet.md).
232
234
  | `@synapsor/dsl` | SQL-like authoring that compiles contexts, capabilities, and workflow declarations into canonical contract JSON. |
233
235
  | `@synapsor/cli` | Synapsor Cloud administration, contract governance, human review, Runner connections, and shared audit records. |
234
236
 
235
- Runner executes locally. The spec is shared by Runner and Cloud/C++; the DSL
236
- is its reviewable source format. Start with [Capability
237
- Authoring](docs/capability-authoring.md). Use `.synapsor.sql` for generic SQL
238
- highlighting; legacy `.synapsor` files produce the same contract JSON.
239
-
240
- Use the [DSL Reference](docs/dsl-reference.md) for exact authoring grammar and
241
- the [Runner Config Reference](docs/runner-config-reference.md) for every wiring
242
- key, default, and path-resolution rule. The
243
- [Store Lifecycle guide](docs/store-lifecycle.md) explains ledger sensitivity,
244
- owner-only permissions, inspection commands, and retention.
237
+ Runner, JSON, `.synapsor.sql`, and the optional TypeScript
238
+ `@synapsor/runner/authoring` frontend all use the same canonical spec. The
239
+ `@synapsor/runner/shadow` helper records app-owned outcomes without granting
240
+ write authority. Start with [Capability Authoring](docs/capability-authoring.md)
241
+ and the [Runner Config Reference](docs/runner-config-reference.md).
245
242
 
246
243
  ## OSS And Cloud
247
244
 
@@ -264,7 +261,7 @@ guide](https://github.com/Synapsor/Synapsor-Runner/blob/main/docs/cloud-cli.md).
264
261
  ## Next Steps
265
262
 
266
263
  - Follow the [step-by-step Synapsor Tutorial](https://github.com/sandeshtiwari/Synapsor-Tutorial).
267
- - Run the [`support-plan-credit` flagship example](examples/support-plan-credit).
264
+ - Run the [`support-billing-agent` flagship example](examples/support-billing-agent).
268
265
  - Connect [Claude, Cursor, OpenAI Agents SDK, or another MCP client](docs/mcp-clients.md).
269
266
  - Author and [push a validated contract to Cloud](docs/cloud-push.md).
270
267
  - Browse the [task-first documentation index](docs/README.md).
@@ -0,0 +1,23 @@
1
+ import { type AgentContextSpec, type CapabilitySpec, type PolicySpec, type ResourceSpec, type SynapsorContract, type WorkflowSpec } from "@synapsor/spec";
2
+ export type SynapsorContractDefinition = Omit<SynapsorContract, "spec_version" | "kind">;
3
+ /** Preserve editor inference for a canonical resource definition. */
4
+ export declare function defineResource<const T extends ResourceSpec>(resource: T): T;
5
+ /** Preserve editor inference for trusted context bindings resolved outside model input. */
6
+ export declare function defineAgentContext<const T extends AgentContextSpec>(context: T): T;
7
+ /** Preserve editor inference for a canonical read, aggregate, proposal, or external capability. */
8
+ export declare function defineCapability<const T extends CapabilitySpec>(capability: T): T;
9
+ /** Preserve editor inference for a canonical workflow declaration. */
10
+ export declare function defineWorkflow<const T extends WorkflowSpec>(workflow: T): T;
11
+ /** Preserve editor inference for a canonical policy declaration. */
12
+ export declare function definePolicy<const T extends PolicySpec>(policy: T): T;
13
+ /**
14
+ * Build and validate the same language-neutral contract consumed by the JSON,
15
+ * SQL-like DSL, local Runner, and Cloud registry paths.
16
+ */
17
+ export declare function defineContract<const T extends SynapsorContractDefinition>(definition: T): SynapsorContract & T;
18
+ /** Validate and normalize a code-first definition into canonical contract JSON shape. */
19
+ export declare function compileContract(definition: SynapsorContractDefinition | SynapsorContract): SynapsorContract;
20
+ /** Serialize normalized canonical JSON for review, version control, or Runner loading. */
21
+ export declare function contractJson(definition: SynapsorContractDefinition | SynapsorContract, indentation?: number): string;
22
+ export type { AgentContextSpec, CapabilitySpec, PolicySpec, ResourceSpec, SynapsorContract, WorkflowSpec, } from "@synapsor/spec";
23
+ //# sourceMappingURL=authoring.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authoring.d.ts","sourceRoot":"","sources":["../src/authoring.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,UAAU,EACf,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACrB,KAAK,YAAY,EAClB,MAAM,gBAAgB,CAAC;AAExB,MAAM,MAAM,0BAA0B,GAAG,IAAI,CAAC,gBAAgB,EAAE,cAAc,GAAG,MAAM,CAAC,CAAC;AAEzF,qEAAqE;AACrE,wBAAgB,cAAc,CAAC,KAAK,CAAC,CAAC,SAAS,YAAY,EAAE,QAAQ,EAAE,CAAC,GAAG,CAAC,CAE3E;AAED,2FAA2F;AAC3F,wBAAgB,kBAAkB,CAAC,KAAK,CAAC,CAAC,SAAS,gBAAgB,EAAE,OAAO,EAAE,CAAC,GAAG,CAAC,CAElF;AAED,mGAAmG;AACnG,wBAAgB,gBAAgB,CAAC,KAAK,CAAC,CAAC,SAAS,cAAc,EAAE,UAAU,EAAE,CAAC,GAAG,CAAC,CAEjF;AAED,sEAAsE;AACtE,wBAAgB,cAAc,CAAC,KAAK,CAAC,CAAC,SAAS,YAAY,EAAE,QAAQ,EAAE,CAAC,GAAG,CAAC,CAE3E;AAED,oEAAoE;AACpE,wBAAgB,YAAY,CAAC,KAAK,CAAC,CAAC,SAAS,UAAU,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC,CAErE;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,CAAC,CAAC,SAAS,0BAA0B,EACvE,UAAU,EAAE,CAAC,GACZ,gBAAgB,GAAG,CAAC,CAQtB;AAED,yFAAyF;AACzF,wBAAgB,eAAe,CAAC,UAAU,EAAE,0BAA0B,GAAG,gBAAgB,GAAG,gBAAgB,CAM3G;AAED,0FAA0F;AAC1F,wBAAgB,YAAY,CAC1B,UAAU,EAAE,0BAA0B,GAAG,gBAAgB,EACzD,WAAW,SAAI,GACd,MAAM,CAKR;AAED,YAAY,EACV,gBAAgB,EAChB,cAAc,EACd,UAAU,EACV,YAAY,EACZ,gBAAgB,EAChB,YAAY,GACb,MAAM,gBAAgB,CAAC"}