8000 V0-15: Add the versioned Nodepad archive workflow by kiran-brahma · Pull Request #35 · kiran-brahma/nodepad-app · GitHub
[go: up one dir, main page]

Skip to content

V0-15: Add the versioned Nodepad archive workflow - #35

Merged
kiran-brahma merged 1 commit into
mainfrom
codex/issue-16-versioned-archive
Jul 23, 2026
Merged

kiran-brahma merged 1 commit into
mainfrom
codex/issue-16-versioned-archive

Conversation

@kiran-brahma
Copy link
Copy Markdown
Owner

Closes #16.

What

Adds the V0 versioned Nodepad archive workflow: export one complete Thinking Workspace as deterministic JSON and import a fully validated archive into a fresh Workspace with collision-safe identity remapping. Validation completes before the transaction begins; import commits all durable data or nothing.

Design (deep modules, no leakage)

  • archive.rs owns the V0 format, deterministic serialization, and full pre-mutation validation. It is pure — no SQLite, no Tauri. Format/version/schema decisions live here alone.
  • workspace.rs owns the SQL extraction (archive_export_data) and the transactional import (import_archive). One transaction: workspace → labels → notes (+ memberships) → relationships (re-canonicalized) → pending syntheses (+ sources/labels) → synthesis history → FTS refresh → commit. A failure at any point rolls back.
  • Reusable durable validators and length constants were promoted to pub(crate) so the archive reuses the same durable rules instead of duplicating limits — one source of truth for each bound.

Acceptance criteria mapping

  • Exported archive has explicit format/version and deterministic durable content (sorted arrays, stable struct field order; only exportedAt/applicationVersion vary).
  • Round-trip preserves all intended domain meaning with fresh identities (Rust test over Unicode, all Note Types, manual/AI provenance, manual/AI Relationships, Labels incl. vocabulary with no Note, pending Synthesis with sources, synthesis history, restart recovery).
  • Imported Workspace is Manual regardless of exported Assistance Policy.
  • Malformed JSON, unknown version, oversize input, invalid enum, duplicate IDs/pairs, broken references, and limit violations fail before mutation.
  • Name and identity collisions cannot overwrite existing data (fresh ids; deterministic (2)/ (3) name suffixing).
  • Import rollback leaves the database unchanged on injected failure (trigger test asserts row counts unchanged).
  • Secrets and transient state are absent from exported bytes (byte-scan test: no selectedModel, cloudConsent, activeWorkspace, undoableCommands, keychain, or the sentinel model id).
  • Canceling either dialog is a successful no-op (frontend tests for export cancel and import cancel).
  • Imported data remains valid after restart and through every view (reopen assertion in round-trip test; data flows through the existing committed snapshot all views read).

Scope fence

No legacy .nodepad import, no partial import/merge, no multi-Workspace export, no encryption, no local provider configuration. Archive extension is .nodepad.json to avoid the legacy .nodepad format.

Delivery workflow evidence

  • Simplicity audit: posted to V0-15: Add the versioned Nodepad archive workflow #16 as a pre-implementation comment (gate: Proceed).
  • Tests:
    • cargo test --lib: 160 passed (12 archive unit tests + round-trip / rollback / byte-scan / collision / malformed integration tests).
    • npx vitest run (project src/): 143 passed (export, import success/cancel/failure UI tests).
  • Gates:
    • npm run typecheck: clean.
    • npm run lint (eslint --max-warnings 0): clean.
    • npm run web:build: green.
    • cargo check: green.
    • npm run test:rust: 160 passed.
  • Fallow (fallow audit --changed-since main): verdict warn with 0 introduced findings (dead-code/complexity/duplication all inherited and pre-existing — out of scope per AGENTS.md).

Notes

  • A pending Synthesis whose source was deleted or moved out of the Workspace is not archived, because its source mapping no longer resolves here and a broken reference is not archivable. Non-stale and edited-source syntheses travel; their source revision is derived from the preserved Note enrichment_revision on import so staleness is correct in the fresh Workspace.
  • Local npm run test discovers stale .claude/worktrees/** test files (gitignored leftovers from prior sessions); on a clean CI checkout there are no such worktrees and the gate passes. Project src/ tests all pass (143/143).

Do not merge without review.

Add the V0 versioned archive format: export one Thinking Workspace as
deterministic JSON and import a fully validated archive into a fresh
Workspace with collision-safe identity remapping.

- archive.rs owns the V0 format, deterministic serialization, and full
  pre-mutation validation (format, version, size, required fields, length
  bounds, enums, unique source ids, label normalization, relationship
  endpoints/pairs, synthesis source ids). No SQLite access.
- workspace.rs owns the SQL extraction (archive_export_data) and the
  transactional import (import_archive): one transaction, fresh ids,
  remapped references, imported Workspace always Manual, name collisions
  append deterministic ' (2)'/' (3)' suffixes, rollback on any failure.
- Reusable durable validators/constants promoted to pub(crate) so the
  archive and the store share one source of truth for every limit.
- Native save/open dialogs with atomic write; cancel is a no-op.
- Export excludes provider keys, selected model, cloud consent, active
  workspace, undo, view state, and paths; durable domain content only.
- Pending Syntheses whose sources left the Workspace are not archived;
  source revision is derived from the preserved Note on import so
  staleness is correct in the fresh Workspace.

Tests: archive format/validation unit tests; Rust round-trip covering
Unicode, all Note Types, manual/AI provenance, manual/AI Relationships,
Labels (including vocabulary with no Note), pending Synthesis with
sources, synthesis history, restart recovery; rollback on injected
failure; byte scan for secrets/transient markers; name collision
suffixing; malformed-before-mutation. Frontend UI tests for export,
import success/cancel/failure.

Closes #16.
@kiran-brahma
kiran-brahma merged commit 0e3ca25 into main Jul 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

V0-15: Add the versioned Nodepad archive workflow

1 participant

0