diff --git a/cmd/mcp-marketplace/main.go b/cmd/mcp-marketplace/main.go new file mode 100644 index 0000000..ad0535b --- /dev/null +++ b/cmd/mcp-marketplace/main.go @@ -0,0 +1,26 @@ +// mcp-marketplace wraps marketplace platforms with open data where +// ToS permits. +package main + +import ( + "log/slog" + "os" +) + +// platform is one supported marketplace platform. +type platform struct { + ID string + Name string + Country string + BaseURL string +} + +var platforms = []platform{ + {ID: "olx-pl", Name: "OLX (PL)", Country: "PL"}, + {ID: "carousell-sg", Name: "Carousell (SG)", Country: "SG"}, + {ID: "facebook-marketplace", Name: "Facebook Marketplace", Country: ""}, +} + +func main() { + slog.New(slog.NewJSONHandler(os.Stderr, nil)).Info("mcp-marketplace starting", "platforms", len(platforms)) +} diff --git a/docs/MARKETPLACE-LEGAL.md b/docs/MARKETPLACE-LEGAL.md new file mode 100644 index 0000000..c4ab7ab --- /dev/null +++ b/docs/MARKETPLACE-LEGAL.md @@ -0,0 +1,25 @@ +# Marketplace Module — Legal Review Per Jurisdiction + +Each marketplace platform we ingest has its own ToS and each +jurisdiction has its own consumer-protection regime. Before +activating an ingestion source we document the per-jurisdiction +posture. + +## Per-platform checklist + +- [ ] ToS allows automated reads of the data we use? +- [ ] If not, is there a published partner API or data-feed? +- [ ] What rate limits apply? +- [ ] Are there fields we are explicitly prohibited from storing? +- [ ] Does the platform require attribution on downstream surfaces? + +## Per-jurisdiction checklist + +- [ ] Consumer-protection regulator identified. +- [ ] Local definition of an "illegal commercial practice" reviewed. +- [ ] Local complaint-forwarding pathway documented (Phase 37). +- [ ] Privacy posture aligns with Phase 48 compliance. + +## Audit cadence + +Annual review, plus an ad-hoc review whenever a platform changes ToS. diff --git a/docs/MARKETPLACE-MODULE.md b/docs/MARKETPLACE-MODULE.md new file mode 100644 index 0000000..d5aa3c6 --- /dev/null +++ b/docs/MARKETPLACE-MODULE.md @@ -0,0 +1,38 @@ +# Marketplace Module + +Same families of scammers operate across job offers, rental +listings, used-car listings, freelance gigs, and online marketplaces. +Phase 55 extends Joblantern's coverage so a single network running +all of them is detected as one cluster. + +## Surfaces + +- Schema: [marketplace_verifications](../migrations/0019_marketplace_verifications.sql) +- MCP server: [mcp-marketplace](../cmd/mcp-marketplace/main.go) +- Rule pack: [redflags](../internal/marketplace/redflags/rules.go) +- Cross-link: [crosslink](../internal/marketplace/crosslink/link.go) +- UI: [ui](../internal/marketplace/ui/flow.go) +- Integration with Phase 42 + 43: [integration](../internal/marketplace/integration/external.go) +- Consumer-protection partnerships: [partnerships](../internal/marketplace/partnerships/consumer.go) +- Operator API: [operator](../internal/marketplace/operator/api.go) + +## Rule highlights + +| Code | Severity | Meaning | +|---------------------------|----------|---------| +| `non-escrow-payment` | 5 | Off-platform escrow (WU, gift card, crypto-only). | +| `advance-fee` | 5 | Non-refundable upfront fee. | +| `shipping-via-seller` | 4 | Shipping fee paid via the seller, not the platform. | +| `price-way-below-market` | 3 | Asking price < 30% of median. | +| `off-platform-pressure` | 2 | Seller refuses platform communication. | + +## Legal + +See [MARKETPLACE-LEGAL](MARKETPLACE-LEGAL.md) for per-platform and +per-jurisdiction posture. + +## See also + +- [RENTAL-MODULE](RENTAL-MODULE.md) +- [GRAPH-ANALYSIS](GRAPH-ANALYSIS.md) +- [RECRUITER-API](RECRUITER-API.md) diff --git a/internal/marketplace/crosslink/link.go b/internal/marketplace/crosslink/link.go new file mode 100644 index 0000000..d819e8e --- /dev/null +++ b/internal/marketplace/crosslink/link.go @@ -0,0 +1,40 @@ +// Package crosslink ties a marketplace submission back to the jobs +// and rental graphs. A network that runs all three is a clear +// scam-operator signature. +package crosslink + +import "strings" + +// Match is one detected overlap. +type Match struct { + Kind string // "phone", "email" + Value string +} + +// Detect returns overlaps across the supplied identifier sets. +func Detect(jobPhones, rentalPhones, mktPhones []string) []Match { + set := func(xs []string) map[string]bool { + m := map[string]bool{} + for _, x := range xs { + if v := strings.TrimSpace(x); v != "" { + m[v] = true + } + } + return m + } + jp := set(jobPhones) + rp := set(rentalPhones) + var out []Match + seen := map[string]bool{} + for _, p := range mktPhones { + v := strings.TrimSpace(p) + if v == "" || seen[v] { + continue + } + if jp[v] || rp[v] { + seen[v] = true + out = append(out, Match{Kind: "phone", Value: v}) + } + } + return out +} diff --git a/internal/marketplace/i18n/terms.go b/internal/marketplace/i18n/terms.go new file mode 100644 index 0000000..eca82b6 --- /dev/null +++ b/internal/marketplace/i18n/terms.go @@ -0,0 +1,13 @@ +// Package i18n localises marketplace-specific terminology. +package i18n + +var Terms = map[string]map[string]string{ + "en": {"seller": "Seller", "escrow": "Escrow", "shipping": "Shipping", "payment": "Payment"}, + "hi": {"seller": "विक्रेता", "escrow": "एस्क्रो", "shipping": "शिपिंग", "payment": "भुगतान"}, + "bn": {"seller": "বিক্রেতা", "escrow": "এসক্রো", "shipping": "শিপিং", "payment": "অর্থপ্রদান"}, + "tl": {"seller": "Nagbebenta", "escrow": "Escrow", "shipping": "Paghahatid", "payment": "Bayad"}, + "id": {"seller": "Penjual", "escrow": "Escrow", "shipping": "Pengiriman", "payment": "Pembayaran"}, + "ar": {"seller": "البائع", "escrow": "ضمان", "shipping": "شحن", "payment": "دفع"}, + "ur": {"seller": "بیچنے والا", "escrow": "ایسکرو", "shipping": "ترسیل", "payment": "ادائیگی"}, + "ne": {"seller": "बिक्रेता", "escrow": "एस्क्रो", "shipping": "ढुवानी", "payment": "भुक्तानी"}, +} diff --git a/internal/marketplace/integration/external.go b/internal/marketplace/integration/external.go new file mode 100644 index 0000000..736a17d --- /dev/null +++ b/internal/marketplace/integration/external.go @@ -0,0 +1,29 @@ +// Package integration wires marketplace verdicts into Phase 42 +// (caller-ID) and Phase 43 (graph analysis) so a scam network across +// jobs, rentals, and marketplaces collapses into one component. +package integration + +// Bridge wraps the small set of hooks the marketplace module needs. +type Bridge interface { + PushPhoneHash(phoneHash, band string) error + PushEntity(kind, id string) error + PushEdge(a, b string) error +} + +// Wire performs the per-verdict propagation using the bridge. +func Wire(b Bridge, phones []string, sellerEntity string, marketEntity string) error { + for _, p := range phones { + if err := b.PushPhoneHash(p, "red"); err != nil { + return err + } + } + if err := b.PushEntity("seller", sellerEntity); err != nil { + return err + } + if marketEntity != "" { + if err := b.PushEdge(sellerEntity, marketEntity); err != nil { + return err + } + } + return nil +} diff --git a/internal/marketplace/operator/api.go b/internal/marketplace/operator/api.go new file mode 100644 index 0000000..d596085 --- /dev/null +++ b/internal/marketplace/operator/api.go @@ -0,0 +1,24 @@ +// Package operator extends the Phase 27 recruiter API for marketplace +// operators. Operators can subscribe to scam-listing notifications +// keyed on their own listing IDs. +package operator + +import "time" + +// Subscription is one operator's webhook subscription for incidents +// touching their listings. +type Subscription struct { + OperatorID string + URL string + Secret []byte + CreatedAt time.Time +} + +// Notification is the wire form delivered to operator endpoints. +type Notification struct { + IncidentID string `json:"incident_id"` + ListingID string `json:"listing_id"` + Band string `json:"band"` + Confidence float64 `json:"confidence"` + At time.Time `json:"at"` +} diff --git a/internal/marketplace/partnerships/consumer.go b/internal/marketplace/partnerships/consumer.go new file mode 100644 index 0000000..51cc5f6 --- /dev/null +++ b/internal/marketplace/partnerships/consumer.go @@ -0,0 +1,24 @@ +// Package partnerships tracks the consumer-protection-agency +// partnerships specific to the marketplace module. These are typically +// not the labour ministries from Phase 37 but parallel consumer +// agencies. +package partnerships + +// Agency is one consumer-protection partner. +type Agency struct { + ID string + Country string + Name string + ContactURL string + MOUSigned bool +} + +// Defaults returns the seed list. +func Defaults() []Agency { + return []Agency{ + {Country: "PH", Name: "DTI Consumer Protection"}, + {Country: "IN", Name: "Consumer Affairs (MoCA)"}, + {Country: "AE", Name: "UAE Consumer Protection Department"}, + {Country: "DE", Name: "Verbraucherzentrale Bundesverband"}, + } +} diff --git a/internal/marketplace/redflags/rules.go b/internal/marketplace/redflags/rules.go new file mode 100644 index 0000000..31bcad5 --- /dev/null +++ b/internal/marketplace/redflags/rules.go @@ -0,0 +1,42 @@ +// Package redflags scores marketplace-specific scam patterns. +package redflags + +import "strings" + +// Flag is a finding. +type Flag struct { + Code string + Severity int + Message string +} + +// Submission is the input the rule pack consumes. +type Submission struct { + PaymentMethod string + ShippingMethod string + PriceBelowMedianRatio float64 + OfferOnlyByDirect bool + BuyerPaysShippingViaSeller bool + AdvanceFeeRequested bool +} + +// Scan runs the rule pack. +func Scan(s Submission) []Flag { + var flags []Flag + if pm := strings.ToLower(s.PaymentMethod); strings.Contains(pm, "western union") || strings.Contains(pm, "gift card") || strings.Contains(pm, "crypto only") { + flags = append(flags, Flag{"non-escrow-payment", 5, "Payment outside platform escrow is a near-universal marketplace scam pattern."}) + } + if s.BuyerPaysShippingViaSeller { + flags = append(flags, Flag{"shipping-via-seller", 4, "Buyer is asked to pay a 'shipping fee' via the seller — typical shipping-diversion."}) + } + if s.AdvanceFeeRequested { + flags = append(flags, Flag{"advance-fee", 5, "Seller asks for an upfront non-refundable fee."}) + } + if s.PriceBelowMedianRatio > 0 && s.PriceBelowMedianRatio < 0.3 { + flags = append(flags, Flag{"price-way-below-market", 3, "Asking price is less than 30% of median for similar items."}) + } + if s.OfferOnlyByDirect { + flags = append(flags, Flag{"off-platform-pressure", 2, "Seller refuses to communicate on the platform."}) + } + return flags +} diff --git a/internal/marketplace/redflags/rules_test.go b/internal/marketplace/redflags/rules_test.go new file mode 100644 index 0000000..5da6daf --- /dev/null +++ b/internal/marketplace/redflags/rules_test.go @@ -0,0 +1,22 @@ +package redflags + +import "testing" + +func TestUsedPhoneFixtureCatchesNetwork(t *testing.T) { + flags := Scan(Submission{ + PaymentMethod: "Western Union only", + BuyerPaysShippingViaSeller: true, + AdvanceFeeRequested: true, + PriceBelowMedianRatio: 0.2, + OfferOnlyByDirect: true, + }) + if len(flags) < 4 { + t.Fatalf("expected >=4 flags, got %d", len(flags)) + } +} + +func TestLegitimatePassesClean(t *testing.T) { + if got := Scan(Submission{PaymentMethod: "platform escrow"}); len(got) != 0 { + t.Fatalf("expected no flags for clean fixture, got %d", len(got)) + } +} diff --git a/internal/marketplace/ui/flow.go b/internal/marketplace/ui/flow.go new file mode 100644 index 0000000..92b05a2 --- /dev/null +++ b/internal/marketplace/ui/flow.go @@ -0,0 +1,24 @@ +// Package ui renders the marketplace submission form. +package ui + +const SubmitForm = ` +Marketplace check + + +
+

Check a marketplace listing

+
+ + + + + + + + + + + +
+
+` diff --git a/migrations/0019_marketplace_verifications.sql b/migrations/0019_marketplace_verifications.sql new file mode 100644 index 0000000..60531c6 --- /dev/null +++ b/migrations/0019_marketplace_verifications.sql @@ -0,0 +1,25 @@ +-- +goose Up +CREATE TABLE IF NOT EXISTS marketplace_verifications ( + id uuid PRIMARY KEY, + submitted_at timestamptz NOT NULL DEFAULT now(), + country text NOT NULL, + platform text, + category text, + listing_url text, + listing_hash text NOT NULL, + price numeric(12,2), + currency text, + contact_phone text, + contact_email text, + payment_method text, + shipping_method text, + risk_score smallint NOT NULL CHECK (risk_score BETWEEN 0 AND 100), + risk_band text NOT NULL CHECK (risk_band IN ('green','yellow','red')), + red_flags jsonb NOT NULL DEFAULT '[]'::jsonb +); + +CREATE INDEX IF NOT EXISTS marketplace_country_idx ON marketplace_verifications(country); +CREATE INDEX IF NOT EXISTS marketplace_phone_idx ON marketplace_verifications(contact_phone); + +-- +goose Down +DROP TABLE IF EXISTS marketplace_verifications;