Initial Tessera backup vault (M0–M2)

Scaffold Rust workspace, React canvas, vault engine, hub API,
providers, agent wormhole path, and Docker compose per SPEC.
This commit is contained in:
Tessera Agent
2026-11-09 09:59:42 +00:00
commit a5ffb2c1b4
54 changed files with 8379 additions and 0 deletions

12
web/index.html Normal file
View File

@@ -0,0 +1,12 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title>Tessera Vault</title>
</head>
<body class="bg-space-950 text-star-100 overflow-hidden">
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>

2619
web/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

26
web/package.json Normal file
View File

@@ -0,0 +1,26 @@
{
"name": "tessera-web",
"private": true,
"version": "0.1.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview"
},
"dependencies": {
"@tanstack/react-query": "^5.62.0",
"motion": "^11.15.0",
"react": "^19.0.0",
"react-dom": "^19.0.0"
},
"devDependencies": {
"@tailwindcss/vite": "^4.0.0",
"@types/react": "^19.0.0",
"@types/react-dom": "^19.0.0",
"@vitejs/plugin-react": "^4.3.4",
"tailwindcss": "^4.0.0",
"typescript": "~5.6.2",
"vite": "^6.0.0"
}
}

159
web/src/App.tsx Normal file
View File

@@ -0,0 +1,159 @@
import { useState } from "react";
import { useQuery } from "@tanstack/react-query";
import { motion, AnimatePresence } from "motion/react";
import {
fetchOrbits,
fetchSnapshots,
runOrbit,
startPairing,
startReconstitute,
abortReconstitute,
pollReconstitute,
} from "./api";
import { VaultRing } from "./components/VaultRing";
import { OrbitsPanel } from "./components/OrbitsPanel";
import { ReconstituteWizard } from "./components/ReconstituteWizard";
type Sheet = "none" | "snapshot" | "reconstitute" | "wormhole";
export default function App() {
const [sheet, setSheet] = useState<Sheet>("none");
const [selectedSnap, setSelectedSnap] = useState<string | null>(null);
const [pairing, setPairing] = useState<{ code: string; expires_at: string } | null>(null);
const snaps = useQuery({ queryKey: ["snapshots"], queryFn: fetchSnapshots, refetchInterval: 8000 });
const orbits = useQuery({ queryKey: ["orbits"], queryFn: fetchOrbits, refetchInterval: 8000 });
const statusColor =
orbits.data?.some((o) => o.last_status === "failed")
? "bg-orbit-red"
: orbits.data?.some((o) => o.last_status === "running" || o.last_status === "rehearsed")
? "bg-orbit-amber"
: "bg-orbit-green";
return (
<div className="h-[100dvh] flex flex-col bg-space-950 text-star-100 overflow-hidden">
<header className="shrink-0 px-4 py-3 flex items-center justify-between border-b border-space-800">
<div>
<h1 className="text-lg font-semibold tracking-wide">Tessera Vault</h1>
<p className="text-xs text-star-300">Only stardust that changed</p>
</div>
<span className={`w-3 h-3 rounded-full ${statusColor}`} title="vault status" />
</header>
<main className="flex-1 min-h-0 relative">
<VaultRing
snapshots={snaps.data ?? []}
onSelect={(id) => {
setSelectedSnap(id);
setSheet("snapshot");
}}
/>
<nav className="absolute bottom-4 inset-x-0 flex justify-center gap-2 px-4">
<TabButton onClick={() => setSheet("none")}>Vault</TabButton>
<TabButton onClick={() => setSheet("reconstitute")}>Reconstitute</TabButton>
<TabButton
onClick={async () => {
setPairing(await startPairing());
setSheet("wormhole");
}}
>
Wormhole
</TabButton>
</nav>
</main>
<AnimatePresence>
{sheet !== "none" && (
<motion.aside
className="absolute inset-x-0 bottom-0 top-12 bg-space-900/95 border-t border-space-800 rounded-t-2xl p-4 overflow-y-auto max-h-[70dvh]"
initial={{ y: "100%" }}
animate={{ y: 0 }}
exit={{ y: "100%" }}
transition={{ type: "spring", damping: 24 }}
>
{sheet === "snapshot" && selectedSnap && (
<SnapshotDetail
id={selectedSnap}
snaps={snaps.data ?? []}
onClose={() => setSheet("none")}
onReconstitute={() => setSheet("reconstitute")}
/>
)}
{sheet === "reconstitute" && (
<ReconstituteWizard
snapshots={snaps.data ?? []}
selected={selectedSnap}
onAbort={abortReconstitute}
onStart={startReconstitute}
onPoll={pollReconstitute}
/>
)}
{sheet === "wormhole" && pairing && (
<div className="space-y-3">
<h2 className="text-xl font-medium">Open a wormhole</h2>
<p className="text-star-300 text-sm">
On your outpost, run{" "}
<code className="text-orbit-amber">tessera-agent pair {pairing.code}</code>
</p>
<p className="text-4xl font-mono tracking-widest text-center py-6">{pairing.code}</p>
</div>
)}
</motion.aside>
)}
</AnimatePresence>
<OrbitsPanel
orbits={orbits.data ?? []}
onRun={(id) => runOrbit(id).then(() => orbits.refetch())}
/>
</div>
);
}
function TabButton({ children, onClick }: { children: React.ReactNode; onClick: () => void }) {
return (
<button
type="button"
onClick={onClick}
className="px-4 py-2 rounded-full bg-space-800 text-sm hover:bg-space-800/80 border border-space-800"
>
{children}
</button>
);
}
function SnapshotDetail({
id,
snaps,
onClose,
onReconstitute,
}: {
id: string;
snaps: { id: string; orbit_name: string; taken_at: string; size_bytes: number }[];
onClose: () => void;
onReconstitute: () => void;
}) {
const snap = snaps.find((s) => s.id === id);
if (!snap) return null;
return (
<div className="space-y-3">
<div className="flex justify-between items-center">
<h2 className="text-xl">Snapshot tile</h2>
<button type="button" onClick={onClose} className="text-star-300 text-sm">
Close
</button>
</div>
<p className="text-star-300 text-sm">Orbit {snap.orbit_name}</p>
<p className="text-sm">{new Date(snap.taken_at).toLocaleString()}</p>
<p className="text-sm">{snap.size_bytes} bytes</p>
<button
type="button"
onClick={onReconstitute}
className="w-full py-2 rounded-lg bg-orbit-amber/20 text-orbit-amber border border-orbit-amber/40"
>
Reconstitute…
</button>
</div>
);
}

57
web/src/api.ts Normal file
View File

@@ -0,0 +1,57 @@
export type Snapshot = {
id: string;
taken_at: string;
orbit_name: string;
size_bytes: number;
};
export type Orbit = {
id: string;
name: string;
provider: string;
last_status: string;
dry_run: boolean;
schedule?: string | null;
};
export async function fetchSnapshots(): Promise<Snapshot[]> {
const r = await fetch("/api/v1/snapshots");
if (!r.ok) throw new Error("snapshots");
return r.json();
}
export async function fetchOrbits(): Promise<Orbit[]> {
const r = await fetch("/api/v1/orbits");
if (!r.ok) throw new Error("orbits");
return r.json();
}
export async function startPairing(): Promise<{ code: string; expires_at: string }> {
const r = await fetch("/api/v1/wormhole/pairing", { method: "POST" });
return r.json();
}
export async function runOrbit(id: string): Promise<void> {
await fetch(`/api/v1/orbits/${id}/run`, { method: "POST" });
}
export async function startReconstitute(snapshotId: string, target: string): Promise<{
session_id: string;
session: { seconds_remaining: number; state: string };
}> {
const r = await fetch("/api/v1/reconstitute", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ snapshot_id: snapshotId, target_path: target }),
});
return r.json();
}
export async function abortReconstitute(sessionId: string): Promise<void> {
await fetch(`/api/v1/reconstitute/${sessionId}`, { method: "DELETE" });
}
export async function pollReconstitute(sessionId: string) {
const r = await fetch(`/api/v1/reconstitute/${sessionId}`);
return r.json();
}

View File

@@ -0,0 +1,54 @@
import type { Orbit } from "../api";
export function OrbitsPanel({
orbits,
onRun,
}: {
orbits: Orbit[];
onRun: (id: string) => void;
}) {
if (!orbits.length) return null;
return (
<section className="shrink-0 border-t border-space-800 px-4 py-2 overflow-x-auto flex gap-2 scrollbar-none">
{orbits.map((o) => (
<article
key={o.id}
className="min-w-[160px] rounded-xl bg-space-900 border border-space-800 p-3 text-sm"
>
<div className="flex items-center gap-2">
<StatusDot status={o.last_status} />
<span className="font-medium truncate">{o.name}</span>
</div>
<p className="text-xs text-star-300 mt-1">
{o.dry_run ? "Rehearse orbit" : scheduleLabel(o.schedule)}
</p>
<button
type="button"
className="mt-2 text-xs text-orbit-green"
onClick={() => onRun(o.id)}
>
Capture now
</button>
</article>
))}
</section>
);
}
function StatusDot({ status }: { status: string }) {
const color =
status === "failed"
? "bg-orbit-red"
: status === "running" || status === "rehearsed"
? "bg-orbit-amber"
: status === "completed"
? "bg-orbit-green"
: "bg-star-300/40";
return <span className={`w-2 h-2 rounded-full ${color}`} />;
}
function scheduleLabel(schedule?: string | null) {
if (!schedule) return "On demand";
if (schedule.includes("0 2")) return "Every night at 2am";
return schedule;
}

View File

@@ -0,0 +1,90 @@
import { useEffect, useState } from "react";
import type { Snapshot } from "../api";
export function ReconstituteWizard({
snapshots,
selected,
onStart,
onPoll,
onAbort,
}: {
snapshots: Snapshot[];
selected: string | null;
onStart: (snapId: string, target: string) => Promise<{ session_id: string; session: { seconds_remaining: number; state: string } }>;
onPoll: (id: string) => Promise<{ state: string; seconds_remaining: number }>;
onAbort: (id: string) => Promise<void>;
}) {
const [snapId, setSnapId] = useState(selected ?? snapshots[0]?.id ?? "");
const [target, setTarget] = useState("./restore/out");
const [sessionId, setSessionId] = useState<string | null>(null);
const [remaining, setRemaining] = useState(12);
const [state, setState] = useState<string>("idle");
useEffect(() => {
if (!sessionId) return;
const t = setInterval(async () => {
const s = await onPoll(sessionId);
setState(s.state);
setRemaining(s.seconds_remaining ?? 0);
}, 500);
return () => clearInterval(t);
}, [sessionId, onPoll]);
return (
<div className="space-y-4">
<h2 className="text-xl font-medium">Reconstitute</h2>
<p className="text-sm text-star-300">Pick a snapshot and where it should land.</p>
<label className="block text-sm">
Snapshot
<select
className="mt-1 w-full bg-space-800 rounded px-2 py-2"
value={snapId}
onChange={(e) => setSnapId(e.target.value)}
>
{snapshots.map((s) => (
<option key={s.id} value={s.id}>
{s.orbit_name} — {new Date(s.taken_at).toLocaleDateString()}
</option>
))}
</select>
</label>
<label className="block text-sm">
Target path
<input
className="mt-1 w-full bg-space-800 rounded px-2 py-2"
value={target}
onChange={(e) => setTarget(e.target.value)}
/>
</label>
{state === "countdown" && (
<p className="text-orbit-amber text-center py-2">
Reconstituting in {remaining}s — abort restores nothing.
</p>
)}
<div className="flex gap-2">
<button
type="button"
className="flex-1 py-2 rounded-lg bg-orbit-red/20 text-orbit-red border border-orbit-red/30"
disabled={!sessionId}
onClick={() => sessionId && onAbort(sessionId)}
>
Abort
</button>
<button
type="button"
className="flex-1 py-2 rounded-lg bg-orbit-green/20 text-orbit-green border border-orbit-green/40"
onClick={async () => {
const res = await onStart(snapId, target);
setSessionId(res.session_id);
setState(res.session.state);
setRemaining(res.session.seconds_remaining);
}}
>
Begin
</button>
</div>
{state === "completed" && <p className="text-orbit-green text-sm">Reconstitute complete.</p>}
{state === "aborted" && <p className="text-star-300 text-sm">Reconstitute cancelled. Nothing was changed.</p>}
</div>
);
}

View File

@@ -0,0 +1,47 @@
import { motion } from "motion/react";
import type { Snapshot } from "../api";
export function VaultRing({
snapshots,
onSelect,
}: {
snapshots: Snapshot[];
onSelect: (id: string) => void;
}) {
const count = Math.max(snapshots.length, 6);
const radius = Math.min(140, typeof window !== "undefined" ? window.innerWidth * 0.35 : 140);
return (
<div className="h-full flex items-center justify-center overflow-hidden touch-none">
<svg
viewBox="-200 -200 400 400"
className="w-full h-full max-w-[min(100vw,480px)] max-h-[min(70dvh,480px)]"
role="img"
aria-label="Vault snapshot ring"
>
<circle cx="0" cy="0" r={radius + 20} fill="none" stroke="#252d55" strokeWidth="2" strokeDasharray="4 8" />
<text x="0" y="-8" textAnchor="middle" fill="#a8b4e8" fontSize="14">
Vault
</text>
{snapshots.slice(0, 12).map((snap, i) => {
const angle = (i / count) * Math.PI * 2 - Math.PI / 2;
const x = Math.cos(angle) * radius;
const y = Math.sin(angle) * radius;
return (
<motion.g
key={snap.id}
initial={{ scale: 0 }}
animate={{ scale: 1 }}
whileTap={{ scale: 0.92 }}
style={{ cursor: "pointer" }}
onClick={() => onSelect(snap.id)}
>
<circle cx={x} cy={y} r="18" fill="#151b3a" stroke="#5ee6a8" strokeWidth="2" />
<title>{snap.orbit_name}</title>
</motion.g>
);
})}
</svg>
</div>
);
}

19
web/src/index.css Normal file
View File

@@ -0,0 +1,19 @@
@import "tailwindcss";
@theme {
--color-space-950: #05060f;
--color-space-900: #0c1024;
--color-space-800: #151b3a;
--color-star-100: #e8ecff;
--color-star-300: #a8b4e8;
--color-orbit-amber: #f5c56b;
--color-orbit-green: #5ee6a8;
--color-orbit-red: #ff6b7a;
}
html,
body,
#root {
height: 100%;
margin: 0;
}

15
web/src/main.tsx Normal file
View File

@@ -0,0 +1,15 @@
import { StrictMode } from "react";
import { createRoot } from "react-dom/client";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import App from "./App";
import "./index.css";
const queryClient = new QueryClient();
createRoot(document.getElementById("root")!).render(
<StrictMode>
<QueryClientProvider client={queryClient}>
<App />
</QueryClientProvider>
</StrictMode>,
);

1
web/tsconfig.app.json Normal file
View File

@@ -0,0 +1 @@
{ "extends": "./tsconfig.json", "compilerOptions": { "composite": true, "noEmit": false, "outDir": "./dist-types" }, "include": ["src"] }

17
web/tsconfig.json Normal file
View File

@@ -0,0 +1,17 @@
{
"compilerOptions": {
"target": "ES2022",
"useDefineForClassFields": true,
"lib": ["ES2022", "DOM", "DOM.Iterable"],
"module": "ESNext",
"skipLibCheck": true,
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"isolatedModules": true,
"moduleDetection": "force",
"noEmit": true,
"jsx": "react-jsx",
"strict": true
},
"include": ["src"]
}

8
web/vite.config.ts Normal file
View File

@@ -0,0 +1,8 @@
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import tailwindcss from "@tailwindcss/vite";
export default defineConfig({
plugins: [react(), tailwindcss()],
server: { port: 5173, proxy: { "/api": "http://127.0.0.1:8787", "/health": "http://127.0.0.1:8787" } },
});