spike(block2): de-risk social layer — key derivation, OfferTransport, NIP-99 round-trip
Throwaway research spike (spike/ branch, outside pub workspace, no prod deps touched). Validates the open Block 2 decisions before committing a funded round: 1. Deterministic one-way secp256k1 (Nostr) key derived from the Ğ1 root seed via HKDF — user still backs up ONE thing. Reproducible + signs (BIP340). 2. OfferTransport abstraction over Nostr NIP-99 (kind 30402); Offer stays inventory/location-agnostic, geohash coarsened on the wire (tested). 3. publish->discover-by-geohash proven end-to-end against an in-process hermetic mini-relay (~34ms round-trip). Findings + risks + recommendation in docs/design/spike-block2-findings.md. Block 1 suite untouched. 14 tests green, analyzer clean.
This commit is contained in:
parent
6eb1517ffb
commit
49b872b405
16 changed files with 1284 additions and 0 deletions
29
spike/block2_spike/lib/src/offer_transport.dart
Normal file
29
spike/block2_spike/lib/src/offer_transport.dart
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
import 'offer.dart';
|
||||
|
||||
/// The abstraction the plan promises lives in `commons_core` (core-domain-
|
||||
/// boundary.md §2, PLAN §4): publish an [Offer], discover offers by area. The
|
||||
/// concrete Nostr NIP-99 backend sits behind this so the domain never talks to
|
||||
/// a relay directly, and a second backend (ActivityPub / FEP-0837) could slot
|
||||
/// in without the app noticing.
|
||||
///
|
||||
/// Spike Question 2 asks whether messaging (NIP-17) and trust (NIP-85) fit
|
||||
/// behind this same seam, or whether they couple more than the plan implies.
|
||||
/// The finding: they do NOT belong here — they share the *key* and the *relay
|
||||
/// connection*, but their verbs differ (send/receive a private DM; assert/read
|
||||
/// a certification). Forcing them behind `OfferTransport` would overload it.
|
||||
/// See spike-block2-findings.md §2 for the proposed 3-interface split over one
|
||||
/// shared `NostrConnection`.
|
||||
abstract interface class OfferTransport {
|
||||
/// Publishes (or replaces) [offer]. Idempotent on the offer id.
|
||||
Future<PublishResult> publish(Offer offer);
|
||||
|
||||
/// Streams offers matching [query]. Emits already-stored matches, then live
|
||||
/// ones as they arrive, until the caller cancels the subscription.
|
||||
Stream<Offer> discover(DiscoveryQuery query);
|
||||
|
||||
/// Retracts a previously published offer (NIP-99: publish a `closed` status /
|
||||
/// NIP-09 deletion). Relays that already replicated it drop it over time.
|
||||
Future<void> retract(String offerId);
|
||||
|
||||
Future<void> close();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue