AletheiaFact / AletheiaFact/aletheia

B2B-3 · Sources: per-namespace dedup redesign + data sanitation migration

Aperta
#2,536 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
backlog server
Lingua principale
TypeScript
Stelle
55
Fork
20
Merge medio
2g 6h
PR unite (30g)
2

Descrizione

Part of the B2B epic (Fase 1 · item 1.1c). The current dedup model makes source isolation impossible and is already a cross-namespace leak vector:

1. **Global `unique` index on `data_hash`** (`server/source/schemas/source.schema.ts:43`, `data_hash = md5(href)`): the first org to cite a URL locks the document for everyone — the collision/deadlock problem.
2. **`create()` dedups cross-namespace** (`server/source/source.service.ts:64-70`): returns the existing doc regardless of namespace.
3. **`updateTargetId()` mixes namespaces** (`source.service.ts:75-84`): one shared source doc accumulates `targetId`s pointing at claims/reviews from different namespaces — a "public" source can carry references to private claim IDs.

## What
- [ ] Replace `unique: data_hash` with a **compound unique index `(nameSpace, data_hash)`** — same URL can exist once *per namespace*; no deadlock
- [ ] `create()` dedups within the namespace: `findOne({ data_hash, nameSpace })`
- [ ] **Sanitation migration**: split existing docs whose `targetId`s cross namespaces (one doc per namespace, each keeping only its own targets); drop old index, create the compound one
- [ ] Add `nameSpace` filtering to `getByDataHash`, `getSourceByHref`, `getByTargetId`, `update`

## Notes
- The sanitation migration is a **prerequisite for any contractual isolation claim** — it must run before the first client, not after.
- The reopen job (B2B-9) must dedup against the public namespace when moving private content to the commons.

**Effort:** ~1–1.5 SP · **Depends on:** —

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Direzione di ricerca

Read server/source/schemas/source.schema.ts and server/source/source.service.ts, then trace the source lookup and update entry points named in the issue. The work is done when deduplication and every listed lookup are namespace-scoped, existing cross-namespace documents are split by namespace, and the old index is replaced by the compound index.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
nodejs, typescript
Ambito
backend, databases, security
Tipo di issue
Refactoring
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Tranquilla
Chiarezza
Specificata chiaramente
Idoneità per principianti
42/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.