# Tasks: Community Profile Sync ## T1 — Add `Tag::CommunityMembership = 0x0E` to storage key encoding **File:** `tidal/src/storage/keys.rs` - Add `CommunityMembership = 0x0E` variant to `Tag` enum. - Add `0x0E => Some(Self::CommunityMembership)` arm to `from_byte`. - Update all tag-listing tests. **Status: COMPLETE** --- ## T2 — Implement `CommunityMembershipIndex` **File:** `tidal/src/entities/community.rs` (new) - `add(user_id, name)` — inserts into sorted Vec, deduplicates. - `get(user_id) -> Vec` — cloned snapshot. - `contains(user_id, name) -> bool`. - `entry_count() -> usize`. - Unit tests covering all methods. **Status: COMPLETE** --- ## T3 — Add `community_membership` field to `TidalDb` **File:** `tidal/src/db/mod.rs` - Add field: `community_membership: Arc`. - Wire into both constructors. **Status: COMPLETE** --- ## T4 — Implement `db/community.rs` **File:** `tidal/src/db/community.rs` (new) - `join_community(user_id, community_name) -> Result<()>` — validate, persist, update index. - `get_community_memberships(user_id) -> Result>` — read from index. - `is_community_member(user_id, community_name) -> Result` — read from index. **Status: COMPLETE** --- ## T5 — Startup rebuild of community membership index **File:** `tidal/src/db/state_rebuild.rs` - `rebuild_community_memberships(users_engine, index)` — scans `Tag::CommunityMembership` keys. - Called from open path. **Status: COMPLETE** --- ## T6 — Signal forwarding: `try_community_forwarding` **File:** `tidal/src/db/signals.rs` - `try_community_forwarding(&self, signal_type, entity_id, weight, timestamp, user_id)`. - Called from `signal_with_context` after `try_cohort_attribution`. **Status: COMPLETE** --- ## T7 — Integration tests **File:** `tidal/tests/m9_community_sync.rs` 10 integration tests: join_and_query_membership, signal_routes_to_community_aggregate, nonmember_signal_not_forwarded, multiple_communities_independent, membership_persists_across_restart, join_idempotent, invalid_community_name_empty, invalid_community_name_too_long, forwarding_does_not_block_primary_write, community_aggregate_windowed_count. **Status: COMPLETE — all 10 pass** --- ## T8 — Verify ``` cargo test --manifest-path tidal/Cargo.toml --lib → 1299 passed cargo test --manifest-path tidal/Cargo.toml --test m9_community_sync → 10 passed cargo clippy --lib -- -D warnings → clean cargo fmt --check → clean ``` **Status: COMPLETE**