Metadata-Version: 2.4
Name: devman-runtime
Version: 0.3.0
Summary: Python runtime (protocol, client, server core) for devman-gen generated device-manager bridges
Author: Kenji Shu
License-Expression: MIT
Project-URL: Repository, https://github.com/kenji0923/devman-runtime
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: OS Independent
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# devman-runtime

Python runtime library for bridges generated by [devman-gen](https://github.com/kenji0923/devman-gen).

devman-gen is a language-agnostic generator that wraps a device-control
library (e.g. `caen_libs` for CAEN HV crates) in a client/server pair with
resource-ownership management. This package is the Python-side runtime that
those generated packages import, so runtime fixes reach every bridge through
a normal dependency upgrade instead of regeneration.

## Contents

- `devman_runtime.protocol` — length-prefixed JSON over TCP.
- `devman_runtime.client` — `ManagerClient`: sessions, `acquire`/`release`
  resource ownership, `invoke`, link-group registration
  (`set_link_groups` / `list_link_groups`).
- `devman_runtime.server` — `ManagerCore` and `serve_manager`: request
  dispatch with ownership enforcement, device lifecycle/periodic hooks,
  client leases. Hook files receive `core` in their context, so
  device-specific safety monitors (e.g. the CAEN trip watchdog in
  caenhv-devman's server_hooks.py) can use the registry and leases.
- `devman_runtime.db` — SQLite-backed ownership and link-group registry.

## Server features

- `client_lease_sec` / `--client-lease-sec`: any authenticated request
  renews a client lease; `core.is_client_live(name)` exposes it to hooks
  (used e.g. for janitoring stale link groups).
- Periodic hook (`periodic_file` / `periodic_function` +
  `periodic_interval_sec`): run a user callback on an interval with access
  to the device singleton and the core.

Device-specific policies (what a "trip" means, when to power off partners)
belong in per-bridge hook files, not in this package.

This package is used by, e.g., `caenhv-devman-client`.
