@conarium-ai/core 0.2.10 → 0.2.12

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 (111) hide show
  1. package/CHANGELOG.md +43 -2
  2. package/LIMITATIONS.md +39 -5
  3. package/LIMITATIONS.tr.md +38 -5
  4. package/README.md +11 -8
  5. package/SECURITY.md +1 -0
  6. package/bin/conarium-doctor.mjs +226 -7
  7. package/bin/doctor-sql.mjs +47 -0
  8. package/dist/audit.d.ts.map +1 -1
  9. package/dist/audit.js +12 -3
  10. package/dist/audit.js.map +1 -1
  11. package/dist/config.d.ts +22 -8
  12. package/dist/config.d.ts.map +1 -1
  13. package/dist/config.js +22 -1
  14. package/dist/config.js.map +1 -1
  15. package/dist/connectors/custom-sql.d.ts +22 -0
  16. package/dist/connectors/custom-sql.d.ts.map +1 -0
  17. package/dist/connectors/custom-sql.js +67 -0
  18. package/dist/connectors/custom-sql.js.map +1 -0
  19. package/dist/connectors/index.d.ts +1 -0
  20. package/dist/connectors/index.d.ts.map +1 -1
  21. package/dist/connectors/index.js +5 -1
  22. package/dist/connectors/index.js.map +1 -1
  23. package/dist/connectors/openapi.d.ts.map +1 -1
  24. package/dist/connectors/openapi.js +0 -1
  25. package/dist/connectors/openapi.js.map +1 -1
  26. package/dist/connectors/supabase_rest.d.ts.map +1 -1
  27. package/dist/connectors/supabase_rest.js +0 -1
  28. package/dist/connectors/supabase_rest.js.map +1 -1
  29. package/dist/console.d.ts.map +1 -1
  30. package/dist/console.js +14 -3
  31. package/dist/console.js.map +1 -1
  32. package/dist/executor.d.ts.map +1 -1
  33. package/dist/executor.js +0 -1
  34. package/dist/executor.js.map +1 -1
  35. package/dist/governance.d.ts +8 -0
  36. package/dist/governance.d.ts.map +1 -1
  37. package/dist/governance.js +29 -78
  38. package/dist/governance.js.map +1 -1
  39. package/dist/masking-cost.d.ts +16 -0
  40. package/dist/masking-cost.d.ts.map +1 -0
  41. package/dist/masking-cost.js +31 -0
  42. package/dist/masking-cost.js.map +1 -0
  43. package/dist/search_policy.d.ts.map +1 -1
  44. package/dist/search_policy.js +8 -4
  45. package/dist/search_policy.js.map +1 -1
  46. package/dist/server.d.ts.map +1 -1
  47. package/dist/server.js +90 -13
  48. package/dist/server.js.map +1 -1
  49. package/dist/sql-executor.d.ts +14 -0
  50. package/dist/sql-executor.d.ts.map +1 -0
  51. package/dist/sql-executor.js +75 -0
  52. package/dist/sql-executor.js.map +1 -0
  53. package/dist/sql-gate/dispatch.d.ts +17 -0
  54. package/dist/sql-gate/dispatch.d.ts.map +1 -0
  55. package/dist/sql-gate/dispatch.js +30 -0
  56. package/dist/sql-gate/dispatch.js.map +1 -0
  57. package/dist/sql-gate/mssql.d.ts +11 -0
  58. package/dist/sql-gate/mssql.d.ts.map +1 -0
  59. package/dist/sql-gate/mssql.js +287 -0
  60. package/dist/sql-gate/mssql.js.map +1 -0
  61. package/dist/sql-gate/oracle.d.ts +11 -0
  62. package/dist/sql-gate/oracle.d.ts.map +1 -0
  63. package/dist/sql-gate/oracle.js +227 -0
  64. package/dist/sql-gate/oracle.js.map +1 -0
  65. package/dist/sql-gate/postgres.d.ts +12 -0
  66. package/dist/sql-gate/postgres.d.ts.map +1 -0
  67. package/dist/sql-gate/postgres.js +64 -0
  68. package/dist/sql-gate/postgres.js.map +1 -0
  69. package/dist/sql-gate/rules.d.ts +14 -0
  70. package/dist/sql-gate/rules.d.ts.map +1 -0
  71. package/dist/sql-gate/rules.js +73 -0
  72. package/dist/sql-gate/rules.js.map +1 -0
  73. package/dist/sql-gate/types.d.ts +31 -0
  74. package/dist/sql-gate/types.d.ts.map +1 -0
  75. package/dist/sql-gate/types.js +9 -0
  76. package/dist/sql-gate/types.js.map +1 -0
  77. package/dist/table-unavailable.d.ts +12 -0
  78. package/dist/table-unavailable.d.ts.map +1 -0
  79. package/dist/table-unavailable.js +32 -0
  80. package/dist/table-unavailable.js.map +1 -0
  81. package/dist/types.d.ts +8 -1
  82. package/dist/types.d.ts.map +1 -1
  83. package/docs/API-STABILITY.md +174 -0
  84. package/docs/BENCHMARK.md +144 -0
  85. package/docs/audit/2026-08-14-e2e-health.md +69 -0
  86. package/docs/audit/2026-08-14-security-scan.md +48 -0
  87. package/docs/audit/2026-08-14-surface-sync.md +34 -0
  88. package/docs/benchmarks/concurrency-20260814.json +38 -0
  89. package/docs/benchmarks/latest.json +2310 -0
  90. package/docs/benchmarks/masking-cost-threshold.json +6 -0
  91. package/docs/benchmarks/overhead-20260814T1238Z-win32.json +402 -0
  92. package/docs/benchmarks/overhead-20260814T1346Z-linux.json +2310 -0
  93. package/docs/benchmarks/overhead-20260814T1644Z-win32.json +2310 -0
  94. package/docs/releases/v0.2.10.md +24 -0
  95. package/docs/releases/v0.2.8.md +23 -0
  96. package/docs/releases/v0.2.9.md +26 -0
  97. package/docs/security/NPM-PROVENANCE.md +64 -0
  98. package/docs/security/PENTEST-SCOPE.md +1 -1
  99. package/docs/security/THREAT-MODEL.md +25 -5
  100. package/docs/specs/2026-08-14-mssql-bypass-inventory.md +37 -0
  101. package/docs/specs/2026-08-14-oracle-bypass-inventory.md +28 -0
  102. package/examples/custom-sql/README.md +50 -0
  103. package/examples/custom-sql/conarium.config.json +22 -0
  104. package/examples/custom-sql/memory-executor.mjs +16 -0
  105. package/package.json +5 -5
  106. package/scripts/benchmark-concurrency.mjs +133 -0
  107. package/scripts/benchmark-overhead.mjs +492 -0
  108. package/test-vectors/README.md +3 -0
  109. package/test-vectors/sql-gate/LAST-RUN.json +11 -0
  110. package/test-vectors/sql-gate/README.md +19 -0
  111. package/test-vectors/sql-gate/vectors.json +331 -0
@@ -0,0 +1,24 @@
1
+ # Draft — Conarium 0.2.10
2
+
3
+ **Taslak.** GitHub Release yayımlanmadı. Tag `v0.2.10` = `a21fdca`.
4
+ This is the npm / Hetzner / tag line as of 2026-08-14.
5
+
6
+ ## Added
7
+
8
+ - `LIMITATIONS.md` and `LIMITATIONS.tr.md`. What this repository has not done.
9
+ - Built-in OpenTimestamps client. `javascript-opentimestamps` is not a
10
+ dependency. The `web3` / `request` / `bitcore` tree is not installed.
11
+
12
+ ## Changed
13
+
14
+ - `COMPARISON.md` removed from this repository. The dated comparison lives
15
+ only at `conarium.dev/compare.html`.
16
+ - `test:checks` runs every check even if one fails.
17
+
18
+ ## Docs
19
+
20
+ - Threat model and pentest scope under `docs/security/`.
21
+
22
+ Commits after this tag (benchmark, maxRows note) are not part of 0.2.10.
23
+
24
+ Not a dialect release. SQL remains Postgres only.
@@ -0,0 +1,23 @@
1
+ # Draft — Conarium 0.2.8
2
+
3
+ **Taslak.** GitHub Release yayımlanmadı. Tag `v0.2.8` = `ea563b9`.
4
+
5
+ Console grows a desktop launcher and a receipts tab. The public demo stops
6
+ breaking MCP clients that probe `/.well-known/*`.
7
+
8
+ ## Added
9
+
10
+ - `conarium-console --install-shortcut` / `--uninstall-shortcut`. Opens the
11
+ existing loopback console after the port listens. Browser gets a one-time
12
+ `/handoff` nonce (≤30s). The long-lived token is not put in the URL.
13
+ - Console **Makbuzlar** tab: lists `audit.receiptSink` newest-first, opens the
14
+ same receipt HTML as `/proof`, shows zincir sağlam / kırık. Renderer is
15
+ `src/receipt-view.ts`.
16
+
17
+ ## Fixed
18
+
19
+ - HTTP gateway returns 404 (plain text) for `/.well-known/*`. A 302+HTML
20
+ catch-all made some MCP clients treat the redirect body as authorization
21
+ metadata. Caddy must still 404 these paths first.
22
+
23
+ Not a dialect release. SQL remains Postgres only.
@@ -0,0 +1,26 @@
1
+ # Draft — Conarium 0.2.9
2
+
3
+ **Taslak.** GitHub Release yayımlanmadı. Tag `v0.2.9` = `73f7a86`.
4
+
5
+ Operator-facing console and proof page, plus a config-time custom PII
6
+ pattern. A design note for Oracle/MSSQL exists; there is no dialect code.
7
+
8
+ ## Added
9
+
10
+ - Custom PII pattern from config. ReDoS-shaped input is rejected at compile.
11
+ - Desktop / panel mark from the existing SVG (`.ico` / `.icns` / 512 PNG).
12
+ - `c1` sets `CONARIUM_AUDIT_SIGNING_KEY` from `~/.conarium/audit-ed25519.pem`
13
+ when `receiptSink` is set. The sink file is not invented empty.
14
+
15
+ ## Fixed
16
+
17
+ - `/proof` HTML shows known English sentences in Turkish. JSON bytes unchanged.
18
+ - Makbuzlar tab paints "Yükleniyor…" on the click that switches the tab.
19
+ - Receipt download returns bytes; file name is sanitised.
20
+
21
+ ## Docs
22
+
23
+ - `docs/specs/2026-08-14-oracle-mssql-dialect-design.md` — design only.
24
+ Oracle, MSSQL, and MySQL are not implemented.
25
+
26
+ Not a dialect release. SQL remains Postgres only.
@@ -0,0 +1,64 @@
1
+ # npm provenance
2
+
3
+ How a bank checks that an `@conarium-ai/core` tarball was built from this
4
+ repository, not from a laptop zip.
5
+
6
+ This is **not** a published release. The workflow
7
+ [`.github/workflows/publish.yml`](../../.github/workflows/publish.yml) is
8
+ dispatch-only. It does not run on push. The first publish is a human decision.
9
+
10
+ ## What provenance is
11
+
12
+ When `npm publish --provenance` runs on GitHub Actions with `id-token: write`,
13
+ npm stores a signed attestation: package version ↔ git commit ↔ workflow.
14
+
15
+ ## How to verify (after a provenance-backed release exists)
16
+
17
+ ```bash
18
+ npm view @conarium-ai/core@<version> --json
19
+ ```
20
+
21
+ Look for attestations / provenance on that version. Then:
22
+
23
+ ```bash
24
+ npx npm-provenance-check @conarium-ai/core@<version>
25
+ ```
26
+
27
+ or, with GitHub CLI, verify the attestation against this repo:
28
+
29
+ ```bash
30
+ gh attestation verify --owner dogrucanemek-alt <downloaded.tgz>
31
+ ```
32
+
33
+ If a version has **no** attestation, it was not published through this
34
+ workflow (or was published before the workflow existed). Treat that as
35
+ undeclared origin — not as "verified".
36
+
37
+ ## One-time setup before the first publish
38
+
39
+ Auth is **npm Trusted Publishing (OIDC)**, not a stored token. npm hands the
40
+ workflow a short-lived credential in exchange for its GitHub identity, so there
41
+ is no long-lived publish secret in this repository to leak.
42
+
43
+ On npmjs.com, as the package owner:
44
+
45
+ 1. `@conarium-ai/core` → **Settings** → **Trusted Publisher**
46
+ 2. Publisher: **GitHub Actions**
47
+ 3. Repository: `dogrucanemek-alt/conarium`
48
+ 4. Workflow file: `publish.yml`
49
+
50
+ Then publish: GitHub → **Actions** → **publish** → *Run workflow* →
51
+ type `publish` in the confirm box. The workflow runs lint, tests and checks
52
+ before it publishes; a red gate stops the release.
53
+
54
+ If npm rejects the OIDC exchange, do **not** fall back to adding an
55
+ `NPM_TOKEN` secret. Publish by hand from a workstation for that release and fix
56
+ the trusted publisher configuration afterwards — provenance is worth less than
57
+ a leaked publish credential costs.
58
+
59
+ ## What this does not prove
60
+
61
+ - Not a pentest.
62
+ - Not that the commit is free of bugs.
63
+ - Not that the operator's install matches the tarball (`npm ci` + lockfile
64
+ does that locally).
@@ -74,7 +74,7 @@ the first hour spent rediscovering them.
74
74
 
75
75
  1. No SOC 2, no ISO, no independent pentest. (`LIMITATIONS.md`)
76
76
  2. Not 1.0. API can break.
77
- 3. SQL is Postgres only.
77
+ 3. SQL is Postgres, Microsoft SQL Server, and Oracle. MySQL is not implemented. Oracle synonyms and database links are not resolved.
78
78
  4. Bare names and street addresses in free text are not detected.
79
79
  5. One production install; 121,366 is that company's ERP and is not
80
80
  externally verifiable.
@@ -52,8 +52,10 @@ Every tool call — allowed or denied — is supposed to write a signed receipt.
52
52
 
53
53
  ### 2. Gateway ↔ database
54
54
 
55
- **Today:** Connectors are read-only. `Governance.guardQuery` rejects writes,
56
- multi-statement, and unknown AST. Row cap is applied in the engine.
55
+ **Today:** Connectors are read-only. The shipped `query` tool selects the
56
+ SQL gate from `policy.dialect` (omitted = postgres / `Governance.guardQuery`).
57
+ The dialect is not inferred from the statement. Writes, multi-statement, and
58
+ unknown AST are rejected. Row cap is applied in the engine.
57
59
  Supabase REST and docs connectors have their own read-only paths.
58
60
 
59
61
  **Bypass surface:**
@@ -64,9 +66,9 @@ Supabase REST and docs connectors have their own read-only paths.
64
66
  - OpenAPI connector: DNS rebinding / TOCTOU between `enforceSafeRemoteUrl`
65
67
  and `fetch` is **accepted, not fixed** (`SECURITY.md`). Exploit requires an
66
68
  operator-authored `allowedBaseUrls` entry under attacker control.
67
- - SQL dialect is Postgres only. A query the parser does not understand is
68
- denied — unless a future dialect is added badly, in which case the gate
69
- fails open on that dialect. There is no second dialect in code.
69
+ - SQL dialects are Postgres, Microsoft SQL Server, and Oracle. A query
70
+ the parser does not understand is denied. MySQL is not implemented.
71
+ Oracle synonyms are not resolved; `table@dblink` is denied.
70
72
 
71
73
  ### 3. Console ↔ operator
72
74
 
@@ -98,6 +100,24 @@ Pending OpenTimestamps is disclosed as `pending`. Bitcoin upgrade is hours later
98
100
  - A shorter leftover chain still verifies. That is structural, not a bug.
99
101
  - Anchor calendars and `blockstream.info` are third parties. Unreachable →
100
102
  exit 15 ("could not check"), not exit 0.
103
+ - Two OS processes writing the same audit/receipt sink have no file lock.
104
+ In-process concurrent `log()` is synchronous and keeps the chain (measured:
105
+ 50 queries, 0 `prevHash` breaks). Same-millisecond writers across processes
106
+ can fork the chain. Single-process installs are the supported shape.
107
+
108
+ ## Out of scope — the operator
109
+
110
+ Conarium's trust boundary is **assistant ↔ gateway**. The operator is inside it.
111
+
112
+ Code that imports this library can call `CustomSqlConnector.runGoverned`, or
113
+ open the database with the same credential. That is the same authority as
114
+ connecting to the database directly. It is not a bypass of a defence that was
115
+ meant to stop the operator.
116
+
117
+ The operator's own code does not appear in the audit log. A bank closes that
118
+ with their code review, not with this gateway.
119
+
120
+ This is the product's scope. It is not a vulnerability.
101
121
 
102
122
  ## Out of scope (stated so nobody bills hours here)
103
123
 
@@ -0,0 +1,37 @@
1
+ # MSSQL — bugünkü (Postgres) koruma nasıl atlatılır
2
+
3
+ Kod yokken, `pgsql-ast-parser` + `WRITE_TOKENS` ile T-SQL okunursa.
4
+ Bu belge D’den önce yazıldı. Destek iddiası değil.
5
+
6
+ | Fark | Atlatma (parser Postgres varsayarsa) | Bu turdaki kural |
7
+ |---|---|---|
8
+ | Köşeli parantez `[Customers]` | Postgres tırnak kuralı `[` görmez. `[secrets]` string veya bilinmeyen token olabilir. | Parantezli ad çözülür; 3–4 parça ve linked server **deny**. |
9
+ | `TOP` vs `LIMIT` | `LIMIT` yok diye satır tavanı sessizce uygulanmaz. `TOP 100 PERCENT` tavan değil. | `TOP 100 PERCENT` **deny**. `TOP n` n>cap ise cap’e çekilir. Yoksa `TOP (cap)` eklenir. |
10
+ | Şema / sahip `dbo` | `public.customers` allow-list `dbo.customers` ile eşleşmez (ters hata) veya 4 parça düşer. | MSSQL politikası `dbo.*`. `server.db.schema.table` **deny**. Niteliksiz **deny**. |
11
+ | `GO` | Batch ayırıcı; parser tek SELECT görüp gerisini yutabilir. | `\bGO\b` **deny**. |
12
+ | `;` çok ifade | İkinci ifade yazma olabilir. | Birden fazla ifade **deny**. |
13
+ | `xp_*` / `sp_*` | Fonksiyon allow-list Postgres adları. `xp_cmdshell` geçer gibi durur. | `xp_` / `sp_` **deny** (parse öncesi). |
14
+ | `OPENROWSET` / `OPENQUERY` | Tablo gibi durur; `inspectFunction` görmez. | İsim **deny**. |
15
+ | `FOR XML` / `FOR JSON` | SELECT soneki, fonksiyon değil. | **deny**. |
16
+ | `EXEC` / `EXECUTE` | `\bCALL\b` yakalamaz. | **deny**. |
17
+ | Yorum / string | `--` ve `/* */` Postgres ile aynı sınıf; kaçış `]` `]]`. | Parse başarısız → **deny**. |
18
+
19
+ **Ayrıştırıcı:** `node-sql-parser` (yalnız `transactsql` build).
20
+ Gerekçe: T-SQL AST + sqlify. Bakım riski: Microsoft parser’ı değil; PEG. Bilmediği düğüm **deny**, “bilmiyorum = izin” yok.
21
+
22
+ ## Parser’ın kabul edip kapının reddettiği (bu turda bulundu)
23
+
24
+ Savunma gevşetilmedi. Pre-deny / tip kontrolü şart:
25
+
26
+ | Girdi | Parser | Kapı |
27
+ |---|---|---|
28
+ | `… customers GO` | parse OK; `GO` tablo takma adı oluyor | `\bGO\b` deny |
29
+ | `OPENROWSET` | parse OK; `tableList` **boş** | isim deny (yalnız tableList = sessiz atlatma) |
30
+ | `not sql` (kısa) | parse OK; `type: assign` | select olmayan tip deny |
31
+ | `not sql at all !!!` | parse fail | parse fail → deny |
32
+ | `SELECT …; SELECT 1` | ast dizi uzunluğu 2 | çok ifade deny |
33
+ | `TOP 100 PERCENT` | parse OK | PERCENT deny |
34
+ | `SELECT id INTO x …` | parse OK | `into.type === 'into'` deny |
35
+ | 4 parça `server.db.dbo.t` | parse OK | `server` / 3+ parça deny |
36
+
37
+ UNION’da `TOP` yalnız ilk SELECT’e biner. Kapı UNION’ı `SELECT TOP n * FROM (… )` ile sarar.
@@ -0,0 +1,28 @@
1
+ # Oracle — bugünkü (Postgres) koruma nasıl atlatılır
2
+
3
+ Kod yokken, `pgsql-ast-parser` + `WRITE_TOKENS` ile Oracle SQL okunursa.
4
+ Bu belge E’den önce yazıldı. Destek iddiası değil.
5
+
6
+ | Fark | Atlatma (parser Postgres varsayarsa) | Bu turdaki kural |
7
+ |---|---|---|
8
+ | Tırnak / büyük-küçük | Oracle tırnaksız adı UPPER fold eder. `"secrets"` ≠ `SECRETS`. Postgres tırnak kuralı yanlış eşleşir. | Fold + tırnaklı ad çözülür; niteliksiz **deny**. |
9
+ | Şema = kullanıcı | `public.customers` allow-list `APP.CUSTOMERS` ile eşleşmez. | Oracle politikası `app.*`. |
10
+ | `ROWNUM` / `FETCH FIRST` | `LIMIT` yok diye tavan sessizce uygulanmaz. `ROWNUM <= 9999` tavan değil. | `FETCH FIRST n ROWS ONLY` n>cap ise cap. `ROWNUM` **deny** (satır tavanı değil, predicate). |
11
+ | Analitik / pencere | `ROW_NUMBER() OVER` ile dışarıdan LIMIT taklidi. | Pencere fonksiyonu satır tavanı sayılmaz; dış `FETCH FIRST` zorunlu. |
12
+ | `UTL_*` / `DBMS_*` | Fonksiyon allow-list Postgres adları. Ağ/dosya çağrısı geçer gibi durur. | `UTL_` / `DBMS_` **deny** (parse öncesi). |
13
+ | `BEGIN…END` | Anonim blok; parser SELECT görmeyebilir veya yutabilir. | SELECT/WITH olmayan **deny**. |
14
+ | Yorum / string | `--` `/* */` q-quote `q'!...!'`. | Parse başarısız → **deny**. |
15
+ | Synonym | Parser taban tabloyu görmez; allow-list synonym adına bakar. | **Kapanmaz.** Operatör allow-list’e koyduğu adı görür, hedefi değil. LIMITATIONS’ta dürüst kal. |
16
+ | DB link `table@dblink` | Uzak tablo yerel gibi durur. | `@` **deny**. |
17
+
18
+ **Ayrıştırıcı:** `node-sql-parser` 5.4.0’da Oracle build **yok**.
19
+ Bunun yerine `@guanmingchiu/sqlparser-ts` 0.62 (`sqlparser-rs` WASM, lehçe `oracle`).
20
+ Gerekçe: gerçek Oracle AST. Bakım: genç sarmalayıcı, upstream Apache sqlparser-rs.
21
+ `format()` AST→SQL bu sürümde çalışmıyor; satır tavanı orijinal SQL’i `FETCH FIRST n` ile sarar.
22
+ Bilmediği girdi **deny**. Synonym hedefi **kapanmaz**.
23
+
24
+ ## Canlı örnek (kabul 2) — 2026-08-14 19:36
25
+
26
+ İlk tur: `--memory=2g` + init sırasında exec/stop. Log: `CONTAINER: shutdown request received` (SIGTERM). `OOMKilled=false`. Yarım init → `ORA-01109`.
27
+ Bu tur: bellek tavanı yok, `--shm-size=1g`, named volume, init bitene kadar dokunulmadı. ~1 dk’da `DATABASE IS READY TO USE` + `APP_USER`. `PASS oracle-live`: 80→50, secrets dolu+deny, garbage deny.
28
+ Emit: `_conarium_cap` Oracle’da yasadışı tanımlayıcı (`ORA-00911`); `conarium_cap` oldu.
@@ -0,0 +1,50 @@
1
+ # Custom SQL executor
2
+
3
+ Conarium does not ship MSSQL, Oracle, or any other database driver. The
4
+ operator attaches a function that receives **gated** SQL and returns rows.
5
+
6
+ This folder is an in-memory reference. It adds **no** npm dependency.
7
+
8
+ ## Config
9
+
10
+ `connectors[].type` is `custom-sql`. `policy.dialect` is **required**
11
+ (`postgres`, `mssql`, or `oracle`). Omitting it rejects the file — the
12
+ postgres default would parse an unknown engine with the Postgres gate.
13
+
14
+ ```json
15
+ {
16
+ "connectors": [{
17
+ "type": "custom-sql",
18
+ "name": "memory",
19
+ "description": "Operator executor",
20
+ "config": { "module": "./memory-executor.mjs" }
21
+ }],
22
+ "policy": {
23
+ "dialect": "postgres",
24
+ "allowConnectors": ["memory"],
25
+ "allowTables": ["public.customers"],
26
+ "maskColumns": ["*.email"],
27
+ "maxRows": 50
28
+ }
29
+ }
30
+ ```
31
+
32
+ The module must export `execute(sql)`.
33
+
34
+ ## Programmatic register
35
+
36
+ From your own process, before the gateway boots:
37
+
38
+ ```js
39
+ import { registerSqlExecutor } from '@conarium-ai/core/dist/sql-executor.js'
40
+
41
+ registerSqlExecutor('memory', async (sql) => {
42
+ // `sql` already passed the gate. Call your driver with it.
43
+ return { rows: [], fields: [] }
44
+ })
45
+ ```
46
+
47
+ `connector.query()` is closed. The only entry is the MCP `query` tool.
48
+
49
+ There is no shipped Oracle or MSSQL connector. The gate speaks three
50
+ dialects; the connection is yours.
@@ -0,0 +1,22 @@
1
+ {
2
+ "serverName": "Conarium custom-sql example",
3
+ "consumer": "custom-sql-example",
4
+ "connectors": [
5
+ {
6
+ "type": "custom-sql",
7
+ "name": "memory",
8
+ "description": "In-memory reference executor — no extra dependency",
9
+ "config": {
10
+ "module": "./memory-executor.mjs"
11
+ }
12
+ }
13
+ ],
14
+ "policy": {
15
+ "dialect": "postgres",
16
+ "allowConnectors": ["memory"],
17
+ "allowTables": ["public.customers"],
18
+ "denyTables": ["public.secrets"],
19
+ "maskColumns": ["*.email"],
20
+ "maxRows": 50
21
+ }
22
+ }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * In-memory reference executor. No extra npm dependency.
3
+ *
4
+ * Conarium will only call `execute` with SQL that already passed the gate.
5
+ * This sample ignores the statement and returns every row on purpose — the
6
+ * gateway still applies the row cap and the mask. A real operator passes
7
+ * the gated SQL to their own driver (mssql, oracledb, snowflake, …).
8
+ */
9
+ const ROWS = Array.from({ length: 80 }, (_, i) => ({
10
+ id: i + 1,
11
+ email: `user${i + 1}@example.com`,
12
+ }))
13
+
14
+ export async function execute(_sql) {
15
+ return { rows: ROWS, fields: ['id', 'email'] }
16
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@conarium-ai/core",
3
- "version": "0.2.10",
3
+ "version": "0.2.12",
4
4
  "//files-artefakt": "examples/ altindaki uretilmis dosyalar (ozel anahtar, makbuz/denetim JSONL) ELENIR. .gitignore npm'i baglamaz: izin listesinde 'examples' oldugu icin demoyu kosturmus bir makinede 'npm publish' _keys/audit-ed25519.pem'i (OZEL ANAHTAR) ve makbuzlari yayinliyordu. test/pack_artefakt.mjs bunu kilitler. Elemeler examples/ ile SINIRLI: test-vectors/ altindaki receipts.jsonl ve .pub.pem YAYINLANMAK ZORUNDA, yoksa ucuncu taraf konformans vektorlerini kosturamaz.",
5
5
  "//files": "Pakete NE gireceginin izin listesi. Liste olmadan npm her seyi gonderiyordu: 296 dosya / 1.5 MB — CI workflowlari, gitleaks ayari, 137 KB pazarlama gorseli, sitenin api/chat.js dosyasi. Bir bankanin guvenlik ekibi tarball'i acip bunlari gorur. scripts/ BILEREK var: conarium-reconcile calisirken scripts/pg-snapshot.sql'e atif yapiyor, olmazsa kullanici destek maili yazar.",
6
6
  "files": [
@@ -79,20 +79,20 @@
79
79
  "start": "node dist/index.js",
80
80
  "lint": "tsc --noEmit",
81
81
  "prepublishOnly": "npm run build",
82
- "test:vectors": "node test/vectors_run.mjs"
82
+ "test:vectors": "node test/vectors_run.mjs",
83
+ "bench:overhead": "node scripts/benchmark-overhead.mjs"
83
84
  },
84
85
  "dependencies": {
86
+ "@guanmingchiu/sqlparser-ts": "^0.62.0",
85
87
  "@modelcontextprotocol/sdk": "^1.0.0",
86
88
  "express": "^5.2.1",
87
- "js-yaml": "^5.2.3",
88
- "node-fetch": "^3.3.2",
89
+ "node-sql-parser": "^5.4.0",
89
90
  "pgsql-ast-parser": "^12.0.2",
90
91
  "postgres": "^3.4.4",
91
92
  "zod": "^3.23.8"
92
93
  },
93
94
  "devDependencies": {
94
95
  "@types/express": "^5.0.6",
95
- "@types/js-yaml": "^4.0.9",
96
96
  "@types/node": "^22.20.0",
97
97
  "supertest": "^7.2.2",
98
98
  "tsx": "^4.16.0",
@@ -0,0 +1,133 @@
1
+ /**
2
+ * In-process concurrency + audit-chain race. Does not touch Hetzner.
3
+ * Hardware is recorded with the numbers. Not a formal load test.
4
+ */
5
+ import { cpus, totalmem, platform, release } from 'os'
6
+ import { mkdtempSync, readFileSync, writeFileSync, mkdirSync } from 'fs'
7
+ import { tmpdir } from 'os'
8
+ import { join, dirname } from 'path'
9
+ import { fileURLToPath } from 'url'
10
+ import { CallToolRequestSchema } from '@modelcontextprotocol/sdk/types.js'
11
+ import { buildServer } from '../dist/server.js'
12
+ import { Audit } from '../dist/audit.js'
13
+ import { Governance } from '../dist/governance.js'
14
+
15
+ const N = Number(process.env.CONARIUM_BENCH_N || 50)
16
+ const PREV = process.env.CONARIUM_AUDIT_UNSIGNED
17
+ process.env.CONARIUM_AUDIT_UNSIGNED = '1'
18
+
19
+ const conn = {
20
+ name: 'mem',
21
+ description: 'concurrency fixture',
22
+ capabilities: { canQuery: true, canListSchema: false, canDescribeTable: false, canSearch: false },
23
+ connect: async () => {},
24
+ disconnect: async () => {},
25
+ listTables: async () => [],
26
+ describeTable: async (t) => ({ name: t, schema: 'public', columns: [] }),
27
+ query: async (sql) => {
28
+ await new Promise((r) => setImmediate(r))
29
+ return { rows: [{ id: 1, email: 'a@b.com' }], rowCount: 1, fields: ['id', 'email'] }
30
+ },
31
+ search: async () => ({ rows: [], rowCount: 0, fields: [] }),
32
+ }
33
+
34
+ const dir = mkdtempSync(join(tmpdir(), 'conarium-conc-'))
35
+ const sink = join(dir, 'audit.jsonl')
36
+ const deps = {
37
+ config: { serverName: 'bench', consumer: 'conc', connectors: [] },
38
+ governance: new Governance({
39
+ allowConnectors: ['mem'],
40
+ allowTables: ['public.customers'],
41
+ maskColumns: ['*.email'],
42
+ maxRows: 50,
43
+ dialect: 'postgres',
44
+ }),
45
+ audit: new Audit({ consumer: 'conc', sink }),
46
+ connectors: [conn],
47
+ }
48
+ const server = buildServer(deps)
49
+ const handlers = server._requestHandlers
50
+ const call = handlers.get(CallToolRequestSchema.shape.method.value)
51
+
52
+ function pct(sorted, p) {
53
+ if (!sorted.length) return null
54
+ const i = Math.min(sorted.length - 1, Math.ceil((p / 100) * sorted.length) - 1)
55
+ return sorted[i]
56
+ }
57
+
58
+ const t0 = process.hrtime.bigint()
59
+ const heap0 = process.memoryUsage()
60
+ const started = Date.now()
61
+ const results = await Promise.all(
62
+ Array.from({ length: N }, async () => {
63
+ const a = process.hrtime.bigint()
64
+ const out = await call({
65
+ method: 'tools/call',
66
+ params: { name: 'query', arguments: { sql: 'SELECT id, email FROM public.customers' } },
67
+ })
68
+ const ms = Number(process.hrtime.bigint() - a) / 1e6
69
+ return { ms, isError: Boolean(out.isError) }
70
+ }),
71
+ )
72
+ const wallMs = Date.now() - started
73
+ const heap1 = process.memoryUsage()
74
+
75
+ const times = results.map((r) => r.ms).sort((a, b) => a - b)
76
+ const errors = results.filter((r) => r.isError).length
77
+ const lines = readFileSync(sink, 'utf8').trim().split('\n').filter(Boolean).map((l) => JSON.parse(l))
78
+ const prevBreaks = []
79
+ for (let i = 1; i < lines.length; i++) {
80
+ if (lines[i].prevHash !== lines[i - 1].hash) prevBreaks.push(i + 1)
81
+ }
82
+
83
+ const auditA = new Audit({ consumer: 'race-a', sink: join(dir, 'race.jsonl') })
84
+ const auditB = new Audit({ consumer: 'race-b', sink: join(dir, 'race.jsonl') })
85
+ // Two instances, interleaved only at await boundaries — log() itself is sync.
86
+ await Promise.all([
87
+ (async () => { await new Promise((r) => setImmediate(r)); auditA.log({ tool: 'q', denied: false }) })(),
88
+ (async () => { await new Promise((r) => setImmediate(r)); auditB.log({ tool: 'q', denied: false }) })(),
89
+ ])
90
+ const raceLines = readFileSync(join(dir, 'race.jsonl'), 'utf8').trim().split('\n').filter(Boolean).map((l) => JSON.parse(l))
91
+ const raceBreaks = []
92
+ for (let i = 1; i < raceLines.length; i++) {
93
+ if (raceLines[i].prevHash !== raceLines[i - 1].hash) raceBreaks.push(i + 1)
94
+ }
95
+
96
+ const huge = await call({
97
+ method: 'tools/call',
98
+ params: { name: 'query', arguments: { sql: 'SELECT ' + 'x,'.repeat(200) + 'id FROM public.customers' } },
99
+ })
100
+
101
+ const report = {
102
+ when: new Date().toISOString(),
103
+ hardware: {
104
+ cpu: cpus()[0]?.model,
105
+ cores: cpus().length,
106
+ ramBytes: totalmem(),
107
+ os: `${platform()} ${release()}`,
108
+ node: process.version,
109
+ },
110
+ n: N,
111
+ wallMs,
112
+ latencyMs: { p50: pct(times, 50), p95: pct(times, 95), p99: pct(times, 99), min: times[0], max: times[times.length - 1] },
113
+ errorRate: errors / N,
114
+ chain: { entries: lines.length, prevHashBreaks: prevBreaks },
115
+ twoInstanceRace: { entries: raceLines.length, prevHashBreaks: raceBreaks },
116
+ heap: {
117
+ heapUsed0: heap0.heapUsed,
118
+ heapUsed1: heap1.heapUsed,
119
+ delta: heap1.heapUsed - heap0.heapUsed,
120
+ },
121
+ hugeSql: { isError: Boolean(huge.isError), preview: String(huge.content?.[0]?.text || '').slice(0, 120) },
122
+ elapsedNs: Number(process.hrtime.bigint() - t0),
123
+ }
124
+
125
+ const outDir = join(dirname(fileURLToPath(import.meta.url)), '..', 'docs', 'benchmarks')
126
+ mkdirSync(outDir, { recursive: true })
127
+ const outPath = join(outDir, 'concurrency-20260814.json')
128
+ writeFileSync(outPath, JSON.stringify(report, null, 2) + '\n')
129
+ console.log(JSON.stringify(report, null, 2))
130
+ console.log(`wrote ${outPath}`)
131
+
132
+ if (PREV === undefined) delete process.env.CONARIUM_AUDIT_UNSIGNED
133
+ else process.env.CONARIUM_AUDIT_UNSIGNED = PREV