@synapsor/runner 1.6.2 → 1.6.4

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 (116) hide show
  1. package/AGENTS.md +2 -2
  2. package/CHANGELOG.md +141 -2
  3. package/CONTRIBUTING.md +10 -3
  4. package/README.md +65 -83
  5. package/SECURITY.md +14 -2
  6. package/THREAT_MODEL.md +64 -4
  7. package/dist/authoring.mjs +151 -16
  8. package/dist/cli.d.ts +31 -3
  9. package/dist/cli.d.ts.map +1 -1
  10. package/dist/local-ui.d.ts +145 -1
  11. package/dist/local-ui.d.ts.map +1 -1
  12. package/dist/runner.mjs +37488 -19009
  13. package/dist/runtime.mjs +4056 -235
  14. package/dist/shadow.mjs +2423 -65
  15. package/docs/README.md +36 -2
  16. package/docs/agent-guided-setup.md +239 -0
  17. package/docs/aggregate-reads.md +14 -5
  18. package/docs/app-owned-executors.md +5 -6
  19. package/docs/approval-roles-and-operator-identity.md +353 -0
  20. package/docs/auto-boundary-and-scoped-explore.md +89 -11
  21. package/docs/capability-authoring.md +21 -2
  22. package/docs/client-recipes.md +1 -1
  23. package/docs/cloud-mode.md +7 -7
  24. package/docs/conformance.md +6 -3
  25. package/docs/current-scope.md +32 -2
  26. package/docs/cursor-plugin.md +3 -3
  27. package/docs/database-enforced-scope.md +6 -0
  28. package/docs/dsl-json-parity.md +75 -0
  29. package/docs/dsl-reference.md +22 -1
  30. package/docs/fresh-developer-usability.md +155 -80
  31. package/docs/getting-started-own-database.md +45 -44
  32. package/docs/guarded-crud-writeback.md +19 -0
  33. package/docs/guided-onboarding.md +399 -0
  34. package/docs/human-attention-notifications.md +367 -0
  35. package/docs/limitations.md +49 -13
  36. package/docs/local-mode.md +36 -22
  37. package/docs/mcp-audit.md +14 -14
  38. package/docs/mcp-client-setup.md +11 -14
  39. package/docs/mcp-clients.md +1 -1
  40. package/docs/migrating-to-synapsor-spec.md +42 -0
  41. package/docs/openai-agents-sdk.md +2 -2
  42. package/docs/production.md +39 -0
  43. package/docs/proposal-evidence-freshness.md +7 -7
  44. package/docs/recipes.md +6 -6
  45. package/docs/release-notes.md +144 -4
  46. package/docs/release-policy.md +20 -7
  47. package/docs/reversible-change-sets.md +1 -1
  48. package/docs/reviewed-database-views.md +132 -0
  49. package/docs/reviewed-relationships.md +245 -0
  50. package/docs/rfcs/006-reviewed-reversible-change-sets.md +1 -1
  51. package/docs/runner-bundles.md +7 -7
  52. package/docs/runner-config-reference.md +132 -0
  53. package/docs/running-a-runner-fleet.md +16 -1
  54. package/docs/schema-api-candidates.md +1 -1
  55. package/docs/security-boundary.md +54 -0
  56. package/docs/store-lifecycle.md +20 -1
  57. package/docs/supervised-automatic-apply.md +267 -0
  58. package/docs/troubleshooting-first-run.md +85 -10
  59. package/docs/use-your-own-database.md +6 -4
  60. package/docs/workbench-ask.md +279 -0
  61. package/docs/writeback-executors.md +7 -7
  62. package/examples/auto-boundary-churn/README.md +1 -1
  63. package/examples/community-solar-clean-room/README.md +7 -0
  64. package/examples/community-solar-clean-room/docker-compose.yml +16 -0
  65. package/examples/community-solar-clean-room/package.json +15 -0
  66. package/examples/community-solar-clean-room/prisma/schema.prisma +171 -0
  67. package/examples/community-solar-clean-room/seed/postgres.sql +571 -0
  68. package/examples/fitflow-guided-onboarding/README.md +43 -0
  69. package/examples/fitflow-guided-onboarding/app/page.tsx +8 -0
  70. package/examples/fitflow-guided-onboarding/docker-compose.yml +16 -0
  71. package/examples/fitflow-guided-onboarding/package.json +18 -0
  72. package/examples/fitflow-guided-onboarding/prisma/schema.prisma +98 -0
  73. package/examples/fitflow-guided-onboarding/seed/postgres.sql +401 -0
  74. package/examples/openai-agents-http/Makefile +1 -1
  75. package/examples/openai-agents-http/README.md +1 -1
  76. package/examples/openai-agents-stdio/Makefile +1 -1
  77. package/examples/openai-agents-stdio/README.md +2 -2
  78. package/examples/openai-agents-stdio/agent.py +1 -4
  79. package/examples/operator-oidc/issuer.mjs +188 -0
  80. package/examples/reference-support-billing-app/README.md +16 -16
  81. package/examples/retail-clean-room/README.md +7 -0
  82. package/examples/retail-clean-room/docker-compose.yml +16 -0
  83. package/examples/retail-clean-room/package.json +9 -0
  84. package/examples/retail-clean-room/prisma/schema.prisma +239 -0
  85. package/examples/retail-clean-room/seed/postgres.sql +781 -0
  86. package/examples/retail-clean-room/view-recipe/average-retained-revenue.synapsor.sql +21 -0
  87. package/examples/retail-clean-room/view-recipe/synapsor.runner.json +25 -0
  88. package/examples/support-plan-credit/README.md +6 -2
  89. package/examples/support-plan-credit/mcp-client-examples/claude-code.sh +1 -4
  90. package/examples/support-plan-credit/mcp-client-examples/claude-desktop.json +1 -4
  91. package/examples/support-plan-credit/mcp-client-examples/codex.config.toml +1 -4
  92. package/examples/support-plan-credit/mcp-client-examples/cursor-global.mcp.json +1 -4
  93. package/examples/support-plan-credit/mcp-client-examples/cursor-project.mcp.json +1 -4
  94. package/examples/support-plan-credit/mcp-client-examples/generic-stdio.json +1 -4
  95. package/examples/support-plan-credit/mcp-client-examples/generic-stdio.mjs +1 -1
  96. package/examples/support-plan-credit/mcp-client-examples/google-adk.py +1 -1
  97. package/examples/support-plan-credit/mcp-client-examples/langchain.mjs +1 -1
  98. package/examples/support-plan-credit/mcp-client-examples/llamaindex.py +1 -1
  99. package/examples/support-plan-credit/mcp-client-examples/openai-agents-stdio.ts +1 -1
  100. package/examples/support-plan-credit/mcp-client-examples/vscode.mcp.json +1 -4
  101. package/fixtures/compatibility/published-1.6.3/manifest.json +76 -0
  102. package/fixtures/compatibility/published-1.6.3/sources/packages/dsl/examples/aggregate-read.synapsor.sql +21 -0
  103. package/fixtures/compatibility/published-1.6.3/sources/packages/dsl/examples/billing-late-fee.synapsor.sql +56 -0
  104. package/fixtures/compatibility/published-1.6.3/sources/packages/dsl/examples/bounded-set-multi-term.synapsor.sql +30 -0
  105. package/fixtures/compatibility/published-1.6.3/sources/packages/dsl/examples/principal-row-scope.synapsor.sql +23 -0
  106. package/fixtures/compatibility/published-1.6.3/sources/packages/spec/fixtures/conformance/aggregate-read/contract.json +119 -0
  107. package/fixtures/compatibility/published-1.6.3/sources/packages/spec/fixtures/conformance/approval-quorum/contract.json +44 -0
  108. package/fixtures/compatibility/published-1.6.3/sources/packages/spec/fixtures/conformance/bounded-set-threats/contract.json +115 -0
  109. package/fixtures/compatibility/published-1.6.3/sources/packages/spec/fixtures/conformance/principal-row-scope/contract.json +78 -0
  110. package/fixtures/compatibility/published-1.6.3/sources/packages/spec/fixtures/conformance/proposal-capability/contract.json +101 -0
  111. package/fixtures/compatibility/published-1.6.3/sources/packages/spec/fixtures/conformance/reversible-change-sets/contract.json +98 -0
  112. package/fixtures/compatibility/published-1.6.3/sources/packages/spec/fixtures/valid/basic-read.contract.json +60 -0
  113. package/llms.txt +10 -5
  114. package/package.json +11 -3
  115. package/schemas/schema-candidate-review.schema.json +42 -0
  116. package/schemas/synapsor.runner.schema.json +227 -4
@@ -14,18 +14,16 @@ review artifacts without sampling source rows or using an LLM.
14
14
 
15
15
  ## Fast path
16
16
 
17
- Set a dedicated SELECT-only, non-owner database URL plus trusted development
18
- scope and run the public guided path:
17
+ Run the public guided path:
19
18
 
20
19
  ```bash
21
- export DATABASE_URL="<postgres-or-mysql-read-url>"
22
- export SYNAPSOR_TENANT_ID="<staging-tenant>"
23
- export SYNAPSOR_PRINCIPAL="<developer-id>"
24
- npx -y -p @synapsor/runner synapsor-runner start --from-env DATABASE_URL
20
+ npx -y @synapsor/runner start
25
21
  ```
26
22
 
27
- A fresh interactive project with no existing config, selector, or automation
28
- input follows:
23
+ Paste a dedicated SELECT-only, non-owner URL into the hidden prompt, explicitly
24
+ approve a regular project `.env` file for this process, or export
25
+ `DATABASE_URL`. A fresh interactive project with no existing config, selector,
26
+ or automation input follows:
29
27
 
30
28
  ```text
31
29
  inspect the whole selected schema and structured application artifacts
@@ -43,10 +41,13 @@ It does not print your database URL, put the URL in MCP client config, expose
43
41
  `execute_sql`, expose approval/commit tools, or give the model write
44
42
  credentials. Before boundary activation it does not read source rows.
45
43
 
46
- `start --from-env` is the shortest public command for first-run onboarding.
47
- Read [Auto Boundary, Scoped Explore, And
48
- Protect](auto-boundary-and-scoped-explore.md) for the complete command and
49
- security reference.
44
+ `start` is the shortest public command for first-run onboarding. When
45
+ `DATABASE_URL` is already exported, Runner uses it automatically. Explicit
46
+ `--from-env`, `--schema`, and `--project-root` values always win.
47
+ Read [Database To First Safe Tool](guided-onboarding.md) for the timed guided
48
+ journey and [Auto Boundary, Scoped Explore, And
49
+ Protect](auto-boundary-and-scoped-explore.md) for the complete security
50
+ reference.
50
51
 
51
52
  Established routes remain unchanged. `--table`, `--answers`, `onboard db`,
52
53
  explicit `init` flags, existing configs, headless startup, JSON output, and CI
@@ -103,7 +104,7 @@ before using staging or production-like data.
103
104
  ## 2. Inspect metadata
104
105
 
105
106
  ```bash
106
- npx -y -p @synapsor/runner synapsor-runner inspect \
107
+ npx -y @synapsor/runner inspect \
107
108
  --engine auto \
108
109
  --from-env DATABASE_URL \
109
110
  --schema public
@@ -112,13 +113,13 @@ npx -y -p @synapsor/runner synapsor-runner inspect \
112
113
  For a disposable staging URL, this also works:
113
114
 
114
115
  ```bash
115
- npx -y -p @synapsor/runner synapsor-runner inspect "$DATABASE_URL" --engine auto --schema public
116
+ npx -y @synapsor/runner inspect "$DATABASE_URL" --engine auto --schema public
116
117
  ```
117
118
 
118
119
  For automation:
119
120
 
120
121
  ```bash
121
- npx -y -p @synapsor/runner synapsor-runner inspect \
122
+ npx -y @synapsor/runner inspect \
122
123
  --engine postgres \
123
124
  --from-env DATABASE_URL \
124
125
  --schema public \
@@ -135,9 +136,9 @@ to your staging table, primary key, tenant key, conflict column, visible fields,
135
136
  allowed write fields, and business limits.
136
137
 
137
138
  ```bash
138
- npx -y -p @synapsor/runner synapsor-runner recipes list
139
- npx -y -p @synapsor/runner synapsor-runner recipes show billing.late_fee_waiver
140
- npx -y -p @synapsor/runner synapsor-runner recipes init billing.late_fee_waiver --output synapsor.runner.json
139
+ npx -y @synapsor/runner recipes list
140
+ npx -y @synapsor/runner recipes show billing.late_fee_waiver
141
+ npx -y @synapsor/runner recipes init billing.late_fee_waiver --output synapsor.runner.json
141
142
  ```
142
143
 
143
144
  Use a recipe when the shape is close. Use the guided wizard or explicit flags
@@ -152,7 +153,7 @@ only the capabilities in your generated `synapsor.runner.json`.
152
153
  In an interactive terminal, run the guided wizard:
153
154
 
154
155
  ```bash
155
- npx -y -p @synapsor/runner synapsor-runner init --from-env DATABASE_URL --mode read_only --wizard
156
+ npx -y @synapsor/runner init --from-env DATABASE_URL --mode read_only --wizard
156
157
  ```
157
158
 
158
159
  The generated context and capabilities are based on your selections. Synapsor
@@ -297,7 +298,7 @@ If you already know the reviewed table/action, generate config directly from
297
298
  metadata and explicit flags:
298
299
 
299
300
  ```bash
300
- npx -y -p @synapsor/runner synapsor-runner init \
301
+ npx -y @synapsor/runner init \
301
302
  --from-env DATABASE_URL \
302
303
  --engine postgres \
303
304
  --schema public \
@@ -321,7 +322,7 @@ when you want exact capability names in the generated contract.
321
322
  For app-owned writeback, replace the direct writer env with a handler executor:
322
323
 
323
324
  ```bash
324
- npx -y -p @synapsor/runner synapsor-runner init \
325
+ npx -y @synapsor/runner init \
325
326
  --from-env DATABASE_URL \
326
327
  --engine postgres \
327
328
  --schema public \
@@ -350,7 +351,7 @@ source primary/unique dedup key; DELETE requires an exact conflict guard and
350
351
  safe cascade/trigger inspection:
351
352
 
352
353
  ```bash
353
- npx -y -p @synapsor/runner synapsor-runner onboard db \
354
+ npx -y @synapsor/runner onboard db \
354
355
  --from-env DATABASE_URL \
355
356
  --table account_credits \
356
357
  --mode review \
@@ -369,7 +370,7 @@ but ambiguous post-commit crashes stop for operator reconciliation.
369
370
  Or generate from a saved inspection snapshot without reconnecting:
370
371
 
371
372
  ```bash
372
- npx -y -p @synapsor/runner synapsor-runner init \
373
+ npx -y @synapsor/runner init \
373
374
  --inspection-json schema-inspection.json \
374
375
  --table invoices \
375
376
  --namespace billing \
@@ -439,7 +440,7 @@ contain database URLs or passwords.
439
440
  ## 6. Generate runner files
440
441
 
441
442
  ```bash
442
- npx -y -p @synapsor/runner synapsor-runner init \
443
+ npx -y @synapsor/runner init \
443
444
  --spec onboarding-selection.json \
444
445
  --non-interactive
445
446
  ```
@@ -459,16 +460,16 @@ files.
459
460
  Generate or refresh MCP client snippets later with:
460
461
 
461
462
  ```bash
462
- npx -y -p @synapsor/runner synapsor-runner mcp config generic --config ./synapsor.runner.json --store ./.synapsor/local.db
463
- npx -y -p @synapsor/runner synapsor-runner mcp config claude-desktop --config ./synapsor.runner.json --store ./.synapsor/local.db
464
- npx -y -p @synapsor/runner synapsor-runner mcp config cursor --config ./synapsor.runner.json --store ./.synapsor/local.db
465
- npx -y -p @synapsor/runner synapsor-runner tools preview --config ./synapsor.runner.json --store ./.synapsor/local.db
463
+ npx -y @synapsor/runner mcp config generic --config ./synapsor.runner.json --store ./.synapsor/local.db
464
+ npx -y @synapsor/runner mcp config claude-desktop --config ./synapsor.runner.json --store ./.synapsor/local.db
465
+ npx -y @synapsor/runner mcp config cursor --config ./synapsor.runner.json --store ./.synapsor/local.db
466
+ npx -y @synapsor/runner tools preview --config ./synapsor.runner.json --store ./.synapsor/local.db
466
467
  ```
467
468
 
468
469
  Call one generated tool locally before wiring an MCP client:
469
470
 
470
471
  ```bash
471
- npx -y -p @synapsor/runner synapsor-runner smoke call --config ./synapsor.runner.json --store ./.synapsor/local.db
472
+ npx -y @synapsor/runner smoke call --config ./synapsor.runner.json --store ./.synapsor/local.db
472
473
  ```
473
474
 
474
475
  `smoke call` uses the same runtime as the MCP server. It records evidence and
@@ -488,8 +489,8 @@ URLs, passwords, approval tools, commit tools, or write credentials.
488
489
  ## 7. Validate the config
489
490
 
490
491
  ```bash
491
- npx -y -p @synapsor/runner synapsor-runner config validate --config synapsor.runner.json
492
- npx -y -p @synapsor/runner synapsor-runner config show --config synapsor.runner.json --redacted
492
+ npx -y @synapsor/runner config validate --config synapsor.runner.json
493
+ npx -y @synapsor/runner config show --config synapsor.runner.json --redacted
493
494
  ```
494
495
 
495
496
  The config stores environment-variable names, not connection-string values.
@@ -497,7 +498,7 @@ The config stores environment-variable names, not connection-string values.
497
498
  Run doctor after setting the referenced environment variables:
498
499
 
499
500
  ```bash
500
- npx -y -p @synapsor/runner synapsor-runner doctor --config synapsor.runner.json
501
+ npx -y @synapsor/runner doctor --config synapsor.runner.json
501
502
  ```
502
503
 
503
504
  Doctor validates config shape, trusted context env vars, source env vars,
@@ -505,7 +506,7 @@ read/write credential separation, table/column metadata when the read URL is
505
506
  available, and the semantic MCP tool boundary. Use JSON for automation:
506
507
 
507
508
  ```bash
508
- npx -y -p @synapsor/runner synapsor-runner doctor --config synapsor.runner.json --json
509
+ npx -y @synapsor/runner doctor --config synapsor.runner.json --json
509
510
  ```
510
511
 
511
512
  ## 8. Serve semantic MCP tools
@@ -515,7 +516,7 @@ Use stdio when a local MCP client can launch Synapsor Runner:
515
516
  ```bash
516
517
  export SYNAPSOR_TENANT_ID="acme"
517
518
  export SYNAPSOR_PRINCIPAL="local_operator"
518
- npx -y -p @synapsor/runner synapsor-runner mcp serve --config ./synapsor.runner.json --store ./.synapsor/local.db
519
+ npx -y @synapsor/runner mcp serve --config ./synapsor.runner.json --store ./.synapsor/local.db
519
520
  ```
520
521
 
521
522
  Use Streamable HTTP when an app/server agent connects through a standard HTTP
@@ -526,7 +527,7 @@ export SYNAPSOR_TENANT_ID="acme"
526
527
  export SYNAPSOR_PRINCIPAL="local_operator"
527
528
  export SYNAPSOR_RUNNER_HTTP_TOKEN="$(node -e 'process.stdout.write(require("node:crypto").randomBytes(32).toString("base64url"))')"
528
529
 
529
- npx -y -p @synapsor/runner synapsor-runner up --serve \
530
+ npx -y @synapsor/runner up --serve \
530
531
  --config ./synapsor.runner.json \
531
532
  --store ./.synapsor/local.db \
532
533
  --auth-token-env SYNAPSOR_RUNNER_HTTP_TOKEN
@@ -540,7 +541,7 @@ serving.
540
541
  The lower-level MCP command starts the same transport directly:
541
542
 
542
543
  ```bash
543
- npx -y -p @synapsor/runner synapsor-runner mcp serve-streamable-http \
544
+ npx -y @synapsor/runner mcp serve-streamable-http \
544
545
  --config ./synapsor.runner.json \
545
546
  --store ./.synapsor/local.db \
546
547
  --auth-token-env SYNAPSOR_RUNNER_HTTP_TOKEN
@@ -571,10 +572,10 @@ tools, commit tools, database URLs, write credentials, or tenant authority.
571
572
  Proposal tools leave the source database unchanged. Review locally:
572
573
 
573
574
  ```bash
574
- npx -y -p @synapsor/runner synapsor-runner proposals list --store ./.synapsor/local.db
575
- npx -y -p @synapsor/runner synapsor-runner proposals show wrp_123 --store ./.synapsor/local.db
576
- npx -y -p @synapsor/runner synapsor-runner proposals approve wrp_123 --store ./.synapsor/local.db --actor local_reviewer --yes
577
- npx -y -p @synapsor/runner synapsor-runner proposals writeback-job wrp_123 --store ./.synapsor/local.db --output job.json
575
+ npx -y @synapsor/runner proposals list --store ./.synapsor/local.db
576
+ npx -y @synapsor/runner proposals show wrp_123 --store ./.synapsor/local.db
577
+ npx -y @synapsor/runner proposals approve wrp_123 --store ./.synapsor/local.db --actor local_reviewer --yes
578
+ npx -y @synapsor/runner proposals writeback-job wrp_123 --store ./.synapsor/local.db --output job.json
578
579
  ```
579
580
 
580
581
  Apply through the trusted worker path with a separate writer credential:
@@ -582,7 +583,7 @@ Apply through the trusted worker path with a separate writer credential:
582
583
  ```bash
583
584
  export SYNAPSOR_DATABASE_WRITE_URL="<postgres-or-mysql-write-url>"
584
585
  SYNAPSOR_ENGINE=postgres \
585
- npx -y -p @synapsor/runner synapsor-runner apply --job job.json --config synapsor.runner.json --store ./.synapsor/local.db
586
+ npx -y @synapsor/runner apply --job job.json --config synapsor.runner.json --store ./.synapsor/local.db
586
587
  ```
587
588
 
588
589
  For `apply --job ... --config ...`, Runner reads the write credential from the
@@ -596,7 +597,7 @@ from environment variables, and the handler receives a structured proposal/job
596
597
  payload, not arbitrary model SQL:
597
598
 
598
599
  ```bash
599
- npx -y -p @synapsor/runner synapsor-runner apply --proposal wrp_123 --config synapsor.runner.json --store ./.synapsor/local.db
600
+ npx -y @synapsor/runner apply --proposal wrp_123 --config synapsor.runner.json --store ./.synapsor/local.db
600
601
  ```
601
602
 
602
603
  See [Writeback Executors](writeback-executors.md).
@@ -604,8 +605,8 @@ See [Writeback Executors](writeback-executors.md).
604
605
  Replay afterward:
605
606
 
606
607
  ```bash
607
- npx -y -p @synapsor/runner synapsor-runner replay show wrp_123 --store ./.synapsor/local.db
608
- npx -y -p @synapsor/runner synapsor-runner replay export wrp_123 --store ./.synapsor/local.db --output replay.json
608
+ npx -y @synapsor/runner replay show wrp_123 --store ./.synapsor/local.db
609
+ npx -y @synapsor/runner replay export wrp_123 --store ./.synapsor/local.db --output replay.json
609
610
  ```
610
611
 
611
612
  ## Boundary
@@ -119,6 +119,12 @@ APPROVAL ROLE billing_reviewer
119
119
  WRITEBACK DIRECT SQL
120
120
  ```
121
121
 
122
+ The role requirement is enforced against verified operator identity outside
123
+ MCP; it is not a PostgreSQL role or model argument. Apply has its own role
124
+ gate. See [Approval Roles And Verified Operator
125
+ Identity](approval-roles-and-operator-identity.md) for the complete tested
126
+ OIDC/JWKS and signed-key paths.
127
+
122
128
  Guarded `INSERT` needs a source-unique, Runner-supplied dedup identity:
123
129
 
124
130
  ```sql
@@ -212,6 +218,19 @@ Resolution appends immutable events and a reconciliation receipt. It does not
212
218
  rewrite history or retry the source mutation. Configured production operator
213
219
  identity is required when enabled.
214
220
 
221
+ ## Optional supervised execution
222
+
223
+ Manual apply remains the default, including for `AUTO APPROVE`. Runner can
224
+ optionally let a separately trusted worker consume approved single-row
225
+ `INSERT`/`UPDATE` proposals, but only after contract permission and an
226
+ independent deployment allowlist bind the exact active digest. The worker
227
+ reuses this same guarded path and repeats current source/evidence, policy,
228
+ limit, writer-posture, receipt, and lease checks immediately before apply.
229
+
230
+ Hard `DELETE`, reversible actions, app-owned executors, and multi-row writes
231
+ are not eligible for the first automatic path. See
232
+ [Operator-Supervised Automatic Apply](supervised-automatic-apply.md).
233
+
215
234
  ## Verification
216
235
 
217
236
  The repository includes a disposable Postgres/MySQL test that proves every
@@ -0,0 +1,399 @@
1
+ # Guided Onboarding: Database To First Safe Tool
2
+
3
+ This is the shortest path from an existing staging Postgres/MySQL database to
4
+ one useful agent tool. It requires no Synapsor account, Cloud login, database
5
+ replication, global install, MCP host, model API key, or hand-authored config,
6
+ DSL, JSON, SQL, DDL, or grants.
7
+
8
+ ## The One-Minute Mental Model
9
+
10
+ Synapsor is creating the small set of database powers your agent may use. It
11
+ does not give the agent SQL access.
12
+
13
+ - Reads return only fields a human reviewed, under tenant and principal scope
14
+ supplied outside model arguments.
15
+ - Scoped Explore is a temporary local development/staging authoring tool.
16
+ - Protect turns one useful analysis into a narrow named capability.
17
+ - A model-facing write call creates an exact proposal. It does not commit.
18
+ - The model cannot activate authority, approve a proposal, or apply a write.
19
+ - A trusted operator or worker rechecks the effect and records a receipt.
20
+
21
+ ## Before You Start
22
+
23
+ Use a disposable or staging database and a dedicated SELECT-only, non-owner
24
+ credential. Keep row-level security, restricted views, or tenant-bound
25
+ credentials underneath Runner where available.
26
+
27
+ Do not put a database URL in project documentation or chat. The shortest path
28
+ uses a hidden terminal prompt:
29
+
30
+ ```bash
31
+ npx -y @synapsor/runner start
32
+ ```
33
+
34
+ Runner can also use an already-exported `DATABASE_URL`. When a regular `.env`
35
+ or `.env.local` file exists, it asks before reading that file and holds the
36
+ selected value only for the current Runner/Workbench process. The URL is not
37
+ written to generated artifacts or the ledger. Runner requires Node 22.13 or
38
+ newer.
39
+
40
+ ## One Command To Workbench
41
+
42
+ Run this from an empty project directory or your application root:
43
+
44
+ ```bash
45
+ npx -y @synapsor/runner start
46
+ ```
47
+
48
+ The command automatically:
49
+
50
+ 1. checks the database and credential posture;
51
+ 2. inspects schema metadata without sampling source rows;
52
+ 3. statically reads supported Prisma, Drizzle, OpenAPI, and existing Synapsor
53
+ definitions when present;
54
+ 4. drafts disabled public DSL, canonical JSON, tests, and a generation lock;
55
+ 5. creates a valid zero-authority Runner config and local SQLite ledger;
56
+ 6. validates every generated artifact;
57
+ 7. opens one secured loopback Workbench URL.
58
+
59
+ Before human activation, the agent has no generated authority and no source row
60
+ has been read. On an explicitly asserted personal development database,
61
+ Workbench offers a fast lane:
62
+
63
+ 1. confirm the database is your own development or disposable test data;
64
+ 2. provide the trusted tenant/principal scope for this in-memory session;
65
+ 3. inspect the one-resource summary and select **Activate this narrow read and
66
+ show a real result**.
67
+
68
+ The single gesture is recorded against the exact boundary digest. Runner
69
+ rechecks schema and read-only role posture, activates one resource with no
70
+ relationships, keeps sensitive and uncertain fields out, and runs one real
71
+ bounded aggregate read. Shared, staging, production-like, remote, widening, and
72
+ write paths do not use this shortcut.
73
+
74
+ Running the same command again resumes. Resume and Try do not rescan, rewrite
75
+ files, or change a digest. Rescan and destructive Start over remain explicit
76
+ human choices.
77
+
78
+ Workbench requires no additional terminal command. If you choose the CLI
79
+ fallbacks below after the first success, install Runner once:
80
+
81
+ ```bash
82
+ npm install -g @synapsor/runner
83
+ ```
84
+
85
+ The remaining examples then use `synapsor-runner` directly instead of
86
+ reacquiring the npm package for every command.
87
+
88
+ ## Five Minutes: First Safe Read
89
+
90
+ The full Workbench path starts with an overview, not a permission matrix. It
91
+ shows:
92
+
93
+ - database and framework evidence found;
94
+ - resources inspected;
95
+ - fields already kept out;
96
+ - unresolved sensitive fields;
97
+ - row identity;
98
+ - tenant and principal scope;
99
+ - database-role and RLS posture;
100
+ - ready and blocked capabilities.
101
+
102
+ Review only the exceptions. Routine conservative defaults are already applied.
103
+ There is no global “approve everything” control.
104
+
105
+ For each selected resource, confirm the exact primary/unique row identity,
106
+ trusted scope, visible fields, kept-out fields, and any aggregate-only fields.
107
+ Then sign the displayed digest. Changing a reviewed decision creates a new
108
+ disabled digest.
109
+
110
+ Choose **Try first safe read**. Runner calls the real local runtime and shows:
111
+
112
+ ```text
113
+ Your first safe tool is working.
114
+
115
+ Tool: <domain>.inspect_<resource>
116
+ Agent can see: <reviewed fields>
117
+ Agent cannot see: <kept-out fields>
118
+ Tenant scope: trusted outside model arguments
119
+ Principal scope: trusted outside model arguments
120
+ Source database changed: no
121
+ ```
122
+
123
+ CLI fallback:
124
+
125
+ ```bash
126
+ synapsor-runner try call --list --format json
127
+ synapsor-runner try call <returned-tool-name> --sample --json
128
+ ```
129
+
130
+ The second command is for an activated named tool with valid generated sample
131
+ input. It does not invent tenant or principal values.
132
+
133
+ ## Optional: Ask Through Your Own Model
134
+
135
+ The no-model Workbench composer is already complete; a provider key is never
136
+ required for onboarding. If you want a chat surface before installing Cursor
137
+ or another MCP client, open **Analyze -> Ask with your model**.
138
+
139
+ Workbench shows the exact reviewed tools first. Select OpenAI, Anthropic, or a
140
+ custom OpenAI-compatible endpoint, choose a named environment credential or a
141
+ session-only masked paste, and acknowledge that reviewed visible data may go
142
+ directly to that provider. Synapsor does not relay it.
143
+
144
+ The provider can request only the displayed tools. It cannot choose trusted
145
+ scope, activate or Protect authority, approve or apply a proposal, or configure
146
+ Runner. A write request produces the same inert proposal as external MCP:
147
+
148
+ ```text
149
+ Proposal only
150
+ Source database changed: no
151
+ The model cannot approve or apply this proposal.
152
+ ```
153
+
154
+ Changing the provider, model, endpoint, runtime config, or reviewed boundary
155
+ requires a new egress acknowledgement. Select **Clear** to cancel and discard
156
+ the in-memory provider configuration and conversation. See [Workbench Ask With
157
+ Your Model](workbench-ask.md) for key handling, endpoint security, fixed bounds,
158
+ the tested provider matrix, and the full no-model alternative.
159
+
160
+ ## Ten Minutes: Explore And Protect
161
+
162
+ Scoped Explore is available only after its exact local authoring boundary is
163
+ activated. It is absent from production, unknown-profile, remote, shared HTTP,
164
+ and non-loopback `tools/list`.
165
+
166
+ In Workbench, choose **Ask an aggregate question**. Select only reviewed
167
+ resources, dimensions, measures, filters, and time buckets. No SQL or plan JSON
168
+ is required.
169
+
170
+ The first release supports bounded:
171
+
172
+ - `count` and reviewed `count_distinct`;
173
+ - `sum` and `avg` over reviewed numeric measures;
174
+ - reviewed categorical dimensions;
175
+ - day, week, and month buckets;
176
+ - typed filters and bounded top-N;
177
+ - up to three activated relationship paths, each containing one or two
178
+ catalog-proven many-to-one links with fan-out one.
179
+
180
+ If a question needs an inactive but proven path, Runner refuses it and
181
+ Workbench offers only that exact path for operator review. The model cannot
182
+ activate it. Optional links require an explicit missing-row choice because
183
+ excluding a row versus retaining an empty group can change business totals.
184
+ See [Reviewed Relationship Paths](reviewed-relationships.md).
185
+
186
+ Minimum cohorts, group limits, response limits, query limits, extraction
187
+ budgets, and anti-differencing budgets are fixed by the activated boundary.
188
+ Small groups are suppressed. Results describe changes or contributors; they do
189
+ not prove causation.
190
+
191
+ CLI fallback for the Workbench-suggested aggregate:
192
+
193
+ ```bash
194
+ synapsor-runner try explore --suggested --json
195
+ ```
196
+
197
+ Choose **Protect this analysis** directly on the successful result. Runner
198
+ freezes its reviewed resources, measures, grouping, time bucket, ordering,
199
+ scope, suppression, and limits into:
200
+
201
+ ```text
202
+ synapsor/protected/drafts/<namespace>__<name>/capability.synapsor.sql
203
+ synapsor/protected/drafts/<namespace>__<name>/synapsor.contract.json
204
+ synapsor/protected/drafts/<namespace>__<name>/contract-tests.json
205
+ ```
206
+
207
+ The capability remains disabled until a human activates its exact digest.
208
+ Disabling Scoped Explore does not remove the protected named capability.
209
+
210
+ Workbench renders generated `.synapsor.sql` with local deterministic syntax
211
+ highlighting. Keywords, names chosen by the author, strings, numbers, comments,
212
+ and punctuation are visually distinct. The copy/plain-text value remains
213
+ byte-identical to the generated file; highlighting loads no CDN and escaped
214
+ source text never becomes HTML.
215
+
216
+ CLI fallback, without copying an opaque query handle:
217
+
218
+ ```bash
219
+ synapsor-runner try protect \
220
+ --name analytics.reviewed_weekly_summary \
221
+ --json
222
+ ```
223
+
224
+ ## Fifteen Minutes: First Proposal
225
+
226
+ After the first read, choose **Add a safe action**. Schema metadata supplies
227
+ structure, never business permission. The human specifies:
228
+
229
+ 1. the business action;
230
+ 2. target resource and exact row identity;
231
+ 3. fields that may change;
232
+ 4. allowed values, transitions, and numeric bounds;
233
+ 5. trusted tenant and principal scope;
234
+ 6. conflict/version guard;
235
+ 7. approval role;
236
+ 8. optional small bounded auto-approval;
237
+ 9. per-operation and daily limits;
238
+ 10. optional reviewed compensation.
239
+
240
+ Runner generates public DSL, canonical JSON, tests, an exact-effect preview,
241
+ and a disabled action. Unsupported or unsafe combinations fail closed. In
242
+ particular, DELETE, bounded-set, quorum, auto-approval, and reversibility cannot
243
+ be combined beyond what the canonical DSL supports.
244
+
245
+ After exact-digest human activation, call the named proposal tool in Workbench
246
+ or through the host-neutral Try path. The result must say:
247
+
248
+ ```text
249
+ Proposal created.
250
+ Source database changed: no.
251
+ The model cannot approve or apply this proposal.
252
+ ```
253
+
254
+ Inspect the latest lifecycle without copying a proposal ID:
255
+
256
+ ```bash
257
+ synapsor-runner lifecycle --details
258
+ ```
259
+
260
+ Approval and apply stay outside MCP:
261
+
262
+ ```bash
263
+ synapsor-runner proposals approve latest --yes
264
+ synapsor-runner apply latest
265
+ synapsor-runner lifecycle show latest --details
266
+ ```
267
+
268
+ Production should use a verified signed-key or OIDC operator identity rather
269
+ than unverified development identity. See [Approval Roles And Verified
270
+ Operator Identity](approval-roles-and-operator-identity.md).
271
+
272
+ These commands show the default human-approval/manual-apply path. A production
273
+ operator can separately opt an eligible action into exact-digest supervised
274
+ execution. That does not give the model an apply tool: the model creates a
275
+ bounded proposal, reviewed policy may approve it, and a separately trusted
276
+ worker repeats all guards before any later source mutation. Existing
277
+ `AUTO APPROVE` contracts remain manual-apply unless both opt-ins are present.
278
+ See [Operator-Supervised Automatic
279
+ Apply](supervised-automatic-apply.md).
280
+
281
+ ## Guarded Development Writeback Setup
282
+
283
+ Preview is always the default:
284
+
285
+ ```bash
286
+ synapsor-runner writeback setup \
287
+ --profile staging \
288
+ --json
289
+ ```
290
+
291
+ The response contains one immutable plan digest and exact setup SQL, objects,
292
+ grants, receipt mode, and next action.
293
+
294
+ - `runner_ledger`: no Synapsor receipt table or receipt grant is added to the
295
+ source database.
296
+ - `source_db` + `auto_migrate`: verifies the configured idempotent first-use
297
+ path using the trusted writer.
298
+ - `source_db` + `precreated`: requires a separate setup/admin URL environment
299
+ name and exact steady-state writer role.
300
+ - app-owned handlers receive no unnecessary source receipt setup.
301
+
302
+ DDL apply is refused for missing, unknown, or production profiles. In
303
+ development/staging, it requires the exact displayed confirmation:
304
+
305
+ ```bash
306
+ synapsor-runner writeback setup \
307
+ --profile staging \
308
+ --writer-role '<steady-state-writer-role>' \
309
+ --setup-url-env SYNAPSOR_SETUP_DATABASE_URL \
310
+ --apply \
311
+ --confirm 'APPLY WRITEBACK SETUP sha256:<reviewed-plan-digest>'
312
+ ```
313
+
314
+ Never reuse the model/read credential as the elevated setup connection.
315
+
316
+ ## Connect An MCP Client
317
+
318
+ Workbench generates ready-to-copy Cursor, Claude, Codex, and generic stdio
319
+ snippets for the same reviewed authority. Stdio opens no network listener and
320
+ needs no HTTP bearer credential.
321
+
322
+ Render the generic snippet:
323
+
324
+ ```bash
325
+ synapsor-runner mcp config --absolute-paths
326
+ ```
327
+
328
+ Preview a project-scoped Cursor change:
329
+
330
+ ```bash
331
+ synapsor-runner mcp install cursor --project --dry-run
332
+ ```
333
+
334
+ No client config contains database URLs, trusted scope values, approval,
335
+ activation, apply, or revert authority.
336
+
337
+ ## Machine-Readable Output
338
+
339
+ Commands that support machine output write exactly one JSON value to stdout.
340
+ Operational logs and diagnostics use stderr:
341
+
342
+ ```bash
343
+ synapsor-runner try explore --suggested --json | jq -e .
344
+ ```
345
+
346
+ On a process-level failure, JSON output uses:
347
+
348
+ ```json
349
+ {
350
+ "ok": false,
351
+ "error": {
352
+ "code": "COMMAND_REJECTED",
353
+ "message": "Safe redacted explanation"
354
+ },
355
+ "recovery": {
356
+ "state_preserved": "What remains intact",
357
+ "source_database_changed": null,
358
+ "next_action": "One exact next action"
359
+ }
360
+ }
361
+ ```
362
+
363
+ `null` means Runner cannot honestly infer the source mutation outcome from a
364
+ generic command exception. Operation-specific receipts and reconciliation
365
+ states remain authoritative.
366
+
367
+ ## Before And After
368
+
369
+ The earlier manual path could require roughly thirteen disconnected steps:
370
+ inspect, compile, create config, validate, doctor, initialize a store, start
371
+ Workbench, generate MCP config, create receipt DDL/grants, run a smoke call,
372
+ approve, and apply.
373
+
374
+ The guided path through the first proposal uses:
375
+
376
+ - one public shell command;
377
+ - deliberate Workbench review and activation;
378
+ - no manual file edits;
379
+ - no external documentation search;
380
+ - no Cursor requirement.
381
+
382
+ The packed FitFlow gate records the exact command count, human decisions, and
383
+ timings in `development/runner-1.6.4-fitflow-results.json`.
384
+
385
+ ## Visual Reference
386
+
387
+ Repository screenshots cover desktop, mobile, light, dark, loading, blocked,
388
+ stale, failure, empty Protect, unavailable-action, optional Ask, refusal, and
389
+ proposal-only states:
390
+
391
+ - [Desktop overview](https://github.com/Synapsor/Synapsor-Runner/blob/main/development/runner-1.6.4-visual/workbench-overview-desktop-light.png)
392
+ - [Mobile overview](https://github.com/Synapsor/Synapsor-Runner/blob/main/development/runner-1.6.4-visual/workbench-overview-mobile-light.png)
393
+ - [Blocked identity review](https://github.com/Synapsor/Synapsor-Runner/blob/main/development/runner-1.6.4-visual/workbench-blocked-identity.png)
394
+ - [Stale/failure recovery](https://github.com/Synapsor/Synapsor-Runner/blob/main/development/runner-1.6.4-visual/workbench-keyboard-stale-failure.png)
395
+ - [Ask kept-out-field refusal](https://github.com/Synapsor/Synapsor-Runner/blob/main/development/runner-1.6.4-retail-visual/05c-ask-refusal.png)
396
+ - [Ask proposal-only result](https://github.com/Synapsor/Synapsor-Runner/blob/main/development/runner-1.6.4-community-solar-visual/13b-ask-proposal-only.png)
397
+
398
+ For common blocked states and one-action recovery commands, use
399
+ [Troubleshooting First Run](troubleshooting-first-run.md).