Isomorphic Shift β Formal Translation & State Correspondence Layer
Repository: SnapKitty Collective
Status: IMPLEMENTATION IN PROGRESS
Authority: Datalog/Prolog source-of-truth
Governance Motto: EVIDENCE OR SILENCE
Mission
The Isomorphic Shift layer provides formally defined, bidirectional transformations connecting:
- Notebook Instructions β Surface-level operation requests (EmojiCode, HolyC, Ada, Python, JavaScript)
- Runtime Representations β Executable states (Rust, Erlang, Lean 4 proof obligations)
- Proof Representations β Formal verification goals (Lean 4, Agda theorems)
- Execution Events β Runtime state transitions logged to WORM
- Receipt Records β Immutable evidence of execution and authorization
Each mapping is:
- Bidirectional with verified round-trip laws
- Semantically preserving (meaning survives transformation)
- Authority-preserving (no unauthorized permission escalation)
- Invertible (unless explicitly rejected as unsupported)
- Classified by category (isomorphism, embedding, projection, normalization, serialization, etc.)
Core Principle: Round-Trip Laws
For every isomorphic shift M:
- Forward then Inverse:
inverse(forward(X)) = canonicalize(X) - Inverse then Forward:
forward(inverse(Y)) = canonicalize(Y) - Semantic Preservation:
meaning(X) = meaning(forward(X)) - Authority Preservation: Shifts must NOT increase permissions, proof status, or release status
Lossy transformations are explicitly rejected as non-isomorphic.
Eight Required Mappings (M1βM8)
| ID | Source Domain | Target Domain | Direction | Classification | Status |
|---|---|---|---|---|---|
| M1 | SurfaceInstruction | CanonicalInstruction | β | Normalization | Design |
| M2 | CanonicalInstruction | LogicTerm | β | Serialization | Design |
| M3 | AuthorizedLogicDecision | RuntimeCommand | β | Projection | Design |
| M4 | ProofObligation | VerifierInvocation | β | Embedding | Design |
| M5 | ExecutionEvent | LogicEventFact | β | Serialization | Design |
| M6 | ExecutionEvent | ReceiptRecord | β | Projection | Design |
| M7 | NotebookCellRecord | LogicCellFact | β | Serialization | Design |
| M8 | RuntimeSpecificValue | CanonicalValue | β | Normalization | Design |
Canonical Intermediate Representation (ISIR)
All shifts pass through a deterministic canonical form with fields:
schema_version: u32β Versioningshift_id: Stringβ Unique shift identifiershift_version: u32β Shift-specific versionsource_domain: Stringβ Domain of origintarget_domain: Stringβ Target domaindirection: Stringβ "forward", "inverse", or "bidirectional"value_type: Stringβ "instruction", "decision", "event", "proof", "receipt", etc.payload: Vec<u8>β CBOR-encoded canonical representationinvariant_set: Vec<String>β List of preserved invariantsrequired_permission: Stringβ Authorization level requiredsource_hash: Stringβ Blake3 hash of sourcecanonical_hash: Stringβ Blake3 hash of canonical form (deterministic)parent_receipt_hash: Option<String>β Ancestry chain
Canonical encoding: Deterministic CBOR (RFC 7049) with canonical item ordering.
Authority Protocol (12-Step Sequence)
- Parse source β Validate syntax
- Validate source schema β Check structural requirements
- Canonicalize β Produce deterministic ISIR
- Identify shift β Look up M1βM8 mapping
- Query Prolog β Check authorization facts and rules
- Validate schema compatibility β Verify domain/codomain match
- Execute bounded transformation β Apply adapter with timeout
- Validate target β Check output schema
- Verify invariants β Confirm all invariants preserved
- Generate evidence β Produce manifest and receipt
- Commit transaction (if applicable) β Atomic append to ledger
- Append receipt β WORM-seal the result
Datalog/Prolog Integration
Source-of-truth authority: All shifts, domains, schemas, authorizations, and permissions are registered as Prolog facts.
Required files:
logic/shifts.plβ All isomorphic shifts registeredlogic/domains.plβ Domain definitions with types and constraintslogic/schemas.plβ Schema versions and compatibility ruleslogic/invariants.plβ Preserved invariants per shiftlogic/shift_authorization.plβ Authorization ruleslogic/shift_validity.plβ Validity checking ruleslogic/semantic_equivalence.plβ Semantic preservation ruleslogic/shift_release.plβ Release-readiness rules
Prohibition: Isomorphic Shift MUST NOT maintain independent copies of:
- Capabilities or revocations
- Proof verification status
- Release status
- Authorization decisions
All queries flow through Prolog.
Implementation Stack
Rust Adapters (adapters/)
m1_surface_to_canonical.rsβ Surface instruction normalizationm2_canonical_to_logic.rsβ Canonical to logic term serializationm3_logic_to_runtime.rsβ Authorized logic decision to runtime commandm4_proof_to_verifier.rsβ Proof obligation to verifier invocationm5_event_to_logic.rsβ Execution event to logic event factm6_event_to_receipt.rsβ Execution event to receipt recordm7_notebook_to_logic.rsβ Notebook cell to logic cell factm8_value_normalization.rsβ Runtime value to canonical value
Each adapter implements:
pub fn forward(source: &Source) -> Result<Target, ShiftError>
pub fn inverse(target: &Target) -> Result<Source, ShiftError>
pub fn verify_round_trip(source: &Source) -> Result<bool, ShiftError>
Logic Engine (logic/)
- Facts: Shift definitions, domain definitions, schema versions
- Rules: Authorization, validity checking, semantic equivalence
- Queries: shift_available/1, shift_permitted/3, round_trip_verified/2
- Tests: Logic-level tests for rule correctness
Tests (tests/)
- RoundTrip: ForwardβInverseβcanonicalize, InverseβForwardβcanonicalize
- SemanticPreservation: Meaning, types, authority survive
- Authority: No permission escalation, no proof status change
- Failure: Malformed rejected, unsupported versions rejected, lossy mappings rejected
- Logic: Unregistered shifts denied, unauthorized agents denied, contradictions detected
Transaction Model
States
preparedβ Source parsed, schema validatedvalidatedβ Canonical form generated, shift identifiedauthorizedβ Prolog authorization successfultransformedβ Adapter executed successfullyinvariants_checkedβ All invariants verifiedcommittedβ Transaction written to ledger (if applicable)receiptedβ Receipt WORM-sealedrejectedβ Operation denied (authorization, validation, or semantic failure)failedβ Adapter timeout, malformed target, or other runtime error
Atomicity
- Commit all or nothing
- Failed stages β automatic rollback
Idempotency
- Same transaction ID + canonical input β returns existing result from ledger
Evidence Bundle
All completed shifts produce:
- Manifest β Metadata about the shift (source, target, timestamp, adapters used)
- Receipt β WORM-sealed proof of execution
- Invariant Proof β Evidence that all invariants were preserved
- Authorization Log β Prolog query results proving authorization
- Test Results β Round-trip verification evidence
Restrictions
β NO additional sub-agents
β NO destructive repository operations
β NO deletion of existing Isomorphic Shift artifacts
β NO Git history rewriting
β NO replacing functioning implementations without evidence
β NO self-authorized runtime mutations
β NO isomorphism claims without verified inverse behavior
β NO completion reports based on scaffolding
Directories
isomorphic-shift/
βββ README.md (this file)
βββ schemas/
β βββ domains.schema.json
β βββ canonical.schema.json
β βββ shift.schema.json
β βββ receipt.schema.json
βββ logic/
β βββ shifts.pl
β βββ domains.pl
β βββ schemas.pl
β βββ invariants.pl
β βββ shift_authorization.pl
β βββ shift_validity.pl
β βββ semantic_equivalence.pl
β βββ shift_release.pl
β βββ tests/
βββ adapters/
β βββ lib.rs
β βββ m1_surface_to_canonical.rs
β βββ m2_canonical_to_logic.rs
β βββ m3_logic_to_runtime.rs
β βββ m4_proof_to_verifier.rs
β βββ m5_event_to_logic.rs
β βββ m6_event_to_receipt.rs
β βββ m7_notebook_to_logic.rs
β βββ m8_value_normalization.rs
β βββ tests/
βββ proofs/
β βββ round_trip_laws.lean
β βββ semantic_preservation.lean
β βββ authority_preservation.lean
βββ tests/
β βββ round_trip_tests.rs
β βββ semantic_preservation_tests.rs
β βββ authority_tests.rs
β βββ failure_tests.rs
β βββ logic_integration_tests.rs
βββ evidence/
β βββ manifests/
β βββ receipts/
β βββ invariant_proofs/
βββ docs/
βββ architecture.md
βββ mapping-catalog.md
βββ invariants.md
βββ source-of-truth-integration.md
βββ threat-model.md
βββ limitations.md
Next Steps
- Define domain types and constraints (domains.pl, domains.schema.json)
- Implement M1βM8 adapters with round-trip verification
- Register shifts in Prolog (shifts.pl)
- Implement authorization rules (shift_authorization.pl)
- Build and test adapters
- Integrate with existing notebook/ledger systems
- Generate evidence bundle
References
- LOC Agent: DEVFLOW-FINANCE/snapkitty-core/src/agents/loc_agent.rs (Triad execution)
- Sovereign Kernel: bob-orchestrator/prolog/sovereign_kernel.pl (Authorization logic)
- Bifrost Transform: DEVFLOW-FINANCE/collectivekitty/lib/bifrost/transform.ts (Event transformation pattern)
- EmojiCode Mapping: EmojiCode β HolyC/Ada/Rust/Haskell (loc_agent.rs emoji_map)
- Notebook: DEVFLOW-FINANCE/sovereign_notebook.ipynb (Triad pipeline trace)