Supplier Network

NOTE

Статус: Live (HEAD 5e4ce54, 2026-05-06). Iter-1 scope: enums + entity + repo. Trust-tier supply chain (ADR-0026 §5b) остаётся stub. Seller axis добавлен в P4b.

BC хранит метаданные о поставщиках, складах (Warehouse) и продавцах (Seller) в виде графа. Все остальные BC обращаются через supplier_ref, warehouse_ref, seller_ref.

Назначение

Единое место истины для:

  • Списка поставщиков и их идентификаторов.
  • Складов поставщика (Warehouse) с типами (regional_center, logistics_center, pickup_office, manufacturer_warehouse, third_party, transit).
  • Sellers (для marketplace-агрегаторов; Smart-shop.pro когда будет).
  • Synchronization cursors (cursor-based ingestion: DKC, future Systeme).

Статус документа

Область действия

Входит:

  • Warehouse aggregate + WarehouseKind enum.
  • Seller aggregate + SellerRating value object (P4b).
  • SupplierRef / WarehouseRef / SellerRef value objects.
  • SyncCursor (revision-based для DKC; date-based zachet для Systeme retrofit).
  • Repo ports (Warehouse, Seller, SyncCursor).

Не входит:

  • Trust-tier weighting (ADR-0026 §5b — Phase 7 stubs).
  • Supply-chain trace (warehouse → supplier_factory link) — Phase 2+.
  • Network discovery / graph queries — отдельный слой когда понадобится.

Публичный контракт

Внутренний Go API

  • WarehouseRepo.GetByRef(ctx, ref).
  • WarehouseRepo.ListBySupplier(ctx, supplierRef).
  • SellerRepo.GetByRef, SellerRepo.UpsertRating.
  • SyncCursorRepo.Get(ctx, supplierRef) / .Set(ctx, cursor) — для DKC ingestion.

Внутренняя архитектура

  • domain/refs.go — value objects SupplierRef / WarehouseRef / SellerRef.
  • domain/entity.goWarehouse aggregate.
  • domain/seller.go + seller_rating.go — Seller + rating.
  • domain/sync_cursor.go — cursor для incremental sync.
  • domain/seller_events.go — events для outbox.
  • infra/pg/ — repos.

Зависимости

  • PostgreSQLwarehouse, seller, seller_rating, supplier_sync_cursor.

Хранилище

ТаблицаНазначение
warehouse(supplier_ref, warehouse_ref) UNIQUE; kind
seller(supplier_ref, seller_ref) UNIQUE
seller_ratingper-seller numeric rating
supplier_sync_cursorrevision_number или iso_date per supplier

Тестирование

  • Unit: go test ./internal/core/supplier-network/...
  • Integration: -tags=integration для repos.

Наблюдаемость

  • Metrics: supplier_warehouses_total, supplier_sellers_total, supplier_sync_cursor_advance_total.

Открытые вопросы / TODO

  • Trust-tier supply chain (ADR-0026 §5b) — stubs only.
  • Supply-chain trace — warehouse → factory link.
  • Network discovery — graph queries (ADR-0013 target).

Связанные документы

  • ADR: 0013, 0025, 0026, 0029.
  • Memory: tracium_p4b_execution.md, tracium_cycle4_dkc_taxonomy_execution.md.