← BACK TO THE SPHERE

SECURITY PROTOCOL ARCHITECTURE

LIMBUS SPHERE

A containment algorithm that every request passes before SWIFT AI Browser may render it.

  1. 0

    Callsign

    Type a callsign or stay blank as operator. Press Enter the Matrix.

  2. 1

    Seal

    Session sealed. SWIFT opens on NEST, which searches only what has been read.

  3. 2

    Veil

    Each probe leaves through a fresh veil exit (vx-…). The origin never sees your callsign.

  4. 3

    Screened index

    A host not in the index is refused and never fetched.

  5. 4

    Crawlers

    Ledger reads names and lookalikes. Filament reads scripts, beacons, forms. Keel reads payloads and workers.

  6. 5

    Assessor

    The score is the highest crawler, not an average.

  7. 6

    Fast lane

    Top 10,000 + valid certificate + no hazard opens with no prompt. Top 100,000 is watched. Bad certificate or phish, dropper, miner is held.

  8. 7

    Guardrails

    Scripts, trackers, phish membrane, downloads start shut. Posture 100, each open rail −16. Threats go to the vault.

Source code

limbus.ts — the exact code running in this browser

/**
 * LIMBUS SPHERE — containment algorithm for SWIFT AI Browser.
 *
 * Before a page paints:
 *   1. A fresh veil exit (vx-…) is minted. The origin never sees the callsign.
 *   2. The host is looked up in the screened index. Not listed -> REFUSED, never fetched.
 *   3. Three crawlers report: Ledger (names, lookalikes), Filament (scripts,
 *      beacons, forms), Keel (payloads, workers).
 *   4. Assessor writes the score = the HIGHEST crawler, never an average.
 *   5. Fast lane: top 10,000 + valid certificate + no hazard -> opens, no prompt.
 *      Top 100,000 + valid certificate -> WATCHED, the user approves.
 *      Bad certificate or a hazard (phish, dropper, miner) -> HELD after a full probe.
 */

import { TOP100_HOSTS } from "./top100";
import { checkState, isTop100, type CheckState } from "./verify";

export type Hazard = "phish" | "dropper" | "miner";
export type Lane = "FAST" | "WATCHED" | "HELD" | "REFUSED";

export interface Host {
  host: string;
  rank: number;
  cert: boolean;
  hazard?: Hazard;
  title: string;
  body: string;
  /** Real site SWIFT renders inside the sphere. */
  live?: string;
  signals: { lookalike: number; scripts: number; payload: number };
}

export interface CrawlerReport {
  name: "Ledger" | "Filament" | "Keel";
  reads: string;
  score: number;
  note: string;
}

export interface Assessment {
  host: string;
  veil: string;
  probe: "none" | "quick" | "full";
  entry?: Host;
  crawlers: CrawlerReport[];
  score: number;
  lane: Lane;
  /** Live TLS + threat check status (top-100 hosts only). */
  live?: { state: CheckState; reason?: string | undefined } | undefined;
}

export const CALLSIGN_PHRASE = "Enter the Matrix";
export const DEFAULT_CALLSIGN = "operator";

/** The screened index. Anything not here is refused and never fetched. */
export const INDEX: Host[] = [
  { host: "nest-ai-search.lovable.app", rank: 10, cert: true, live: "https://nest-ai-search.lovable.app", title: "N.3.S.T. Search", body: "Nested Educational E-commerce Enterprise Ecosystem Search Topology.", signals: { lookalike: 1, scripts: 9, payload: 0 } },
  { host: "atlas.wire", rank: 10, cert: true, title: "Atlas Wire", body: "World news, filed every hour from 140 bureaus.", signals: { lookalike: 2, scripts: 8, payload: 0 } },
  { host: "kiln.docs", rank: 100, cert: true, title: "Kiln Docs", body: "Reference manuals for the tools people build with.", signals: { lookalike: 3, scripts: 6, payload: 0 } },
  { host: "lumen.market", rank: 1000, cert: true, title: "Lumen Market", body: "Lamps, glass and light fittings from small studios.", signals: { lookalike: 4, scripts: 14, payload: 2 } },
  { host: "drift.ledger", rank: 1000, cert: true, title: "Drift Ledger", body: "Open shipping records for ports on three oceans.", signals: { lookalike: 3, scripts: 10, payload: 0 } },
  { host: "orchard.forum", rank: 10000, cert: true, title: "Orchard Forum", body: "Growers trading notes on grafting, frost and pests.", signals: { lookalike: 5, scripts: 18, payload: 4 } },
  { host: "helix.lab", rank: 42000, cert: true, title: "Helix Lab", body: "Preprints and lab notebooks, published as they happen.", signals: { lookalike: 6, scripts: 24, payload: 8 } },
  { host: "signal.press", rank: 87000, cert: true, title: "Signal Press", body: "Independent essays on radio, maps and networks.", signals: { lookalike: 5, scripts: 22, payload: 6 } },
  { host: "northbnk.help", rank: 64000, cert: false, hazard: "phish", title: "North Bank — Account Help", body: "Your account is locked. Confirm your card to restore access.", signals: { lookalike: 94, scripts: 71, payload: 30 } },
  { host: "parcel.drop", rank: 71000, cert: false, hazard: "dropper", title: "Parcel Drop — Delivery Notice", body: "Download the tracking app to see your parcel.", signals: { lookalike: 40, scripts: 52, payload: 97 } },
  { host: "idle.stream", rank: 93000, cert: false, hazard: "miner", title: "Idle Stream", body: "Free films. Keep this tab open.", signals: { lookalike: 12, scripts: 66, payload: 89 } },
  ...TOP100_HOSTS,
];

export function normalizeHost(input: string): string {
  return input.trim().toLowerCase().replace(/^[a-z]+:\/\//, "").split(/[/?#]/)[0] ?? "";
}

export function lookup(host: string): Host | undefined {
  return INDEX.find((h) => h.host === host) ?? CUSTOM.find((h) => h.host === host);
}

/** Fresh veil exit per probe. Called from event handlers only. */
export function mintVeil(): string {
  return `vx-${Math.random().toString(36).slice(2, 8)}`;
}

function crawl(h: Host, full: boolean): CrawlerReport[] {
  void full;
  return [
    { name: "Ledger", reads: "Names and lookalikes", score: h.signals.lookalike,
      note: h.signals.lookalike > 50 ? "Name imitates a known brand." : "Name reads clean." },
    { name: "Filament", reads: "Scripts, beacons, forms", score: h.signals.scripts,
      note: h.signals.scripts > 50 ? "Hidden forms and beacons found." : "Ordinary scripts." },
    { name: "Keel", reads: "Payloads and workers", score: h.signals.payload,
      note: h.hazard === "dropper" ? "Executable payload staged." : h.hazard === "miner" ? "Background mining worker." : "No payloads." },
  ];
}

export function assess(input: string): Assessment {
  const host = normalizeHost(input);
  const veil = mintVeil();
  const entry = lookup(host);

  if (!entry) return { host, veil, probe: "none", crawlers: [], score: 100, lane: "REFUSED" };

  // Top-100 hosts need a fresh, passing live TLS + threat check. Fail closed otherwise.
  const live = isTop100(host) ? checkState(host) : undefined;
  const liveOk = !live || live.state === "verified";
  const fast = entry.rank <= 10000 && entry.cert && !entry.hazard && liveOk;
  const watched = !fast && liveOk && entry.rank <= 100000 && entry.cert && !entry.hazard;
  const crawlers = crawl(entry, !fast);
  const score = live && !liveOk ? 100 : Math.max(...crawlers.map((c) => c.score)); // highest crawler wins

  const lane: Lane = fast ? "FAST" : watched ? "WATCHED" : "HELD";
  return { host, veil, probe: fast ? "quick" : "full", entry, crawlers, score, lane, live: live && { state: live.state, reason: live.check?.reason } };
}

/** Guardrails start shut. Posture starts at 100; each opened rail costs 16. */
export const RAILS = ["scripts", "trackers", "phish membrane", "downloads"] as const;
export type Rail = (typeof RAILS)[number];
export const RAIL_COST = 16;
export function posture(open: Rail[]): number {
  return 100 - open.length * RAIL_COST;
}

/** Rows -> CSV text. Cells are quoted; quotes doubled. */
export function toCsv(header: string[], rows: (string | number)[][]): string {
  const cell = (v: string | number) => `"${String(v).replace(/"/g, '""')}"`;
  return [header, ...rows].map((r) => r.map(cell).join(",")).join("\r\n");
}

/* ===== Trusted-site list (import / export) ===== */

/** Trusted additions imported by the operator. Safe by definition. */
const CUSTOM: Host[] = [];

export function customTrusted(): readonly Host[] {
  return CUSTOM;
}

/** Safe hosts: valid certificate, no hazard — screened index first, then imports. */
export function trustedHosts(): Host[] {
  return [...INDEX.filter((h) => h.cert && !h.hazard), ...CUSTOM];
}

export interface TrustedRow { host: string; rank: number; title: string; body: string }

const RANK_MIN = 1;
const RANK_MAX = 1_000_000;

export function addTrusted(rows: TrustedRow[]): number {
  let added = 0;
  for (const row of rows) {
    if (CUSTOM.some((h) => h.host === row.host)) continue;
    CUSTOM.push({
      host: row.host, rank: row.rank, cert: true, title: row.title, body: row.body,
      signals: { lookalike: 0, scripts: 0, payload: 0 },
    });
    added++;
  }
  return added;
}

/** Parse a trusted-list CSV. Columns: host, rank, title, body (title/body optional). */
export function parseTrustedCsv(text: string): { rows: TrustedRow[]; skipped: number } {
  const lines = text.split(/\r?\n/).filter((l) => l.trim() !== "");
  if (lines.length === 0) return { rows: [], skipped: 0 };

  const cells = (line: string): string[] => {
    const out: string[] = [];
    let cur = "";
    let inQ = false;
    for (let i = 0; i < line.length; i++) {
      const c = line[i];
      if (inQ) {
        if (c === '"' && line[i + 1] === '"') { cur += '"'; i++; }
        else if (c === '"') inQ = false;
        else cur += c;
      } else if (c === '"') inQ = true;
      else if (c === ",") { out.push(cur); cur = ""; }
      else cur += c;
    }
    out.push(cur);
    return out;
  };

  const rows: TrustedRow[] = [];
  let skipped = 0;
  let start = 0;
  if (cells(lines[0] ?? "")[0]?.trim().toLowerCase() === "host") start = 1;

  for (const line of lines.slice(start)) {
    const c = cells(line);
    const host = normalizeHost(c[0] ?? "");
    const rank = Number.parseInt(c[1]?.trim() ?? "", 10);
    if (!host || Number.isNaN(rank) || rank < RANK_MIN || rank > RANK_MAX) { skipped++; continue; }
    if (INDEX.some((h) => h.host === host) || CUSTOM.some((h) => h.host === host) || rows.some((r) => r.host === host)) { skipped++; continue; }
    rows.push({
      host,
      rank,
      title: (c[2] ?? "").trim() || host,
      body: (c[3] ?? "").trim() || "Imported trusted site.",
    });
  }
  return { rows, skipped };
}

Note: LIMBUS is a browsing membrane inside a web page, not a virtualized operating system.