Skip to content

fix(vault): prove the rebuild really deployed, and report what it moved - #18

Merged
pyramation merged 1 commit into
mainfrom
fix/rebuild-verify-deploy
Aug 8, 2026
Merged

fix(vault): prove the rebuild really deployed, and report what it moved#18
pyramation merged 1 commit into
mainfrom
fix/rebuild-verify-deploy

Conversation

@pyramation

Copy link
Copy Markdown
Contributor

Summary

"Rebuild database" gave no evidence it did anything, so a skipped deploy would have been indistinguishable from a working one. Two changes, both about making the operation verifiable.

It cannot silently deploy nothing. deployFresh now checks the schema it just deployed before anything is copied into it:

handle.unregister();
await Vault.assertDeployed(handle.db);   // throws unless dcrypt_vault has every COPY_ORDER table

For the record on the original worry — pgpm skipping because of its ledger — that can't happen here: registerPglite() hands back a brand-new in-memory PGlite with no pgpm_migrate schema at all (fast: true keeps no ledger), so every rebuild is a first deploy. Verified directly: the log lines a rebuild emits are identical to first-run creation (Deploying local module: pgpm-verify / pgpm-base32 / pgpm-totp / dcrypt-vault), the rebuilt database has 9 dcrypt_vault tables and no pgpm* schema, and the copied ciphertext still decrypts under the same passphrase. The assert is there so a future pgpm that does decide to skip fails loudly instead of leaving an empty database.

It says what it moved. rebuild() returns the counts instead of void:

interface RebuildReport { tables: number; copied: Record<string, number> }

so Settings reports Database rebuilt: 9 tables deployed, 34 rows carried over (12 items). rather than a flat "Every item was carried over."

copyTable returns its row count to feed that; no change to what it copies or to the on-disk format.

Testing

packages/vault: 8 tests pass, including the rebuild test (which now also exercises assertDeployed, since a rebuild that deployed nothing would throw before copying). Desktop lint, 27 tests and build pass.

Link to Devin session: https://app.devin.ai/sessions/04636534e07048089ffb6b78142e12cd
Requested by: @pyramation

A rebuild that silently deployed nothing would look identical to a working one, so assert the fresh schema carries every table before copying, and return per-table row counts for the Settings toast.
@pyramation pyramation self-assigned this Aug 8, 2026
@devin-ai-integration

Copy link
Copy Markdown

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@pyramation
pyramation merged commit 3ea3008 into main Aug 8, 2026
5 checks passed
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.

1 participant