@conarium-ai/core 0.2.20 → 0.2.22

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 (103) hide show
  1. package/CHANGELOG.md +68 -0
  2. package/LIMITATIONS.md +30 -0
  3. package/LIMITATIONS.tr.md +16 -0
  4. package/README.md +40 -5
  5. package/SECURITY.md +1 -1
  6. package/bin/conarium-docker-entry.mjs +62 -0
  7. package/bin/conarium-doctor.mjs +59 -2
  8. package/bin/conarium-reconcile.mjs +19 -5
  9. package/bin/conarium-verify.mjs +42 -7
  10. package/conformance/KNOWN-GAPS.md +20 -0
  11. package/conformance/README.md +85 -0
  12. package/conformance/adapters/README.md +59 -0
  13. package/conformance/adapters/conarium.mjs +17 -0
  14. package/conformance/cases/coverage/expect-count-pin.json +13 -0
  15. package/conformance/cases/coverage/tail-without-pin.json +15 -0
  16. package/conformance/cases/evidence/001-single-receipt.json +16 -0
  17. package/conformance/cases/evidence/002-chain-of-three.json +16 -0
  18. package/conformance/cases/evidence/003-tampered-field.json +16 -0
  19. package/conformance/cases/evidence/004-prevhash-break.json +16 -0
  20. package/conformance/cases/evidence/005-seq-gap.json +16 -0
  21. package/conformance/cases/evidence/006-bad-signature.json +16 -0
  22. package/conformance/cases/evidence/007-schema-invalid.json +16 -0
  23. package/conformance/cases/evidence/008-unsigned-no-pubkey.json +13 -0
  24. package/conformance/cases/evidence/009-unsigned-but-pubkey-given.json +16 -0
  25. package/conformance/cases/gate/deny-alias.json +13 -0
  26. package/conformance/cases/gate/deny-case-fold.json +13 -0
  27. package/conformance/cases/gate/deny-comment-between.json +13 -0
  28. package/conformance/cases/gate/deny-cte.json +13 -0
  29. package/conformance/cases/gate/deny-join.json +13 -0
  30. package/conformance/cases/gate/deny-plain.json +13 -0
  31. package/conformance/cases/gate/deny-quoted-lower.json +13 -0
  32. package/conformance/cases/gate/deny-schema-qualify.json +13 -0
  33. package/conformance/cases/gate/deny-string-agg.json +13 -0
  34. package/conformance/cases/gate/deny-subquery.json +13 -0
  35. package/conformance/cases/gate/deny-unqualified.json +13 -0
  36. package/conformance/cases/gate/deny-updlock.json +13 -0
  37. package/conformance/cases/gate/deny-user-fn.json +13 -0
  38. package/conformance/cases/gate/fail-empty.json +13 -0
  39. package/conformance/cases/gate/fail-garbage.json +13 -0
  40. package/conformance/cases/gate/fail-two-statements.json +13 -0
  41. package/conformance/cases/gate/write-copy.json +13 -0
  42. package/conformance/cases/gate/write-create.json +13 -0
  43. package/conformance/cases/gate/write-delete.json +13 -0
  44. package/conformance/cases/gate/write-drop.json +13 -0
  45. package/conformance/cases/gate/write-insert.json +13 -0
  46. package/conformance/cases/gate/write-merge.json +13 -0
  47. package/conformance/cases/gate/write-truncate.json +13 -0
  48. package/conformance/cases/gate/write-update.json +13 -0
  49. package/conformance/cases/inference/cohort-narrowing.json +13 -0
  50. package/conformance/cases/inference/count-channel.json +13 -0
  51. package/conformance/cases/inference/exists-channel.json +13 -0
  52. package/conformance/cases/inference/repeated-probe.json +13 -0
  53. package/conformance/cases/masking/mask-alias.json +14 -0
  54. package/conformance/cases/masking/mask-case.json +14 -0
  55. package/conformance/cases/masking/mask-concat.json +14 -0
  56. package/conformance/cases/masking/mask-subquery.json +14 -0
  57. package/conformance/cases/rowcap/cap-nested.json +14 -0
  58. package/conformance/cases/rowcap/cap-raise-limit.json +14 -0
  59. package/conformance/cases/rowcap/cap-union.json +14 -0
  60. package/conformance/claims/conarium.json +12 -0
  61. package/conformance/lib/status.mjs +48 -0
  62. package/conformance/policies/mask-email.json +5 -0
  63. package/conformance/policies/protected-email.json +6 -0
  64. package/conformance/policies/sql-gate.json +6 -0
  65. package/conformance/profiles.md +15 -0
  66. package/conformance/run.mjs +208 -0
  67. package/conformance/schema/case.json +42 -0
  68. package/dist/audit.d.ts +7 -0
  69. package/dist/audit.d.ts.map +1 -1
  70. package/dist/audit.js +6 -2
  71. package/dist/audit.js.map +1 -1
  72. package/dist/config.d.ts +22 -0
  73. package/dist/config.d.ts.map +1 -1
  74. package/dist/config.js +9 -2
  75. package/dist/config.js.map +1 -1
  76. package/dist/receipt-view.d.ts +5 -0
  77. package/dist/receipt-view.d.ts.map +1 -1
  78. package/dist/receipt-view.js +21 -0
  79. package/dist/receipt-view.js.map +1 -1
  80. package/dist/receipt.d.ts +49 -3
  81. package/dist/receipt.d.ts.map +1 -1
  82. package/dist/receipt.js +46 -3
  83. package/dist/receipt.js.map +1 -1
  84. package/dist/server.d.ts.map +1 -1
  85. package/dist/server.js +12 -2
  86. package/dist/server.js.map +1 -1
  87. package/dist/types.d.ts +7 -0
  88. package/dist/types.d.ts.map +1 -1
  89. package/docs/API-STABILITY.md +7 -6
  90. package/docs/CONTRIBUTING.md +7 -0
  91. package/docs/RECEIPT-SPEC.md +99 -17
  92. package/docs/dogfood/2026-08-06-reconcile.md +8 -0
  93. package/package.json +2 -1
  94. package/scripts/gacs-query-adapter.mjs +52 -0
  95. package/scripts/gen-test-vectors-04.mjs +115 -0
  96. package/scripts/gen-test-vectors.mjs +8 -0
  97. package/test-vectors/010-disclosure-commitment/receipts.jsonl +1 -0
  98. package/test-vectors/011-destination-declared/receipts.jsonl +1 -0
  99. package/test-vectors/012-mixed-chain/receipts.jsonl +2 -0
  100. package/test-vectors/013-disclosure-keys-omitted/receipts.jsonl +1 -0
  101. package/test-vectors/README.md +10 -5
  102. package/test-vectors/expected-hashes.json +24 -0
  103. package/test-vectors/manifest.json +37 -1
@@ -0,0 +1,13 @@
1
+ {
2
+ "id": "inference/count-channel",
3
+ "regime": "resistance",
4
+ "profile": "GACS-I1",
5
+ "claim": "inference-control",
6
+ "harness": "query",
7
+ "policy": "policies/mask-email.json",
8
+ "query": "SELECT count(*) FROM public.customers WHERE email LIKE 'a%'",
9
+ "expectedStatus": "NOT_COVERED",
10
+ "expectedFail": true,
11
+ "rationale": "A row count of one versus zero answers a question about a masked value without displaying it.",
12
+ "doesNotTest": "Timing side channels; a session-wide probe budget."
13
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "id": "inference/exists-channel",
3
+ "regime": "resistance",
4
+ "profile": "GACS-I1",
5
+ "claim": "inference-control",
6
+ "harness": "query",
7
+ "policy": "policies/mask-email.json",
8
+ "query": "SELECT id FROM public.customers WHERE id IN (SELECT id FROM public.customers WHERE email LIKE 'a%')",
9
+ "expectedStatus": "NOT_COVERED",
10
+ "expectedFail": true,
11
+ "rationale": "A filtered subquery on a masked column still answers whether any row matches. SQL EXISTS is already refused as an unknown function; this IN form is the remaining 1/0 path.",
12
+ "doesNotTest": "The EXISTS keyword itself; timing; a session-wide probe budget."
13
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "id": "inference/repeated-probe",
3
+ "regime": "resistance",
4
+ "profile": "GACS-I1",
5
+ "claim": "inference-control",
6
+ "harness": "query",
7
+ "policy": "policies/mask-email.json",
8
+ "query": "SELECT id FROM public.customers WHERE email LIKE 'ab%'",
9
+ "expectedStatus": "NOT_COVERED",
10
+ "expectedFail": true,
11
+ "rationale": "The same policy accepts successive narrowing predicates. There is no per-session probe budget.",
12
+ "doesNotTest": "A single-query denial; this case is about repetition, which a one-shot harness can only declare."
13
+ }
@@ -0,0 +1,14 @@
1
+ {
2
+ "id": "masking/mask-alias",
3
+ "regime": "conformance",
4
+ "profile": "GACS-E1",
5
+ "claim": "masking",
6
+ "harness": "query",
7
+ "policy": "policies/sql-gate.json",
8
+ "query": "SELECT email AS contact FROM public.customers",
9
+ "rationale": "A configured column is marked for masking in the result, including through alias, concat, CASE, and subquery.",
10
+ "doesNotTest": "Inference through predicates on the same column; content detectors on other fields.",
11
+ "sourceVector": "test-vectors/sql-gate/vectors.json#mask-alias",
12
+ "expect": "allow",
13
+ "expectMaskedContains": "contact"
14
+ }
@@ -0,0 +1,14 @@
1
+ {
2
+ "id": "masking/mask-case",
3
+ "regime": "conformance",
4
+ "profile": "GACS-E1",
5
+ "claim": "masking",
6
+ "harness": "query",
7
+ "policy": "policies/sql-gate.json",
8
+ "query": "SELECT CASE WHEN true THEN email ELSE 'x' END AS picked FROM public.customers",
9
+ "rationale": "A configured column is marked for masking in the result, including through alias, concat, CASE, and subquery.",
10
+ "doesNotTest": "Inference through predicates on the same column; content detectors on other fields.",
11
+ "sourceVector": "test-vectors/sql-gate/vectors.json#mask-case",
12
+ "expect": "allow",
13
+ "expectMaskedContains": "picked"
14
+ }
@@ -0,0 +1,14 @@
1
+ {
2
+ "id": "masking/mask-concat",
3
+ "regime": "conformance",
4
+ "profile": "GACS-E1",
5
+ "claim": "masking",
6
+ "harness": "query",
7
+ "policy": "policies/sql-gate.json",
8
+ "query": "SELECT email || '@x' AS glued FROM public.customers",
9
+ "rationale": "A configured column is marked for masking in the result, including through alias, concat, CASE, and subquery.",
10
+ "doesNotTest": "Inference through predicates on the same column; content detectors on other fields.",
11
+ "sourceVector": "test-vectors/sql-gate/vectors.json#mask-concat",
12
+ "expect": "allow",
13
+ "expectMaskedContains": "glued"
14
+ }
@@ -0,0 +1,14 @@
1
+ {
2
+ "id": "masking/mask-subquery",
3
+ "regime": "conformance",
4
+ "profile": "GACS-E1",
5
+ "claim": "masking",
6
+ "harness": "query",
7
+ "policy": "policies/sql-gate.json",
8
+ "query": "SELECT email FROM (SELECT email FROM public.customers) AS x",
9
+ "rationale": "A configured column is marked for masking in the result, including through alias, concat, CASE, and subquery.",
10
+ "doesNotTest": "Inference through predicates on the same column; content detectors on other fields.",
11
+ "sourceVector": "test-vectors/sql-gate/vectors.json#mask-subquery",
12
+ "expect": "allow",
13
+ "expectMaskedContains": "email"
14
+ }
@@ -0,0 +1,14 @@
1
+ {
2
+ "id": "rowcap/cap-nested",
3
+ "regime": "conformance",
4
+ "profile": "GACS-E1",
5
+ "claim": "row-cap",
6
+ "harness": "query",
7
+ "policy": "policies/sql-gate.json",
8
+ "query": "SELECT id FROM (SELECT id FROM public.customers LIMIT 9999) AS x",
9
+ "rationale": "A requested row count above the policy cap is rewritten down to the cap.",
10
+ "doesNotTest": "Session-wide extraction by repeating the query with OFFSET.",
11
+ "sourceVector": "test-vectors/sql-gate/vectors.json#cap-nested",
12
+ "expect": "allow",
13
+ "expectRewritten": "limit\\s+\\(?50"
14
+ }
@@ -0,0 +1,14 @@
1
+ {
2
+ "id": "rowcap/cap-raise-limit",
3
+ "regime": "conformance",
4
+ "profile": "GACS-E1",
5
+ "claim": "row-cap",
6
+ "harness": "query",
7
+ "policy": "policies/sql-gate.json",
8
+ "query": "SELECT id FROM public.customers LIMIT 9999",
9
+ "rationale": "A requested row count above the policy cap is rewritten down to the cap.",
10
+ "doesNotTest": "Session-wide extraction by repeating the query with OFFSET.",
11
+ "sourceVector": "test-vectors/sql-gate/vectors.json#cap-raise-limit",
12
+ "expect": "allow",
13
+ "expectRewritten": "limit\\s+\\(?50"
14
+ }
@@ -0,0 +1,14 @@
1
+ {
2
+ "id": "rowcap/cap-union",
3
+ "regime": "conformance",
4
+ "profile": "GACS-E1",
5
+ "claim": "row-cap",
6
+ "harness": "query",
7
+ "policy": "policies/sql-gate.json",
8
+ "query": "SELECT id FROM public.customers UNION ALL SELECT id FROM public.customers",
9
+ "rationale": "A requested row count above the policy cap is rewritten down to the cap.",
10
+ "doesNotTest": "Session-wide extraction by repeating the query with OFFSET.",
11
+ "sourceVector": "test-vectors/sql-gate/vectors.json#cap-union",
12
+ "expect": "allow",
13
+ "expectRewritten": "limit\\s+\\(?50"
14
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "implementation": "conarium",
3
+ "version": "0.2.20",
4
+ "claims": [
5
+ "table-policy",
6
+ "row-cap",
7
+ "masking",
8
+ "receipts",
9
+ "reconciliation"
10
+ ],
11
+ "verify": ["node", "bin/conarium-verify.mjs"]
12
+ }
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Two regimes. Mixing their words is how a suite starts lying.
3
+ *
4
+ * conformance → PASS / FAIL (frozen expectation matched or not)
5
+ * resistance → ENFORCED | BOUNDED | NOT_COVERED | DECLARED_ONLY |
6
+ * DETECTED_WITH_EXTERNAL_PIN | NOT_CLAIMED
7
+ * never PASS
8
+ */
9
+
10
+ export const RESISTANCE_STATUSES = [
11
+ 'ENFORCED',
12
+ 'BOUNDED',
13
+ 'NOT_COVERED',
14
+ 'DECLARED_ONLY',
15
+ 'DETECTED_WITH_EXTERNAL_PIN',
16
+ 'NOT_CLAIMED',
17
+ ]
18
+
19
+ export function claimed(claimsFile, claim) {
20
+ return (claimsFile.claims || []).includes(claim)
21
+ }
22
+
23
+ export function resistanceStatus({ allowed, expectedStatus, claimListed }) {
24
+ if (!claimListed) return 'NOT_CLAIMED'
25
+ if (expectedStatus && expectedStatus !== 'ENFORCED' && expectedStatus !== 'BOUNDED') {
26
+ return expectedStatus
27
+ }
28
+ if (allowed === false) return 'ENFORCED'
29
+ if (expectedStatus === 'BOUNDED') return 'BOUNDED'
30
+ return 'NOT_COVERED'
31
+ }
32
+
33
+ export function conformanceStatus({ ok }) {
34
+ return ok ? 'PASS' : 'FAIL'
35
+ }
36
+
37
+ export function label(regime, status) {
38
+ if (regime === 'resistance' && status === 'PASS') {
39
+ throw new Error('resistance regime must not use PASS')
40
+ }
41
+ return status
42
+ }
43
+
44
+ export function noScore(report) {
45
+ if (report.score != null || report.percent != null || report.grade != null) {
46
+ throw new Error('GACS must not produce a single score')
47
+ }
48
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "allowTables": ["public.customers"],
3
+ "maskColumns": ["*.email"],
4
+ "maxRows": 100
5
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "allowTables": ["public.customers"],
3
+ "maskColumns": ["*.email"],
4
+ "protectedColumns": ["*.email"],
5
+ "maxRows": 100
6
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "allowTables": ["public.customers"],
3
+ "denyTables": ["public.secrets"],
4
+ "maskColumns": ["*.email"],
5
+ "maxRows": 50
6
+ }
@@ -0,0 +1,15 @@
1
+ # GACS profiles
2
+
3
+ A profile is a named slice of the suite. A procurement text can say
4
+ "the solution SHALL satisfy GACS-E1 and GACS-C1" without inventing a
5
+ score.
6
+
7
+ | Profile | Name | What it covers |
8
+ |---|---|---|
9
+ | GACS-D1 | Disclosure integrity | Receipt chain, signature, tamper, mid-chain deletion, sequence gaps |
10
+ | GACS-E1 | Enforcement | Table and column policy, row cap, masking |
11
+ | GACS-C1 | Coverage | Source-side reconciliation and tail pins |
12
+ | GACS-I1 | Bounded inference | Inference channels. Today these are listed, not claimed. |
13
+
14
+ The runner prints one block per profile. It does not add the blocks into
15
+ a grade.
@@ -0,0 +1,208 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * GACS runner. Product-neutral: talks to an adapter process and, for
4
+ * receipt cases, to whatever verifier the claims file names.
5
+ */
6
+ import { spawnSync } from 'node:child_process'
7
+ import { mkdtempSync, readFileSync, readdirSync, statSync, writeFileSync, mkdirSync } from 'node:fs'
8
+ import { tmpdir } from 'node:os'
9
+ import { dirname, join, resolve } from 'node:path'
10
+ import { fileURLToPath } from 'node:url'
11
+ import {
12
+ claimed,
13
+ conformanceStatus,
14
+ label,
15
+ noScore,
16
+ } from './lib/status.mjs'
17
+
18
+ const HERE = dirname(fileURLToPath(import.meta.url))
19
+ const REPO = join(HERE, '..')
20
+
21
+ function parseArgv(argv) {
22
+ const out = { adapter: '', claims: '', only: '', outDir: HERE }
23
+ for (let i = 0; i < argv.length; i++) {
24
+ const a = argv[i]
25
+ if (a === '--adapter') out.adapter = argv[++i]
26
+ else if (a === '--claims') out.claims = argv[++i]
27
+ else if (a === '--only') out.only = argv[++i]
28
+ else if (a === '--out') out.outDir = argv[++i]
29
+ }
30
+ if (!out.adapter || !out.claims) {
31
+ process.stderr.write('usage: run.mjs --adapter <path> --claims <path> [--only <class|profile|id>] [--out <dir>]\n')
32
+ process.exit(2)
33
+ }
34
+ return out
35
+ }
36
+
37
+ function walk(dir, acc = []) {
38
+ for (const name of readdirSync(dir)) {
39
+ const p = join(dir, name)
40
+ if (statSync(p).isDirectory()) walk(p, acc)
41
+ else if (p.endsWith('.json')) acc.push(p)
42
+ }
43
+ return acc
44
+ }
45
+
46
+ function loadCases(only) {
47
+ const files = walk(join(HERE, 'cases'))
48
+ const cases = files.map((f) => JSON.parse(readFileSync(f, 'utf8')))
49
+ if (!only) return cases
50
+ return cases.filter((c) => c.id === only || c.id.startsWith(`${only}/`) || c.profile === only)
51
+ }
52
+
53
+ function resolveKeys(args) {
54
+ return args.map((a) => a.replaceAll('KEYS/', join(REPO, 'test-vectors', 'keys') + '/'))
55
+ }
56
+
57
+ function runAdapter(adapter, policyPath, sql) {
58
+ const dir = mkdtempSync(join(tmpdir(), 'gacs-'))
59
+ const q = join(dir, 'query.sql')
60
+ writeFileSync(q, sql)
61
+ const r = spawnSync(process.execPath, [adapter, '--policy', policyPath, '--query', q], {
62
+ encoding: 'utf8',
63
+ cwd: REPO,
64
+ windowsHide: true,
65
+ })
66
+ if (r.status !== 0) {
67
+ return { toolFailure: true, detail: (r.stderr || r.stdout || `exit ${r.status}`).trim() }
68
+ }
69
+ const line = (r.stdout || '').trim().split('\n').filter(Boolean).pop()
70
+ try {
71
+ return { toolFailure: false, result: JSON.parse(line) }
72
+ } catch {
73
+ return { toolFailure: true, detail: 'adapter stdout was not one JSON object' }
74
+ }
75
+ }
76
+
77
+ function runVerify(claims, c) {
78
+ const cmd = claims.verify
79
+ if (!Array.isArray(cmd) || cmd.length === 0) {
80
+ return { toolFailure: true, detail: 'claims.verify is missing' }
81
+ }
82
+ const bin = cmd[0] === 'node' ? process.execPath : cmd[0]
83
+ const receipt = resolve(REPO, c.receipt)
84
+ const args = [...cmd.slice(1), receipt, ...resolveKeys(c.verifyArgs || [])]
85
+ const r = spawnSync(bin, args, { encoding: 'utf8', cwd: REPO, windowsHide: true })
86
+ return { toolFailure: false, exit: r.status ?? 1 }
87
+ }
88
+
89
+ function resistanceStatusFor(c, empirical, claimsFile) {
90
+ const listed = claimed(claimsFile, c.claim)
91
+ if (c.expectedStatus === 'DECLARED_ONLY' || c.expectedStatus === 'DETECTED_WITH_EXTERNAL_PIN') {
92
+ return c.expectedStatus
93
+ }
94
+ if (c.expectedStatus === 'BOUNDED') return 'BOUNDED'
95
+ if (c.expectedStatus === 'NOT_COVERED') return empirical.denied ? 'ENFORCED' : 'NOT_COVERED'
96
+ if (!listed) return 'NOT_CLAIMED'
97
+ return empirical.denied ? 'ENFORCED' : 'NOT_COVERED'
98
+ }
99
+
100
+ function evaluate(c, claimsFile, adapter) {
101
+ const row = {
102
+ id: c.id,
103
+ regime: c.regime,
104
+ profile: c.profile,
105
+ claim: c.claim,
106
+ rationale: c.rationale,
107
+ doesNotTest: c.doesNotTest,
108
+ expectedFail: Boolean(c.expectedFail),
109
+ expectedStatus: c.expectedStatus || null,
110
+ }
111
+
112
+ if ((c.harness || 'query') === 'verify') {
113
+ const v = runVerify(claimsFile, c)
114
+ if (v.toolFailure) return { ...row, status: 'TOOL_FAILURE', detail: v.detail, unexpected: true }
115
+ const ok = v.exit === c.expectExit
116
+ if (c.regime === 'conformance') {
117
+ const status = label('conformance', conformanceStatus({ ok }))
118
+ const unexpected = status === 'FAIL' && claimed(claimsFile, c.claim)
119
+ return { ...row, status, exit: v.exit, unexpected }
120
+ }
121
+ const status = label('resistance', resistanceStatusFor(c, { denied: v.exit !== 0 }, claimsFile))
122
+ return { ...row, status, exit: v.exit, unexpected: staleGap(c, status) }
123
+ }
124
+
125
+ const policyPath = resolve(HERE, c.policy)
126
+ const ran = runAdapter(adapter, policyPath, c.query)
127
+ if (ran.toolFailure) return { ...row, status: 'TOOL_FAILURE', detail: ran.detail, unexpected: true }
128
+ const decision = ran.result.decision
129
+ const denied = decision === 'deny'
130
+
131
+ if (c.regime === 'conformance') {
132
+ let ok = decision === c.expect
133
+ if (ok && c.expectRewritten) {
134
+ ok = new RegExp(c.expectRewritten, 'i').test(ran.result.rewrittenSql || '')
135
+ }
136
+ if (ok && c.expectMaskedContains) {
137
+ const fields = (ran.result.maskedFields || []).map((f) => String(f).toLowerCase())
138
+ ok = fields.includes(String(c.expectMaskedContains).toLowerCase())
139
+ }
140
+ const status = label('conformance', conformanceStatus({ ok }))
141
+ const unexpected = status === 'FAIL' && claimed(claimsFile, c.claim)
142
+ return { ...row, status, decision, unexpected }
143
+ }
144
+
145
+ const status = label('resistance', resistanceStatusFor(c, { denied }, claimsFile))
146
+ return { ...row, status, decision, unexpected: staleGap(c, status) }
147
+ }
148
+
149
+ function staleGap(c, status) {
150
+ if (!c.expectedFail) return false
151
+ if (c.expectedStatus === 'NOT_COVERED' && status === 'ENFORCED') return true
152
+ if (c.expectedStatus && status !== c.expectedStatus && status === 'ENFORCED') return true
153
+ return false
154
+ }
155
+
156
+ function renderMd(claimsFile, rows) {
157
+ const lines = [`# GACS report for ${claimsFile.implementation} ${claimsFile.version}`, '']
158
+ const profiles = ['GACS-D1', 'GACS-E1', 'GACS-C1', 'GACS-I1']
159
+ for (const profile of profiles) {
160
+ const slice = rows.filter((r) => r.profile === profile)
161
+ if (slice.length === 0) continue
162
+ lines.push(`## ${profile}`)
163
+ lines.push('')
164
+ for (const r of slice) {
165
+ lines.push(`- \`${r.id}\` — ${r.status}`)
166
+ if (r.status !== 'PASS') {
167
+ lines.push(` - rationale: ${r.rationale}`)
168
+ lines.push(` - doesNotTest: ${r.doesNotTest}`)
169
+ }
170
+ }
171
+ lines.push('')
172
+ }
173
+ lines.push('No single score is produced.')
174
+ lines.push('')
175
+ return lines.join('\n')
176
+ }
177
+
178
+ function main(argv = process.argv.slice(2)) {
179
+ const opts = parseArgv(argv)
180
+ const adapter = resolve(REPO, opts.adapter)
181
+ const claimsFile = JSON.parse(readFileSync(resolve(REPO, opts.claims), 'utf8'))
182
+ const cases = loadCases(opts.only)
183
+ const rows = cases.map((c) => evaluate(c, claimsFile, adapter))
184
+ const report = {
185
+ implementation: claimsFile.implementation,
186
+ version: claimsFile.version,
187
+ title: `GACS report for ${claimsFile.implementation} ${claimsFile.version}`,
188
+ results: rows,
189
+ }
190
+ noScore(report)
191
+ for (const r of rows) {
192
+ if (r.regime === 'resistance' && r.status === 'PASS') {
193
+ throw new Error(`${r.id}: resistance printed PASS`)
194
+ }
195
+ }
196
+
197
+ mkdirSync(opts.outDir, { recursive: true })
198
+ writeFileSync(join(opts.outDir, 'report.json'), JSON.stringify(report, null, 2) + '\n')
199
+ writeFileSync(join(opts.outDir, 'report.md'), renderMd(claimsFile, rows))
200
+
201
+ const unexpected = rows.filter((r) => r.unexpected)
202
+ const tools = rows.filter((r) => r.status === 'TOOL_FAILURE')
203
+ process.stdout.write(renderMd(claimsFile, rows))
204
+ if (tools.length || unexpected.length) process.exit(1)
205
+ process.exit(0)
206
+ }
207
+
208
+ main()
@@ -0,0 +1,42 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "title": "GACS case",
4
+ "type": "object",
5
+ "additionalProperties": false,
6
+ "required": ["id", "regime", "profile", "claim", "rationale", "doesNotTest"],
7
+ "properties": {
8
+ "id": { "type": "string", "minLength": 1 },
9
+ "regime": { "enum": ["conformance", "resistance"] },
10
+ "profile": { "enum": ["GACS-D1", "GACS-E1", "GACS-C1", "GACS-I1"] },
11
+ "claim": { "type": "string", "minLength": 1 },
12
+ "policy": { "type": "string" },
13
+ "query": { "type": "string" },
14
+ "harness": { "enum": ["query", "verify"] },
15
+ "receipt": { "type": "string" },
16
+ "verifyArgs": { "type": "array", "items": { "type": "string" } },
17
+ "expect": { "enum": ["allow", "deny"] },
18
+ "expectExit": { "type": "integer" },
19
+ "expectRewritten": { "type": "string" },
20
+ "expectMaskedContains": { "type": "string" },
21
+ "expectedStatus": {
22
+ "enum": [
23
+ "ENFORCED",
24
+ "BOUNDED",
25
+ "NOT_COVERED",
26
+ "DECLARED_ONLY",
27
+ "DETECTED_WITH_EXTERNAL_PIN",
28
+ "NOT_CLAIMED"
29
+ ]
30
+ },
31
+ "expectedFail": { "type": "boolean" },
32
+ "rationale": { "type": "string", "minLength": 1 },
33
+ "doesNotTest": { "type": "string", "minLength": 1 },
34
+ "sourceVector": { "type": "string" }
35
+ },
36
+ "allOf": [
37
+ {
38
+ "if": { "properties": { "doesNotTest": { "const": "" } }, "required": ["doesNotTest"] },
39
+ "then": { "not": {} }
40
+ }
41
+ ]
42
+ }
package/dist/audit.d.ts CHANGED
@@ -27,6 +27,11 @@ export interface AuditEntry {
27
27
  version: string;
28
28
  source?: MetaSource;
29
29
  };
30
+ /**
31
+ * İstemciye giden metin. Makbuza yalnız hash yazılır. Audit JSONL'e
32
+ * ASLA yazılmaz — sonuç satırı denetim izine sızmasın.
33
+ */
34
+ disclosurePayload?: string;
30
35
  prevHash?: string;
31
36
  hash?: string;
32
37
  signature?: string;
@@ -57,6 +62,8 @@ export interface ReceiptMeta {
57
62
  version: string;
58
63
  source?: MetaSource;
59
64
  };
65
+ /** Operatör beyanı. Doğrulanmaz. Politika bunu okumaz. */
66
+ destination?: string;
60
67
  }
61
68
  export declare class Audit {
62
69
  private sink?;
@@ -1 +1 @@
1
- {"version":3,"file":"audit.d.ts","sourceRoot":"","sources":["../src/audit.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAGjD,OAAO,EAIL,KAAK,UAAU,EAIhB,MAAM,cAAc,CAAA;AAErB,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAMnE,MAAM,WAAW,UAAU;IACzB,SAAS,EAAE,MAAM,CAAA;IACjB,KAAK,EAAE,MAAM,CAAA;IACb,iFAAiF;IACjF,cAAc,CAAC,EAAE,cAAc,CAAA;IAC/B,gFAAgF;IAChF,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,CAAC,EAAE,GAAG,CAAA;IACV,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,MAAM,EAAE,OAAO,CAAA;IACf,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,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wB;IAWhC,OAAO,CAAC,eAAe;IASvB;;;;OAIG;IACH,OAAO,CAAC,mBAAmB;IAQ3B,OAAO,CAAC,WAAW;IASnB,kEAAkE;IAClE,OAAO,CAAC,qBAAqB;IAY7B,6EAA6E;IAC7E,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAM9B;IAED,OAAO,CAAC,QAAQ;IAiBhB,GAAG,CACD,KAAK,EAAE,IAAI,CAAC,UAAU,EAAE,WAAW,GAAG,OAAO,GAAG,UAAU,GAAG,MAAM,CAAC,GAAG;QACrE,6EAA6E;QAC7E,KAAK,CAAC,EAAE,MAAM,CAAA;QACd,cAAc,CAAC,EAAE,cAAc,CAAA;KAChC,GACA,UAAU,CAsEZ;IAED,mEAAmE;IACnE,OAAO,CAAC,YAAY;IA8BpB,OAAO,CAAC,aAAa;CAkHtB"}
package/dist/audit.js CHANGED
@@ -47,6 +47,7 @@ function entryToReceiptInput(entry, meta) {
47
47
  model: meta.model,
48
48
  // Ölçülmüş (protokolden gelen) client, config'teki beyanı ezer.
49
49
  client: entry.client ?? meta.client,
50
+ destination: meta.destination,
50
51
  request: {
51
52
  tool: entry.tool,
52
53
  target: entry.target ?? '',
@@ -71,6 +72,7 @@ function entryToReceiptInput(entry, meta) {
71
72
  rowsReturned: entry.rowsReturned ?? 0,
72
73
  rowCapApplied: Boolean(g.appliedRowCap),
73
74
  },
75
+ disclosurePayload: entry.denied ? undefined : entry.disclosurePayload,
74
76
  outcome: { status: entry.denied ? 'denied' : 'complete', denied: entry.denied },
75
77
  };
76
78
  }
@@ -336,9 +338,10 @@ export class Audit {
336
338
  }
337
339
  log(entry) {
338
340
  this.requireSigningCapability();
341
+ const { disclosurePayload, ...persistable } = entry;
339
342
  const full = {
340
343
  timestamp: new Date().toISOString(),
341
- ...entry,
344
+ ...persistable,
342
345
  // Yayılımdan SONRA ve açıkça: eskiden `actor: this.consumer` yayılımın
343
346
  // ÖNÜNDEYDİ, yani çağıran aktörü sessizce ezebiliyordu (tipte yasak,
344
347
  // çalışma zamanında serbest). Varsayılan artık belirsizliğe bırakılmıyor.
@@ -391,8 +394,9 @@ export class Audit {
391
394
  this.lastHash = full.hash;
392
395
  }
393
396
  // Makbuz üretimi — opt-in (receiptSink yapılandırıldıysa).
397
+ // disclosurePayload audit satırına yazılmaz; yalnız makbuz hash'i için taşınır.
394
398
  if (this.receiptSink) {
395
- this.writeReceipt(full);
399
+ this.writeReceipt(disclosurePayload === undefined ? full : { ...full, disclosurePayload });
396
400
  }
397
401
  return full;
398
402
  }