searchQueryBuilder still emits the pre-NIP-AMB ext path shape (ext.30168.<pub>.<d>.<field>) #54
Labels
No labels
bug
discussion
enhancement
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
edufeed/edufeed-app#54
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
src/lib/helpers/educational/searchQueryBuilder.jsstill builds ext filters from the old kind-coordinate path shape (ext.30168.<pub>.<d>.<fieldId>/#ext:30168:<pub>:<d>:<fieldId>). The read and write paths were migrated to the conformant NIP-AMB grammarext:<ns>:<facet>[:sub]; the search/filter path was not. A filter this builder produces can therefore never match a tag the write path produces.Where
Two helpers and their doc comments:
searchQueryBuilder.js:46-47—extPathToSearchPath()→`ext.${extKey.replace(/:/g, '.')}`searchQueryBuilder.js:57-58—extPathToTagKey()→`ext:${extKey}`20,42,53Call sites:
searchQueryBuilder.js:120(NIP-50searchstring) and:151(multi-letter#ext:...tag filters).Why it's wrong
The conformant grammar, per
parseTagKey()insrc/lib/helpers/educational/parseExtensionTags.js:151-171, is left-anchored and namespace-based:ekwNamespace.js:27-32documents the same shape and the target serialization, e.g.ext:org.edufeed.ekw.konfi:<slug>:id.Feed the builder's key through that parser and the segments land in the wrong slots:
So the filter targets namespace
30168, facetaaa— neither of which exists in the data.Severity: latent today, but the tests lock the bug in
The emission path is reachable in production —
src/lib/loaders/amb-search.js:42and:78both callbuildSearchFilterObject(). Butfilters.extFieldsis never populated outside tests: greppingextFieldsacrosssrc/returns hits only insearchQueryBuilder.jsandsrc/lib/__tests__/searchQueryBuilder.test.js. Nothing inurlParams.jsor the route components sets it.So no user-visible search is broken right now. The real risk is that
src/lib/__tests__/searchQueryBuilder.test.js:25-60asserts the stale shape as correct — e.g.Whoever next wires ext facets into the filter UI will inherit the wrong shape with a green suite behind it.
Suggested fix
filters.extFieldson<ns>:<facet>instead of30168:<pub>:<d>:<fieldId>.extPathToTagKey()→ext:<ns>:<facet>(+:idfor concept values, which:151-160already appends).extPathToSearchPath()should emit, or drop it — see the note below.searchQueryBuilder.test.jsto assert the conformant shape, and the doc comments at lines 20 / 42 / 53.Note on the dot-path (
search) halfWorth an explicit decision rather than a mechanical rewrite. With reverse-DNS namespaces a dot path is ambiguous:
ext.org.edufeed.ekw.konfi.themen.idgives no way to know where<ns>ends and<facet>begins. The multi-letter tag filter (#ext:org.edufeed.ekw.konfi:themen:id) is exact-match and unambiguous, because the event literally carries that key. Recommendation: make the#ext:tag filter the primary mechanism and treat the dot path as optional/removable.Relay-side context: the ext grammar parser lives in nostrlib
eventstore/typesense30142/nostr_amb.goand now indexes bare scalarext:<ns>:<facet>tags (nostrlibedufeed@99dfee4, deployed via amb-relaymain@a07fb3a).Found while designing the WordPress AMB plugin's facet filters (channel
#edufeed-wordpress-integration), which deliberately does not mirror this builder for the reasons above.