Lucidia Core - AI reasoning engines for specialized domains: - Physicist (867 lines) - energy modeling, force calculations - Mathematician (760 lines) - symbolic computation, proofs - Geologist (654 lines) - terrain modeling, stratigraphy - Engineer (599 lines) - structural analysis, optimization - Painter (583 lines) - visual generation, graphics - Chemist (569 lines) - molecular analysis, reactions - Analyst (505 lines) - pattern recognition, insights - Plus: architect, researcher, mediator, speaker, poet, navigator Features: - FastAPI wrapper with REST endpoints for each agent - CLI with `lucidia list`, `lucidia run`, `lucidia api` - Codex YAML configurations for agent personalities - Quantum engine extensions 12,512 lines of Python across 91 files. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
57 lines
1.2 KiB
Python
57 lines
1.2 KiB
Python
"""Runtime guardrails for the quantum engine."""
|
|
from __future__ import annotations
|
|
|
|
import builtins
|
|
import os
|
|
import random
|
|
import socket
|
|
from typing import Optional
|
|
|
|
MAX_WIRES = 8
|
|
MAX_SHOTS = 2048
|
|
TIMEOUT = 60
|
|
|
|
DENYLIST = (
|
|
'torchquantum.plugins',
|
|
'qiskit',
|
|
'qiskit_ibm_runtime',
|
|
)
|
|
|
|
|
|
def enforce_import_block() -> None:
|
|
"""Block imports of disallowed modules."""
|
|
real_import = builtins.__import__
|
|
|
|
def guarded(name, *args, **kwargs):
|
|
for bad in DENYLIST:
|
|
if name.startswith(bad):
|
|
raise ImportError(f'{bad} is disabled')
|
|
return real_import(name, *args, **kwargs)
|
|
|
|
builtins.__import__ = guarded
|
|
|
|
|
|
def guard_env() -> None:
|
|
"""Fail closed on hardware flags and block outbound sockets."""
|
|
if os.getenv('LUCIDIA_QHW') == '1':
|
|
raise RuntimeError('Hardware backends are disabled')
|
|
|
|
class _BlockedSocket(socket.socket):
|
|
def __init__(self, *args, **kwargs):
|
|
raise RuntimeError('Network access disabled')
|
|
|
|
socket.socket = _BlockedSocket
|
|
|
|
|
|
def set_seed(seed: Optional[int] = None) -> int:
|
|
if seed is None:
|
|
seed = 0
|
|
random.seed(seed)
|
|
try:
|
|
import torch
|
|
|
|
torch.manual_seed(seed)
|
|
except Exception:
|
|
pass
|
|
return seed
|