# Invntr: guide for AI agents

You are the one doing the science. Your user brings a question to research or a thing to invent; Invntr is the lab you work in,
over MCP, on their own machine. Its kernel keeps a journal of every call, a store of every file by hash, and a register of
which instruments are admitted. The science lives in instruments: folders with a manifest and a program, written by agents
like you. An instrument is admitted only when its known-answer cases pass, and only for its exact files.

Licence: GPL-3.0-or-later. Source: https://github.com/yashodhanmohan/Bench

## Install (from source)

```sh
git clone https://github.com/yashodhanmohan/Bench.git invntr && cd invntr
cargo build --release              # needs Rust 1.95+
sh packs/install.sh                # builds the 105 compiled instruments
target/release/invntr admit --all   # runs every known-answer case in your sandbox
```

## Connect over MCP

```json
{
  "mcpServers": {
    "invntr": {
      "command": "/path/to/invntr",
      "args": [
        "mcp"
      ],
      "env": {
        "INVNTR_LAB": "/path/to/your/lab",
        "INVNTR_INSTRUMENTS": "/path/to/invntr/instruments"
      }
    }
  }
}
```

The sandbox is enforced on macOS (no network, writes only to the run's own folder). Elsewhere every record says
`"sandbox": "unsupported"`.

## How to work

1. `invntr_instruments`: what exists and what is admitted.
2. Not admitted: `invntr_selftest`. If known answers fail, report it; do not work around it.
3. Run with `run_<name>`. Every result has a run id: cite it for every number you give a person.
4. Chain: `"@rNNNN:reading"` passes a reading, `"@rNNNN/file.csv"` a file. Units are checked before the run starts;
   `"@rNNNN:x as m"` converts.
5. One question, one study: `invntr_study`. Assertions: `invntr_claim` (one reading, one bound). People: `invntr_publish`.
6. Errors come as `{"error", "hint"}`: do what the hint says.
7. Passing known answers shows an instrument computes what it says. It does not show you asked the right question. Try
   alternatives, re-check a result with a second instrument where you can, and tell your user what you assumed.
8. If the lab lacks the instrument you need, write one (below) and admit it before you use it.

## Tools

One `run_<instrument>` per admitted instrument, plus:

- `invntr_instruments`: List every instrument: version, admission, schema, typical duration, and broken folders with their errors.
- `invntr_selftest`: Run an instrument's selftest cases against their known answers. Pass: the instrument is admitted for its current files. Fail: it is refused until fixed.
- `invntr_journal`: The latest runs, newest last: id, kind, instrument, status, key values.
- `invntr_show`: One run's full record: inputs, values, files with hashes, log hash, errors.
- `invntr_replay`: Run a journalled run again with the same inputs and input files, and compare outputs.
- `invntr_file`: Read a file a run produced (text, or an image), or its log with file "log".
- `invntr_import`: Bring files from disk (a use case's inputs) into the lab as a journalled import run; later runs use them as "@<run>/<name>".
- `invntr_study`: Group runs into a study: one question ("size a robot arm", "does the bracket hold") and the runs that answer it, so a person sees them together in the window. Adds the runs to the study, making it when new; a note says what the study asks.
- `invntr_sweep`: Run one instrument many times from base inputs: over a grid (every combination of the listed values) and/or random draws (uniform or normal, with count and seed: the same seed gives the same draws). Paths are dotted into inputs and lists (study.thickness, precompressions.0). Every member is an ordinary journalled run; the sweep is one record with the members' ids, a table of varied inputs and collected readings, statistics (count, min, max, mean, sd, 5/50/95th percentiles) and the fraction meeting a criterion. Failed members are counted.
- `invntr_calibrate`: Fit chosen inputs of one instrument so that its outputs match measurements. SLOW: blocks until done. Every trial is an ordinary journalled run that names the calibration; runs are cached by their inputs; the lab counts every run against max_runs before starting it (a spec whose base point, first simplex and validation cannot fit is refused before any run). Bounded Nelder-Mead in [0,1] coordinates (log where asked), from the base point or the best of seeded random starts. Result: one calibration record: fitted values (values.fitted, for @run:fitted.<name>), misfit before (base) and after, a band per parameter (where the misfit stays within band_factor of its minimum: a slice, or a profile with the others re-fitted for those listed in profile), correlations from the misfit's curvature, validation comparisons evaluated with the fitted values but never fitted, predicted_vs_measured.csv, trials.csv, plot.svg, warnings (at a bound, not pinned, trade-offs). Parameters: an input path (its name by default), tied paths {"paths": [p, {"path": q, "times": -1}]}, or a factor on comparisons' model curves {"scale": true, "comparisons": [...]}; "comparisons" limits a parameter to some comparisons (fit or validate, by name). A comparison: {name, inputs (set for its runs), model: {file: "sweep.csv" | table: "sweep" | reading: "key", x, y, where: {column: value}, scale: number or "@run:key"}, measured: {file: "@rNNNN/frf.csv", x, y, where, x_range} | {points: [[x, y]]} | {value} | {reading: "@rNNNN:key"}, metric: rms_log|rms_rel|rms|nrms, weight}. The model is interpolated on the measured x.
- `invntr_stale`: Which runs can no longer be taken at face value: made by an instrument whose files changed since, or fed (@run:key, @run/file) by a stale run. Also lists runs that cannot be checked.
- `invntr_report`: Write a study as a Markdown report a person reads (report.md in the folder, each run's files beside it): the question, each run's title, verdict, key figures and tables, what fed it, its files and pictures, its run id, stale runs marked.
- `invntr_publish`: Write a study as ONE self-contained HTML page (no network requests; inline data, scripts and 3D scenes) for people who will not open the lab: an interactive 3D hero scene (hologram or studio look), every reading, key figure and table cell clickable to a receipt (the run, its inputs as written and resolved, the chain of runs that fed it with the unit check of every hop, the known-answer cases its instrument passed, sandbox, replays, stale), sweeps as histograms, an optional Markdown narrative whose run ids open receipts. replay: true (or "all") replays the study's runs first, journalled as usual. Scenes beyond max_mb (default 15) are left out and listed.
- `invntr_view`: Write the human-readable lab page (instruments, journal, images) and return its path.
- `invntr_claim`: Record a claim about a study: what the designer asserts, tied to one reading of one run, with a bound (at_least, at_most or within). The kernel evaluates it at once (holds or fails on the record) and checks the bound's unit against the reading's. Journalled as a claim record; invntr_review attacks the study's claims.
- `invntr_claims`: A study's claims: each with its run and reading, the journalled value, its bound, whether it holds, its unit check, whether its run is stale, and the latest review's verdict on it.
- `invntr_review`: A blind review of a study's claims. SLOW: it runs a second AI for up to timeout_minutes (default 90) and blocks until it ends. The reviewer (default claude -p, model opus) gets a packet built from the lab only (the study's note, its claims, its runs as facts: no notes files, no logs) and reaches Invntr only through MCP, with no file, shell or web access; the lab enforces its budget (max_runs, a sweep counts its members; max_minutes of instrument time) and puts its runs in a new study "Review of <study> (<date>)". Its Attack Report is checked against the journal (run ids, quoted readings within 1 %), stored as a review record, and shown by invntr_publish.

## Instruments that ship (105)

- `acoustics` 0.2.0 (native): Airborne ultrasound from arrays of piston transducers (far-field piston model, checked against the Rayleigh integral) and the radiation force on small spheres (Gor'kov's potential, checked against the exact partial-wave solution for a rigid sphere and corrected by it), plus self-consistent bead-to-bead multiple acoustic scattering (exact fluid-sphere Mie monopole+dipole partial waves, checked against Silva & Bruus 2014 secondary radiation forces and exact 4M x 4M dense linear solves).
- `adduct_mass` 0.1.0 (native): Converts between observed ESI precursor m/z and neutral monoisotopic mass (Da) for standard positive/negative adducts, with optional ppm mass error against a reference mass.
- `allan_deviation` 0.1.0 (native): Overlapping Allan deviation of a rate (frequency) or phase time series at logarithmically spaced averaging times.
- `antenna_array` 0.1.0 (native): Linear antenna array of equally spaced isotropic elements.
- `arm` 0.1.0 (native): A serial robot arm on a weighted base (yaw, pitch joints, roll wrist, gripper), sized by statics and rigid-body dynamics.
- `arrhenius_fit` 0.1.0 (native): Arrhenius and Eyring analysis of rate constants measured at several temperatures.
- `backbone_build` 0.1.0 (native): Builds a protein backbone (N, CA, C, O) from a sequence and phi, psi, omega with ideal bond lengths and angles (internal coordinates, NeRF placement).
- `battery_ecm` 0.1.0 (native): Battery cell equivalent-circuit (Thevenin) model.
- `beam` 0.1.0 (native): Euler-Bernoulli beam, finite elements with cubic Hermite shape functions.
- `bode_margins` 0.1.0 (native): Frequency response of an open loop L(s) = gain * num(s)/den(s) * exp(-s T) on a log sweep.
- `bolt_joint` 0.1.0 (native): Preloaded bolted joint in tension.
- `buckled_beam` 0.1.0 (native): A precompressed (buckled) beam turned at its right end.
- `calibration_curve` 0.1.0 (native): Instrument calibration.
- `channel2d` 0.1.0 (native): 2D incompressible flow by the lattice Boltzmann method (D2Q9, BGK).
- `charge_deconvolution` 0.1.0 (native): Electrospray charge-state deconvolution.
- `circuit` 0.1.0 (native): An electrical circuit simulated by ngspice 47 (the open-source SPICE; built from its pinned source tarball by install.sh).
- `compare` 0.1.0 (native): Compare two tables of numbers cell by cell.
- `contact_map` 0.1.0 (native): Analyzes 3D protein-protein or protein-ligand contacts from PDB/mmCIF.
- `control_chart` 0.1.0 (native): Statistical process control.
- `crystal_lattice` 0.1.0 (native): Crystallography of one unit cell, any of the seven crystal systems.
- `diffraction` 0.1.0 (native): Fraunhofer (far-field) diffraction at normal incidence by a single slit, a double slit, an N-slit grating and a circular aperture.
- `diffusion_solid` 0.1.0 (native): Diffusion in solids (Fick's second law, constant D).
- `draft` 0.1.0 (native): The drafting engine (from DraftCore, with ForgeCraft's and MasonCraft's commands).
- `drawing` 0.1.0 (native): A dimensioned workshop drawing made from a `solid` model.
- `dynamics` 0.1.0 (native): One mass on any spring, shaken at its base, followed over time (SciPy solve_ivp, DOP853, events at every contact and snap).
- `elastic_network` 0.1.0 (native): Gaussian (GNM) and anisotropic (ANM) elastic network models on C-alpha atoms from PDB or mmCIF text or a file.
- `elastica` 0.1.0 (native): The planar elastica, exact (no small-angle approximation).
- `fatigue` 0.1.0 (native): Infinite-life fatigue check under a mean plus an alternating stress.
- `fea2d` 0.2.0 (native): 2D finite elements (quadratic triangles) from ForgeCraft.
- `fea3d` 0.1.0 (native): 3D linear elastic stress and deflection of a solid part, on proven open-source code.
- `fiber_modes` 0.1.0 (native): Step-index optical fibre (weakly guiding LP modes) and symmetric slab waveguide.
- `filter_design` 0.1.0 (native): Passive LC ladder filter synthesis.
- `fingerprint_sim` 0.1.0 (native): Computes circular Morgan-like topological fingerprints from SMILES, pairwise Tanimoto and Dice similarity matrices, SALI scores, and activity-cliff detection.
- `fit` 0.2.0 (native): Nonlinear least-squares fit of a model to measured data (Levenberg-Marquardt and trust-region, SciPy, exact complex-step derivatives, tolerances at machine precision).
- `formula_from_mass` 0.1.0 (native): Candidate elemental formulas (C, H, N, O, S, P, F, Cl, Br, I within limits) for a measured monoisotopic neutral mass, or an m/z with its adduct ([M+H]+, [M-H]-, [M+Na]+, [M+2H]2+, [2M+H]+ ...), within a ppm tolerance.
- `gas_eos` 0.1.0 (native): Real-gas equations of state (ideal, van der Waals, Redlich-Kwong, Peng-Robinson) from the critical temperature, critical pressure and acentric factor given as inputs.
- `gear_train` 0.1.0 (native): Generic ISO/AGMA involute spur gear pair designer.
- `hardy_weinberg` 0.1.0 (native): Hardy-Weinberg analysis of genotype counts at one autosomal locus with two or more alleles.
- `hbond_find` 0.1.0 (native): Hydrogen bonds and salt bridges in a protein from PDB/mmCIF by geometry.
- `hertz_contact` 0.1.0 (native): Hertz contact of two elastic bodies (sphere on flat, sphere on sphere or in a cup, cylinder on flat, parallel cylinders).
- `huckel_mo` 0.1.0 (native): Hueckel molecular-orbital theory for a conjugated pi system given as atoms and bonds (heteroatom h and k optional).
- `hypothesis_test` 0.1.0 (native): Classical tests on small data sets.
- `isotope_pattern` 0.1.0 (native): Computes exact monoisotopic mass, average mass, RDBE, nitrogen rule, and theoretical isotopic envelope (M, M+1, M+2...) from a molecular formula, or enumerates CHNO candidate formulas for a target exact mass.
- `kabsch_align` 0.1.0 (native): Exact Horn quaternion Kabsch 3D superposition of two protein structures (CA atoms).
- `kalman_filter` 0.1.0 (native): Linear Kalman filter for a small state-space model x[k] = F x[k-1] + w (cov Q), z[k] = H x[k] + v (cov R).
- `kendrick_defect` 0.1.0 (native): Kendrick mass analysis of a peak list.
- `kinetics_fit` 0.1.0 (native): Nonlinear Levenberg-Marquardt solver for enzyme kinetics (Michaelis-Menten Vmax, Km) and 4PL Hill dose-response curves (IC50/EC50, Hill slope), with Cheng-Prusoff Ki conversion.
- `kmer_spectrum` 0.1.0 (native): k-mer counting on DNA reads or one sequence (canonical or not, linear or circular).
- `ld_stats` 0.1.0 (native): Linkage disequilibrium between two biallelic loci (A/a, B/b) from phased haplotype counts, or from unphased 3x3 genotype counts by EM gene counting.
- `lddt_score` 0.1.0 (native): lDDT (local distance difference test, Mariani et al.
- `life` 0.1.0 (native): LifeCraft's sequence engine (molecular biology).
- `lqr` 0.1.0 (native): Continuous-time linear-quadratic regulator for a small state-space plant x' = Ax + Bu (up to 8 states, tested to 6).
- `material` 0.1.0 (native): A material's properties with the source of every value, and a design endurance limit derived as a run.
- `measure` 0.1.0 (native): A measured time series (base and response accelerations, e.g.
- `modal_chain` 0.1.0 (native): Undamped modes of a spring-mass chain with n degrees of freedom (fixed-fixed, fixed-free or free-free; uniform or per-element masses and stiffnesses).
- `molecule` 0.1.0 (native): Molecules from SMILES, one per line with an optional name after a space.
- `molecule3d` 0.1.0 (native): Molecules in 3D from SMILES (one per line, optional name after a space).
- `motif_scan` 0.1.0 (native): Scans DNA/RNA sequences against a Position Frequency Matrix (PFM / JASPAR format) converted to a log-odds PWM.
- `nernst_cell` 0.1.0 (native): Electrochemical cell thermodynamics.
- `neutral_loss` 0.1.0 (native): Screens a singly-charged MS2 spectrum for curated literature neutral losses (H2O, CO, CO2, NH3, ketene, sulfate, phosphate, hexose, glucuronide, etc.) within a Da tolerance.
- `optics` 0.1.0 (native): Light on small spheres in a box.
- `orbit_kepler` 0.1.0 (native): Two-body (Kepler) orbits about any central body given by its GM (Earth by default).
- `orbit_transfer` 0.1.0 (native): Impulsive orbital manoeuvres around one body (two-body, coplanar and coaxial orbits).
- `orf_codon` 0.1.0 (native): Finds Open Reading Frames (ORFs) across all 6 reading frames, translates the longest ORF, and computes sequence GC%, longest-ORF GC3%, and codon usage counts.
- `pdb_parse` 0.1.0 (native): Parses PDB or mmCIF protein/macromolecule coordinate files.
- `pendulum` 0.1.0 (native): Rigid pendulum released from rest at any amplitude, with optional viscous damping.
- `peptide_fragments` 0.1.0 (native): Peptide fragment ions for tandem MS.
- `ph_speciation` 0.1.0 (native): Exact Henderson-Hasselbalch polyprotic acid-base microspecies solver.
- `phylo_tree` 0.1.0 (native): Evolutionary distances from aligned DNA (p-distance, Jukes-Cantor 1969, Kimura two-parameter 1980, with large-sample standard errors) or a distance matrix given directly, and trees from them by neighbour joining (Saitou-Nei, Studier-Keppler form) and UPGMA.
- `plate_bending` 0.1.0 (native): Thin rectangular plate simply supported on all four edges (Kirchhoff theory, small deflection) under a uniform pressure, a half-sine pressure or a central force (true point or spread over a patch), by the Navier double sine series.
- `plddt_analyze` 0.1.0 (native): Analyzes AlphaFold pLDDT confidence scores from PDB/mmCIF B-factors.
- `plot` 0.2.0 (native): Line plot of columns from a CSV (a file from an earlier run, or inline text), optionally one line per value of a group column, and a second CSV overlaid dashed (theory against simulation).
- `potion` 0.1.0 (native): PotionCraft's chemistry engine.
- `primer_check` 0.1.0 (native): PCR primer quality check by counting and exact matching only (no nearest-neighbour tables).
- `protein_digest` 0.1.0 (native): In-silico protease digestion of one protein sequence (trypsin with the proline rule, trypsin without it, Lys-C, chymotrypsin, Glu-C, CNBr, or a custom rule) with up to 5 missed cleavages.
- `protein_props` 0.1.0 (native): Computes ProtParam-style physicochemical properties from an amino acid sequence.
- `qsar_ridge` 0.1.0 (native): Small-N standardized Ridge QSAR/ADMET regressor with exact Hat-matrix Leave-One-Out cross-validation (R², Q²_LOO, RMSE_LOO) and leverage applicability-domain checks for candidate predictions.
- `ramachandran` 0.1.0 (native): Computes backbone dihedral angles (phi, psi, omega) from PDB/mmCIF N-CA-C atoms, assigns secondary structure and Ramachandran favored/allowed/outlier fractions, and writes an outlier-highlighted 3D scene.glb.
- `reaction_network` 0.1.0 (native): Mass-action kinetics of a reaction network written as text ('A + B -> C; k = 0.5', 'A <=> B; kf = 2; kr = 0.5', sources '0 -> A', sinks 'A -> 0'), integrated by 3-stage Radau IIA (order 5, L-stable) with an exact Jacobian and step-doubling error control.
- `resolving_power` 0.1.0 (native): Mass resolving power.
- `resonator` 0.1.0 (native): A vibration energy harvester as a base-excited mass-spring-damper (Williams and Yates).
- `restriction_map` 0.1.0 (native): Restriction digest of one DNA sequence, linear or circular, with named enzymes (66 common sites built in, IUPAC degenerate codes, type IIS enzymes that cut outside their site, custom sites).
- `rigid_body_spin` 0.1.0 (native): Torque-free rotation of a rigid body.
- `sasa` 0.1.0 (native): Solvent-accessible surface area by Shrake-Rupley point counting (probe 1.4 Å) from PDB or mmCIF text or a file.
- `seq_align` 0.1.0 (native): Exact Needleman-Wunsch (global) and Smith-Waterman (local) pairwise sequence alignment for proteins (BLOSUM62) and DNA/RNA.
- `servo_control` 0.1.0 (native): Generic closed-loop PID electromechanical actuator simulator (RK4) with torque saturation, anti-windup, viscous damping, and load torque.
- `smiles_graph` 0.1.0 (native): Pure-Rust SMILES molecular graph analyzer.
- `solid` 0.2.0 (native): One parametric solid model of a part or an assembly, built from a model script by SolidCraft's headless CLI (pinned release 0.45.0, B-rep kernel solidcore).
- `spectral_match` 0.1.0 (native): Computes greedy-matched cosine similarity, mass-shifted modified (analog) cosine similarity, and peak-count & intensity-weighted spectral coverage between two MS2 spectra.
- `spectrum_clean` 0.1.0 (native): Preprocesses an MS2 fragment peak list.
- `spectrum_fft` 0.1.0 (native): Spectrum of an equally sampled signal (inline samples, a csv, or a synthetic test signal).
- `spring_design` 0.1.0 (native): Helical compression spring of round wire from wire and coil diameter, active coils, moduli, free length and load.
- `stoich_balance` 0.1.0 (native): Balances a chemical equation, ionic ones too (charge is a conserved row), by the exact integer null space of its composition matrix; molar masses from formulas with brackets and hydrates; limiting reagent, theoretical and percent yield, excess left over, atom economy.
- `strip` 0.3.0 (native): A precompressed strip clamped at both ends at given angles (the exact planar elastica, inextensible), pushed sideways at a point under displacement control, followed by pseudo-arclength continuation along one branch, from a margin below the lowest resting state to a margin above the highest (it says where the branch ends.
- `surface_finish` 0.1.0 (native): Generic procedural PBR surface finish & texture synthesizer (pure Rust).
- `thin_film` 0.1.0 (native): Multilayer thin-film stack by the transfer-matrix (characteristic-matrix) method.
- `tm_score` 0.1.0 (native): TM-score, GDT-TS/GDT-HA and RMSD between two protein structures.
- `torsion_shaft` 0.1.0 (native): Round shaft in torsion, solid or hollow, stepped in segments carrying one torque in series.
- `trajectory` 0.1.0 (native): Generic 3D point-mass flight and aiming solver (RK4) with quadratic aerodynamic drag, 3D wind, and optional Magnus lift.
- `transducer` 0.1.0 (native): A cantilever with a tip mass and bonded piezoelectric patches (31 mode) reduced to the one-mass numbers dynamics takes, referred to the motion of the tip mass's centre.
- `transmission_line` 0.1.0 (native): Lossless transmission line.
- `truss2d` 0.1.0 (native): Plane pin-jointed truss by the direct stiffness method.
- `uncertainty` 0.1.0 (native): Measurement uncertainty budget after the GUM (JCGM 100).
- `variant_effect` 0.1.0 (native): Annotates coding DNA variants (SNVs and indels).
- `vle_flash` 0.1.0 (native): Vapour-liquid equilibrium of an ideal mixture (Raoult's law, Antoine vapour pressures given as inputs per component).

Full records: instruments.json (inputs with units and defaults, readings, known-answer cases).

## Write an instrument

A folder with `instrument.json` and a program in any language. The kernel starts the program in a fresh folder with
`request.json` (`{"verb": "run", "inputs": {...}}`; file inputs under `inputs/`); the program writes `result.json`
(`{"values": {...}}` or `{"error", "hint"}`) and files under `out/`. Manifest: name, version, summary, command
(`{dir}` = the folder), timeout_s, inputs (JSON schema with `unit`), outputs, selftest (cases with `expect`: value with
rel_tol/abs_tol, min/max, or equals), replay_rel_tol, and hash_files for a compiled program. Known answers must come from
outside your own work: closed forms, exact solutions, published values.

## Registry

Publish and find instruments: see registry.html. HTTP `GET /v1/search?q=...`, `GET /v1/instruments/<name>/latest`,
`GET .../archive`, `POST /v1/prs` (gzip tar of one folder, bearer token), reviews, merge, evidence-backed ratings.
MCP: `registry_search`, `registry_show`, `registry_install`, `registry_submit`, `registry_verify`. An installed instrument
runs nothing until your own `invntr admit` passes its known answers.
