@conarium-ai/core 0.2.11 → 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 (56) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/LIMITATIONS.md +15 -2
  3. package/LIMITATIONS.tr.md +14 -2
  4. package/SECURITY.md +1 -0
  5. package/bin/conarium-doctor.mjs +18 -0
  6. package/dist/audit.d.ts.map +1 -1
  7. package/dist/audit.js +12 -3
  8. package/dist/audit.js.map +1 -1
  9. package/dist/config.d.ts +14 -8
  10. package/dist/config.d.ts.map +1 -1
  11. package/dist/config.js +16 -1
  12. package/dist/config.js.map +1 -1
  13. package/dist/connectors/custom-sql.d.ts +22 -0
  14. package/dist/connectors/custom-sql.d.ts.map +1 -0
  15. package/dist/connectors/custom-sql.js +67 -0
  16. package/dist/connectors/custom-sql.js.map +1 -0
  17. package/dist/connectors/index.d.ts +1 -0
  18. package/dist/connectors/index.d.ts.map +1 -1
  19. package/dist/connectors/index.js +5 -1
  20. package/dist/connectors/index.js.map +1 -1
  21. package/dist/connectors/openapi.d.ts.map +1 -1
  22. package/dist/connectors/openapi.js +0 -1
  23. package/dist/connectors/openapi.js.map +1 -1
  24. package/dist/connectors/supabase_rest.d.ts.map +1 -1
  25. package/dist/connectors/supabase_rest.js +0 -1
  26. package/dist/connectors/supabase_rest.js.map +1 -1
  27. package/dist/executor.d.ts.map +1 -1
  28. package/dist/executor.js +0 -1
  29. package/dist/executor.js.map +1 -1
  30. package/dist/search_policy.d.ts.map +1 -1
  31. package/dist/search_policy.js +8 -4
  32. package/dist/search_policy.js.map +1 -1
  33. package/dist/server.d.ts.map +1 -1
  34. package/dist/server.js +87 -12
  35. package/dist/server.js.map +1 -1
  36. package/dist/sql-executor.d.ts +14 -0
  37. package/dist/sql-executor.d.ts.map +1 -0
  38. package/dist/sql-executor.js +75 -0
  39. package/dist/sql-executor.js.map +1 -0
  40. package/dist/table-unavailable.d.ts +12 -0
  41. package/dist/table-unavailable.d.ts.map +1 -0
  42. package/dist/table-unavailable.js +32 -0
  43. package/dist/table-unavailable.js.map +1 -0
  44. package/dist/types.d.ts +4 -3
  45. package/dist/types.d.ts.map +1 -1
  46. package/docs/API-STABILITY.md +2 -2
  47. package/docs/BENCHMARK.md +20 -0
  48. package/docs/benchmarks/concurrency-20260814.json +38 -0
  49. package/docs/security/NPM-PROVENANCE.md +64 -0
  50. package/docs/security/THREAT-MODEL.md +18 -0
  51. package/examples/custom-sql/README.md +50 -0
  52. package/examples/custom-sql/conarium.config.json +22 -0
  53. package/examples/custom-sql/memory-executor.mjs +16 -0
  54. package/package.json +1 -4
  55. package/scripts/benchmark-concurrency.mjs +133 -0
  56. package/test-vectors/sql-gate/LAST-RUN.json +1 -1
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Assistant-facing table errors must not distinguish "denied" from "missing".
3
+ * The audit log keeps the real reason. Timing is a residual side channel:
4
+ * a deny never reaches the connector (that stays); a missing table may.
5
+ */
6
+ export function tableUnavailableMessage(table) {
7
+ return `Access to table '${table}' is not available.`;
8
+ }
9
+ export function tableUnavailableError(table) {
10
+ return new Error(tableUnavailableMessage(table));
11
+ }
12
+ export function tableFromAccessDeny(message) {
13
+ const m = message.match(/Access to table '([^']+)' is not permitted by policy/);
14
+ return m?.[1];
15
+ }
16
+ export function isMissingTableMessage(message) {
17
+ return /not found|does not exist|invalid object name|ora-00942|unknown table|unknown relation/i.test(message);
18
+ }
19
+ /** After the real reason is in the audit log, rewrite the assistant error. */
20
+ export function publicizeTableError(err, fallbackTable) {
21
+ const msg = err instanceof Error ? err.message : String(err);
22
+ const denied = tableFromAccessDeny(msg);
23
+ if (denied)
24
+ throw tableUnavailableError(denied);
25
+ if (isMissingTableMessage(msg)) {
26
+ const named = msg.match(/(?:table|relation)\s+(?:not found:\s*)?['"]?([a-zA-Z0-9_.]+)/i)?.[1] ??
27
+ fallbackTable;
28
+ throw tableUnavailableError(named ?? 'unknown');
29
+ }
30
+ throw err;
31
+ }
32
+ //# sourceMappingURL=table-unavailable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"table-unavailable.js","sourceRoot":"","sources":["../src/table-unavailable.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,UAAU,uBAAuB,CAAC,KAAa;IACnD,OAAO,oBAAoB,KAAK,qBAAqB,CAAA;AACvD,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,KAAa;IACjD,OAAO,IAAI,KAAK,CAAC,uBAAuB,CAAC,KAAK,CAAC,CAAC,CAAA;AAClD,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,OAAe;IACjD,MAAM,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,sDAAsD,CAAC,CAAA;IAC/E,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;AACf,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,OAAe;IACnD,OAAO,wFAAwF,CAAC,IAAI,CAClG,OAAO,CACR,CAAA;AACH,CAAC;AAED,8EAA8E;AAC9E,MAAM,UAAU,mBAAmB,CAAC,GAAY,EAAE,aAAsB;IACtE,MAAM,GAAG,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;IAC5D,MAAM,MAAM,GAAG,mBAAmB,CAAC,GAAG,CAAC,CAAA;IACvC,IAAI,MAAM;QAAE,MAAM,qBAAqB,CAAC,MAAM,CAAC,CAAA;IAC/C,IAAI,qBAAqB,CAAC,GAAG,CAAC,EAAE,CAAC;QAC/B,MAAM,KAAK,GACT,GAAG,CAAC,KAAK,CAAC,+DAA+D,CAAC,EAAE,CAAC,CAAC,CAAC;YAC/E,aAAa,CAAA;QACf,MAAM,qBAAqB,CAAC,KAAK,IAAI,SAAS,CAAC,CAAA;IACjD,CAAC;IACD,MAAM,GAAG,CAAA;AACX,CAAC"}
package/dist/types.d.ts CHANGED
@@ -20,8 +20,9 @@ export interface GovernancePolicy {
20
20
  maxRows?: number;
21
21
  /**
22
22
  * Which SQL gate the shipped `query` tool uses. Operator declaration —
23
- * never inferred from the statement. Omitted = `postgres` (today's path).
24
- * Unknown values reject the config; they do not fall back.
23
+ * never inferred from the statement. Omitted = `postgres` (today's path)
24
+ * except when a `custom-sql` connector is present: that path requires an
25
+ * explicit dialect. Unknown values reject the config; they do not fall back.
25
26
  */
26
27
  dialect?: 'postgres' | 'mssql' | 'oracle';
27
28
  /**
@@ -133,7 +134,7 @@ export interface AuditConfig {
133
134
  };
134
135
  }
135
136
  export interface ConnectorConfig {
136
- type: 'postgres' | 'supabase' | 'supabase-rest' | 'openapi' | 'files' | 'docs' | 'slack' | 'jira';
137
+ type: 'postgres' | 'supabase' | 'supabase-rest' | 'openapi' | 'files' | 'docs' | 'slack' | 'jira' | 'custom-sql';
137
138
  name: string;
138
139
  description: string;
139
140
  config: Record<string, string>;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc;IAC7B,UAAU,EAAE,eAAe,EAAE,CAAA;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,6EAA6E;IAC7E,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,sDAAsD;IACtD,MAAM,CAAC,EAAE,gBAAgB,CAAA;IACzB,2BAA2B;IAC3B,KAAK,CAAC,EAAE,WAAW,CAAA;CACpB;AAED,MAAM,WAAW,gBAAgB;IAC/B,kHAAkH;IAClH,WAAW,CAAC,EAAE,MAAM,EAAE,CAAA;IACtB,yEAAyE;IACzE,UAAU,CAAC,EAAE,MAAM,EAAE,CAAA;IACrB,qFAAqF;IACrF,WAAW,CAAC,EAAE,MAAM,EAAE,CAAA;IACtB,mEAAmE;IACnE,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB;;;;OAIG;IACH,OAAO,CAAC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AE,OAAO,CAAA;IACjB,SAAS,EAAE,OAAO,CAAA;IAClB,SAAS,EAAE,OAAO,CAAA;IAClB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAA;IAC/B,QAAQ,EAAE,MAAM,CAAA;IAChB,MAAM,EAAE,MAAM,EAAE,CAAA;IAChB,GAAG,CAAC,EAAE,MAAM,CAAA;CACb;AAED,MAAM,WAAW,qBAAqB;IACpC,QAAQ,EAAE,OAAO,CAAA;IACjB,aAAa,EAAE,OAAO,CAAA;IACtB,gBAAgB,EAAE,OAAO,CAAA;IACzB,SAAS,EAAE,OAAO,CAAA;CACnB;AAED,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,CAAA;IACnB,YAAY,EAAE,qBAAqB,CAAA;IACnC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;IACxB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;IAC3B,UAAU,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC,CAAA;IACpC,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAAA;IAClD,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,WAAW,CAAC,CAAA;IAC5D,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,WAAW,CAAC,CAAA;CAC/D"}
@@ -82,11 +82,11 @@ Parsed by `src/config.ts` (Zod `.strict()`). Unknown keys reject the file.
82
82
  | Field | Label |
83
83
  |---|---|
84
84
  | `connectors[]` (`type`, `name`, `description`, `config`) | experimental |
85
- | `connectors[].type` enum (`postgres`, `supabase`, `supabase-rest`, `openapi`, `files`, `docs`, `slack`, `jira`) | experimental — values can be added or removed |
85
+ | `connectors[].type` enum (`postgres`, `supabase`, `supabase-rest`, `openapi`, `files`, `docs`, `slack`, `jira`, `custom-sql`) | experimental — values can be added or removed |
86
86
  | `serverName` `serverVersion` `consumer` | experimental |
87
87
  | `policy.allowTables` `denyTables` | **candidate** (default-deny, deny wins) |
88
88
  | `policy.maskColumns` `maxRows` | experimental (cap ceiling is 10 000 at parse) |
89
- | `policy.dialect` (`postgres` omitted default, `mssql`, `oracle`) | experimental — unknown values reject the file; not inferred from SQL |
89
+ | `policy.dialect` (`postgres` omitted default, `mssql`, `oracle`) | experimental — unknown values reject the file; not inferred from SQL; required when a `custom-sql` connector is present |
90
90
  | `policy.allowConnectors` `denyConnectors` | experimental — empty allow is fail-closed |
91
91
  | `policy.allowTools` `denyTools` | experimental |
92
92
  | `policy.profiles` `actorProfiles` | experimental |
package/docs/BENCHMARK.md CHANGED
@@ -122,3 +122,23 @@ Not a substitute for the table above. Shows the same cliff without a socket.
122
122
  100 is the last measured point still in the low-millisecond band
123
123
  (same-limit partial overhead p50 = 5.0 ms). 500 is already 87 ms.
124
124
  The doctor and `parseConariumConfig` warn. They do not reject the query.
125
+
126
+ ---
127
+
128
+ ## Concurrency (in-process, not Hetzner)
129
+
130
+ Replay: `node scripts/benchmark-concurrency.mjs` (needs `npm run build`).
131
+ Raw: [`benchmarks/concurrency-20260814.json`](benchmarks/concurrency-20260814.json).
132
+
133
+ | | |
134
+ |---|---|
135
+ | CPU | Intel Core Ultra 9 275HX × 24 |
136
+ | RAM | 32 GB |
137
+ | OS | win32 10.0.26200 |
138
+ | Node | v24.5.0 |
139
+ | N | 50 concurrent MCP `query` (mock connector) |
140
+ | When | 2026-08-14T18:19Z |
141
+
142
+ p50 **45.5 ms** · p95 **48.6 ms** · p99 **61.3 ms** · wall **98 ms** · error rate **0**.
143
+ Single `Audit` instance: 50 entries, **0** `prevHash` breaks (`log()` is synchronous).
144
+ This is not a leak hunt and not a two-process sink race.
@@ -0,0 +1,38 @@
1
+ {
2
+ "when": "2026-08-14T18:19:21.122Z",
3
+ "hardware": {
4
+ "cpu": "Intel(R) Core(TM) Ultra 9 275HX",
5
+ "cores": 24,
6
+ "ramBytes": 33752997888,
7
+ "os": "win32 10.0.26200",
8
+ "node": "v24.5.0"
9
+ },
10
+ "n": 50,
11
+ "wallMs": 98,
12
+ "latencyMs": {
13
+ "p50": 45.5191,
14
+ "p95": 48.5808,
15
+ "p99": 61.335,
16
+ "min": 41.8328,
17
+ "max": 61.335
18
+ },
19
+ "errorRate": 0,
20
+ "chain": {
21
+ "entries": 50,
22
+ "prevHashBreaks": []
23
+ },
24
+ "twoInstanceRace": {
25
+ "entries": 2,
26
+ "prevHashBreaks": []
27
+ },
28
+ "heap": {
29
+ "heapUsed0": 25426680,
30
+ "heapUsed1": 35596152,
31
+ "delta": 10169472
32
+ },
33
+ "hugeSql": {
34
+ "isError": false,
35
+ "preview": "{\n \"rowCount\": 1,\n \"fields\": [\n \"id\",\n \"email\"\n ],\n \"rows\": [\n {\n \"id\": 1,\n \"email\": \"[MASKED_PII"
36
+ },
37
+ "elapsedNs": 121576800
38
+ }
@@ -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).
@@ -100,6 +100,24 @@ Pending OpenTimestamps is disclosed as `pending`. Bitcoin upgrade is hours later
100
100
  - A shorter leftover chain still verifies. That is structural, not a bug.
101
101
  - Anchor calendars and `blockstream.info` are third parties. Unreachable →
102
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.
103
121
 
104
122
  ## Out of scope (stated so nobody bills hours here)
105
123
 
@@ -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.11",
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": [
@@ -86,8 +86,6 @@
86
86
  "@guanmingchiu/sqlparser-ts": "^0.62.0",
87
87
  "@modelcontextprotocol/sdk": "^1.0.0",
88
88
  "express": "^5.2.1",
89
- "js-yaml": "^5.2.3",
90
- "node-fetch": "^3.3.2",
91
89
  "node-sql-parser": "^5.4.0",
92
90
  "pgsql-ast-parser": "^12.0.2",
93
91
  "postgres": "^3.4.4",
@@ -95,7 +93,6 @@
95
93
  },
96
94
  "devDependencies": {
97
95
  "@types/express": "^5.0.6",
98
- "@types/js-yaml": "^4.0.9",
99
96
  "@types/node": "^22.20.0",
100
97
  "supertest": "^7.2.2",
101
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
@@ -7,5 +7,5 @@
7
7
  "crashed": 0,
8
8
  "bypasses": 0,
9
9
  "result": "bulunamadi",
10
- "when": "2026-08-14T17:35:25.099Z"
10
+ "when": "2026-08-14T20:01:39.940Z"
11
11
  }