Bound discovery without an unsupported owner filter

Signed-off-by: kenny lopez <klopez4212@gmail.com>
This commit is contained in:
kenny lopez
2026-10-15 07:13:38 -04:00
parent b8e17b0896
commit a7336b122a
2 changed files with 5 additions and 7 deletions

View File

@@ -43,6 +43,9 @@ Future<List<AgentDirectoryEntry>> _loadAssistants(
final profiles = <String, NostrEvent>{};
final seen = <String>{};
const pageSize = 100;
// The current relay only indexes single-letter NIP-01 tag filters. It
// silently drops #auth, so owner-scoped discovery needs relay support.
// Until then fail visibly at this bound rather than drain the directory.
const maxPages = 10;
for (var page = 1; page <= maxPages; page++) {
sync.check();
@@ -50,11 +53,6 @@ Future<List<AgentDirectoryEntry>> _loadAssistants(
NostrFilter(
kinds: const [0],
authors: pubkey == null ? null : [pubkey],
tags: pubkey == null
? {
'#auth': [sync.pubkey],
}
: const {},
limit: pageSize,
extensions: {'page': page},
),

View File

@@ -125,7 +125,7 @@ void main() {
expect(relay.requestedPages, [1, 2]);
});
test(
'owner discovery is scoped and bounded even when the relay keeps paging',
'directory discovery is bounded even when the relay keeps paging',
() async {
final repeated = [
for (var i = 0; i < 99; i++) profile(agent, ownedBy: owner, time: i),
@@ -140,7 +140,7 @@ void main() {
);
expect(relay.requestedPages.length, 10);
for (final filter in relay.requestedTags) {
expect(filter['#auth'], [owner.public]);
expect(filter.containsKey('#auth'), isFalse);
expect(filter['limit'], 100);
}
},