@sunaiva/gate 1.0.0 → 1.1.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/BUSINESS_LICENSE.md +70 -0
- package/CHANGELOG.md +148 -0
- package/LICENSE +0 -0
- package/README.md +411 -27
- 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 +24 -6
- 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 +33 -0
- package/dist/engine/hmac-verifier.d.ts.map +1 -0
- package/dist/engine/hmac-verifier.js +161 -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 +222 -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 +184 -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.d.ts.map +0 -0
- package/dist/index.js +289 -2
- package/dist/index.js.map +1 -1
- package/dist/rules/categories.json +0 -0
- package/dist/rules/presets.json +0 -0
- package/dist/rules/rules.json +200 -100
- 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/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 +11 -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 +11 -3
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# Business Source License — `@sunaiva/gate`
|
|
2
|
+
|
|
3
|
+
This package is published under the **Business Source License 1.1 (BUSL-1.1)**.
|
|
4
|
+
The full BUSL-1.1 legal text lives in [`LICENSE`](./LICENSE) and at
|
|
5
|
+
<https://mariadb.com/bsl11/>. This document is a plain-language summary so
|
|
6
|
+
contributors and prospective customers know what they can and cannot do.
|
|
7
|
+
|
|
8
|
+
## What you can do today, for free
|
|
9
|
+
|
|
10
|
+
The following uses are licensed at no cost the moment you `npx @sunaiva/gate`:
|
|
11
|
+
|
|
12
|
+
- **Evaluation, exploration, and proof-of-concept work** in any environment.
|
|
13
|
+
- **Internal development, testing, staging, and CI** runs — including running
|
|
14
|
+
the gate inside team workflows that never touch external paying customers.
|
|
15
|
+
- **Personal, hobbyist, academic, and research use** of any kind.
|
|
16
|
+
- **Forking, modifying, and redistributing the source code** under the same
|
|
17
|
+
BUSL-1.1 terms, with attribution preserved.
|
|
18
|
+
|
|
19
|
+
## What requires a commercial license
|
|
20
|
+
|
|
21
|
+
You need a paid license from Sunaiva Digital if you use this package to
|
|
22
|
+
provide a service to **third-party paying customers in production** (i.e.
|
|
23
|
+
running it in the critical path of a revenue-generating product before the
|
|
24
|
+
Change Date below). Contact **kinan@sunaiva.ai** for pricing.
|
|
25
|
+
|
|
26
|
+
## Change Date and Change License
|
|
27
|
+
|
|
28
|
+
- **Change Date**: **2030-05-10** (4 years after the first publication of
|
|
29
|
+
`@sunaiva/gate` on the npm registry — version `1.0.0`, 2026-05-10).
|
|
30
|
+
- **Change License**: **Apache License, Version 2.0** (chosen for its broad
|
|
31
|
+
compatibility, explicit patent grant, and standing as the most common
|
|
32
|
+
conversion target for BUSL-licensed projects).
|
|
33
|
+
- **Current version**: `1.1.0` ("Foundation Release"), 2026-05-12 — the first
|
|
34
|
+
release with the full constitutional rule set enforced locally and the Ship
|
|
35
|
+
Confidence Gate MCP tool wired. The `1.0.x` releases are deprecated on npm
|
|
36
|
+
(see [`CHANGELOG.md`](./CHANGELOG.md)).
|
|
37
|
+
|
|
38
|
+
On the Change Date, this version of `@sunaiva/gate` automatically converts to
|
|
39
|
+
Apache-2.0 with no further action required from anyone. Each future minor or
|
|
40
|
+
patch release ships under BUSL-1.1 with its own 4-year clock from its own
|
|
41
|
+
publication date.
|
|
42
|
+
|
|
43
|
+
## Why BUSL-1.1?
|
|
44
|
+
|
|
45
|
+
Sunaiva Gate is a **thin, public wrapper** over a deliberately proprietary
|
|
46
|
+
backend. The wrapper code — the rule engine, hook adapter, and CLI — is open
|
|
47
|
+
so anyone can inspect, audit, and extend it. The backend services that
|
|
48
|
+
deliver premium rules, witness validation, signed proof envelopes, and
|
|
49
|
+
on-chain attestation remain **private commercial infrastructure** and are
|
|
50
|
+
not distributed under this license at all.
|
|
51
|
+
|
|
52
|
+
BUSL-1.1 lets us publish the wrapper openly today, give every user real
|
|
53
|
+
constitutional enforcement out of the box, and still preserve the commercial
|
|
54
|
+
runway needed to fund the backend's development.
|
|
55
|
+
|
|
56
|
+
## Backend status is unaffected by the Change Date
|
|
57
|
+
|
|
58
|
+
The backend services are **not** shipped under BUSL-1.1. They are
|
|
59
|
+
proprietary infrastructure operated by Sunaiva Digital. Their licensing
|
|
60
|
+
status is **independent** of any clock in this repository. When the
|
|
61
|
+
`@sunaiva/gate` wrapper converts to Apache-2.0 on 2030-05-10, the backend
|
|
62
|
+
remains commercial and proprietary — only the wrapper code's licence
|
|
63
|
+
changes. Customers relying on backend-tier features will continue to need a
|
|
64
|
+
paid Sunaiva subscription regardless of the wrapper's licence state.
|
|
65
|
+
|
|
66
|
+
## Questions
|
|
67
|
+
|
|
68
|
+
- General licensing questions: **kinan@sunaiva.ai**
|
|
69
|
+
- Security concerns: **security@sunaivadigital.com**
|
|
70
|
+
- Commercial / paid tiers: **support@sunaivadigital.com**
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to `@sunaiva/gate` follow the [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) format and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## [1.1.0] — 2026-05-12 — "Foundation Release"
|
|
8
|
+
|
|
9
|
+
First publicly-supported release. Closes all 7 CRITICAL findings from the signed
|
|
10
|
+
Ship-Confidence verdict on `1.0.1` (`01KRDBCEYF2CAB21G6Y3E9VVH5`, RED), restores
|
|
11
|
+
the constitutional enforcement promise the README has always made, and ships the
|
|
12
|
+
paid-tier Ship Confidence Gate integration as a real MCP tool rather than a
|
|
13
|
+
README claim.
|
|
14
|
+
|
|
15
|
+
### Added
|
|
16
|
+
- **MCP server runtime with 6 tools**: `validate_action`, `log_bypass`,
|
|
17
|
+
`get_rules`, `update_rules`, `get_audit_log`, and (NEW) `ship_confidence_check`.
|
|
18
|
+
- **Ship-confidence gate** — TypeScript port of the Genesis Python hook
|
|
19
|
+
`.claude/hooks/ship_confidence_gate.py` v1.2.0, exposed both as the
|
|
20
|
+
`ship_confidence_check` MCP tool and as the `--ship-confidence <artifact-id>`
|
|
21
|
+
CLI flag.
|
|
22
|
+
- **Cross-vendor HMAC-SHA256 verdict verification** with byte-compatible
|
|
23
|
+
canonical-JSON encoding to the `sunaiva-ship-confidence` Python skill
|
|
24
|
+
(sorted keys, `","`/`":"` separators, constant-time signature compare).
|
|
25
|
+
- **Premium backend client** (`src/engine/backend-client.ts`) — optional HTTP +
|
|
26
|
+
JWT path to `https://gate.sunaiva.dev/api/v1/match` for evaluating the 68
|
|
27
|
+
premium rules server-side. Opt-in via `SUNAIVA_GATE_BACKEND_URL` +
|
|
28
|
+
`SUNAIVA_GATE_API_TOKEN`. Backend errors fail-OPEN per-rule (never blocks the
|
|
29
|
+
user on Sunaiva outage).
|
|
30
|
+
- **Constitutional immutability guards** — load-time re-merge plus write-time
|
|
31
|
+
rejection. The 32 constitutional rules cannot be disabled via `update_rules`
|
|
32
|
+
and cannot be bypassed via `log_bypass`, even if `~/.sunaiva/gate-config.json`
|
|
33
|
+
is hand-edited.
|
|
34
|
+
- **`--smoke-test` CLI flag** — pre-deployment self-check with three canned
|
|
35
|
+
evaluations (allow / block / block) and an explicit `Constitutional rules —
|
|
36
|
+
32` count line. Exit 0 = HEALTHY, 1 = DEGRADED, 5 = missing required files.
|
|
37
|
+
- **Bundle invariant tests** — `tests/bundle.test.ts` asserts the package ships
|
|
38
|
+
with exactly 32 constitutional rules (patterns intact) and 68 premium stubs
|
|
39
|
+
(patterns replaced with `"[server-side]"`).
|
|
40
|
+
- **Audit ledger fields** — every entry now records `tier`, `audit_status`,
|
|
41
|
+
`evidence`, and an `event_type` discriminator so paid-tier ship-confidence
|
|
42
|
+
events and free-tier local evaluations are queryable separately.
|
|
43
|
+
- **Kill-switch** (`DISABLE_SUNAIVA_GATE=1`) — short-circuits every
|
|
44
|
+
`validate_action` to `allowed: true` with a structured response shape and
|
|
45
|
+
unconditional stderr disclosure.
|
|
46
|
+
- **Dry-run mode** (`SUNAIVA_GATE_DRY_RUN=1`) — evaluates rules normally but
|
|
47
|
+
never blocks; response includes `dry_run: true` and `would_have_blocked: [...]`.
|
|
48
|
+
- **Premium-skipped notice** — when premium rules are active but no backend
|
|
49
|
+
is configured, the first event per session prints
|
|
50
|
+
`[sunaiva-gate v1.1.0] N premium rules skipped (no backend configured).`
|
|
51
|
+
to stderr and records `skipped_premium: [rule_ids]` in the audit log.
|
|
52
|
+
- `CHANGELOG.md` (this file) and `tests/version-consistency.test.ts`
|
|
53
|
+
preventing future version drift between `package.json`, `src/index.ts`,
|
|
54
|
+
and `src/tools/validate.ts`.
|
|
55
|
+
|
|
56
|
+
### Changed
|
|
57
|
+
- **`DEFAULT_CONFIG.active_rules`** expanded from 5 constitutional IDs to all
|
|
58
|
+
32 — the package now boots with the full constitutional set active by default.
|
|
59
|
+
- **License model documented**: BUSL-1.1 wrapper, Change Date **2030-05-10**,
|
|
60
|
+
Change License **Apache-2.0**. The premium backend remains proprietary and is
|
|
61
|
+
not affected by the BUSL clock.
|
|
62
|
+
- **Tier model published**: Free / Pro / Enterprise per
|
|
63
|
+
[`TIER_DEFINITIONS.md`](./TIER_DEFINITIONS.md). The per-call pricing claims
|
|
64
|
+
from the 1.0.x README (`$0.005/$0.02/$0.25 per call`) and the legacy
|
|
65
|
+
"Pro / Shield / Shield+TEE" tier names are **struck**.
|
|
66
|
+
|
|
67
|
+
### Fixed
|
|
68
|
+
- **C1** — `rules.json` now ships inside the npm tarball at `dist/rules/rules.json`
|
|
69
|
+
with all 32 constitutional patterns intact. Previous releases loaded from
|
|
70
|
+
`~/.sunaiva/rules.json` only, which the strip-patterns build step had emptied
|
|
71
|
+
to `"[server-side]"` placeholders on the install path.
|
|
72
|
+
- **C2** — `update_rules({disable: ['fin-001']})` now returns a structured
|
|
73
|
+
`CONSTITUTIONAL_RULE_IMMUTABLE` error and persists nothing. Previously the
|
|
74
|
+
call was honoured silently.
|
|
75
|
+
- **C3** — `log_bypass({rule_id: 'fin-001'})` now returns a structured
|
|
76
|
+
`CONSTITUTIONAL_RULE_CANNOT_BE_BYPASSED` error and writes nothing to the
|
|
77
|
+
bypass log. Previously the bypass was recorded.
|
|
78
|
+
- **C4** — Premium rules now produce a one-time-per-session stderr notice
|
|
79
|
+
when skipped and increment `skipped_premium` in every audit entry, instead
|
|
80
|
+
of being silently dropped.
|
|
81
|
+
- **C5** — Unhandled exceptions in the gate's own code now exit with code **3**
|
|
82
|
+
and write a `decision: 'error'` audit entry, instead of exiting 0 (fail-open).
|
|
83
|
+
Opt-in legacy behaviour available via `SUNAIVA_GATE_FAIL_OPEN_ON_ERROR=1`.
|
|
84
|
+
- **C6** — Malformed input now exits with code **4** and writes a
|
|
85
|
+
`decision: 'invalid_input'` audit entry, instead of exiting 0 (fail-open).
|
|
86
|
+
Same opt-in escape hatch as C5.
|
|
87
|
+
- **C7** — Ship Confidence Gate behaviour is no longer an unbacked README claim;
|
|
88
|
+
it is the `ship_confidence_check` MCP tool plus the `--ship-confidence` CLI
|
|
89
|
+
flag, with audit entries tagged `tier: "paid" | "free"`.
|
|
90
|
+
|
|
91
|
+
### Tests
|
|
92
|
+
- 30/30 backend-client + version-consistency tests pass.
|
|
93
|
+
- 18/18 ship-confidence-gate Python parity tests pass (TypeScript port).
|
|
94
|
+
- 19/19 ship-confidence-gate TypeScript port tests pass.
|
|
95
|
+
- Bundle invariant assertions confirm 32 constitutional rules + 68 premium
|
|
96
|
+
stubs in the published tarball.
|
|
97
|
+
|
|
98
|
+
### Migration from 1.0.x
|
|
99
|
+
- **`1.0.0` and `1.0.1` were never production-ready** and are deprecated on npm
|
|
100
|
+
with the message:
|
|
101
|
+
`"PREVIEW BUILD - DO NOT USE. Use @sunaiva/gate@1.1.0 for the production-ready release."`
|
|
102
|
+
- Drop-in upgrade: bump the dependency to `1.1.0`. No MCP config changes
|
|
103
|
+
required. The MCP server name (`sunaiva-gate`) and tool surface are backward
|
|
104
|
+
compatible — only new tools are added.
|
|
105
|
+
- If you were depending on the 1.0.x fail-open exit code for malformed input,
|
|
106
|
+
set `SUNAIVA_GATE_FAIL_OPEN_ON_ERROR=1` to restore the legacy behaviour.
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
## [1.0.1] — UNRELEASED
|
|
111
|
+
|
|
112
|
+
Iteration build. Not published to npm. Superseded by 1.1.0.
|
|
113
|
+
|
|
114
|
+
The signed Ship-Confidence verdict on this commit
|
|
115
|
+
(`01KRDBCEYF2CAB21G6Y3E9VVH5`, RED) flagged 7 CRITICAL gaps between the
|
|
116
|
+
README's promises and the actual implementation. All seven are closed in 1.1.0.
|
|
117
|
+
Roadmap detail: [`ROADMAP_1_1_0.md`](./ROADMAP_1_1_0.md).
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
## [1.0.0] — 2026-05-10 — DEPRECATED
|
|
122
|
+
|
|
123
|
+
First publish-to-npm. Deprecated immediately on the npm registry per the
|
|
124
|
+
runbook in [`PUBLISH_RUNBOOK.md`](./PUBLISH_RUNBOOK.md).
|
|
125
|
+
|
|
126
|
+
### Deprecated
|
|
127
|
+
- npm deprecation message:
|
|
128
|
+
`"PREVIEW BUILD - DO NOT USE. Missing tests, support paths, verification commands. Use @sunaiva/gate@1.1.0 for the production-ready release."`
|
|
129
|
+
|
|
130
|
+
### What was missing
|
|
131
|
+
- `dist/rules/rules.json` not bundled — constitutional rules loaded from
|
|
132
|
+
`~/.sunaiva/rules.json` only (C1).
|
|
133
|
+
- Constitutional rules disable-able via `update_rules` (C2).
|
|
134
|
+
- Constitutional rules bypass-able via `log_bypass` (C3).
|
|
135
|
+
- Premium rules silently dropped with no audit count or user notice (C4).
|
|
136
|
+
- Fail-open on unhandled exceptions (C5).
|
|
137
|
+
- Fail-open on malformed input (C6).
|
|
138
|
+
- Ship Confidence Gate behaviour absent from the npm surface (C7).
|
|
139
|
+
|
|
140
|
+
See [`ROADMAP_1_1_0.md`](./ROADMAP_1_1_0.md) for the full finding-by-finding
|
|
141
|
+
work plan that produced 1.1.0.
|
|
142
|
+
|
|
143
|
+
---
|
|
144
|
+
|
|
145
|
+
*Format: [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) ·
|
|
146
|
+
Versioning: [Semantic Versioning](https://semver.org/spec/v2.0.0.html) ·
|
|
147
|
+
License: [BUSL-1.1](./BUSINESS_LICENSE.md) (Change Date 2030-05-10, Change
|
|
148
|
+
License Apache-2.0).*
|
package/LICENSE
CHANGED
|
File without changes
|