Spaces:
Runtime error
Runtime error
GitHub Copilot commited on
Commit ·
f94712a
1
Parent(s): 7d38f33
Protocol 45: Hex Dissolution & Suite Restoration
Browse files- logos/ingest/__init__.py +0 -0
- logos/ingest/dissolution.py +102 -0
- logos/logos_suite.py +75 -0
- logos_project +0 -1
logos/ingest/__init__.py
ADDED
|
File without changes
|
logos/ingest/dissolution.py
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import binascii
|
| 3 |
+
import numpy as np
|
| 4 |
+
import sympy
|
| 5 |
+
from collections import Counter
|
| 6 |
+
|
| 7 |
+
class DissolutionCore:
|
| 8 |
+
def __init__(self, chunk_size=1024):
|
| 9 |
+
"""
|
| 10 |
+
The 'Stomach' of LOGOS. Digests raw files into Mathematical Atoms.
|
| 11 |
+
chunk_size: How many bytes to process at once (The Bite Size).
|
| 12 |
+
Protocol 45: Hex Dissolution.
|
| 13 |
+
"""
|
| 14 |
+
self.chunk_size = chunk_size
|
| 15 |
+
|
| 16 |
+
# Pre-compute Prime Weights for all Byte values (0-255)
|
| 17 |
+
# This is a lookup table for "Semantic Gravity"
|
| 18 |
+
self.atom_weights = self._generate_atomic_weights()
|
| 19 |
+
|
| 20 |
+
def _generate_atomic_weights(self):
|
| 21 |
+
"""
|
| 22 |
+
Maps every possible Byte (00-FF) to its Greatest Prime Factor (GPF).
|
| 23 |
+
Ex: 'FF' (255) -> Factors: 3, 5, 17 -> GPF: 17
|
| 24 |
+
Ex: '07' (7) -> Factors: 7 -> GPF: 7
|
| 25 |
+
"""
|
| 26 |
+
weights = {}
|
| 27 |
+
for i in range(256):
|
| 28 |
+
if i < 2:
|
| 29 |
+
weights[i] = 0 # Null/Unity has no heat
|
| 30 |
+
else:
|
| 31 |
+
factors = sympy.primefactors(i)
|
| 32 |
+
weights[i] = max(factors)
|
| 33 |
+
return weights
|
| 34 |
+
|
| 35 |
+
def ingest_file(self, file_path):
|
| 36 |
+
"""
|
| 37 |
+
Reads a file and dissolves it into a Hex-Atom Stream.
|
| 38 |
+
Returns: A stream of 'Physical Atoms' ready for the Tension Web.
|
| 39 |
+
"""
|
| 40 |
+
if not os.path.exists(file_path):
|
| 41 |
+
raise FileNotFoundError(f"Target not acquired: {file_path}")
|
| 42 |
+
|
| 43 |
+
print(f">> [DISSOLVE] Initiating breakdown of: {os.path.basename(file_path)}")
|
| 44 |
+
|
| 45 |
+
hex_stream = []
|
| 46 |
+
heat_map = []
|
| 47 |
+
|
| 48 |
+
with open(file_path, 'rb') as f:
|
| 49 |
+
while True:
|
| 50 |
+
# 1. Read Binary
|
| 51 |
+
chunk = f.read(self.chunk_size)
|
| 52 |
+
if not chunk:
|
| 53 |
+
break
|
| 54 |
+
|
| 55 |
+
# 2. Convert to Integers (The Atoms)
|
| 56 |
+
# We work with Ints (0-255) because they map directly to Primes
|
| 57 |
+
atoms = list(chunk)
|
| 58 |
+
|
| 59 |
+
# 3. Calculate 'Heat' (GPF) for this chunk
|
| 60 |
+
chunk_heat = [self.atom_weights[a] for a in atoms]
|
| 61 |
+
|
| 62 |
+
# 4. Store (In production, this streams to the DB/Visualizer)
|
| 63 |
+
hex_stream.extend(atoms)
|
| 64 |
+
heat_map.extend(chunk_heat)
|
| 65 |
+
|
| 66 |
+
return self._analyze_residue(hex_stream, heat_map)
|
| 67 |
+
|
| 68 |
+
def _analyze_residue(self, atoms, heat):
|
| 69 |
+
"""
|
| 70 |
+
Produces the 'Meta-Tensor' report from the dissolved matter.
|
| 71 |
+
"""
|
| 72 |
+
total_atoms = len(atoms)
|
| 73 |
+
avg_heat = np.mean(heat) if heat else 0
|
| 74 |
+
entropy = self._calculate_shannon_entropy(atoms)
|
| 75 |
+
|
| 76 |
+
# Find the 'Dominant Resonance' (Most frequent Prime Weight)
|
| 77 |
+
if heat:
|
| 78 |
+
heat_counts = Counter(heat)
|
| 79 |
+
dominant_prime = heat_counts.most_common(1)[0][0]
|
| 80 |
+
else:
|
| 81 |
+
dominant_prime = 0
|
| 82 |
+
|
| 83 |
+
return {
|
| 84 |
+
"status": "DISSOLVED",
|
| 85 |
+
"total_atoms": total_atoms,
|
| 86 |
+
"system_entropy": f"{entropy:.4f}",
|
| 87 |
+
"average_heat": f"{avg_heat:.2f}",
|
| 88 |
+
"dominant_resonance": f"Prime {dominant_prime}",
|
| 89 |
+
"hex_preview": binascii.hexlify(bytearray(atoms[:16])).decode('utf-8').upper()
|
| 90 |
+
}
|
| 91 |
+
|
| 92 |
+
def _calculate_shannon_entropy(self, data):
|
| 93 |
+
"""
|
| 94 |
+
Standard entropy calculation to detect 'Noise' vs 'Signal'.
|
| 95 |
+
"""
|
| 96 |
+
if not data: return 0
|
| 97 |
+
counts = Counter(data)
|
| 98 |
+
probs = [count / len(data) for count in counts.values()]
|
| 99 |
+
return -sum(p * np.log2(p) for p in probs)
|
| 100 |
+
|
| 101 |
+
if __name__ == "__main__":
|
| 102 |
+
print("Dissolution Core v1.0")
|
logos/logos_suite.py
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import sys
|
| 2 |
+
import os
|
| 3 |
+
import time
|
| 4 |
+
|
| 5 |
+
# Ensure logos in path
|
| 6 |
+
# If running as script, parent dir needed
|
| 7 |
+
current_dir = os.path.dirname(os.path.abspath(__file__))
|
| 8 |
+
parent_dir = os.path.dirname(current_dir)
|
| 9 |
+
if parent_dir not in sys.path:
|
| 10 |
+
sys.path.insert(0, parent_dir)
|
| 11 |
+
|
| 12 |
+
def main_menu():
|
| 13 |
+
print("\n")
|
| 14 |
+
print("========================================")
|
| 15 |
+
print(" LOGOS STRATOS - MANIFOLD LAUNCHER ")
|
| 16 |
+
print("========================================")
|
| 17 |
+
print("1. Start Neural Router (Server)")
|
| 18 |
+
print("2. Launch MTL REPL (Interactive)")
|
| 19 |
+
print("3. Ingest File (Hex Dissolution)")
|
| 20 |
+
print("4. Exit")
|
| 21 |
+
print("========================================")
|
| 22 |
+
|
| 23 |
+
choice = input(">> Select Directive: ")
|
| 24 |
+
|
| 25 |
+
if choice == '1':
|
| 26 |
+
print(">> Igniting Neural Router...")
|
| 27 |
+
# Use subprocess to run module
|
| 28 |
+
os.system(f"{sys.executable} -m logos.server")
|
| 29 |
+
elif choice == '2':
|
| 30 |
+
print(">> Accessing Manifold REPL...")
|
| 31 |
+
try:
|
| 32 |
+
from logos.mtl.interpreter import MTLInterpreter
|
| 33 |
+
interpreter = MTLInterpreter()
|
| 34 |
+
print("MTL v33.0 Ready. (Type 'exit' to quit)")
|
| 35 |
+
while True:
|
| 36 |
+
code = input("mtl> ")
|
| 37 |
+
if code.lower() in ['exit', 'quit']: break
|
| 38 |
+
try:
|
| 39 |
+
res = interpreter.execute(code)
|
| 40 |
+
print(f"=> {res}")
|
| 41 |
+
except Exception as ex:
|
| 42 |
+
print(f"Error: {ex}")
|
| 43 |
+
except Exception as e:
|
| 44 |
+
print(f"REPL Error: {e}")
|
| 45 |
+
input("Press Enter...")
|
| 46 |
+
elif choice == '3':
|
| 47 |
+
print(">> [INGEST] Enter path to target file (Image/Video/Text):")
|
| 48 |
+
target_path = input(" >> Path: ").strip().strip('"')
|
| 49 |
+
try:
|
| 50 |
+
from logos.ingest.dissolution import DissolutionCore
|
| 51 |
+
core = DissolutionCore()
|
| 52 |
+
print(">> Engaging Dissolution Protocols...")
|
| 53 |
+
report = core.ingest_file(target_path)
|
| 54 |
+
print("\n" + "="*40)
|
| 55 |
+
print(f" [STATUS] {report['status']}")
|
| 56 |
+
print(f" [ATOMS] {report['total_atoms']}")
|
| 57 |
+
print(f" [HEAT] {report['average_heat']} (Avg GPF)")
|
| 58 |
+
print(f" [RESONANCE] {report['dominant_resonance']}")
|
| 59 |
+
print(f" [ENTROPY] {report['system_entropy']}")
|
| 60 |
+
print(f" [HEAD] {report['hex_preview']}...")
|
| 61 |
+
print("="*40 + "\n")
|
| 62 |
+
except Exception as e:
|
| 63 |
+
print(f"[!] DISSOLUTION FAILED: {e}")
|
| 64 |
+
input("Press Enter to stabilize...")
|
| 65 |
+
elif choice == '4':
|
| 66 |
+
sys.exit(0)
|
| 67 |
+
else:
|
| 68 |
+
pass # loop
|
| 69 |
+
|
| 70 |
+
if __name__ == "__main__":
|
| 71 |
+
while True:
|
| 72 |
+
try:
|
| 73 |
+
main_menu()
|
| 74 |
+
except KeyboardInterrupt:
|
| 75 |
+
sys.exit(0)
|
logos_project
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
Subproject commit 75b641f8e63f4fc840b4dd5b63ec2e4113f163a7
|
|
|
|
|
|