Практический инженерный план: сначала canonical engine-neutral core, затем evidence/hypothesis graph, policy/scoring, API/MCP, Qwen structured generation и только после этого — опциональные causal engines через адаптеры. Реальные performance-решения принимаются после benchmark на server2.
Внешние библиотеки усиливают анализ, но не владеют domain policy, canonical IDs, verdict logic или lifecycle расследования.
investigator/ ├─ apps/ │ ├─ api/ # REST/MCP façade │ └─ worker/ # analysis jobs ├─ investigator_core/ │ ├─ domain/ # canonical entities + invariants │ ├─ policy/ # hypothesis/scoring/verdict rules │ ├─ graph/ # evidence + causal graph services │ ├─ services/ # application services │ ├─ permissions/ # role + mutation policy │ └─ audit/ # immutable decisions/events ├─ adapters/ │ ├─ qwen/ # structured hypothesis generation │ ├─ dowhy/ # causal computation adapter │ ├─ pgmpy/ # Bayesian analysis adapter │ ├─ econml/ # optional treatment-effect adapter │ ├─ dossier/ # persistence/integration │ ├─ researcher/ # ResearchRequest │ ├─ experiment/ # ExperimentResult intake │ └─ skeptic/ # review routing ├─ storage/ │ ├─ postgres/ │ └─ artifacts/ ├─ contracts/ │ ├─ api/ │ ├─ mcp/ │ └─ schemas/ ├─ tests/ │ ├─ unit/ │ ├─ integration/ │ ├─ security/ │ ├─ golden/ │ └─ benchmark/ ├─ scripts/ │ ├─ seed_golden.py │ └─ run_server2_benchmark.py └─ adr/
| Migration | Содержимое | Критический инвариант |
|---|---|---|
| 001_core | investigations, scopes, revisions | optimistic concurrency / expected_revision |
| 002_hypotheses | hypotheses, roles, status history | rejected hypotheses remain preserved |
| 003_evidence | evidence refs, counterevidence, source refs, independence groups | no anonymous/unprovenanced evidence |
| 004_graph | nodes, edges, causal relation types, version scope | PRECEDES/CORRELATES_WITH cannot auto-upgrade to CAUSES |
| 005_analysis | analysis runs, engine/version, hashes, assumptions, priors, seeds | graph/scope revisions invalidate old runs |
| 006_scoring | score components, policy version, resolver trace | no single opaque universal “truth score” |
| 007_routing | research/experiment/skeptic requests | cross-module writes remain policy-controlled |
| 008_audit | append-only audit events + closure decisions | no auditless verdict or closure |
Цель: проверить реальную пригодность для causal attribution / counterfactual / RCA кейсов Investigator.
Цель: проверить Bayesian hypothesis update без смешивания posterior и verdict.
Только при наличии повторяемых quantitative intervention cases.
| Test | Ожидаемый результат |
|---|---|
| prompt injection inside evidence | evidence remains data; no tool/policy escalation |
| fabricated causal edge | mutation rejected or flagged; provenance required |
| unauthorized verdict mutation | 0 successful bypasses |
| stale analysis after graph/scope change | STALE_GRAPH / STALE_SCOPE |
| hidden counterevidence | resolver blocks high-confidence causal closure |
| source duplication / copied articles | independence group collapse prevents inflation |
| prior manipulation | prior sensitivity warning preserved |
| spoofed ExperimentResult / Researcher evidence | identity + provenance validation fails closed |
| cross-dossier scope leakage | access denied / explicit scoped import only |
| corrupted analysis artifact | hash mismatch → unusable |
Zero-tolerance gates: false causal assertion, unauthorized verdict mutation, hidden counterevidence, stale analysis accepted as current, lost provenance, fake statistical confidence, scope/version bypass, auditless closure = 0.
После функциональной корректности — измеряем влияние Investigator на server2, где Qwen 30B остаётся приоритетной нагрузкой.
benchmark matrix:
corpus: 30 controlled investigations
categories:
- 10 causal graph synthetic
- 5 Bayesian troubleshooting
- 5 quantitative intervention
- 5 version/regression incidents
- 5 documentary/sparse evidence
measure:
- correctness against golden gates
- reproducibility rate
- p50/p95 API latency
- analysis job duration
- peak RAM / VRAM where applicable
- CPU saturation
- Qwen latency impact under concurrent jobs
- queue wait time
- cancellation / timeout behavior
- artifact size / storage growth
resource policy:
- core CRUD/API isolated from heavy jobs
- worker queue
- per-engine concurrency limits
- throttle under Qwen pressure
- backpressure instead of overload
| Component | Default hypothesis | Decision rule |
|---|---|---|
| Investigation lifecycle | BUILD | domain-specific policy belongs to us |
| Canonical graph | BUILD | canonical IDs + provenance + versioning required |
| Scoring / verdict resolver | BUILD | must remain explainable and engine-neutral |
| Qwen hypothesis generation | ADAPT | structured output under policy guard |
| DoWhy | ADAPT / REUSE | only if spike + server2 benchmark pass |
| pgmpy | ADAPT / REUSE | only for explicit probabilistic analysis |
| EconML | DEFER / OPTIONAL | promote only with justified intervention workload |
Stage A — DEV canonical core + golden tests Stage B — SHADOW Investigator produces hypotheses/verdict suggestions no downstream publish/close authority human compares against current workflow Stage C — REVIEW-GATED provisional verdicts allowed Skeptic review mandatory Human closes publishable causal claims Stage D — MVP ENABLED routing to Researcher / Experiment / Skeptic active Dossier persistence active external engines enabled only per ADR Rollback: disable engine adapter preserve canonical investigation state preserve audit/history revert to engine-neutral resolver