Taewoo Park

Research

instrument-control-skills

Nine agent skills that let an agent write laboratory instrument-control code that is safe, accurate, precise, integral, complete and atomic — in one shot, with linters and proofs rather than advice.

Instrument code fails differently from normal software

A plausible-looking script can burn a sample, quench a magnet, or — silently — write a dataset that is subtly wrong and gets published. The third failure is the dangerous one, because nothing in the run announces it and the cost lands years later on somebody else's citation.

The knowledge that prevents all three is tribal: limiter ordering, sign-preserving ramps, stale-buffer traps, NaN discipline, lock ordering. It is learned lab by lab, usually by breaking something, and it leaves when the person who learned it leaves. So I wrote it down as things an agent — or a human — can execute rather than merely read.

The bottleneck that does not live inside a file system

Instrument control was the next bottleneck on my list, and it is a different category of problem from everything before it: the failure mode is physical, the feedback loop is slow, and the resource I would normally learn on — time at the actual instrument — is the scarcest thing in the lab.

So I wrote the knowledge down as executable artefacts and handed the question of whether it works to a separate benchmark, OSICBench. This is also where MagLab's instrument surface stops being a scaffold and a safety check and becomes the driver, the linter and the proof.

The adjacent surface in [MagLab](maglab.html): scaffold, SCPI validation, static safety check
The adjacent surface in MagLab: scaffold, SCPI validation, static safety check
Safe
Every exit path leaves outputs OFF; fail-closed on any doubt.
Accurate
Stored values are what the instrument DID, not what was asked of it.
Precise
Settling, integration, filtering and averaging are engineered rather than defaulted.
Integral
Missing data stays missing as NaN; configuration is immutable; metadata is complete.
Complete
Full lifecycle, every state handled, tested, no stubs.
Atomic
Every multi-step change — apply, export, share — is all or nothing.

Every pattern ships as something you can execute

Runnable scaffolds generate a full driver package whose tests pass before you edit a single line, so the starting point is green rather than aspirational. AST linters mechanically fail the classic disasters — a bare except: pass, returning zero on failure, torn-file exports, an engine with no shutdown path — instead of describing them in a style guide nobody re-reads.

Hardware-free proof harnesses provide mocks with ordered call logs and fault injection, so a claim like outputs off on every path becomes a pytest assertion rather than a hope. An acceptance scorecard grades a package against all six virtues and runs its tests in one command.

Every skill ships its instruction file, its references, and working scripts or examples with their own test suites. Nothing in the bundle is documentation-only, and that is the only claim I make for it.

The skill that owns the order the others run in

It carries the end-to-end workflow, the map from each virtue to the practices that satisfy it, an anti-pattern catalog aimed specifically at the mistakes language models make in this domain, the procedure for mining a manual into a spec, and the master checklist. Its script is the six-virtue scorecard the rest of the bundle is graded by.

Three skills between a manual and a first connection

visa-instrument-driver owns the package architecture, the connection contract and single-owner resource handling, and ships a scaffolder, a driver linter, and a reference driver with tests. fail-closed-safety owns a thirteen-entry safety catalog and shutdown ordering, and ships a safety linter plus a fault-injection example with its proofs.

scpi-precision-io owns the parts that decide whether a number is real: verify-after-write, operation-complete synchronisation, fresh-fetch rather than stale buffer, batching, and the engineering of settling, integration time and filtering. It ships a timing-budget tool and a verified-write library that I test against a deliberately lying instrument, because that is the only way to prove a verify-after-write actually verifies.

Five skills between a first reading and a shareable dataset

measurement-integrity holds the NaN covenant, per-channel failure thresholds, frozen configurations and the metadata schema, with a linter, a NaN tracker and an immutable config implementation. sweep-engine-design gives a headless engine core, a state machine, an abort contract and automation loops, and ships a complete runnable engine with twelve fault-injection tests and a Qt adapter.

atomic-data-export enforces write-to-temp, fsync, rename, along with the run folder layout and honest partial exports, and ships a drop-in module with crash-injection tests. instrument-mock-testing defines the mock architecture, five proof recipes and hardware-library stubbing, with a generator that builds the mock from the driver itself. multi-instrument-lifecycle covers shared ownership, paired fan-out and fan-in, lock ordering, run arbitration and a watchdog, with a reference hub and deadlock and symmetry tests.

From a manual PDF to a scorecard without touching an instrument

The manual becomes a mined spec. The spec becomes a scaffold whose tests are green as generated. The safety envelope and the SCPI map get filled in. The engine is built on the headless skeleton. Mocks are generated from the driver itself rather than written by hand. The five proof recipes run against those mocks. The linters and the scorecard return six passes out of six. Only then comes the first-contact rehearsal.

Everything to the left of first contact costs seconds and no hardware, which is the whole point: I spend the expensive resource last, on a package that has already failed everything it was going to fail.

The repository proves its own claims on every run

A single test command validates every skill's format and content policy, runs every script against good and bad fixtures, executes all of the example test suites including the fault-injection ones, and replays the scaffold, test and scorecard loop end to end.

You can also run that loop by hand in three commands: scaffold a driver into a temporary directory, run its tests and watch them pass as generated, then run the acceptance check and get six virtues with six passes. A bundle that claims to produce packages which already pass should be willing to demonstrate it in its own README, so mine does.

Portable by construction, because the edges are injected

It installs as a Claude Code plugin in two lines, or as personal skills by copying the skill folders into any agent runtime that reads them. The requirements are Python 3.10 or newer, numpy for the examples and pytest to run the tests.

No VISA library and no GUI toolkit are needed, because transports and toolkits are injected at the edges — not an installation convenience but one of the patterns the bundle teaches, demonstrated on itself. The design notes say why there are nine skills, why I shaped the linters the way I did, and why every pattern had to become something executable. MIT licensed.