Migration: calternal migrate-v0 (M1-M9) + user create #51

Closed
kayg wants to merge 0 commits from issue/12-migrate-v0-2 into dev
Owner

Part of #12 (step 2: the tool plus a dry run on staging).

calternal migrate-v0 --from <v0 user dir> --to <home> --report <file> [--dry-run] [--overwrite-edited], a new crate crates/migrate-v0 implementing kayg's decisions M1-M9 (ADR 0034 updated).

  • M1 day notes become YYYY-MM-DD.md with id day-YYYY-MM-DD (the same id the daily-notes plugin derives, agreed with #8), and v0's generated daily heading and title are removed. Other notes become <Title>.md (from title:, then the H1, then the file name), with a number added when names clash.
  • M2 links are repaired by file name, date, title, slug or alias and written as [t](<Note.md>). Unmatched links stay as written and are reported. [[wikilinks]] always become standard links. Code blocks and inline code are never touched.
  • M3, M5 frontmatter keys are dropped, times move to ISO +05:30, empty last edited: is filled from the file time, and aliases stay.
  • M4 unreferenced ^ids are stripped. M6 conflict copies are not migrated. M7 tasks blocks are stripped and listed.
  • M8 only notes and the files they link to move.
  • Safety: the v0 Home is only read. The same input always gives the same bytes. A file edited after a run is never overwritten unless asked.

Tests: 22 new tests cover every rule on synthetic v0 Homes, plus idempotency (same dir and a fresh dir), the edited-file guard and dry runs. The whole workspace passes: 152 tests, clippy -D warnings clean.

Real data on staging (read-only copy off prod):

  • 693 notes migrated, all adopted by a real calternal serve with day-* ids.
  • A second run is a no-op.
  • Debian and Nix builds produce byte-identical output.
  • The summary (counts only) is on #12.
  • The migrated Home is at /mnt/hdd/calternal-migrate/home on calternal-staging. It is installed into kayg's next account only after the account exists, with the service stopped (see crates/migrate-v0/README.md).

Also in this PR (rebased onto dev, after #46 and #47):

  • calternal user create <name> makes a person with no passkey and prints a one-time token that enrolls their first passkey. It's a recovery token bound to that person. Any unused first-owner token stops working, and sign-in status offers setup while nobody has a passkey. Six new tests: enrolment as the same person, exactly once under a storm, expiry, unique names, an old first-owner token refused, and no leaks before sign-in. 176 workspace tests pass.
  • deploy/next/remote.sh stop | start for data maintenance: stop stops the service and takes a snapshot, and start starts it and waits for a healthy check.

🤖 Generated with Claude Code

https://claude.ai/code/session_018Yyy8fQGxPLkLa8v8NXz7T

Part of #12 (step 2: the tool plus a dry run on staging). `calternal migrate-v0 --from <v0 user dir> --to <home> --report <file> [--dry-run] [--overwrite-edited]`, a new crate `crates/migrate-v0` implementing kayg's decisions M1-M9 (ADR 0034 updated). - **M1** day notes become `YYYY-MM-DD.md` with id `day-YYYY-MM-DD` (the same id the daily-notes plugin derives, agreed with #8), and v0's generated daily heading and title are removed. Other notes become `<Title>.md` (from `title:`, then the H1, then the file name), with a number added when names clash. - **M2** links are repaired by file name, date, title, slug or alias and written as `[t](<Note.md>)`. Unmatched links stay as written and are reported. `[[wikilinks]]` always become standard links. Code blocks and inline code are never touched. - **M3, M5** frontmatter keys are dropped, times move to ISO +05:30, empty `last edited:` is filled from the file time, and `aliases` stay. - **M4** unreferenced `^ids` are stripped. **M6** conflict copies are not migrated. **M7** `tasks` blocks are stripped and listed. - **M8** only notes and the files they link to move. - **Safety:** the v0 Home is only read. The same input always gives the same bytes. A file edited after a run is never overwritten unless asked. **Tests:** 22 new tests cover every rule on synthetic v0 Homes, plus idempotency (same dir and a fresh dir), the edited-file guard and dry runs. The whole workspace passes: 152 tests, clippy `-D warnings` clean. **Real data on staging (read-only copy off prod):** - 693 notes migrated, all adopted by a real `calternal serve` with `day-*` ids. - A second run is a no-op. - Debian and Nix builds produce byte-identical output. - The summary (counts only) is on #12. - The migrated Home is at `/mnt/hdd/calternal-migrate/home` on calternal-staging. It is installed into kayg's next account only after the account exists, with the service stopped (see `crates/migrate-v0/README.md`). **Also in this PR (rebased onto dev, after #46 and #47):** - **`calternal user create <name>`** makes a person with no passkey and prints a one-time token that enrolls their first passkey. It's a recovery token bound to that person. Any unused first-owner token stops working, and sign-in status offers setup while nobody has a passkey. Six new tests: enrolment as the same person, exactly once under a storm, expiry, unique names, an old first-owner token refused, and no leaks before sign-in. 176 workspace tests pass. - **`deploy/next/remote.sh stop | start`** for data maintenance: `stop` stops the service and takes a snapshot, and `start` starts it and waits for a healthy check. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_018Yyy8fQGxPLkLa8v8NXz7T
Implements kayg's decisions M1-M9 (#12): day notes become YYYY-MM-DD.md
with id day-YYYY-MM-DD, other notes <Title>.md; links repaired by file
name, date, title, slug or alias and written as [t](<Note.md>), the rest
kept and reported; wikilinks always become standard links; navigation
keys, uid/type/slug/calternal-events/calternal-reminders dropped; dates
to ISO +05:30, empty last edited filled from the file time; unreferenced
^ids and tasks query blocks stripped; conflict copies not migrated; only
notes and the files they link to move.

The v0 Home is only read. Same input, same bytes; files edited after a
run are never overwritten without --overwrite-edited. Code is never
rewritten. ADR 0034 updated.

Part of #12

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018Yyy8fQGxPLkLa8v8NXz7T
Sign-in: calternal user create, so a Home can be filled before first sign-in
All checks were successful
CI / rust (pull_request) Successful in 58s
CI / web (pull_request) Successful in 59s
80631e5608
`calternal user create <name>` makes a person with no passkey and prints
a one-time token that enrolls their first one (a recovery token bound to
that person). Any unused first-owner token stops working, so no stranger
can become a second owner. The sign-in status offers setup while nobody
has a passkey. Tested like recovery: enrolment as the same person,
exactly once under a storm, expiry, unique names, no leaks before sign-in.

deploy/next/remote.sh gains `stop` (stop + snapshot) and `start` (start +
health check) for maintenance on the data.

Part of #12

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018Yyy8fQGxPLkLa8v8NXz7T
Author
Owner

Reviewed by Claude: migration rules M1-M9 with 22 tests and byte-identical reruns; user create binds a one-time token to an existing passkey-less user, invalidates any first-owner token (no owner hijack), exactly-once under 12 concurrent finishes. CI green. Merging.

Reviewed by Claude: migration rules M1-M9 with 22 tests and byte-identical reruns; user create binds a one-time token to an existing passkey-less user, invalidates any first-owner token (no owner hijack), exactly-once under 12 concurrent finishes. CI green. Merging.
Author
Owner

Closing: this branch is already fully contained in dev (it landed through a merge train). Branch cleanup, 2026-10-15.

Closing: this branch is already fully contained in `dev` (it landed through a merge train). Branch cleanup, 2026-10-15.
kayg closed this pull request 2026-10-15 08:35:31 +00:00
All checks were successful
CI / rust (pull_request) Successful in 58s
CI / web (pull_request) Successful in 59s

Pull request closed

Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
kayg/calternal!51
No description provided.