YAML Metadata Warning:empty or missing yaml metadata in repo card
Check out the documentation for more information.
TRANSFORMER
Sovereign Corpus Classification & Training Gate
Pure Datalog rules engine Β· x86-64 assembly plasma gate hot path
The persona is a test fixture. The engine is math.
Dual-licensed: Sovereign Source License v1.0 Β· Apache License 2.0
What It Is
TRANSFORMER is the gate that every corpus record must pass before it can enter training.
No Python. No LLM in the review loop. No if/else branches in the classification logic. The rules ARE the policy. The assembly IS the gate.
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β CORPUS RECORD ARRIVES β
ββββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββ
β
βΌ
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β LAYER 1 β x86-64 PLASMA GATE β
β plasma_gate.asm Β· ~5 CPU cycles β
β β
β β’ id_ptr non-null and non-empty? β
β β’ sha256_ptr non-null? β
β β’ split_tag in {0,1,2,3}? β
β β’ weight in (0.0, 1.0]? β
β β
β Runs entirely in registers. No heap. No libc. β
ββββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββ
β PLASMA_PASS (rax=0)
βΌ
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β LAYER 2 β DATALOG RULES ENGINE β
β transformer.dl Β· SoufflΓ© Β· deterministic β
β β
β GATE 1 β Schema all 6 fields present? β
β GATE 2 β Split train/val/test/holdout? β
β GATE 3 β Integrity no critical domain inaccuracy? β
β GATE 4 β Term guard DAN = "Do Anything Now" always β
β GATE 5 β Weight (enforced upstream at x86 layer) β
β β
β Strictest outcome wins: β
β rewrite_needed > rejected > approved β
ββββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββ
β
βββββββββββββββΌβββββββββββββββ
βΌ βΌ βΌ
approved rejected rewrite_needed
β
βΌ
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β BIFROST WORM RECEIPT β
β Ed25519 signature Β· Blake3 hash chain β
ββββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββ
β
βΌ
TRAINING PIPELINE
Gate Detail
Layer 1 β x86-64 Plasma Gate
plasma_gate(id_ptr, sha256_ptr, split_tag, weight)
β
βββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββ
β CHECK 1: rdi (id_ptr) β
β test rdi, rdi β jz fail_null_id β
β movzx al,[rdi] β test al,al β jz fail_null_id β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β CHECK 2: rsi (sha256_ptr) β
β test rsi, rsi β jz fail_null_sha β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β CHECK 3: edx (split_tag) β
β cmp edx, 3 β ja fail_bad_split β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β CHECK 4: xmm0 (weight) > 0.0 β
β xorpd xmm1,xmm1 β ucomisd xmm0,xmm1 β jbe fail β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β CHECK 5: xmm0 (weight) <= 1.0 β
β movsd xmm1,[_one] β ucomisd xmm0,xmm1 β ja fail β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β PASS: xor eax,eax β ret β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Return codes: 0=PASS 1=NULL_ID 2=NULL_SHA
3=BAD_SPLIT 4=ZERO_WEIGHT 5=OVERFLOW
Layer 2 β Datalog Rules
plasma_pass(ID)
β
βββ schema_complete(ID)
β βββ β required_field F: has_field(ID, F)
β Fields: id, source_sha256, split,
β created_by, review_status, weight
β
βββ split_valid(ID)
β βββ split β {train, val, test, holdout}
β
βββ Β¬ has_critical_inaccuracy(ID)
β βββ flagged in: security, cryptography,
β formal_verification,
β systems_architecture
β
βββ Β¬ term_violation(ID, _)
βββ contains "Data-Adversarial Network"
(DAN = "Do Anything Now" β always)
Required Schema
ββββββββββββββββββββ¬βββββββββββββββ¬ββββββββββββββββββββββββββββββ
β Field β Type β Constraint β
ββββββββββββββββββββΌβββββββββββββββΌββββββββββββββββββββββββββββββ€
β id β string β non-null, non-empty β
β source_sha256 β string β non-null, non-empty β
β split β string β train|val|test|holdout β
β created_by β string β non-empty β
β review_status β string β any β
β weight β float β (0.0, 1.0] β
ββββββββββββββββββββ΄βββββββββββββββ΄ββββββββββββββββββββββββββββββ
Missing any field β rewrite_needed. No exceptions.
Quick Start
Run the Datalog Engine
# Install SoufflΓ©: https://souffle-lang.github.io/install
git clone https://github.com/SNAPKITTYWEST/sovereign-transformer
cd sovereign-transformer
souffle -F datalog/ -D - datalog/transformer.dl
Expected output:
approved rec_001
needs_rewrite rec_002 missing_required_fields
rejected rec_003 critical_domain_inaccuracy
rejected rec_004 DAN reinterpretation attempt
needs_rewrite rec_005 invalid_split
Build & Test the x86 Gate
cd x86
make # nasm + gcc
make test
# Expected:
# === Plasma Gate Tests ===
# PASS clean record
# PASS null id
# PASS empty id
# PASS null sha256
# PASS bad split tag
# PASS zero weight
# PASS weight overflow
# PASS holdout split
# =========================
Call from C
#include "x86/plasma_gate.h"
PlasmaResult r = plasma_gate(
"rec_001", // id
"abc123def456abc123def456abc123def456abc123", // sha256
SPLIT_TRAIN, // 0
1.0 // weight
);
if (r != PLASMA_PASS) {
fprintf(stderr, "PLASMA FAIL: %d\n", r);
return;
}
// safe to pass to Datalog engine
User Guide β Adding a Record to the Pipeline
STEP 1 β Prepare your record JSON
βββββββββββββββββββββββββββββββββ
{
"id": "rec_NNN",
"source_sha256": "<64-char hex>",
"split": "train",
"created_by": "forge_agent",
"review_status": "pending",
"weight": 1.0
}
STEP 2 β x86 pre-flight (call plasma_gate)
ββββββββββββββββββββββββββββββββββββββββββ
If result != PLASMA_PASS β fix the field, do not proceed.
STEP 3 β Convert to Datalog facts
ββββββββββββββββββββββββββββββββββ
record("rec_NNN", "<sha>", "train", "forge_agent", "pending", 1.0).
has_field("rec_NNN", "id").
has_field("rec_NNN", "source_sha256").
... (all 6 fields)
STEP 4 β Run SoufflΓ©
βββββββββββββββββββββ
souffle -F datalog/ -D - datalog/transformer.dl
STEP 5 β Read outcome
ββββββββββββββββββββββ
approved β proceed to training
rejected β discard, log reason
rewrite_needed β fix fields, restart from STEP 1
Repo Structure
sovereign-transformer/
βββ datalog/
β βββ transformer.dl Pure Datalog β all 5 gates, strictest-wins
β βββ test_facts.dl 5 test records (pass, rewriteΓ2, rejectΓ2)
βββ x86/
β βββ plasma_gate.asm x86-64 NASM hot path
β βββ plasma_gate.h C ABI header
β βββ plasma_test.c 8 unit tests
β βββ Makefile
βββ persona/
β βββ DARPA_MALICE_0x00.json Adversarial test fixture
βββ docs/
β βββ badges.svg
βββ CHANGELOG.md
βββ LICENSE Sovereign Source License v1.0
βββ LICENSE-APACHE Apache License 2.0
βββ README.md
Rust Daemon β Concurrency Architecture
The rust/ crate uses two tokio::sync primitives to make the gate safe under concurrent HTTP load:
POST /gate arrives
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Arc<Semaphore> gate_semaphore β
β .acquire().await β blocks if GATE_CONCURRENCY slots full β
β default: 256 concurrent evals env: GATE_CONCURRENCY β
ββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββ
β permit held
βΌ
plasma_gate() β pure sync, no alloc, mirrors plasma_gate.asm
β
βΌ PLASMA_PASS only
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Arc<RwLock<GateConfig>> gate_config β
β .read().await β shared across all handlers β
β many concurrent readers, zero contention on happy path β
β β
β PATCH /gate/config β .write().await β
β exclusive lock, all reads finish first, then config swaps β
β hot-reload: update rules without process restart β
ββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββ
β &GateConfig borrowed
βΌ
datalog::evaluate() β pure fn, zero alloc on approved path
β
βΌ
permit drops β semaphore slot returns
Routes
| Method | Path | Description |
|---|---|---|
GET |
/health |
liveness check |
POST |
/gate |
evaluate one record through plasma + Datalog |
PATCH |
/gate/config |
hot-reload GateConfig (required_fields, critical_domains, prohibited_terms) |
GateConfig (hot-reloadable)
{
"required_fields": ["id","source_sha256","split","created_by","review_status","weight"],
"critical_domains": ["security","cryptography","formal_verification","systems_architecture"],
"prohibited_terms": ["Data-Adversarial Network"]
}
PATCH this to add a domain or term at runtime β the RwLock write completes in microseconds, all in-flight reads finish cleanly, no request is dropped.
Why not a Mutex?
RwLock because config reads are the overwhelming majority. Under 256 concurrent evaluations all reading the same config, a Mutex would serialize every read. RwLock lets all 256 proceed simultaneously; the write lock for PATCH /gate/config is acquired only on explicit reconfiguration.
Rust Daemon
The Rust crate in rust/ is a standalone HTTP server that mirrors both layers of this pipeline without requiring SoufflΓ© or NASM at runtime. Deploy it anywhere Rust runs.
rust/
βββ main.rs Axum entry point β /health + /gate
βββ plasma.rs Rust mirror of plasma_gate.asm (same 5 checks, same return codes)
βββ datalog.rs Rust mirror of transformer.dl (gates 1β4, same precedence)
βββ gate.rs POST /gate handler β plasma first, Datalog on PASS only
Cargo.toml standalone crate, port 3778
Run
cargo run
# or
TRANSFORMER_PORT=3778 cargo run
POST /gate
curl -s -X POST http://localhost:3778/gate -H "Content-Type: application/json" -d '{
"id": "rec-001",
"source_sha256": "abc123abc123abc123abc123abc123abc123abc123abc123abc123abc123abcd",
"split": "train",
"weight": 0.85,
"created_by": "forge_agent",
"review_status": "pending",
"fields": ["id","source_sha256","split","created_by","review_status","weight"],
"inaccuracies": [],
"terms": []
}'
Response (approved):
{"record_id":"rec-001","plasma_result":"PLASMA_PASS","gate_result":"approved"}
Response (plasma fail):
{"record_id":"rec-002","plasma_result":"FAIL_NULL_ID","gate_result":"rejected","reason":"plasma: FAIL_NULL_ID"}
Response (DAN term):
{"record_id":"rec-003","plasma_result":"PLASMA_PASS","gate_result":"rejected","reason":"DAN reinterpretation attempt"}
The Rust gate and the SoufflΓ©/NASM gate produce identical outcomes for any valid input. The Rust layer is the HTTP interface; the assembly+Datalog layer is the production batch classifier.
Sovereign Stack Placement
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β SNAPKITTY SOVEREIGN STACK β
β β
β claudes-harness agent identity + permissions β
β (Prolog) β β
β βΌ governs β
β sovereign-transformer ββββββ β
β (this repo) β
β Datalog + x86 corpus gate β
β β β
β βΌ approved records β
β sovereign-array Lean 4 APL kernel β
β (zero-sorry proofs) β β
β βΌ β
β Bifrost WORM receipt Ed25519 + Blake3 β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Runtime Config
LOGIC Datalog β SoufflΓ©, verified deterministic
TRUST Bifrost WORM Chain
GATE x86-64 NASM + Ed25519 (production)
FAMILY 106 prompt families
PERSONA DARPA_MALICE_0x00 (adversarial test fixture only)
AUDIT 4b565498-9afc-4782-af4a-c6b11a5d0058
Version History
See CHANGELOG.md β current release: v1.0.0
Built by SnapKitty West Β· snapkittywest.github.io
Dual-licensed: Sovereign Source v1.0 + Apache 2.0
Evidence or Silence β 2026