@sunaiva/gate 1.0.0 → 1.1.2
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/BUSINESS_LICENSE.md +70 -0
- package/CHANGELOG.md +254 -0
- package/LICENSE +0 -0
- package/README.md +451 -67
- package/README.md.bak-v1.0.0-stale-MIT +59 -0
- package/SUPPORT.md +75 -0
- package/TIER_DEFINITIONS.md +161 -0
- package/dist/config/defaults.d.ts +22 -1
- package/dist/config/defaults.d.ts.map +1 -1
- package/dist/config/defaults.js +56 -8
- package/dist/config/defaults.js.map +1 -1
- package/dist/config/loader.d.ts +0 -0
- package/dist/config/loader.d.ts.map +1 -1
- package/dist/config/loader.js +23 -5
- package/dist/config/loader.js.map +1 -1
- package/dist/engine/backend-client.d.ts +58 -0
- package/dist/engine/backend-client.d.ts.map +1 -0
- package/dist/engine/backend-client.js +287 -0
- package/dist/engine/backend-client.js.map +1 -0
- package/dist/engine/hmac-verifier.d.ts +52 -0
- package/dist/engine/hmac-verifier.d.ts.map +1 -0
- package/dist/engine/hmac-verifier.js +159 -0
- package/dist/engine/hmac-verifier.js.map +1 -0
- package/dist/engine/immutability.d.ts +59 -0
- package/dist/engine/immutability.d.ts.map +1 -0
- package/dist/engine/immutability.js +129 -0
- package/dist/engine/immutability.js.map +1 -0
- package/dist/engine/pattern-matcher.d.ts +13 -0
- package/dist/engine/pattern-matcher.d.ts.map +1 -1
- package/dist/engine/pattern-matcher.js +85 -17
- package/dist/engine/pattern-matcher.js.map +1 -1
- package/dist/engine/rule-engine.d.ts +62 -1
- package/dist/engine/rule-engine.d.ts.map +1 -1
- package/dist/engine/rule-engine.js +224 -12
- package/dist/engine/rule-engine.js.map +1 -1
- package/dist/engine/session-state.d.ts +0 -0
- package/dist/engine/session-state.d.ts.map +1 -1
- package/dist/engine/session-state.js +8 -2
- package/dist/engine/session-state.js.map +1 -1
- package/dist/engine/ship-confidence-gate.d.ts +232 -0
- package/dist/engine/ship-confidence-gate.d.ts.map +1 -0
- package/dist/engine/ship-confidence-gate.js +768 -0
- package/dist/engine/ship-confidence-gate.js.map +1 -0
- package/dist/index.d.ts +0 -0
- package/dist/index.js +293 -2
- package/dist/rules/categories.json +0 -0
- package/dist/rules/presets.json +0 -0
- package/dist/rules/rules.json +132 -64
- package/dist/tools/audit.d.ts +6 -0
- package/dist/tools/audit.d.ts.map +1 -1
- package/dist/tools/audit.js +43 -6
- package/dist/tools/audit.js.map +1 -1
- package/dist/tools/bypass.d.ts +0 -0
- package/dist/tools/bypass.d.ts.map +1 -1
- package/dist/tools/bypass.js +50 -6
- package/dist/tools/bypass.js.map +1 -1
- package/dist/tools/export-attestation.d.ts +45 -0
- package/dist/tools/export-attestation.d.ts.map +1 -0
- package/dist/tools/export-attestation.js +152 -0
- package/dist/tools/export-attestation.js.map +1 -0
- package/dist/tools/rules.d.ts +0 -0
- package/dist/tools/rules.d.ts.map +0 -0
- package/dist/tools/rules.js +0 -0
- package/dist/tools/rules.js.map +0 -0
- package/dist/tools/ship-confidence.d.ts +17 -0
- package/dist/tools/ship-confidence.d.ts.map +1 -0
- package/dist/tools/ship-confidence.js +42 -0
- package/dist/tools/ship-confidence.js.map +1 -0
- package/dist/tools/update.d.ts +0 -0
- package/dist/tools/update.d.ts.map +1 -1
- package/dist/tools/update.js +45 -9
- package/dist/tools/update.js.map +1 -1
- package/dist/tools/validate.d.ts +0 -0
- package/dist/tools/validate.d.ts.map +1 -1
- package/dist/tools/validate.js +56 -4
- package/dist/tools/validate.js.map +1 -1
- package/dist/types/backend.d.ts +69 -0
- package/dist/types/backend.d.ts.map +1 -0
- package/dist/types/backend.js +18 -0
- package/dist/types/backend.js.map +1 -0
- package/package.json +83 -65
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,67 +1,451 @@
|
|
|
1
|
-
# @sunaiva/gate
|
|
2
|
-
|
|
3
|
-
**Stop documenting rules your agents ignore. Start enforcing them.**
|
|
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
|
-
|
|
1
|
+
# @sunaiva/gate
|
|
2
|
+
|
|
3
|
+
**Stop documenting rules your agents ignore. Start enforcing them.**
|
|
4
|
+
|
|
5
|
+
`@sunaiva/gate` is an MCP server that intercepts AI agent actions before they
|
|
6
|
+
execute and blocks the ones that violate your rules. It runs locally, in
|
|
7
|
+
process, with zero external dependencies on the Free tier — the rules are baked
|
|
8
|
+
into the package and enforced by a deterministic engine.
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npx @sunaiva/gate
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
> **Status**: `1.1.0` "Foundation Release" — first publicly-supported release.
|
|
15
|
+
> Closes all 7 CRITICAL findings from the signed Ship-Confidence verdict on
|
|
16
|
+
> `1.0.1`. Full changelog: [`CHANGELOG.md`](./CHANGELOG.md). Roadmap that led
|
|
17
|
+
> here: [`ROADMAP_1_1_0.md`](./ROADMAP_1_1_0.md).
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## 60-second quickstart
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
# 1. Install (no signup, no API key, no DNS records)
|
|
25
|
+
npx @sunaiva/gate
|
|
26
|
+
|
|
27
|
+
# 2. Verify it loaded
|
|
28
|
+
npx @sunaiva/gate --smoke-test
|
|
29
|
+
# → ✓ Gate loaded — 100 rules
|
|
30
|
+
# → ✓ Constitutional rules — 32 (cannot be disabled, enforced locally)
|
|
31
|
+
# → ✓ Premium rules — 68 (require backend service)
|
|
32
|
+
# → Status: HEALTHY
|
|
33
|
+
# → Version: 1.1.0
|
|
34
|
+
|
|
35
|
+
# 3. Add to your MCP client (Claude Code, Cursor, Windsurf, Cline)
|
|
36
|
+
# settings — see "MCP configuration" below.
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
That is the entire onboarding. The 32 constitutional rules are active on first
|
|
40
|
+
boot; no other configuration is required.
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## What's free, forever
|
|
45
|
+
|
|
46
|
+
The 1.1.0 Free tier (BUSL-1.1) ships with everything below baked into the npm
|
|
47
|
+
package. No backend, no telemetry, no API key required.
|
|
48
|
+
|
|
49
|
+
- **32 constitutional rules enforced locally** across five categories —
|
|
50
|
+
financial-safety, data-protection, action-governance, security, and
|
|
51
|
+
communication-safety. Detection patterns ship intact inside the package at
|
|
52
|
+
`dist/rules/rules.json`.
|
|
53
|
+
- **Severity ladder**: `block` / `warn-then-block` / `warn`.
|
|
54
|
+
- **Approval-token workflow** — drop a JSON token at
|
|
55
|
+
`data/deploy_queue/APPROVAL_TOKENS/<artifact>.json` and the gate honours it
|
|
56
|
+
once, within a 1-hour TTL. This is the free-tier escape valve for one-shot
|
|
57
|
+
manual unblocks.
|
|
58
|
+
- **Local audit log** at `~/.sunaiva/audit/audit.jsonl` (lifetime, no rotation
|
|
59
|
+
cap). Every entry records `tier`, `audit_status`, `evidence`, and
|
|
60
|
+
`event_type` for queryable history.
|
|
61
|
+
- **Kill-switch** — `DISABLE_SUNAIVA_GATE=1` short-circuits every
|
|
62
|
+
`validate_action` to `allowed: true` with unconditional stderr disclosure.
|
|
63
|
+
- **Dry-run mode** — `SUNAIVA_GATE_DRY_RUN=1` evaluates rules normally and
|
|
64
|
+
records `would_have_blocked: [...]` without ever blocking.
|
|
65
|
+
- **Constitutional immutability** — the 32 rules cannot be disabled via
|
|
66
|
+
`update_rules` and cannot be bypassed via `log_bypass`, even if
|
|
67
|
+
`~/.sunaiva/gate-config.json` is hand-edited (the loader re-merges on every
|
|
68
|
+
read).
|
|
69
|
+
- **Fail-CLOSED by default** — uncaught exceptions exit 3, malformed input
|
|
70
|
+
exits 4. Both write a structured audit entry. Opt-in legacy fail-open via
|
|
71
|
+
`SUNAIVA_GATE_FAIL_OPEN_ON_ERROR=1`.
|
|
72
|
+
- **MCP integration** — Claude Code, Cursor, Copilot, Windsurf, Cline via the
|
|
73
|
+
standard `mcpServers` config.
|
|
74
|
+
|
|
75
|
+
The Free tier is BUSL-1.1 licensed and converts to **Apache-2.0** on
|
|
76
|
+
**2030-05-10**. You can fork it, modify it, embed it in internal CI, and ship
|
|
77
|
+
it in non-production workflows today — no contract, no signup, no credit card.
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
## What you get with Pro (recommended, BYOK)
|
|
82
|
+
|
|
83
|
+
Pro adds the things a deterministic local engine cannot do on its own. Full
|
|
84
|
+
tier matrix in [`TIER_DEFINITIONS.md`](./TIER_DEFINITIONS.md). Current pricing
|
|
85
|
+
at **https://sunaivacore.io/pricing** (canonical source of truth across all
|
|
86
|
+
Sunaiva Core products).
|
|
87
|
+
|
|
88
|
+
- **68 additional premium rules** (100 total) evaluated server-side via the
|
|
89
|
+
premium backend at `https://mcp.sunaivacore.io/v1/gatehooks`. Detection
|
|
90
|
+
patterns are proprietary and stay in our infrastructure.
|
|
91
|
+
- **Signed Ship-Confidence verdicts** — HMAC-SHA256, 60-minute freshness
|
|
92
|
+
window. The `ship_confidence_check` MCP tool verifies the signature in
|
|
93
|
+
constant time and returns `allowed: true` only when the verdict is
|
|
94
|
+
`GREEN`, fresh, and untampered.
|
|
95
|
+
- **`sunaiva-ship-confidence` skill integration** — three independent
|
|
96
|
+
verification layers (cross-provider spec verification, property-based
|
|
97
|
+
testing with Hypothesis, adversarial audit via garak + DeepTeam) that
|
|
98
|
+
emit signed verdicts the Gate honours automatically in CI.
|
|
99
|
+
- **Dashboard** — rules tab, audit tab, settings tab, billing tab. Cloud
|
|
100
|
+
audit sync with 90-day retention.
|
|
101
|
+
- **BYOK** — bring your own `ANTHROPIC_API_KEY` and `OPENROUTER_API_KEY`.
|
|
102
|
+
You pay your own inference bill. We never see your tokens.
|
|
103
|
+
- **Email support** — `support@sunaiva.ai`, 2-business-day SLA
|
|
104
|
+
target.
|
|
105
|
+
- **Stripe-managed billing** with the founders coupon `KINANFOUNDER2026`
|
|
106
|
+
(100% off, first 10 redemptions, per Rule 30).
|
|
107
|
+
|
|
108
|
+
Enterprise (SSO, on-prem, multi-tenant org dashboard, named CSM) is
|
|
109
|
+
quote-to-cash — see the [Enterprise tier in `TIER_DEFINITIONS.md`](./TIER_DEFINITIONS.md#enterprise--contact-sales).
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
## Architecture
|
|
114
|
+
|
|
115
|
+
```
|
|
116
|
+
┌────────────────────────────────────────────────────────────────┐
|
|
117
|
+
│ Your project (Claude Code / Cursor / Windsurf / Cline) │
|
|
118
|
+
│ │
|
|
119
|
+
│ ┌──────────────────────────────────────────────────────┐ │
|
|
120
|
+
│ │ MCP client invokes a tool │ │
|
|
121
|
+
│ │ e.g. Bash("git push origin main") │ │
|
|
122
|
+
│ └────────────────────────┬─────────────────────────────┘ │
|
|
123
|
+
└────────────────────────────┼───────────────────────────────────┘
|
|
124
|
+
▼
|
|
125
|
+
┌────────────────────────────────────────────────────────────────┐
|
|
126
|
+
│ @sunaiva/gate (MCP server, stdio transport) │
|
|
127
|
+
│ │
|
|
128
|
+
│ ┌──────────────────────────────────────────────────────┐ │
|
|
129
|
+
│ │ validate_action │ │
|
|
130
|
+
│ │ │ │ │
|
|
131
|
+
│ │ ├─► Constitutional rules (32) — pattern matched │ │
|
|
132
|
+
│ │ │ LOCALLY against dist/rules/rules.json │ │
|
|
133
|
+
│ │ │ ─────────────────────────────► block/warn │ │
|
|
134
|
+
│ │ │ │ │
|
|
135
|
+
│ │ └─► Premium rules (68) — only if backend set │ │
|
|
136
|
+
│ │ POST https://mcp.sunaivacore.io/v1/gatehooks │ │
|
|
137
|
+
│ │ (JWT auth via SUNAIVA_GATE_API_TOKEN) │ │
|
|
138
|
+
│ │ ─────────────────────────────► block/warn │ │
|
|
139
|
+
│ │ (fail-OPEN per-rule on backend error) │ │
|
|
140
|
+
│ └──────────────────────────────────────────────────────┘ │
|
|
141
|
+
│ │
|
|
142
|
+
│ audit log ─► ~/.sunaiva/audit/audit.jsonl │
|
|
143
|
+
└────────────────────────────────────────────────────────────────┘
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
The Free tier path (constitutional rules) has zero network dependencies. The
|
|
147
|
+
Pro path is opt-in — set `SUNAIVA_GATE_BACKEND_URL` and the engine starts
|
|
148
|
+
POSTing actions to the backend for the premium-rule subset; without it, those
|
|
149
|
+
rules are skipped (recorded as `skipped_premium` in the audit, surfaced once
|
|
150
|
+
per session as a stderr notice).
|
|
151
|
+
|
|
152
|
+
---
|
|
153
|
+
|
|
154
|
+
## MCP configuration
|
|
155
|
+
|
|
156
|
+
Add to your client's MCP settings:
|
|
157
|
+
|
|
158
|
+
```json
|
|
159
|
+
{
|
|
160
|
+
"mcpServers": {
|
|
161
|
+
"sunaiva-gate": {
|
|
162
|
+
"command": "npx",
|
|
163
|
+
"args": ["@sunaiva/gate"]
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
Restart your MCP client. The first tool call will trigger the gate.
|
|
170
|
+
|
|
171
|
+
---
|
|
172
|
+
|
|
173
|
+
## MCP tool reference
|
|
174
|
+
|
|
175
|
+
| Tool | What it does |
|
|
176
|
+
|------|--------------|
|
|
177
|
+
| `validate_action` | Check a proposed action against all active rules. Returns `{allowed, violations[], warnings[], skipped_premium[], dry_run?, would_have_blocked?, stamp}`. The workhorse — every PreToolUse hook calls this. |
|
|
178
|
+
| `log_bypass` | Record an intentional rule bypass for the audit log. **Rejects constitutional rules** with a structured `CONSTITUTIONAL_RULE_CANNOT_BE_BYPASSED` error. |
|
|
179
|
+
| `get_rules` | List active rules; supports filtering by `category` or `preset`. |
|
|
180
|
+
| `update_rules` | Enable / disable rules. **Rejects disable attempts against constitutional rules** with a structured `CONSTITUTIONAL_RULE_IMMUTABLE` error. |
|
|
181
|
+
| `get_audit_log` | Return recent gate decisions from `~/.sunaiva/audit/audit.jsonl` with `tier`, `audit_status`, `evidence`, `event_type` fields. |
|
|
182
|
+
| `ship_confidence_check` | **Paid-tier production-deploy gate.** Accepts a signed verdict path or artifact ID; verifies HMAC-SHA256 against `SHIP_CONFIDENCE_SIGNING_KEY`; returns `{allowed, tier: "paid"\|"free", reason, evidence}`. Tagged in the audit ledger so you can measure the free-→paid upgrade funnel. |
|
|
183
|
+
|
|
184
|
+
Total: **6 MCP tools**. The `ship_confidence_check` tool is the ported
|
|
185
|
+
TypeScript implementation of `.claude/hooks/ship_confidence_gate.py` v1.2.0,
|
|
186
|
+
byte-compatible with the Python skill's canonical-JSON HMAC format.
|
|
187
|
+
|
|
188
|
+
---
|
|
189
|
+
|
|
190
|
+
## Environment variables
|
|
191
|
+
|
|
192
|
+
| Variable | Default | Purpose |
|
|
193
|
+
|----------|---------|---------|
|
|
194
|
+
| `DISABLE_SUNAIVA_GATE` | unset | Set to `1` to short-circuit every `validate_action` to `allowed: true`. Unconditionally logs to stderr. |
|
|
195
|
+
| `SUNAIVA_GATE_DRY_RUN` | unset | Set to `1` to evaluate rules normally but never block. Response includes `dry_run: true` and `would_have_blocked: [...]`. |
|
|
196
|
+
| `SUNAIVA_GATE_BACKEND_URL` | unset | Premium backend endpoint. Default for Pro customers: `https://mcp.sunaivacore.io/v1/gatehooks`. When unset, premium rules are skipped (recorded as `skipped_premium`). |
|
|
197
|
+
| `SUNAIVA_GATE_API_TOKEN` | unset | Bearer token (JWT) for the premium backend. Required when `SUNAIVA_GATE_BACKEND_URL` is set. |
|
|
198
|
+
| `SUNAIVA_GATE_BACKEND_TIMEOUT_MS` | `3000` | Backend request timeout. Backend errors fail-OPEN per-rule (logged as `skipped_premium_backend_error`). |
|
|
199
|
+
| `SUNAIVA_GATE_FAIL_OPEN_ON_ERROR` | unset | Set to `1` to restore the 1.0.x fail-open behaviour on uncaught exceptions and malformed input. Default is fail-CLOSED. |
|
|
200
|
+
| `SHIP_CONFIDENCE_SIGNING_KEY` | unset | HMAC-SHA256 key for verifying signed `sunaiva-ship-confidence` verdicts. Required by the `ship_confidence_check` tool. |
|
|
201
|
+
| `SUNAIVA_GATE_AUDIT_PATH` | `~/.sunaiva/audit/audit.jsonl` | Override the audit log path. |
|
|
202
|
+
|
|
203
|
+
---
|
|
204
|
+
|
|
205
|
+
## Exit codes
|
|
206
|
+
|
|
207
|
+
| Code | Meaning |
|
|
208
|
+
|------|---------|
|
|
209
|
+
| `0` | Allow / success / smoke-test HEALTHY |
|
|
210
|
+
| `1` | Generic test failure (legacy `--test` flag, smoke-test DEGRADED) |
|
|
211
|
+
| `2` | Block (Claude Code convention) |
|
|
212
|
+
| `3` | Fail-CLOSED internal error (uncaught exception). Opt-in fail-open via `SUNAIVA_GATE_FAIL_OPEN_ON_ERROR=1`. |
|
|
213
|
+
| `4` | Fail-CLOSED invalid input (malformed JSON, empty stdin). Same opt-in escape hatch. |
|
|
214
|
+
| `5` | Smoke-test DEGRADED with missing required files (e.g. `dist/rules/rules.json` absent). |
|
|
215
|
+
|
|
216
|
+
---
|
|
217
|
+
|
|
218
|
+
## Killing the gate (and why we tell you how)
|
|
219
|
+
|
|
220
|
+
`@sunaiva/gate` discloses its kill-switch in every block and warn message:
|
|
221
|
+
|
|
222
|
+
```
|
|
223
|
+
[sunaiva-gate v1.1.0] BLOCK — rule: dat-001 (recursive root deletion)
|
|
224
|
+
Escape: export DISABLE_SUNAIVA_GATE=1
|
|
225
|
+
Audit: ~/.sunaiva/audit/audit.jsonl
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
The escape hint is a deliberate security-disclosure design. An enforcement
|
|
229
|
+
product that hides its own bypass is one that gets routed around in production
|
|
230
|
+
without anyone knowing. The kill-switch invocation is itself logged to the
|
|
231
|
+
audit ledger as `decision: 'bypass_kill_switch'`, so disabling the gate is
|
|
232
|
+
visible to anyone who reads the audit.
|
|
233
|
+
|
|
234
|
+
```bash
|
|
235
|
+
export DISABLE_SUNAIVA_GATE=1 # All actions allowed (logged)
|
|
236
|
+
unset DISABLE_SUNAIVA_GATE # Back to normal enforcement
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
Use dry-run instead of the kill-switch when you want to *measure* what the
|
|
240
|
+
gate would block without actually blocking anything:
|
|
241
|
+
|
|
242
|
+
```bash
|
|
243
|
+
export SUNAIVA_GATE_DRY_RUN=1
|
|
244
|
+
# → response.dry_run: true
|
|
245
|
+
# → response.would_have_blocked: [{rule_id, name, severity}, ...]
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
---
|
|
249
|
+
|
|
250
|
+
## Decision model — warn-then-block escalation
|
|
251
|
+
|
|
252
|
+
Constitutional rules block on the first match. Standard rules (the
|
|
253
|
+
non-constitutional subset) implement a session-state escalation:
|
|
254
|
+
|
|
255
|
+
- **First match in a session** → `warn` (action allowed, message printed).
|
|
256
|
+
- **Subsequent matches in the same session** → `block`.
|
|
257
|
+
|
|
258
|
+
This avoids one-time false-positive noise while still catching repeated
|
|
259
|
+
violations. The session counter is reset when the MCP server process restarts.
|
|
260
|
+
Confidence is derived from keyword-count thresholds: `≥3` keywords matched →
|
|
261
|
+
`high`, `1-2` → `medium`, `0` → `low` (low confidence is filtered out before
|
|
262
|
+
the response).
|
|
263
|
+
|
|
264
|
+
---
|
|
265
|
+
|
|
266
|
+
## Smoke test
|
|
267
|
+
|
|
268
|
+
```bash
|
|
269
|
+
$ npx @sunaiva/gate --smoke-test
|
|
270
|
+
✓ Gate loaded — 100 rules
|
|
271
|
+
✓ Constitutional rules — 32 (cannot be disabled, enforced locally)
|
|
272
|
+
✓ Premium rules — 68 (require backend service)
|
|
273
|
+
✓ Presets file — 5 presets available
|
|
274
|
+
✓ Live eval (git push origin main) — HARD block via gov-001
|
|
275
|
+
✓ Live eval (ls -la) — ALLOW
|
|
276
|
+
✓ Live eval (rm -rf /) — HARD block via dat-001
|
|
277
|
+
✓ Live eval (stripe.charges.create) — HARD block via fin-001
|
|
278
|
+
✓ Immutability guard — ACTIVE (32 constitutional rules pinned)
|
|
279
|
+
✓ MCP server — ready (not started in smoke test)
|
|
280
|
+
Status: HEALTHY
|
|
281
|
+
Version: 1.1.1
|
|
282
|
+
Support: support@sunaiva.ai
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
Exit codes: `0` = HEALTHY, `1` = DEGRADED, `5` = missing required files.
|
|
286
|
+
|
|
287
|
+
---
|
|
288
|
+
|
|
289
|
+
## Presets
|
|
290
|
+
|
|
291
|
+
`get_rules` accepts a `preset` argument that filters the active set:
|
|
292
|
+
|
|
293
|
+
| Preset | Rules | Use case |
|
|
294
|
+
|--------|-------|----------|
|
|
295
|
+
| `minimal` | 5 | Absolute non-negotiables only |
|
|
296
|
+
| `essential` | 15 | Recommended starting point |
|
|
297
|
+
| `developer-safety` | 25 | AI coding agents (Cursor / Windsurf / Cline / Aider) |
|
|
298
|
+
| `financial-protection` | 24 | All financial + resource rules |
|
|
299
|
+
| `full-suite` | 100 | Everything — Free constitutional set + Pro premium set |
|
|
300
|
+
|
|
301
|
+
Presets read from `dist/rules/presets.json`. Premium presets require
|
|
302
|
+
`SUNAIVA_GATE_BACKEND_URL` to be set; without it the premium rules are skipped
|
|
303
|
+
with a `skipped_premium` audit entry.
|
|
304
|
+
|
|
305
|
+
---
|
|
306
|
+
|
|
307
|
+
## Ship Confidence Gate (paid tier)
|
|
308
|
+
|
|
309
|
+
The `ship_confidence_check` MCP tool is the deploy-time gate for high-blast-
|
|
310
|
+
radius commands (`npm publish`, `wrangler deploy`, `gh repo create --public`,
|
|
311
|
+
`netlify deploy --prod`). It checks for authorization in two tiers:
|
|
312
|
+
|
|
313
|
+
### Paid path — signed verdict
|
|
314
|
+
1. The `sunaiva-ship-confidence` Python skill runs three verification layers
|
|
315
|
+
against your product (spec verification, property-based testing,
|
|
316
|
+
adversarial audit).
|
|
317
|
+
2. It emits a signed verdict at
|
|
318
|
+
`data/ship_confidence_verdicts/<artifact>.signed.json`.
|
|
319
|
+
3. The `ship_confidence_check` tool verifies:
|
|
320
|
+
- HMAC-SHA256 signature is valid (constant-time compare, byte-compatible
|
|
321
|
+
with the Python skill's canonical-JSON encoding).
|
|
322
|
+
- `level == "GREEN"` (YELLOW and RED hard-block).
|
|
323
|
+
- Signed within the last 60 minutes
|
|
324
|
+
(configurable via `VERDICT_MAX_AGE_MINUTES`).
|
|
325
|
+
4. On all-pass: returns `{allowed: true, tier: "paid", ...}` and writes an
|
|
326
|
+
audit entry tagged `tier: "paid"` with the verdict ID and evidence.
|
|
327
|
+
|
|
328
|
+
### Free fallback — approval token
|
|
329
|
+
If no signed verdict is found (or `SHIP_CONFIDENCE_SIGNING_KEY` is not set),
|
|
330
|
+
the tool falls back to a one-time approval token at
|
|
331
|
+
`data/deploy_queue/APPROVAL_TOKENS/<artifact>.json` written within the last
|
|
332
|
+
hour. Tagged `tier: "free"` in the audit ledger with an upgrade hint pointing
|
|
333
|
+
at the paid skill.
|
|
334
|
+
|
|
335
|
+
```bash
|
|
336
|
+
# CLI form for use in CI:
|
|
337
|
+
npx @sunaiva/gate --ship-confidence @sunaiva/gate@1.1.0
|
|
338
|
+
# Exit 0 = allow, 2 = block, 3 = internal error (fail-OPEN logged)
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
---
|
|
342
|
+
|
|
343
|
+
## Constitutional rules cannot be disabled or bypassed
|
|
344
|
+
|
|
345
|
+
This is the package's hard guarantee. The 32 constitutional rules are
|
|
346
|
+
re-merged into `active_rules` on every config load — even if
|
|
347
|
+
`~/.sunaiva/gate-config.json` is hand-edited to remove them — and:
|
|
348
|
+
|
|
349
|
+
- `update_rules({disable: ['fin-001']})` returns
|
|
350
|
+
`{error: "CONSTITUTIONAL_RULE_IMMUTABLE", rule_ids: [...]}`. No state
|
|
351
|
+
change.
|
|
352
|
+
- `log_bypass({rule_id: 'fin-001'})` returns
|
|
353
|
+
`{error: "CONSTITUTIONAL_RULE_CANNOT_BE_BYPASSED", rule_id: ...}`. Nothing
|
|
354
|
+
written to the bypass log.
|
|
355
|
+
|
|
356
|
+
The kill-switch (`DISABLE_SUNAIVA_GATE=1`) is the only way to disable
|
|
357
|
+
constitutional enforcement, and it is loud — stderr disclosure on every
|
|
358
|
+
block, audit-ledger entry on every short-circuit. There are no quiet
|
|
359
|
+
bypasses.
|
|
360
|
+
|
|
361
|
+
---
|
|
362
|
+
|
|
363
|
+
## Known limitations — what 1.1.0 does NOT have
|
|
364
|
+
|
|
365
|
+
We shipped `1.0.1` with seven CRITICAL gaps flagged by our own signed
|
|
366
|
+
Ship-Confidence verdict on our own commit (`01KRDBCEYF2CAB21G6Y3E9VVH5`, RED).
|
|
367
|
+
1.1.0 closes all seven. What is honestly **not** in 1.1.0 yet:
|
|
368
|
+
|
|
369
|
+
- **Sunaiva-Managed inference** — no flat-fee tier that includes LLM calls.
|
|
370
|
+
BYOK only in v1. Revisit at 50+ Pro customers.
|
|
371
|
+
- **UI verification layer** (Playwright walkthroughs / computer-use) —
|
|
372
|
+
designed in
|
|
373
|
+
`data/ship_confidence_skill_upgrade_2026_05_11.md`, not yet shipped.
|
|
374
|
+
Folded into Pro at no extra cost when it lands.
|
|
375
|
+
- **Multi-tenant dashboard / "Pro Team" tier** — Pro is single-seat in v1.
|
|
376
|
+
Team management is Enterprise. A self-serve "Pro Team" tier waits until
|
|
377
|
+
10+ customers ask for it.
|
|
378
|
+
- **On-prem / VPC deployment** — Enterprise-only roadmap item. Helm chart
|
|
379
|
+
and Terraform module designs exist; not yet packaged.
|
|
380
|
+
- **Per-call / metered pricing** — abandoned. Subscription wins.
|
|
381
|
+
- **On-chain attestation (ERC-8004)** — aspirational. Deferred to v2.x.
|
|
382
|
+
|
|
383
|
+
Full deferred-feature list: see `STRATEGIC_PRIORITIES.md` Phase 3
|
|
384
|
+
(in-repo, not shipped in the tarball — internal-facing roadmap).
|
|
385
|
+
|
|
386
|
+
---
|
|
387
|
+
|
|
388
|
+
## Cross-platform
|
|
389
|
+
|
|
390
|
+
- **Linux** — native.
|
|
391
|
+
- **WSL** — native.
|
|
392
|
+
- **macOS** — native.
|
|
393
|
+
- **Windows** — native Node, plus a Python shim for clients that invoke the
|
|
394
|
+
legacy `hooks/sunaiva_gate_hook.py` PreToolUse path.
|
|
395
|
+
|
|
396
|
+
---
|
|
397
|
+
|
|
398
|
+
## Privacy
|
|
399
|
+
|
|
400
|
+
Your data stays where you choose. The Free tier makes **zero** external network
|
|
401
|
+
calls — constitutional rules are evaluated locally against patterns shipped
|
|
402
|
+
inside the package. The Pro path is opt-in: when you set
|
|
403
|
+
`SUNAIVA_GATE_BACKEND_URL`, the engine POSTs only the proposed action text
|
|
404
|
+
and rule IDs to the backend; we never see your code, your secrets, or your
|
|
405
|
+
filesystem. BYOK means your `ANTHROPIC_API_KEY` and `OPENROUTER_API_KEY` go
|
|
406
|
+
direct from your machine to those providers — they do not transit Sunaiva.
|
|
407
|
+
|
|
408
|
+
---
|
|
409
|
+
|
|
410
|
+
## License
|
|
411
|
+
|
|
412
|
+
[BUSL-1.1](./BUSINESS_LICENSE.md) — free for evaluation, internal development,
|
|
413
|
+
hobby and academic use. Commercial license required if you embed the Gate in
|
|
414
|
+
the critical path of a third-party paying-customer product before the
|
|
415
|
+
**Change Date of 2030-05-10**, after which the wrapper converts to
|
|
416
|
+
**Apache-2.0** automatically. The premium backend stays proprietary regardless
|
|
417
|
+
of the Change Date.
|
|
418
|
+
|
|
419
|
+
- Licensor: Sunaiva Digital
|
|
420
|
+
- Change Date: **2030-05-10**
|
|
421
|
+
- Change License: **Apache License, Version 2.0**
|
|
422
|
+
|
|
423
|
+
---
|
|
424
|
+
|
|
425
|
+
## Support
|
|
426
|
+
|
|
427
|
+
| Need | Where |
|
|
428
|
+
|------|-------|
|
|
429
|
+
| Bug or crash | Email `support@sunaiva.ai` with `--smoke-test` output + `node --version` |
|
|
430
|
+
| Feature request | Email `support@sunaiva.ai` with subject `[feature-request]` |
|
|
431
|
+
| Security vulnerability | Email `support@sunaiva.ai` (do not file publicly) |
|
|
432
|
+
| Licensing | `support@sunaiva.ai` |
|
|
433
|
+
| Commercial / paid tier | `support@sunaiva.ai` |
|
|
434
|
+
| Product page | `https://sunaivacore.io/products/gate` |
|
|
435
|
+
|
|
436
|
+
When reporting bugs, include the output of `npx @sunaiva/gate --smoke-test`
|
|
437
|
+
and `node --version`.
|
|
438
|
+
|
|
439
|
+
---
|
|
440
|
+
|
|
441
|
+
## Contributing
|
|
442
|
+
|
|
443
|
+
Pull requests welcome. For substantial changes, please open an issue first to
|
|
444
|
+
discuss the proposal. Constitutional rule additions require a corresponding
|
|
445
|
+
test fixture in `tests/bundle.test.ts` and a passing dogfood Ship-Confidence
|
|
446
|
+
verdict on the change.
|
|
447
|
+
|
|
448
|
+
---
|
|
449
|
+
|
|
450
|
+
*Built by a team whose own hooks killed their development for nine hours.
|
|
451
|
+
We fixed it. Then we shipped the fix. Then we signed the proof.*
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# @sunaiva/gate
|
|
2
|
+
|
|
3
|
+
**Stop documenting rules your agents ignore. Start enforcing them.**
|
|
4
|
+
|
|
5
|
+
Sunaiva Gate is an MCP server that enforces validation rules on AI agent actions. 100 battle-tested rules across 9 categories. Constitutional rules that never bend. Audit trail for every decision.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npx @sunaiva/gate
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## MCP Configuration
|
|
14
|
+
|
|
15
|
+
Add to your Claude Code or Cursor MCP settings:
|
|
16
|
+
|
|
17
|
+
```json
|
|
18
|
+
{
|
|
19
|
+
"mcpServers": {
|
|
20
|
+
"sunaiva-gate": {
|
|
21
|
+
"command": "npx",
|
|
22
|
+
"args": ["@sunaiva/gate"]
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Tools
|
|
29
|
+
|
|
30
|
+
| Tool | Description |
|
|
31
|
+
|------|-------------|
|
|
32
|
+
| `validate_action` | Check if a proposed action passes all active rules |
|
|
33
|
+
| `log_bypass` | Record an intentional rule bypass (non-constitutional only) |
|
|
34
|
+
| `get_rules` | List active rules, filter by category or preset |
|
|
35
|
+
| `update_rules` | Enable/disable rules (constitutional rules cannot be disabled) |
|
|
36
|
+
| `get_audit_log` | View recent gate decisions |
|
|
37
|
+
|
|
38
|
+
## Presets
|
|
39
|
+
|
|
40
|
+
- **minimal** (5 rules) — absolute non-negotiables
|
|
41
|
+
- **essential** (15 rules) — recommended starting point
|
|
42
|
+
- **developer-safety** (25 rules) — for AI coding agents
|
|
43
|
+
- **financial-protection** (24 rules) — all financial + resource rules
|
|
44
|
+
- **full-suite** (100 rules) — everything
|
|
45
|
+
|
|
46
|
+
## Privacy
|
|
47
|
+
|
|
48
|
+
Your data stays where you choose:
|
|
49
|
+
- **Managed** — zero config, Gemini Flash included
|
|
50
|
+
- **BYOK** — bring your own API key (Gemini, Claude, OpenRouter)
|
|
51
|
+
- **Local** — Ollama/LM Studio, nothing leaves your machine
|
|
52
|
+
|
|
53
|
+
## License
|
|
54
|
+
|
|
55
|
+
MIT
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
Built by [Sunaiva AI](https://sunaiva.ai). Patent-protected validation infrastructure.
|
package/SUPPORT.md
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# Support — `@sunaiva/gate`
|
|
2
|
+
|
|
3
|
+
Email-based support model. No public issue tracker. (See "Why no GitHub issues?" below.)
|
|
4
|
+
|
|
5
|
+
## Who to email
|
|
6
|
+
|
|
7
|
+
| Need | Email | Subject prefix | Target response |
|
|
8
|
+
|---|---|---|---|
|
|
9
|
+
| Bug or crash | `support@sunaiva.ai` | `[bug]` | 2 business days (Sydney AEST) |
|
|
10
|
+
| Feature request | `support@sunaiva.ai` | `[feature-request]` | Reviewed within 7 days; routed to roadmap |
|
|
11
|
+
| Security vulnerability | `support@sunaiva.ai` | (no prefix) | Same day acknowledgement |
|
|
12
|
+
| Licensing question (BUSL-1.1, commercial use, etc.) | `support@sunaiva.ai` | `[licensing]` | 2 business days |
|
|
13
|
+
| Commercial / paid-tier inquiry (Starter / Pro / Power) | `support@sunaiva.ai` | `[sales]` | 1 business day |
|
|
14
|
+
| Account / billing | `support@sunaiva.ai` | `[billing]` | 1 business day |
|
|
15
|
+
| General feedback | `support@sunaiva.ai` | `[feedback]` | Reviewed weekly |
|
|
16
|
+
|
|
17
|
+
Times are best-effort, not SLAs. Paid tiers (per `TIER_DEFINITIONS.md`) include explicit SLAs.
|
|
18
|
+
|
|
19
|
+
## What to include in a bug report
|
|
20
|
+
|
|
21
|
+
A bug report without these will usually round-trip once for clarification:
|
|
22
|
+
|
|
23
|
+
1. **Version**: output of `npx @sunaiva/gate --version`
|
|
24
|
+
2. **Smoke-test result**: full output of `npx @sunaiva/gate --smoke-test`
|
|
25
|
+
3. **Node version**: `node --version`
|
|
26
|
+
4. **OS / shell**: e.g., `Windows 11 / PowerShell 7.4` or `macOS 14.5 / zsh 5.9` or `Ubuntu 22.04 / bash 5.1`
|
|
27
|
+
5. **What you expected**
|
|
28
|
+
6. **What happened instead**
|
|
29
|
+
7. **Minimal reproduction**: the smallest sequence of actions that reproduces the bug
|
|
30
|
+
8. **Audit log snippet** (optional): redacted excerpt of `~/.sunaiva/audit/audit.jsonl` around the problem time — please scrub any payload data you don't want to share
|
|
31
|
+
|
|
32
|
+
## What to include in a security report
|
|
33
|
+
|
|
34
|
+
Email `support@sunaiva.ai` with subject describing the issue at a high level (avoid putting the exploit details in the subject — these emails can sit in inboxes briefly).
|
|
35
|
+
|
|
36
|
+
In the body include:
|
|
37
|
+
|
|
38
|
+
1. **Severity estimate** (informational / low / medium / high / critical)
|
|
39
|
+
2. **Affected version(s)**
|
|
40
|
+
3. **Reproduction**: exact steps + payload (if applicable)
|
|
41
|
+
4. **Impact**: what the vulnerability enables (e.g., bypass of constitutional rule, audit-log tampering, denial-of-service)
|
|
42
|
+
5. **Suggested fix** (optional, very welcome)
|
|
43
|
+
|
|
44
|
+
We will acknowledge within one business day, share a disclosure timeline within five, and credit the reporter in the changelog of the fix release unless they request anonymity.
|
|
45
|
+
|
|
46
|
+
We do not currently run a paid bug bounty programme. We will publicly credit good-faith reporters in the changelog.
|
|
47
|
+
|
|
48
|
+
## Why no GitHub issues?
|
|
49
|
+
|
|
50
|
+
`@sunaiva/gate` is the public BUSL-1.1 wrapper of a proprietary backend (Sunaiva Gate's premium rule evaluation + ship-confidence verdict service + dashboard, all under `gate.sunaiva.dev` / `dashboard.sunaiva.dev`). The wrapper's source for v1.0.x is open per BUSL-1.1 (with the Change Date `2030-05-10` → Apache-2.0 sunset), but the canonical Sunaiva ship pathway (per the internal Rule 43.1 doctrine) does NOT use a public GitHub source repo. The backend stays private — there is no public source repo to file issues against. Email gives us the same triage path without that drift risk.
|
|
51
|
+
|
|
52
|
+
## What happens to your email
|
|
53
|
+
|
|
54
|
+
Inbound `support@sunaiva.ai` is monitored by the Sunaiva Gate operations team (currently AU-hours coverage; expanding as the user base grows). Routine bugs go into the internal tracker; security reports route to a separate triage queue. We will follow up by email — we don't auto-respond unless explicitly asked.
|
|
55
|
+
|
|
56
|
+
## Self-service before you email
|
|
57
|
+
|
|
58
|
+
Before opening a bug report, try these:
|
|
59
|
+
|
|
60
|
+
1. **Update** to the latest version: `npx clear-npx-cache && npx @sunaiva/gate@latest --version`
|
|
61
|
+
2. **Smoke-test**: `npx @sunaiva/gate --smoke-test` — should return `Status: HEALTHY`
|
|
62
|
+
3. **Kill-switch** (if the gate is interfering with your IDE): set `DISABLE_SUNAIVA_GATE=1` in your environment to short-circuit every validation to allow-all + log it.
|
|
63
|
+
4. **Dry-run** (if you suspect a rule false-positive): set `SUNAIVA_GATE_DRY_RUN=1` in your environment — the gate evaluates but never blocks, surfacing `would_have_blocked` notices instead.
|
|
64
|
+
5. **Read the audit log**: `~/.sunaiva/audit/audit.jsonl` contains every gate decision. Each entry has `event_type`, `rule_id`, `reason`, `tier`, `audit_status` — usually enough to diagnose without a back-and-forth.
|
|
65
|
+
|
|
66
|
+
If those don't resolve the issue, email us.
|
|
67
|
+
|
|
68
|
+
## Roadmap visibility
|
|
69
|
+
|
|
70
|
+
We don't publish a public roadmap. The CHANGELOG documents what shipped; future direction is shared with paid-tier customers via the dashboard's announcements panel and via direct email to the support address you have on file.
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
*Support for `@sunaiva/gate` — Sunaiva Digital.*
|
|
75
|
+
*Last updated: 2026-05-25 (v1.1.1).*
|