From b25261612380ce6a794d9e033912bbd151a95889 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 29 Jul 2026 14:00:19 +0000 Subject: [PATCH 1/2] Add full audit export: JSON, SQLite, and PDF MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Product Hunt feature request: a way to audit/back up the full graph data (entities, trust scores, conflict candidates), not just memories. The existing "Data Management" export and "Backup & Restore" only ever covered memories (+ sessions for backup) — the entity graph, trust scores, and conflict candidates were only reachable via individual paginated REST reads. Adds server/core/full_export.py with three outputs sharing one data pass (build_full_export): - GET /api/export/full.json — raw machine-readable bundle - GET /api/export/full.sqlite — a consistent copy of the live DB via SQLite's online backup API (Database.create_safety_backup) - GET /api/export/full.pdf — human-readable summary report (fpdf2, optional dependency, added as the `pdf` extra) Also: `levh export-full --format {json,sqlite,pdf}` CLI command, three buttons in Settings -> Data Management, and TrustService.list_all_trust to fetch every stored trust breakdown (not just below-threshold ones). --- frontend/src/app/settings/page.tsx | 69 +++++++++++++ frontend/src/lib/api.ts | 21 ++++ pyproject.toml | 2 + server/api.py | 63 ++++++++++++ server/cli.py | 67 ++++++++++++ server/core/database.py | 9 ++ server/core/full_export.py | 158 +++++++++++++++++++++++++++++ server/core/memory_engine.py | 5 + server/core/trust_service.py | 18 ++++ tests/test_full_export.py | 59 +++++++++++ 10 files changed, 471 insertions(+) create mode 100644 server/core/full_export.py create mode 100644 tests/test_full_export.py diff --git a/frontend/src/app/settings/page.tsx b/frontend/src/app/settings/page.tsx index 3608a93..656b82f 100644 --- a/frontend/src/app/settings/page.tsx +++ b/frontend/src/app/settings/page.tsx @@ -104,6 +104,10 @@ export default function SettingsPage() { const [consolidateResult, setConsolidateResult] = useState(""); const fileInputRef = useRef(null); + // Full audit export (memories + entity graph + trust + conflicts) + const [fullExportBusy, setFullExportBusy] = useState<"" | "json" | "sqlite" | "pdf">(""); + const [fullExportError, setFullExportError] = useState(""); + // Backup & restore const [backupPass, setBackupPass] = useState(""); const [backingUp, setBackingUp] = useState(false); @@ -242,6 +246,23 @@ export default function SettingsPage() { setImportingJson(false); }; + const downloadFullExport = async (format: "json" | "sqlite" | "pdf") => { + setFullExportBusy(format); + setFullExportError(""); + try { + const { blob, filename } = await api.exportFull(format); + const url = URL.createObjectURL(blob); + const a = document.createElement("a"); + a.href = url; + a.download = filename; + a.click(); + URL.revokeObjectURL(url); + } catch (e) { + setFullExportError(e instanceof Error ? e.message : String(e)); + } + setFullExportBusy(""); + }; + const downloadBackup = async () => { setBackingUp(true); try { @@ -947,6 +968,54 @@ export default function SettingsPage() { /> +
+

+ Full audit export — memories, entity graph, trust scores, and conflict candidates + in one file. For auditing or backing up everything, not just memories. +

+
+ + + +
+ {fullExportError && ( + {fullExportError} + )} +
+