Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions cmd/mcp-marketplace/main.go
Original file line number Diff line number Diff line change
@@ -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))
}
25 changes: 25 additions & 0 deletions docs/MARKETPLACE-LEGAL.md
Original file line number Diff line number Diff line change
@@ -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.
38 changes: 38 additions & 0 deletions docs/MARKETPLACE-MODULE.md
Original file line number Diff line number Diff line change
@@ -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)
40 changes: 40 additions & 0 deletions internal/marketplace/crosslink/link.go
Original file line number Diff line number Diff line change
@@ -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
}
13 changes: 13 additions & 0 deletions internal/marketplace/i18n/terms.go
Original file line number Diff line number Diff line change
@@ -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": "भुक्तानी"},
}
29 changes: 29 additions & 0 deletions internal/marketplace/integration/external.go
Original file line number Diff line number Diff line change
@@ -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
}
24 changes: 24 additions & 0 deletions internal/marketplace/operator/api.go
Original file line number Diff line number Diff line change
@@ -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"`
}
24 changes: 24 additions & 0 deletions internal/marketplace/partnerships/consumer.go
Original file line number Diff line number Diff line change
@@ -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"},
}
}
42 changes: 42 additions & 0 deletions internal/marketplace/redflags/rules.go
Original file line number Diff line number Diff line change
@@ -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
}
22 changes: 22 additions & 0 deletions internal/marketplace/redflags/rules_test.go
Original file line number Diff line number Diff line change
@@ -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))
}
}
24 changes: 24 additions & 0 deletions internal/marketplace/ui/flow.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Package ui renders the marketplace submission form.
package ui

const SubmitForm = `<!doctype html>
<html><head><meta charset="utf-8"><title>Marketplace check</title>
<link rel="stylesheet" href="/static/joblantern.css"></head>
<body>
<main class="container">
<h1>Check a marketplace listing</h1>
<form action="/marketplace/submit" method="post">
<label>Listing URL <input name="listing_url" type="url" required></label>
<label>Platform <input name="platform" required></label>
<label>Category <input name="category"></label>
<label>Country (ISO-2) <input name="country" maxlength="2" required></label>
<label>Price <input name="price" type="number" step="0.01"></label>
<label>Currency <input name="currency" maxlength="3"></label>
<label>Payment method <input name="payment_method"></label>
<label>Shipping method <input name="shipping_method"></label>
<label>Seller phone <input name="contact_phone" type="tel"></label>
<label>Seller email <input name="contact_email" type="email"></label>
<button type="submit">Check</button>
</form>
</main>
</body></html>`
25 changes: 25 additions & 0 deletions migrations/0019_marketplace_verifications.sql
Original file line number Diff line number Diff line change
@@ -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;
Loading