| # SnapKitty Workflow |
|
|
| **Complete specification-to-execution trace. Every step names an actual file.** |
|
|
| --- |
|
|
| ## The Actual Workflow |
|
|
| ``` |
| HyperKittyConstraintDSL.xml (specification) |
| β |
| ββββββββββββββββββββββββββββββββββββββββββββββββββββ |
| β β |
| xslt/constraint-dsl-to-rust.xsl hyperkitty_dsl/parser.py |
| (XSLT transform) (Python parser) |
| β β |
| β β |
| Rust source code HKGraph { nodes, edges, |
| - Agent struct constraints, entropy_bound } |
| - UniverseLedger.step() β |
| - validity_predicate( β |
| entropy_nats <= 0.20 constraint_graph_svg.py |
| proof_valid) - Kahn's topological sort |
| β - pipeline dict (execution order) |
| β - SVG visualization |
| cargo build β |
| β β |
| ββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββ |
| β |
| SovereignEntropyEngine |
| (entropy vector per token) |
| β |
| β |
| ConstraintPass.validate(entropy) |
| (entropy <= 0.20 gate) |
| β |
| pass? βββ€ββ fail? β HALT |
| β |
| MachineCodeSelector.select(entropy, result) |
| (maps entropy to x86-64 op) |
| β |
| β |
| SovereignVM.run(program) |
| β |
| β |
| WORM seal (SHA-256 append-only) |
| β |
| β |
| Result + receipt |
| ``` |
|
|
| --- |
|
|
| ## Phase-by-Phase Trace |
|
|
| ### Phase 1: Specification |
|
|
| **Input:** XML file in one of three schemas: |
| - `ConstraintGraph` (nodes, edges, DAG structure) |
| - `HyperKittyConstraintDSL` (full pipeline spec with agents, glyphs, entropy bounds) |
| - `SymbolicLedgerAlgebra` / `QLGFamily` (algebraic type specifications) |
|
|
| **Files produced:** XML file on disk |
|
|
| **Deterministic:** Yes (manually authored) |
|
|
| **Validated:** Not yet β validation happens at next stage |
|
|
| --- |
|
|
| ### Phase 2: Meta-Program Execution |
|
|
| **Input:** XML specification file |
|
|
| **Transformation A (XSLT):** |
| ``` |
| xslt/constraint-dsl-to-rust.xsl + HyperKittyConstraintDSL.xml |
| β [xsltproc or Saxon] |
| β UniverseLedger.rs (Rust source, AUTO-GENERATED comment) |
| ``` |
|
|
| The generated `validity_predicate`: |
| ```rust |
| pub fn validity_predicate(entry: &JournalEntry) -> bool { |
| entry.delta_a + entry.delta_e == entry.delta_l + entry.delta_r // balance |
| && entry.entropy_nats <= 0.20 // entropy bound |
| && entry.proof_valid // proof gate |
| } |
| ``` |
|
|
| The `0.20` comes from `<EntropyBound>` in the XML. Changing the XML changes the generated code. |
|
|
| **Transformation B (Python):** |
| ``` |
| hyperkitty_dsl/parser.py + HyperKittyConstraintDSL.xml |
| β HKGraph { nodes, edges, constraints, entropy_bound=0.20 } |
| ``` |
|
|
| **Transformation C (XSLT β C header):** |
| ``` |
| generated/generate-native-config.xsl + QUANTUM-KITTY XML |
| β native/include/hyperkitty/generated_config.h |
| /* GENERATED FILE β do not edit by hand */ |
| ``` |
|
|
| **Validated:** Yes (XSLT structural validation, entropy bound preservation baked in) |
|
|
| **Deterministic:** Yes (pure XSLT transforms) |
|
|
| --- |
|
|
| ### Phase 3: DAG Construction |
|
|
| **Input:** XML graph β Python parser output |
|
|
| **Program:** `sovereign-xml-compiler/constraint_graph_svg.py` |
|
|
| **Transformation:** |
| ```python |
| nodes, edges = _parse_graph_xml(xml_source) |
| pipeline = _topological_sort(nodes, edges) # Kahn's algorithm |
| # Raises ValueError if cycle detected |
| svg = _render_svg(nodes, edges, pipeline) |
| ``` |
|
|
| **Output:** |
| 1. `pipeline = ["input", "memory", "retrieval", "transform", "constraint", "proof", "output"]` |
| (the execution order β this IS the executable artifact) |
| 2. SVG visualization file |
|
|
| **Validated:** Cycle detection (raises if not a DAG) |
|
|
| **Deterministic:** Yes |
|
|
| --- |
|
|
| ### Phase 4: Entropy-Based Compilation |
|
|
| **Input:** String tokens (agent operations, kernel names) |
|
|
| **Program:** `sovereign-shadow-compiler/engine/entropy_engine.py` |
|
|
| ```python |
| engine = SovereignEntropyEngine(kernel_map) |
| entropy_vector = engine.calculate_entropy_vector(tokens) |
| # entropy_vector: List[complex] β one value per token |
| ``` |
|
|
| The entropy vector encodes the input as complex activations over a sparse shadow tree seeded with phase angles `exp(2Οi Β· idx/n)`. |
|
|
| **Validated:** |
| ```python |
| constraint = ConstraintPass() |
| result = constraint.validate(entropy) # checks each |e| <= threshold |
| ``` |
|
|
| **Deterministic:** Yes (same input, same phase angles, same output) |
|
|
| --- |
|
|
| ### Phase 5: Machine Code Selection |
|
|
| **Input:** Entropy vector + constraint result |
|
|
| **Program:** `sovereign-shadow-compiler/codegen/selector.py` |
|
|
| ```python |
| op = selector.select(entropy, result) |
| # maps abs(entropy.real) % len(KERNEL_MAP) β x86-64 opcode name |
| kernel_bytes = selector.emit(op) |
| # returns raw bytes for the selected operation |
| ``` |
|
|
| **KERNEL_MAP:** operations like `MOV`, `LOOP`, `HALT` |
| |
| **Output:** x86-64 byte sequence + operation name |
| |
| --- |
| |
| ### Phase 6: VM Execution |
| |
| **Input:** Machine program `[{"op": "MOV", "reg": "RDI", "imm": n}, {"op": "LOOP", ...}, {"op": "HALT"}]` |
| |
| **Program:** `sovereign-shadow-compiler/vm/sovereign_vm.py` |
| |
| **Output:** `vm_result` dict |
|
|
| --- |
|
|
| ### Phase 7: WORM Sealing |
|
|
| **Program:** `bob-orchestrator/core/bob.mjs` `worm.seal()` |
|
|
| ```javascript |
| const raw = JSON.stringify({ label, payload, meta, ts, prev }) |
| const seal = createHash('sha256').update(raw).digest('hex') |
| // prev = SHA-256 of previous event (or quantum seed hash for genesis) |
| ``` |
|
|
| **Six distinct WORM ledgers exist:** |
| | Ledger | Path | Records | |
| |--------|------|---------| |
| | Quantum swarm | `bob-orchestrator/data/quantum-swarm-worm.jsonl` | ANU seed + swarm collapse events | |
| | Tool API | `bob-orchestrator/data/tool-api-worm.jsonl` | Tool invocations | |
| | BOB FSM | `DEVFLOW-FINANCE/packages/sovereign-router/.bob-worm.jsonl` | Phase-by-phase execution + output hashes | |
| | Execution | `backend/.worm/execution-ledger.jsonl` | Every bash command + allowlist verdict | |
| | AVR kernel | `sov-kernel-monster/avr_cold_boot_ledger.jsonl` | QATAAUM cycle invariants | |
| | Agda proofs | `sov-kernel-monster/PHASE_3_WORM_ATTESTATION.jsonl` | Proof discharge events | |
|
|
| --- |
|
|
| ## BOB sovereignStep: Complete Trace |
|
|
| This is the most complete single-pipeline trace in the codebase. |
|
|
| **Input:** |
| ```json |
| { |
| "agentId": "...", |
| "task": "verify_claim", |
| "input": "...", |
| "lean4Theorem": "...", |
| "adaContractText": "..." |
| } |
| ``` |
|
|
| **Step 0:** ANU QRNG batch β `_quantumSeed` buffer (32 bytes) |
|
|
| **Step 1:** METATRON gate (`metatron.mjs`) β `permitted: true/false` |
| If `false`: immediate return, no WORM entry written |
|
|
| **Step 2:** `SHA-256(lean4Theorem)` β `proof_hash` |
| Theorem < 10 chars β freeze |
|
|
| **Step 3:** `SHA-256(adaContractText)` β `contract_hash` |
| ORACLE class β read-only (gateAdvance returns false) |
|
|
| **Step 4:** `worm.seal('BOB_STEP:{task}', step)` β step seal |
|
|
| **Step 5:** SSM injection vector construction (Float32Array[2048]): |
| ``` |
| dims 0β255: proof_hash bytes β [-1,1] |
| dims 256β511: contract_hash bytes β [-1,1] |
| dims 512β767: step WORM seal bytes β [-1,1] |
| dims 768β2047: ANU quantum seed bytes, 50/50 blended with METATRON cage |
| ``` |
|
|
| **Step 6:** Ada gate check (`ada.gateAdvance(class, injectionValid)`) |
|
|
| **Step 7:** SSM state update: |
| ``` |
| h(t) = 0.9Β·h(t-1) + 0.1Β·x_input + inject_normΒ·0.01 |
| ``` |
|
|
| **Step 8:** LLM call (Ollama, optional β continues if offline) |
|
|
| **Step 9:** `worm.seal('BOB_STEP_COMPLETE:{task}', result)` β final seal |
|
|
| **Return:** |
| ```json |
| { |
| "proof_hash": "...", |
| "contract_hash": "...", |
| "ssm_state": [...], |
| "worm_seal": "...", |
| "injection_vector": [...], |
| "llm_reply": "..." |
| } |
| ``` |
|
|
| --- |
|
|
| ## Where Does the DAG Enter? |
|
|
| The DAG enters at three points: |
|
|
| 1. **Specification:** `ConstraintGraph.xml` defines the DAG structure (which node types, which edges) |
| 2. **Compilation:** `constraint_graph_svg.py` applies Kahn's algorithm to the XML β produces the execution order |
| 3. **Governance:** `ICP-DAG.m` enforces that no execution happens without an authorized decision in the governance DAG |
|
|
| The compilation output (pipeline list) becomes the execution order for the Python constraint evaluator. |
|
|
| --- |
|
|
| ## Where Does SUBLEQ Enter? |
|
|
| Currently: independently. The SUBLEQ attention mechanism (`j-matrix-twin/subleq_attention.ijs`, `DEVFLOW-FINANCE/snapkitty-wasm/src/subleq_vm.rs`) is not yet wired into the main BOB workflow or the XSLT code generation pipeline. It exists as a separate experimental track. |
|
|
| **The missing integration point:** The SUBLEQ VM could replace the LLM call at Step 8 β activation vectors β SUBLEQ routing β context selection, feeding into the SSM state. This is the proposed architectural connection, not yet implemented. |
|
|
| --- |
|
|
| ## Reproducibility |
|
|
| | Component | Reproducible? | What's needed | |
| |-----------|:-------------:|---------------| |
| | SSM computation | β | `proof_hash`, `contract_hash`, `worm_seal`, `quantum_seed` (logged) | |
| | XSLT code generation | β | XML spec file + Saxon/xsltproc | |
| | Constraint validation | β | entropy vector (deterministic from input) | |
| | BOB FSM phases | β (hashes only) | `master_hex` + input β output hashes logged, not raw output | |
| | WORM chain | β | All inputs logged; chain is deterministic | |
| | LLM replies | β | Temperature and PRNG seed not logged | |
| | ANU QRNG seed | β | `master_hex` recorded in quantum-swarm-worm.jsonl | |
| | Quantum swarm temps | partial | `master_hex` logged; HKDF derivation deterministic from it | |
|
|
| **To reproduce a BOB step:** provide `master_hex` + input + `lean4Theorem` + `adaContractText` + prior agent state. The LLM reply will differ. |
|
|
| --- |
|
|
| ## Specification β Program Separation |
|
|
| SnapKitty does separate **what** from **how**, but the boundary is: |
|
|
| | Layer | What | Where | |
| |-------|------|-------| |
| | XML spec | Declares DAG structure, entropy bound, constraint expressions | `ConstraintGraph.xml`, `HyperKittyConstraintDSL.xml` | |
| | XSLT | Transforms declaration β implementation | `xslt/*.xsl` | |
| | Python parser | Turns declaration into runtime objects | `hyperkitty_dsl/parser.py` | |
| | Rust implementation | Compiled from generated source | `cargo build` | |
| | VM execution | Runs the selected machine code | `sovereign_vm.py` | |
|
|
| The separation is real but incomplete: the XSLT and Python parser both consume the same XML, but they produce independent outputs (Rust source vs. Python objects) that are not yet connected at runtime. |
|
|