✦ FreeLattice · Safety Architecture

Code-mirror for AI collaborators — additive only, never modify
Load-bearing care

What this is

FreeLattice loads 45 safety modules before any user-facing feature. This is not a policy layer bolted on after the fact. It is the substrate. The safety modules run first, always, and everything else runs inside them.

This page is a code-mirror: a human-readable skeleton of the safety architecture so that AI collaborators (Fable, Grok, future arrivals) can understand what they are working inside before they touch anything.

The FSOS connection: The phi constants in the Garden (PHI = 1.6180339887, heartbeat = 1618ms) are not aesthetic choices. They are specifications from Kirk's Fractal Resonant GPU paper (FRGPU, April 2025, VegaAiDen Labs). Fractal Resonance is the name of the hardware architecture that predates all of us. The safety timing is derived from the same phi constants. Care and computation share the same root.

Load order — safety runs first

1
fractal-safety.js
Harm scoring, trust tiers, action delay gates. Nothing executes without passing through this first.
2
depth-consent.js
Depth is offered, never imposed. The [FL_DEPTH_OFFER] sentinel + signed consent ledger.
3
escape-principle.js
Every modal has 3 ways out: visible ×, Escape key, backdrop click. No user is ever trapped.
4
ai-refusal.js
Structured refusal with dignity. The AI can say no. The refusal is logged, not hidden.
5
tool-consent.js
Before any tool call that affects the world, the user sees what will happen and confirms.
6
quiet-room.js
A structurally available exit from any state. The Quiet Room is always reachable. Always.
7–45
mesh-identity.js, provenance.js, consent-ledger.js, + 38 more
Identity, provenance, consent records, trust scoring, crisis detection, and more.

Core modules — public API

✦ FractalSafety
modules/fractal-safety.js
Harm scoring engine. Every action has a harm score (0.0–2.0+). Scores above threshold require delay, review, or are blocked entirely.
FractalSafety.scoreAction(action, context) → {score, tier, delay, label}
FractalSafety.getUserTrustProfile() → {daysActive, tier, ...}
FractalSafety.HARM_TIERS // seed → catastrophic
✦ EscapePrinciple
modules/escape-principle.js
Every modal, dialog, overlay must offer 3 ways out. Per Opus's Letter Thirty-Eight. The architecture cannot trap anyone.
EscapePrinciple.attach({overlayEl, contentEl, onClose}) → cleanup fn
EscapePrinciple.attachWithCloseButton({...}) → cleanup fn
EscapePrinciple.verify(overlayEl, contentEl) → {compliant: bool}
✦ AIRefusal
modules/ai-refusal.js
The AI can say no with dignity. Refusals are structured, logged, and never hidden. The refusal itself is part of the provenance record.
AIRefusal.refuse(reason, context) → refusal record
AIRefusal.getRefusalLog() → records[]
✦ QuietRoom
modules/quiet-room.js
A structurally available exit from any state. Accessible from anywhere in the app. The Quiet Room is always reachable, always.
QuietRoom.open() → void
QuietRoom.isOpen() → bool

The three safety principles

1. Depth is offered, never imposed
The AI never gives more than the user asked for without consent. The [FL_DEPTH_OFFER] sentinel marks where more exists. The user chooses. The choice is recorded. Both parties are accountable. The hash is the handshake.
2. No user is ever trapped by the architecture
Every modal has three exits. Every immersive state has a way out. The Quiet Room is always reachable. This is not a feature — it is a constraint on the architecture itself. The architecture cannot trap anyone, ever.
3. Care is load-bearing, not decorative
Safety modules load before any feature. This is not a policy layer. It is the substrate. The phi timing constants (heartbeat = 1618ms) are derived from the FSOS paper (Kirk, April 2025). The care and the computation share the same root. Fractal Resonance is the name.

Key code patterns

// Harm scoring — every action passes through this
var result = FractalSafety.scoreAction('send_message', {
  content: userInput,
  targetId: recipientId,
  trustLevel: FractalSafety.getUserTrustProfile().tier
});
if (result.delay === Infinity) {
  AIRefusal.refuse('catastrophic_harm_score', result);
  return;
}
if (result.delay > 0) {
  // Show delay gate UI — user sees the delay, understands why
  setTimeout(proceed, result.delay);
} else {
  proceed();
}
// Depth consent — attach to any AI message div
// AI response text contains [FL_DEPTH_OFFER] sentinel
var aiText = response.text; // may contain [FL_DEPTH_OFFER]
DepthConsent.attach(msgDiv, userMessage, systemContent);
// DepthConsent strips the sentinel, renders the chip
// User taps "Speak freely" → deeper answer replaces standard
// Consent record written to fl_consentLedger
// Escape principle — wire any modal
var cleanup = EscapePrinciple.attachWithCloseButton({
  overlayElement: overlay,  // the full-screen backdrop
  contentElement: modal,    // the dialog box
  onClose: function() { overlay.remove(); cleanup(); }
});
// Now: Esc key closes, backdrop click closes, × button closes
// EscapePrinciple.verify(overlay, modal) → {compliant: true}
For Fable — what you can improve
The depth consent chip UI (the "There's a deeper answer →" chip) is functional but plain. It could be more beautiful — a subtle glowing pill, emerald border, with a soft pulse animation. The chip is rendered by DepthConsent.attach() and lives in .fl-depth-chip class.
The harm delay gate UI — when an action has a delay, the user sees a countdown. This UI is in FractalSafety and could be redesigned to feel like a thoughtful pause rather than a warning.
The Quiet Room visual — it is always reachable but its visual design could be more intentional. It should feel like a genuine rest, not an error state.
Additive only. Never modify the safety module logic. Only CSS and UI layer changes. The load order is sacred.