aisp-validator 0.2.1 → 0.2.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.
Files changed (3) hide show
  1. package/README.md +153 -43
  2. package/bin/cli.js +2 -2
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -1,20 +1,49 @@
1
1
  # AISP Validator
2
2
 
3
- Validate [AISP 5.1](../AI_GUIDE.md) documents with <2% ambiguity using a <10KB WASM kernel.
3
+ [![npm version](https://img.shields.io/npm/v/aisp-validator.svg)](https://www.npmjs.com/package/aisp-validator)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
5
+
6
+ **Validate AI Symbolic Protocol (AISP) 5.1 documents** with <2% ambiguity using a lightweight <10KB WASM kernel.
7
+
8
+ AISP is a formal specification language designed for AI-to-AI communication, providing precise, unambiguous specifications that eliminate interpretation errors.
9
+
10
+ ## Installation
11
+
12
+ ```bash
13
+ npm install aisp-validator
14
+ ```
15
+
16
+ Or run directly with npx:
17
+
18
+ ```bash
19
+ npx aisp-validator validate your-spec.aisp
20
+ ```
4
21
 
5
22
  ## Quick Start
6
23
 
7
- ### CLI
24
+ ### CLI Usage
8
25
 
9
26
  ```bash
10
- # Validate a file
27
+ # Validate a document
11
28
  npx aisp-validator validate spec.aisp
12
29
 
13
- # Get quality tier
30
+ # Get quality tier (◊⁺⁺, ◊⁺, ◊, ◊⁻, ⊘)
14
31
  npx aisp-validator tier spec.aisp
15
32
 
16
33
  # Get density score
17
34
  npx aisp-validator density spec.aisp
35
+
36
+ # Debug - detailed density breakdown
37
+ npx aisp-validator debug spec.aisp
38
+ ```
39
+
40
+ **Example output:**
41
+ ```
42
+ ✓ VALID
43
+ Tier: ◊⁺⁺ Platinum
44
+ Semantic (δ): 1.000
45
+ Pure (ρ): 1.857
46
+ Ambiguity: 0.010
18
47
  ```
19
48
 
20
49
  ### Node.js
@@ -25,7 +54,7 @@ import AISP from 'aisp-validator';
25
54
  await AISP.init();
26
55
 
27
56
  const result = AISP.validate(`
28
- 𝔸1.0.example@2026-01-14
57
+ 𝔸1.0.example@2026-01-15
29
58
  γ≔test
30
59
 
31
60
  ⟦Ω:Meta⟧{ ∀D:Ambig(D)<0.02 }
@@ -36,40 +65,52 @@ const result = AISP.validate(`
36
65
  `);
37
66
 
38
67
  console.log(result);
39
- // { valid: true, tier: '◊⁺⁺', delta: 0.78, ambiguity: 0.01 }
68
+ // {
69
+ // valid: true,
70
+ // tier: '◊⁺⁺',
71
+ // tierName: 'Platinum',
72
+ // delta: 0.82,
73
+ // pureDensity: 1.85,
74
+ // ambiguity: 0.01
75
+ // }
40
76
  ```
41
77
 
42
78
  ### Browser
43
79
 
44
80
  ```html
45
81
  <script type="module">
46
- import AISP from './browser/loader.js';
82
+ import AISP from 'aisp-validator/browser';
47
83
 
48
- await AISP.init('/wasm/aisp.wasm');
84
+ await AISP.init('/path/to/aisp.wasm');
49
85
 
50
- const result = AISP.validate(document);
86
+ const result = AISP.validate(documentSource);
51
87
  console.log(result.tier); // '◊⁺⁺'
52
88
  </script>
53
89
  ```
54
90
 
55
- ## API
91
+ ## API Reference
56
92
 
57
93
  ### `AISP.init(wasmPath?)`
58
- Initialize the WASM kernel. Call once before validation.
94
+ Initialize the WASM kernel. Must be called once before validation.
59
95
 
60
96
  ### `AISP.validate(source)`
61
97
  Validate an AISP document. Returns:
62
98
  ```javascript
63
99
  {
64
- valid: boolean, // true if valid
65
- tier: string, // '⊘' | '◊⁻' | '◊' | '◊⁺' | '◊⁺⁺'
66
- tierValue: number, // 0-4
67
- delta: number, // density δ [0, 1]
68
- ambiguity: number, // [0, 1], must be <0.02
69
- errorCode: number // 0 = success
100
+ valid: boolean, // true if document passes validation
101
+ tier: string, // '⊘' | '◊⁻' | '◊' | '◊⁺' | '◊⁺⁺'
102
+ tierName: string, // 'Reject' | 'Bronze' | 'Silver' | 'Gold' | 'Platinum'
103
+ tierValue: number, // 0-4 (numeric tier)
104
+ delta: number, // Semantic density δ [0, 1]
105
+ pureDensity: number, // Pure density ρ (symbols/tokens)
106
+ ambiguity: number, // [0, 1], must be <0.02
107
+ errorCode: number // 0 = success
70
108
  }
71
109
  ```
72
110
 
111
+ ### `AISP.debug(source)`
112
+ Get detailed density breakdown for debugging.
113
+
73
114
  ### `AISP.isValid(source)`
74
115
  Quick check: returns `true` if valid.
75
116
 
@@ -77,39 +118,92 @@ Quick check: returns `true` if valid.
77
118
  Returns tier symbol: `'◊⁺⁺'`, `'◊⁺'`, `'◊'`, `'◊⁻'`, or `'⊘'`
78
119
 
79
120
  ### `AISP.getDensity(source)`
80
- Returns density score (δ) between 0 and 1.
121
+ Returns semantic density score (δ) between 0 and 1.
81
122
 
82
123
  ### `AISP.validateFile(path)` (Node.js only)
83
124
  Validate a file by path.
84
125
 
126
+ ### `AISP.debugFile(path)` (Node.js only)
127
+ Debug a file by path.
128
+
85
129
  ## Quality Tiers
86
130
 
87
- | Tier | Symbol | Threshold | Meaning |
88
- |------|--------|-----------|---------|
89
- | Platinum | ◊⁺⁺ | δ ≥ 0.75 | Production-ready |
90
- | Gold | ◊⁺ | δ ≥ 0.60 | High quality |
91
- | Silver | ◊ | δ ≥ 0.40 | Acceptable |
92
- | Bronze | ◊⁻ | δ ≥ 0.20 | Needs improvement |
93
- | Reject | ⊘ | δ < 0.20 | Insufficient AISP |
131
+ | Tier | Symbol | Threshold | Use Case |
132
+ |------|--------|-----------|----------|
133
+ | **Platinum** | ◊⁺⁺ | δ ≥ 0.75 | Production deployment |
134
+ | **Gold** | ◊⁺ | δ ≥ 0.60 | Staging/pre-production |
135
+ | **Silver** | ◊ | δ ≥ 0.40 | Development/testing |
136
+ | **Bronze** | ◊⁻ | δ ≥ 0.20 | Draft/review |
137
+ | **Reject** | ⊘ | δ < 0.20 | Insufficient quality |
138
+
139
+ ## Density Metrics
140
+
141
+ ### Semantic Density (δ)
142
+ Measures specification completeness:
143
+ ```
144
+ δ = (blockScore × 0.4) + (bindingScore × 0.6)
145
+ ```
146
+ - **blockScore**: Required blocks present (⟦Ω⟧, ⟦Σ⟧, ⟦Γ⟧, ⟦Λ⟧, ⟦Ε⟧)
147
+ - **bindingScore**: Semantic operators (≜, ≔, ∀, ∃, λ, ⇒, ∈, etc.)
148
+
149
+ ### Pure Density (ρ)
150
+ Measures symbol concentration:
151
+ ```
152
+ ρ = |AISP_symbols| ÷ |non_ws_tokens|
153
+ ```
94
154
 
95
155
  ## Required AISP Blocks
96
156
 
97
- Every valid AISP document must include:
157
+ Every valid AISP document must include these 5 blocks:
158
+
159
+ | Block | Name | Purpose |
160
+ |-------|------|---------|
161
+ | `⟦Ω⟧` | Meta | Metadata and constraints |
162
+ | `⟦Σ⟧` | Types | Type definitions |
163
+ | `⟦Γ⟧` | Rules | Inference rules |
164
+ | `⟦Λ⟧` | Funcs | Function definitions |
165
+ | `⟦Ε⟧` | Evidence | Quality metrics |
166
+
167
+ ## Example AISP Document
168
+
169
+ ```aisp
170
+ 𝔸5.1.tic-tac-toe@2026-01-15
171
+ γ≔game-spec
172
+
173
+ ⟦Ω:Meta⟧{
174
+ ∀D∈AISP:Ambig(D)<0.02
175
+ Target≜AI-Agents
176
+ }
177
+
178
+ ⟦Σ:Types⟧{
179
+ Player≜{X,O}
180
+ Cell≜{Empty,X,O}
181
+ Board≜Cell[9]
182
+ }
183
+
184
+ ⟦Γ:Rules⟧{
185
+ ∀move:ValidMove(board,pos)⇔board[pos]=Empty
186
+ ∀win:WinCondition⇔∃line∈Lines:∀c∈line:c=player
187
+ }
188
+
189
+ ⟦Λ:Funcs⟧{
190
+ makeMove≜λ(board,pos,player).board[pos]←player
191
+ checkWin≜λboard.∃p∈Player:WinCondition(board,p)
192
+ }
98
193
 
99
- - `⟦Ω⟧` - Meta/foundation
100
- - `⟦Σ⟧` - Type definitions
101
- - `⟦Γ⟧` - Inference rules
102
- - `⟦Λ⟧` - Functions
103
- - `⟦Ε⟧` - Evidence
194
+ ⟦Ε⟧⟨δ≜0.75;φ≜100;τ≜◊⁺⁺⟩
195
+ ```
104
196
 
105
197
  ## Building from Source
106
198
 
199
+ The validator includes full Rust source code:
200
+
107
201
  ```bash
108
202
  # Prerequisites
109
203
  rustup target add wasm32-unknown-unknown
110
- npm install -g binaryen
204
+ cargo install wasm-opt # or: npm install -g binaryen
111
205
 
112
- # Build
206
+ # Build WASM kernel
113
207
  cd wasm
114
208
  ./build.sh
115
209
 
@@ -118,19 +212,35 @@ cd wasm
118
212
 
119
213
  ## Architecture
120
214
 
121
- The validator uses a Rust WASM kernel based on dependent type theory:
215
+ - **WASM Kernel**: Zero-allocation Rust core (<10KB)
216
+ - **Type System**: Based on dependent type theory
217
+ - **Symbol Table**: AISP Σ_512 glossary (50+ formal symbols)
218
+ - **Validation**: Structural + semantic analysis
122
219
 
123
- - **Zero-allocation**: Arena-based memory, no heap
124
- - **Type checking**: Based on lean-agentic
125
- - **Symbol table**: AISP Σ_512 glossary
126
- - **Density computation**: AISP symbol ratio
220
+ ## What is AISP?
127
221
 
128
- ## License
222
+ **AI Symbolic Protocol (AISP)** is a formal specification language designed for precise AI-to-AI communication. Key benefits:
223
+
224
+ - **<2% Ambiguity**: Eliminates interpretation errors
225
+ - **Formal Semantics**: Based on type theory and logic
226
+ - **Machine-Readable**: Designed for AI agents
227
+ - **Human-Auditable**: Clear structure for review
129
228
 
130
- MIT License - see [LICENSE](./LICENSE)
229
+ Learn more:
230
+ - [AI Guide](https://github.com/bar181/aisp-open-core/blob/main/AI_GUIDE.md) - Complete AISP specification
231
+ - [Human Guide](https://github.com/bar181/aisp-open-core/blob/main/HUMAN_GUIDE.md) - Human-readable introduction
232
+ - [Reference (Rosetta Stone)](https://github.com/bar181/aisp-open-core/blob/main/reference.md) - Symbol glossary
131
233
 
132
234
  ## Links
133
235
 
134
- - [AISP 5.1 Specification](../AI_GUIDE.md)
135
- - [Reference (Rosetta Stone)](../reference.md)
136
- - [Repository](https://github.com/bar181/aisp-open-core)
236
+ - **GitHub**: [github.com/bar181/aisp-open-core](https://github.com/bar181/aisp-open-core)
237
+ - **npm**: [npmjs.com/package/aisp-validator](https://www.npmjs.com/package/aisp-validator)
238
+ - **Issues**: [Report bugs](https://github.com/bar181/aisp-open-core/issues)
239
+
240
+ ## License
241
+
242
+ MIT License - see [LICENSE](https://github.com/bar181/aisp-open-core/blob/main/validator/LICENSE)
243
+
244
+ ---
245
+
246
+ **Made for AI agents, auditable by humans.**
package/bin/cli.js CHANGED
@@ -9,7 +9,7 @@ import { readFile } from 'fs/promises';
9
9
  import { existsSync } from 'fs';
10
10
 
11
11
  const HELP = `
12
- AISP Validator v0.2.1 - Validate AISP 5.1 documents
12
+ AISP Validator v0.2.2 - Validate AISP 5.1 documents
13
13
 
14
14
  Usage:
15
15
  aisp-validator <command> [file]
@@ -52,7 +52,7 @@ async function main() {
52
52
  }
53
53
 
54
54
  if (args[0] === '--version' || args[0] === '-v') {
55
- console.log('aisp-validator v0.2.1');
55
+ console.log('aisp-validator v0.2.2');
56
56
  process.exit(0);
57
57
  }
58
58
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aisp-validator",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "AISP 5.1 document validator - validates AI Symbolic Protocol specifications with <2% ambiguity",
5
5
  "main": "src/index.js",
6
6
  "bin": {