AletheiaFact / AletheiaFact/aletheia
B2B-3 · Sources: per-namespace dedup redesign + data sanitation migration
- Lenguaje dominante
- TypeScript
- Estrellas
- 55
- Forks
- 20
- Merge medio
- 2 d 6 h
- PR fusionados (30 d)
- 2
Descripción
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:** —
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Evaluación
Este issue todavía no se ha evaluado.