Skip to content

Commit dc3082c

Browse files
Jonathan D.A. Jewellclaude
andcommitted
feat: integrate proven library for formally verified safety
Integrates the proven library (SafeMath, SafeString, SafeHex, SafePath) for formally verified safety operations throughout the codebase. Changes: - Types.res: Use SafeMath.inRangeExcluding for byte validation - Bindings.res: Use SafeHex.encodeSpaced for hex display - Bindings.res: Use SafeString.toCodePoints/fromCodePoints for conversions - Bindings.res: Use SafePath.isSafe for path traversal prevention - main.js: Add path validation in UI with real-time feedback New files: - src/proven/: Local copy of proven library modules - src/Types.res: Centralized type definitions - index.html: Phosphor-green terminal UI - src/main.js: Vanilla JS UI with state management - kernel/striker.fth: Forth kernel for substrate operations - vite.config.js: Vite build configuration - deno.json: Deno runtime configuration - rescript.json: ReScript compiler configuration Build: ReScript compiles, Vite builds (8.47KB JS, 6.43KB CSS) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 8fb9dbd commit dc3082c

29 files changed

Lines changed: 4291 additions & 70 deletions

Justfile

Lines changed: 120 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ set positional-arguments := true
99
# Project metadata
1010
project := "dotmatrix-fileprinter"
1111
version := "1.0.0"
12-
tier := "infrastructure"
12+
tier := "infrastructure"
13+
14+
# Gforth is in toolbox
15+
gforth := "toolbox run gforth"
1316

1417
# ═══════════════════════════════════════════════════════════════════════════════
1518
# DEFAULT & HELP
@@ -23,36 +26,112 @@ default:
2326
info:
2427
@echo "Project: {{project}}"
2528
@echo "RSR Tier: {{tier}}"
29+
@echo "Version: {{version}}"
2630
@echo "Phase: $(just state-phase)"
31+
@echo ""
32+
@echo "Stack:"
33+
@echo " Neural: ReScript + TEA"
34+
@echo " Symbolic: Nickel"
35+
@echo " Physical: Forth (Gforth)"
36+
@echo " Bridge: Tauri 2.0 (Rust)"
2737

2838
# ═══════════════════════════════════════════════════════════════════════════════
29-
# BUILD & STRIKE (Project Specific)
39+
# DEVELOPMENT
3040
# ═══════════════════════════════════════════════════════════════════════════════
3141

32-
# Build the Neuro-Symbolic pipeline (ReScript + Tauri/Rust)
33-
build:
42+
# Install dependencies (run once)
43+
setup:
44+
@echo "Checking dependencies..."
45+
@command -v deno >/dev/null || (echo "ERROR: Deno not found. Install from https://deno.land" && exit 1)
46+
@toolbox run command -v gforth >/dev/null || (echo "WARNING: Gforth not found in toolbox. Install with: toolbox run sudo dnf install gforth" && exit 0)
47+
@command -v cargo >/dev/null || (echo "ERROR: Rust/Cargo not found. Install from https://rustup.rs" && exit 1)
48+
@echo "Installing npm packages via Deno..."
49+
@deno install
50+
@echo "Setup complete!"
51+
52+
# Start development server (hot-reload)
53+
dev:
54+
@echo "Starting development server..."
55+
@deno task dev
56+
57+
# Build ReScript only
58+
build-res:
3459
@echo "Compiling Neural Layer (ReScript)..."
35-
@rescript build
36-
@echo "Compiling Physical Host (Tauri)..."
37-
@cargo tauri build
60+
@deno run -A npm:rescript build
61+
62+
# Build frontend (ReScript + Vite)
63+
build-frontend:
64+
@echo "Building frontend..."
65+
@deno task build
66+
67+
# Build Tauri app (full release)
68+
build: build-frontend
69+
@echo "Building Tauri application..."
70+
@cd src-tauri && cargo build --release
71+
@echo "Build complete: src-tauri/target/release/{{project}}"
72+
73+
# Run Tauri in development mode
74+
tauri-dev: build-res
75+
@echo "Starting Tauri development mode..."
76+
@cargo tauri dev
77+
78+
# ═══════════════════════════════════════════════════════════════════════════════
79+
# FORTH KERNEL
80+
# ═══════════════════════════════════════════════════════════════════════════════
3881

39-
# Execute a Deterministic Byte-Strike using the Golden Prompt
40-
# Usage: just strike "104,101,108,108,111"
41-
strike bytes: build
42-
@echo "Initiating Forth Strike Sequence..."
43-
@./src-tauri/target/release/{{project}} --strike "{{bytes}}"
82+
# Test the Forth kernel directly
83+
test-forth:
84+
@echo "Testing Forth kernel..."
85+
@cd {{justfile_directory()}} && {{gforth}} kernel/striker.fth -e 'test-strike bye'
86+
@echo ""
87+
@echo "Verifying output..."
88+
@hexdump -C test.bin
89+
@rm -f test.bin
90+
91+
# Interactive Forth session
92+
forth-repl:
93+
@echo "Starting Forth REPL (type 'bye' to exit)..."
94+
@cd {{justfile_directory()}} && {{gforth}} kernel/striker.fth
95+
96+
# Execute a Deterministic Byte-Strike via Forth directly
97+
# Usage: just strike-direct "72,101,108,108,111" output.bin
98+
strike-direct bytes output="dist/substrate.bin":
99+
@echo "Preparing strike data..."
100+
@mkdir -p $(dirname {{output}})
101+
@echo "CREATE STRIKE-DATA {{bytes}} ," > kernel/data.fth
102+
@echo "Executing Forth strike..."
103+
@cd {{justfile_directory()}} && {{gforth}} kernel/striker.fth kernel/data.fth -e 's" {{output}}" strike-init STRIKE-DATA $(echo "{{bytes}}" | tr "," "\n" | wc -l) strike-sequence strike-close bye'
104+
@echo "Strike complete. Verifying..."
105+
@hexdump -C {{output}}
106+
107+
# ═══════════════════════════════════════════════════════════════════════════════
108+
# VERIFICATION
109+
# ═══════════════════════════════════════════════════════════════════════════════
44110

45111
# Verify the Physical Truth of the substrate (ASCII-clean, no 0xA0)
46112
verify target="dist/substrate.bin":
47113
@echo "Verifying Physical Byte Truth for {{target}}..."
48114
@hexdump -C {{target}}
49-
@if grep -obUP "\xa0" {{target}}; then \
115+
@echo ""
116+
@if grep -obUaP '\xa0' {{target}} 2>/dev/null; then \
50117
echo "FAIL: NBSP (0xA0) CONTAMINATION DETECTED"; \
51118
exit 1; \
119+
elif grep -obUaP '\xc2' {{target}} 2>/dev/null; then \
120+
echo "WARN: UTF-8 marker (0xC2) detected"; \
52121
else \
53122
echo "PASS: Substrate is ASCII-pure."; \
54123
fi
55124

125+
# Check for any non-ASCII bytes
126+
verify-strict target="dist/substrate.bin":
127+
@echo "Strict ASCII verification for {{target}}..."
128+
@if LC_ALL=C grep -P '[^\x00-\x7F]' {{target}} 2>/dev/null; then \
129+
echo "FAIL: Non-ASCII bytes detected"; \
130+
exit 1; \
131+
else \
132+
echo "PASS: File is strictly ASCII (0x00-0x7F)"; \
133+
fi
134+
56135
# ═══════════════════════════════════════════════════════════════════════════════
57136
# RSR COMPLIANCE & STATE
58137
# ═══════════════════════════════════════════════════════════════════════════════
@@ -93,8 +172,34 @@ container-build:
93172

94173
# Count lines of deterministic code
95174
loc:
96-
@find . \( -name "*.res" -o -name "*.fth" -o -name "*.rs" -o -name "*.ncl" \) | xargs wc -l | tail -1
175+
@echo "Lines of code by language:"
176+
@echo " ReScript: $(find . -name '*.res' -not -path './node_modules/*' | xargs wc -l 2>/dev/null | tail -1 | awk '{print $1}')"
177+
@echo " Forth: $(find . -name '*.fth' | xargs wc -l 2>/dev/null | tail -1 | awk '{print $1}')"
178+
@echo " Rust: $(find . -name '*.rs' | xargs wc -l 2>/dev/null | tail -1 | awk '{print $1}')"
179+
@echo " Nickel: $(find . -name '*.ncl' | xargs wc -l 2>/dev/null | tail -1 | awk '{print $1}')"
97180

98181
# Show TODOs in the substrate
99182
todos:
100-
@grep -rn "TODO\|FIXME" .
183+
@grep -rn "TODO\|FIXME" --include="*.res" --include="*.rs" --include="*.fth" --include="*.ncl" . 2>/dev/null || echo "No TODOs found"
184+
185+
# Clean build artifacts
186+
clean:
187+
@echo "Cleaning build artifacts..."
188+
@rm -rf dist/ node_modules/ .rescript/
189+
@rm -rf src-tauri/target/
190+
@rm -f kernel/data.fth test.bin
191+
@echo "Clean complete"
192+
193+
# Format all code
194+
fmt:
195+
@echo "Formatting code..."
196+
@deno run -A npm:rescript format src/*.res
197+
@cd src-tauri && cargo fmt
198+
@echo "Format complete"
199+
200+
# Check types without building
201+
check:
202+
@echo "Type checking..."
203+
@deno run -A npm:rescript build -- -warn-error +a
204+
@cd src-tauri && cargo check
205+
@echo "Type check complete"

deno.json

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"$schema": "https://deno.land/x/deno/cli/schemas/config-file.v1.json",
3+
"name": "@hyperpolymath/dotmatrix-fileprinter",
4+
"version": "1.0.0",
5+
"tasks": {
6+
"dev": "deno run -A npm:vite --host",
7+
"build": "deno run -A npm:rescript && deno run -A npm:vite build",
8+
"build:res": "deno run -A npm:rescript",
9+
"build:vite": "deno run -A npm:vite build",
10+
"preview": "deno run -A npm:vite preview",
11+
"check": "deno run -A npm:rescript format src/*.res && deno run -A npm:rescript",
12+
"tauri:dev": "deno task build:res && cargo tauri dev",
13+
"tauri:build": "deno task build && cargo tauri build",
14+
"test:forth": "gforth kernel/striker.fth -e 'test-strike bye'",
15+
"verify": "hexdump -C dist/substrate.bin"
16+
},
17+
"imports": {
18+
"@tauri-apps/api": "npm:@tauri-apps/api@^2",
19+
"@tauri-apps/plugin-dialog": "npm:@tauri-apps/plugin-dialog@^2",
20+
"@tauri-apps/plugin-fs": "npm:@tauri-apps/plugin-fs@^2",
21+
"@tauri-apps/plugin-shell": "npm:@tauri-apps/plugin-shell@^2",
22+
"rescript": "npm:rescript@^12.0.0",
23+
"@rescript/core": "npm:@rescript/core@^1.6.0",
24+
"@rescript/runtime": "npm:@rescript/runtime@^12.0.0",
25+
"vite": "npm:vite@^6.0.0"
26+
},
27+
"compilerOptions": {
28+
"lib": ["deno.window", "dom", "dom.iterable"],
29+
"jsx": "react-jsx",
30+
"jsxImportSource": "react"
31+
},
32+
"nodeModulesDir": "auto",
33+
"lint": {
34+
"include": ["src/"],
35+
"rules": {
36+
"tags": ["recommended"]
37+
}
38+
},
39+
"fmt": {
40+
"include": ["src/"],
41+
"indentWidth": 2,
42+
"singleQuote": false
43+
}
44+
}

0 commit comments

Comments
 (0)