refactor(relay): drop dead Typesense config + correct stale search comments

The Typesense search backend was replaced by Postgres FTS in this rewrite,
but two vestiges remained in live code:

- `Config.typesense_url` / `Config.typesense_key` were still parsed from
  `TYPESENSE_URL` / `TYPESENSE_API_KEY` and stored on the struct, yet read
  nowhere outside config.rs. Removed the fields, env parsing, and struct init.
- Several doc/inline comments still described the search path as hitting
  Typesense (req.rs NIP-50 handler, bridge.rs post-filter rationale). The
  behavior is unchanged but the engine is Postgres FTS; corrected the naming
  so the comments match the code.

Kept genuinely historical references intact (event.rs note that the old
index_event worker is gone; query.rs/schema provenance of the legacy
__global__ sentinel and the FTS migration).

cargo check -p buzz-relay green.

Co-authored-by: Tyler Longwell <tlongwell@block.xyz>
Signed-off-by: Tyler Longwell <tlongwell@block.xyz>
This commit is contained in:
npub1qyvc0c5kl4gqv2fd97fsk46tu378sqgy35vc83rvgfwne90sel7s0ed67d
2026-06-27 11:48:44 -04:00
co-authored by Tyler Longwell
parent bfbfe57513
commit f1f6bbf3c2
4 changed files with 7 additions and 19 deletions
+1 -1
View File
@@ -79,7 +79,7 @@ anyhow = "1"
uuid = { version = "1", features = ["v4", "serde"] }
chrono = { version = "0.4", features = ["serde"] }
# HTTP client (webhook delivery, Typesense indexing)
# HTTP client (webhook delivery)
reqwest = { version = "0.13", features = ["json", "rustls"], default-features = false }
# Cryptography
+3 -3
View File
@@ -773,7 +773,7 @@ pub async fn count_events(
/// Decide whether a search hit should be returned to the caller.
///
/// Mirrors the WS NIP-50 path's post-filter step in `handlers/req.rs`:
/// Typesense receives only the kind/authors/time pushdown, so any other filter
/// the FTS backend receives only the kind/authors/time pushdown, so any other filter
/// constraint (`#p`, `#h`, `#e`, `#d`, `ids`, …) must be enforced here against
/// the full stored event. Without this, an authorized engram search such as
/// `{"kinds":[30174],"#p":[self]}` would leak text-matching envelopes whose
@@ -1571,7 +1571,7 @@ mod tests {
/// Setup: two engram envelopes by different agents for different owners.
/// An authorized search for `{kinds:[30174], #p:[owner_a]}` would be
/// approved by the engram gate (owner_a is querying engrams addressed to
/// them). Typesense's pushdown only carries `kind:=[30174]`, so the
/// them). The FTS pushdown only carries `kind:=[30174]`, so the
/// envelope for owner_b can come back as a text-match hit. The post-filter
/// in `search_hit_accepted` must reject it.
#[test]
@@ -1602,7 +1602,7 @@ mod tests {
}
/// `authors=[agent_a]` search must not return an envelope authored by agent_b,
/// even if Typesense's text match would otherwise surface it. (Typesense does
/// even if the FTS text match would otherwise surface it. (The FTS query does
/// carry an `authors` pushdown today, so this is defence-in-depth; mirroring
/// the WS contract.)
#[test]
-12
View File
@@ -31,10 +31,6 @@ pub struct Config {
pub database_url: String,
/// Redis connection URL used by the pub/sub manager.
pub redis_url: String,
/// Typesense search server URL.
pub typesense_url: String,
/// Typesense API key.
pub typesense_key: String,
/// Public WebSocket URL of this relay, advertised in NIP-11.
pub relay_url: String,
/// Maximum number of concurrent WebSocket connections.
@@ -177,12 +173,6 @@ impl Config {
let redis_url =
std::env::var("REDIS_URL").unwrap_or_else(|_| "redis://localhost:6379".to_string());
let typesense_url =
std::env::var("TYPESENSE_URL").unwrap_or_else(|_| "http://localhost:8108".to_string());
let typesense_key =
std::env::var("TYPESENSE_API_KEY").unwrap_or_else(|_| "buzz_dev_key".to_string());
let relay_url =
std::env::var("RELAY_URL").unwrap_or_else(|_| "ws://localhost:3000".to_string());
@@ -400,8 +390,6 @@ impl Config {
bind_addr,
database_url,
redis_url,
typesense_url,
typesense_key,
relay_url,
max_connections,
max_concurrent_handlers,
+3 -3
View File
@@ -190,7 +190,7 @@ pub async fn handle_req(
}
}
// Search filters hit Typesense and return historical hits, then EOSE.
// Search filters hit Postgres FTS and return historical hits, then EOSE.
// They are not registered for fan-out. The sensitive-kind gates above
// already ran, so an authed member cannot use search to bypass author/#p
// rules for kind:30174 or other globally-stored gated kinds.
@@ -374,9 +374,9 @@ pub async fn handle_req(
);
}
/// Handle a NIP-50 search REQ: query Typesense, fetch full events, deliver results, EOSE.
/// Handle a NIP-50 search REQ: query Postgres FTS, fetch full events, deliver results, EOSE.
/// Search subscriptions are one-shot — no persistent subscription is registered.
/// Maximum Typesense pages to fetch per filter (prevents unbounded loops).
/// Maximum FTS pages to fetch per filter (prevents unbounded loops).
const MAX_SEARCH_PAGES: u32 = 10;
/// Resolve request-local channel access, repairing a stale cache-negative.