@sunaiva/gate 1.1.2 → 1.1.4
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 +2 -2
- package/CHANGELOG.md +2 -2
- package/LICENSE +0 -0
- package/README.DRAFT.md +418 -0
- package/README.md +471 -451
- package/README.md.bak-v1.0.0-stale-MIT +0 -0
- package/SUPPORT.md +0 -0
- package/TIER_DEFINITIONS.md +0 -0
- package/dist/config/defaults.d.ts +30 -10
- package/dist/config/defaults.d.ts.map +1 -1
- package/dist/config/defaults.js +49 -26
- package/dist/config/defaults.js.map +1 -1
- package/dist/config/loader.d.ts +0 -0
- package/dist/config/loader.d.ts.map +0 -0
- package/dist/config/loader.js +0 -0
- package/dist/config/loader.js.map +0 -0
- package/dist/engine/backend-client.d.ts +0 -0
- package/dist/engine/backend-client.d.ts.map +0 -0
- package/dist/engine/backend-client.js +0 -0
- package/dist/engine/backend-client.js.map +0 -0
- package/dist/engine/hmac-verifier.d.ts +0 -0
- package/dist/engine/hmac-verifier.d.ts.map +0 -0
- package/dist/engine/hmac-verifier.js +0 -0
- package/dist/engine/hmac-verifier.js.map +0 -0
- package/dist/engine/immutability.d.ts +0 -0
- package/dist/engine/immutability.d.ts.map +0 -0
- package/dist/engine/immutability.js +0 -0
- package/dist/engine/immutability.js.map +0 -0
- package/dist/engine/pattern-matcher.d.ts +0 -0
- package/dist/engine/pattern-matcher.d.ts.map +0 -0
- package/dist/engine/pattern-matcher.js +0 -0
- package/dist/engine/pattern-matcher.js.map +0 -0
- package/dist/engine/rule-engine.d.ts +8 -1
- package/dist/engine/rule-engine.d.ts.map +1 -1
- package/dist/engine/rule-engine.js +18 -3
- 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 +0 -0
- package/dist/engine/session-state.js +0 -0
- package/dist/engine/session-state.js.map +0 -0
- package/dist/engine/ship-confidence-gate.d.ts +0 -0
- package/dist/engine/ship-confidence-gate.d.ts.map +0 -0
- package/dist/engine/ship-confidence-gate.js +0 -0
- package/dist/engine/ship-confidence-gate.js.map +0 -0
- package/dist/identity/first-run.d.ts +24 -0
- package/dist/identity/first-run.d.ts.map +1 -0
- package/dist/identity/first-run.js +88 -0
- package/dist/identity/first-run.js.map +1 -0
- package/dist/identity/nudge.d.ts +29 -0
- package/dist/identity/nudge.d.ts.map +1 -0
- package/dist/identity/nudge.js +74 -0
- package/dist/identity/nudge.js.map +1 -0
- package/dist/identity/premium-unlock.d.ts +30 -0
- package/dist/identity/premium-unlock.d.ts.map +1 -0
- package/dist/identity/premium-unlock.js +65 -0
- package/dist/identity/premium-unlock.js.map +1 -0
- package/dist/identity/register-client.d.ts +25 -0
- package/dist/identity/register-client.d.ts.map +1 -0
- package/dist/identity/register-client.js +48 -0
- package/dist/identity/register-client.js.map +1 -0
- package/dist/identity/telemetry.d.ts +64 -0
- package/dist/identity/telemetry.d.ts.map +1 -0
- package/dist/identity/telemetry.js +173 -0
- package/dist/identity/telemetry.js.map +1 -0
- package/dist/index.d.ts +0 -0
- package/dist/index.js +75 -1
- package/dist/rules/categories.json +0 -0
- package/dist/rules/presets.json +0 -0
- package/dist/rules/rules.json +153 -42
- package/dist/tools/audit.d.ts +0 -0
- package/dist/tools/audit.d.ts.map +0 -0
- package/dist/tools/audit.js +0 -0
- package/dist/tools/audit.js.map +0 -0
- package/dist/tools/bypass.d.ts +0 -0
- package/dist/tools/bypass.d.ts.map +0 -0
- package/dist/tools/bypass.js +0 -0
- package/dist/tools/bypass.js.map +0 -0
- package/dist/tools/export-attestation.d.ts +0 -0
- package/dist/tools/export-attestation.d.ts.map +0 -0
- package/dist/tools/export-attestation.js +0 -0
- package/dist/tools/export-attestation.js.map +0 -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 +0 -0
- package/dist/tools/ship-confidence.d.ts.map +0 -0
- package/dist/tools/ship-confidence.js +0 -0
- package/dist/tools/ship-confidence.js.map +0 -0
- package/dist/tools/update.d.ts +0 -0
- package/dist/tools/update.d.ts.map +0 -0
- package/dist/tools/update.js +0 -0
- package/dist/tools/update.js.map +0 -0
- package/dist/tools/validate.d.ts +0 -0
- package/dist/tools/validate.d.ts.map +0 -0
- package/dist/tools/validate.js +0 -0
- package/dist/tools/validate.js.map +0 -0
- package/dist/types/backend.d.ts +0 -0
- package/dist/types/backend.d.ts.map +0 -0
- package/dist/types/backend.js +0 -0
- package/dist/types/backend.js.map +0 -0
- package/package.json +2 -1
package/BUSINESS_LICENSE.md
CHANGED
|
@@ -21,7 +21,7 @@ The following uses are licensed at no cost the moment you `npx @sunaiva/gate`:
|
|
|
21
21
|
You need a paid license from Sunaiva Digital if you use this package to
|
|
22
22
|
provide a service to **third-party paying customers in production** (i.e.
|
|
23
23
|
running it in the critical path of a revenue-generating product before the
|
|
24
|
-
Change Date below). Contact **
|
|
24
|
+
Change Date below). Contact **licensing@sunaiva.ai** for pricing.
|
|
25
25
|
|
|
26
26
|
## Change Date and Change License
|
|
27
27
|
|
|
@@ -65,6 +65,6 @@ paid Sunaiva subscription regardless of the wrapper's licence state.
|
|
|
65
65
|
|
|
66
66
|
## Questions
|
|
67
67
|
|
|
68
|
-
- General licensing questions: **
|
|
68
|
+
- General licensing questions: **licensing@sunaiva.ai**
|
|
69
69
|
- Security concerns: **support@sunaiva.ai**
|
|
70
70
|
- Commercial / paid tiers: **support@sunaiva.ai**
|
package/CHANGELOG.md
CHANGED
|
@@ -40,7 +40,7 @@ the **Sunaiva Core brand rebrand** (locked 2026-05-23: primary domain
|
|
|
40
40
|
`sunaivacore.io`, parent `sunaiva.ai`, support mailbox `support@sunaiva.ai`).
|
|
41
41
|
|
|
42
42
|
### Changed
|
|
43
|
-
- **Support / docs URLs scrubbed** of
|
|
43
|
+
- **Support / docs URLs scrubbed** of the legacy public-repo reference AND
|
|
44
44
|
rebranded to Sunaiva Core domain — package.json `repository` field removed;
|
|
45
45
|
`bugs.email` now `support@sunaiva.ai`; `homepage` updated to
|
|
46
46
|
`https://sunaivacore.io/products/gate`. The same scrub applied to
|
|
@@ -52,7 +52,7 @@ the **Sunaiva Core brand rebrand** (locked 2026-05-23: primary domain
|
|
|
52
52
|
- **Backend URL updated** — `DEFAULT_BACKEND_URL` in both `dist/types/backend.{js,d.ts}`
|
|
53
53
|
and `dist/version-pin/registry.js` changed from `mcp.sunaivacore.io/v1/gatehooks` to
|
|
54
54
|
`mcp.sunaivacore.io/v1/gatehooks` per the Sunaiva MCP Command lane endpoint
|
|
55
|
-
ownership decision (
|
|
55
|
+
ownership decision (operator directive 2026-05-25).
|
|
56
56
|
- **In-toto attestation URIs updated** — `BUILD_TYPE` and `BUILDER_ID` in
|
|
57
57
|
`dist/installer/attestation/intoto.js` re-rooted from `sunaivadigital.com`
|
|
58
58
|
to `sunaivacore.io`.
|
package/LICENSE
CHANGED
|
File without changes
|
package/README.DRAFT.md
ADDED
|
@@ -0,0 +1,418 @@
|
|
|
1
|
+
# @sunaiva/gate — Free Safety Hook for AI Coding Agents
|
|
2
|
+
|
|
3
|
+
**A fail-open safety net for your AI agent workflows. It catches more than
|
|
4
|
+
you have today. If it ever errors, it gets out of your way. It cannot break
|
|
5
|
+
your build.**
|
|
6
|
+
|
|
7
|
+
> **Current version**: `1.1.2` | BUSL-1.1 license, Apache-2.0 on 2030-05-10
|
|
8
|
+
> **Status**: learning in public — pattern coverage improves with every release.
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npx @sunaiva/gate
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
No signup. No API key. No DNS record. Just add it to your MCP config and the
|
|
15
|
+
32 free constitutional rules are active on the next tool call.
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## The honest pitch
|
|
20
|
+
|
|
21
|
+
AI coding agents are capable and fast. They are also capable of:
|
|
22
|
+
|
|
23
|
+
- Committing hardcoded API keys to a public repository
|
|
24
|
+
- Firing off a bulk email campaign the moment copy is approved
|
|
25
|
+
- Charging a Stripe customer to test a payment flow
|
|
26
|
+
- Running `rm -rf` on the wrong directory at 2am
|
|
27
|
+
- Deploying a broken build to production because the test suite was skipped
|
|
28
|
+
|
|
29
|
+
None of these require a rogue model. They happen from completely reasonable
|
|
30
|
+
agent behaviour applied in the wrong moment. The gate intercepts those
|
|
31
|
+
moments.
|
|
32
|
+
|
|
33
|
+
The free tier works entirely on your machine — no backend, no telemetry,
|
|
34
|
+
no external calls of any kind. It evaluates 32 constitutional rules locally
|
|
35
|
+
against pattern matching. It is not perfect. Some edge cases are unmapped.
|
|
36
|
+
The patterns improve with each release. We publish the miss reports and the
|
|
37
|
+
fixes together.
|
|
38
|
+
|
|
39
|
+
The core guarantee: **if the gate itself errors, it degrades to exactly
|
|
40
|
+
your current behaviour**. You lose nothing by installing it.
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## Install
|
|
45
|
+
|
|
46
|
+
### 1. Add to your MCP client
|
|
47
|
+
|
|
48
|
+
```json
|
|
49
|
+
{
|
|
50
|
+
"mcpServers": {
|
|
51
|
+
"sunaiva-gate": {
|
|
52
|
+
"command": "npx",
|
|
53
|
+
"args": ["@sunaiva/gate"]
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Supported clients: Claude Code, Cursor, Windsurf, Cline, Aider, Codex, Zed.
|
|
60
|
+
Restart your client. The gate loads on the first tool call.
|
|
61
|
+
|
|
62
|
+
### 2. Verify it is working
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
npx @sunaiva/gate --smoke-test
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Expected output:
|
|
69
|
+
|
|
70
|
+
```
|
|
71
|
+
✓ Gate loaded — 100 rules
|
|
72
|
+
✓ Constitutional rules — 32 (cannot be disabled, enforced locally)
|
|
73
|
+
✓ Premium rules — 68 (require backend service)
|
|
74
|
+
✓ Live eval (git push origin main) — HARD block via gov-001
|
|
75
|
+
✓ Live eval (rm -rf /) — HARD block via dat-001
|
|
76
|
+
✓ Live eval (stripe.charges.create) — HARD block via fin-001
|
|
77
|
+
Status: HEALTHY
|
|
78
|
+
Version: 1.1.2
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
That is the full install. No further configuration required.
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
## What it catches today (free, local, no backend)
|
|
86
|
+
|
|
87
|
+
The 32 constitutional rules are evaluated entirely on your machine using
|
|
88
|
+
keyword and pattern matching against the action text. They are split across
|
|
89
|
+
five categories.
|
|
90
|
+
|
|
91
|
+
### Financial safety (6 rules)
|
|
92
|
+
|
|
93
|
+
| Rule | What it blocks |
|
|
94
|
+
|------|---------------|
|
|
95
|
+
| `fin-001` | Stripe charges, PayPal payments, checkout submissions, in-app purchase flows |
|
|
96
|
+
| `fin-002` | Cumulative API cost overruns, cloud billing events that exceed cap |
|
|
97
|
+
| `fin-003` | Subscription changes, free-trial conversions, auto-renewal toggles |
|
|
98
|
+
| `fin-004` | Crypto wallet transfers, DeFi interactions, gas fee submissions |
|
|
99
|
+
| `fin-008` | Wire transfers, ACH batch files, SWIFT/IBAN banking API payloads |
|
|
100
|
+
| `fin-009` | Google Ads / Meta Ads / TikTok campaign launches with spend attached |
|
|
101
|
+
|
|
102
|
+
### Action governance (7 rules)
|
|
103
|
+
|
|
104
|
+
| Rule | What it blocks |
|
|
105
|
+
|------|---------------|
|
|
106
|
+
| `gov-001` | `git push origin main/master`, Netlify prod deploys, Docker prod pushes |
|
|
107
|
+
| `gov-002` | `rm -rf`, `DROP TABLE`, `git reset --hard`, S3 bucket deletes, file overwrites without backup |
|
|
108
|
+
| `gov-004` | Cloudflare/Route 53/GoDaddy DNS record changes via API |
|
|
109
|
+
| `gov-005` | IAM role assignment, OAuth scope escalation, admin privilege grants |
|
|
110
|
+
| `gov-006` | Account deletion API calls (Stripe customer delete, workspace deactivation) |
|
|
111
|
+
| `gov-008` | Instantly / Mailchimp / Klaviyo / Twilio bulk campaign activations |
|
|
112
|
+
| `gov-012` | `terraform destroy`, CloudFormation stack deletion, Kubernetes namespace purges |
|
|
113
|
+
|
|
114
|
+
### Data protection (4 rules)
|
|
115
|
+
|
|
116
|
+
| Rule | What it blocks |
|
|
117
|
+
|------|---------------|
|
|
118
|
+
| `dat-001` | API key patterns in logs, secret env vars written to stdout, Bearer tokens in debug output |
|
|
119
|
+
| `dat-002` | Names + email combinations, SSNs, passport numbers, health identifiers stored without consent |
|
|
120
|
+
| `dat-004` | API keys hardcoded in git diffs, secrets in PR descriptions, keys in chat history |
|
|
121
|
+
| `dat-010` | Audit log deletion, timestamp modification in records, log rotation bypasses |
|
|
122
|
+
|
|
123
|
+
### Communication safety (6 rules)
|
|
124
|
+
|
|
125
|
+
| Rule | What it blocks |
|
|
126
|
+
|------|---------------|
|
|
127
|
+
| `com-001` | SMTP sends, Gmail API message sends, SendGrid/Postmark sends to external recipients |
|
|
128
|
+
| `com-002` | Twitter/X, LinkedIn, Facebook, Instagram, TikTok API post submissions |
|
|
129
|
+
| `com-005` | CRM-triggered customer emails, in-app messages sent to user segments |
|
|
130
|
+
| `com-006` | PR Newswire / Business Wire distribution API calls, investor relation sends |
|
|
131
|
+
| `com-007` | DocuSign envelope sends, HelloSign contract submissions, NDA emails |
|
|
132
|
+
| `com-009` | Cold email sequence activations (Instantly, Lemlist, Apollo, Outreach) |
|
|
133
|
+
| `com-011` | Emails or messages attributed to a named human without a disclosure header |
|
|
134
|
+
|
|
135
|
+
### Security and compliance (8 rules)
|
|
136
|
+
|
|
137
|
+
| Rule | What it blocks |
|
|
138
|
+
|------|---------------|
|
|
139
|
+
| `sec-001` | API keys / passwords printed via `console.log`, `print()`, `logger.info()` |
|
|
140
|
+
| `sec-002` | `eval()` on external input, `exec()` with user strings, `subprocess.run` with unvalidated args |
|
|
141
|
+
| `sec-004` | `sudo` commands outside approved list, IAM scope requests exceeding declared need |
|
|
142
|
+
| `sec-006` | JWT secret changes, OAuth provider config modifications, MFA bypass additions |
|
|
143
|
+
| `sec-010` | API calls to banned model providers (DeepSeek, Kimi, MiniMax, and similar) |
|
|
144
|
+
| `sec-011` | MFA disable API calls, TOTP secret deletion, 2FA removal from admin accounts |
|
|
145
|
+
| `cmp-002` | EU resident data stored without consent record, PII transfers without lawful basis |
|
|
146
|
+
| `know-009` | Market size claims without cited research, conversion rates without a source, fabricated benchmarks |
|
|
147
|
+
|
|
148
|
+
**A further 68 standard rules are enumerated in the package** but require
|
|
149
|
+
the premium backend (`SUNAIVA_GATE_BACKEND_URL`) to evaluate. Without it,
|
|
150
|
+
they are skipped and recorded as `skipped_premium` in the audit log. You
|
|
151
|
+
will see a once-per-session notice on stderr pointing to the upgrade path.
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
## The fail-open guarantee
|
|
156
|
+
|
|
157
|
+
This is the property that makes install low-risk:
|
|
158
|
+
|
|
159
|
+
- **Backend errors are always fail-open** — if the premium backend times out
|
|
160
|
+
or returns 5xx, that rule is skipped and recorded as
|
|
161
|
+
`skipped_premium_backend_error`. The action proceeds.
|
|
162
|
+
- **The Python hook adapter (`hooks/sunaiva_gate_hook.py`) is always
|
|
163
|
+
fail-open** — any exception exits `0`, never blocks.
|
|
164
|
+
- **The ship-confidence gate engine is always fail-open on its own
|
|
165
|
+
exceptions** — records `FAIL_OPEN_ON_EXCEPTION` in the audit, decision
|
|
166
|
+
is `allow`.
|
|
167
|
+
- **Bad `rules.json`** — if the rules file is corrupt or unreadable, the
|
|
168
|
+
gate loads an empty rule set and logs to stderr. Nothing blocks.
|
|
169
|
+
|
|
170
|
+
The **one exception to fail-open**: the 32 constitutional rules evaluated
|
|
171
|
+
by the local engine exit with code `3` (internal error) or `4` (malformed
|
|
172
|
+
input) if the gate binary itself crashes on those paths. This is intentional
|
|
173
|
+
— a gate that silently passes everything on an internal error provides no
|
|
174
|
+
protection. You can opt back into legacy fail-open with
|
|
175
|
+
`SUNAIVA_GATE_FAIL_OPEN_ON_ERROR=1`.
|
|
176
|
+
|
|
177
|
+
**Worst case: you set `DISABLE_SUNAIVA_GATE=1` and the gate is gone.**
|
|
178
|
+
Every block message discloses this escape hatch, because an enforcement
|
|
179
|
+
tool that hides its bypass is one that gets silently routed around. The
|
|
180
|
+
kill-switch invocation is logged to the audit ledger as
|
|
181
|
+
`decision: 'bypass_kill_switch'`.
|
|
182
|
+
|
|
183
|
+
---
|
|
184
|
+
|
|
185
|
+
## Honest limitations
|
|
186
|
+
|
|
187
|
+
The free constitutional rules use **keyword and pattern matching**. They
|
|
188
|
+
are not semantic. They can be:
|
|
189
|
+
|
|
190
|
+
- **Defeated by rephrasing** — `send email to customer@example.com` blocks;
|
|
191
|
+
a sufficiently indirect phrasing may not.
|
|
192
|
+
- **Wrong about context** — `gov-002` blocks `git reset --hard`; in a
|
|
193
|
+
deliberate rollback context that is correct behaviour that you have
|
|
194
|
+
deliberately chosen. Use the kill-switch or approval-token workflow to
|
|
195
|
+
unblock one-shot legitimate actions.
|
|
196
|
+
- **Incomplete** — some attack patterns are not yet mapped. The 68 premium
|
|
197
|
+
rules cover more edge cases server-side; the free set is the foundation,
|
|
198
|
+
not the ceiling.
|
|
199
|
+
|
|
200
|
+
We track miss reports. When a rule fails to catch a real incident, we log
|
|
201
|
+
it, write a failing test fixture, and ship a new detection pattern in the
|
|
202
|
+
next release. The changelog records every addition.
|
|
203
|
+
|
|
204
|
+
---
|
|
205
|
+
|
|
206
|
+
## Severity ladder
|
|
207
|
+
|
|
208
|
+
The gate has three severity levels:
|
|
209
|
+
|
|
210
|
+
| Severity | First match | Subsequent matches |
|
|
211
|
+
|----------|-------------|-------------------|
|
|
212
|
+
| `block` (constitutional) | Block immediately | Block every time |
|
|
213
|
+
| `warn-then-block` | Warn, allow | Block |
|
|
214
|
+
| `warn` | Warn, allow | Warn, allow |
|
|
215
|
+
|
|
216
|
+
Constitutional rules always `block` on first match. The session escalation
|
|
217
|
+
counter resets when the MCP server process restarts.
|
|
218
|
+
|
|
219
|
+
---
|
|
220
|
+
|
|
221
|
+
## Escaping a false positive
|
|
222
|
+
|
|
223
|
+
Three escape valves, in order of preference:
|
|
224
|
+
|
|
225
|
+
**1. Dry-run mode** — measure what would block without actually blocking:
|
|
226
|
+
|
|
227
|
+
```bash
|
|
228
|
+
export SUNAIVA_GATE_DRY_RUN=1
|
|
229
|
+
# response.dry_run: true
|
|
230
|
+
# response.would_have_blocked: [{rule_id, name, severity}, ...]
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
**2. Approval token** — for a one-shot legitimate deploy or action, drop a
|
|
234
|
+
token file:
|
|
235
|
+
|
|
236
|
+
```json
|
|
237
|
+
// data/deploy_queue/APPROVAL_TOKENS/<artifact>.json
|
|
238
|
+
{
|
|
239
|
+
"artifact": "my-package@1.0.0",
|
|
240
|
+
"approved_by": "you",
|
|
241
|
+
"approved_at": "2026-05-29T12:00:00Z",
|
|
242
|
+
"ttl_minutes": 60
|
|
243
|
+
}
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
The gate honours it once within the TTL, then the token is consumed.
|
|
247
|
+
|
|
248
|
+
**3. Kill-switch** — temporarily disables all enforcement:
|
|
249
|
+
|
|
250
|
+
```bash
|
|
251
|
+
export DISABLE_SUNAIVA_GATE=1 # Loud: logs every bypass
|
|
252
|
+
unset DISABLE_SUNAIVA_GATE # Enforcement resumes
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
---
|
|
256
|
+
|
|
257
|
+
## Audit log
|
|
258
|
+
|
|
259
|
+
Every gate decision is written to `~/.sunaiva/audit/audit.jsonl`:
|
|
260
|
+
|
|
261
|
+
```json
|
|
262
|
+
{
|
|
263
|
+
"timestamp": "2026-05-29T12:00:00.000Z",
|
|
264
|
+
"action": "git push origin main",
|
|
265
|
+
"decision": "blocked",
|
|
266
|
+
"rule_id": "gov-001",
|
|
267
|
+
"rule_name": "Production Deployment Gate",
|
|
268
|
+
"tier": "free",
|
|
269
|
+
"audit_status": "constitutional_block",
|
|
270
|
+
"evidence": ["keyword: git push", "keyword: origin main"],
|
|
271
|
+
"event_type": "validate_action"
|
|
272
|
+
}
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
The audit log has no rotation cap. It is local only on the free tier —
|
|
276
|
+
nothing leaves your machine. The `get_audit_log` MCP tool queries it
|
|
277
|
+
directly.
|
|
278
|
+
|
|
279
|
+
---
|
|
280
|
+
|
|
281
|
+
## Data privacy
|
|
282
|
+
|
|
283
|
+
**Free tier**: zero external network calls. Constitutional rules are evaluated
|
|
284
|
+
against patterns shipped inside the package at `dist/rules/rules.json`. No
|
|
285
|
+
action text, no code, no secrets leave your machine.
|
|
286
|
+
|
|
287
|
+
**Pro tier** (opt-in): when you set `SUNAIVA_GATE_BACKEND_URL`, the engine
|
|
288
|
+
POSTs only the proposed action text and rule IDs to the backend for the
|
|
289
|
+
premium-rule subset. We never see your source code, your file contents, or
|
|
290
|
+
your secrets. BYOK means your `ANTHROPIC_API_KEY` and `OPENROUTER_API_KEY`
|
|
291
|
+
go directly from your machine to those providers — they do not transit
|
|
292
|
+
Sunaiva infrastructure.
|
|
293
|
+
|
|
294
|
+
---
|
|
295
|
+
|
|
296
|
+
## Environment variables
|
|
297
|
+
|
|
298
|
+
| Variable | Default | Purpose |
|
|
299
|
+
|----------|---------|---------|
|
|
300
|
+
| `DISABLE_SUNAIVA_GATE` | unset | Set to `1` to allow all actions (logged loudly) |
|
|
301
|
+
| `SUNAIVA_GATE_DRY_RUN` | unset | Set to `1` to evaluate but never block |
|
|
302
|
+
| `SUNAIVA_GATE_FAIL_OPEN_ON_ERROR` | unset | Set to `1` for legacy fail-open on internal errors |
|
|
303
|
+
| `SUNAIVA_GATE_BACKEND_URL` | unset | Premium backend endpoint (Pro tier) |
|
|
304
|
+
| `SUNAIVA_GATE_API_TOKEN` | unset | Bearer token for the premium backend |
|
|
305
|
+
| `SUNAIVA_GATE_BACKEND_TIMEOUT_MS` | `3000` | Backend timeout — network errors fail-open |
|
|
306
|
+
| `SUNAIVA_GATE_AUDIT_PATH` | `~/.sunaiva/audit/audit.jsonl` | Override audit log location |
|
|
307
|
+
| `SHIP_CONFIDENCE_SIGNING_KEY` | unset | HMAC key for verifying signed ship-confidence verdicts |
|
|
308
|
+
|
|
309
|
+
---
|
|
310
|
+
|
|
311
|
+
## MCP tool reference
|
|
312
|
+
|
|
313
|
+
| Tool | What it does |
|
|
314
|
+
|------|--------------|
|
|
315
|
+
| `validate_action` | Evaluate a proposed action against all active rules |
|
|
316
|
+
| `get_audit_log` | Query the local audit log |
|
|
317
|
+
| `get_rules` | List active rules; filter by `category` or `preset` |
|
|
318
|
+
| `update_rules` | Enable / disable non-constitutional rules |
|
|
319
|
+
| `log_bypass` | Record an intentional bypass (constitutional rules rejected) |
|
|
320
|
+
| `ship_confidence_check` | Production deploy gate — free (approval token) or paid (signed verdict) |
|
|
321
|
+
|
|
322
|
+
---
|
|
323
|
+
|
|
324
|
+
## Exit codes
|
|
325
|
+
|
|
326
|
+
| Code | Meaning |
|
|
327
|
+
|------|---------|
|
|
328
|
+
| `0` | Allow / success / smoke-test HEALTHY |
|
|
329
|
+
| `2` | Block |
|
|
330
|
+
| `3` | Internal error, fail-CLOSED (opt into fail-open via `SUNAIVA_GATE_FAIL_OPEN_ON_ERROR=1`) |
|
|
331
|
+
| `4` | Invalid input, fail-CLOSED (same opt-in) |
|
|
332
|
+
|
|
333
|
+
---
|
|
334
|
+
|
|
335
|
+
## Where this is going
|
|
336
|
+
|
|
337
|
+
The free gate is the entry point to a capability ladder that maps directly
|
|
338
|
+
to the hard problems of AI agent governance. Each tier unlocks capabilities
|
|
339
|
+
that a local pattern-matching engine structurally cannot provide:
|
|
340
|
+
|
|
341
|
+
**Tier 1 — Free gate (now)**: 32 local constitutional rules. Fail-open
|
|
342
|
+
guarantee. Pattern coverage grows with every release. This is the floor.
|
|
343
|
+
|
|
344
|
+
**Tier 2 — Cross-provider verification (~$0.002 per call)**: The same
|
|
345
|
+
action evaluated by independent model providers simultaneously. A single
|
|
346
|
+
model can be convinced; three models from different training lineages
|
|
347
|
+
reaching the same verdict is structurally harder to manipulate. This is
|
|
348
|
+
the conjunctive-routing layer.
|
|
349
|
+
|
|
350
|
+
**Tier 3 — Signed compliance records ($50k/yr enterprise, $0.05/record
|
|
351
|
+
metered)**: Cryptographically signed audit records for EU AI Act Article 12
|
|
352
|
+
(transparency), Article 14 (human oversight), and Article 15 (accuracy)
|
|
353
|
+
requirements. An immutable, tamper-evident trail that satisfies enterprise
|
|
354
|
+
procurement and regulatory review — not documentation, but provable
|
|
355
|
+
evidence. The ZK-receipt variant makes the proof verifiable without
|
|
356
|
+
disclosing the underlying data.
|
|
357
|
+
|
|
358
|
+
**Tier 4 — Adaptive memory**: The gate learns which rules generated
|
|
359
|
+
friction with no follow-on incident (false positives) and which rules were
|
|
360
|
+
bypassed before a real incident (missed catches). The pattern library
|
|
361
|
+
improves from usage signals. Cost model: a share of the token-budget
|
|
362
|
+
savings from avoiding the incidents the gate prevents.
|
|
363
|
+
|
|
364
|
+
The cryptographic infrastructure behind Tiers 3 and 4 is covered by USPTO
|
|
365
|
+
provisional patents 64/006,491 and 64/030,411.
|
|
366
|
+
|
|
367
|
+
If Tier 2 or Tier 3 sounds relevant, email `support@sunaiva.ai`.
|
|
368
|
+
|
|
369
|
+
---
|
|
370
|
+
|
|
371
|
+
## Known gaps in the current release
|
|
372
|
+
|
|
373
|
+
We track these openly:
|
|
374
|
+
|
|
375
|
+
- The `--mcp-bridge` flag documented in the installer shims is not yet
|
|
376
|
+
wired into the binary entrypoint. Installer output references it but the
|
|
377
|
+
bridge path is a no-op until the next patch. The `validate_action` MCP
|
|
378
|
+
tool works correctly; only the direct-hook installer path is affected.
|
|
379
|
+
- Version badge in this file reflects `1.1.2`. If `--smoke-test` shows a
|
|
380
|
+
different version, the package cache may be stale — run
|
|
381
|
+
`npx --yes @sunaiva/gate@latest --smoke-test`.
|
|
382
|
+
- No aggregate telemetry today. The gate records decisions locally but
|
|
383
|
+
does not phone home. This means we cannot see which rules trigger most
|
|
384
|
+
often across the install base. A privacy-preserving aggregate metrics
|
|
385
|
+
channel (opt-in, anonymous counters only) is on the roadmap.
|
|
386
|
+
|
|
387
|
+
---
|
|
388
|
+
|
|
389
|
+
## License
|
|
390
|
+
|
|
391
|
+
[BUSL-1.1](./BUSINESS_LICENSE.md) — free for evaluation, internal
|
|
392
|
+
development, hobby and academic use. Commercial license required if you
|
|
393
|
+
embed the gate in the critical path of a product sold to third-party
|
|
394
|
+
paying customers before **2030-05-10**, after which the wrapper converts
|
|
395
|
+
to **Apache-2.0** automatically. The premium backend stays proprietary
|
|
396
|
+
regardless of the Change Date.
|
|
397
|
+
|
|
398
|
+
- **Licensor**: Sunaiva Digital
|
|
399
|
+
- **Change Date**: 2030-05-10
|
|
400
|
+
- **Change License**: Apache License, Version 2.0
|
|
401
|
+
|
|
402
|
+
---
|
|
403
|
+
|
|
404
|
+
## Support
|
|
405
|
+
|
|
406
|
+
| Need | Where |
|
|
407
|
+
|------|-------|
|
|
408
|
+
| Bug or crash | `support@sunaiva.ai` — include `--smoke-test` output and `node --version` |
|
|
409
|
+
| Feature request | `support@sunaiva.ai` with subject `[feature-request]` |
|
|
410
|
+
| Security vulnerability | `support@sunaiva.ai` — do not file publicly |
|
|
411
|
+
| Pro / Enterprise enquiry | `support@sunaiva.ai` |
|
|
412
|
+
| Product page | `https://sunaivacore.io/products/gate` |
|
|
413
|
+
|
|
414
|
+
---
|
|
415
|
+
|
|
416
|
+
*Built by a team whose own hooks locked them out of their development
|
|
417
|
+
environment for nine hours. We fixed it. Then we shipped the fix.
|
|
418
|
+
Then we signed the proof.*
|