Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 25 additions & 15 deletions MODULE.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,22 @@ druggability dossier for one protein target and writes it as a single JSON file
that validates against `schemas/output.schema.json`, with a side-panel
interpretability object at `output.interpretability`.

## The one command
## The command

```bash
python -m simulation run --input input.json --output output.json
python -m simulation run --mode live|replay --input input.json --output output.json
```

Copy-pasteable example against the shipped example request:

```bash
# from the station root (managed/druggability-dossier/), with the env from below active
micromamba run -n druggability-simulation \
python -m simulation run --input examples/input.json --output /tmp/dossier.json
python -m simulation run --mode replay \
--input examples/input.json --output /tmp/dossier.json
```

`--input` and `--output` are both required paths. `--input` must satisfy
`--mode`, `--input`, and `--output` are required. `--input` must satisfy
`schemas/input.schema.json` (one required field, `uniprot_accession`).

## Exit codes
Expand All @@ -28,8 +29,8 @@ micromamba run -n druggability-simulation \
| --- | --- |
| `0` | success — dossier written, and BOTH the output schema and the interpretability schema validated |
| `2` | invalid input — request missing/failing `schemas/input.schema.json`; **nothing is written** |
| `3` | dossier production failed — the managed agent could not be invoked (see below); **nothing is written** |
| `4` | validation failed — the dossier was written to `--output` for inspection, but it (or its interpretability object) did not validate |
| `3` | dossier production failed — a `simulation.execution-error.v1` terminal object is written with the exact reason code |
| `4` | provider/replay output was invalid — a `simulation.execution-error.v1` terminal object is written with `reasonCode: INVALID_OUTPUT` instead of publishing the invalid dossier |
| `1` | usage error |

Any nonzero code is a failure. Exit `0` is returned only when the dossier and its
Expand Down Expand Up @@ -85,16 +86,26 @@ Both `simulation/requirements.txt` (exact versions) and

## How the dossier is produced (and what a live run needs)

`run_pipeline` in `simulation/pipeline.py` invokes the **Claude Managed Agent**
that is this station — there is no pure-Python re-run of the science. It drives
the documented headless route (`bun run console druggability-dossier -- --once
"<task>"`, README step 3 / `scripts/console.ts`), which runs the deployed agent,
`--mode live` invokes the **existing Claude Managed Agent** that is this station;
there is no pure-Python re-run of the science. Set `LABRADOR_RUNTIME_ROOT` to the
full LABrador checkout that already contains the managed-agent runtime and an
existing deployment. The split station drives that checkout's documented
headless route (`bun scripts/console.ts small-molecule-tractability-review --
--once "<task>"`), which runs the deployed agent,
answers any custom-tool round-trips in-process, prints the agent's final reply
(the dossier JSON) to stdout, and logs to stderr; the module then parses that
JSON. A live run therefore needs `ANTHROPIC_API_KEY`, network access, `bun` on
PATH, and the agent to have been deployed (`manifest.deployment.agent_id` set).
When any of those is absent, `run_pipeline` raises a typed error and the command
fails loudly (exit `3`) rather than hanging or fabricating a dossier.
fails loudly (exit `3`) rather than hanging, deploying anything, or falling
back to replay. Stable terminal codes distinguish runtime, deployment,
credential, dependency, timeout, provider, and invalid-output failures. The
managed-provider session receives a 90-minute limit; the orchestrator owns the
90-minute node timeout.

`--mode replay` uses only the bundled real-dossier cache. Cache hits are stamped
`CACHED_DOSSIER`; misses return an honest `insufficient_evidence` dossier with
no invented scientific values.

The **schemas, examples, and interpretability logic are self-contained** and need
none of that: they run offline against the checked-in `examples/` and fixtures,
Expand All @@ -106,9 +117,8 @@ which is what `simulation/test_module.py` exercises.
micromamba run -n druggability python simulation/test_module.py
```

Offline, no paid calls: it monkeypatches `run_pipeline` with a recorded real
dossier (`examples/output.json`) to check the end-to-end contract (exit 0, output
written, stdout empty, output validates), checks that malformed input and a
raising pipeline both fail loudly with nothing written, and checks that
Offline, no paid calls: it runs replay against the bundled real dossier and
checks the end-to-end contract (exit 0, output written, stdout empty, output
validates), checks malformed input and exact live terminal errors, and checks that
`build_interpretability` validates against `schemas/interpretability.schema.json`
for the example dossier and both integration fixtures.
32 changes: 29 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,40 @@ Additional skills support this core pipeline, including `falsification-sweep`

## Input / output contract

The input and output are JSON. The formal JSON Schemas live under `schema/`:
The input and output are JSON. The formal JSON Schemas live under `schemas/`:

- `schema/input.schema.json` — the request contract.
- `schema/output.schema.json` — the dossier contract.
- `schemas/input.schema.json` — the request contract.
- `schemas/output.schema.json` — the dossier contract.

The `input` block is echoed back verbatim on every run and is never inferred.
See `CLAUDE.md` for the full field-by-field contract and operating rules.

## Run it

Choose the mode explicitly; live mode never falls back to replay:

```bash
# Deterministic bundled cache; no provider calls.
python -m simulation run --mode replay \
--input examples/input.json --output /tmp/dossier.json

# Existing Paperclip/Proto/Modal-backed managed agent. This does not deploy it.
LABRADOR_RUNTIME_ROOT=/path/to/LABrador \
python -m simulation run --mode live \
--input examples/input.json --output /tmp/dossier.json
```

A failed live run exits nonzero and writes a small
`simulation.execution-error.v1` object with `status: CANNOT_COMPLETE` and an
exact `reasonCode`. A replay cache hit remains labelled `CACHED_DOSSIER`; it is
never reported as live.

Every successful dossier is also validated against the exact shared
interpretability schema vendored from `platform-contracts`; its source commit
and SHA-256 are recorded in `schemas/contract.lock.json`. Invalid provider
output becomes terminal `CANNOT_COMPLETE / INVALID_OUTPUT` rather than being
published as a scientific dossier.

## Not a substitute for experiment

This station reports computational and retrieved evidence about small-molecule
Expand Down
10 changes: 10 additions & 0 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@
"invocation": "outcome",
"session_policy": "fresh",
"max_iterations": 3,
"local_cli": {
"command": "python -m simulation run --mode live|replay --input <path> --output <path>",
"live_runtime_root_env": "LABRADOR_RUNTIME_ROOT",
"managed_agent_names": [
"small-molecule-tractability-review",
"druggability-dossier"
],
"deploys_agent": false,
"orchestrator_timeout_seconds": 5400
},
"mcp_servers": [],
"runtime_notes": [
"Custom-tool handlers run in the calling process, not the sandbox (lib/claude-managed-agent.ts consumeUntilEndTurn -> executeCustomTool). That is what lets this agent reach the paperclip binary and the fpocket/mdpocket conda stack, neither of which the sandbox can install.",
Expand Down
11 changes: 9 additions & 2 deletions schemas/README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
# Simulation-station JSON Schemas

The machine-readable contract for the simulation (druggability-dossier) station.
Three files, all [JSON Schema draft 2020-12](https://json-schema.org/):
The machine-readable contract for the simulation (druggability-dossier) station:
three [JSON Schema draft 2020-12](https://json-schema.org/) documents plus one
source lock.

| file | what it governs |
| --- | --- |
| `input.schema.json` | the **request** a caller sends the station |
| `output.schema.json` | the **dossier** the station returns |
| `interpretability.schema.json` | the **`output.interpretability`** object — the LABrador shared interpretability contract (v1.0.0) |
| `contract.lock.json` | exact `platform-contracts` source commit, path, and SHA-256 for the vendored interpretability schema |

## The interpretability contract (required)

Expand All @@ -28,6 +30,11 @@ dossier — no recomputation, no fabrication; unknowns stay `null` and earn a
`basis` OBSERVED|INFERRED|MODELED|SYNTHETIC; `direction` positive|negative|neutral|mixed|unknown;
`grade` HIGH|MODERATE|LOW|UNSUPPORTED; `severity` INFO|WARNING|ERROR.

This repository vendors the contract byte-for-byte from
`REagent-LABrador/platform-contracts` commit
`755499b42ab65d3b01f959b11624dd4e61bdd561`. The expected SHA-256 is recorded
in `contract.lock.json` and enforced by the offline module tests.

## What these are, and what they are not

These schemas enforce **shape, types, and vocabularies** — the structural
Expand Down
11 changes: 11 additions & 0 deletions schemas/contract.lock.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"schemaVersion": "labrador.contract-lock.v1",
"sourceRepository": "https://github.com/REagent-LABrador/platform-contracts",
"sourceCommit": "755499b42ab65d3b01f959b11624dd4e61bdd561",
"contracts": {
"interpretability.schema.json": {
"sourcePath": "schemas/interpretability.schema.json",
"sha256": "ac7b27908688851b4fc3de5e3d31642a6e9d4422b422f57161f2c9ab42c3d6bb"
}
}
}
Loading