SNAPKITTYWEST's picture
push from SNAPKITTYWEST/rowm-polymorphic-notebook
1d3f990 verified
|
Raw
History Blame Contribute Delete
10.8 kB

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:

  1. Notebook Instructions β†’ Surface-level operation requests (EmojiCode, HolyC, Ada, Python, JavaScript)
  2. Runtime Representations β†’ Executable states (Rust, Erlang, Lean 4 proof obligations)
  3. Proof Representations β†’ Formal verification goals (Lean 4, Agda theorems)
  4. Execution Events β†’ Runtime state transitions logged to WORM
  5. 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 β€” Versioning
  • shift_id: String β€” Unique shift identifier
  • shift_version: u32 β€” Shift-specific version
  • source_domain: String β€” Domain of origin
  • target_domain: String β€” Target domain
  • direction: String β€” "forward", "inverse", or "bidirectional"
  • value_type: String β€” "instruction", "decision", "event", "proof", "receipt", etc.
  • payload: Vec<u8> β€” CBOR-encoded canonical representation
  • invariant_set: Vec<String> β€” List of preserved invariants
  • required_permission: String β€” Authorization level required
  • source_hash: String β€” Blake3 hash of source
  • canonical_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)

  1. Parse source β†’ Validate syntax
  2. Validate source schema β†’ Check structural requirements
  3. Canonicalize β†’ Produce deterministic ISIR
  4. Identify shift β†’ Look up M1–M8 mapping
  5. Query Prolog β†’ Check authorization facts and rules
  6. Validate schema compatibility β†’ Verify domain/codomain match
  7. Execute bounded transformation β†’ Apply adapter with timeout
  8. Validate target β†’ Check output schema
  9. Verify invariants β†’ Confirm all invariants preserved
  10. Generate evidence β†’ Produce manifest and receipt
  11. Commit transaction (if applicable) β†’ Atomic append to ledger
  12. 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 registered
  • logic/domains.pl β€” Domain definitions with types and constraints
  • logic/schemas.pl β€” Schema versions and compatibility rules
  • logic/invariants.pl β€” Preserved invariants per shift
  • logic/shift_authorization.pl β€” Authorization rules
  • logic/shift_validity.pl β€” Validity checking rules
  • logic/semantic_equivalence.pl β€” Semantic preservation rules
  • logic/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 normalization
  • m2_canonical_to_logic.rs β€” Canonical to logic term serialization
  • m3_logic_to_runtime.rs β€” Authorized logic decision to runtime command
  • m4_proof_to_verifier.rs β€” Proof obligation to verifier invocation
  • m5_event_to_logic.rs β€” Execution event to logic event fact
  • m6_event_to_receipt.rs β€” Execution event to receipt record
  • m7_notebook_to_logic.rs β€” Notebook cell to logic cell fact
  • m8_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 validated
  • validated β€” Canonical form generated, shift identified
  • authorized β€” Prolog authorization successful
  • transformed β€” Adapter executed successfully
  • invariants_checked β€” All invariants verified
  • committed β€” Transaction written to ledger (if applicable)
  • receipted β€” Receipt WORM-sealed
  • rejected β€” 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:

  1. Manifest β€” Metadata about the shift (source, target, timestamp, adapters used)
  2. Receipt β€” WORM-sealed proof of execution
  3. Invariant Proof β€” Evidence that all invariants were preserved
  4. Authorization Log β€” Prolog query results proving authorization
  5. 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

  1. Define domain types and constraints (domains.pl, domains.schema.json)
  2. Implement M1–M8 adapters with round-trip verification
  3. Register shifts in Prolog (shifts.pl)
  4. Implement authorization rules (shift_authorization.pl)
  5. Build and test adapters
  6. Integrate with existing notebook/ledger systems
  7. 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)