V3 S5 : graphe documentaire + doublons + collections

Backend : resource_links + scan_session_id (000021), réconciliation
déterministe (same_scan outbox, doublons SHA-256 à l'upload + backfill,
same_issuer/référence via faits effectifs, verdicts préservés, élagage
auto), GET /files/:id/relations + verdict (owner-only),
GET /duplicates (groupes + gain récupérable). Tests service + handlers
+ migrations.

Mobile (Room v22) : links + collections, scanSessionId dans les creates
de scan, LinksRepository (sync + verdicts REST), « Voir aussi » dans la
fiche (verdict infirmer/re-confirmer), écran Doublons (garder le plus
récent), collections locales (sauver/rejouer/supprimer). FR/EN.

Contrat docs/api-v1.md (/relations, pas /links — pris par le partage),
V3.md (S5 livré, version_of non matérialisé).
This commit is contained in:
venture
2026-09-26 11:16:35 +02:00
parent 2d984fd665
commit 37dc36f1f2
66 changed files with 3933 additions and 34 deletions
+19 -4
View File
@@ -34,7 +34,9 @@ type FactDTO struct {
// ProcessText extracts facts from text and replaces the resource's auto
// facts. Empty text clears stale auto facts. Never touches user corrections.
func (e *Extract) ProcessText(resourceID, text string) error {
// Afterwards the deterministic links are reconciled (same_issuer /
// same_reference may have appeared or vanished) — best-effort.
func (e *Extract) ProcessText(ownerID, resourceID, text string) error {
raw := extract.FromText(text)
params := make([]repository.FactParam, 0, len(raw))
for _, f := range raw {
@@ -59,7 +61,13 @@ func (e *Extract) ProcessText(resourceID, text string) error {
Confidence: f.Confidence,
})
}
return e.Repository.Resources.UpsertAutoFacts(resourceID, params)
if err := e.Repository.Resources.UpsertAutoFacts(resourceID, params); err != nil {
return err
}
if err := e.Repository.Resources.ReconcileLinks(ownerID, resourceID); err != nil {
log.Printf("extract: reconcile %s: %v", resourceID, err)
}
return nil
}
// Backfill processes files with OCR text but no auto facts yet (one boot
@@ -75,7 +83,7 @@ func (e *Extract) Backfill(batch int) (int, error) {
return total, nil
}
for _, p := range pending {
if err := e.ProcessText(p.ResourceID, p.Text); err != nil {
if err := e.ProcessText(p.UserID, p.ResourceID, p.Text); err != nil {
log.Printf("extract: backfill %s: %v", p.ResourceID, err)
continue
}
@@ -140,7 +148,14 @@ func (s *Resources) CorrectFacts(userID, resourceID string, facts []FactDTO) err
}
params = append(params, p)
}
return s.Repository.Resources.CorrectFacts(resourceID, params)
if err := s.Repository.Resources.CorrectFacts(resourceID, params); err != nil {
return err
}
// Les faits ont changé : les arêtes same_issuer/same_reference suivent.
if err := s.Repository.Resources.ReconcileLinks(userID, resourceID); err != nil {
log.Printf("extract: reconcile %s: %v", resourceID, err)
}
return nil
}
func validateFactParam(i int, f FactDTO) (repository.FactParam, error) {