Metadata-Version: 2.4
Name: conductor-lab
Version: 0.1.5
Summary: Standalone Conductor jump-host agent
License-Expression: MIT
Requires-Python: >=3.12
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: cryptography==50.0.1
Requires-Dist: pydantic==2.12.5
Requires-Dist: grpcio<2,>=1.81.1
Requires-Dist: protobuf<7,>=6.33.5
Requires-Dist: pyyaml<7,>=6.0.3
Requires-Dist: keyring<26,>=25.6
Requires-Dist: websockets<16,>=15
Requires-Dist: qubic-queue==0.1.0
Requires-Dist: pyusb>=1.3.1
Requires-Dist: PyVISA>=1.16.1
Requires-Dist: pyvisa-py[usb]>=0.8.1
Dynamic: license-file

# Conductor lab client

## Linux user service

After installing the released `conductor-lab` package (executable `conductor`), sign in
and review any local approvals in the foreground first. On Linux with systemd, run:

```sh
conductor service install
conductor service start
conductor service status
conductor service stop
conductor service remove
```

Installation only writes a private unit under `${XDG_CONFIG_HOME:-$HOME/.config}/systemd/user/`
and reloads the user manager. It does not start, enroll, install dependencies, read
credentials, enable boot/login startup, or request elevated privileges. `start` is explicit
and runs the existing `--profile lab start` command using the installed interpreter and
console script. The unit records only the resolved `CONDUCTOR_CONFIG_DIR` path
and the existing validated `CONDUCTOR_LAB_DELIVERY_URL`, not tokens or a copy of the shell
environment. Set that delivery URL as for foreground queue startup before installation;
missing or invalid values fail without writing a unit. Use the same configuration directory
for subsequent foreground commands. User-profile services are not supported.

The service runs without a terminal while the user manager remains active. It does not
enable lingering or automatically restart after a stop, crash or revocation. Existing
browser consent and local approvals still apply; complete them in the foreground if
startup reports they are missing. `conductor stop` also stops the agent without restarting
it. Service stop sends the existing graceful shutdown signal, with systemd killing any
remaining children after 90 seconds. Remove stops before deleting the unit. An inactive
`status` returns systemctl's nonzero status. Inspect logs with
`journalctl --user -u conductor-lab.service`.

Run installation again to retry a failed manager reload. A changed unit requires explicit
removal and reinstallation; do this after relocating or replacing the CLI environment.
Installation verifies that the user manager sees the unit at the written path. If the
shell's `XDG_CONFIG_HOME` differs from the manager's, use the manager's config home and
reinstall rather than treating a successful reload as a successful installation.
Keep the CLI installation available while the service is installed. macOS retains
foreground `conductor start` support; the direct Windows lab agent remains unsupported.
systemd does not support an interpreter executable path containing quotes or backslashes;
installation rejects those paths. Spaces, dollar signs and percent signs are supported.

Conductor is the lightweight jump-host client for Control's lab-agent API. Lab
forwards come from the lab configuration loaded in Control. The agent sends
heartbeats, connects to those configured endpoints when authorized by a signed
job grant, and reports read-only endpoint health. It does not enumerate
instruments or change lab configuration.

The client uses Python 3.12, standard-library HTTP/TCP clients, PyYAML, and the
maintained adapter packages; it does not install Control's scientific stack.

For hosted and release-assisted uv/pip installation, upgrades, removal, and
version/help checks, follow the [CLI installation guide](../docs/conductor-installer.md#customer-installation).
For device-code approval and troubleshooting, see the
[lab client setup guide](../docs/lab-client-setup.md).
See [lab access](../docs/lab-access.md) for ownership and the coordinated
schema/client cutover, and [instrument connections](../docs/instrument-connections.md)
for worker routing.

## Install and log in

The published distribution is `conductor-lab`; the command is `conductor`.
With Bash and curl on a supported Linux or macOS system, install as your normal
user:

```shell
curl --proto '=https' --tlsv1.2 -fsSL https://install.conductorquantum.com/install.sh | bash
export PATH="$HOME/.local/bin:$PATH"
conductor --version
conductor --help
```

Without CPython 3.12 the installer provides one through uv, and it adds
`~/.local/bin` to PATH in your shell profile for new terminals.
Installation starts no login or service. Rerun the installer to upgrade;
the [installation guide](../docs/conductor-installer.md#customer-installation)
also covers uninstall and uv/pip with the required release-supplied dependency.
Bare `uv tool install conductor-lab` and `pip install conductor-lab` are not
supported because `qubic-queue` is not on PyPI.

To join an existing lab from your own computer, run `conductor login --profile user`
and approve access in the browser. Production at
`https://control.conductorquantum.com` is the default target. See
[user-profile connection](../docs/lab-client-setup.md#use-the-user-profile).

## Commands

| Command | Purpose |
| --- | --- |
| `conductor lab` / `login --profile lab` | Open browser enrollment, choose configuration, and automatically install/start its services |
| `conductor logout` | Clear the saved login |
| `conductor lab connect` | Connect this computer to a lab |
| `conductor lab status` | Send one heartbeat and display lab status |
| `conductor lab switch` | Authenticate to a lab and start the agent |
| `conductor lab gateway-credential set CONNECTION` | Store a queue lab's OPX gateway credential in the OS keychain, read without echo from a prompt or standard input |
| `conductor start` | Run the lab heartbeat and configured-forward agent |
| `conductor connections` | List the lab's configured forwards and the ID that `lab gateway-credential set` takes |

Use `conductor COMMAND --help` for options. The target is selected at build time,
not with a runtime `--target` option; see the developer procedure below. The separate
user profile is available with `--profile user`; lab and user credentials are
stored independently.

## USB and VISA prerequisites

PyUSB, PyVISA and the PyVISA-py USB backend are ordinary runtime dependencies;
no driver extra is required. The Python USB backend also needs an
operator-provided system `libusb-1.0` runtime and permission to access the
configured USB device. Python package installation does not install native
libraries, change USB permissions, enumerate instruments or start services.
NI-VISA is not bundled. Follow the lab's approved native-library and
serial-scoped USB permission setup before using hardware.

These dependencies do not yet make a plain PyPI install possible: the separate
`qubic-queue` requirement remains until the QubiC dependency cutover lands.
Use the existing released installer or developer procedure below in the meantime.

## Test against production, staging or local

This is the canonical procedure for **developers on Conductor-controlled computers**.
Never install unreleased builds on customer or lab machines. Ordinary users must
use the [released installer](../docs/conductor-installer.md#customer-installation).
No command below logs in, starts a service or contacts hardware.

### Install from a local checkout

Use Git, Node.js 22+, uv and CPython 3.12. The private Control checkout must include
both `conductor/` and `Instruments/qubic_queue/`; copying the CLI directory alone
omits its local dependency. Run from the repository root:

```sh
export UV_NO_ENV_FILE=1
node dev/conductor-dev.mjs version
node dev/conductor-dev.mjs install --target staging
export PATH="$HOME/.local/bin:$PATH"
conductor-staging --version
conductor-staging --help
```

The helper copies the packages into a temporary build directory, applies runtime
constraints from `conductor/uv.lock`, builds any required sibling dependency
locally and stamps a version such as `0.1.2.dev89+g8845af5b045c`. A `.dirty` suffix
means one of the source packages has uncommitted changes. The checkout's release metadata is
not rewritten. Release/deploy tooling rejects these dev versions.

`conductor-staging` is a separate uv tool from the released `conductor`, with
its own saved login and the default server `https://staging.control.conductorquantum.com`.
The helper's `--target production` (also its default) installs an unreleased
`conductor` instead; it is **not** a production release and can shadow or replace
an existing command. Prefer the staging target for side-by-side testing.

For a local target, first prepare your isolated stack with the
[local setup guide](../docs/local-testing.md). Then run:

```sh
node dev/conductor-dev.mjs install --target local --isolated
conductor-local --version
conductor-local --help
```

This pins the isolated stack's entry **public** key into the build and installs
`conductor-local`. The helper consumes the stack's signing material internally;
never print or copy it. Without a prepared stack, installation stops with a
missing-local-entry-key error. For non-default ports and checkout-specific login
storage, follow [Connect a configured lab](../docs/local-testing.md#connect-a-configured-lab).
The default local server is `http://127.0.0.1:3000`; do not use it for a different
isolated checkout by accident.

After changing source or switching branches, rerun the same install command;
`uv tool upgrade` does not rebuild the helper's temporary source tree. Remove
these tools with `uv tool uninstall conductor-lab-staging` or
`uv tool uninstall conductor-lab-local`. Saved login/configuration is separate
from the tool and is not removed by uninstalling it.

### Install a private Git branch or commit with uv

Use a recent uv with Git-source support and existing authenticated Git access to
`conductorquantum/control`. Authenticate through your normal credential manager;
never put a token in the URL, command line, documentation or logs. Both installs
below need network access to GitHub and the Python package index. A full commit
SHA is preferable for reproducing a result; a branch moves.

Use separate tool directories so this experiment does not replace the released
CLI. `REF=staging` tests the branch; replace it with a reviewed full commit SHA
to test that exact revision:

```sh
export UV_NO_ENV_FILE=1
export UV_TOOL_DIR="$HOME/.local/share/conductor-source-tools"
export UV_TOOL_BIN_DIR="$HOME/.local/share/conductor-source-bin"
REF=staging
uv tool install --python 3.12 \
  "git+https://github.com/conductorquantum/control.git@${REF}#subdirectory=conductor"
"$UV_TOOL_BIN_DIR/conductor" --version
"$UV_TOOL_BIN_DIR/conductor" --help
```

Unlike the helper, this builds the source distribution without dev-version or
target stamping. The command remains `conductor`, defaults to production, and
reports the version declared in that revision even when it is unreleased.
Record the resolved commit from uv's installation output; `--version` alone
cannot prove which source you tested. For revisions that require `qubic-queue`,
uv also builds it from the sibling directory at the same Git revision. It resolves
other dependencies from the index rather than applying the checkout's lockfile.
Use the local-checkout helper when you need the reviewed dependency constraints
and target stamping.

To refresh the branch or switch commits, rerun the command with `--reinstall
--refresh` and the intended `REF`. Remove the experiment and restore uv's normal
directories in this shell when finished:

```sh
uv tool uninstall conductor-lab
unset UV_TOOL_DIR UV_TOOL_BIN_DIR
```

### QubiC support for an unreleased candidate base wheel

The optional-dependency change in [CON-1379](https://linear.app/conductorquantum/issue/CON-1379)
is not a published PyPI release. Its candidate base wheel can run without QubiC;
the currently released `0.1.2` still requires the
[release-assisted installation](../docs/conductor-installer.md#customer-installation).
Do not replace a candidate wheel below with `pip install conductor-lab` and
assume the unshipped behavior is available on PyPI.

For developer-only testing of a reviewed candidate base wheel, a supported
QubiC add-on is already published with release `0.1.2`. Its SHA-256 matches the
[release provenance](https://install.conductorquantum.com/releases/0.1.2/provenance.json).
Set `BASE_WHEEL` to the actual absolute path of your reviewed candidate wheel;
the path below is a placeholder:

```sh
BASE_WHEEL=/absolute/path/to/conductor_lab-VERSION-py3-none-any.whl
QUBIC_URL='https://install.conductorquantum.com/releases/0.1.2/qubic_queue-0.1.0-py3-none-any.whl#sha256=051e7d4be095566bb945a48f1f17948a354fccf19efd01157b93541177f2ddb2'
```

With pip, use a fresh candidate-only environment:

```sh
python3.12 -m venv ~/.venvs/conductor-candidate
. ~/.venvs/conductor-candidate/bin/activate
python -m pip install "$BASE_WHEEL"
python -m pip install "$QUBIC_URL"
conductor --version
conductor --help
python -c 'import qubic_queue; print("QubiC add-on imports successfully")'
deactivate
```

With uv, install both into a separate tool environment rather than adding the
wheel to an unrelated Python environment:

```sh
export UV_TOOL_DIR="$HOME/.local/share/conductor-candidate-tools"
export UV_TOOL_BIN_DIR="$HOME/.local/share/conductor-candidate-bin"
uv tool install --python 3.12 --with "qubic-queue @ $QUBIC_URL" "$BASE_WHEEL"
"$UV_TOOL_BIN_DIR/conductor" --version
"$UV_TOOL_BIN_DIR/conductor" --help
uv tool uninstall conductor-lab
unset UV_TOOL_DIR UV_TOOL_BIN_DIR
```

These commands were verified with the candidate base wheel and the published
add-on, not with a newly published base package. They prove installation and
imports, not instrument connectivity or hardware safety. There is no assumed
`[qubic]` extra. The hosted installer already includes QubiC through its released
requirements; it needs no separate add-on step. Remove the dedicated pip venv
after deactivating it when testing is finished; keep saved configuration separate.

### Published prereleases and staging installers

As verified on November 16, 2026, PyPI lists only stable `0.1.2`, TestPyPI has
no `conductor-lab` project, and this repository defines no public staging
installer channel. `--pre` does not turn the stable release into a development
build. Use the source procedures above, not an invented TestPyPI or staging URL.
The [installer release process](../docs/conductor-installer.md#publish-a-release)
is separate from building an unreleased CLI; these instructions authorize no
publication or deployment.

## Agent behavior

Heartbeats contain the local hostname and Conductor version. At each forwards
refresh, the agent lists the lab's configured forwards, reconciles grant-gated
TCP listeners, and checks the configured endpoints in a bounded background
worker. Health reports contain only the forward ID, health value, a short
health message, and the port the forward listens on (null when it has none).
A forward listens on its instrument's port. When Linux refuses a port below 1024
to a non-root agent, the forward listens on the port plus 10000 instead and
reports that port, which the server checks before the worker dials it. Probes are read-only and never update forward or configuration
data. If a lab has no configured forwards, Conductor logs:

```text
No connections are configured for this lab; load a configuration in Control.
```

Keep the foreground terminal open, or use service supervision for unattended
operation. `Ctrl-C` shuts down listeners and preserves the login.

## Development and verification

From `conductor/`:

```shell
uv sync
uv run ruff check .
uv run ruff format --check .
uv run mypy
uv run pytest
```

The package is also covered by the repository's Bazel targets:
`//conductor:pytest`, `//conductor:ruff`, `//conductor:format`, and
`//conductor:mypy`.

Configured endpoints carry one stable YAML `connection_id`. Use `connections`
to list them. `instruments forwards`, `start --private-network`, the `network` command
and the `--network-client`/`--network-socket` options are rejected. `lab connect`,
`lab status` and `lab switch` retain their connection/profile behavior.

## Maintained instrument packages

`conductor lab` or `conductor login --profile lab` opens browser enrollment. Choose the
configuration and approve applying it; Conductor verifies, installs, starts and supervises its
private gRPC services automatically. Fresh health reports turn configured sources green.
Slow installation runs separately from heartbeats and grant checks. One connection's
installation failure does not stop another healthy service. Busy health is reported
as unknown and does not restart a live child or interrupt its authorized streams.
`packages plan`, `packages approve` and `packages sync` remain advanced diagnostics; the
normal enrollment flow requires no package commands. Signed job grants remain required. See the
[package delivery guide](../docs/instrument-packages.md) for host requirements, release trust,
upgrade/rollback and hardware acceptance.

For customer development and production handoff, follow
[customer lab onboarding](../docs/customer-lab-onboarding.md). It covers adapter
development over tailnet SSH, installing CLI wheels for the lab profile, automatic adapter delivery, release promotion,
lab invitations and calibration developers' separate user profiles.

Family metadata is generated from the [Control registrations](../control/src/control/config/families/README.md) and packaged as `conductor_lab/families.json`.
