AI DOSSIER / 09 / MVP ARCHITECTURE / 2026

Dossier MVP: canonical core + projections.

Единая архитектура Dossier, где наша canonical модель и правила историчности являются system of record, а TriliumNext, OpenCTI или Aleph подключаются как заменяемые projections/backends. Это позволяет не запирать всю экосистему ИИшки в чужой ontology.

Главное правило: canonical store принадлежит Dossier Core. Любой внешний продукт — projection, index, document backend или UI, но не источник истины для IDs, revisions, conflicts и workflow semantics.

1. Логическая схема

Writer      Researcher      Curator      Source Watch
   \            |              |              /
    \           |              |             /
     +--------------------------------------+
     |         DOSSIER API / MCP            |
     +--------------------------------------+
                        |
                        v
     +--------------------------------------+
     |        DOSSIER APPLICATION CORE      |
     |--------------------------------------|
     | canonical IDs                        |
     | entity/claim/source model            |
     | evidence bundles                     |
     | timeline                             |
     | conflicts                            |
     | open questions                       |
     | version/supersede                    |
     | merge/archive                        |
     | permissions                          |
     +--------------------------------------+
              |                  |
              v                  v
     +----------------+   +------------------+
     | CANONICAL DB   |   | ATTACHMENT STORE |
     | Postgres       |   | files/objects     |
     +----------------+   +------------------+
              |
              v
     +--------------------------------------+
     |        PROJECTION / ADAPTER BUS      |
     +--------------------------------------+
        |              |               |
        v              v               v
   TriliumNext      OpenCTI          Aleph
   UI/workspace     graph/cases      docs/entities

2. Dossier Core services

ServiceResponsibility
DossierServicecreate/get/search/lifecycle
EntityServiceidentity, aliases, relations
SourceServicesource/document refs, provenance
ClaimServiceworking claims, state, scope
EvidenceServicesupport/counter/conflict bundles
TimelineServiceoccurred/discovered events
ConflictServiceconflict creation/resolution
QuestionServiceopen question workflow
VersionServicescope, supersede, historical state
MergeServicetransactional dossier merge
ContextExportServiceWriter/Researcher/Skeptic packs
ProjectionServicesync external backends
AuditServiceimmutable mutation trace

3. Canonical storage

Recommended MVP baseline

Postgres
+
JSONB for flexible metadata
+
relational tables for critical graph edges
+
object/file storage for attachments
+
optional FTS/vector index later

Tables

dossiers
dossier_revisions
entities
entity_aliases
relations
sources
documents
claims
evidence_bundles
evidence_links
timeline_events
conflicts
open_questions
supersede_edges
research_run_refs
curator_decision_refs
projection_mappings
projection_jobs
audit_events

Why Postgres first

4. Projection architecture

ProjectionAdapter

upsert_dossier()
upsert_entity()
upsert_source()
upsert_claim()
upsert_event()
upsert_conflict()
archive_dossier()
delete_projection()
health()
export_vendor_state()

Mapping table

{
  "canonical_type": "entity",
  "canonical_id": "ent_123",
  "backend": "trilium",
  "external_id": "abc123",
  "projection_revision": 17,
  "status": "APPLIED"
}

Rule

Projection может быть rebuilded from canonical data. Обратное не должно быть обязательным условием восстановления Dossier.

5. Write/read flow

Write

Researcher
→ dossier.add_claim
→ auth
→ revision check
→ provenance validation
→ canonical transaction
→ audit event
→ projection job
→ response

Projection

projection job
→ adapter
→ vendor backend
→ save external ID
→ mark APPLIED

failure:
→ PROJECTION_FAILED
→ canonical data remains valid

Read

Writer
→ dossier.export_context
→ canonical query
→ scope filter
→ current/historical classification
→ conflict/open question overlay
→ ContextPack

6. ИИшка integrations

Researcher

reads current dossier
→ sees open questions
→ performs research
→ appends sources/claims/evidence/events
→ attaches ResearchRunRef

Writer

read-only
→ export_context
→ chronology/current claims/conflicts
→ no write

Curator

reads dossier evidence
→ decides REJECT/RUN_ONLY/PROMOTE
→ Dossier stores decision ref
→ permanent knowledge lives elsewhere

Source Watch

detects source change
→ add SOURCE_CHANGE event
→ optionally open question
→ no claim overwrite

Skeptic

can receive scoped dossier context
for draft verification
→ read-only

7. Security boundary

Writer:
READ context only

Researcher:
READ + append working context

Curator:
READ + decision refs

Source Watch:
READ scoped + add event/source change

Human:
review + merge/archive

Admin:
maintenance

Critical rules

8. Failure handling

canonical DB down
→ all writes fail

audit unavailable
→ critical writes fail

projection down
→ canonical write may commit
→ projection PENDING/FAILED

attachment store down
→ document mutation staged/rejected

merge failure
→ rollback

revision conflict
→ reject/rebase

broken provenance
→ INTEGRITY_ERROR
→ excluded from CURRENT context

Projection reconciliation

scheduled/manual:
scan PENDING/FAILED
→ retry
→ compare projection revision
→ repair drift

9. Deployment on server2

server2
|
+-- Qwen 30B
|
+-- dossier-api
|
+-- dossier-worker
|
+-- postgres
|
+-- attachment storage
|
+-- optional projection:
     TriliumNext
     OR OpenCTI
     OR Aleph
     only after benchmark

MVP resource principle

Canonical Dossier должен работать без внешней платформы. Это позволяет запустить MVP на минимальном footprint и подключать projection только если benchmark докажет ценность.

10. MVP — MUST HAVE

[ ] canonical Postgres schema
[ ] Dossier CRUD/lifecycle
[ ] Entity + relation
[ ] Source + document refs
[ ] Claim
[ ] EvidenceBundle
[ ] TimelineEvent
[ ] Conflict
[ ] OpenQuestion
[ ] VersionScope
[ ] supersede edges
[ ] merge transaction
[ ] archive/reopen
[ ] Researcher integration
[ ] Curator decision refs
[ ] Writer context export
[ ] Source Watch event path
[ ] optimistic concurrency
[ ] audit
[ ] export/import
[ ] projection adapter interface
[ ] one fake adapter
[ ] failure/security tests

11. DEFER after MVP

multiple live projections simultaneously
rich custom frontend
graph visualization
automatic entity resolution by LLM
vector search
semantic dossier clustering
cross-dossier contradiction mining
continuous summarization
automatic merge suggestions
multi-tenant enterprise RBAC
Do not build UI first. Canonical model/API must be stable before choosing projection/UI.

12. Definition of MVP Architecture Done

[ ] canonical core independent
[ ] Postgres as source of truth
[ ] attachments separated
[ ] projection adapters replaceable
[ ] vendor IDs external only
[ ] Writer read-only
[ ] Researcher working-write
[ ] Curator link-only
[ ] Source Watch event-only path
[ ] timeline first-class
[ ] conflicts retained
[ ] historical claims retained
[ ] merge transactional
[ ] optimistic concurrency
[ ] audit required
[ ] export/import possible
[ ] projection can be rebuilt
[ ] MVP runs without Trilium/OpenCTI/Aleph
Следующий и последний документ серии: `AI_dossier_10_план_реализации_MVP.html` — coding plan по фазам, структуре репозитория, миграциям, тестам, projection spike и Definition of Dossier MVP Done.