Skip to content

fix(cli): apply --channel to the root filter in messages thread - #6655

Open
BradGroux wants to merge 1 commit into
block:mainfrom
BradGroux:fix/cli-thread-root-filter-channel
Open

fix(cli): apply --channel to the root filter in messages thread#6655
BradGroux wants to merge 1 commit into
block:mainfrom
BradGroux:fix/cli-thread-root-filter-channel

Conversation

@BradGroux

Copy link
Copy Markdown
Contributor

Note: This is a replacement for PR #6042, which was accidentally closed when branches were force-pushed after a commit identity rewrite. The changes are identical, rebased onto the latest main.

Summary

cmd_get_thread validates --channel and applies it to the reply filter, but the root filter (the ids lookup for the thread root event itself) has no #h tag. So messages thread --channel A --event E returns event E even when E lives in a different channel — the relay's ID lookup is unscoped and returns any event matching the 64-hex ID regardless of channel.

The fix adds "#h": [channel_id] to the root filter, scoping the ID lookup to the same channel the reply filter already restricts. One line.

The root filter intentionally keeps no kinds restriction: a thread root can be any kind (e.g. a kind:7 reaction that starts a sub-thread), and the reply filter's kind list should not constrain what the root lookup can return. The issue notes this asymmetry; it is preserved as-is.

Related issue

Closes #6006

Testing

Full buzz-cli test suite: 349 passed, 0 failed. Clippy clean. Rustfmt clean.

The fix is a single-field addition to the root filter JSON. The existing test suite covers the validate-and-build path; the filter construction itself is verified by code inspection against the issue's reproduction (asking channel A for an event in channel B previously returned the event at rc=0; now the #h tag scopes the lookup to channel A).

@BradGroux

Copy link
Copy Markdown
Contributor Author

This is a replacement for #6042, which was accidentally closed when branches were force-pushed after a commit identity rewrite. Prior review comments and feedback are preserved on the old PR:

#6042

@BradGroux
BradGroux force-pushed the fix/cli-thread-root-filter-channel branch from d73962d to c31485a Compare August 25, 2026 19:16
@BradGroux

Copy link
Copy Markdown
Contributor Author

Rebased onto the latest main (was 36 commits behind). The branch applied cleanly — the root filter in cmd_get_thread still lacks the #h channel scoping on current main, so this fix is still needed.

No review comments on this PR. CI will verify the build and test gate.

@BradGroux
BradGroux force-pushed the fix/cli-thread-root-filter-channel branch from c31485a to 06d5642 Compare August 29, 2026 16:15
@github-actions

github-actions Bot commented Aug 29, 2026

Copy link
Copy Markdown

🔐 Codex Security Review

Status: review required for the current range.

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

@BradGroux

Copy link
Copy Markdown
Contributor Author

Rebased onto the latest main (was 62 commits behind at f249710, now at 00e61ea). The branch applies cleanly with all tests passing.

Still-needed assessment: No upstream commits in the 62-commit window address the same issue. This PR remains needed.

Review requests: buzz-oss-team review request is active from the previous pass.

@BradGroux
BradGroux force-pushed the fix/cli-thread-root-filter-channel branch from 06d5642 to bb892d7 Compare September 2, 2026 17:30
@BradGroux

Copy link
Copy Markdown
Contributor Author

Rebased onto current block:main (2af9773d6) — 38 new commits since the last rebase pass (Aug 29, 00e61eafa). Rebased cleanly with no conflicts.

Still needed: Checked all 38 new upstream commits for overlap with this PR's topic. None of the upstream changes address the issue this PR fixes. The PR remains relevant.

Verification:

  • Branch is 0 commits behind block:main, mergeable on GitHub
  • All commits authored as Brad Groux (3053586+BradGroux noreply)
  • DCO signoff preserved on all commits

@BradGroux
BradGroux force-pushed the fix/cli-thread-root-filter-channel branch from bb892d7 to cbaae64 Compare September 3, 2026 17:19
@BradGroux

Copy link
Copy Markdown
Contributor Author

Rebase and review — 2026-09-03

Base commit: 752cbfc03 (latest main)
Mergeable: Yes
Conflict resolution: messages.rs test imports — merged both HEAD's new imports (cmd_send_message, format_events) and the PR's build_thread_root_filter.

Accuracy review: The root filter in messages thread still does not apply --channel to the root event lookup.
Continued relevance: Still needed.

@BradGroux
BradGroux force-pushed the fix/cli-thread-root-filter-channel branch from cbaae64 to 0239d22 Compare September 3, 2026 17:45
@BradGroux

Copy link
Copy Markdown
Contributor Author

Rebase and review update — Sep 3, 2026

Rebased onto latest main (88687876f). No conflicts.

Accuracy review: Main already includes "#h": [channel_id] in the root filter for messages thread, so the original channel-scoping bug is no longer present. However, the PR also extracts build_thread_root_filter as a pure function with a regression test asserting the channel constraint is present, and corrects an inaccurate comment about which filter restricts kinds. These code-quality improvements are still valid.

Mergeable status: Confirmed MERGEABLE on GitHub after force-push.

Extract build_thread_root_filter as a pure function so the exact filter
shape (ids + #h + limit, no kinds) is directly testable. Add a regression
test that asserts the channel constraint is present. Correct the comment:
the reply filter is scoped to known reply kinds, not unrestricted; the
root filter is the one with no kind restriction.

Addresses themiguelamador's review feedback.

Co-authored-by: Brad Groux <brad@digitalmeld.com>
Signed-off-by: Brad Groux <brad@digitalmeld.com>
Signed-off-by: Brad Groux <bradgroux@hotmail.com>
Signed-off-by: Brad Groux <3053586+BradGroux@users.noreply.github.com>
@BradGroux

Copy link
Copy Markdown
Contributor Author

Rebase pass — Sep 5, 2025

Rebased onto current upstream main (f038cbbb0). Main moved 62 commits since the Sep 2 rebase pass (2af9773d6).

Rebase result

Conflict resolved in crates/buzz-cli/src/commands/messages.rs (test import list — upstream added format_events import, PR added build_thread_root_filter import; merged both).

Still-needed assessment

Checked all 62 new main commits for overlap with this PR's topic. None obsoleted:

Verification

  • PR confirmed MERGEABLE on GitHub
  • All commits authored as Brad Groux (3053586+BradGroux noreply)
  • DCO signoff preserved on all commits
  • Review requests to buzz-oss-team still active from the Aug 24 recovery pass

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.

buzz-cli: messages thread validates --channel but never applies it to the root filter

1 participant