Repository navigation
Description
Summary
id key import and id key import-seed install the restored private key before flag_restored() writes .id-key-restored or .id-key-client-restored. restored_key::mark_restored currently uses std::fs::write directly on the marker, so it truncates an existing marker in place and does not durably publish the new contents.
If the process or machine stops during/after that write, the restored key may remain installed while the marker is absent, empty, or partial. restored_key() interprets an empty marker as None; pending() only warns when the marker names an active key. A missing/empty or incomplete marker can therefore make later id serve and keyset operations omit the restore-and-rotate warning for a key that was restored from backup.
This is a crash-safety defect in the implemented restore-rotation flag, not a request to add restore/rotation behavior. The marker is intentionally advisory; this issue concerns losing that warning state.
Evidence
Verified on fresh origin/main b03284079be68158b737d7bd8ceccb95f4a0e52e:
pkgs/id/crates/id-directory/src/restored_key.rs:46-50:mark_restoredcallsstd::fs::write(marker, format!("{public_key}\n"))directly.restored_key.rs:57-62: an empty marker is converted toNone, the same result as a missing marker.restored_key.rs:100-111:pending()only returns the marker's key when it is still an active admin key.pkgs/id/crates/id-cli/src/commands/key.rs:85-124: import writes/replaces the private key before callingflag_restored; the marker write follows the key installation.pkgs/id/crates/id-cli/src/commands/serve.rs:1398-1404andcommands/keyset.rs:139-145use the marker to display the warning.id-directoryalready depends onid-core;id_core::durable_write::write_durableprovides a sibling-temp, file-sync, rename, and parent-directory-sync pattern used by otherpkgs/idstate files.
Dedupe
- OPEN id: encrypted identity backup — seed-phrase export/restore + passphrase-wrapped server backup #2381 specifies the restore-forces-rotation feature, which is implemented; this issue is the narrower crash-safety defect in persisting its marker.
- CLOSED fix(id): fsync temp files before rename in SequenceFile, registry and list-store saves #12152/fix(id): fsync temp files before rename in SequenceFile, registry and list-store saves #12153 cover three different counter/registry/list-store writers. CLOSED fix(id): make world namespace and publication registry writes durable #12254/fix(id): durably write namespace and publication state #12255 cover the world namespace and publication registry. Neither includes the restored-key markers.
- Fresh all-state searches for
restored_key,mark_restored, and restored-key rotation markers, plus an open-PR search, found no matching issue or PR.
Acceptance criteria
- Persist both server and client restore markers through a durable atomic-write path (or an equivalent helper): sync complete marker contents before replacing the target, then sync the containing directory.
- Preserve useful path context and ensure a failed marker write does not leave a truncated/empty marker in place.
- Add focused regression coverage for replacing an existing marker and for the durable-write failure boundaries, including that a marker remains readable as the prior or new complete key rather than an empty/partial value.
- Existing restored-key status, serve-warning, and keyset-rotation tests pass.
No source change was made in this audit.
Activity
developing-today commentedon Nov 22, 2026
CODE-4562