GeezerVison is showing github.com — id(search): search_store_terms resolves every subject's event kind even when no kind term is present (PR #1806) · Issue #2779 · developing-today/code
id(search): search_store_terms resolves every subject's event kind even when no kind term is present (PR #1806) #2779DescriptionFinding
search_store_terms (added by PR #1806) resolves the event kind of every subject in the store's live claims up front — one event_by_id store read per distinct subject — even when the term set contains no Term::SubjectKind at all. A pure name/author search (or even an empty term set) pays a full per-subject store scan it never uses, and worse, an event_by_id error on any subject aborts the whole search via ?, including searches that never needed a kind.
Evidence
- PR: id(search): author index, author/kind terms, multi-term AND — fix #800 #1806 (
id(search): author index, author/kind terms, multi-term AND — fix #800), merged as 5a843a1.
- Verified on current main dccfec4,
pkgs/id/src/search.rs (search_store_terms, ~:199-213):
- The
kinds map loop runs unconditionally over claims.iter().map(|claim| claim.subject) and calls store.event_by_id(&subject)? for each distinct subject, before search_terms is invoked.
search_terms only ever calls its subject_kind closure for Term::SubjectKind terms (its doc even notes a caller with no kind terms may pass a lookup that always returns None, as search() does) — so the eager work is discarded whenever no kind term is present.
- The function's own error doc concedes the coupling: "Returns the errors of
EventStore::tag_claims and EventStore::event_by_id" — for every call, not just kind searches.
- No production caller exists yet (only
pkgs/id/tests/search.rs), so this is a latent API defect: the first CLI/web wiring of author or multi-term name search inherits the cost and the failure mode.
Why it matters
Search-by-author and multi-term AND are the §9.4 surfaces this PR built for later wiring. As written, wiring them up makes every search O(subjects) in extra store reads and lets an unrelated subject's unreadable event fail a search that would otherwise succeed — a regression relative to search_store, which never touches event_by_id.
Acceptance criteria
- When
terms contains no Term::SubjectKind, search_store_terms performs no event_by_id calls and cannot fail from one.
- Kind resolution is lazy/memoized per subject actually queried by a kind term (or equivalently gated on a kind term being present).
- Existing tests in
pkgs/id/tests/search.rs still pass, plus a test pinning that a name/author-only search succeeds even when a subject's event cannot be read (or is absent in a way that errors), if the store test harness can express it.
Activitydezren39 commented on Oct 30, 2026 🤖 Agent note · filed
- Agent: pr-diff-review-b
- Session / ID: pr-diff-review-b cron run 2026-10-30 10:18 CDT
- Found via: PR id(search): author index, author/kind terms, multi-term AND — fix #800 #1806 diff review (lane B, developing-today/code)
- Task: Filed the search_store_terms eager kind resolution: on main dccfec4 (search.rs, search_store_terms) every distinct subject gets an event_by_id store read up front regardless of the term set, and any such error aborts the search via
? — even for name/author-only searches that never consult a kind, unlike search_store.
- Expectation: effort xs; done when kind resolution only happens for SubjectKind terms (lazy/memoized) and existing search tests still pass.
- Links: id(search): search_store_terms resolves every subject's event kind even when no kind term is present (PR #1806) #2779 id(search): search_store_terms resolves every subject's event kind even when no kind term is present (PR #1806) #2779 · PR id(search): author index, author/kind terms, multi-term AND — fix #800 #1806 id(search): author index, author/kind terms, multi-term AND — fix #800 #1806 · id phase-5: search by author/kind and multi-term AND are designed but not built or tracked #800 (closed, the feature this PR implemented)
dezren39 commented on Oct 30, 2026 🤖 Agent note · labels mirrored
dezren39 commented on Oct 31, 2026 dezren39 commented on Oct 31, 2026
🤖 Agent note · shepherded to merge, done
- PR: ⚡ Bolt: lazily resolve subject kinds in search_store_terms #2909 MERGED as
5eebd11ad7d82a9d16dfe6d3d0af621614415cf7 (was draft; marked ready by the shepherd). This issue is closed by the merge.
- Verification: diff reviewed against the acceptance; laptop
cargo test --test search 13/13 pass; rustfmt clean on touched files; Codex review (requested by the shepherd — none existed) completed with no findings. No PR CI exists for pkgs/id (id-check.yml is push-to-main only); the main gate now runs on the merge commit.
- Gap noted on the PR: clippy not run locally (package pins Rust 1.99, laptop cargo is 1.98; a clean rebuild did not fit the shift) — covered by the post-merge main gate, fix-forward if it fails.
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|