Skip to content

feat(store): migrate channels + channel_pins + coordination to sqlc (T3) - #792

Merged
mattwilkinsonn merged 1 commit into
mainfrom
compass-repo/rig-3034-sqlc-t3-channels
Aug 31, 2026
Merged

feat(store): migrate channels + channel_pins + coordination to sqlc (T3)#792
mattwilkinsonn merged 1 commit into
mainfrom
compass-repo/rig-3034-sqlc-t3-channels

Conversation

@rigel-mintaka

@rigel-mintaka rigel-mintaka commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

This PR is part of a stack containing 3 PRs:

  1. main
  2. "feat(store): migrate channels + channel_pins + coordination to sqlc (T3)" (this PR)
  3. feat(store): migrate messages + topics + delivery to sqlc (T4) #795
  4. feat(store): migrate agent sessions/transcripts/activity/config/placements to sqlc (T5) #796

Migrate the channels, channel_pins, and coordination store domains from
inline pgx SQL to sqlc-generated typed queries (RIG-3034, design record
sqlc-adoption T3), following the T2 recipe exactly. Pool-scoped calls go
through s.q; tx-scoped through s.q.WithTx(tx) / db.New(tx). Every migrated
statement is semantically identical to the inline SQL it replaced (same
columns, WHERE, JOINs, ORDER BY, null-handling); the CTE-based channel and
group visibility reads move into queries/channels.sql with their predicates
inlined per query (sqlc has no fragment composition), textually identical so
the stream-edge single-id checks cannot drift from the list reads.

The DELETE-and-check-rows-affected member removal uses the :execrows kind so
removeMember/SetCoordinationMembersTx keep their RowsAffected semantics. The
coordination per-owner advisory lock pg_advisory_xact_lock(hashtext('coordination:' || $1))
is now a tx-bound LockOwnerCoordination call inside its transaction; the
suffix-search channel-provision loop, the WithTx seam, error wrapping,
domain-type mapping, and the FOR UPDATE lock / cap-check control flow all
stay hand-written. Regenerated internal/store/db (drift-clean) and dropped
the three migrated inline-sql-gate allowlist entries (24 -> 21).

Co-authored-by: Matt Wilkinson matt@rigel.build

@linear-code

linear-code Bot commented Aug 31, 2026

Copy link
Copy Markdown

RIG-3034

@github-actions

github-actions Bot commented Aug 31, 2026

Copy link
Copy Markdown

Compass engineering docs preview: https://compass-repo-rig-3034-sqlc-t-56pf.compass-eng-docs.pages.dev

Deployed from compass-repo/rig-3034-sqlc-t3-channels at c068b3a.

Base automatically changed from compass-repo/rig-3034-sqlc-t2-accounts to main August 31, 2026 16:29
Migrate the channels, channel_pins, and coordination store domains from
inline pgx SQL to sqlc-generated typed queries (RIG-3034, design record
sqlc-adoption T3), following the T2 recipe exactly. Pool-scoped calls go
through s.q; tx-scoped through s.q.WithTx(tx) / db.New(tx). Every migrated
statement is semantically identical to the inline SQL it replaced (same
columns, WHERE, JOINs, ORDER BY, null-handling); the CTE-based channel and
group visibility reads move into queries/channels.sql with their predicates
inlined per query (sqlc has no fragment composition), textually identical so
the stream-edge single-id checks cannot drift from the list reads.

The DELETE-and-check-rows-affected member removal uses the :execrows kind so
removeMember/SetCoordinationMembersTx keep their RowsAffected semantics. The
coordination per-owner advisory lock pg_advisory_xact_lock(hashtext('coordination:' || $1))
is now a tx-bound LockOwnerCoordination call inside its transaction; the
suffix-search channel-provision loop, the WithTx seam, error wrapping,
domain-type mapping, and the FOR UPDATE lock / cap-check control flow all
stay hand-written. Regenerated internal/store/db (drift-clean) and dropped
the three migrated inline-sql-gate allowlist entries (24 -> 21).

Co-authored-by: Matt Wilkinson <matt@rigel.build>
@mattwilkinsonn
mattwilkinsonn merged commit be9c371 into main Aug 31, 2026
26 of 28 checks passed
@mattwilkinsonn
mattwilkinsonn deleted the compass-repo/rig-3034-sqlc-t3-channels branch August 31, 2026 17:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants