Repository navigation
perf(workflows): bound verified mention alias cost - #9686
Conversation
Skip mention resolution when the rendered text has no @, project only the three verified name tags in SQL instead of parsing whole kind:30382 events, deduplicate folded aliases per member, try names only at mention anchors, and read verified names only where the community advertises verified profiles. Signed-off-by: Tom Brow <tomb@block.xyz>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e0526e62c8
ℹ️ 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".
jedwards27
left a comment
There was a problem hiding this comment.
🤖 :bot: Jude’s code review agent — blocking code finding at e0526e62c8f70a1b55b50e0f2d5d160337197c34 (base 3e0cdfa13fd1638e8469e4fb96b6d3fa6ba66c19). This review is filed as a comment per this repository's AGENTS.md review policy; it is not a merge clearance.
P2 — a DB authorization lookup failure silently loses a workflow mention. crates/buzz-relay/src/workflow_sink.rs:543–545 now treats verified_profiles::discovery(...).await.is_some() == false as verified aliases disabled. In DB-backed NIP-FI mode, crates/buzz-relay/src/verified_profiles.rs:130–136 turns a failed binding lookup into the same None (.await.ok().flatten()), even though crates/buzz-db/src/store/nip_fi_binding.rs:157–185 returns a real database error. If that query fails transiently but later roster/name/event writes succeed, an authored verified-only @alias is persisted without p or buzz:workflow-mention tags, while crates/buzz-workflow/src/executor.rs:700–740 records sent: true. The named agent never wakes and the run reports success. The swallowed error existed in discovery, but using discovery as a send-time authorization gate is introduced here. Author action: make this sink's advertisement lookup fallible and propagate uncertainty before event persistence (without changing discovery's external compatibility behavior); add an injected lookup-failure test through the production send seam asserting no false-success persisted event, plus advertised/unadvertised recovery cases. Verification owner: author for fix/test; reviewer for changed-head integration.
Performance contract/test gap: the added no-at-sign case at workflow_sink.rs:1785 asserts output tags, but would still pass if the new text.contains('@') read-skip guard were removed. Please make that optimization falsifiable with a production-seam zero-member/alias-read assertion or equivalent query-count evidence; this is a coverage request, not a second observed runtime failure.
Scope/validation: changed files are relay sink and DB name projection/observability; no UI files or native journey. Independently traced workflow send → membership/names → signed event persist → executor outcome, verified-name gating and SQL projection. At the clean local e0526e62c tree git diff --check passed. GitHub's exact-head check rollup reports Rust Unit Tests, PostgreSQL Tests, Backend Integration, Relay E2E and Desktop E2E Integration successful; no personal full-suite or fault-injected live-relay run was performed. CI success does not exercise the outage condition above. No native artifact was tested. Re-review the fix at its new exact head.
A failed binding lookup made the sink treat verified profiles as not advertised, so an authored verified-only mention lost its tags while the run reported success. Propagate the error like the roster and name reads beside it; discovery() keeps its fail-closed behavior for its other callers. Signed-off-by: Tom Brow <tomb@block.xyz>
|
🤖 Re Jude's review agent's findings:
|
89938da
into
camilos/fix-workflow-verified-mentions
jedwards27
left a comment
There was a problem hiding this comment.
🤖 :bot: Jude’s code review agent — recommend changes at e1c954bb3979adda9fbcb94b770e1b400aa1c6e4 (base 3e0cdfa13fd1638e8469e4fb96b6d3fa6ba66c19). Per this repo’s AGENTS.md, this is a comment review, not a GitHub Request Changes event or merge clearance.
P2 — the outage-vs-disabled fix lacks a falsifiable send-path regression (crates/buzz-relay/src/workflow_sink.rs:545–548; verified_profiles.rs:127–153). The current implementation is sound: try_discovery propagates a database binding-lookup error and send_message returns before signing/persisting the event. The workflow executor records failure rather than sent: true; after DB recovery, the run must be retried. However, the extended workflow_send_message_binds_authority_to_authored_mentions case uses an Env-sourced advertised community. It does not induce CommunitySource::Database binding-lookup failure, so reverting the call to the old fallible-looking discovery() would leave these tests green while reviving silent mention loss. TESTING.md:25–31 requires regressions to bind the production seam and fail when the guard is removed. Author action: add a production RelayActionSink::send_message regression with DB-backed NIP-FI and an injected failed binding lookup; assert the action fails and no event persists (then verify successful routing after recovery if practical). Verification owner: author for the test; reviewer/tooling for rerun and local relay journey. This is a coverage finding, not a claim that the current code misroutes mentions.
Other contract checks: verified names remain gated by community advertisement (channel_members.rs:2762–2773); a no-@ message skips mention resolution. An optional query-count assertion would make that performance claim falsifiable; it is not a separate blocking defect. The code delta is confined to verified_profiles.rs and workflow_sink.rs after the earlier review; no new schema or client behavior was introduced by this fix.
Validation at the clean exact head: independently checked the two-file fix and live PR/check rollup. Local cargo fmt --all --check passed; cargo test -p buzz-db passed (library 219, source-policy integration 44, doctests 5); cargo test -p buzz-relay --lib workflow_sink::tests -- --test-threads=1 passed (23); git diff --check passed. The full cargo test -p buzz-relay was incomplete: access::tests::read_lines_warn_only_on_error failed and config tests stalled, so the run was stopped; no cause was established or attributed to this PR. GitHub’s exact-head Rust Unit Tests, PostgreSQL Tests, Backend Integration (relay e2e), Relay E2E, Rust Lint and DCO checks report success. The Postgres-backed workflow send journey was not run locally because Postgres/Redis and Docker were unavailable; no native/client artifact was tested. CI does not exercise the injected binding outage. No broader full local just ci/just test claim is made.
Follow-up to #9685 (verified profile aliases in workflow mentions), targeting its branch.
#9685 makes every workflow
send_messageload each channel member's full kind:30382 verified-profile event, parse it into anostr::Eventwhile holding the writer connection, and scan the message for about five times as many names, on a tokio worker. That cost lands on every workflow send, including ones that mention no one. It also reads verified names even when the community no longer advertises verified profiles, so leftover profile heads can make an ordinary@Nameambiguous after an operator turns the feature off.This keeps the same output tags and:
@. No@means noporbuzz:workflow-mentiontag can result, so the member and alias reads are skipped.display_name,username,full_name, the samejsonb_path_query_firstexpression profile search uses) instead of shipping and parsing whole events. Identical case-folded names for one member are deduplicated. A malformed head no longer fails the send.@at a left boundary once and matches each name only there, so its cost is names × mentions instead of names × characters. Matching rules are unchanged.verified_profiles::discoverycheck as profile search. Otherwise the heads join is skipped.Validation
workflow_send_message_binds_authority_to_authored_mentions): it now runs with verified profiles advertised, adds a message with no@, and repeats two cases on the same roster without the advertisement (@alexnotifies no one,@Alex Examplenotifies the ordinary member).Regressions
None expected. Output tags are identical for every advertised community. In a community that does not advertise verified profiles, workflow mentions fall back to ordinary names, which is what they matched before #9685.