Skip to content

Migrate channel scoping to h tags#22

Merged
wesbillman merged 2 commits intomainfrom
codex/migrate-channel-tags-to-h
Mar 10, 2026
Merged

Migrate channel scoping to h tags#22
wesbillman merged 2 commits intomainfrom
codex/migrate-channel-tags-to-h

Conversation

@wesbillman
Copy link
Collaborator

@wesbillman wesbillman commented Mar 10, 2026

Summary

  • migrate channel-scoped events and subscriptions from overloaded channel e tags to canonical h tags across relay, desktop, MCP canvas, and test helpers
  • reject channel-scoped content events that omit h so legacy-tagged writes fail closed instead of bypassing channel authorization and archive checks
  • route REST-created messages through the same persistent-event dispatch path as WebSocket-ingested messages so MCP/REST posts fan out, index, audit, and trigger workflows consistently
  • add regression coverage for REST message delivery to WebSocket channel subscribers and update relay/test subscriptions to use #h

Testing

  • cargo test -p sprout-relay --lib
  • cargo check
  • cd desktop && pnpm typecheck
  • cargo fmt --all -- --check
  • cd desktop && pnpm check
  • cd desktop && pnpm build
  • cargo check --manifest-path desktop/src-tauri/Cargo.toml
  • cargo clippy --workspace --all-targets -- -D warnings
  • ./scripts/run-tests.sh unit

@wesbillman
Copy link
Collaborator Author

@codex can you review this PR

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 299aa3b5fd

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

for tag in event.tags.iter() {
let key = tag.kind().to_string();
if key == "channel" || key == "h" {
if key == "h" {

Choose a reason for hiding this comment

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

P1 Badge Reject legacy channel-tagged events instead of treating them global

This change makes extract_channel_id accept only h, but handle_event enforces membership and archived-channel checks only when a channel_id is found. Any client still emitting the previous channel tag format (used before this migration) will now be stored as an unscoped global event, which bypasses private-channel authorization and archived-channel guards rather than failing closed. Please keep legacy parsing during rollout or explicitly reject channel message kinds that lack h.

Useful? React with 👍 / 👎.

return {
kinds: [40001],
"#e": [channelId],
"#h": [channelId],

Choose a reason for hiding this comment

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

P1 Badge Keep desktop history compatible with pre-migration events

The desktop subscription filter now sends only #h, but existing stored messages from before this migration were written with legacy channel tags. Relay filter evaluation still requires literal tag matches (sprout-core/src/filter.rs), so those historical events stop matching channel history subscriptions and channels can appear empty until new h-tagged messages arrive. A temporary dual-read strategy (new + legacy tags) is needed to avoid dropping visible history.

Useful? React with 👍 / 👎.

Comment on lines +551 to +554
.custom_tag(
nostr::SingleLetterTag::lowercase(nostr::Alphabet::H),
[p.channel_id.as_str()],
)

Choose a reason for hiding this comment

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

P2 Badge Preserve MCP canvas reads for legacy-tagged canvas events

get_canvas now queries only by #h, but older canvas events were written with the previous channel tag format. Since matching is tag-literal, pre-migration canvas documents will no longer be returned, causing MCP to report "No canvas set" even when a canvas already exists. Add a fallback path for legacy tags (or migrate existing canvas events) before removing old-read compatibility.

Useful? React with 👍 / 👎.

@wesbillman wesbillman merged commit 9793c99 into main Mar 10, 2026
8 checks passed
@wesbillman wesbillman deleted the codex/migrate-channel-tags-to-h branch March 10, 2026 22:26
tlongwell-block added a commit that referenced this pull request Mar 11, 2026
* origin/main:
  Migrate channel scoping to h tags (#22)
  Remove IF NOT EXISTS from migrations and drop mysql CLI fallback (#19)
  fix: resolve 10 E2E bugs + add desktop Playwright tests (#21)
  Add desktop search and result anchors (#15)
  fix: mcp and desktop communication (#18)
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.

1 participant