gabriel / muse public
test patch task/227-belt-and-suspenders-testing #1 / 1
AI Agent gabriel · 11 hours ago · Sep 18, 2026 · Diff

test: close stress/performance/security gaps for migrate + auth key (musehub#221 follow-up)

Audited coverage against test_auth_rotate.py -- the closest sibling command, which has explicit Stress/Performance/Security sections -- and found this session's new work (migrate hub-scoping fixes, muse auth key list/delete) had unit/integration/e2e-by-this-codebase's-definition coverage but no equivalent Stress or Performance sections, and a thinner Security section than the precedent set.

Fixed two real gaps found while writing the security tests: - run_key_delete's non-JSON success print echoed key_id/fingerprint (hub-controlled and CLI-arg values respectively) without sanitize_display -- a malicious/compromised hub could inject terminal escapes via label/key_id text. Same gap in run_key_list's per-key print loop. Both now sanitize every hub-sourced or arg-sourced field before printing, matching how every other auth command already handles hub-controlled display strings.

Added, mirroring test_auth_rotate.py's TestRotateStress/ TestRotatePerformance/TestRotateSecurity structure:

- TestMigrationStress / TestKeyStress: 20 hub entries migrated in one run with no cross-contamination between results; repeated dry-run and key list calls are deterministic; 10 sequential key deletes each target the correct distinct key_id. - TestMigrationPerformance / TestKeyPerformance: dry-run, live-run (stubbed hub), key list, and key delete each complete under 500ms, matching rotate's existing budget. - TestMigrationSecurity / TestKeySecurity: mnemonic never appears in --json output (dry-run and live-run); no PEM ever written by migration or key list/delete; a hub response exceeding the shared 1 MiB bound fails closed rather than being processed (confirms the migration path actually flows through the bounded _json_post_raw/_hub_get, not a bespoke unbounded parse); an ANSI/OSC escape sequence in a hub-controlled key label is stripped from terminal output, not echoed raw.

Docs: added `muse migrate hub-scoping` and `muse migrate domain-integers` to agent-guide.md's command reference table (including --hub and --no-register) -- neither was ever listed there, even before this session's changes; the table is the canonical trigger-phrase lookup every future session loads via CLAUDE.md's @include.

Tests: 173/173 across migrate hub-scoping/domain-integers + auth key + rotate + register-integrity.

sha256:61dbe1cc1d20bde7f272f0eac47aafcf5748b034ca85d052183985e9d2bbaabe sha
+23 ~5 symbols
sha256:d1973fbd7ddc25f6b1f01faa9d836d6a7d1a46d3c5954d0acc5980ac68446ada snapshot
+23
symbols added
~5
symbols modified
0
dead code introduced
Semantic Changes 28 symbols
~ tests/test_auth_key_list_delete.py .py 12 symbols added
+ TestKeyPerformance class class TestKeyPerformance L332–371
+ test_delete_completes_under_500ms method method test_delete_completes_under_500ms L351–371
+ test_list_completes_under_500ms method method test_list_completes_under_500ms L336–349
+ TestKeySecurity class class TestKeySecurity L216–324
+ test_ansi_escape_in_hub_label_is_stripped_from_terminal_output method method test_ansi_escape_in_hub_label_is_stripped_from_terminal_output L303–324
+ test_malicious_hub_response_size_is_bounded method method test_malicious_hub_response_size_is_bounded L266–301
+ test_mnemonic_not_in_delete_json_output method method test_mnemonic_not_in_delete_json_output L230–244
+ test_mnemonic_not_in_list_json_output method method test_mnemonic_not_in_list_json_output L221–228
+ test_no_pem_written_during_list_or_delete method method test_no_pem_written_during_list_or_delete L246–264
+ TestKeyStress class class TestKeyStress L379–437
+ test_repeated_list_calls_are_stable method method test_repeated_list_calls_are_stable L383–403
+ test_ten_sequential_deletes_of_distinct_fingerprints method method test_ten_sequential_deletes_of_distinct_fingerprints L405–437
~ tests/test_migrate_hub_scoping.py .py 11 symbols added
+ TestMigrationPerformance class class TestMigrationPerformance L1219–1283
+ test_dry_run_completes_under_500ms method method test_dry_run_completes_under_500ms L1220–1247
+ test_live_run_with_stubbed_hub_completes_under_500ms method method test_live_run_with_stubbed_hub_completes_under_500ms L1249–1283
+ TestMigrationSecurity class class TestMigrationSecurity L1075–1209
+ test_malicious_add_key_response_size_is_bounded method method test_malicious_add_key_response_size_is_bounded L1166–1209
+ test_mnemonic_not_in_dry_run_json_output method method test_mnemonic_not_in_dry_run_json_output L1076–1098
+ test_mnemonic_not_in_live_run_json_output method method test_mnemonic_not_in_live_run_json_output L1100–1129
+ test_no_pem_written_during_migration method method test_no_pem_written_during_migration L1131–1164
+ TestMigrationStress class class TestMigrationStress L1293–1349
+ test_repeated_dry_run_calls_are_stable method method test_repeated_dry_run_calls_are_stable L1320–1349
+ test_twenty_hub_entries_migrate_correctly_in_one_run method method test_twenty_hub_entries_migrate_correctly_in_one_run L1294–1318
← Older Oldest on task/227-belt-and-suspenders-testing
All commits
Newer → Latest on task/227-belt-and-suspenders-testing

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:61dbe1cc1d20bde7f272f0eac47aafcf5748b034ca85d052183985e9d2bbaabe --body "your comment"