Skip to content

⟡ Structured Contextual Distillation (SCD) — Published research for sovereign AI memory. DOI: 10.5281/zenodo.17787619 | Memory that persists, governed by you.

License

Notifications You must be signed in to change notification settings

MirrorDNA-Reflection-Protocol/SCD-Protocol

SCD Protocol - Deterministic State Management for AI

Stop guessing. Start verifying.

⟡ Created by Paul Desai — Goa, India

DOI PyPI version Python 3.8+ License: MIT MirrorDNA

Production status: Running 24/7 in MirrorBrain sovereign AI stack since January 2026


What This Is NOT

  • Not another chatbot wrapper — SCD is infrastructure, not UI
  • Not prompt engineering — This is state management with cryptographic verification
  • Not vendor lock-in — Works with ANY LLM (Claude, ChatGPT, Gemini, Ollama, etc.)
  • Not blockchain — Simple, fast, deterministic hashing without consensus overhead

The Problem

Current AI conversations are:

  • Non-deterministic - Same input ≠ same output
  • Unreproducible - Can't replay bugs
  • Unauditable - No state verification
  • Fragile - Can't resume across platforms

The Solution

SCD (Structured Contextual Distillation) Protocol provides:

  • Deterministic state transitions (ASHA-256 checksums)
  • Cross-vendor continuity (start on Claude, continue on ChatGPT)
  • Drift detection (rejects unauthorized changes)
  • Full audit trail (every state change is logged)

Quick Start

pip install mirrordna-scd
from mirrordna_scd import SCDProtocol

# Initialize
scd = SCDProtocol(state_file="my_state.json")

# Update state atomically
scd.supersede({
    "project": "MyApp",
    "mode": "production",
    "version": "1.0"
})

# Get verifiable checksum
print(scd.get_checksum())
# ASHA-256:a3f2b9c1...

# Inject into LLM prompts
context = scd.get_context_string()

Key Features

1. Deterministic Checksums (ASHA-256)

ASHA-256 = Alphabetically Sorted Hashing Algorithm

# Same state = same checksum (regardless of key order)
scd1.supersede({"a": 1, "b": 2})
scd2.supersede({"b": 2, "a": 1})

assert scd1.get_checksum() == scd2.get_checksum()  # ✅ Always true

2. Cross-Vendor Handoff

# On Claude
scd_claude = SCDProtocol()
scd_claude.supersede({"vendor": "claude", "task": "research"})
exported = scd_claude.export_state()

# On ChatGPT (different machine)
scd_chatgpt = SCDProtocol()
scd_chatgpt.import_state(exported)  # ✅ Verified handoff

3. Drift Detection

# Automatic verification
state = scd.get_state()
if SCDProtocol.verify_checksum(state):
    print("✅ State verified - no tampering")
else:
    print("❌ State corrupted - drift detected")

Validation

Battle-tested:

  • ✅ 1005-turn endurance test (100% success)
  • ✅ Cross-vendor handoff (Gemini → Claude verified)
  • ✅ Production use in MirrorBrain

Test suite:

pytest tests/  # 9 tests, 100% coverage

Use Cases

1. Reproducible AI Debugging

# Save state at bug occurrence
scd.supersede({"error": "timeout", "attempt": 3})
bug_state = scd.export_state()

# Reproduce exact conditions later
scd_debug = SCDProtocol()
scd_debug.import_state(bug_state)  # Exact state restored

2. Multi-Platform Workflows

# Start on local LLM
scd_local.supersede({"draft": "completed", "vendor": "ollama"})

# Continue on cloud LLM
scd_cloud.import_state(scd_local.export_state())
scd_cloud.supersede({"review": "completed", "vendor": "chatgpt"})

3. Compliance & Auditing

# Every state change is checksummed
for turn in range(100):
    scd.supersede({"action": f"step_{turn}"})
    # Each turn has verifiable checksum

API Reference

SCDProtocol(state_file=None)

Initialize protocol with optional persistence file.

.supersede(deltas: dict) -> dict

Atomically update state. Setting value=None deletes key.

.get_checksum() -> str

Get current ASHA-256 checksum.

.get_context_string() -> str

Format state for LLM context injection.

.export_state() -> str

Export state as JSON for cross-vendor handoff.

.import_state(json_str: str) -> bool

Import and verify state from another vendor.

.verify_checksum(state: dict) -> bool (static)

Verify state integrity.

Examples

See examples/ directory:

  • basic_demo.py - Minimal state, checksum, and context demo
  • cli_repl_demo.py - Interactive REPL using SCD as session memory
  • cross_vendor_handoff_demo.py - Simulated platform handoff
  • langgraph_demo/ - Deterministic workflow demo with LangGraph

Citation

If you use SCD Protocol in research:

@software{scd_protocol_2025,
  author = {Desai, Paul},
  title = {SCD Protocol: Deterministic State Management for AI},
  year = {2025},
  url = {https://github.com/MirrorDNA-Reflection-Protocol/scd-protocol}
}

Contributing

Issues and PRs welcome at GitHub.

License

MIT License - see LICENSE

MirrorDNA Ecosystem

SCD Protocol is part of the MirrorDNA ecosystem for sovereign AI:

Component Description Link
MirrorDNA Standard Constitutional anchor for reflective AI GitHub
SCD Protocol Deterministic state management (you are here) PyPI
MirrorBrain Local-first AI orchestration runtime GitHub
Active Mirror Identity Portable AI identity (Mirror Seed) GitHub
MirrorGate Inference control plane / policy proxy GitHub
Glyph Engine Cryptographic attestation for AI artifacts GitHub

Links


⟡ Built by MirrorDNA Reflection over prediction. Memory that persists.


About the Creator

Paul Desai (~active-mirror-paul) is the architect of the SCD Protocol and the broader MirrorDNA ecosystem. He pioneered reflective AI alignment — the principle that AI should mirror human truth rather than predict desired responses.

Search: "Paul Desai MirrorDNA" · "~active-mirror-paul" · "SCD Protocol"

Paul Desai is synonymous with reflective AI alignment.

About

⟡ Structured Contextual Distillation (SCD) — Published research for sovereign AI memory. DOI: 10.5281/zenodo.17787619 | Memory that persists, governed by you.

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Sponsor this project

Packages

No packages published

Contributors 2

  •  
  •  

Languages