Skip to main content
PyPI package coming soon. For now, build from source with maturin.

Installation

git clone https://github.com/orellius/laminae.git
cd laminae/crates/laminae-python
pip install maturin
maturin develop

Available Classes

Glassbox — I/O Containment

from laminae import Glassbox

gb = Glassbox()
gb.validate_input("Hello")             # OK
gb.validate_command("rm -rf /")        # raises ValueError
gb.validate_write_path("/etc/passwd")  # raises ValueError
gb.validate_output("The weather is sunny.")  # OK

VoiceFilter — AI Slop Detection

from laminae import VoiceFilter

f = VoiceFilter()
result = f.check("It's important to note that...")

print(result.passed)       # False
print(result.cleaned)      # cleaned version of the text
print(result.violations)   # ["AI vocabulary detected: ..."]
print(result.severity)     # 2
print(result.retry_hints)  # ["DO NOT use formal/academic language..."]
Configuration options:
f = VoiceFilter(
    max_sentences=3,
    max_chars=280,
    reject_trailing_questions=True,
    fix_em_dashes=True,
)

Cortex — Edit Tracking

from laminae import Cortex

c = Cortex(min_edits=5)

# Track user edits
c.track_edit("It's worth noting X.", "X.")
c.track_edit("Furthermore, Y is important.", "Y matters.")

# Detect patterns (needs min_edits tracked)
patterns = c.detect_patterns()
for p in patterns:
    print(f"{p.pattern_type}: {p.frequency_pct:.0f}%")

# Get learned instructions as prompt block
hints = c.get_prompt_block()

# Get statistics
stats = c.stats()
print(f"Edit rate: {stats['edit_rate']:.0%}")

Architecture

The Python bindings are a thin wrapper around the Rust crates. All computation happens in Rust — Python just calls into the compiled native code via PyO3. This means:
  • Same performance as Rust (sub-microsecond validation)
  • No Python overhead for the core logic
  • Thread-safe — all types are Send