fix: hub-scoping migration never actually signed or registered with the hub (musehub#221 follow-up)
Found while planning the real rollout of `muse migrate hub-scoping`: the shared `_make_hub_register_fn` shim used by both `migrate hub-scoping` and `migrate domain-integers` called `_post_challenge`/`_post_verify` with the wrong argument shapes entirely (positional args instead of the payload dicts those functions actually take) and never signed the challenge nonce at all. The resulting TypeError was swallowed by a broad `except Exception`, so a live run would silently report `hub_registered: false` for every entry -- meaning identity.toml would claim a new hub-scoped key while the hub server still only recognized the old one, breaking auth against that hub on the very next request. This was never caught because the test suite only ever exercised `run_migration` with a `MagicMock` hub_register_fn -- the shim itself was untested.
- `_make_hub_register_fn` now takes `seed` and mirrors the real challenge/sign/verify flow from `muse auth register` (auth.py:1656-1703): derives the private key at the *new* hub-scoped path, builds the correct payload dicts, actually signs the nonce with `sign_bytes`, and submits a real signature. Both call sites (`_run_domain_integers`, `_run_hub_scoping`) updated to pass `seed` through. - Added `--hub <url>` to `migrate hub-scoping` so a live run can target one hub at a time instead of migrating every pre-hub-scoping entry (including production) in a single all-or-nothing invocation. - 12 new tests: challenge/verify payload shape, real signature verification against the newly derived public key, fail-closed on a missing challenge_token, fail-closed (not raise) on hub HTTP errors, and CLI-level `--hub` filtering (valid + unknown hub). All new tests mock the HTTP layer only -- no real keychain or network access, per MUSE_KEYCHAIN_BACKEND=disabled discipline.
Verified via `--dry-run` against the real identity.toml: confirms all three real hub entries (localhost, staging, production) still need this migration, with zero writes.
Tests: 48/48 in test_migrate_hub_scoping.py, 116/116 across the full migrate/auth-register targeted set.
Semantic Changes
16 symbols
0 comments
muse hub commit comment sha256:46ec1508d0a0173522de9d4928d536003fbee08f203c47130c60ebb2ee217344 --body "your comment"
No comments yet. Be the first to start the discussion.