feat(aggregator): scraper daemon + dual-mode write-policy (#1046)#1069
Open
c03rad0r wants to merge 4 commits into
Open
feat(aggregator): scraper daemon + dual-mode write-policy (#1046)#1069c03rad0r wants to merge 4 commits into
c03rad0r wants to merge 4 commits into
Conversation
c03rad0r
added a commit
to c03rad0r/market
that referenced
this pull request
Jun 26, 2026
Resolves prettier CI failures flagged in review of PRs PlebeianApp#1066/PlebeianApp#1069 (see t_f79d730e). Touches only files already in the env-config fix: - src/lib/stores/ndk.ts: wrap over-width constants import; collapse primaryAgg ternary to single line (fits print width) - deploy-simple/aggregator/docker-compose.yml: single-quote ports mapping (pre-existing double-quote violation)
c03rad0r
added a commit
to c03rad0r/market
that referenced
this pull request
Jun 26, 2026
…App#1069 + RELAY_PLAN.md Reconcile the write-policy conflict between PR PlebeianApp#1066 (market-kind gate) and PR PlebeianApp#1069 (dual-mode gate + scraper): - Adopt dual-mode gate from PlebeianApp#1069 as final design: PUBLIC market kinds from any pubkey, RESTRICTED kinds (gift wraps, orders, wallets) from root + WoT only - Merge expanded kind set from PlebeianApp#1066 into the dual-mode structure: adds 4 (DMs), 5 (deletions), 1111 (comments), 30018 (legacy products), 30000 (app settings), 25910 (ctxvm), 31989 (NIP-89 handler rec) - Add RELAY_PLAN.md from PlebeianApp#1066 (updated for dual-mode) - Root npub bootstrap retained for all kinds This ensures the marketplace shows all sellers' public data while keeping private order/payment data gated to trusted pubkeys. Refs PlebeianApp#1046, PlebeianApp#1066, PlebeianApp#1069
c03rad0r
added a commit
to c03rad0r/market
that referenced
this pull request
Jun 26, 2026
…dual-mode gate Add 7 market-relevant kinds missing from the scraper branch's PUBLIC_MARKET_KINDS, discovered in the PlebeianApp#1066 codebase audit: - 4 (DMs/NIP-04), 5 (deletions), 1111 (comments) - 30018 (NIP-15 legacy products), 30000 (app settings/vanity/NIP-05) - 25910 (ctxvm messages), 31989 (NIP-89 handler recommendation) Also add RELAY_PLAN.md documenting the two-tier relay topology and dual-mode gate policy. The dual-mode design from PlebeianApp#1069 is preserved: PUBLIC kinds from any pubkey, RESTRICTED kinds (gift wraps, orders, wallets, app data) from root + WoT only. Refs PlebeianApp#1046, PlebeianApp#1066, PlebeianApp#1069
This test file was added in the prettier commit but targets an applesauce-relay + RelayLiveness client architecture that the committed src/lib/ctxcn-client.ts does not implement (it uses nostr-tools SimplePool). The class API it asserts against — healthyRelays(), allRelaysUnhealthy(), RelayLiveness.failover — does not exist in the current client, so 21 of 23 tests fail (the 3 surfaced by CI at lines 297/310/323 plus 18 more), all with 'pool/liveness is undefined'. It is a duplicate of contextvm-client.test.ts, which already covers the real PlebianCurrencyClient against nostr-tools (6/6 pass). The relay aggregator is unrelated to the currency client, so this file is simply an accidental inclusion. Removing it: full test:unit suite goes 103 pass / 0 fail. Refs PlebeianApp#1046, PlebeianApp#1066
Reframe the MARKET_AGGREGATOR_RELAY doc comment as a read-only caching relay for marketplace events rather than a 'WoT-gated' relay, matching the product framing of this PR. Refs PlebeianApp#1046, PlebeianApp#1066
c03rad0r
added a commit
to c03rad0r/market
that referenced
this pull request
Jun 27, 2026
…anApp#1069) 108 tests covering: - write-policy dual-mode gate: PUBLIC market kinds accepted from anyone, RESTRICTED kinds (1059/1060/30078/13/14/16/17/17375) gated to root npub + WoT allowlist, unknown kinds rejected; allowlist hot-reload on mtime change; full stdin/stdout strfry plugin protocol via subprocess. - scraper daemon: pubkey tracking/harvest with MAX_PUBKEYS cap, bounded LRU event dedup, kind-3 follow + kind-10002 relay-list parsing, WoT export, stale pruning, relay-index discovery, and the relay_worker mirror path (chunked-author + #p subscriptions over SCRAPE_KINDS, deduped republish) with a stubbed websocket module. pytest.ini adds pythonpath=. so the flat aggregator modules are importable; write-policy.py (hyphenated) is loaded via importlib.
cdead97 to
8a489c8
Compare
…p#1046) Active scraper daemon that mirrors marketplace events into the aggregator relay from PlebeianApp#1066, plus a dual-mode write-policy: public market kinds accepted from anyone, restricted kinds gated to the operator + allowlist. Stacked on feat/market-agg-relay (PlebeianApp#1066).
8a489c8 to
fde91ff
Compare
7 tasks
Contributor
Author
c03rad0r
added a commit
to c03rad0r/market
that referenced
this pull request
Jun 28, 2026
…App#1069 + RELAY_PLAN.md Reconcile the write-policy conflict between PR PlebeianApp#1066 (market-kind gate) and PR PlebeianApp#1069 (dual-mode gate + scraper): - Adopt dual-mode gate from PlebeianApp#1069 as final design: PUBLIC market kinds from any pubkey, RESTRICTED kinds (gift wraps, orders, wallets) from root + WoT only - Merge expanded kind set from PlebeianApp#1066 into the dual-mode structure: adds 4 (DMs), 5 (deletions), 1111 (comments), 30018 (legacy products), 30000 (app settings), 25910 (ctxvm), 31989 (NIP-89 handler rec) - Add RELAY_PLAN.md from PlebeianApp#1066 (updated for dual-mode) - Root npub bootstrap retained for all kinds This ensures the marketplace shows all sellers' public data while keeping private order/payment data gated to trusted pubkeys. Refs PlebeianApp#1046, PlebeianApp#1066, PlebeianApp#1069
Contributor
Author
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds an active scraper daemon to the aggregator relay from #1066, so it continuously mirrors marketplace events from upstream relays into one fast local relay — instead of only storing events explicitly published to it. The market app then reads from a single, pre-populated relay. Also adds a write-policy that accepts all marketplace event kinds.
Why
The aggregator relay deployed in #1066 only holds events explicitly published to it. Without active scraping it would miss most marketplace activity — listings, profiles, ratings, etc. live spread across many public relays. The scraper pre-fetches and caches them so the app's reads resolve against one healthy local relay instead of fanning out across potentially-slow public relays.
Refs #1046. Depends on #1066.
Changes
scraper.py(new)#psubscriptions, and republishes every matching event into strfry. Tracks discovered pubkeys (capped viaMAX_PUBKEYS) and prunes stale entries hourly.write-policy.pytests/(new)MAX_PUBKEYScap, bounded-LRU event dedup, kind-3 follow + kind-10002 relay-list parsing, pruning, discovery, and therelay_workermirror path (subscription construction + deduped republish) with a stubbedwebsocket.Dockerfilepy3-websocket-client(thewebsocket-clientlibscraper.pyimports).docker-compose.ymlscraperservice (depends onstrfry-market-agg, read-writestatevolume, internalws://strfry-market-agg:7777URL).README.mdstrfry.conf/.env.exampleArchitecture
Test plan
pytest deploy-simple/aggregator/ -q→ 108 passed — write-policy market-kind acceptance (via a real subprocess exercising the stdin/stdout plugin protocol) and scraper logic +relay_workermirror path with a stubbedwebsocketmodule (no network)..pyfilespy_compileclean;docker-compose.ymlvalidated.