File size: 12,163 Bytes
a2b0af0 cc034bf | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 | ---
license: other
license_name: non-ai-mpl-2.0
license_link: https://huggingface.co/Snapkitty/ruby-self-resonance/blob/main/LICENSE
tags:
- snapkitty
- october-2026-drop
- ruby
- sinatra
- wasm
- assembly
- permission-layer
- access-control
- cryptography
---
> Mirrored from [https://github.com/SNAPKITTYWEST/ruby-self-resonance](https://github.com/SNAPKITTYWEST/ruby-self-resonance) at commit `0577129`. Part of the **SnapKitty October 2026 main drop**.
# Ruby Self-Resonance Stack
[](LICENSE)
[](https://www.ruby-lang.org/)
[](frontend/app.rb)
[](https://ahmadaliparr.github.io/ruby-self-resonance/)
[](docs/index.html)
[](ethical_guardrails.asm)
[](LICENSE)
**TheVoidIntent Systems β a coherence-based permission layer in Ruby, with two front ends: a live Sinatra dashboard and a zero-server WebAssembly playground on GitHub Pages.**
Instead of RBAC or OAuth, actions are permitted or denied by *thermodynamic alignment checks*. An intent core measures action coherence against a seeded intent vector. A resonance engine folds information into crystallization density at the orbital baseline frequency of **1/13 β 0.076923**. A deterministic policy draws the final boundary. Two x86-64 NASM modules implement the ethical guardrails and network containment in fixed-point integer arithmetic β no floating point anywhere near the guardrail path.
## Live demo
**[βΆ Open the WASM Playground](https://ahmadaliparr.github.io/ruby-self-resonance/)** β the repository's own `ruby_self_resonance.rb` running *in your browser*, compiled from Ruby 3.2 to WebAssembly via [ruby.wasm](https://github.com/ruby/ruby.wasm). Authorize actions, fold information, watch density climb toward Ξ£. No server, no install.

*The Sinatra dashboard mid-demo: coherence 1.6763, density 3.8462 accumulating toward Ξ£ = 44.0, resonance frequency 1/13, and the append-only diary below.*

*The append-only field diary: initialization and a granted permission, with full payloads and microsecond timestamps.*
## Architecture
```mermaid
flowchart TB
subgraph RUBY["Ruby core (verbatim)"]
MK[MathKernel<br/>clamp Β· normalize Β· distance Β· cosine_similarity]
AV[ActionVector<br/>immutable, frozen]
DE[Decision<br/>allowed? Β· denied? Β· to_h]
FD[FieldDiary<br/>append-only, deep-frozen events]
IC[IntentSimCore<br/>intent Β· coherence Β· entropy Β· risk]
ME[MezquiaResonanceEngine<br/>creases Β· density Β· 1/13 Β· Ξ£=44.0]
CP[CoherencePolicy<br/>deterministic permit?/explain]
PR[PermissionRuntime<br/>unified execution boundary]
MK --> IC
AV --> PR
FD --> IC
IC --> PR
ME --> PR
CP --> PR
PR --> DE
end
subgraph FRONT["Front ends (new)"]
SIN[Sinatra dashboard<br/>server-side Ruby]
WASM[WASM playground<br/>Ruby 3.2 in the browser]
end
subgraph ASM["x86-64 NASM (verbatim)"]
EG[ethical_guardrails<br/>fixed-point monitor]
NC[network_containment<br/>WARNING β TRUTHLOCK]
end
PR --> SIN
PR --> WASM
IC -.->|concept| FD
```
## The verbatim contract
Every file at the repo root is the author's code **exactly as supplied** β nothing rewritten, nothing "fixed," nothing redesigned. The only additions are SPDX license headers and the two front ends. Where the supplied code has observable behavior worth knowing, it is documented below under Honesty notes β not altered.
## Layout
| File | What it is |
|---|---|
| `lib/ruby_self_resonance.rb` | The complete stack: `MathKernel`, `ActionVector`, `Decision`, `FieldDiary`, `IntentSimCore`, `MezquiaResonanceEngine`, `CoherencePolicy`, `PermissionRuntime` β plus the author's example run |
| `lib/field_diary.rb` | `FieldDiary` (emotional-state creases: stable β seeking β crystallizing β dissonant β sovereign), `HRRCalculator` (HRR = (ΞEntropy/ΞTime) Γ 1/13), `IntegratedIntentSimEngine` |
| `lib/initialization_matrix.rb` | `ProgressiveInitializationMatrix` β the 44-stage boot sequence (field priming β intent alignment β coherence β sovereignty) |
| `lib/codex_absorber.rb` | `CodexAbsorber` β YAML intent-manifest ingestion β TypeScript/Python codegen |
| `lib/git_locksmith.rb` | `GitImmutabilityLocksmith` β SHA-256 file scan + sovereign-anchor check |
| `bin/resonance_repl.rb` | Interactive REPL (`init`, `fold`, `fold!`, `action`, `status`, `diary`, `threshold`, `reset`) |
| `asm/ethical_guardrails.asm` | x86-64 NASM ethical alignment monitor, fixed-point; demo runs EVT-001/002/003 |
| `asm/network_containment.asm` | x86-64 NASM containment module: WARNING β CONTAINMENT β TRUTHLOCK (exit 13) |
| `config/intent_manifest.yaml` | `void_nexus_override_01` sovereign alignment manifest |
| `Dockerfile`, `docker-compose.yml` | Multi-stage Ruby/Node build + isolated-network compose service |
| `docs/architecture.txt` | The module tree, as supplied |
| `frontend/` | **New:** Sinatra 4 dashboard (server-side) |
| `docs/` | **New:** GitHub Pages WASM playground (client-side, zero server); `docs/lib/` holds the byte-identical copy of the stack the playground evaluates |
## The resonance frequency
Every density, recovery-rate, and guardrail calculation in this system is anchored to one constant:
```
RESONANCE_CONSTANT = 1.0 / 13.0 β 0.076923
```
It appears as the HRR anchor (`HRRCalculator`), the crystallization gain per fold (`MezquiaResonanceEngine`), the fixed-point `RESONANCE_NUM/RESONANCE_DEN` in the NASM guardrails, and the `VOID_RESONANCE_INDEX=0.076923` in the Docker build. Both front ends surface it as a first-class readout β the **resonance frequency** card β because it is the single number the whole stack breathes at.
## Front end 1 β Sinatra dashboard (server-side)
`frontend/` wires the verbatim `RubySelfResonance::PermissionRuntime` to the web:
- **Dashboard** (`GET /`) β live coherence score, emotional state, crystallization density vs Ξ£ = 44.0, the 1/13 frequency readout, sovereignty flag, diary count, active policy bounds.
- **Authorize** (`POST /authorize`) β submit name, vector, entropy cost, purpose, risk β a `Decision` (permitted/denied, with coherence, entropy Ξ, risk, reason).
- **Fold** (`POST /fold`) β grow density by (purpose / entropy) Γ 1/13 per fold; below Ξ£ the engine's designed `DissonanceOverride` surfaces as a status, not an error.
- **Diary** (`GET /diary`) β the full append-only event log.
- **Reset** (`POST /reset`) β reinitialize with the default intent.
Hand-authored CSS, no frameworks. Default intent is `[1.0, 0.8, 0.6, 0.9]` (4-dimensional, matching the module's example); action vectors must match its dimensionality or the dashboard reports the mismatch cleanly.
```bash
cd frontend
gem install sinatra rackup puma # or: bundle install
rackup -p 4567 # β http://localhost:4567
```
## Front end 2 β WASM playground (GitHub Pages, zero server)
`docs/` is a static site (the Pages source) where the **actual `ruby_self_resonance.rb`** β the verbatim file, copied byte-for-byte β executes inside the visitor's browser:
1. `playground.js` streams `ruby+stdlib.wasm` (Ruby 3.2, β32 MB) from jsDelivr and boots it with the official `@ruby/wasm-wasi` browser runtime.
2. It fetches `docs/lib/ruby_self_resonance.rb` and `vm.eval`s it verbatim β including the author's example run, which executes live on load.
3. A `$playground` runtime is created; every button (authorize, fold, diary, reset) round-trips through real Ruby via JSON strings. No Ruby was rewritten for the browser β the same classes, the same constants, the same Ξ£.
Because it is fully static, it deploys to GitHub Pages with nothing to operate: enable Pages with source `docs/` on `main` and the playground is live.
## Verification record (measured 2026-10-02)
**Ruby core** β all six `.rb` files pass `ruby -c` on Ruby 3.2.3.
**Sinatra dashboard** β booted and every route exercised live:
- `GET /` β 200, dashboard renders real state
- `POST /authorize` with the example action β **PERMITTED** (`coherence_threshold_satisfied`)
- `POST /authorize` with a hostile vector (entropy 5.0, purpose 0.01, risk 0.99) β **DENIED**
- `POST /fold` Γ5 β density 3.8462, accumulating; below Ξ£ the designed dissonance status displays
- `GET /diary` β 200, events listed; `POST /reset` β 303, diary clean
- Screenshots above were captured from this live session
**WASM playground** β verified in two halves:
- *Ruby half:* the exact playground boot sequence (eval verbatim file, `state`, authorize permitted/denied, folds, diary, reset) executed under **real ruby.wasm** (Ruby 3.2.0 in WASM) β all checks pass, behavior identical to native Ruby
- *Browser half:* all DOM wiring (state cards, authorize β PERMITTED, fold results, bad-vector error, reset) tested against a stubbed VM in headless Chromium β 9/9 pass, zero page errors
- The CDN URLs (`browser.script.iife.js`, `ruby+stdlib.wasm` @ 2.3.0) and the `DefaultRubyVM` API were verified against the official ruby.wasm release artifacts
**NASM modules** β both assemble clean (`nasm -f elf64`, `ld`) and run as their headers describe:
- `ethical_guardrails`: EVT-001/002 clear the guardrails (under sovereign-override warning); EVT-003 (drift 1.32 > 1.13 max) rejected β `[HALT]`, exit 1
- `network_containment`: WARNING β CONTAINMENT β TRUTHLOCK, exits 13
**Supporting modules** β `CodexAbsorber` ingests `intent_manifest.yaml` (`void_nexus_override_01`); `GitImmutabilityLocksmith` scans SHA-256 and matches its sovereign anchor; `FieldDiary#record_crease` records/filters correctly.
## Honesty notes
- `ruby_self_resonance.rb` calls `Time#iso8601`, which lives in Ruby's `time` stdlib and is not loaded by default β running the file standalone raises `NoMethodError`. The Sinatra app requires `time` in *its own* file; the WASM playground prepends `require "time"` at eval time. The supplied file is untouched.
- `IntegratedIntentSimEngine#process_agent_tick` references `RESONANCE_CONSTANT`, which is defined on `HRRCalculator`, not on the engine β calling it raises `NameError`. Preserved verbatim, as supplied.
- `GitImmutabilityLocksmith#fetch_latest_commit_hash` returns a hardcoded hash (its own comments say it is mocking the git layer); the SHA-256 file scan itself is real.
- The `Dockerfile` references `package.json`, `ethical_guardrails.ts`, `runtime_pipeline.ts`, and `network_alert.ts`, which were not part of the supplied material β preserved as written.
- `docs/lib/ruby_self_resonance.rb` is a byte-identical copy of the `lib/` file, kept so the static Pages site can fetch it. The `lib/` file is canonical.
- The WASM playground streams its Ruby binary from jsDelivr at page load (β32 MB first visit, then cached). The Sinatra dashboard needs no such download.
## License
NON-AI Mozilla Public License 2.0 β see [LICENSE](LICENSE). Section 3.6 prohibits using this software to train or improve machine-learning systems. No commercial license is offered; there is no dual licensing.
### πΌ Commercial License
This repository is published under **NON-AI Mozilla Public License 2.0**. Building a commercial product or service? A **proprietary commercial license** from Snapkitty Collective LLC lets you ship this code on terms other than the NON-AI Mozilla Public License 2.0.
**[β Get a commercial license](mailto:A.parr@belespritdaccord.uk?subject=Commercial%20license:%20ruby-self-resonance)** Β· A.parr@belespritdaccord.uk
|