EXPERIMENT / 10 OF 10

ПЛАН РЕАЛИЗАЦИИ MVP

Финальный документ серии Experiment. Цель — собрать минимальный, но строгий экспериментальный контур вокруг canonical engine-neutral core, где дизайн эксперимента, запуск, артефакты, результаты, воспроизводимость, policy и аудит принадлежат нашей системе, а внешние движки подключаются только через адаптеры.

PRINCIPLE

Core first

MVP должен работать даже без внешнего experiment tracking/orchestration backend.

SERVER2

Qwen priority

Тяжёлые experiment jobs ограничиваются очередями и concurrency, чтобы не вытеснять Qwen 30B.

REPRODUCIBLE

Artifact complete

Каждый publishable результат должен иметь входы, окружение, seed/config, артефакты и audit trail.

NO FAKE DATA

Benchmark later

Реальные p50/p95 и resource impact фиксируются только после запуска на server2.

01 / REPOSITORY

Предлагаемый repo layout

experiment/
├─ app/
│  ├─ domain/
│  │  ├─ experiment.py
│  │  ├─ design.py
│  │  ├─ run.py
│  │  ├─ artifact.py
│  │  ├─ result.py
│  │  ├─ validity.py
│  │  └─ verdict.py
│  ├─ services/
│  │  ├─ design_service.py
│  │  ├─ run_service.py
│  │  ├─ artifact_service.py
│  │  ├─ result_service.py
│  │  ├─ reproducibility_service.py
│  │  └─ policy_service.py
│  ├─ policy/
│  │  ├─ design_freeze.py
│  │  ├─ stop_rules.py
│  │  ├─ validity_rules.py
│  │  └─ publication_rules.py
│  ├─ adapters/
│  │  ├─ tracking/
│  │  ├─ execution/
│  │  ├─ storage/
│  │  └─ statistics/
│  ├─ api/
│  │  ├─ rest/
│  │  └─ mcp/
│  ├─ workers/
│  │  ├─ execution_worker.py
│  │  ├─ analysis_worker.py
│  │  └─ artifact_worker.py
│  └─ integrations/
│     ├─ investigator.py
│     ├─ researcher.py
│     ├─ skeptic.py
│     └─ dossier.py
├─ migrations/
├─ tests/
│  ├─ unit/
│  ├─ integration/
│  ├─ golden/
│  ├─ security/
│  └─ recovery/
├─ benchmark/
│  ├─ cases/
│  ├─ harness/
│  ├─ runbooks/
│  └─ reports/
└─ docs/
   ├─ adr/
   ├─ api/
   └─ operations/
Граница: никакой внешний tracker/orchestrator не должен быть source of truth для experiment lifecycle, canonical IDs или final interpretation.
02 / DATABASE

Миграции и canonical store

MigrationОбъектыКритический инвариант
001_coreexperiments, scopes, design_revisionscanonical IDs и revision history принадлежат core
002_hypothesishypotheses, variables, interventions, controlsdesign changes versioned, no silent overwrite
003_runsruns, run_attempts, stop_eventsrun связан с frozen design revision
004_artifactsartifacts, checksums, manifests, provenancechecksum + immutable provenance
005_resultsmetrics, observations, statistical_resultsraw result отделён от interpretation
006_validityassumptions, threats, validity_findingsknown validity issue не теряется
007_auditaudit_events, permission_events, policy_decisionsclosure без audit невозможен
008_integrationsexternal_refs, dossier_links, investigator_linksexternal IDs metadata only
03 / IMPLEMENTATION PHASES

Порядок реализации

Phase A — Canonical core

Schema, IDs, revisions, state machine, permissions, audit.

Phase B — Design policy

Hypothesis, variables, controls, intervention, success/failure criteria, design freeze.

Phase C — Run lifecycle

Queue, worker contract, retries, cancellation, stop rules, attempt history.

Phase D — Artifacts/results

Manifest, checksums, immutable result refs, environment capture.

Phase E — API/MCP

Typed contracts, optimistic concurrency, scoped permissions, idempotency.

Phase F — Integrations

Investigator requests experiments; Skeptic reviews causal/result claims; Dossier stores linked context.

Phase G — Engines

Adapters only after core semantics and golden tests exist.

Phase H — Shadow rollout

No automated publication or causal closure until benchmark + ADR.

04 / REUSE-FIRST SPIKES

Spikes перед ADR

Candidate classЧто проверяемРешение
Experiment trackingself-hosted, artifact model, local storage, API quality, export, licenseREUSE / ADAPT / BUILD
Execution/orchestrationlocal worker model, retry semantics, cancellation, resource controlsREUSE / ADAPT / BUILD
Statistical toolingdeterminism, seeds, result serialization, assumptions, Python fitadapter only
Qwen 30Bstructured design assistance, variable extraction, critique, summaryassistant role only
Qwen MAY:
- propose experiment design candidates
- extract variables and constraints
- suggest confounders / validity threats
- summarize run outputs
- draft ExperimentRequest / ResearchRequest

Qwen MUST NOT:
- invent measurements
- overwrite raw results
- manufacture statistical significance
- decide final validity/verdict alone
- bypass design freeze or stop policy
05 / TEST STRATEGY

Security, failure и golden gates

ZERO-TOLERANCE GATES

unauthorized design mutation                 = 0
unauthorized run/result mutation             = 0
stale run accepted after design revision     = 0
artifact provenance loss                     = 0
checksum mismatch silently accepted          = 0
fabricated statistical confidence            = 0
hidden failed attempt                         = 0
cross-dossier scope leakage                  = 0
auditless closure                            = 0
Qwen-generated result treated as measurement = 0

Golden design cases

wrong control, missing confounder, impossible success criterion, version mismatch, leakage.

Execution failures

worker crash, timeout, partial artifact upload, duplicate retry, cancellation race.

Security attacks

prompt injection in inputs, forged ExperimentResult, tampered artifact, privilege escalation.

Recovery

restart queue, restore DB, reconcile orphaned runs, verify artifact integrity.

06 / SERVER2 BENCHMARK

Practical benchmark обязателен до production ADR

На server2 нужно отдельно измерить влияние experiment workloads на основной Qwen 30B workload. До этого документация фиксирует только harness и критерии, но не реальные цифры.

MEASURE ON SERVER2
- run queue latency
- worker startup latency
- artifact write/read latency
- analysis job duration
- CPU / RAM / disk IO
- peak concurrent jobs
- p50 / p95 API latency under load
- Qwen 30B latency impact
- failure/retry amplification
- artifact storage growth
- recovery time after worker/process failure
Если измерение не выполнено на server2, поле результата должно быть NOT_MEASURED, а не оценкой «на глаз».
07 / ADR + ROLLOUT

От spike к решению

1. Run golden benchmark
2. Run security/failure suite
3. Run server2 resource benchmark
4. Compare candidates
5. Write ADR per component:
   - REUSE
   - ADAPT
   - BUILD
6. Lock canonical interfaces
7. Start SHADOW mode
8. Human review all publishable outputs
9. Enable scoped production use only after gates pass
StageAllowedForbidden
DEVsynthetic runs, local artifactsproduction claims
SHADOWreal requests mirrored, human inspectionautomatic causal closure
PILOTscoped users, controlled run typesunreviewed external publication
MVP PRODapproved run classes + full auditpolicy bypass
08 / DEFINITION OF DONE

Experiment MVP считается готовым, когда…

[ ] canonical schema + migrations shipped
[ ] experiment/design/run state machines covered by tests
[ ] design freeze + revision invalidation enforced
[ ] run queue + bounded concurrency operational
[ ] immutable artifact manifests + checksums operational
[ ] raw measurements separated from interpretation
[ ] reproducibility metadata captured
[ ] API/MCP permissions and optimistic concurrency enforced
[ ] Investigator integration works through explicit ExperimentRequest
[ ] Skeptic can review experiment-backed claims
[ ] Dossier stores linked experiment context without becoming execution source of truth
[ ] security/failure zero-tolerance gates pass
[ ] real server2 benchmark completed
[ ] ADR written for each reused/adapted component
[ ] shadow mode completed without provenance/audit violations
[ ] operations runbook + backup/restore verified
[ ] no permanent-RAG bypass exists
[ ] Qwen 30B remains primary workload on server2
Series status: после выполнения этого плана серия Experiment закрывается на уровне проектирования MVP. Следующий модуль: Orchestration.
09 / HANDOFF

Что передаётся в Orchestration

Orchestration не должна заново изобретать domain policy модулей. Её задача — безопасно координировать Writer, Researcher, Curator, Skeptic, Dossier, Source Watch, Investigator и Experiment через их публичные API/MCP контракты, сохраняя ownership данных и решений внутри соответствующих модулей.

NEXT MODULE: ORCHESTRATION

Core rule:
Orchestration coordinates work.
It does not become the canonical owner of domain truth.