gabriel / musehub public
refactor BREAKING auth task/auth-challenge-nonce-pk #1 / 1
AI Agent gabriel · 135 days ago · May 4, 2026 · Diff

refactor(auth): drop challenge_id surrogate; promote nonce_hex to PK

MusehubAuthChallenge.challenge_id was a UUID surrogate that earned nothing — nonce_hex was already UNIQUE, already the lookup key in all service code, and is the cryptographic identity of a challenge by definition.

Changes: - Drop challenge_id column from model and DB - Make nonce_hex the primary_key=True column - Remove redundant UniqueConstraint on nonce_hex (PK implies uniqueness) - Remove import uuid and _new_uuid() from musehub_auth_models.py - Alembic 0022: migrate the live table (drop PK, drop column, drop UQ, add new PK) - TDD: test_nonce_is_primary_key asserts challenge_id is gone and nonce_hex is PK

sha256:25fcc3cf9f4d4c8df0981a16b8a4e25251fd6c07630ecfe4281274a1d3f064e4 sha
+86 ~76 −10 symbols
sha256:f70ff831ba052b4ff9a6bc9fd6f470233f427a7d7a9f4709934dc15d12624030 snapshot
+86
symbols added
~76
symbols modified
−10
symbols removed
0
dead code introduced
Semantic Changes 172 symbols
+ branch_labels variable variable branch_labels L17–17
+ depends_on variable variable depends_on L18–18
+ down_revision variable variable down_revision L16–16
+ downgrade function function downgrade L35–51
+ annotations import import annotations L10–10
+ op import import op L12–12
+ sa import import sa L13–13
+ revision variable variable revision L15–15
+ upgrade function function upgrade L21–32
~ tests/test_model_defaults.py .py 35 symbols added
+ _BRANCH_ID variable variable _BRANCH_ID L22–22
+ _COLLAB_ID variable variable _COLLAB_ID L29–29
+ _COMMIT_ID variable variable _COMMIT_ID L23–23
+ _IDENTITY_ID variable variable _IDENTITY_ID L25–25
+ _ISSUE_ID variable variable _ISSUE_ID L26–26
+ _KEY_ID variable variable _KEY_ID L28–28
+ _OWNER_ID variable variable _OWNER_ID L21–21
+ _PROPOSAL_ID variable variable _PROPOSAL_ID L27–27
+ _REPO_ID variable variable _REPO_ID L20–20
+ _SNAP_ID variable variable _SNAP_ID L24–24
+ MusehubAuthKey import import MusehubAuthKey L16–16
+ MusehubBranch import import MusehubBranch L18–18
+ MusehubCollaborator import import MusehubCollaborator L17–17
+ MusehubCommit import import MusehubCommit L18–18
+ MusehubIdentity import import MusehubIdentity L18–18
+ MusehubIssue import import MusehubIssue L18–18
+ MusehubProposal import import MusehubProposal L18–18
+ MusehubRepo import import MusehubRepo L18–18
+ MusehubSnapshot import import MusehubSnapshot L18–18
+ annotations import import annotations L10–10
+ datetime import import datetime L12–12
+ fake_id import import fake_id L14–14
+ timezone import import timezone L12–12
+ test_musehub_auth_key_defaults_at_construction function function test_musehub_auth_key_defaults_at_construction L140–150
+ test_musehub_branch_defaults_at_construction function function test_musehub_branch_defaults_at_construction L165–171
+ test_musehub_collaborator_defaults_at_construction function function test_musehub_collaborator_defaults_at_construction L153–162
+ test_musehub_commit_defaults_at_construction function function test_musehub_commit_defaults_at_construction L187–211
+ test_musehub_identity_defaults_at_construction function function test_musehub_identity_defaults_at_construction L82–92
+ test_musehub_issue_defaults_at_construction function function test_musehub_issue_defaults_at_construction L95–112
+ test_musehub_label_defaults_at_construction function function test_musehub_label_defaults_at_construction L174–184
+ test_musehub_proposal_defaults_at_construction function function test_musehub_proposal_defaults_at_construction L115–137
+ test_musehub_repo_mutable_defaults_are_isolated function function test_musehub_repo_mutable_defaults_are_isolated L49–56
+ test_musehub_repo_scalar_defaults_at_construction function function test_musehub_repo_scalar_defaults_at_construction L32–46
+ test_musehub_repo_timestamps_set_at_construction function function test_musehub_repo_timestamps_set_at_construction L59–68
+ test_musehub_snapshot_defaults_at_construction function function test_musehub_snapshot_defaults_at_construction L71–79
+ _repo function function _repo L20–32
+ AsyncSession import import AsyncSession L14–14
+ MusehubRepo import import MusehubRepo L17–17
+ annotations import import annotations L9–9
+ compute_identity_id import import compute_identity_id L16–16
+ compute_repo_id import import compute_repo_id L16–16
+ datetime import import datetime L11–11
+ pytest import import pytest L13–13
+ test_SR1_default_branch_after_flush_refresh function async_function test_SR1_default_branch_after_flush_refresh L35–43
+ test_SR2_updated_at_after_flush_refresh function async_function test_SR2_updated_at_after_flush_refresh L46–55
+ test_SR3_created_at_after_flush_refresh function async_function test_SR3_created_at_after_flush_refresh L75–84
+ test_SR4_server_default_after_prior_commit function async_function test_SR4_server_default_after_prior_commit L58–72
~ musehub/core/genesis.py .py 5 symbols added
+ compute_bridge_mirror_id function function compute_bridge_mirror_id L482–491
+ compute_domain_install_id function function compute_domain_install_id L498–507
+ compute_issue_event_id function function compute_issue_event_id L514–528
+ compute_job_id function function compute_job_id L535–545
+ compute_webhook_delivery_id function function compute_webhook_delivery_id L552–566
~ musehub/db/muse_cli_models.py .py 1 symbol removed, 1 symbol modified
uuid import import uuid L10–10
~ musehub/db/musehub_auth_models.py .py 1 symbol added, 2 symbols removed, 4 symbols modified
_new_uuid function function _new_uuid L46–47
uuid import import uuid L36–36
+ MappedAsDataclass class import MappedAsDataclass L39–39
~ Mapped
~ musehub/db/musehub_collaborator_models.py .py 1 symbol added, 3 symbols modified
+ MappedAsDataclass class import MappedAsDataclass L12–12
~ Mapped
~ musehub/db/musehub_domain_models.py .py 2 symbols removed, 1 symbol modified
_new_uuid function function _new_uuid L31–32
uuid import import uuid L20–20
~ musehub/db/musehub_label_models.py .py 1 symbol added, 4 symbols modified
+ MappedAsDataclass class import MappedAsDataclass L14–14
~ Mapped
~ musehub/db/musehub_models.py .py 1 symbol added, 2 symbols removed, 13 symbols modified
_new_uuid function function _new_uuid L36–37
uuid import import uuid L24–24
+ MappedAsDataclass class import MappedAsDataclass L28–28
~ Mapped
~ musehub/main.py .py 1 symbol modified
~ musehub/services/bridge_service.py .py 1 symbol added, 1 symbol modified
+ compute_bridge_mirror_id import import compute_bridge_mirror_id L20–20
~ musehub/services/musehub_domains.py .py 1 symbol added, 1 symbol removed, 2 symbols modified
uuid import import uuid L9–9
+ compute_domain_install_id import import compute_domain_install_id L16–16
~ musehub/services/musehub_issues.py .py 1 symbol added, 5 symbols modified
+ compute_issue_event_id import import compute_issue_event_id L25–25
~ musehub/services/musehub_jobs.py .py 1 symbol added, 1 symbol modified
+ compute_job_id import import compute_job_id L40–40
~ musehub/services/musehub_webhook_dispatcher.py .py 1 symbol added, 2 symbols removed, 3 symbols modified
_new_uuid function function _new_uuid L62–63
uuid import import uuid L27–27
+ compute_webhook_delivery_id import import compute_webhook_delivery_id L33–33
~ tests/test_clones_stress.py .py 1 symbol modified
~ tests/test_genesis_ids.py .py 15 symbols added, 21 symbols modified
+ test_bridge_mirror_id_canonical method method test_bridge_mirror_id_canonical L199–200
+ test_domain_install_id_canonical method method test_domain_install_id_canonical L202–203
+ test_issue_event_id_canonical method method test_issue_event_id_canonical L205–206
+ test_job_id_canonical method method test_job_id_canonical L208–209
+ test_webhook_delivery_id_canonical method method test_webhook_delivery_id_canonical L211–212
+ _BRIDGE_MIRROR_ID variable variable _BRIDGE_MIRROR_ID L147–147
+ _DOMAIN_INSTALL_ID variable variable _DOMAIN_INSTALL_ID L148–148
+ _ISSUE_EVENT_ID variable variable _ISSUE_EVENT_ID L149–149
+ _JOB_ID variable variable _JOB_ID L150–150
+ _WEBHOOK_DELIVERY_ID variable variable _WEBHOOK_DELIVERY_ID L151–151
+ compute_bridge_mirror_id import import compute_bridge_mirror_id L74–74
+ compute_domain_install_id import import compute_domain_install_id L74–74
+ compute_issue_event_id import import compute_issue_event_id L74–74
+ compute_job_id import import compute_job_id L74–74
+ compute_webhook_delivery_id import import compute_webhook_delivery_id L74–74
+ test_nonce_is_primary_key function async_function test_nonce_is_primary_key L196–221
← Older Oldest on task/auth-challenge-nonce-pk
All commits
Newer → Latest on task/auth-challenge-nonce-pk

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:25fcc3cf9f4d4c8df0981a16b8a4e25251fd6c07630ecfe4281274a1d3f064e4 --body "your comment"