@synapsor/runner 1.6.3 → 1.6.5
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.
- package/AGENTS.md +2 -2
- package/CHANGELOG.md +94 -8
- package/CONTRIBUTING.md +10 -3
- package/README.md +90 -109
- package/SECURITY.md +7 -3
- package/THREAT_MODEL.md +37 -0
- package/dist/authoring.mjs +98 -13
- package/dist/cli.d.ts +12 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/local-ui.d.ts +60 -0
- package/dist/local-ui.d.ts.map +1 -1
- package/dist/runner.mjs +7688 -2227
- package/dist/runtime.mjs +528 -51
- package/docs/README.md +14 -0
- package/docs/agent-guided-setup.md +13 -11
- package/docs/aggregate-reads.md +14 -5
- package/docs/app-owned-executors.md +5 -6
- package/docs/auto-boundary-and-scoped-explore.md +70 -14
- package/docs/capability-authoring.md +2 -2
- package/docs/client-recipes.md +41 -12
- package/docs/cloud-mode.md +7 -7
- package/docs/conformance.md +6 -3
- package/docs/current-scope.md +13 -2
- package/docs/cursor-plugin.md +3 -3
- package/docs/database-enforced-scope.md +6 -0
- package/docs/dsl-reference.md +12 -1
- package/docs/fresh-developer-usability.md +6 -6
- package/docs/getting-started-own-database.md +52 -50
- package/docs/guided-onboarding.md +104 -34
- package/docs/host-compatibility.md +24 -11
- package/docs/limitations.md +34 -14
- package/docs/local-mode.md +20 -20
- package/docs/mcp-audit.md +14 -14
- package/docs/mcp-client-setup.md +26 -14
- package/docs/mcp-clients.md +47 -11
- package/docs/migrating-to-synapsor-spec.md +5 -1
- package/docs/openai-agents-sdk.md +2 -2
- package/docs/proposal-evidence-freshness.md +7 -7
- package/docs/recipes.md +6 -6
- package/docs/release-notes.md +100 -10
- package/docs/release-policy.md +20 -7
- package/docs/reversible-change-sets.md +1 -1
- package/docs/reviewed-database-views.md +132 -0
- package/docs/reviewed-relationships.md +245 -0
- package/docs/rfcs/006-reviewed-reversible-change-sets.md +1 -1
- package/docs/runner-bundles.md +7 -7
- package/docs/schema-api-candidates.md +1 -1
- package/docs/security-boundary.md +30 -0
- package/docs/troubleshooting-first-run.md +63 -19
- package/docs/use-your-own-database.md +6 -4
- package/docs/workbench-ask.md +279 -0
- package/docs/writeback-executors.md +7 -7
- package/examples/auto-boundary-churn/README.md +1 -1
- package/examples/community-solar-clean-room/README.md +7 -0
- package/examples/community-solar-clean-room/docker-compose.yml +16 -0
- package/examples/community-solar-clean-room/package.json +15 -0
- package/examples/community-solar-clean-room/prisma/schema.prisma +171 -0
- package/examples/community-solar-clean-room/seed/postgres.sql +571 -0
- package/examples/fitflow-guided-onboarding/README.md +2 -2
- package/examples/openai-agents-http/Makefile +1 -1
- package/examples/openai-agents-http/README.md +1 -1
- package/examples/openai-agents-stdio/Makefile +1 -1
- package/examples/openai-agents-stdio/README.md +2 -2
- package/examples/openai-agents-stdio/agent.py +1 -4
- package/examples/reference-support-billing-app/README.md +16 -16
- package/examples/retail-clean-room/README.md +7 -0
- package/examples/retail-clean-room/docker-compose.yml +16 -0
- package/examples/retail-clean-room/package.json +9 -0
- package/examples/retail-clean-room/prisma/schema.prisma +239 -0
- package/examples/retail-clean-room/seed/postgres.sql +781 -0
- package/examples/retail-clean-room/view-recipe/average-retained-revenue.synapsor.sql +21 -0
- package/examples/retail-clean-room/view-recipe/synapsor.runner.json +25 -0
- package/examples/support-plan-credit/mcp-client-examples/claude-code.sh +1 -4
- package/examples/support-plan-credit/mcp-client-examples/claude-desktop.json +1 -4
- package/examples/support-plan-credit/mcp-client-examples/codex.config.toml +1 -4
- package/examples/support-plan-credit/mcp-client-examples/cursor-global.mcp.json +1 -4
- package/examples/support-plan-credit/mcp-client-examples/cursor-project.mcp.json +1 -4
- package/examples/support-plan-credit/mcp-client-examples/generic-stdio.json +1 -4
- package/examples/support-plan-credit/mcp-client-examples/generic-stdio.mjs +1 -1
- package/examples/support-plan-credit/mcp-client-examples/google-adk.py +1 -1
- package/examples/support-plan-credit/mcp-client-examples/langchain.mjs +1 -1
- package/examples/support-plan-credit/mcp-client-examples/llamaindex.py +1 -1
- package/examples/support-plan-credit/mcp-client-examples/openai-agents-stdio.ts +1 -1
- package/examples/support-plan-credit/mcp-client-examples/vscode.mcp.json +1 -4
- package/fixtures/compatibility/published-1.6.3/manifest.json +76 -0
- package/fixtures/compatibility/published-1.6.3/sources/packages/dsl/examples/aggregate-read.synapsor.sql +21 -0
- package/fixtures/compatibility/published-1.6.3/sources/packages/dsl/examples/billing-late-fee.synapsor.sql +56 -0
- package/fixtures/compatibility/published-1.6.3/sources/packages/dsl/examples/bounded-set-multi-term.synapsor.sql +30 -0
- package/fixtures/compatibility/published-1.6.3/sources/packages/dsl/examples/principal-row-scope.synapsor.sql +23 -0
- package/fixtures/compatibility/published-1.6.3/sources/packages/spec/fixtures/conformance/aggregate-read/contract.json +119 -0
- package/fixtures/compatibility/published-1.6.3/sources/packages/spec/fixtures/conformance/approval-quorum/contract.json +44 -0
- package/fixtures/compatibility/published-1.6.3/sources/packages/spec/fixtures/conformance/bounded-set-threats/contract.json +115 -0
- package/fixtures/compatibility/published-1.6.3/sources/packages/spec/fixtures/conformance/principal-row-scope/contract.json +78 -0
- package/fixtures/compatibility/published-1.6.3/sources/packages/spec/fixtures/conformance/proposal-capability/contract.json +101 -0
- package/fixtures/compatibility/published-1.6.3/sources/packages/spec/fixtures/conformance/reversible-change-sets/contract.json +98 -0
- package/fixtures/compatibility/published-1.6.3/sources/packages/spec/fixtures/valid/basic-read.contract.json +60 -0
- package/llms.txt +10 -5
- package/package.json +9 -2
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
CREATE AGENT CONTEXT retail_analytics_context
|
|
2
|
+
BIND tenant_id FROM ENVIRONMENT SYNAPSOR_TENANT_ID REQUIRED
|
|
3
|
+
BIND principal FROM ENVIRONMENT SYNAPSOR_PRINCIPAL REQUIRED
|
|
4
|
+
TENANT BINDING tenant_id
|
|
5
|
+
PRINCIPAL BINDING principal
|
|
6
|
+
END
|
|
7
|
+
|
|
8
|
+
CREATE CAPABILITY retail.average_net_revenue_retention_pacific
|
|
9
|
+
DESCRIPTION 'Return the privacy-suppressed average net-to-gross revenue retention rate for Pacific orders assigned to the trusted manager.'
|
|
10
|
+
RETURNS HINT 'Returns one scalar average in basis points or a suppression result; never order rows.'
|
|
11
|
+
USING CONTEXT retail_analytics_context
|
|
12
|
+
SOURCE retail_postgres
|
|
13
|
+
ON public.reviewed_order_performance
|
|
14
|
+
PRIMARY KEY order_id
|
|
15
|
+
TENANT KEY merchant_id
|
|
16
|
+
PRINCIPAL SCOPE KEY assigned_manager_id
|
|
17
|
+
AGGREGATE READ AVG net_revenue_retention_basis_points
|
|
18
|
+
SELECT WHERE region_id = 'region-pacific'
|
|
19
|
+
MIN GROUP SIZE 5
|
|
20
|
+
REQUIRE EVIDENCE
|
|
21
|
+
END
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 1,
|
|
3
|
+
"mode": "review",
|
|
4
|
+
"storage": {
|
|
5
|
+
"sqlite_path": "./.synapsor/view-recipe.db"
|
|
6
|
+
},
|
|
7
|
+
"contracts": [
|
|
8
|
+
"./average-retained-revenue.contract.json"
|
|
9
|
+
],
|
|
10
|
+
"sources": {
|
|
11
|
+
"retail_postgres": {
|
|
12
|
+
"engine": "postgres",
|
|
13
|
+
"read_url_env": "DATABASE_URL",
|
|
14
|
+
"statement_timeout_ms": 3000,
|
|
15
|
+
"database_scope": {
|
|
16
|
+
"mode": "postgres_rls",
|
|
17
|
+
"tenant_setting": "app.tenant_id",
|
|
18
|
+
"principal_setting": "app.principal"
|
|
19
|
+
},
|
|
20
|
+
"credential_scope": {
|
|
21
|
+
"mode": "shared"
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -4,7 +4,7 @@ import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js"
|
|
|
4
4
|
const transport = new StdioClientTransport({
|
|
5
5
|
command: "npx",
|
|
6
6
|
args: [
|
|
7
|
-
"-y", "
|
|
7
|
+
"-y", "@synapsor/runner", "mcp", "serve",
|
|
8
8
|
"--config", "./examples/support-plan-credit/synapsor.runner.json",
|
|
9
9
|
"--store", "./tmp/support-plan-credit/local.db",
|
|
10
10
|
],
|
|
@@ -21,7 +21,7 @@ root_agent = LlmAgent(
|
|
|
21
21
|
server_params=StdioServerParameters(
|
|
22
22
|
command="npx",
|
|
23
23
|
args=[
|
|
24
|
-
"-y", "
|
|
24
|
+
"-y", "@synapsor/runner",
|
|
25
25
|
"mcp", "serve", "--config",
|
|
26
26
|
"./examples/support-plan-credit/synapsor.runner.json",
|
|
27
27
|
"--store", "./tmp/support-plan-credit/local.db",
|
|
@@ -5,7 +5,7 @@ const client = new MultiServerMCPClient({
|
|
|
5
5
|
transport: "stdio",
|
|
6
6
|
command: "npx",
|
|
7
7
|
args: [
|
|
8
|
-
"-y", "
|
|
8
|
+
"-y", "@synapsor/runner", "mcp", "serve",
|
|
9
9
|
"--config", "./examples/support-plan-credit/synapsor.runner.json",
|
|
10
10
|
"--store", "./tmp/support-plan-credit/local.db",
|
|
11
11
|
],
|
|
@@ -7,7 +7,7 @@ async def main() -> None:
|
|
|
7
7
|
client = BasicMCPClient(
|
|
8
8
|
"npx",
|
|
9
9
|
args=[
|
|
10
|
-
"-y", "
|
|
10
|
+
"-y", "@synapsor/runner", "mcp", "serve",
|
|
11
11
|
"--config", "./examples/support-plan-credit/synapsor.runner.json",
|
|
12
12
|
"--store", "./tmp/support-plan-credit/local.db",
|
|
13
13
|
],
|
|
@@ -2,7 +2,7 @@ import { Agent, MCPServerStdio, run } from "@openai/agents";
|
|
|
2
2
|
|
|
3
3
|
const synapsor = new MCPServerStdio({
|
|
4
4
|
name: "Synapsor Runner",
|
|
5
|
-
fullCommand: "npx -y
|
|
5
|
+
fullCommand: "npx -y @synapsor/runner mcp serve --config examples/support-plan-credit/synapsor.runner.json --store ./tmp/support-plan-credit/local.db --alias-mode openai",
|
|
6
6
|
});
|
|
7
7
|
|
|
8
8
|
await synapsor.connect();
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schema_version": "synapsor.published-compatibility.v1",
|
|
3
|
+
"published_packages": {
|
|
4
|
+
"@synapsor/runner": {
|
|
5
|
+
"version": "1.6.3",
|
|
6
|
+
"npm_shasum": "bc0131f3452a9ad1ef53b5ba3c60b2ff4f776f84"
|
|
7
|
+
},
|
|
8
|
+
"@synapsor/dsl": {
|
|
9
|
+
"version": "1.6.0",
|
|
10
|
+
"npm_shasum": "b2010be0b7bcd45ee70a7539e4150c3a680ee37f"
|
|
11
|
+
},
|
|
12
|
+
"@synapsor/spec": {
|
|
13
|
+
"version": "1.6.0",
|
|
14
|
+
"npm_shasum": "cc162e525dc36e2aaa9dd7953465f2ba7bdbf042"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"contracts": [
|
|
18
|
+
{
|
|
19
|
+
"path": "packages/spec/fixtures/valid/basic-read.contract.json",
|
|
20
|
+
"source_sha256": "5ec499965f639d784603b7942390d18a3e742d79e4d510dbea470e166a743972",
|
|
21
|
+
"canonical_sha256": "9d3addfde77eb6528aae7b9e81ae0f582b5c002aa77ebb2d7381fe663f5f5b1e"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"path": "packages/spec/fixtures/conformance/aggregate-read/contract.json",
|
|
25
|
+
"source_sha256": "830bc208b749bb9ed6a4b4468571d58d68bc8a2b6e1072fc45fb87d1c68697e7",
|
|
26
|
+
"canonical_sha256": "ccc6ea17f449bfc207d1cea70ef3320d575c450a3904c850dcb631132c6e5602"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"path": "packages/spec/fixtures/conformance/proposal-capability/contract.json",
|
|
30
|
+
"source_sha256": "d4c25fb8f79f04c13bdb3daf8c18a44d4f1c61596660a67bf35d46d0f94f4100",
|
|
31
|
+
"canonical_sha256": "d895081246d41a072892b5dde6929099302492a77a229033fbfa5052cce34b18"
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"path": "packages/spec/fixtures/conformance/bounded-set-threats/contract.json",
|
|
35
|
+
"source_sha256": "c902d45457789a6d87504ca434c8b299f3e09be779f3bfdf7bbd8684d575a10e",
|
|
36
|
+
"canonical_sha256": "64c7078ff1687762d95c17873238759b3572dce499f903a8d6f1aaa8faae5f24"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"path": "packages/spec/fixtures/conformance/reversible-change-sets/contract.json",
|
|
40
|
+
"source_sha256": "7e4f8da90a4b235097f76e70a7f550153bbf62d219e7ef6f4f2194f6c36fa205",
|
|
41
|
+
"canonical_sha256": "181f2e93ad3c53b9a1345a4ed6c8b5e24ab0201c00159f38659f0c2a00c037de"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"path": "packages/spec/fixtures/conformance/principal-row-scope/contract.json",
|
|
45
|
+
"source_sha256": "00a05c1f4e82cc9c4e5d2d68c9c9201cd9512ac42d63292314bb7b4845026996",
|
|
46
|
+
"canonical_sha256": "fc96a5327ab0f4b311c90da9b5585348e81349ed66bd3a22e41e5f29804c32a8"
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"path": "packages/spec/fixtures/conformance/approval-quorum/contract.json",
|
|
50
|
+
"source_sha256": "dde6b328f648ba60d837fa363494d764d7eb0d2d9a8a81ff70a9c077edde410c",
|
|
51
|
+
"canonical_sha256": "9407a7d0cc4439c773c3caf721aaed6c6e163c403fa67518632829d8c5de33e7"
|
|
52
|
+
}
|
|
53
|
+
],
|
|
54
|
+
"dsl_sources": [
|
|
55
|
+
{
|
|
56
|
+
"path": "packages/dsl/examples/aggregate-read.synapsor.sql",
|
|
57
|
+
"source_sha256": "bccac4c2eb0ab7b2fc099c7fb3f6fdc25ee2e6e534282aa19b46f0aec8191b8d",
|
|
58
|
+
"canonical_sha256": "0cc2d892f00a31a3582d773812a26c6c45c0ce343e1d8d09da226a5bbb7c93eb"
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
"path": "packages/dsl/examples/billing-late-fee.synapsor.sql",
|
|
62
|
+
"source_sha256": "f5c462cff7aa0cd01a08543c6096ee1d225ebba449d65b7470815b1aa7ec42cd",
|
|
63
|
+
"canonical_sha256": "d495df575d64e798a730dad385e097dfc2c2f371a1505865bc45179ad3c479f2"
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"path": "packages/dsl/examples/bounded-set-multi-term.synapsor.sql",
|
|
67
|
+
"source_sha256": "0ae199034ebba8b25146435c911576118f948b55b54636a5e68f46002cd1c6dd",
|
|
68
|
+
"canonical_sha256": "5b3e84cf8f5062a8afcd50763bde907e6a141977456e74a81d01f8b3a484e422"
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
"path": "packages/dsl/examples/principal-row-scope.synapsor.sql",
|
|
72
|
+
"source_sha256": "08ccd769d633417ea45d478383d9628991f43262223f12c78bbd776202b10253",
|
|
73
|
+
"canonical_sha256": "e29f2819c267210e54f783c40d0f550d11d0d1de844dbe1590ed8c3405af3cf7"
|
|
74
|
+
}
|
|
75
|
+
]
|
|
76
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
CREATE AGENT CONTEXT finance_operator
|
|
2
|
+
BIND tenant_id FROM ENVIRONMENT SYNAPSOR_TENANT_ID REQUIRED
|
|
3
|
+
BIND principal FROM ENVIRONMENT SYNAPSOR_PRINCIPAL REQUIRED
|
|
4
|
+
TENANT BINDING tenant_id
|
|
5
|
+
PRINCIPAL BINDING principal
|
|
6
|
+
END
|
|
7
|
+
|
|
8
|
+
CREATE CAPABILITY billing.overdue_balance_total
|
|
9
|
+
DESCRIPTION 'Return one suppressed overdue-balance aggregate for the trusted tenant.'
|
|
10
|
+
RETURNS HINT 'Returns one scalar or a suppression result; never member rows.'
|
|
11
|
+
USING CONTEXT finance_operator
|
|
12
|
+
SOURCE local_postgres
|
|
13
|
+
ON public.invoices
|
|
14
|
+
PRIMARY KEY id
|
|
15
|
+
TENANT KEY tenant_id
|
|
16
|
+
AGGREGATE READ SUM balance_cents
|
|
17
|
+
SELECT WHERE status = 'overdue'
|
|
18
|
+
MIN GROUP SIZE 5
|
|
19
|
+
KEEP OUT customer_email, private_notes
|
|
20
|
+
REQUIRE EVIDENCE
|
|
21
|
+
END
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
CREATE AGENT CONTEXT local_operator
|
|
2
|
+
BIND tenant_id FROM ENVIRONMENT SYNAPSOR_TENANT_ID REQUIRED
|
|
3
|
+
BIND principal FROM ENVIRONMENT SYNAPSOR_PRINCIPAL REQUIRED
|
|
4
|
+
TENANT BINDING tenant_id
|
|
5
|
+
PRINCIPAL BINDING principal
|
|
6
|
+
END
|
|
7
|
+
|
|
8
|
+
CREATE CAPABILITY billing.inspect_invoice
|
|
9
|
+
DESCRIPTION 'Inspect one invoice in the trusted tenant before proposing a waiver.'
|
|
10
|
+
RETURNS HINT 'Returns reviewed invoice fields plus evidence/query-audit handles.'
|
|
11
|
+
USING CONTEXT local_operator
|
|
12
|
+
SOURCE local_postgres
|
|
13
|
+
ON public.invoices
|
|
14
|
+
PRIMARY KEY id
|
|
15
|
+
TENANT KEY tenant_id
|
|
16
|
+
CONFLICT GUARD updated_at
|
|
17
|
+
LOOKUP invoice_id BY id
|
|
18
|
+
ARG invoice_id STRING REQUIRED MAX LENGTH 128 DESCRIPTION 'Invoice id such as INV-3001.'
|
|
19
|
+
ALLOW READ id, tenant_id, customer_id, status, late_fee_cents, waiver_reason, updated_at
|
|
20
|
+
KEEP OUT card_token, internal_risk_score
|
|
21
|
+
REQUIRE EVIDENCE
|
|
22
|
+
MAX ROWS 1
|
|
23
|
+
END
|
|
24
|
+
|
|
25
|
+
CREATE CAPABILITY billing.propose_late_fee_waiver
|
|
26
|
+
DESCRIPTION 'Propose waiving one invoice late fee after inspecting invoice and policy evidence.'
|
|
27
|
+
RETURNS HINT 'Returns a review-required proposal id, exact diff, evidence handle, and source_database_changed:false.'
|
|
28
|
+
USING CONTEXT local_operator
|
|
29
|
+
SOURCE local_postgres
|
|
30
|
+
ON public.invoices
|
|
31
|
+
PRIMARY KEY id
|
|
32
|
+
TENANT KEY tenant_id
|
|
33
|
+
CONFLICT GUARD updated_at
|
|
34
|
+
LOOKUP invoice_id BY id
|
|
35
|
+
ARG invoice_id STRING REQUIRED MAX LENGTH 128 DESCRIPTION 'Invoice id such as INV-3001.'
|
|
36
|
+
ARG waiver_reason TEXT REQUIRED MAX LENGTH 500 DESCRIPTION 'Business reason for the proposed waiver.'
|
|
37
|
+
ALLOW READ id, tenant_id, customer_id, status, late_fee_cents, waiver_reason, updated_at
|
|
38
|
+
KEEP OUT card_token, internal_risk_score
|
|
39
|
+
REQUIRE EVIDENCE
|
|
40
|
+
MAX ROWS 1
|
|
41
|
+
PROPOSE ACTION billing.waive_late_fee
|
|
42
|
+
ALLOW WRITE late_fee_cents, waiver_reason
|
|
43
|
+
PATCH late_fee_cents = 0
|
|
44
|
+
PATCH waiver_reason = ARG waiver_reason
|
|
45
|
+
APPROVAL ROLE billing_lead
|
|
46
|
+
WRITEBACK DIRECT SQL
|
|
47
|
+
END
|
|
48
|
+
|
|
49
|
+
CREATE AGENT WORKFLOW billing.late_fee_review
|
|
50
|
+
USING CONTEXT local_operator
|
|
51
|
+
ALLOW CAPABILITY billing.inspect_invoice
|
|
52
|
+
ALLOW CAPABILITY billing.propose_late_fee_waiver
|
|
53
|
+
REQUIRE EVIDENCE
|
|
54
|
+
APPROVAL REQUIRED ROLE billing_lead
|
|
55
|
+
CHECKPOINT PROPOSAL ONLY
|
|
56
|
+
END
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
CREATE AGENT CONTEXT local_operator
|
|
2
|
+
BIND tenant_id FROM ENVIRONMENT SYNAPSOR_TENANT_ID REQUIRED
|
|
3
|
+
BIND principal FROM ENVIRONMENT SYNAPSOR_PRINCIPAL REQUIRED
|
|
4
|
+
TENANT BINDING tenant_id
|
|
5
|
+
PRINCIPAL BINDING principal
|
|
6
|
+
END
|
|
7
|
+
|
|
8
|
+
CREATE CAPABILITY cases.close_high_risk
|
|
9
|
+
DESCRIPTION 'Close active high-risk support cases within reviewed row and value caps.'
|
|
10
|
+
RETURNS HINT 'Returns a proposal for the exact reviewed set; source rows remain unchanged.'
|
|
11
|
+
USING CONTEXT local_operator
|
|
12
|
+
SOURCE support_db
|
|
13
|
+
ON public.support_cases
|
|
14
|
+
PRIMARY KEY id
|
|
15
|
+
TENANT KEY tenant_id
|
|
16
|
+
CONFLICT GUARD version
|
|
17
|
+
LOOKUP reason BY id
|
|
18
|
+
ARG reason STRING REQUIRED MAX LENGTH 100
|
|
19
|
+
ALLOW READ id, tenant_id, risk_level, case_status, exposure_cents, version
|
|
20
|
+
REQUIRE EVIDENCE
|
|
21
|
+
PROPOSE ACTION close_high_risk UPDATE SET
|
|
22
|
+
SELECT WHERE risk_level = 'high' AND case_status = 'active'
|
|
23
|
+
MAX ROWS 10
|
|
24
|
+
MAX TOTAL exposure_cents BEFORE 50000
|
|
25
|
+
ALLOW WRITE case_status
|
|
26
|
+
PATCH case_status = 'closed'
|
|
27
|
+
ADVANCE VERSION version USING INTEGER INCREMENT
|
|
28
|
+
APPROVAL ROLE support_manager
|
|
29
|
+
WRITEBACK DIRECT SQL
|
|
30
|
+
END
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
CREATE AGENT CONTEXT care_session
|
|
2
|
+
BIND hospital_id FROM HTTP_CLAIM hospital_id REQUIRED
|
|
3
|
+
BIND principal FROM HTTP_CLAIM sub REQUIRED
|
|
4
|
+
TENANT BINDING hospital_id
|
|
5
|
+
PRINCIPAL BINDING principal
|
|
6
|
+
END
|
|
7
|
+
|
|
8
|
+
CREATE CAPABILITY care.inspect_assigned_patient
|
|
9
|
+
DESCRIPTION 'Inspect one patient assigned to the authenticated case manager within the trusted hospital.'
|
|
10
|
+
RETURNS HINT 'Returns reviewed patient fields and evidence only when both tenant and assignee locks match.'
|
|
11
|
+
USING CONTEXT care_session
|
|
12
|
+
SOURCE local_postgres
|
|
13
|
+
ON public.patients
|
|
14
|
+
PRIMARY KEY id
|
|
15
|
+
TENANT KEY hospital_id
|
|
16
|
+
PRINCIPAL SCOPE KEY assigned_to
|
|
17
|
+
LOOKUP patient_id BY id
|
|
18
|
+
ARG patient_id STRING REQUIRED MAX LENGTH 128 DESCRIPTION 'Reviewed patient identifier.'
|
|
19
|
+
ALLOW READ id, hospital_id, display_name, care_status, updated_at
|
|
20
|
+
KEEP OUT assigned_to, diagnosis_notes, insurance_member_id
|
|
21
|
+
REQUIRE EVIDENCE
|
|
22
|
+
MAX ROWS 1
|
|
23
|
+
END
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
{
|
|
2
|
+
"spec_version": "0.1",
|
|
3
|
+
"kind": "SynapsorContract",
|
|
4
|
+
"metadata": {
|
|
5
|
+
"name": "aggregate read and enum conformance",
|
|
6
|
+
"version": "1.0.0"
|
|
7
|
+
},
|
|
8
|
+
"resources": [
|
|
9
|
+
{
|
|
10
|
+
"name": "billing_invoices",
|
|
11
|
+
"engine": "postgres",
|
|
12
|
+
"schema": "public",
|
|
13
|
+
"table": "invoices",
|
|
14
|
+
"primary_key": "id",
|
|
15
|
+
"tenant_key": "tenant_id"
|
|
16
|
+
}
|
|
17
|
+
],
|
|
18
|
+
"contexts": [
|
|
19
|
+
{
|
|
20
|
+
"name": "billing_context",
|
|
21
|
+
"bindings": [
|
|
22
|
+
{
|
|
23
|
+
"name": "tenant_id",
|
|
24
|
+
"source": "environment",
|
|
25
|
+
"key": "SYNAPSOR_TENANT_ID"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"name": "principal",
|
|
29
|
+
"source": "environment",
|
|
30
|
+
"key": "SYNAPSOR_PRINCIPAL"
|
|
31
|
+
}
|
|
32
|
+
],
|
|
33
|
+
"tenant_binding": "tenant_id",
|
|
34
|
+
"principal_binding": "principal"
|
|
35
|
+
}
|
|
36
|
+
],
|
|
37
|
+
"capabilities": [
|
|
38
|
+
{
|
|
39
|
+
"name": "billing.sum_overdue_balance",
|
|
40
|
+
"description": "Return one privacy-suppressed aggregate for the trusted tenant.",
|
|
41
|
+
"returns_hint": "Returns one scalar or a suppression result; never member rows.",
|
|
42
|
+
"kind": "aggregate_read",
|
|
43
|
+
"context": "billing_context",
|
|
44
|
+
"source": "local_postgres",
|
|
45
|
+
"subject": {
|
|
46
|
+
"resource": "billing_invoices"
|
|
47
|
+
},
|
|
48
|
+
"args": {},
|
|
49
|
+
"visible_fields": [],
|
|
50
|
+
"kept_out_fields": [
|
|
51
|
+
"customer_email",
|
|
52
|
+
"private_notes"
|
|
53
|
+
],
|
|
54
|
+
"evidence": {
|
|
55
|
+
"required": true,
|
|
56
|
+
"query_audit": true
|
|
57
|
+
},
|
|
58
|
+
"aggregate": {
|
|
59
|
+
"function": "sum",
|
|
60
|
+
"column": "balance_cents",
|
|
61
|
+
"selection": {
|
|
62
|
+
"all": [
|
|
63
|
+
{
|
|
64
|
+
"column": "status",
|
|
65
|
+
"operator": "eq",
|
|
66
|
+
"value": "overdue"
|
|
67
|
+
}
|
|
68
|
+
]
|
|
69
|
+
},
|
|
70
|
+
"minimum_group_size": 5
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
"name": "billing.inspect_invoice",
|
|
75
|
+
"description": "Inspect one tenant-scoped invoice using a reviewed risk enum.",
|
|
76
|
+
"kind": "read",
|
|
77
|
+
"context": "billing_context",
|
|
78
|
+
"source": "local_postgres",
|
|
79
|
+
"subject": {
|
|
80
|
+
"resource": "billing_invoices"
|
|
81
|
+
},
|
|
82
|
+
"args": {
|
|
83
|
+
"invoice_id": {
|
|
84
|
+
"type": "string",
|
|
85
|
+
"required": true,
|
|
86
|
+
"max_length": 128
|
|
87
|
+
},
|
|
88
|
+
"risk_level": {
|
|
89
|
+
"type": "string",
|
|
90
|
+
"required": true,
|
|
91
|
+
"enum": [
|
|
92
|
+
"low",
|
|
93
|
+
"medium",
|
|
94
|
+
"high"
|
|
95
|
+
]
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
"lookup": {
|
|
99
|
+
"id_from_arg": "invoice_id"
|
|
100
|
+
},
|
|
101
|
+
"visible_fields": [
|
|
102
|
+
"id",
|
|
103
|
+
"tenant_id",
|
|
104
|
+
"status",
|
|
105
|
+
"balance_cents"
|
|
106
|
+
],
|
|
107
|
+
"kept_out_fields": [
|
|
108
|
+
"customer_email",
|
|
109
|
+
"private_notes"
|
|
110
|
+
],
|
|
111
|
+
"evidence": {
|
|
112
|
+
"required": true,
|
|
113
|
+
"query_audit": true
|
|
114
|
+
},
|
|
115
|
+
"max_rows": 1
|
|
116
|
+
}
|
|
117
|
+
]
|
|
118
|
+
}
|
|
119
|
+
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"spec_version": "0.1",
|
|
3
|
+
"kind": "SynapsorContract",
|
|
4
|
+
"contexts": [
|
|
5
|
+
{
|
|
6
|
+
"name": "local_operator",
|
|
7
|
+
"bindings": [
|
|
8
|
+
{ "name": "tenant_id", "source": "environment", "key": "SYNAPSOR_TENANT_ID" },
|
|
9
|
+
{ "name": "principal", "source": "environment", "key": "SYNAPSOR_PRINCIPAL" }
|
|
10
|
+
],
|
|
11
|
+
"tenant_binding": "tenant_id",
|
|
12
|
+
"principal_binding": "principal"
|
|
13
|
+
}
|
|
14
|
+
],
|
|
15
|
+
"capabilities": [
|
|
16
|
+
{
|
|
17
|
+
"name": "billing.propose_late_fee_waiver",
|
|
18
|
+
"kind": "proposal",
|
|
19
|
+
"context": "local_operator",
|
|
20
|
+
"subject": {
|
|
21
|
+
"schema": "public",
|
|
22
|
+
"table": "invoices",
|
|
23
|
+
"primary_key": "id",
|
|
24
|
+
"tenant_key": "tenant_id",
|
|
25
|
+
"conflict_key": "updated_at"
|
|
26
|
+
},
|
|
27
|
+
"args": { "invoice_id": { "type": "string" } },
|
|
28
|
+
"lookup": { "id_from_arg": "invoice_id" },
|
|
29
|
+
"visible_fields": ["id", "tenant_id", "late_fee_cents", "updated_at"],
|
|
30
|
+
"proposal": {
|
|
31
|
+
"action": "billing.waive_late_fee",
|
|
32
|
+
"allowed_fields": ["late_fee_cents"],
|
|
33
|
+
"patch": { "late_fee_cents": { "fixed": 0 } },
|
|
34
|
+
"conflict_guard": { "column": "updated_at" },
|
|
35
|
+
"approval": {
|
|
36
|
+
"mode": "human",
|
|
37
|
+
"required_role": "billing_lead",
|
|
38
|
+
"required_approvals": 2
|
|
39
|
+
},
|
|
40
|
+
"writeback": { "mode": "direct_sql" }
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
]
|
|
44
|
+
}
|