proef 0.2.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- proef/__init__.py +25 -0
- proef/acquisition.py +244 -0
- proef/ad.py +159 -0
- proef/adapters/__init__.py +0 -0
- proef/adapters/admet.py +196 -0
- proef/adapters/bio/__init__.py +0 -0
- proef/adapters/bio/rdkit_ops.py +52 -0
- proef/adapters/bio/safety_rules.json +146 -0
- proef/adapters/bio/seq_alerts.py +79 -0
- proef/adapters/bio/structure_score.py +85 -0
- proef/adapters/bio/tox_alerts.py +99 -0
- proef/adapters/data/__init__.py +0 -0
- proef/adapters/data/admet.py +62 -0
- proef/adapters/data/chembl.py +110 -0
- proef/adapters/data/frozen/admet/MANIFEST.json +48 -0
- proef/adapters/data/frozen/admet/bbb_martins/test.csv +407 -0
- proef/adapters/data/frozen/admet/bbb_martins/train_val.csv +1625 -0
- proef/adapters/data/frozen/admet/caco2_wang/test.csv +183 -0
- proef/adapters/data/frozen/admet/caco2_wang/train_val.csv +729 -0
- proef/adapters/data/frozen/admet/hia_hou/test.csv +118 -0
- proef/adapters/data/frozen/admet/hia_hou/train_val.csv +462 -0
- proef/adapters/data/moleculenet.py +60 -0
- proef/adapters/databases/__init__.py +0 -0
- proef/adapters/databases/chembl_gates.py +121 -0
- proef/adapters/databases/chembl_lookup.py +35 -0
- proef/adapters/databases/open_targets.py +102 -0
- proef/adapters/databases/pubmed.py +94 -0
- proef/adapters/devices/__init__.py +0 -0
- proef/adapters/devices/ezo_ph.py +251 -0
- proef/adapters/devices/hcs_microscope.py +143 -0
- proef/adapters/devices/lcms.py +123 -0
- proef/adapters/devices/scheduler.py +84 -0
- proef/adapters/devices/sila2.py +134 -0
- proef/adapters/genomics/alphagenome.py +146 -0
- proef/adapters/lab/__init__.py +0 -0
- proef/adapters/lab/bioprocess.py +32 -0
- proef/adapters/lab/devices.py +170 -0
- proef/adapters/lab/imaging.py +226 -0
- proef/adapters/lab/mhs_driver.py +124 -0
- proef/adapters/lab/opentrons.py +222 -0
- proef/adapters/lab/ot2_sim.py +174 -0
- proef/adapters/lab/plate_reader_share.py +108 -0
- proef/adapters/lab/protein_design.py +199 -0
- proef/adapters/lab/recording.py +119 -0
- proef/adapters/lab/replay.py +107 -0
- proef/adapters/lab/simulator.py +282 -0
- proef/adapters/lab/synthesis.py +92 -0
- proef/adapters/models/__init__.py +0 -0
- proef/adapters/models/anthropic_provider.py +157 -0
- proef/adapters/models/assayloop_ranker.py +67 -0
- proef/adapters/models/from_env.py +93 -0
- proef/adapters/models/gp_policy.py +93 -0
- proef/adapters/models/gp_policy_gp.py +36 -0
- proef/adapters/models/llm_policy.py +187 -0
- proef/adapters/models/openai_compat.py +150 -0
- proef/adapters/models/sklearn_policy.py +65 -0
- proef/adapters/retrosynthesis.py +247 -0
- proef/adapters/sandbox/__init__.py +20 -0
- proef/adapters/sandbox/agentenv.py +145 -0
- proef/adapters/sandbox/docker.py +217 -0
- proef/adapters/sandbox/local.py +164 -0
- proef/adapters/sandbox/opensandbox.py +122 -0
- proef/adapters/store/__init__.py +0 -0
- proef/adapters/store/sqlite.py +207 -0
- proef/adaptive.py +108 -0
- proef/advisory.py +76 -0
- proef/analysis_profiles/__init__.py +8 -0
- proef/analysis_profiles/measurements.py +266 -0
- proef/analysis_profiles/plate_assay.py +316 -0
- proef/analysis_report.py +195 -0
- proef/analysis_store.py +183 -0
- proef/anchor.py +154 -0
- proef/api/app.py +107 -0
- proef/api/launch.py +170 -0
- proef/api/v1/__init__.py +29 -0
- proef/api/v1/analyses.py +367 -0
- proef/api/v1/campaigns.py +802 -0
- proef/api/v1/deps.py +10 -0
- proef/api/v1/evals.py +16 -0
- proef/api/v1/evidence.py +132 -0
- proef/api/v1/governance.py +35 -0
- proef/api/v1/inbox.py +119 -0
- proef/api/v1/lab.py +110 -0
- proef/api/v1/pauses.py +77 -0
- proef/api/v1/programs.py +397 -0
- proef/api/v1/results.py +147 -0
- proef/api/v1/schemas.py +932 -0
- proef/api/v1/system.py +79 -0
- proef/api/v1/trees.py +216 -0
- proef/api/wizard_sessions.py +253 -0
- proef/approvals.py +102 -0
- proef/assays/__init__.py +15 -0
- proef/assays/dls.py +114 -0
- proef/assays/dsf.py +81 -0
- proef/assays/elisa.py +58 -0
- proef/assays/properties.py +65 -0
- proef/assays/simulate.py +157 -0
- proef/audit.py +152 -0
- proef/autoloop.py +1620 -0
- proef/benchmark.py +442 -0
- proef/campaign_fsm.py +151 -0
- proef/citations.py +141 -0
- proef/cli.py +1249 -0
- proef/connect.py +74 -0
- proef/core/__init__.py +0 -0
- proef/core/contracts/__init__.py +35 -0
- proef/core/contracts/analysis.py +100 -0
- proef/core/contracts/models.py +395 -0
- proef/core/device_card.py +125 -0
- proef/core/hypothesis.py +720 -0
- proef/core/interfaces.py +164 -0
- proef/core/registry.py +123 -0
- proef/core/safety.py +324 -0
- proef/core/workflow.py +159 -0
- proef/critic.py +62 -0
- proef/demo.py +164 -0
- proef/derivation.py +128 -0
- proef/diary.py +301 -0
- proef/eln.py +87 -0
- proef/evals/__init__.py +1 -0
- proef/evals/hallucination.py +86 -0
- proef/evals/harness.py +358 -0
- proef/evals/orchestration.py +254 -0
- proef/evals/tasks.py +1010 -0
- proef/evals/toolcalls.py +425 -0
- proef/experiment.py +172 -0
- proef/experiment_analysis.py +114 -0
- proef/experiments/__init__.py +0 -0
- proef/experiments/grounding_exp.py +689 -0
- proef/figures.py +218 -0
- proef/fitting.py +309 -0
- proef/fixtures.py +140 -0
- proef/flywheel.py +125 -0
- proef/followup.py +126 -0
- proef/governance.py +290 -0
- proef/groundedness.py +361 -0
- proef/grounding.py +202 -0
- proef/hypothesis_agent.py +369 -0
- proef/ingest.py +157 -0
- proef/instruments.json +173 -0
- proef/interpret.py +95 -0
- proef/kinetic.py +102 -0
- proef/labread/__init__.py +45 -0
- proef/labread/analysis.py +428 -0
- proef/labread/common.py +153 -0
- proef/labread/formats.py +190 -0
- proef/labread/layout.py +168 -0
- proef/labread/pubchem.py +179 -0
- proef/labselect.py +431 -0
- proef/materials.py +140 -0
- proef/mcp_instrument.py +396 -0
- proef/mcp_server.py +283 -0
- proef/modality.py +111 -0
- proef/model_guard.py +245 -0
- proef/output_blocks.py +183 -0
- proef/paths.py +32 -0
- proef/physfail.py +55 -0
- proef/plan.py +160 -0
- proef/plots.py +123 -0
- proef/predictors.py +217 -0
- proef/probes.py +79 -0
- proef/problem_tree.py +581 -0
- proef/program.py +308 -0
- proef/protocol_design.py +42 -0
- proef/proxy.py +78 -0
- proef/readiness.py +259 -0
- proef/reliability.py +49 -0
- proef/report.py +117 -0
- proef/reproduce.py +310 -0
- proef/reviewer.py +254 -0
- proef/sandbox_session.py +247 -0
- proef/sandboxd.py +109 -0
- proef/scaffold.py +195 -0
- proef/series.py +327 -0
- proef/skills.py +203 -0
- proef/sweep.py +83 -0
- proef/taste.py +177 -0
- proef/templates/confirmatory-followup.json +34 -0
- proef/templates/dose-response-screen.json +39 -0
- proef/templates/sar-exploration.json +38 -0
- proef/templates.py +124 -0
- proef/toolkit.py +433 -0
- proef/toolloop.py +133 -0
- proef/tools.py +441 -0
- proef/tpp.py +185 -0
- proef/views/__init__.py +14 -0
- proef/views/counts.py +102 -0
- proef/views/experiment.py +154 -0
- proef/views/ids.py +49 -0
- proef/views/narrative.py +294 -0
- proef/views/pipeline.py +370 -0
- proef/vision.py +165 -0
- proef/watch.py +790 -0
- proef/wizard_chain.py +25 -0
- proef/wizard_store.py +373 -0
- proef-0.2.0.dist-info/METADATA +662 -0
- proef-0.2.0.dist-info/RECORD +200 -0
- proef-0.2.0.dist-info/WHEEL +4 -0
- proef-0.2.0.dist-info/entry_points.txt +14 -0
- proef-0.2.0.dist-info/licenses/LICENSE +202 -0
proef/connect.py
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"""proef connect — device discovery for scientists who shouldn't know "adapter".
|
|
2
|
+
|
|
3
|
+
`proef connect scan <dir>` inspects a folder (e.g. a network share a plate reader
|
|
4
|
+
auto-exports to), detects formats with the same engine as `proef read`, and prints
|
|
5
|
+
a ready-to-use configuration. `proef connect robot <ip>` probes an Opentrons
|
|
6
|
+
robot's HTTP API. No vocabulary required: the tool names the device it found.
|
|
7
|
+
"""
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
from typing import Any
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def scan_share(directory: str | Path, max_files: int = 50) -> dict[str, Any]:
|
|
15
|
+
"""Detect what instruments are writing into a share/outbox."""
|
|
16
|
+
from proef.labread import detect_format
|
|
17
|
+
|
|
18
|
+
d = Path(directory)
|
|
19
|
+
if not d.is_dir():
|
|
20
|
+
raise FileNotFoundError(f"not a directory: {d}")
|
|
21
|
+
found: dict[str, list[str]] = {}
|
|
22
|
+
files = [f for f in sorted(d.iterdir()) if f.is_file()][: max_files]
|
|
23
|
+
for f in files:
|
|
24
|
+
fmt = detect_format(f)
|
|
25
|
+
if fmt != "unknown":
|
|
26
|
+
found.setdefault(fmt, []).append(f.name)
|
|
27
|
+
suggestions = []
|
|
28
|
+
if found.get("long") or found.get("grid") or found.get("xlsx"):
|
|
29
|
+
suggestions.append({
|
|
30
|
+
"device": "plate reader (auto-exporting to this share)",
|
|
31
|
+
"adapter": "PlateReaderShare",
|
|
32
|
+
"usage": f"PlateReaderShare(share_dir={str(d)!r}) "
|
|
33
|
+
"— or just: proef read <file>, proef watch <dir>"})
|
|
34
|
+
if found.get("npy"):
|
|
35
|
+
suggestions.append({
|
|
36
|
+
"device": "Proef imaging evidence",
|
|
37
|
+
"adapter": "ImagingSimulatorLab",
|
|
38
|
+
"usage": "read via read_plate(<file>.npy) or proef read"})
|
|
39
|
+
if not suggestions:
|
|
40
|
+
suggestions.append({
|
|
41
|
+
"device": "nothing recognized yet",
|
|
42
|
+
"adapter": "SimulatorLab",
|
|
43
|
+
"usage": "start with the virtual lab: proef demo"})
|
|
44
|
+
return {"directory": str(d), "scanned": len(files), "formats": found,
|
|
45
|
+
"suggestions": suggestions}
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def probe_robot(ip: str, port: int = 31950, timeout: int = 5) -> dict[str, Any]:
|
|
49
|
+
"""Check an Opentrons robot is reachable and identify it."""
|
|
50
|
+
import json
|
|
51
|
+
import urllib.request
|
|
52
|
+
|
|
53
|
+
base = ip if ip.startswith("http") else f"http://{ip}:{port}"
|
|
54
|
+
try:
|
|
55
|
+
with urllib.request.urlopen(f"{base.rstrip('/')}/health", timeout=timeout) as r:
|
|
56
|
+
info = json.loads(r.read())
|
|
57
|
+
return {"reachable": True, "name": info.get("name"),
|
|
58
|
+
"api_version": info.get("apiVersion"),
|
|
59
|
+
"adapter": "OpentronsLab",
|
|
60
|
+
"usage": f'OpentronsLab(base_url="{base}") — pair with '
|
|
61
|
+
"LabGateway(SafetyEngine)"}
|
|
62
|
+
except Exception as exc:
|
|
63
|
+
return {"reachable": False, "error": str(exc)[:120], "base_url": base}
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def format_scan(result: dict[str, Any]) -> str:
|
|
67
|
+
lines = [f"scanned {result['scanned']} files in {result['directory']}"]
|
|
68
|
+
for fmt, names in result["formats"].items():
|
|
69
|
+
lines.append(f" {fmt:6} x{len(names):<3} e.g. {names[0]}")
|
|
70
|
+
lines.append(" →")
|
|
71
|
+
for s in result["suggestions"]:
|
|
72
|
+
lines.append(f" device: {s['device']}")
|
|
73
|
+
lines.append(f" setup: {s['usage']}")
|
|
74
|
+
return "\n".join(lines)
|
proef/core/__init__.py
ADDED
|
File without changes
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"""Proef core contracts."""
|
|
2
|
+
from proef.core.contracts.models import ( # noqa: F401
|
|
3
|
+
Actor,
|
|
4
|
+
ActorKind,
|
|
5
|
+
Artifact,
|
|
6
|
+
ArtifactKind,
|
|
7
|
+
ArtifactRef,
|
|
8
|
+
AssayResult,
|
|
9
|
+
AssayType,
|
|
10
|
+
Envelope,
|
|
11
|
+
EventType,
|
|
12
|
+
GateType,
|
|
13
|
+
InstrumentInfo,
|
|
14
|
+
Measurement,
|
|
15
|
+
MeasurementFlag,
|
|
16
|
+
Priority,
|
|
17
|
+
Proposal,
|
|
18
|
+
ProtocolOp,
|
|
19
|
+
ProtocolStep,
|
|
20
|
+
ProtocolSubmission,
|
|
21
|
+
ProvenanceRecord,
|
|
22
|
+
QCInfo,
|
|
23
|
+
ReagentSpec,
|
|
24
|
+
RunStatus,
|
|
25
|
+
SampleKind,
|
|
26
|
+
SampleSpec,
|
|
27
|
+
StageError,
|
|
28
|
+
StageName,
|
|
29
|
+
StageResult,
|
|
30
|
+
StageStatus,
|
|
31
|
+
StageTask,
|
|
32
|
+
ToolInvocation,
|
|
33
|
+
ToolName,
|
|
34
|
+
ToolResult,
|
|
35
|
+
)
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"""Generic experiment-analysis contracts (modality-neutral).
|
|
2
|
+
|
|
3
|
+
The analysis lifecycle — artifacts, revisions, evidence origin, uncertainty,
|
|
4
|
+
human disposition — is shared across bio/chemical/material work. Domain
|
|
5
|
+
INTERPRETATION (plates, wells, IC50, Z′, controls) lives in analysis
|
|
6
|
+
profiles behind a profile discriminator; these types never require any of
|
|
7
|
+
those concepts.
|
|
8
|
+
"""
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
from enum import Enum
|
|
12
|
+
from typing import Any, Literal
|
|
13
|
+
|
|
14
|
+
from pydantic import BaseModel, Field
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class AnalysisProfile(str, Enum):
|
|
18
|
+
"""Which domain interpretation owns this analysis. New profiles are
|
|
19
|
+
added ONLY when a real second use case validates the shared seam."""
|
|
20
|
+
plate_assay = "plate_assay"
|
|
21
|
+
measurements = "measurements" # a table of values per sample (properties, not dose series)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class EvidenceOrigin(str, Enum):
|
|
25
|
+
"""Where the measured values came from. Stored, propagated to every
|
|
26
|
+
report, never inferred from a filename or UI route."""
|
|
27
|
+
measured = "measured" # instrument export from an identified/declared device
|
|
28
|
+
historical = "historical" # frozen external dataset or paper deposit
|
|
29
|
+
simulated = "simulated" # Proef-generated measurement data
|
|
30
|
+
predicted = "predicted" # model output / proxy metric
|
|
31
|
+
unknown = "unknown" # declared unknown — never guessed
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class AnalysisState(str, Enum):
|
|
35
|
+
"""Explicit persisted lifecycle states. Generic states first;
|
|
36
|
+
profile-specific holds are diagnostics that may hold the session."""
|
|
37
|
+
# generic forward path
|
|
38
|
+
uploaded = "uploaded"
|
|
39
|
+
preview_ready = "preview_ready"
|
|
40
|
+
configured = "configured"
|
|
41
|
+
analyzed = "analyzed"
|
|
42
|
+
reviewed = "reviewed"
|
|
43
|
+
# generic failures
|
|
44
|
+
unreadable = "unreadable" # bytes could not be parsed at all
|
|
45
|
+
needs_input = "needs_input" # a required companion artifact is missing
|
|
46
|
+
analysis_failed = "analysis_failed" # analysis raised on parseable input
|
|
47
|
+
# profile-specific holds (plate assay today)
|
|
48
|
+
needs_mapping = "needs_mapping" # layout required but absent/incomplete
|
|
49
|
+
unsupported_regime = "unsupported_regime" # interpretation refused by regime gate
|
|
50
|
+
qc_hold = "qc_hold" # QC below the profile's floor
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
GENERIC_STATES = {AnalysisState.uploaded, AnalysisState.preview_ready,
|
|
54
|
+
AnalysisState.configured, AnalysisState.analyzed,
|
|
55
|
+
AnalysisState.reviewed, AnalysisState.unreadable,
|
|
56
|
+
AnalysisState.needs_input, AnalysisState.analysis_failed}
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
class DispositionAction(str, Enum):
|
|
60
|
+
"""What a human did with a computed call. Acknowledgement is NOT
|
|
61
|
+
orthogonal experimental confirmation — 'confirmed' stays reserved for
|
|
62
|
+
the campaign confirmation-agreement semantics."""
|
|
63
|
+
acknowledge = "acknowledge"
|
|
64
|
+
comment = "comment"
|
|
65
|
+
override = "override"
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
class HumanDisposition(BaseModel):
|
|
69
|
+
action: DispositionAction
|
|
70
|
+
reason: str = ""
|
|
71
|
+
target: str = "" # sample/call the disposition names, when specific
|
|
72
|
+
actor: str = "scientist"
|
|
73
|
+
at: float = Field(default_factory=lambda: __import__("time").time())
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
class AnalysisArtifact(BaseModel):
|
|
77
|
+
"""A stored file bound by digest. Raw bytes live OUTSIDE the provenance
|
|
78
|
+
chain; the chain holds the sha256."""
|
|
79
|
+
kind: Literal["source", "layout", "result", "report"]
|
|
80
|
+
storage_path: str # generated id path — never the user filename
|
|
81
|
+
original_name: str = "" # sanitized display metadata only
|
|
82
|
+
sha256: str = ""
|
|
83
|
+
size: int = 0
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
class AnalysisDiagnostic(BaseModel):
|
|
87
|
+
severity: Literal["info", "warning", "blocker"]
|
|
88
|
+
code: str # stable machine code, e.g. "no_layout"
|
|
89
|
+
message: str
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
class PreliminaryCall(BaseModel):
|
|
93
|
+
"""A threshold-conditional preliminary verdict on ONE entity of the
|
|
94
|
+
profile's result (compound, specimen, …). Emitted ONLY when the
|
|
95
|
+
scientist registered a threshold; otherwise estimate-only."""
|
|
96
|
+
entity: str
|
|
97
|
+
call: Literal["validated", "invalidated", "inconclusive", "no_call"]
|
|
98
|
+
reason: str = ""
|
|
99
|
+
value: float | None = None
|
|
100
|
+
ci: tuple[float | None, float | None] | None = None
|
|
@@ -0,0 +1,395 @@
|
|
|
1
|
+
"""Proef core contracts — pydantic models for the five integration contracts.
|
|
2
|
+
|
|
3
|
+
Mirrors contracts/v1/*.yaml (OpenAPI drafts). These types cross every block
|
|
4
|
+
boundary; adapters and user code should only exchange these + the interfaces.
|
|
5
|
+
"""
|
|
6
|
+
from __future__ import annotations
|
|
7
|
+
|
|
8
|
+
import time
|
|
9
|
+
import uuid
|
|
10
|
+
from enum import Enum
|
|
11
|
+
from typing import Any, Literal
|
|
12
|
+
|
|
13
|
+
from pydantic import BaseModel, Field
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def new_id() -> str:
|
|
17
|
+
return str(uuid.uuid4())
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def now() -> float:
|
|
21
|
+
return time.time()
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class Envelope(BaseModel):
|
|
25
|
+
"""Common wrapper on every contract message (P5: provenance ref required path)."""
|
|
26
|
+
contract_id: str = Field(default_factory=new_id)
|
|
27
|
+
schema_version: Literal["v1"] = "v1"
|
|
28
|
+
experiment_branch_id: str
|
|
29
|
+
parent_branch_id: str | None = None
|
|
30
|
+
provenance_ref: str | None = None
|
|
31
|
+
created_at: float = Field(default_factory=now)
|
|
32
|
+
trace_id: str | None = None
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class StageName(str, Enum):
|
|
36
|
+
target_id = "target_id"
|
|
37
|
+
hit_generation = "hit_generation"
|
|
38
|
+
lead_optimization = "lead_optimization"
|
|
39
|
+
preclinical = "preclinical"
|
|
40
|
+
trial_design = "trial_design"
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
class GateType(str, Enum):
|
|
44
|
+
approve_candidate_batch = "approve_candidate_batch"
|
|
45
|
+
approve_wetlab_protocol = "approve_wetlab_protocol"
|
|
46
|
+
approve_trial_protocol = "approve_trial_protocol"
|
|
47
|
+
arbitrary_redirect = "arbitrary_redirect"
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
class ArtifactKind(str, Enum):
|
|
51
|
+
target_dossier = "target_dossier"
|
|
52
|
+
molecule = "molecule"
|
|
53
|
+
biologic = "biologic"
|
|
54
|
+
hypothesis = "hypothesis"
|
|
55
|
+
protocol = "protocol"
|
|
56
|
+
assay_result = "assay_result"
|
|
57
|
+
trial_protocol = "trial_protocol"
|
|
58
|
+
report = "report"
|
|
59
|
+
model_output = "model_output"
|
|
60
|
+
raw_telemetry = "raw_telemetry"
|
|
61
|
+
other = "other"
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
class ArtifactRef(BaseModel):
|
|
65
|
+
artifact_id: str = Field(default_factory=new_id)
|
|
66
|
+
kind: ArtifactKind
|
|
67
|
+
uri: str
|
|
68
|
+
sha256: str | None = None
|
|
69
|
+
metadata: dict[str, Any] = Field(default_factory=dict)
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
# ---------------------------------------------------------------- StageTask
|
|
73
|
+
|
|
74
|
+
class StageStatus(str, Enum):
|
|
75
|
+
succeeded = "succeeded"
|
|
76
|
+
failed_retryable = "failed_retryable"
|
|
77
|
+
failed_terminal = "failed_terminal"
|
|
78
|
+
needs_human = "needs_human"
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
class StageError(BaseModel):
|
|
82
|
+
code: str
|
|
83
|
+
message: str
|
|
84
|
+
retryable: bool = False
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
class StageTask(BaseModel):
|
|
88
|
+
"""Orchestration -> Agents. Idempotent via task_id; redelivery is deduped."""
|
|
89
|
+
envelope: Envelope
|
|
90
|
+
task_id: str = Field(default_factory=new_id)
|
|
91
|
+
stage: StageName
|
|
92
|
+
attempt: int = 1
|
|
93
|
+
gate_after: GateType | None = None
|
|
94
|
+
input_artifacts: list[ArtifactRef] = Field(default_factory=list)
|
|
95
|
+
context: dict[str, Any] = Field(default_factory=dict)
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
class Proposal(BaseModel):
|
|
99
|
+
"""A next-round proposal emitted by the analysis stage (active-learning loop)."""
|
|
100
|
+
summary: str
|
|
101
|
+
payload: dict[str, Any] = Field(default_factory=dict)
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
class StageResult(BaseModel):
|
|
105
|
+
"""Agents -> Orchestration."""
|
|
106
|
+
envelope: Envelope
|
|
107
|
+
task_id: str
|
|
108
|
+
status: StageStatus
|
|
109
|
+
output_artifacts: list[ArtifactRef] = Field(default_factory=list)
|
|
110
|
+
next_round_proposals: list[Proposal] = Field(default_factory=list)
|
|
111
|
+
error: StageError | None = None
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
# ------------------------------------------------------------ ToolInvocation
|
|
115
|
+
|
|
116
|
+
class ToolName(str, Enum):
|
|
117
|
+
# Block C — models & knowledge
|
|
118
|
+
fm_predict_structure = "c.fm.predict_structure"
|
|
119
|
+
fm_generate_molecules = "c.fm.generate_molecules"
|
|
120
|
+
fm_predict_property = "c.fm.predict_property"
|
|
121
|
+
fm_predict_admet = "c.fm.predict_admet"
|
|
122
|
+
kb_search_literature = "c.kb.search_literature"
|
|
123
|
+
registry_get_put_candidate = "c.registry.get_put_candidate"
|
|
124
|
+
evals_benchmark_batch = "c.evals.benchmark_batch"
|
|
125
|
+
evals_rank_batch = "c.evals.rank_batch"
|
|
126
|
+
flywheel_submit_example = "c.flywheel.submit_example"
|
|
127
|
+
flywheel_list_model_variants = "c.flywheel.list_model_variants"
|
|
128
|
+
# Block D — lab
|
|
129
|
+
lab_list_capabilities = "d.lab.list_capabilities"
|
|
130
|
+
lab_submit_protocol = "d.lab.submit_protocol"
|
|
131
|
+
lab_get_status = "d.lab.get_status"
|
|
132
|
+
lab_fetch_results = "d.lab.fetch_results"
|
|
133
|
+
lab_cancel = "d.lab.cancel"
|
|
134
|
+
# Block E — simulation & data
|
|
135
|
+
sim_docking = "e.sim.docking"
|
|
136
|
+
sim_md_job = "e.sim.md_job"
|
|
137
|
+
sim_assay_prediction = "e.sim.assay_prediction"
|
|
138
|
+
sim_trial_simulation = "e.sim.trial_simulation"
|
|
139
|
+
data_query_feature_store = "e.data.query_feature_store"
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
class ToolInvocation(BaseModel):
|
|
143
|
+
envelope: Envelope
|
|
144
|
+
invocation_id: str = Field(default_factory=new_id)
|
|
145
|
+
tool: ToolName
|
|
146
|
+
args: dict[str, Any] = Field(default_factory=dict)
|
|
147
|
+
timeout_secs: int = 300
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
class ToolResult(BaseModel):
|
|
151
|
+
envelope: Envelope
|
|
152
|
+
invocation_id: str
|
|
153
|
+
status: Literal["succeeded", "failed", "rejected"]
|
|
154
|
+
output: dict[str, Any] = Field(default_factory=dict)
|
|
155
|
+
model_version: str | None = None
|
|
156
|
+
rejection_reason: str | None = None
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
# --------------------------------------------------------- ProtocolSubmission
|
|
160
|
+
|
|
161
|
+
class AssayType(str, Enum):
|
|
162
|
+
binding = "binding"
|
|
163
|
+
enzymatic = "enzymatic"
|
|
164
|
+
cytotoxicity = "cytotoxicity"
|
|
165
|
+
counterscreen = "counterscreen"
|
|
166
|
+
adme = "adme"
|
|
167
|
+
pcr = "pcr"
|
|
168
|
+
sequencing = "sequencing"
|
|
169
|
+
plate_reader = "plate_reader"
|
|
170
|
+
# materials characterization
|
|
171
|
+
tensile = "tensile"
|
|
172
|
+
dsc = "dsc"
|
|
173
|
+
dls = "dls"
|
|
174
|
+
ftir = "ftir"
|
|
175
|
+
xrd = "xrd"
|
|
176
|
+
density = "density"
|
|
177
|
+
# biologics
|
|
178
|
+
elisa = "elisa"
|
|
179
|
+
dsf = "dsf"
|
|
180
|
+
immunogenicity = "immunogenicity"
|
|
181
|
+
aggregation = "aggregation"
|
|
182
|
+
thermal_stability = "thermal_stability"
|
|
183
|
+
# cell therapy
|
|
184
|
+
potency = "potency"
|
|
185
|
+
sterility = "sterility"
|
|
186
|
+
phenotype_stability = "phenotype_stability"
|
|
187
|
+
# mRNA
|
|
188
|
+
expression = "expression"
|
|
189
|
+
stability = "stability"
|
|
190
|
+
# agrochemical
|
|
191
|
+
organism_dose_response = "organism_dose_response"
|
|
192
|
+
phytotoxicity = "phytotoxicity"
|
|
193
|
+
custom = "custom"
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
def coerce_assay_type(name) -> "AssayType":
|
|
197
|
+
"""Map a free-form assay name (LLM-proposed or metric-derived) onto
|
|
198
|
+
the legal enum; unknown names fall back to 'custom'. Never crash a
|
|
199
|
+
campaign over vocabulary."""
|
|
200
|
+
if isinstance(name, AssayType):
|
|
201
|
+
return name
|
|
202
|
+
n = str(name or "").strip().lower().replace("-", "_").replace(" ", "_")
|
|
203
|
+
if not n:
|
|
204
|
+
return AssayType.custom
|
|
205
|
+
legal = {a.value: a for a in AssayType}
|
|
206
|
+
if n in legal:
|
|
207
|
+
return legal[n]
|
|
208
|
+
for suffix in ("_test", "_assay", "_assays", "_screen", "_measurement"):
|
|
209
|
+
if n.endswith(suffix) and n[:-len(suffix)] in legal:
|
|
210
|
+
return legal[n[:-len(suffix)]]
|
|
211
|
+
for value in sorted(legal, key=len, reverse=True):
|
|
212
|
+
if value != "custom" and (value in n or n in value):
|
|
213
|
+
return legal[value]
|
|
214
|
+
return AssayType.custom
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
class Priority(str, Enum):
|
|
218
|
+
low = "low"
|
|
219
|
+
normal = "normal"
|
|
220
|
+
high = "high"
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
class ProtocolOp(str, Enum):
|
|
224
|
+
dispense = "dispense"
|
|
225
|
+
mix = "mix"
|
|
226
|
+
incubate = "incubate"
|
|
227
|
+
transfer = "transfer"
|
|
228
|
+
measure = "measure"
|
|
229
|
+
centrifuge = "centrifuge"
|
|
230
|
+
heat = "heat"
|
|
231
|
+
plate = "plate"
|
|
232
|
+
sequence = "sequence"
|
|
233
|
+
wait = "wait"
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
class ProtocolStep(BaseModel):
|
|
237
|
+
seq: int = Field(ge=1)
|
|
238
|
+
op: ProtocolOp
|
|
239
|
+
params: dict[str, Any] = Field(default_factory=dict)
|
|
240
|
+
depends_on: list[int] = Field(default_factory=list)
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
class SampleKind(str, Enum):
|
|
244
|
+
compound = "compound"
|
|
245
|
+
protein = "protein"
|
|
246
|
+
cell_line = "cell_line"
|
|
247
|
+
nucleic_acid = "nucleic_acid"
|
|
248
|
+
buffer = "buffer"
|
|
249
|
+
other = "other"
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
class SampleSpec(BaseModel):
|
|
253
|
+
sample_id: str
|
|
254
|
+
kind: SampleKind
|
|
255
|
+
candidate_artifact_id: str | None = None
|
|
256
|
+
concentration: str | None = None
|
|
257
|
+
metadata: dict[str, Any] = Field(default_factory=dict)
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
class ReagentSpec(BaseModel):
|
|
261
|
+
name: str
|
|
262
|
+
amount: str
|
|
263
|
+
lot: str | None = None
|
|
264
|
+
bsl_level: int = Field(default=1, ge=1, le=4)
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
class ProtocolSubmission(BaseModel):
|
|
268
|
+
"""Assay Planning Agent -> Protocol Compiler (Block D). Abstract wet-lab protocol."""
|
|
269
|
+
envelope: Envelope
|
|
270
|
+
protocol_id: str = Field(default_factory=new_id)
|
|
271
|
+
title: str
|
|
272
|
+
assay_type: AssayType
|
|
273
|
+
priority: Priority = Priority.normal
|
|
274
|
+
steps: list[ProtocolStep] = Field(min_length=1)
|
|
275
|
+
samples: list[SampleSpec] = Field(default_factory=list)
|
|
276
|
+
reagents: list[ReagentSpec] = Field(default_factory=list)
|
|
277
|
+
controls: list[str] = Field(default_factory=list)
|
|
278
|
+
constraints: dict[str, Any] = Field(default_factory=dict)
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
# --------------------------------------------------------------- AssayResult
|
|
282
|
+
|
|
283
|
+
class RunStatus(str, Enum):
|
|
284
|
+
completed = "completed"
|
|
285
|
+
partial = "partial"
|
|
286
|
+
failed = "failed"
|
|
287
|
+
cancelled = "cancelled"
|
|
288
|
+
|
|
289
|
+
|
|
290
|
+
class MeasurementFlag(str, Enum):
|
|
291
|
+
out_of_range = "out_of_range"
|
|
292
|
+
below_lod = "below_lod"
|
|
293
|
+
suspect = "suspect"
|
|
294
|
+
control = "control"
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
class Measurement(BaseModel):
|
|
298
|
+
sample_id: str
|
|
299
|
+
well: str | None = None
|
|
300
|
+
assay_type: str
|
|
301
|
+
value: float
|
|
302
|
+
unit: str
|
|
303
|
+
uncertainty: float | None = None
|
|
304
|
+
replicate: int = Field(default=1, ge=1)
|
|
305
|
+
derived_metrics: dict[str, float] = Field(default_factory=dict)
|
|
306
|
+
flags: list[MeasurementFlag] = Field(default_factory=list)
|
|
307
|
+
metadata: dict[str, Any] = Field(default_factory=dict) # adapter-specific evidence
|
|
308
|
+
|
|
309
|
+
|
|
310
|
+
class InstrumentInfo(BaseModel):
|
|
311
|
+
adapter: str # e.g. "simulator", "opentrons"
|
|
312
|
+
instrument_id: str
|
|
313
|
+
raw_output_uri: str | None = None
|
|
314
|
+
|
|
315
|
+
|
|
316
|
+
class QCInfo(BaseModel):
|
|
317
|
+
controls_passed: bool = True
|
|
318
|
+
z_prime: float | None = None # assay window quality (imaging/plate readouts)
|
|
319
|
+
failed_wells: list[str] = Field(default_factory=list)
|
|
320
|
+
notes: str | None = None
|
|
321
|
+
|
|
322
|
+
|
|
323
|
+
class AssayResult(BaseModel):
|
|
324
|
+
"""Telemetry -> Orchestration/Analysis. Normalized results + lineage."""
|
|
325
|
+
envelope: Envelope
|
|
326
|
+
run_id: str = Field(default_factory=new_id)
|
|
327
|
+
protocol_id: str
|
|
328
|
+
instrument: InstrumentInfo
|
|
329
|
+
status: RunStatus
|
|
330
|
+
measurements: list[Measurement] = Field(default_factory=list)
|
|
331
|
+
qc: QCInfo = Field(default_factory=QCInfo)
|
|
332
|
+
|
|
333
|
+
|
|
334
|
+
# ----------------------------------------------------------- ProvenanceRecord
|
|
335
|
+
|
|
336
|
+
class EventType(str, Enum):
|
|
337
|
+
artifact_created = "artifact_created"
|
|
338
|
+
model_invocation = "model_invocation"
|
|
339
|
+
tool_invocation = "tool_invocation"
|
|
340
|
+
lab_run = "lab_run"
|
|
341
|
+
simulation_job = "simulation_job"
|
|
342
|
+
evaluation = "evaluation"
|
|
343
|
+
gate_decision = "gate_decision"
|
|
344
|
+
stage_transition = "stage_transition"
|
|
345
|
+
problem_defined = "problem_defined"
|
|
346
|
+
hypothesis_proposed = "hypothesis_proposed"
|
|
347
|
+
hypotheses_filtered = "hypotheses_filtered"
|
|
348
|
+
experiment_defined = "experiment_defined"
|
|
349
|
+
experiment_readiness_reviewed = "experiment_readiness_reviewed"
|
|
350
|
+
hypothesis_tested = "hypothesis_tested"
|
|
351
|
+
hypothesis_validated = "hypothesis_validated"
|
|
352
|
+
hypothesis_invalidated = "hypothesis_invalidated"
|
|
353
|
+
hypothesis_inconclusive = "hypothesis_inconclusive"
|
|
354
|
+
synthesis_complete = "synthesis_complete"
|
|
355
|
+
sandbox_fork = "sandbox_fork"
|
|
356
|
+
sandbox_snapshot = "sandbox_snapshot"
|
|
357
|
+
sandbox_create = "sandbox_create"
|
|
358
|
+
sandbox_exec = "sandbox_exec"
|
|
359
|
+
sandbox_destroy = "sandbox_destroy"
|
|
360
|
+
|
|
361
|
+
|
|
362
|
+
class ActorKind(str, Enum):
|
|
363
|
+
agent = "agent"
|
|
364
|
+
human = "human"
|
|
365
|
+
service = "service"
|
|
366
|
+
instrument = "instrument"
|
|
367
|
+
|
|
368
|
+
|
|
369
|
+
class Actor(BaseModel):
|
|
370
|
+
kind: ActorKind
|
|
371
|
+
id: str
|
|
372
|
+
sandbox_id: str | None = None
|
|
373
|
+
model_version: str | None = None
|
|
374
|
+
prompt_ref: str | None = None
|
|
375
|
+
|
|
376
|
+
|
|
377
|
+
class Artifact(BaseModel):
|
|
378
|
+
artifact_id: str
|
|
379
|
+
kind: ArtifactKind
|
|
380
|
+
uri: str
|
|
381
|
+
sha256: str | None = None
|
|
382
|
+
metadata: dict[str, Any] = Field(default_factory=dict)
|
|
383
|
+
|
|
384
|
+
|
|
385
|
+
class ProvenanceRecord(BaseModel):
|
|
386
|
+
"""Everything -> Provenance Store. Append-only, WORM, hash-chained."""
|
|
387
|
+
envelope: Envelope
|
|
388
|
+
record_id: str = Field(default_factory=new_id)
|
|
389
|
+
event_type: EventType
|
|
390
|
+
actor: Actor
|
|
391
|
+
artifact: Artifact | None = None
|
|
392
|
+
inputs: list[Artifact] = Field(default_factory=list)
|
|
393
|
+
decision: dict[str, Any] | None = None
|
|
394
|
+
prev_record_hash: str | None = None
|
|
395
|
+
record_hash: str | None = None
|