@synapsor/runner 0.1.6 → 0.1.8

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.
@@ -26,6 +26,8 @@ CREATE AGENT CONTEXT local_operator
26
26
  END
27
27
 
28
28
  CREATE CAPABILITY billing.inspect_invoice
29
+ DESCRIPTION 'Inspect one invoice in the trusted tenant before proposing a waiver.'
30
+ RETURNS HINT 'Returns reviewed invoice fields plus evidence/query-audit handles.'
29
31
  USING CONTEXT local_operator
30
32
  SOURCE local_postgres
31
33
  ON public.invoices
@@ -33,13 +35,15 @@ CREATE CAPABILITY billing.inspect_invoice
33
35
  TENANT KEY tenant_id
34
36
  CONFLICT GUARD updated_at
35
37
  LOOKUP invoice_id BY id
36
- ARG invoice_id STRING REQUIRED MAX 128
38
+ ARG invoice_id STRING REQUIRED MAX LENGTH 128 DESCRIPTION 'Invoice id such as INV-3001.'
37
39
  ALLOW READ id, tenant_id, status, late_fee_cents, updated_at
38
40
  REQUIRE EVIDENCE
39
41
  MAX ROWS 1
40
42
  END
41
43
 
42
44
  CREATE CAPABILITY billing.propose_late_fee_waiver
45
+ DESCRIPTION 'Propose waiving one invoice late fee after inspecting invoice and policy evidence.'
46
+ RETURNS HINT 'Returns a review-required proposal id, exact diff, evidence handle, and source_database_changed:false.'
43
47
  USING CONTEXT local_operator
44
48
  SOURCE local_postgres
45
49
  ON public.invoices
@@ -47,8 +51,8 @@ CREATE CAPABILITY billing.propose_late_fee_waiver
47
51
  TENANT KEY tenant_id
48
52
  CONFLICT GUARD updated_at
49
53
  LOOKUP invoice_id BY id
50
- ARG invoice_id STRING REQUIRED MAX 128
51
- ARG reason TEXT REQUIRED MAX 500
54
+ ARG invoice_id STRING REQUIRED MAX LENGTH 128 DESCRIPTION 'Invoice id such as INV-3001.'
55
+ ARG reason TEXT REQUIRED MAX LENGTH 500 DESCRIPTION 'Business reason for the proposed waiver.'
52
56
  ALLOW READ id, tenant_id, status, late_fee_cents, waiver_reason, updated_at
53
57
  REQUIRE EVIDENCE
54
58
  MAX ROWS 1
@@ -56,6 +60,7 @@ CREATE CAPABILITY billing.propose_late_fee_waiver
56
60
  ALLOW WRITE late_fee_cents, waiver_reason
57
61
  PATCH late_fee_cents = 0
58
62
  PATCH waiver_reason = ARG reason
63
+ BOUND late_fee_cents 0..10000
59
64
  APPROVAL ROLE billing_lead
60
65
  WRITEBACK DIRECT SQL
61
66
  END
@@ -64,10 +69,15 @@ END
64
69
  Compile and validate:
65
70
 
66
71
  ```bash
67
- synapsor-runner dsl compile ./contract.synapsor --out ./synapsor.contract.json
72
+ synapsor-runner dsl compile ./contract.synapsor --out ./synapsor.contract.json --strict
68
73
  synapsor-runner contract validate ./synapsor.contract.json
69
74
  synapsor-runner contract bundle ./synapsor.contract.json --out ./synapsor-runner-bundle
70
75
  synapsor-runner cloud push ./synapsor.contract.json --dry-run
76
+ synapsor-runner cloud push ./synapsor.contract.json \
77
+ --api-url "$SYNAPSOR_CLOUD_BASE_URL" \
78
+ --token "$SYNAPSOR_CLOUD_TOKEN" \
79
+ --workspace "$SYNAPSOR_PROJECT_ID" \
80
+ --name billing-late-fee
71
81
  ```
72
82
 
73
83
  Reference the generated contract from local runner wiring:
@@ -95,6 +105,31 @@ synapsor-runner tools preview --config ./synapsor.runner.json --store ./.synapso
95
105
  synapsor-runner mcp serve --config ./synapsor.runner.json --store ./.synapsor/local.db
96
106
  ```
97
107
 
108
+ `--strict` treats DSL safety warnings as errors. Use it in CI so proposal
109
+ capabilities cannot accidentally lose descriptions, returns hints, or numeric
110
+ patch bounds during review.
111
+
112
+ ## DSL / JSON Capability Parity
113
+
114
+ The DSL compiles to canonical `@synapsor/spec` JSON. It must not silently weaken
115
+ reviewed runner JSON capabilities. Current parity:
116
+
117
+ | JSON field | DSL clause | Since | Notes |
118
+ | --- | --- | --- | --- |
119
+ | capability `description` | `DESCRIPTION '...'` | 0.1.8 | Recommended for every model-facing tool; strict mode warns when proposal capabilities omit it. |
120
+ | capability `returns_hint` | `RETURNS HINT '...'` | 0.1.8 | Recommended for every model-facing tool; strict mode warns when proposal capabilities omit it. |
121
+ | arg `description` | `ARG name TYPE ... DESCRIPTION '...'` | 0.1.8 | Used in MCP tool input schemas. |
122
+ | arg `minimum` | `ARG amount NUMBER MIN 1` | 0.1.8 | NUMBER args only. |
123
+ | arg `maximum` | `ARG amount NUMBER MAX 2500` | 0.1.8 | NUMBER args only. |
124
+ | arg `max_length` | `ARG reason TEXT MAX LENGTH 500` | 0.1.8 | STRING/TEXT args only. Legacy `MAX 500` is still accepted for existing DSL files, but `MAX LENGTH` is the reviewed spelling. |
125
+ | arg `enum` | Not expressible in DSL yet | 0.1 | Use embedded JSON or generated contract JSON when enum allowlists are required. |
126
+ | proposal `numeric_bounds` | `BOUND column 1..2500`, `BOUND column ..2500`, or `BOUND column 1..` | 0.1.8 | Applies to patched numeric columns. Strict mode warns when a NUMBER arg is patched without arg min/max or a matching `BOUND`. |
127
+ | proposal `transition_guards` | `TRANSITION status ALLOW pending -> approved\|rejected` or `TRANSITION status FROM current_status ALLOW open -> closed` | 0.1.8 | Values are state strings; use `|` for multiple target states. |
128
+ | proposal `conflict_guard` | `CONFLICT GUARD updated_at` | 0.1 | If omitted, DSL emits an explicit weak-guard acknowledgement. Prefer a real row-version column. |
129
+ | proposal `approval` | `APPROVAL ROLE billing_lead` | 0.1 | Local mode records the required role; enforcement is still outside the model-facing MCP tool. |
130
+ | proposal `writeback` | `WRITEBACK DIRECT SQL`, `WRITEBACK APP HANDLER EXECUTOR name`, `WRITEBACK CLOUD WORKER`, `WRITEBACK NONE` | 0.1.7 | Handler URLs/tokens stay in `synapsor.runner.json`; contracts carry only the handler name. |
131
+ | evidence options | `REQUIRE EVIDENCE` | 0.1 | Detailed evidence sources/handle prefixes are not expressible in DSL yet; use embedded JSON or generated contract JSON for those. |
132
+
98
133
  ## Direct Runner Config Path
99
134
 
100
135
  Directly embedding capabilities in `synapsor.runner.json` remains supported for
@@ -300,6 +335,34 @@ Use an app-owned executor when an approved proposal needs richer business work:
300
335
  creating a credit row, inserting an outbox event, updating multiple app tables,
301
336
  or calling your own service.
302
337
 
338
+ In DSL, keep the reviewed business contract portable and name the executor:
339
+
340
+ ```sql
341
+ CREATE CAPABILITY billing.propose_plan_credit
342
+ CONTEXT trusted_operator
343
+ SOURCE local_postgres
344
+ ON public.invoices
345
+ PRIMARY KEY id
346
+ TENANT KEY tenant_id
347
+ ARG invoice_id STRING REQUIRED
348
+ ARG amount_cents NUMBER REQUIRED
349
+ ARG reason STRING REQUIRED
350
+ LOOKUP invoice_id
351
+ VISIBLE id, tenant_id, customer_id, status, credit_requested_cents, credit_reason, updated_at
352
+ PROPOSE ACTION billing.grant_plan_credit
353
+ ALLOW WRITE credit_requested_cents, credit_reason
354
+ PATCH credit_requested_cents = ARG amount_cents
355
+ PATCH credit_reason = ARG reason
356
+ CONFLICT GUARD updated_at
357
+ APPROVAL ROLE billing_lead
358
+ WRITEBACK APP HANDLER EXECUTOR billing_handler
359
+ END
360
+ ```
361
+
362
+ `billing_handler` is contract content. Its URL, bearer-token env var, signing
363
+ secret env var, and timeout stay in `synapsor.runner.json` so credentials never
364
+ enter the portable contract:
365
+
303
366
  ```json
304
367
  "executors": {
305
368
  "billing_handler": {
@@ -316,7 +379,7 @@ or calling your own service.
316
379
  }
317
380
  ```
318
381
 
319
- Then reference it from a proposal capability:
382
+ For legacy embedded JSON capabilities, reference the same executor directly:
320
383
 
321
384
  ```json
322
385
  {
@@ -26,6 +26,17 @@ The fixture set is intentionally small in 0.1. It covers the runner-supported
26
26
  semantic surface first: trusted context, scoped reads, evidence handles,
27
27
  proposal boundaries, kept-out fields, manual approval, and replay envelopes.
28
28
 
29
+ Additional 0.1 parity coverage currently lives in tests and verification
30
+ scripts rather than separate `cloud-push/` or `dsl-json-parity/` conformance
31
+ fixture directories:
32
+
33
+ - `docs/dsl-json-parity.md`, DSL/spec tests, and the
34
+ `numeric-bounds-transition` C++ export fixture cover richer DSL/JSON parity
35
+ fields such as `returns_hint`, numeric bounds, and transition guards.
36
+ - The main Synapsor repo script `scripts/verify_contract_cloud_push.sh`
37
+ verifies real Cloud push, retrieval, idempotent versioning, unauthorized
38
+ rejection, and runner-bundle download against a live local control-plane.
39
+
29
40
  ## Runner Usage
30
41
 
31
42
  Runner tests load every conformance `contract.json` and verify that the MCP
@@ -351,6 +351,28 @@ It launches the official MCP stdio client transport against `synapsor-runner mcp
351
351
  The business state changed after the agent saw it, so Synapsor refused to commit.
352
352
  ```
353
353
 
354
+ The same live writeback smoke has a clearer release-check alias:
355
+
356
+ ```bash
357
+ corepack pnpm test:live-apply
358
+ ```
359
+
360
+ Prerequisites:
361
+
362
+ - Docker daemon running;
363
+ - local ports `55433`, `55434`, and `53307` available;
364
+ - no Synapsor Cloud account, API key, hosted workspace, or production database.
365
+
366
+ Expected output:
367
+
368
+ - disposable Postgres billing, Postgres support, and MySQL orders containers start;
369
+ - MCP `tools/list` exposes reviewed semantic tools, not raw SQL;
370
+ - proposal calls create exact before/after diffs while source rows remain unchanged;
371
+ - local approval happens outside MCP;
372
+ - guarded writeback applies approved jobs and records receipts/replay;
373
+ - idempotent retry returns the existing receipt;
374
+ - a stale-row write is blocked as a conflict.
375
+
354
376
  ## Optional MCP client configs
355
377
 
356
378
  After the Docker demo passes, developers who want to attach an MCP client can use the checked-in stdio config shapes in:
@@ -139,7 +139,7 @@ You can also compile from the SQL-like authoring layer:
139
139
 
140
140
  ```bash
141
141
  synapsor-runner dsl validate ./contract.synapsor
142
- synapsor-runner dsl compile ./contract.synapsor --out ./synapsor.contract.json
142
+ synapsor-runner dsl compile ./contract.synapsor --out ./synapsor.contract.json --strict
143
143
  ```
144
144
 
145
145
  ## Bundle For Local Runner
@@ -10,6 +10,36 @@ npx -y -p @synapsor/runner synapsor-runner demo --quick
10
10
  The OSS runner command is `synapsor-runner`. The `synapsor` command is reserved
11
11
  for the Synapsor Cloud CLI.
12
12
 
13
+ ## Unreleased
14
+
15
+ ### DSL / JSON Contract Parity
16
+
17
+ - Adds portable spec fields for capability `returns_hint`, proposal
18
+ `numeric_bounds`, and proposal `transition_guards`.
19
+ - Extends the DSL with `DESCRIPTION`, `RETURNS HINT`, arg descriptions,
20
+ numeric arg min/max, text `MAX LENGTH`, patch `BOUND`, and `TRANSITION`
21
+ clauses.
22
+ - Adds DSL warnings and `--strict` mode so proposal capabilities cannot
23
+ silently lose reviewed safety metadata.
24
+ - Preserves compiled bounds through `contracts: []` into Runner propose-time
25
+ enforcement and accepts pure-contract configs with `capabilities: []`.
26
+ - Adds `docs/dsl-json-parity.md` as the field-by-field support matrix across
27
+ JSON spec, DSL, Runner, C++/Cloud, and Cloud push.
28
+
29
+ ### Cloud Registry Push
30
+
31
+ - Wires non-dry-run `synapsor-runner cloud push` to the Cloud control API.
32
+ - Keeps dry-run network-free and prints server-confirmed contract, version,
33
+ digest, and registry details for real uploads.
34
+ - Adds clearer 401/403/404/409/422/network error messages without printing
35
+ bearer tokens.
36
+
37
+ ### Release Verification
38
+
39
+ - Adds `corepack pnpm test:live-apply` as the documented Docker-backed live
40
+ apply smoke for disposable Postgres/MySQL MCP examples, guarded writeback,
41
+ idempotent retry, stale-row conflict, receipts, and replay.
42
+
13
43
  ## 0.1.5
14
44
 
15
45
  ### Contract Authoring Front Door
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synapsor/runner",
3
- "version": "0.1.6",
3
+ "version": "0.1.8",
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",
@@ -52,11 +52,6 @@
52
52
  "engines": {
53
53
  "node": ">=22.5.0"
54
54
  },
55
- "scripts": {
56
- "build": "tsc -b && node ../../scripts/build-runner-package.mjs",
57
- "prepack": "cd ../.. && corepack pnpm build:runner-package",
58
- "test": "vitest run"
59
- },
60
55
  "dependencies": {
61
56
  "@modelcontextprotocol/sdk": "1.29.0",
62
57
  "mysql2": "^3.11.0",
@@ -77,5 +72,9 @@
77
72
  },
78
73
  "publishConfig": {
79
74
  "access": "public"
75
+ },
76
+ "scripts": {
77
+ "build": "tsc -b && node ../../scripts/build-runner-package.mjs",
78
+ "test": "vitest run"
80
79
  }
81
- }
80
+ }