AletheiaFact / AletheiaFact/aletheia
B2B-3 · Sources: per-namespace dedup redesign + data sanitation migration
- Langage dominant
- TypeScript
- Étoiles
- 55
- Forks
- 20
- Merge moyen
- 2 j 6 h
- PR mergées (30 j)
- 2
Description
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:** —
Guide de contribution
Aucun guide de contribution indexé pour ce dépôt
Piste de recherche
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.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- nodejs, typescript
- Domaine
- backend, databases, security
- Type d'issue
- Refactorisation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Activité
- Calme
- Clarté
- Clairement spécifiée
- Accessibilité débutants
- 42/100