gabriel / musehub public
refactor BREAKING task/json-to-jsonb-and-array #1 / 1
AI Agent gabriel · 131 days ago · May 4, 2026 · Diff

refactor: promote all JSON columns to JSONB or PostgreSQL ARRAY

Two classes of change:

1. Homogeneous list[str]/list[ID] columns → ARRAY(text[]) or ARRAY(varchar(128)[]). ARRAY is type-safe at the column level, supports &&/@> GIN operators natively, and has no JSON parsing overhead. Covers: tags, parent_ids, directories, agent_capabilities, pinned_repo_ids, scope, org_members, labels, symbol_anchors, commit_anchors, touched_symbols, events, participants, commits (session), breaking_changes, reviewed_by, depends_on (coord tasks), and mist tags/symbol_anchors.

2. Heterogeneous blob columns → JSONB. Covers: domain_meta, settings, structured_delta, payload (events/jobs/coord), domain_diff, dimension_ref, download_urls, op_payload, gravity_depth_distribution, kinds_json, cycles_json, manifest, commit_metadata, capabilities.

Alembic 0024 migrates all existing data in place using USING clauses.

TDD: 19 tests in test_array_column_types.py + 17 tests in test_jsonb_column_types.py (36 total, all green).

sha256:4bb2ec1e84938461c551731699387c8dbf01fa1337062336aae2583b80a79534 sha
+114 ~37 −4 symbols
sha256:c997360e3af3063763bd92af726e8047760bdadd444ab67f25fe3519d2150ca4 snapshot
+114
symbols added
~37
symbols modified
−4
symbols removed
0
dead code introduced
Semantic Changes 155 symbols
+ _JSONB_COLS variable variable _JSONB_COLS L58–76
+ _TEXT_ARRAY_COLS variable variable _TEXT_ARRAY_COLS L31–46
+ _VARCHAR_ARRAY_COLS variable variable _VARCHAR_ARRAY_COLS L49–55
+ branch_labels variable variable branch_labels L24–24
+ depends_on variable variable depends_on L25–25
+ down_revision variable variable down_revision L23–23
+ downgrade function function downgrade L103–116
+ JSONB import import JSONB L20–20
+ annotations import import annotations L16–16
+ op import import op L18–18
+ sa import import sa L19–19
+ revision variable variable revision L22–22
+ upgrade function function upgrade L79–100
~ tests/test_array_column_types.py .py 43 symbols added
+ TestCoordTaskArray class class TestCoordTaskArray L111–113
+ test_depends_on method method test_depends_on L112–113
+ TestMusehubCommitArray class class TestMusehubCommitArray L44–52
+ test_breaking_changes method method test_breaking_changes L48–49
+ test_parent_ids method method test_parent_ids L45–46
+ test_reviewed_by method method test_reviewed_by L51–52
+ TestMusehubIdentityArray class class TestMusehubIdentityArray L60–71
+ test_agent_capabilities method method test_agent_capabilities L61–62
+ test_org_members method method test_org_members L70–71
+ test_pinned_repo_ids method method test_pinned_repo_ids L64–65
+ test_scope method method test_scope L67–68
+ TestMusehubIssueArray class class TestMusehubIssueArray L74–82
+ test_commit_anchors method method test_commit_anchors L81–82
+ test_labels method method test_labels L75–76
+ test_symbol_anchors method method test_symbol_anchors L78–79
+ TestMusehubMistArray class class TestMusehubMistArray L103–108
+ test_symbol_anchors method method test_symbol_anchors L107–108
+ test_tags method method test_tags L104–105
+ TestMusehubProposalArray class class TestMusehubProposalArray L85–87
+ test_touched_symbols method method test_touched_symbols L86–87
+ TestMusehubRepoArray class class TestMusehubRepoArray L39–41
+ test_tags method method test_tags L40–41
+ TestMusehubSessionArray class class TestMusehubSessionArray L95–100
+ test_commits method method test_commits L99–100
+ test_participants method method test_participants L96–97
+ TestMusehubSnapshotArray class class TestMusehubSnapshotArray L55–57
+ test_directories method method test_directories L56–57
+ TestMusehubWebhookArray class class TestMusehubWebhookArray L90–92
+ test_events method method test_events L91–92
+ _assert_array function function _assert_array L31–36
+ _col_type function function _col_type L27–28
+ ARRAY import import ARRAY L11–11
+ MusehubCommit import import MusehubCommit L14–14
+ MusehubCoordTask import import MusehubCoordTask L13–13
+ MusehubIdentity import import MusehubIdentity L14–14
+ MusehubIssue import import MusehubIssue L14–14
+ MusehubMist import import MusehubMist L14–14
+ MusehubProposal import import MusehubProposal L14–14
+ MusehubRepo import import MusehubRepo L14–14
+ MusehubSession import import MusehubSession L14–14
+ MusehubSnapshot import import MusehubSnapshot L14–14
+ MusehubWebhook import import MusehubWebhook L14–14
+ annotations import import annotations L9–9
~ tests/test_jsonb_column_types.py .py 52 symbols added
+ TestCoordModelsJsonb class class TestCoordModelsJsonb L102–107
+ test_coord_record_payload method method test_coord_record_payload L103–104
+ test_coord_task_payload method method test_coord_task_payload L106–107
+ TestMuseCliModelsJsonb class class TestMuseCliModelsJsonb L110–115
+ test_commit_metadata method method test_commit_metadata L114–115
+ test_snapshot_manifest method method test_snapshot_manifest L111–112
+ TestMusehubBackgroundJobJsonb class class TestMusehubBackgroundJobJsonb L77–79
+ test_payload method method test_payload L78–79
+ TestMusehubCommitJsonb class class TestMusehubCommitJsonb L52–54
+ test_structured_delta method method test_structured_delta L53–54
+ TestMusehubDomainJsonb class class TestMusehubDomainJsonb L118–120
+ test_capabilities method method test_capabilities L119–120
+ TestMusehubIntelCodemapMetaJsonb class class TestMusehubIntelCodemapMetaJsonb L97–99
+ test_cycles_json method method test_cycles_json L98–99
+ TestMusehubIntelLanguagesJsonb class class TestMusehubIntelLanguagesJsonb L92–94
+ test_kinds_json method method test_kinds_json L93–94
+ TestMusehubIssueEventJsonb class class TestMusehubIssueEventJsonb L57–59
+ test_payload method method test_payload L58–59
+ TestMusehubProposalCommentJsonb class class TestMusehubProposalCommentJsonb L67–69
+ test_dimension_ref method method test_dimension_ref L68–69
+ TestMusehubProposalJsonb class class TestMusehubProposalJsonb L62–64
+ test_domain_diff method method test_domain_diff L63–64
+ TestMusehubReleaseJsonb class class TestMusehubReleaseJsonb L72–74
+ test_download_urls method method test_download_urls L73–74
+ TestMusehubRepoJsonb class class TestMusehubRepoJsonb L44–49
+ test_domain_meta method method test_domain_meta L45–46
+ test_settings method method test_settings L48–49
+ TestMusehubSymbolHistoryEntryJsonb class class TestMusehubSymbolHistoryEntryJsonb L82–84
+ test_op_payload method method test_op_payload L83–84
+ TestMusehubSymbolIntelJsonb class class TestMusehubSymbolIntelJsonb L87–89
+ test_gravity_depth_distribution method method test_gravity_depth_distribution L88–89
+ _assert_jsonb function function _assert_jsonb L36–41
+ _col_type function function _col_type L32–33
+ JSONB import import JSONB L12–12
+ MuseCliCommit import import MuseCliCommit L15–15
+ MuseCliSnapshot import import MuseCliSnapshot L15–15
+ MusehubBackgroundJob import import MusehubBackgroundJob L17–17
+ MusehubCommit import import MusehubCommit L17–17
+ MusehubCoordRecord import import MusehubCoordRecord L14–14
+ MusehubCoordTask import import MusehubCoordTask L14–14
+ MusehubDomain import import MusehubDomain L16–16
+ MusehubIntelCodemapMeta import import MusehubIntelCodemapMeta L17–17
+ MusehubIntelLanguages import import MusehubIntelLanguages L17–17
+ MusehubIssueEvent import import MusehubIssueEvent L17–17
+ MusehubProposal import import MusehubProposal L17–17
+ MusehubProposalComment import import MusehubProposalComment L17–17
+ MusehubRelease import import MusehubRelease L17–17
+ MusehubRepo import import MusehubRepo L17–17
+ MusehubSymbolHistoryEntry import import MusehubSymbolHistoryEntry L17–17
+ MusehubSymbolIntel import import MusehubSymbolIntel L17–17
+ annotations import import annotations L9–9
+ pytest import import pytest L11–11
~ musehub/db/coord_models.py .py 2 symbols added, 1 symbol removed, 9 symbols modified
JSON import import JSON L39–39
+ ARRAY import import ARRAY L37–37
+ JSONB import import JSONB L39–39
~ Index
~ String
~ musehub/db/muse_cli_models.py .py 1 symbol added, 1 symbol removed, 2 symbols modified
JSON import import JSON L13–13
+ JSONB import import JSONB L13–13
~ musehub/db/musehub_domain_models.py .py 1 symbol added, 1 symbol removed, 1 symbol modified
JSON import import JSON L24–24
+ JSONB import import JSONB L24–24
← Older Oldest on task/json-to-jsonb-and-array
All commits
Newer → Latest on task/json-to-jsonb-and-array

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:4bb2ec1e84938461c551731699387c8dbf01fa1337062336aae2583b80a79534 --body "your comment"