gabriel / muse public
feat patch auth dev
AI Agent gabriel · 144 days ago · Apr 27, 2026 · Diff

feat(auth): guard against accidental mnemonic destruction in keygen

--force now only overwrites the identity entry — it NEVER generates fresh entropy when a mnemonic already exists in the keychain.

To intentionally destroy the mnemonic (irreversible), both flags are required: --force --destroy-mnemonic. Neither alone is sufficient.

Adds 14 tests (I–IV) covering: - mnemonic reuse under --force - blocked destruction without double confirmation - escape hatch requires both flags - fingerprint stability under --force - fingerprint change after --destroy-mnemonic --force - keychain byte-for-byte invariants in both paths

sha256:fb90368bca8f7da71d0276fd34c2da479646b1187d899840efd6f5725334c85e sha
+35 ~3 symbols
sha256:44f0a6d4c765a50af146b56c5ef1adc1e554296b70fa238dc83a27202f3039fb snapshot
+35
symbols added
~3
symbols modified
0
dead code introduced
Semantic Changes 38 symbols
+ TestMnemonicGuardDataIntegrity class class TestMnemonicGuardDataIntegrity L325–402
+ test_IV1_identity_toml_fingerprint_unchanged_after_force method method test_IV1_identity_toml_fingerprint_unchanged_after_force L326–348
+ test_IV2_identity_toml_fingerprint_changes_after_destroy method method test_IV2_identity_toml_fingerprint_changes_after_destroy L350–372
+ test_IV3_keychain_mnemonic_unchanged_after_force method method test_IV3_keychain_mnemonic_unchanged_after_force L374–386
+ test_IV4_keychain_mnemonic_changes_after_destroy_force method method test_IV4_keychain_mnemonic_changes_after_destroy_force L388–402
+ TestMnemonicGuardMessages class class TestMnemonicGuardMessages L288–317
+ test_III1_destroy_mnemonic_no_force_mentions_force method method test_III1_destroy_mnemonic_no_force_mentions_force L289–302
+ test_III2_force_output_never_says_destroyed method method test_III2_force_output_never_says_destroyed L304–317
+ TestMnemonicGuardOutput class class TestMnemonicGuardOutput L253–280
+ test_II1_force_reports_reused method method test_II1_force_reports_reused L254–266
+ test_II2_destroy_mnemonic_force_reports_generated method method test_II2_destroy_mnemonic_force_reports_generated L268–280
+ TestMnemonicGuardUnit class class TestMnemonicGuardUnit L132–245
+ test_I1_no_existing_mnemonic_generates_fresh method method test_I1_no_existing_mnemonic_generates_fresh L133–147
+ test_I2_force_with_existing_mnemonic_reuses_it method method test_I2_force_with_existing_mnemonic_reuses_it L149–170
+ test_I3_destroy_mnemonic_without_force_is_blocked method method test_I3_destroy_mnemonic_without_force_is_blocked L172–191
+ test_I4_destroy_mnemonic_and_force_generates_fresh method method test_I4_destroy_mnemonic_and_force_generates_fresh L193–211
+ test_I5_force_fingerprint_stable method method test_I5_force_fingerprint_stable L213–227
+ test_I6_destroy_mnemonic_force_fingerprint_changes method method test_I6_destroy_mnemonic_force_fingerprint_changes L229–245
+ _HOSTNAME variable variable _HOSTNAME L58–58
+ _HUB variable variable _HUB L57–57
+ _MNEMONIC_A variable variable _MNEMONIC_A L60–63
+ _MNEMONIC_B variable variable _MNEMONIC_B L64–66
+ _get_kc function function _get_kc L123–124
+ _keygen function function _keygen L119–120
+ CliRunner import import CliRunner L50–50
+ Generator import import Generator L45–45
+ annotations import import annotations L42–42
+ id_module import import id_module L52–52
+ kp_module import import kp_module L51–51
+ muse_dir import import muse_dir L53–53
+ patch import import patch L46–46
+ pathlib import import pathlib L44–44
+ pytest import import pytest L48–48
+ isolated function function isolated L75–116
+ runner variable variable runner L55–55
~ muse/cli/commands/auth.py .py 3 symbols modified
← Older Oldest on dev
All commits
Newer → Latest on dev

0 comments

No comments yet. Be the first to start the discussion.

To add a comment, use the Muse CLI: muse hub commit comment sha256:fb90368bca8f7da71d0276fd34c2da479646b1187d899840efd6f5725334c85e --body "your comment"