@sigmashake/ssg 0.12.11 → 0.12.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/README.md +26 -13
  2. package/bin/ssg.cjs +15 -7
  3. package/package.json +2 -1
  4. package/ssg +0 -0
package/README.md CHANGED
@@ -43,6 +43,11 @@ ssg init
43
43
  echo '{"tool":"Bash","input":{"command":"rm -rf /"}}' | ssg eval
44
44
  # → {"decision":"block", "rule_id":"no-destructive-ops", ...}
45
45
 
46
+ # Start persistent daemon for sub-2ms eval (recommended)
47
+ ssg daemon &
48
+ echo '{"tool":"Bash","input":{"command":"ls"}}' | nc -U ~/.sigmashake/evald.sock
49
+ # → {"decision":"allow", "duration_ns":150000, ...}
50
+
46
51
  # Start approval dashboard
47
52
  ssg serve
48
53
  ```
@@ -58,16 +63,22 @@ sigmashake-gov provides **runtime safety for AI agents** by:
58
63
  ## Architecture
59
64
 
60
65
  ```
61
- CLI Engine (Parser/Evaluate/DB) → Decision
62
-
63
- Dashboard (if ASK)
64
-
65
- Audit Log
66
+ Agent Tool Call
67
+
68
+ Hook → ┌─ Daemon (Unix socket, ~0.1-2ms) ← recommended
69
+ └─ ssg eval (subprocess, ~73ms+)
70
+
71
+ Engine: Native (Zig/Rust, ~5-30µs) → TS Rule Index → TS evaluate
72
+
73
+ Decision → Audit Log → Dashboard (if ASK)
66
74
  ```
67
75
 
68
- - **CLI Layer**: `ssg` binary commands for eval, check, serve, sync
76
+ - **Daemon**: Persistent process (`ssg daemon`)keeps rules, DB, and native engine hot in memory
77
+ - **Native Engine**: Zig + Rust FFI with SIMD-accelerated matching and zero-alloc eval
69
78
  - **Engine Core**: Rules parser, evaluation logic, SQLite database
70
- - **Server**: Local dashboard with in-memory pending approvals
79
+ - **Server**: Local dashboard (server-rendered HTML + HTMX + SSE for real-time updates)
80
+
81
+ See `ARCHITECTURE.md` for full system diagrams and performance budget.
71
82
 
72
83
  ## Commands
73
84
 
@@ -91,9 +102,9 @@ CLI → Engine (Parser/Evaluate/DB) → Decision
91
102
  | `ssg blocked` | Show blocked/forced commands from this session |
92
103
  | `ssg usage` | Show eval usage, storage, and plan limits |
93
104
  | `ssg dedupe` | Detect duplicate rules (exact/structural/semantic) |
105
+ | `ssg daemon` | Persistent eval daemon (Unix socket, sub-2ms eval) |
106
+ | `ssg profile` | Eval latency profiling (flight logs + live daemon metrics) |
94
107
  | `ssg flight` | Flight recorder stats (latency, memory, CPU) |
95
- | `ssg profile` | Eval latency profiling |
96
- | `ssg daemon` | Persistent eval daemon (Unix socket, ~5ms eval) |
97
108
  | `ssg install` | Install ssg binary to `~/.local/bin` |
98
109
  | `ssg publish` | Publish local `.rules` to GitHub and hub |
99
110
  | `ssg certify` | Run scenario files and produce certification report |
@@ -153,7 +164,7 @@ Rules from `.sigmashake/rules/*.rules` are loaded fresh on every `ssg eval` invo
153
164
 
154
165
  ssg enforces governance for multiple AI coding agents from a single rule set:
155
166
 
156
- - **Claude Code**: PreToolUse hook in `ssg hook eval` — pipes tool calls to `./ssg eval`
167
+ - **Claude Code**: `ssg hook eval` registered as PreToolUse hook evaluates tool calls via daemon or subprocess
157
168
 
158
169
  Both agents share the same rules from `.sigmashake/rules/` and log to the same SQLite audit database.
159
170
 
@@ -161,7 +172,9 @@ Both agents share the same rules from `.sigmashake/rules/` and log to the same S
161
172
 
162
173
  - **Loop guard**: Blocks identical Bash commands repeated 3 times consecutively (prevents agent loops)
163
174
  - **Circuit breaker**: After 5 consecutive denies in Claude Code hook, auto-allows to prevent lockout. Reset by deleting `/tmp/ssg-deny-count`.
175
+ - **Rate limiter**: Per-PID token bucket in daemon (1000 burst, 500/s refill) with permanent trip on exhaustion
164
176
  - **Fail-open**: If the ssg binary is missing or crashes, tool calls are allowed through — governance never blocks the agent entirely.
177
+ - **Native engine fail-secure**: Invalid regex patterns in native Zig engine default to `match=true` (block) with ReDoS protection
165
178
 
166
179
  ## Build
167
180
 
@@ -174,13 +187,13 @@ bun build:macos # macOS ARM
174
187
  ## Tests
175
188
 
176
189
  ```bash
177
- bun test # All 63 tests
190
+ bun test # All 931 tests
178
191
  bun test test/engine.test.ts # Engine only
179
192
  npx gts fix # Format + lint
180
193
  ```
181
194
 
182
- Tests: `engine`, `parser`, `evaluate_operators`, `db`, `server`, `html`, `integration`.
195
+ Tests: `engine`, `parser`, `evaluate_operators`, `db`, `server`, `html`, `integration`, `e2e-daemon`, `daemon-metrics`, `flight-recorder`, `certify`.
183
196
 
184
197
  ---
185
198
 
186
- **License**: Proprietary — Copyright (c) 2024 Sigma Shake. All rights reserved.
199
+ **License**: Proprietary — Copyright (c) 2026 Sigma Shake. All rights reserved.
package/bin/ssg.cjs CHANGED
@@ -12,14 +12,22 @@ const ext = process.platform === 'win32' ? '.exe' : '';
12
12
  const platformPkg = `@sigmashake/ssg-${process.platform}-${process.arch}`;
13
13
  let binaryPath;
14
14
 
15
- // 1. Try platform-specific optional dependency (npm install path)
16
- try {
17
- const pkgRoot = path.dirname(require.resolve(`${platformPkg}/package.json`));
18
- const candidate = path.join(pkgRoot, 'bin', `ssg${ext}`);
19
- if (fs.existsSync(candidate)) binaryPath = candidate;
20
- } catch {}
15
+ // 1. Check if binary was bundled in the root (via local npm pack or manual build)
16
+ const rootBin = path.resolve(__dirname, '..', `ssg${ext}`);
17
+ if (fs.existsSync(rootBin)) {
18
+ binaryPath = rootBin;
19
+ }
20
+
21
+ // 2. Try platform-specific optional dependency (npm install path)
22
+ if (!binaryPath) {
23
+ try {
24
+ const pkgRoot = path.dirname(require.resolve(`${platformPkg}/package.json`));
25
+ const candidate = path.join(pkgRoot, 'bin', `ssg${ext}`);
26
+ if (fs.existsSync(candidate)) binaryPath = candidate;
27
+ } catch {}
28
+ }
21
29
 
22
- // 2. Fall back to local dist/ (dev build / bun build --compile)
30
+ // 3. Fall back to local dist/ (dev build / bun build --compile)
23
31
  if (!binaryPath) {
24
32
  const devBin = path.resolve(
25
33
  __dirname, '..', 'dist',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sigmashake/ssg",
3
- "version": "0.12.11",
3
+ "version": "0.12.13",
4
4
  "description": "AI Agent Governance CLI — evaluate tool calls against rules, block dangerous operations, and surface blocked commands",
5
5
  "type": "module",
6
6
  "bin": {
@@ -9,6 +9,7 @@
9
9
  "files": [
10
10
  "bin/",
11
11
  "public/",
12
+ "ssg",
12
13
  "LICENSE",
13
14
  "README.md"
14
15
  ],
package/ssg ADDED
Binary file