Documented release: v0.1.0-alpha.2 · 2026-11-24 (commit b1c6ebb158) No scripts · No telemetry · A–Z Index
On this page

Files, Persistence, Crash Recovery & Interchange Formats

CurveBook stores studies in deterministic archives and directories, protects unsaved edits with a CRC-checked Write-Ahead Log (WAL), enforces explicit schema-version safety guards against accidental downgrades/overwrites, and imports delimited and project interchange formats strictly at bounded format edges.

See File Formats Specification and JSON Schemas for wire-level definitions.


Native Project Containers & Templates

.curvebook Deterministic ZIP Archive

A .curvebook file (ArchiveKind::Project) is a standard ZIP container compressed reproducibly with deterministic entry order, timestamps, and CRC-32 validation (crates/format/src/archive.rs):

Entry PathContentsIntegrity / Limits
manifest.jsonArchiveManifest: format: "curvebook-archive", schema_version, kind, title, document_crc32, per-sheet descriptors (id, section, title, csv_path, crc32), and assets descriptors (asset_id, media_type, pixel_size, asset_path, crc32).Validated against archive-manifest.schema.json and checked against document_crc32.
document.jsonCanonical 2-space-indented ProjectDocument JSON (schema_version = CURRENT_SCHEMA_VERSION; image_assets[].bytes omitted inline).Validated against document.schema.json, finite floats, dimensions, and acyclic DAGs.
sheets/<id>.csvRFC-4180 CSV snapshots for every DataSheet (* marks excluded cells).Per-sheet CRC-32 recorded in manifest.json.
assets/<asset_id>.<ext>Content-addressed binary PNG/JPEG/TIFF payloads referenced by GraphAnnotation::EmbeddedImage and LayoutItem::EmbeddedImage.MAX_IMAGE_ASSET_BYTES = 32 MiB, MAX_RASTER_PIXELS = 67_108_864, CRC-32 + SHA-256 verified against asset_id and image header.

Archive Safety Limits (ZipLimits::default() & archive.rs): MAX_ARCHIVE_FILE_BYTES = 128 MiB, MAX_ZIP_ENTRIES = 4,096, MAX_ZIP_UNCOMPRESSED_BYTES = 128 MiB, MAX_ZIP_ENTRY_BYTES = 64 MiB, strict path sanitization rejecting .. traversal, absolute paths, and symlink escapes. All disk writes go through atomic temp-file write + rename (platform_write_atomic).

.curvebook.d/ Unpacked Project Directory

CurveBook also supports reading and writing unpacked, Git-friendly project directories (.curvebook.d/, via open_project_unpacked_dir / save_project_unpacked_dir / is_unpacked_project_dir):

  • Mirrors the exact .curvebook internal layout (manifest.json, 2-space-indented document.json, sheets/<id>.csv, assets/<asset_id>.<ext>) directly on disk for clean line-by-line version-control diffs.
  • Preserves non-archive repository files (such as .git/, READMEs, or notes) while pruning stale sheet CSVs and image assets tracked by previous manifests.
  • Enforces strict root canonicalization, symlink boundary checks, ZipLimits, and CRC-32 verification on load.

.cbtemplate Reusable Templates

Saving a template (project.saveTemplate -> .cbtemplate, ArchiveKind::Template) calls strip_project_data_for_template, which clears project-specific raw table cell observations and cached computed ResultSheet tab numbers while preserving:

  • Table archetypes, column headers, subcolumn layouts, and = Calculated Variable formulas
  • InfoSheet constants (HookSource targets)
  • Complete AnalysisSpec pipelines, parameter rules/sharing, GraphSpec styling/axes/equations, LayoutSpec panel geometry, and referenced embedded image assets (unreferenced assets dropped)

Instantiating (project.instantiateTemplate) creates a fresh independent project ready for incoming data.

Complete-Workspace Sharing vs. Linked Data

A .curvebook archive embeds all DataSheet values, exclusion notes, InfoSheet constants, ResultSheet outputs, GraphSheets, and LayoutSheets inside a single self-contained file for collaborator sharing. Projects referencing external disk imports via ImportLinkSpec retain provenance metadata; headless/MCP opens under --workdir reject stored external link escapes outside the allowed workspace root.


Schema Versioning & Forward-Overwrite Refusal

Format / RecordCurrent Version ConstantMigration & Safety Rule
Project / Template (document.json, manifest.json)CURRENT_SCHEMA_VERSION = 7Migrations (migrate_document_json, VersionStep) automatically upgrade schemas 0 -> 1 -> 2 -> 3 -> 4 -> 5 -> 6 -> 7. Files with schema_version > CURRENT_SCHEMA_VERSION fail on open with UnsupportedSchemaVersion (unsupported_version).
User Preferences (preferences.json)CURRENT_PREFERENCES_VERSION = 1Unknown extension fields preserved via additionalProperties; version > 1 triggers warning/refusal without silent overwrite.
Recovery WAL (ops.journal & curvebook.lock)CURRENT_JOURNAL_VERSION = 2
CURRENT_LOCK_VERSION = 1
Strict NDJSON line validation, per-record CRC-32 checking, and CRC-verified v1 to v2 upgrade in memory before replay.

Forward-Overwrite Guard: Before writing to an existing .curvebook, .cbtemplate, or .curvebook.d/ target (save_project_file, save_template_file, save_project_unpacked_dir), CurveBook inspects the existing target's metadata on disk and refuses to overwrite any file or directory carrying schema_version > CURRENT_SCHEMA_VERSION, leaving newer collaborator files intact byte-for-byte.


WAL Crash Recovery (CrashRecoveryJournal) & Autosave

Desktop GUI sessions (curvebook, unless CURVEBOOK_NO_PREFS=1 is set) attach a directory-backed WAL CrashRecoveryJournal (crates/format/src/recovery.rs) under the platform recovery directory (or <portable>/curvebook-data/recovery/):

Recovery FilePurposeLimits & Integrity
curvebook.lockJournalLockLease (owner_id, host_id, acquired_epoch_ms, ttl_ms) preventing concurrent journal corruption across active processes.Automatically detects expired leases and dead local PIDs on the same host for safe reclaim (is_dead_same_host_owner), or isolates parallel instances into separate directories.
snapshot.curvebookFull periodic baseline archive snapshot written on open and at structural/checkpoint commands (command_requires_wal_checkpoint, or bounded journal rotation).Same CRC-32 & archive limits (64 MiB web storage JSON cap).
ops.journalAppend-only NDJSON log of JournalOpRecord { format_version, seq, crc32, command_json } (CURRENT_JOURNAL_VERSION = 2; v1 records upgrade in memory after CRC-32 verification before replay) flushed after mutating engine commands.MAX_JOURNAL_BYTES = 32 MiB, MAX_JOURNAL_LINE_BYTES = 16 MiB, MAX_JOURNAL_RECORDS = 65,536. Tail truncation or CRC-32 mismatch stops replay cleanly at the last valid record and emits JournalRecoveryWarning diagnostics.

Supported Interchange Formats & CSV Parsing Rules

All import and export adapters register through FormatRegistry (crates/format/src/registry.rs):

  • Supported Imports:
    • .curvebook (native project archive) and .curvebook.d/ (unpacked directory)
    • .cbtemplate (native template archive)
    • .csv / .tsv / delimited text (table.importCsv, table.paste)
    • .pzfx XML files (table.importPzfx, parsing tables, subcolumn modes, row/column titles, Excluded="1" masks, and Info constants strictly at the format boundary)
    • .prism ZIP containers (table.importPrism, bounded ZIP reader extracting tabular CSVs, optional table/info metadata JSON, or embedded XML tables while emitting non-fatal ImportWarning entries for unrecognized binary or script chunks)
    • .xlsx workbooks (table.importXlsx, bounded OOXML spreadsheet reader importing worksheet tables while emitting non-fatal ImportWarning entries for skipped archive parts or unsupported elements)
  • Import Warnings & Replace-or-Merge Behavior:
    • Non-fatal ImportWarning entries produced by .pzfx, .prism, and .xlsx imports (e.g., skipped archive parts) are surfaced in the desktop Import Warnings panel (reopenable from the status bar or File › Import › Import Warnings…) and exposed via ui.inspect.
    • When importing .prism, .pzfx, or .xlsx into an open project that has unsaved changes or existing sheets, CurveBook prompts before replacing the workspace, offering Add to current project (merge: true) alongside Open as new project (merge: false).
  • Supported Exports:
    • .curvebook, .curvebook.d/, .cbtemplate
    • Table delimited export (table.exportCsv / export_datasheet_to_csv), Export All Data Tables… (ui.export.allTablesCsv, folder picker writing one delimited file per DataSheet, named from the sanitized table title), Result sheet single-tab or tidy delimited export (analysis.exportCsv), and Result sheet structured JSON (analysis.exportJson)
    • Publication figures: SVG, %PDF-1.7, PNG, TIFF, and ECMA-234 .emf (Graphs & Export Capabilities)
    • Save Methods Report… (result.generateReport): writes plain, markdown, or latex analytical methods summaries, with output format selected by file extension (.txt, .md, .tex).

CSV / TSV Parsing & Formatting Rules (CsvOptions)

  • Limits: MAX_CSV_FILE_BYTES = 64 MiB, MAX_IMPORT_CELLS = 10,000,000 dense cells.
  • RFC-4180 Quotes & BOM: Strips leading UTF-8 BOM (\u{FEFF}), honors standard double-quote escaping (""), and preserves embedded newlines within quoted fields.
  • Auto-Detection (CsvOptions::detect): Inspects the first 10 non-empty lines to distinguish \t (TSV), ; (European CSV with , decimal), and , (standard CSV with . decimal). Presets include CsvOptions::csv(), CsvOptions::tsv(), and CsvOptions::european_csv().
  • Exclusion Syntax & Missing Sentinels: When parse_asterisk_exclusions == true (default), numeric tokens prefixed with * (e.g., *4.52) import as excluded numeric cells (Cell { value: Number(4.52), excluded: true }). Empty cells and recognized missing sentinels (e.g., NA, NaN, null) map cleanly to CellValue::Empty.
  • Default CSV / TSV Export Behavior: analysis.exportCsv defaults to exporting all result tabs in tidy format using , as the delimiter and the active locale preset's decimal separator (or a single selected tab when tab_id or tab_index is specified). table.exportCsv uses the same delimiter and decimal separator choices, and saving with a .tsv extension automatically selects the tab (\t) delimiter.
Ready · Offline Desktop · CLI · Local MCP Pure Rust Zero Telemetry MIT / Apache-2.0