speclock 4.5.7 → 5.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 CHANGED
@@ -8,13 +8,15 @@
8
8
  <a href="https://www.npmjs.com/package/speclock"><img src="https://img.shields.io/npm/v/speclock.svg?style=flat-square&color=4F46E5" alt="npm version" /></a>
9
9
  <a href="https://www.npmjs.com/package/speclock"><img src="https://img.shields.io/npm/dm/speclock.svg?style=flat-square&color=22C55E" alt="npm downloads" /></a>
10
10
  <a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square" alt="MIT License" /></a>
11
- <a href="https://modelcontextprotocol.io"><img src="https://img.shields.io/badge/MCP-31_tools-green.svg?style=flat-square" alt="MCP 31 tools" /></a>
11
+ <a href="https://modelcontextprotocol.io"><img src="https://img.shields.io/badge/MCP-39_tools-green.svg?style=flat-square" alt="MCP 39 tools" /></a>
12
12
  </p>
13
13
 
14
14
  <p align="center">
15
15
  <a href="https://sgroy10.github.io/speclock/">Website</a> · <a href="https://www.npmjs.com/package/speclock">npm</a> · <a href="https://smithery.ai/servers/sgroy10/speclock">Smithery</a> · <a href="https://github.com/sgroy10/speclock">GitHub</a>
16
16
  </p>
17
17
 
18
+ <p align="center"><strong>Developed by <a href="https://github.com/sgroy10">Sandeep Roy</a></strong> · Free &amp; Open Source (MIT License)</p>
19
+
18
20
  ---
19
21
 
20
22
  ```
@@ -30,7 +32,7 @@ AI: ⚠️ BLOCKED — violates lock "Never touch the auth system"
30
32
  Should I find another approach?
31
33
  ```
32
34
 
33
- **557 tests. 98% pass rate. 0 false positives across 5 domains. Gemini Flash hybrid for universal domain coverage.**
35
+ **940 tests. 99.4% pass rate. 0 false positives across 13 suites. Gemini Flash hybrid, Spec Compiler, Code Graph, Typed Constraints, Python SDK, ROS2 integration.**
34
36
 
35
37
  ---
36
38
 
@@ -235,7 +237,109 @@ Import and export policies between projects. Share constraint templates across y
235
237
 
236
238
  ---
237
239
 
238
- ## 31 MCP Tools
240
+ ## Spec Compiler (v5.0)
241
+
242
+ Paste a PRD, README, or architecture doc — SpecLock extracts all constraints automatically:
243
+
244
+ ```
245
+ Input: "We're building a fintech app. Use React and FastAPI.
246
+ Never touch the auth module. Response time must stay
247
+ under 200ms. Payments go through Stripe."
248
+
249
+ Output: 2 text locks:
250
+ - "Never touch the auth module"
251
+ - "Payments go through Stripe — don't change provider"
252
+ 1 typed lock:
253
+ - response_time_ms <= 200 (numerical)
254
+ 2 decisions:
255
+ - "Use React for frontend"
256
+ - "Use FastAPI for backend"
257
+ ```
258
+
259
+ Uses Gemini Flash by default ($0.01 per 1000 compilations). No API key needed for core SpecLock — only the compiler uses LLM. Falls back gracefully if no key is set.
260
+
261
+ ---
262
+
263
+ ## Code Graph (v5.0)
264
+
265
+ Live dependency graph of your codebase. Parses JS/TS/Python imports.
266
+
267
+ ```
268
+ $ speclock blast-radius src/core/memory.js
269
+
270
+ Direct Dependents: 8 files
271
+ Transitive Impact: 14 files (33% of codebase)
272
+ Max Depth: 4 hops
273
+ ```
274
+
275
+ **Lock-to-file mapping:** Lock "Never modify auth" → automatically maps to `src/api/auth.js`, `src/middleware/auth.js`, `src/utils/jwt.js`. No configuration needed.
276
+
277
+ **Module detection:** Groups files into logical modules, tracks inter-module dependencies, identifies critical paths.
278
+
279
+ ---
280
+
281
+ ## Typed Constraints (v5.0)
282
+
283
+ Real-time value and state checking for autonomous systems, IoT, robotics:
284
+
285
+ ```javascript
286
+ // Numerical: speed must be <= 2.0 m/s
287
+ { constraintType: "numerical", metric: "speed_mps", operator: "<=", value: 2.0 }
288
+
289
+ // Range: temperature must stay between 20-25°C
290
+ { constraintType: "range", metric: "temperature_c", min: 20, max: 25 }
291
+
292
+ // State: never go from armed → disarmed without approval
293
+ { constraintType: "state", metric: "system_mode", forbidden: [{ from: "armed", to: "disarmed" }] }
294
+
295
+ // Temporal: heartbeat must occur every 30 seconds
296
+ { constraintType: "temporal", metric: "heartbeat_s", operator: "<=", value: 30 }
297
+ ```
298
+
299
+ ---
300
+
301
+ ## Python SDK & ROS2 (v5.0)
302
+
303
+ ```bash
304
+ pip install speclock-sdk
305
+ ```
306
+
307
+ ```python
308
+ from speclock import ConstraintChecker
309
+ checker = ConstraintChecker(constraints)
310
+ result = checker.check({"metric": "speed_mps", "value": 3.5})
311
+ # → violation: speed exceeds 2.0 m/s limit
312
+ ```
313
+
314
+ **ROS2 Guardian Node:** Real-time constraint enforcement for robots. Subscribes to sensor topics, checks constraints at configurable rate, publishes violations, triggers emergency stop.
315
+
316
+ ---
317
+
318
+ ## REST API v2 (v5.0)
319
+
320
+ Real-time constraint checking for autonomous systems:
321
+
322
+ ```bash
323
+ # Single check
324
+ POST /api/v2/check-typed { metric, value, entity }
325
+
326
+ # Batch check (up to 100)
327
+ POST /api/v2/check-batch { checks: [...] }
328
+
329
+ # SSE streaming (real-time violations)
330
+ GET /api/v2/stream
331
+
332
+ # Spec Compiler
333
+ POST /api/v2/compiler/compile { text, autoApply }
334
+
335
+ # Code Graph
336
+ GET /api/v2/graph/blast-radius?file=src/core/memory.js
337
+ GET /api/v2/graph/lock-map
338
+ ```
339
+
340
+ ---
341
+
342
+ ## 39 MCP Tools
239
343
 
240
344
  <details>
241
345
  <summary><b>Memory</b> — goal, locks, decisions, notes, deploy facts</summary>
@@ -308,6 +412,30 @@ Import and export policies between projects. Share constraint templates across y
308
412
 
309
413
  </details>
310
414
 
415
+ <details>
416
+ <summary><b>Typed Constraints</b> — numerical, range, state, temporal (v5.0)</summary>
417
+
418
+ | Tool | What it does |
419
+ |------|-------------|
420
+ | `speclock_add_typed_lock` | Add typed constraint (numerical/range/state/temporal) |
421
+ | `speclock_check_typed` | Check proposed values against typed constraints |
422
+ | `speclock_list_typed_locks` | List all typed constraints |
423
+ | `speclock_update_threshold` | Update typed lock thresholds |
424
+
425
+ </details>
426
+
427
+ <details>
428
+ <summary><b>Spec Compiler & Code Graph</b> — NL→constraints, dependency analysis (v5.0)</summary>
429
+
430
+ | Tool | What it does |
431
+ |------|-------------|
432
+ | `speclock_compile_spec` | Compile natural language into structured constraints |
433
+ | `speclock_build_graph` | Build/refresh code dependency graph |
434
+ | `speclock_blast_radius` | Calculate blast radius of file changes |
435
+ | `speclock_map_locks` | Map locks to actual code files |
436
+
437
+ </details>
438
+
311
439
  ---
312
440
 
313
441
  ## CLI
@@ -380,7 +508,7 @@ The AI opens the file and sees:
380
508
  │ AI Tool (Claude Code, Cursor, Bolt.new...) │
381
509
  └────────────┬──────────────────┬──────────────────┘
382
510
  │ │
383
- MCP Protocol (31 tools) npm File-Based
511
+ MCP Protocol (39 tools) npm File-Based
384
512
  │ (SPECLOCK.md + CLI)
385
513
  │ │
386
514
  ┌────────────▼──────────────────▼──────────────────┐
@@ -429,15 +557,23 @@ The AI opens the file and sees:
429
557
  | Suite | Tests | Pass Rate | What it covers |
430
558
  |-------|------:|----------:|----------------|
431
559
  | Adversarial Conflict | 61 | 100% | Euphemisms, temporal evasion, compound sentences |
560
+ | Typed Constraints | 61 | 100% | Numerical, range, state, temporal validation |
432
561
  | Phase 4 (Multi-domain) | 91 | 100% | Fintech, e-commerce, IoT, healthcare, SaaS |
433
562
  | John (Indie Dev Journey) | 86 | 100% | 8-session Bolt.new build with 5 locks |
434
563
  | Sam (Enterprise HIPAA) | 124 | 100% | HIPAA locks, PHI, encryption, RBAC |
564
+ | Auth & Crypto | 114 | 100% | API keys, RBAC, AES-256 encryption |
565
+ | Audit Chain | 35 | 100% | HMAC-SHA256 chain integrity |
566
+ | Enforcement | 40 | 100% | Hard/advisory mode, overrides |
567
+ | Compliance Export | 50 | 100% | SOC 2, HIPAA, CSV formats |
568
+ | REST API v2 | 28 | 100% | Typed constraint endpoints, SSE |
569
+ | Spec Compiler | 24 | 100% | NL→constraints parsing, auto-apply |
570
+ | Code Graph | 33 | 100% | Import parsing, blast radius, lock mapping |
571
+ | Python SDK | 62 | 100% | pip install, constraint checking |
572
+ | ROS2 Guardian | 26 | 100% | Robot safety constraint enforcement |
435
573
  | Real-World Testers | 105 | 95% | 5 developers, 30+ locks, diverse domains |
436
- | Payment/Salary/PII | 35 | 100% | Cross-vocabulary: payroll, salary, compensation |
437
- | Claude Tester (G-Suite) | 55 | 95% | Independent AI tester, adversarial probing |
438
- | **Total** | **557** | **98%** | |
574
+ | **Total** | **940** | **99.4%** | **13 suites, 15 domains** |
439
575
 
440
- Tested across: fintech, e-commerce, IoT, healthcare, SaaS, gaming, biotech, aerospace, payments, payroll. All 11 Indian payment gateways detected (Razorpay, PayU, Cashfree, PhonePe, Paytm, CCAvenue, BillDesk, Instamojo, Juspay, Stripe, PayPal). Zero false positives on UI/cosmetic actions.
576
+ Tested across: fintech, e-commerce, IoT, healthcare, SaaS, gaming, biotech, aerospace, payments, payroll, robotics, autonomous systems. All 11 Indian payment gateways detected. Zero false positives on UI/cosmetic actions.
441
577
 
442
578
  ---
443
579
 
@@ -475,4 +611,4 @@ Built by **[Sandeep Roy](https://github.com/sgroy10)**
475
611
 
476
612
  ---
477
613
 
478
- <p align="center"><i>v4.5.7557 tests, 98% pass rate, 31 MCP tools, Gemini hybrid. Because remembering isn't enough.</i></p>
614
+ <p align="center"><i>v5.0.0940 tests, 99.4% pass rate, 39 MCP tools, Spec Compiler, Code Graph, Typed Constraints, Python SDK, ROS2, REST API v2. Because remembering isn't enough.</i></p>
package/package.json CHANGED
@@ -2,9 +2,9 @@
2
2
 
3
3
  "name": "speclock",
4
4
 
5
- "version": "4.5.7",
5
+ "version": "5.0.0",
6
6
 
7
- "description": "AI constraint engine stops AI from breaking what you locked. Semantic detection, Gemini LLM hybrid, 31 MCP tools, HMAC audit chain, RBAC, encryption, SOC 2/HIPAA compliance. Works with Claude Code, Cursor, Bolt.new, Lovable.",
7
+ "description": "AI Constraint Engine for autonomous systems governance. Spec Compiler (NL→constraints), Code Graph (blast radius, lock-to-file mapping), Typed constraints (numerical, range, state, temporal), REST API v2, Python SDK, ROS2 integration. 39 MCP tools, Gemini LLM hybrid, HMAC audit chain, RBAC, encryption, SOC 2/HIPAA compliance.",
8
8
 
9
9
  "type": "module",
10
10
 
package/src/cli/index.js CHANGED
@@ -117,7 +117,7 @@ function refreshContext(root) {
117
117
 
118
118
  function printHelp() {
119
119
  console.log(`
120
- SpecLock v4.5.7 — AI Constraint Engine (Gemini LLM + Policy-as-Code + SSO + Dashboard + Telemetry + Auth + RBAC + Encryption)
120
+ SpecLock v5.0.0 — AI Constraint Engine (Spec Compiler + Code Graph + Typed Constraints + Python SDK + ROS2 + REST API v2 + Gemini LLM + Policy-as-Code + Auth + RBAC + Encryption)
121
121
  Developed by Sandeep Roy (github.com/sgroy10)
122
122
 
123
123
  Usage: speclock <command> [options]