Skip to content

refactor(db): split channel membership store - #6782

Merged
TheSentinel454 merged 1 commit into
mainfrom
codex/issue-7-channel-membership-store
Aug 28, 2026
Merged

refactor(db): split channel membership store#6782
TheSentinel454 merged 1 commit into
mainfrom
codex/issue-7-channel-membership-store

Conversation

@TheSentinel454

@TheSentinel454 TheSentinel454 commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Current reconstructed head

Exact base: codex/issue-7-roster-test-fixtures at 5df440c411be9705eb29a57f0c41f7239767e007
Exact head: codex/issue-7-channel-membership-store at 8ad0782ee311f5f51b714494ce750c5937f127cc

This current head removes crates/buzz-db/tests/store_ownership.rs; no replacement path-sensitive ownership test is introduced. Apart from removing that complete test-file diff, the production patch is byte-for-byte identical to the previously reviewed slice. This remains part of tracker #2 and the #17/#19 acceptance work.

Independent exact-head review from a separate clean Blox workstation found no issues. Current-head evidence passed formatting, strict buzz-db clippy, 111 non-PostgreSQL library tests with 200 PostgreSQL tests ignored, the observability source test, relay consumer compilation, exact ownership/unique-span review checks, and 3 channel and 19 membership PostgreSQL tests on native PostgreSQL where applicable.

Why

Complete the channel ownership slice of tracker #2 and domain issue #7 while preserving the runtime/store boundary established by #6660 and #6668. This child stacks on the test-only fixture prerequisite #6819 above #6777 and carries forward PR #6700's membership/replacement lock timing without changing lock or transaction behavior.

What

  • Keep channel lifecycle, metadata, TTL advisory locking, and lifecycle tests in channel.rs
  • Move membership/roster records, SQL, advisory-lock helpers, Db methods, focused tests, and datastore spans to a dedicated channel_members.rs
  • Preserve existing buzz_db::channel::* paths with compatibility re-exports while exposing the dedicated module
  • Move the four roster-fence PostgreSQL tests out of lib.rs

Stack

Non-goals

Risk Assessment

Moderate review surface, low semantic risk. The file split is large, but method signatures, SQL, bind order, membership and replacement lock namespaces, transaction boundaries, and span names remain unchanged. Compatibility re-exports preserve existing buzz_db::channel::* consumers.

Blox Verification

Author workstation: buzz-tornquist-issue-2-store-stack (2046520), exact head 8376e19d0da3ec77550590cd91cc3dfe284d95d6.

  • cargo fmt --all --check — passed
  • cargo clippy -p buzz-db -p buzz-relay --all-targets -- -D warnings — passed
  • Native PostgreSQL channel lifecycle suite — 3 passed
  • Native PostgreSQL membership/roster suite — 17 passed; two pre-existing ignored-test fixture failures reproduced identically on the untouched parent 2de5444: large_roster_reconciliation_candidates_respect_snapshot_count_and_signer and locked_member_snapshot_blocks_post_capture_membership_mutation both receive the migration-0032 23514 invalid-p-tag rejection. This extraction intentionally does not fold a test-behavior fix into the move.
  • cargo test -p buzz-relay --lib -- --test-threads=1 — 908 passed, 48 ignored; the existing load-sensitive mesh demo test returned 504, matching the Add database pressure observability #6700/parent baseline
  • cargo test -p buzz-relay --lib api::mesh_demo::tests::demo_join_forwarded_arm_round_trips_echo -- --exact --test-threads=1 — passed

Independent exact-head review: buzz-tornquist-pr-6782-review (2048397) found no remaining critical, important, or minor issues. The full implementation review also independently reproduced both stated PostgreSQL fixture failures on the exact parent and passed the relay library suite (909 passed, 48 ignored).

Generated with Codex

Superseded pre-comment restack verification

PR #6700 merged before publication completed. This layer was restacked onto current main through the exact parent named above; the final cumulative tip is 2ddcc8a. Cumulative author gates passed: formatting and diff checks; buzz-db and buzz-relay all-target clippy with -D warnings; DB lib 111 passed / 200 ignored; ownership 22/22; observability 1/1; the full isolated PostgreSQL domain matrix; and relay lib 910 passed / 49 ignored.

  • Workstation: buzz-tornquist-pr-6782-final-review (2057620), fresh shallow checkout
  • Base: c60e793eadde79d9eab9f48bbb2ede0ad4831f9b
  • Head: fa09b6c81c4db3b3e1940a2117a97ab2186e49f7
  • Findings: none

Reviewed both commits in base..head. Channel lifecycle/metadata, TTL transitions, and their lock rationale remain in channel.rs; membership authorization, roster fencing/snapshots, membership advisory locking, membership records, and focused tests move together to channel_members.rs. SQL, transaction, and lock sequences are preserved.

Verification: format and diff checks passed; buzz-db --all-targets clippy passed with -D warnings; DB lib tests passed (111 passed, 200 PostgreSQL tests ignored); ownership (2/2) and observability (1/1) guards passed; native PostgreSQL 17 passed 3 channel lifecycle tests plus 19 membership/roster tests with migrations 1-32 successful; relay lib test target compiled successfully. Final worktree was detached at the exact head and clean.

Complete evidence archive SHA-256: 81ae374095f649ca7a25d8b9a4fc864257b7925d1b44657a69ca111523adf36e.

Comment-addressed restack

Review follow-up on #6777 removed only the low-value replaceable ownership source test. This PR was restacked onto its rewritten parent; its production patch is unchanged.

  • Exact base: 21d1b265c133292e6707e766cd4204e6a43f08af
  • Exact head: 25138bfd6588e046170dbdbc4ed953bdc3cf7ed1
  • Final cumulative tip: 6fa2f104d42c6ba85bdf62e7ccb74ceaf4a84f67
  • Per-layer patch-ID and tree audits confirm this PR’s production diff is unchanged from its pre-comment head.
  • Cumulative Blox gate: formatting and diff checks; strict buzz-db/buzz-relay Clippy; DB lib 111 passed / 200 ignored; ownership 21/21; observability 1/1; every moved PostgreSQL test; relay lib 910 passed / 49 ignored.
  • Independent re-review at this exact head: no findings; fresh exact-parent/head Blox review passed fmt/diff, strict Clippy, DB lib 111 passed / 200 ignored, current ownership/observability guards, 3 channel plus 19 membership PostgreSQL tests, and relay compilation.

@TheSentinel454
TheSentinel454 force-pushed the codex/issue-7-channel-membership-store branch from 8376e19 to fa09b6c Compare August 25, 2026 20:06
@TheSentinel454
TheSentinel454 changed the base branch from codex/issue-6-finish-replaceable-store to codex/issue-7-roster-test-fixtures August 25, 2026 20:12
@TheSentinel454
TheSentinel454 force-pushed the codex/issue-7-channel-membership-store branch from fa09b6c to 25138bf Compare August 25, 2026 20:59
@TheSentinel454 TheSentinel454 changed the title db: split channel membership store refactor(db): split channel membership store Aug 26, 2026
@TheSentinel454
TheSentinel454 force-pushed the codex/issue-7-channel-membership-store branch 2 times, most recently from 6c0196a to 8ad0782 Compare August 26, 2026 15:53
@TheSentinel454
TheSentinel454 marked this pull request as ready for review August 27, 2026 14:05
@TheSentinel454
TheSentinel454 requested a review from a team as a code owner August 27, 2026 14:05

@wpfleger96 wpfleger96 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Combined review from three independent passes (two source reviews + one E2E test run at exact head 8ad0782): no blocking findings; two MINOR (non-blocking) notes below.

Verified clean:

  • Pure split confirmed independently by both source reviews: every production/helper/test function body byte-identical after relocation; all 29 Db wrappers keep their signatures, delegation, docs, and all 28 datastore span names; the buzz_channel_membership: advisory-lock namespace, SQL, bind order, and transaction boundaries are unchanged. Sole visibility change is row_to_channel_recordpub(crate), which is the right narrow seam.
  • Compat re-exports in channel.rs cover all 24 moved public items, so existing buzz_db::channel::* consumers are unaffected.
  • The PR body's mention of removing tests/store_ownership.rs is stale relative to this diff — that file is already absent at the exact base, so this PR contains no test-file deletion.
  • E2E at head on fresh Postgres: relocated channel::tests:: 3/3, new channel_members::tests:: 19/19 (including all four roster-fence cases), cargo check -p buzz-relay passes. Three unrelated full-suite failures reproduce identically at the parent commit and predate this stack.

MINOR (non-blocking):

  1. ~170 lines of Postgres test scaffolding (setup_pool, make_test_community, create_test_channel, scratch-DB helpers) are now duplicated between the two modules' test mods — and a third copy lands in #6784. A shared #[cfg(test)] helper module would collapse them; fine as a stack-wide follow-up rather than a change here.
  2. MemberRole is re-exported from both channel and channel_members, leaving two equivalent import paths. Harmless; worth consolidating whenever the compat re-exports are eventually retired.

Base automatically changed from codex/issue-7-roster-test-fixtures to main August 27, 2026 20:07
Signed-off-by: OpenAI Codex <codex@openai.com>
@TheSentinel454
TheSentinel454 force-pushed the codex/issue-7-channel-membership-store branch from 8ad0782 to ffb06a0 Compare August 27, 2026 20:07
@github-actions

Copy link
Copy Markdown

🔐 Codex Security Review

Status: review required for the current range.

The current range is 57216c942f171db305135bcb6a4ede2d87e0be8a...ffb06a01220d7d5d99245593c51d932e1c0df98a.
A new review must complete for this exact range. When manual authorization
is required, a Block organization member must comment exactly
@buzz-security-review ffb06a01220d7d5d99245593c51d932e1c0df98a to authorize a new review.
Any previous review applies only to its recorded range.

@TheSentinel454
TheSentinel454 merged commit e76c819 into main Aug 28, 2026
39 checks passed
@TheSentinel454
TheSentinel454 deleted the codex/issue-7-channel-membership-store branch August 28, 2026 14:55
TheSentinel454 added a commit that referenced this pull request Aug 28, 2026
…edia-layout-migration

* commit 'e76c81968b65b0755b83efdd59dc3375c59ddf40': (159 commits)
  refactor(db): split channel membership store (#6782)
  feat(auth): add NIP-FI canonical assertion verifier and contracts (#6776)
  fix(desktop): resolve exact typed mentions on space (#6862)
  perf(desktop): restore project context during startup (#6939)
  fix(desktop): lift right auxiliary pane above shared header backdrop (#6966)
  fix(ci): bump Codex CLI to 0.150.1 to unhang security review jobs (#6962)
  feat(desktop): implement 30178 team catalog backend (#5112)
  feat(model-capabilities): humanize Databricks UC model families (#6955)
  feat(agent): discover Databricks Unity Catalog models (#6918)
  test(db): use canonical channel roster fixtures (#6819)
  preserve channel description paragraph breaks (#6946)
  fix(cli): enrich template cardinality error with per-candidate presence and profile hints (#4825)
  Fix Codex security review authorization (#6913)
  fix(db): disable heartbeat vacuum truncation (#6898)
  chore(deps): update rui314/setup-mold digest to 7e4f20a (#6663)
  chore(deps): update dependency vitest to v4.1.11 (#6667)
  chore(deps): update dependency @tanstack/react-virtual to v3.14.10 (#6666)
  chore(deps): update ubuntu:24.04 docker digest to 33ceb71 (#6664)
  fix(projects): allow owners to delete agent projects (#6533)
  Fade expanded video controls on hover (#6926)
  ...

# Conflicts:
#	crates/buzz-deletion/src/lib.rs
#	crates/buzz-media/Cargo.toml
#	crates/buzz-media/src/lib.rs
#	crates/buzz-media/src/storage.rs
wpfleger96 pushed a commit that referenced this pull request Aug 28, 2026
…-history

* origin/main:
  refactor(relay): NIP-98 admin auth with Operator/Moderator roles and NIP-11 discovery (#3777)
  refactor(db): split channel membership store (#6782)
  feat(auth): add NIP-FI canonical assertion verifier and contracts (#6776)
  fix(desktop): resolve exact typed mentions on space (#6862)
  perf(desktop): restore project context during startup (#6939)
  fix(desktop): lift right auxiliary pane above shared header backdrop (#6966)

Signed-off-by: Duncan <dcfd242e557282d7a1e2cf2e6877522682f1e5c6156dc92ca7d90eaedd3b0f95@buzz.block.builderlab.xyz>
yjc801 added a commit to yjc801/buzz that referenced this pull request Aug 28, 2026
Resolves the crates/buzz-db/src/lib.rs conflict from upstream block#6782
(channel-membership store split). Upstream relocated the four
channel-roster-fence tests to channel_members.rs; the seven
replaceable-event tests the fork had duplicated into lib.rs already live
byte-identically in replaceable.rs. Both sets are dropped from lib.rs and
the fork-only waker launch-bundle replacement test is kept.

Signed-off-by: Junchao Yan <yjc801@gmail.com>
wpfleger96 pushed a commit that referenced this pull request Aug 28, 2026
…agent-edit

* origin/main:
  Refresh mobile utility surfaces and theme picker (#6944)
  fix(desktop): complete project empty and context states (#6980)
  Fix mobile jump-to-latest flicker (#6807)
  refactor(relay): NIP-98 admin auth with Operator/Moderator roles and NIP-11 discovery (#3777)
  refactor(db): split channel membership store (#6782)

Signed-off-by: Duncan <dcfd242e557282d7a1e2cf2e6877522682f1e5c6156dc92ca7d90eaedd3b0f95@buzz.block.builderlab.xyz>
delkc added a commit that referenced this pull request Aug 28, 2026
…rding-v3

* origin/main:
  Refresh mobile utility surfaces and theme picker (#6944)
  fix(desktop): complete project empty and context states (#6980)
  Fix mobile jump-to-latest flicker (#6807)
  refactor(relay): NIP-98 admin auth with Operator/Moderator roles and NIP-11 discovery (#3777)
  refactor(db): split channel membership store (#6782)
  feat(auth): add NIP-FI canonical assertion verifier and contracts (#6776)

Signed-off-by: Clay Delk <clay.delk@gmail.com>
wpfleger96 pushed a commit that referenced this pull request Aug 28, 2026
…enericize

* origin/main:
  feat(desktop): add team sharing to community catalog (#3995)
  Refresh mobile utility surfaces and theme picker (#6944)
  fix(desktop): complete project empty and context states (#6980)
  Fix mobile jump-to-latest flicker (#6807)
  refactor(relay): NIP-98 admin auth with Operator/Moderator roles and NIP-11 discovery (#3777)
  refactor(db): split channel membership store (#6782)
  feat(auth): add NIP-FI canonical assertion verifier and contracts (#6776)
  fix(desktop): resolve exact typed mentions on space (#6862)
  perf(desktop): restore project context during startup (#6939)
  fix(desktop): lift right auxiliary pane above shared header backdrop (#6966)

Signed-off-by: Duncan <dcfd242e557282d7a1e2cf2e6877522682f1e5c6156dc92ca7d90eaedd3b0f95@buzz.block.builderlab.xyz>
TheSentinel454 added a commit that referenced this pull request Aug 28, 2026
## Summary

Finish the remaining database-store extraction tracked by
[TheSentinel454#2](TheSentinel454#2)
in one reviewable PR.

This consolidates the previously stacked domain slices after #6782
merged. It preserves the runtime/store boundary established by #6660,
#6668, #6700, and #6782 while separating database runtime infrastructure
from domain-owned persistence:

- `runtime/` owns pool construction and sizing, writer/reader routing,
read sessions and route proofs, transaction infrastructure,
observability primitives, replica fencing, health support, migrations,
and cross-cutting runtime tests.
- `store/` owns domain records, SQL, row parsing, locks and invariants,
`Db` domain methods, focused tests, and logical-operation datastore
spans.
- `lib.rs` remains a 57-line compatibility facade that preserves
existing crate-root paths and `Db` method signatures through re-exports.

Domain coverage includes API tokens, authentication allowlists,
reminders, event queries, threads, reactions, feeds, users and DMs,
push, workflows/runs/approvals, relay membership and invites, product
feedback, moderation/admin moderation, relay admin actions/operators,
git repositories, archived identities, usage, partition maintenance,
deletion, channel membership inherited from merged #6782, and the final
runtime/store layout.

The branch has been rebased onto current `main`. Database changes that
landed there were incorporated rather than overwritten:
`relay_admin_actions.rs` and `relay_operators.rs` now live under
`store/`, their 27 public `Db` wrappers and existing behavior remain
intact, and every wrapper has exactly one fixed-name datastore span.
Concurrent changes to migration, moderation, admin moderation, and error
handling are also retained.

### Exact base and head

- Base: `main` at `ed11c8d8bf0a17402be5cf243724f89471530d2f`
- Head: `codex/issue-2-store-extraction` at
`be24430472d1a87ac5c0d6026c620cd6caea3537`

### Related issue

- Structural tracker:
[TheSentinel454#2](TheSentinel454#2)
- Domain trackers:
[#6](TheSentinel454#6),
[#7](TheSentinel454#7),
[#12](TheSentinel454#12),
[#13](TheSentinel454#13)
- Acceptance trackers:
[#17](TheSentinel454#17),
[#19](TheSentinel454#19)

This supersedes #6783, #6784, #6787, #6788, #6789, #6792, #6820, #6794,
#6796, #6797, #6798, #6799, #6804, #6805, #6806, #6808, #6809, #6811,
#6812, #6813, #6814, #6815, and #6890. Their discussions remain
available for review history.

### #17 / #19 acceptance

- Preserves the metric names, fixed labels, transaction/lock timing
boundaries, and privacy/cardinality constraints introduced by #6700.
- Keeps exactly one datastore span per public logical operation,
including the 27 relay-admin wrappers added on `main`.
- Removes `store_ownership.rs`; physical ownership and focused source
guards now enforce the boundary directly.
- Leaves no `impl Db`, domain SQL, focused domain test group, or
datastore span in `lib.rs`.
- Preserves existing public paths such as `buzz_db::channel`,
`buzz_db::event`, and `buzz_db::workflow` through crate-root re-exports
while keeping internal `runtime` and `store` namespaces private.

### Non-goals

- No SQL, schema, locking, transaction, retry, timeout, or
client-visible behavior changes.
- No generic store traits, domain handles, broad `PgExecutor` migration,
new store crate, raw pool accessor, or broader directory reorganization.
- No tracker issues are closed by this PR.

### Risk

The cumulative diff is large but structural. Risk is primarily
module-path, ownership, or conflict-resolution drift. It is mitigated by
preserving public re-exports, comparing the newly moved `main`
implementations to their upstream source, source guards, touched-crate
compilation, PostgreSQL-backed test coverage, and an independent
exact-head review on a separate clean Blox workstation.

### Testing

Author workstation `buzz-tornquist-pr-6987-rebase`, rebased branch
ending at exact head `be24430472d1a87ac5c0d6026c620cd6caea3537`:

- `cargo fmt --all --check`
- `cargo clippy -p buzz-db -p buzz-relay --all-targets -- -D warnings`
- `cargo test -p buzz-db --lib` — 113 passed, 240 PostgreSQL tests
intentionally ignored
- `cargo test -p buzz-db --test observability_source` — 2 passed
- PostgreSQL-backed `buzz-db` coverage under native PostgreSQL — 235
passed in the shared serial run; the five shared-state/config-sensitive
cases passed as isolated reruns against fresh schemas, including the two
owner-limit tests with their fixture's
`BUZZ_MAX_COMMUNITIES_PER_OWNER=3`
- `cargo test -p buzz-relay --lib -- --test-threads=1` under native
PostgreSQL/Redis — 991 passed; the three current-month
partition-sensitive identity-archive cases passed after provisioning the
August 2026 test partition; 87 infrastructure-marked tests remained
ignored
- Source/diff guards — relay-admin implementation bodies match current
`main`; all 27 public wrapper signatures are retained; exactly one
datastore span wraps each wrapper; `lib.rs` has zero `impl Db` blocks
and zero datastore spans; no duplicate top-level relay-admin modules or
`store_ownership.rs`; `error.rs` matches current `main`

Independent clean review workstation `buzz-tornquist-pr-6987-review`,
detached at exact head `be24430472d1a87ac5c0d6026c620cd6caea3537`:

- `cargo fmt --all --check`
- `cargo clippy -p buzz-db -p buzz-relay --all-targets -- -D warnings`
- `cargo test -p buzz-db --lib` — 113 passed, 240 ignored
- `cargo test -p buzz-db --test observability_source` — 2 passed
- Exact-head ownership/re-export/instrumentation audit — no remaining
actionable findings

---------

Signed-off-by: OpenAI Codex <codex@openai.com>
Signed-off-by: tornquist <tornquist@squareup.com>
Co-authored-by: OpenAI Codex <codex@openai.com>
wpfleger96 pushed a commit that referenced this pull request Aug 28, 2026
…c-agent-commit-identity

* origin/main:
  feat(desktop): add team sharing to community catalog (#3995)
  Refresh mobile utility surfaces and theme picker (#6944)
  fix(desktop): complete project empty and context states (#6980)
  Fix mobile jump-to-latest flicker (#6807)
  refactor(relay): NIP-98 admin auth with Operator/Moderator roles and NIP-11 discovery (#3777)
  refactor(db): split channel membership store (#6782)
  feat(auth): add NIP-FI canonical assertion verifier and contracts (#6776)
  fix(desktop): resolve exact typed mentions on space (#6862)
  perf(desktop): restore project context during startup (#6939)
  fix(desktop): lift right auxiliary pane above shared header backdrop (#6966)
  fix(ci): bump Codex CLI to 0.150.1 to unhang security review jobs (#6962)
  feat(desktop): implement 30178 team catalog backend (#5112)
  feat(model-capabilities): humanize Databricks UC model families (#6955)
  feat(agent): discover Databricks Unity Catalog models (#6918)
  test(db): use canonical channel roster fixtures (#6819)
  preserve channel description paragraph breaks (#6946)
  fix(cli): enrich template cardinality error with per-candidate presence and profile hints (#4825)
  Fix Codex security review authorization (#6913)
  fix(db): disable heartbeat vacuum truncation (#6898)

Signed-off-by: Duncan <dcfd242e557282d7a1e2cf2e6877522682f1e5c6156dc92ca7d90eaedd3b0f95@buzz.block.builderlab.xyz>
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.

3 participants