Repository navigation
feat(migrate): ColumnMigration owns the rules of a column migration #1276
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
ebd7033
feat(migrate): add ColumnMigration and move the engine's opt-in rules…
claude e0ba9d0
refactor(cli): resolve every decrypt command through ColumnMigration
claude bde5b73
docs(skills): describe the forced-pass and waiver rules ColumnMigrati…
claude e464c66
refactor(cli): split decrypt status into row builders
claude 7928e22
chore: address review of the ColumnMigration work
claude f22c8c0
test(cli): leave no cipherstash schema behind from the decrypt lifecy…
claude 2c489a1
fix(migrate): read obligations from earlier event shapes and record t…
claude c705194
fix(cli): reconcile ColumnMigration with main's decrypt fixes
claude fb838a3
fix(migrate,cli): address review of the column migration API
claude 6a7230e
fix(migrate): name the twin on an observed-absent drop
claude b26a009
fix(migrate): keep the engine's resume fields over caller details
claude bb0c01a
docs(changeset): one sentence per line
claude 97d60b7
fix(migrate): make Obligation and PassPlan discriminated unions
claude 1d9fee6
test(migrate): cover the error-name fallback, batch details, closing …
claude d2c232e
fix(cli): skip forward-only columns in decrypt status before loading …
claude File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| --- | ||
| '@cipherstash/migrate': minor | ||
| 'stash': patch | ||
| --- | ||
|
|
||
| `@cipherstash/migrate` adds `ColumnMigration`, one place for the rules of a column migration in either direction: which twin column it pairs with (the flag, the recorded pairing, the manifest, then the naming convention), its phase, whether a forced pass is owed, and which open migration in the other direction blocks it. | ||
| `ColumnMigration.load()` reads it from `cipherstash.cs_migrations`; `confirmDualWrites()`, `recordDropGenerated()` and `recordSourceRemoved()` record events, refusing those the rules forbid with a `ColumnMigrationError`. | ||
| The pure rules are exported as `deriveColumnMigration`, `openCounterpart`, `planPassFor`, `passProgress`, `deriveTwinName` and `manifestTwin`. | ||
|
|
||
| `runBackfill` and `runDecryptBackfill` now apply the rules themselves rather than leaving them to the caller. | ||
| Every event records whether its pass was forced. | ||
| An interrupted forced pass is finished as one by the next run, with or without `force`, and the result says why in `forcedBy`. | ||
| A forward backfill resumes after a failed run from its last committed position, counts its total once when it resumes a forced pass, and refuses to start while a reverse migration of the same columns is open. | ||
| `runBackfill` now throws a `ColumnMigrationError` with code `twin-mismatch` when `encryptedColumn` differs from the encrypted column already recorded for that column, rather than continuing into a different one. | ||
| A reverse backfill over a twin that already holds values is forced unless the caller confirmed dual-writes with the `plaintext-current` waiver. | ||
| Error events store the error's class (`errorName`) and safe details instead of its message, which could carry row data. | ||
|
|
||
| `stash decrypt plan`, `status`, `backfill` and `drop` resolve every column through `ColumnMigration`, so they always agree on the twin and the phase. | ||
| `decrypt status` flags `forward-open`, `twin-has-values` and `forced-pass-owed`. | ||
| `decrypt backfill --confirm-plaintext-current` is accepted on a later run as long as no forced pass has started, and refused while a started forced pass is owed. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
languages/typescript/packages/cli/src/commands/decrypt/__tests__/backfill-help.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| /** | ||
| * The command registry is plain data with no imports, so `decrypt backfill`'s | ||
| * help writes its flag names and limits as literals. These tests hold them to | ||
| * the constants the command enforces, so the help cannot drift from them. | ||
| */ | ||
|
|
||
| import { MAX_DECRYPT_CHUNK_SIZE } from '@cipherstash/migrate' | ||
| import { describe, expect, it } from 'vitest' | ||
| import { renderCommandHelp } from '@/cli/help.js' | ||
| import { DEFAULT_DECRYPT_CHUNK_SIZE } from '../backfill.js' | ||
| import { TWIN_HAZARD_FLAGS } from '../lib/resolve-pair.js' | ||
|
|
||
| const help = renderCommandHelp('decrypt backfill', 'npx stash') ?? '' | ||
|
|
||
| describe('decrypt backfill help', () => { | ||
| it('states the chunk-size bound and default the command enforces', () => { | ||
| expect(help).toContain(`from 1 to ${MAX_DECRYPT_CHUNK_SIZE}`) | ||
| expect(help).toMatch( | ||
| new RegExp(`--chunk-size <n>[\\s\\S]*${DEFAULT_DECRYPT_CHUNK_SIZE}`), | ||
| ) | ||
| }) | ||
|
|
||
| it.each(Object.values(TWIN_HAZARD_FLAGS))( | ||
| 'offers %s, a way past a twin that holds values, as a flag', | ||
| (flag) => { | ||
| expect(help).toContain(` ${flag}`) | ||
| }, | ||
| ) | ||
| }) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.