@eyeoverthink/sva-gate 1.0.0 → 2.0.0
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/README.md +143 -132
- package/bin/sva-gate.js +172 -153
- package/package.json +63 -63
- package/src/index.d.ts +111 -96
- package/src/index.js +47 -46
- package/src/mcp-server.js +268 -264
- package/src/receipt.js +412 -341
package/README.md
CHANGED
|
@@ -1,132 +1,143 @@
|
|
|
1
|
-
# `@eyeoverthink/sva-gate` (`v1.0.0`)
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
---
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
##
|
|
131
|
-
|
|
132
|
-
|
|
1
|
+
# `@eyeoverthink/sva-gate` (`v1.0.0`)
|
|
2
|
+
|
|
3
|
+
> **2.0.0 — breaking: verification now asks whose signature counts.** A receipt is `ok` only when it is intact
|
|
4
|
+
> **and** signed by a key you name in `expectedPublicKeys` (CLI: `--key <hex>`). Without it an intact receipt is
|
|
5
|
+
> `outcome: 'integrity_only'`, because anyone can mint an intact receipt with their own key. Small-order Ed25519
|
|
6
|
+
> keys (which verify any message with no private key) are refused. AER-1 v0.4 receipts carry no issuer signature and
|
|
7
|
+
> are reported as `integrity_only`; their deliverable is now checked against the outputs. The Merkle tree is now real
|
|
8
|
+
> RFC 6962 (raw digest bytes); receipts minted by 1.x still verify and report `merkleEncoding: 'legacy-hex-text'`.
|
|
9
|
+
> `allowUnpinned: true` (CLI `--allow-unpinned`) restores the 1.x behaviour for demos and migration.
|
|
10
|
+
|
|
11
|
+
[](https://github.com/eyeoverthink/sva-gate/actions/workflows/ci.yml)
|
|
12
|
+
[](LICENSE)
|
|
13
|
+
|
|
14
|
+
**Zero-dependency 3-layer verification SDK, CLI, and stdio MCP server for AI agents.**
|
|
15
|
+
|
|
16
|
+
Unifies the proven standards from [`eyeoverthink/sva-standard`](https://github.com/eyeoverthink/sva-standard) (`v1.7.0`, 106/106 tri-runtime conformance) and [`eyeoverthink/logic-chain-judge`](https://github.com/eyeoverthink/logic-chain-judge) (`v1.0.0`, 321 tests) into **one installable package** with **zero external runtime dependencies** (Node 22+ ESM with TypeScript `.d.ts` definitions + pure Python 3.10+ stdlib companion in `python/`).
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## 1. Drop Into Claude Code / Cursor / Codex / Any MCP Client (4 Lines)
|
|
21
|
+
|
|
22
|
+
```json
|
|
23
|
+
{
|
|
24
|
+
"mcpServers": {
|
|
25
|
+
"sva-gate": {
|
|
26
|
+
"command": "npx",
|
|
27
|
+
"args": ["-y", "@eyeoverthink/sva-gate", "mcp"]
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Gives any agent **6 deterministic verification tools** over stdio JSON-RPC 2.0:
|
|
34
|
+
|
|
35
|
+
| MCP Tool | Layer | What It Enforces |
|
|
36
|
+
| --- | --- | --- |
|
|
37
|
+
| `sva_seal_text` | Layer 2 (`EMA/1`) | Seals PII/secrets (emails, SSNs, API keys, phones) into typed placeholders + `StreamSealGuard` cross-token split-secret sealing + zero-width prompt-injection scan |
|
|
38
|
+
| `sva_mint_receipt` | Layer 1 (`SVA-ER/1`) | Mints an Ed25519-signed, RFC 6962 `0x00`/`0x01` Merkle-proven receipt + matching `OPEG/1` `S4_COMMIT` envelope |
|
|
39
|
+
| `sva_verify_receipt` | Layer 1 (`SVA-ER/1` + `AER-1`) | Verifies **`SVA-ER/1`** receipts AND **IETF `draft-zambo-aer1-26` (`AER-1` v0.4)** receipts offline |
|
|
40
|
+
| `sva_opeg_check` | Layer 2 (`OPEG/1`) | Fail-closed pre-commit gate: blocks `DIRECT_INFERENCE`, tampered `R_san` digests, and invalid receipts (`sva-er/1` or `aer-1`) |
|
|
41
|
+
| `sva_judge_audit` | Layer 3 (`SVA-JEV/1`) | Calibrated epistemic judge gates: Wilson 95% CI > 2/3, author self-vote exclusion, mandatory verbatim `>= 12`-char quotes, hidden planted-fake traps, and zero-LLM `new_terms` invention scanner |
|
|
42
|
+
| `sva_crystallize_skill` | Layer 1 (`VSC/1`) | Zero-LLM deterministic parameter binder induction with leave-one-out verification and novel-wording near-miss rejection |
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## 2. CLI Quick Start (10-Second Offline Self-Test)
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
# Run built-in 3-layer verification (receipts + OPEG tamper block + StreamSealGuard + SVA-JEV/1 + skill crystallizer)
|
|
50
|
+
npx @eyeoverthink/sva-gate self-test
|
|
51
|
+
|
|
52
|
+
# Seal secrets & scan for prompt injection
|
|
53
|
+
npx @eyeoverthink/sva-gate seal "Patient SSN 123-45-6789 key sk-ant-api03-abcdefghijklmnop1234567890"
|
|
54
|
+
|
|
55
|
+
# Demo cross-token split-secret streaming redaction
|
|
56
|
+
npx @eyeoverthink/sva-gate stream-demo
|
|
57
|
+
|
|
58
|
+
# Mint a signed SVA-ER/1 receipt + OPEG/1 envelope
|
|
59
|
+
npx @eyeoverthink/sva-gate mint '{"answer":42,"unit":"ms"}'
|
|
60
|
+
|
|
61
|
+
# Verify an SVA-ER/1 OR IETF AER-1 v0.4 receipt offline
|
|
62
|
+
npx @eyeoverthink/sva-gate verify receipt.json [deliverable.json]
|
|
63
|
+
|
|
64
|
+
# Evaluate an OPEG/1 gate or SVA-JEV/1 judge envelope fail-closed
|
|
65
|
+
npx @eyeoverthink/sva-gate gate opeg-envelope.json
|
|
66
|
+
npx @eyeoverthink/sva-gate judge jev-envelope.json
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## 3. JS / TypeScript SDK (`0` Dependencies)
|
|
72
|
+
|
|
73
|
+
```js
|
|
74
|
+
import {
|
|
75
|
+
mintSvaEr1,
|
|
76
|
+
verifyAnyReceipt,
|
|
77
|
+
evaluateOpeg1,
|
|
78
|
+
evaluateSvaJev1,
|
|
79
|
+
StreamSealGuard,
|
|
80
|
+
JEV_SEMANTICS,
|
|
81
|
+
} from '@eyeoverthink/sva-gate';
|
|
82
|
+
|
|
83
|
+
// 1. Mint & verify an SVA-ER/1 receipt + OPEG/1 S4_COMMIT envelope
|
|
84
|
+
const { receipt, deliverable, opegEnvelope, publicKeyHex } = mintSvaEr1({ rSan: { ok: true, value: 42 } });
|
|
85
|
+
// Name the key you trust. The verifier never trusts the key inside the receipt by itself.
|
|
86
|
+
const trust = { expectedPublicKeys: [publicKeyHex] };
|
|
87
|
+
console.log(verifyAnyReceipt(receipt, { deliverable, ...trust })); // { format: 'sva-er/1', ok: true, outcome: 'verified', trust: 'pinned', ... }
|
|
88
|
+
console.log(evaluateOpeg1(opegEnvelope, trust)); // { ok: true, gate: 'pass', ... }
|
|
89
|
+
console.log(verifyAnyReceipt(receipt, { deliverable })); // { ok: false, outcome: 'integrity_only', ... } — intact, signer not trusted
|
|
90
|
+
|
|
91
|
+
// 2. Seal split-token API keys across streaming chunks
|
|
92
|
+
const sg = new StreamSealGuard();
|
|
93
|
+
const safe = ['Key sk-', 'ant-api03-abcdefghijklmnop1234567890 ok'].map((c) => sg.push(c)).join('') + sg.flush();
|
|
94
|
+
|
|
95
|
+
// 3. Enforce SVA-JEV/1 epistemic judge gates
|
|
96
|
+
const verdict = evaluateSvaJev1({
|
|
97
|
+
spec: 'sva-jev/1',
|
|
98
|
+
semantics: JEV_SEMANTICS,
|
|
99
|
+
mode: 'claim_trace',
|
|
100
|
+
ledgerTexts: ['[stage 1] Enforce 80% quorum via verify_run.'],
|
|
101
|
+
briefText: 'Enforce 80% quorum with 9999 retries via invented_helper_v2.',
|
|
102
|
+
plantedFakes: [{ id: 'fake-1', verdict: 'unsupported' }],
|
|
103
|
+
});
|
|
104
|
+
// -> { ok: false, newTerms: ['9999', 'invented_helper_v2'], ... }
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
## 4. Pure Python 3.10+ Companion (`python/`)
|
|
110
|
+
|
|
111
|
+
Zero `pip` dependencies (standard library only):
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
pip install ./python
|
|
115
|
+
python -m unittest discover -s python/tests -v
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
```python
|
|
119
|
+
from sva_gate import JEV_SEMANTICS, evaluate_sva_jev1
|
|
120
|
+
res = evaluate_sva_jev1({
|
|
121
|
+
"spec": "sva-jev/1",
|
|
122
|
+
"semantics": JEV_SEMANTICS,
|
|
123
|
+
"mode": "calibration",
|
|
124
|
+
"answered": 36, "total": 36, "right": 33, "realFound": 12, "realTotal": 12,
|
|
125
|
+
})
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
## Honest Limits
|
|
131
|
+
|
|
132
|
+
- **Signatures prove post-signing integrity and key possession**, not that a compromised host didn't fabricate data prior to signing. Local unsynced clocks are explicitly labeled `unattested`.
|
|
133
|
+
- **`SVA-JEV/1` verdicts are stamped `stability-signal-not-correctness`** — multi-model consensus is never proof of truth.
|
|
134
|
+
- **Deterministic `new_terms` catches invented numbers and code identifiers**, not subtle semantic paraphrasing.
|
|
135
|
+
|
|
136
|
+
## Related Repositories & Live Offline Playgrounds
|
|
137
|
+
|
|
138
|
+
- **Open Standards & 5 Zero-Backend Browser Labs:** https://eyeoverthink.github.io/sva-standard/ (`eyeoverthink/sva-standard`)
|
|
139
|
+
- **Calibrated Epistemic Judge Pipeline:** https://github.com/eyeoverthink/logic-chain-judge
|
|
140
|
+
|
|
141
|
+
## License
|
|
142
|
+
|
|
143
|
+
Apache-2.0 — see [LICENSE](LICENSE).
|
package/bin/sva-gate.js
CHANGED
|
@@ -1,153 +1,172 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
// @eyeoverthink/sva-gate CLI — Zero-dependency 3-layer AI verification CLI & stdio MCP server.
|
|
3
|
-
|
|
4
|
-
import fs from 'node:fs';
|
|
5
|
-
import {
|
|
6
|
-
mintSvaEr1,
|
|
7
|
-
verifyAnyReceipt,
|
|
8
|
-
evaluateOpeg1,
|
|
9
|
-
evaluateSvaJev1,
|
|
10
|
-
detect,
|
|
11
|
-
SealSession,
|
|
12
|
-
StreamSealGuard,
|
|
13
|
-
scanInjection,
|
|
14
|
-
induce,
|
|
15
|
-
leaveOneOut,
|
|
16
|
-
applySpec,
|
|
17
|
-
novelWording,
|
|
18
|
-
startStdioMcpServer,
|
|
19
|
-
JEV_SEMANTICS,
|
|
20
|
-
} from '../src/index.js';
|
|
21
|
-
|
|
22
|
-
const USAGE = `sva-gate v1.0.0 — Zero-dependency 3-layer AI verification CLI & MCP server
|
|
23
|
-
|
|
24
|
-
Commands:
|
|
25
|
-
sva-gate mcp Start stdio JSON-RPC 2.0 MCP server (6 tools)
|
|
26
|
-
sva-gate seal <text> Seal PII/secrets & scan for prompt injection
|
|
27
|
-
sva-gate stream-demo Demonstrate StreamSealGuard cross-token sealing
|
|
28
|
-
sva-gate mint <json-file | inline-json> Mint SVA-ER/1 receipt + OPEG/1 S4_COMMIT envelope
|
|
29
|
-
sva-gate verify <receipt.json> [deliverable]
|
|
30
|
-
sva-gate gate <opeg-envelope.json>
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
if (
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
console.log(
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
};
|
|
124
|
-
const
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
const
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// @eyeoverthink/sva-gate CLI — Zero-dependency 3-layer AI verification CLI & stdio MCP server.
|
|
3
|
+
|
|
4
|
+
import fs from 'node:fs';
|
|
5
|
+
import {
|
|
6
|
+
mintSvaEr1,
|
|
7
|
+
verifyAnyReceipt,
|
|
8
|
+
evaluateOpeg1,
|
|
9
|
+
evaluateSvaJev1,
|
|
10
|
+
detect,
|
|
11
|
+
SealSession,
|
|
12
|
+
StreamSealGuard,
|
|
13
|
+
scanInjection,
|
|
14
|
+
induce,
|
|
15
|
+
leaveOneOut,
|
|
16
|
+
applySpec,
|
|
17
|
+
novelWording,
|
|
18
|
+
startStdioMcpServer,
|
|
19
|
+
JEV_SEMANTICS,
|
|
20
|
+
} from '../src/index.js';
|
|
21
|
+
|
|
22
|
+
const USAGE = `sva-gate v1.0.0 — Zero-dependency 3-layer AI verification CLI & MCP server
|
|
23
|
+
|
|
24
|
+
Commands:
|
|
25
|
+
sva-gate mcp Start stdio JSON-RPC 2.0 MCP server (6 tools)
|
|
26
|
+
sva-gate seal <text> Seal PII/secrets & scan for prompt injection
|
|
27
|
+
sva-gate stream-demo Demonstrate StreamSealGuard cross-token sealing
|
|
28
|
+
sva-gate mint <json-file | inline-json> Mint SVA-ER/1 receipt + OPEG/1 S4_COMMIT envelope
|
|
29
|
+
sva-gate verify <receipt.json> [deliverable] --key <hex> Verify SVA-ER/1 or IETF AER-1 v0.4 receipt offline
|
|
30
|
+
sva-gate gate <opeg-envelope.json> --key <hex> Evaluate OPEG/1 S4_COMMIT gate fail-closed
|
|
31
|
+
|
|
32
|
+
--key <hex> Ed25519 public key allowed to have signed (repeatable). Without it an intact
|
|
33
|
+
receipt is reported as integrity_only and the exit code is 1.
|
|
34
|
+
--allow-unpinned Accept any signer (1.x behaviour; demos and migration only).
|
|
35
|
+
sva-gate judge <jev-envelope.json> Evaluate SVA-JEV/1 epistemic judge gate
|
|
36
|
+
sva-gate self-test Run built-in 3-layer end-to-end verification check
|
|
37
|
+
`;
|
|
38
|
+
|
|
39
|
+
// --key <hex> (repeatable): the Ed25519 key(s) allowed to have signed. --allow-unpinned: accept any signer (1.x behaviour).
|
|
40
|
+
function trustFlags(argv) {
|
|
41
|
+
const args = [], keys = [];
|
|
42
|
+
let allowUnpinned = false;
|
|
43
|
+
for (let i = 0; i < argv.length; i++) {
|
|
44
|
+
if (argv[i] === '--key') keys.push(argv[++i]);
|
|
45
|
+
else if (argv[i] === '--allow-unpinned') allowUnpinned = true;
|
|
46
|
+
else args.push(argv[i]);
|
|
47
|
+
}
|
|
48
|
+
return { args, trust: { expectedPublicKeys: keys.length ? keys : null, allowUnpinned } };
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function readJsonArg(arg) {
|
|
52
|
+
if (!arg) throw new Error('Missing JSON argument or file path');
|
|
53
|
+
if (fs.existsSync(arg) && fs.statSync(arg).isFile()) {
|
|
54
|
+
return JSON.parse(fs.readFileSync(arg, 'utf8'));
|
|
55
|
+
}
|
|
56
|
+
return JSON.parse(arg);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const [cmd, ...rest] = process.argv.slice(2);
|
|
60
|
+
|
|
61
|
+
if (!cmd || cmd === '-h' || cmd === '--help') {
|
|
62
|
+
console.log(USAGE);
|
|
63
|
+
process.exit(0);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (cmd === 'mcp') {
|
|
67
|
+
startStdioMcpServer();
|
|
68
|
+
} else if (cmd === 'seal') {
|
|
69
|
+
const text = rest.join(' ');
|
|
70
|
+
const findings = detect(text);
|
|
71
|
+
const session = new SealSession();
|
|
72
|
+
const sealed = session.apply(text, findings);
|
|
73
|
+
console.log(JSON.stringify({ sealed, findingsCount: findings.length, audit: session.audit(sealed), injection: scanInjection(text) }, null, 2));
|
|
74
|
+
} else if (cmd === 'stream-demo') {
|
|
75
|
+
const chunks = ['Key sk-', 'ant-api03-abcdefghijklmnop1234567890 SSN 123-', '45-6789 mail elena@', 'northstar.org ok.'];
|
|
76
|
+
const sg = new StreamSealGuard();
|
|
77
|
+
const sealed = chunks.map((c) => sg.push(c)).join('') + sg.flush();
|
|
78
|
+
console.log(JSON.stringify({ chunks, sealed, audit: sg.session.audit(sealed) }, null, 2));
|
|
79
|
+
} else if (cmd === 'mint') {
|
|
80
|
+
const rSan = readJsonArg(rest[0]);
|
|
81
|
+
const res = mintSvaEr1({ rSan });
|
|
82
|
+
console.log(JSON.stringify(res, null, 2));
|
|
83
|
+
} else if (cmd === 'verify') {
|
|
84
|
+
const { args: pos, trust } = trustFlags(rest);
|
|
85
|
+
const receipt = readJsonArg(pos[0]);
|
|
86
|
+
let deliverable = null;
|
|
87
|
+
if (pos[1]) {
|
|
88
|
+
deliverable = fs.existsSync(pos[1]) ? fs.readFileSync(pos[1], 'utf8') : pos[1];
|
|
89
|
+
}
|
|
90
|
+
const res = verifyAnyReceipt(receipt, { deliverable, ...trust });
|
|
91
|
+
console.log(JSON.stringify(res, null, 2));
|
|
92
|
+
process.exit(res.ok ? 0 : 1);
|
|
93
|
+
} else if (cmd === 'gate') {
|
|
94
|
+
const { args: pos, trust } = trustFlags(rest);
|
|
95
|
+
const env = readJsonArg(pos[0]);
|
|
96
|
+
const res = evaluateOpeg1(env, trust);
|
|
97
|
+
console.log(JSON.stringify(res, null, 2));
|
|
98
|
+
process.exit(res.ok ? 0 : 1);
|
|
99
|
+
} else if (cmd === 'judge') {
|
|
100
|
+
const env = readJsonArg(rest[0]);
|
|
101
|
+
const res = evaluateSvaJev1(env);
|
|
102
|
+
console.log(JSON.stringify(res, null, 2));
|
|
103
|
+
process.exit(res.ok ? 0 : 1);
|
|
104
|
+
} else if (cmd === 'self-test') {
|
|
105
|
+
// 1. Layer 1 + 2: Mint SVA-ER/1 + OPEG/1, verify pass, verify tamper block
|
|
106
|
+
const minted = mintSvaEr1({ agencyName: 'sva-gate-selftest', missionId: 'ms_selftest', rSan: { answer: 42, unit: 'ms' } });
|
|
107
|
+
const pin = { expectedPublicKeys: [minted.publicKeyHex] };
|
|
108
|
+
const rOk = verifyAnyReceipt(minted.receipt, { deliverable: minted.deliverable, ...pin });
|
|
109
|
+
const gOk = evaluateOpeg1(minted.opegEnvelope, pin);
|
|
110
|
+
const badEnv = structuredClone(minted.opegEnvelope);
|
|
111
|
+
badEnv.sanitizer.rSan.answer = 999;
|
|
112
|
+
const gBad = evaluateOpeg1(badEnv, pin);
|
|
113
|
+
|
|
114
|
+
// 2. Layer 2: StreamSealGuard cross-token secret sealing
|
|
115
|
+
const sg = new StreamSealGuard();
|
|
116
|
+
const sOut = ['Token sk-', 'ant-api03-abcdefghijklmnop1234567890 done'].map((c) => sg.push(c)).join('') + sg.flush();
|
|
117
|
+
const sClean = sg.session.audit(sOut).clean && !sOut.includes('sk-ant-api03');
|
|
118
|
+
|
|
119
|
+
// 3. Layer 3: SVA-JEV/1 calibrated judge + planted fake + zero-LLM new_terms block
|
|
120
|
+
const jPass = evaluateSvaJev1({
|
|
121
|
+
spec: 'sva-jev/1', semantics: JEV_SEMANTICS, mode: 'calibration',
|
|
122
|
+
answered: 36, total: 36, right: 33, realFound: 12, realTotal: 12,
|
|
123
|
+
});
|
|
124
|
+
const jBlock = evaluateSvaJev1({
|
|
125
|
+
spec: 'sva-jev/1', semantics: JEV_SEMANTICS, mode: 'claim_trace',
|
|
126
|
+
ledgerTexts: ['[stage 1] Enforce 80% quorum via verify_run.'],
|
|
127
|
+
briefText: 'Enforce 80% quorum with 9999 retries via invented_helper_v2.',
|
|
128
|
+
plantedFakes: [{ id: 'fake-1', verdict: 'unsupported' }],
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
// 4. Skill Crystallizer zero-LLM binder check
|
|
132
|
+
const skill = {
|
|
133
|
+
name: 'sequential_discount',
|
|
134
|
+
params: {
|
|
135
|
+
type: 'object',
|
|
136
|
+
properties: {
|
|
137
|
+
price: { type: 'number', description: 'original price' },
|
|
138
|
+
d1: { type: 'number', description: 'first discount as decimal fraction' },
|
|
139
|
+
d2: { type: 'number', description: 'second discount as decimal fraction' },
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
};
|
|
143
|
+
const pos = [
|
|
144
|
+
{ task: 'A $100 jacket is 20% off, then an extra 10% off. What is the final price?', input: { price: 100, d1: 0.2, d2: 0.1 } },
|
|
145
|
+
{ task: 'A $80 pair of shoes is 15% off, then an extra 20% off. What is the final price?', input: { price: 80, d1: 0.15, d2: 0.2 } },
|
|
146
|
+
{ task: 'A $150 backpack is 30% off, then an extra 5% off. What is the final price?', input: { price: 150, d1: 0.3, d2: 0.05 } },
|
|
147
|
+
];
|
|
148
|
+
const neg = [{ task: 'A $200 desk is 20% off, then 8% sales tax is added. What is the final price?' }];
|
|
149
|
+
const { spec } = induce(pos, neg, skill);
|
|
150
|
+
const looRows = leaveOneOut(pos, neg, skill);
|
|
151
|
+
const loo = { passed: looRows.filter((r) => r.ok).length, total: looRows.length, ok: looRows.every((r) => r.ok) };
|
|
152
|
+
const bound = spec ? applySpec(spec, 'A $240 coat is 25% off, then an extra 10% off. What is the final price?') : null;
|
|
153
|
+
const trapNovel = novelWording(pos, 'A $200 shoe is 10% off, then 8% sales tax is added. What is the final price?');
|
|
154
|
+
const trapBlocked = !applySpec(spec, 'A $200 shoe is 10% off, then 8% sales tax is added. What is the final price?') || trapNovel.length > 0;
|
|
155
|
+
|
|
156
|
+
const ok = Boolean(
|
|
157
|
+
rOk.ok && gOk.ok && !gBad.ok && sClean && jPass.ok && !jBlock.ok && loo.ok && bound?.price === 240 && trapBlocked
|
|
158
|
+
);
|
|
159
|
+
console.log(JSON.stringify({
|
|
160
|
+
ok,
|
|
161
|
+
layers: {
|
|
162
|
+
receiptAndOpeg: { verified: rOk.ok, gatePass: gOk.ok, tamperBlocked: !gBad.ok },
|
|
163
|
+
streamPrivacyMembrane: { clean: sClean, sealedPreview: sOut },
|
|
164
|
+
epistemicJudge: { calibrationPass: jPass.ok, inventedTermsBlocked: !jBlock.ok, newTerms: jBlock.newTerms },
|
|
165
|
+
skillCrystallizer: { leaveOneOut: loo, boundPrice: bound?.price ?? null, taxTrapRejected: trapBlocked },
|
|
166
|
+
},
|
|
167
|
+
}, null, 2));
|
|
168
|
+
process.exit(ok ? 0 : 1);
|
|
169
|
+
} else {
|
|
170
|
+
console.error(`Unknown command: ${cmd}\n\n${USAGE}`);
|
|
171
|
+
process.exit(1);
|
|
172
|
+
}
|