Compatibility Rules
Hegemony runs as several parts that are not always upgraded at the same moment: the API, the workers, the step plugins, and runs already in progress in Temporal. A worker that runs far from the API may lag behind it for longer. These rules keep every supported combination working. Each rule names the test that enforces it, where one exists.
Summary
| Part | Rule | Enforced by |
|---|---|---|
| Step plugins | Reach the platform only through the step SDK's named methods; never an internal path | The guard test of the hegemony-step-plugins repository |
| Device transports | No promise: first-party only, may change in any release | Not a contract; see Device Transports |
| Step SDK version | Changes only when the SDK changes; major = SDK_ABI_VERSION | The SDK version check in the hegemony-step-plugins repository; tests/core/test_step_sdk_contract.py against the oldest and newest SDK the floor admits |
| Internal API | A worker one minor release behind the API keeps working | tests/api/test_internal_api_contract.py |
| Temporal workflows | A run started on the old code finishes on the new code | Review; workflow.patched |
| Database | After the 1.0.0 baseline, migrations only add | Database Migrations |
| Settings | A renamed setting keeps its old name as an alias for a release | Review |
Step Plugins
The plugin contract is the step SDK, hegemony_step_sdk, in the hegemony-step-plugins repository: BaseHandler and its flags, the HandlerContext, and the methods of HandlerServices.
- No internal paths. A plugin never builds an internal-API request itself. Internal paths may change, and a worker in a remote zone will refuse most of them. It uses the named methods of
ctx.services(fetch_run_artifacts,fetch_run, …) and the functions ofhegemony_step_sdk.run_access, which reach only the step's own run and its organization. A test in the plugin repository fails when plugin code callsopen_api_clientor names an/internal/path. - Additions only. A new method, flag or field is optional for the host: a plugin checks for a new method with
getattrand falls back or fails clearly, asrun_accessdoes. Removing or changing one is an ABI change and bumpsSDK_ABI_VERSION. - Declare what a handler is. A handler that drives the platform instead of a device (starting child runs, sending notifications, writing secrets, syncing inventory) sets
central_only = True. Today this only records the fact (registry.central_only()lists such handlers); routing by zone is planned, and will keep these handlers on central workers. A handler that declareswrites_secretsorsyncs_inventorycounts as central-only too, even without the flag (older plugin releases have none).
Device Transports
The stable contract is handlers and HandlerServices, as above. The device-transport interface in the same SDK (hegemony_step_sdk.transports) is not part of it. It has no stability promise and may change in any release, 1.0.0 and the long-term-support lines included.
The interface is:
- the
hegemony.device_transportsentry-point group and theTransportRegistrya transport registers with; DeviceConnectionSpecandJumpHostSpec;HostKeyVerifier,SshAlgorithmRecorder,ConnectionCancellationRegistryandTransportOutputSink;- the
supports_*class flags the worker reads when it builds a transport (supports_host_key_verifier,supports_ssh_algorithm_recorder,supports_output_sink).
It is for the transports shipped in the hegemony-step-plugins repository only: netmiko, scrapli and asyncssh. A device transport from anyone else is not supported.
The reason: a transport receives resolved passwords and keys, and it enforces the SSH host-key and algorithm rules (SSH Host Keys). That makes it platform code, not a plugin of the kind this contract covers. The hegemony-transport-support package the built-in transports share is internal in the same way.
A handler is not affected. It opens a device session with ctx.services.connect(...) and uses the session it gets back; that method and that session are part of the stable contract. So is ctx.services.resolve_device_credentials(...) and the DeviceCredentials it returns, including the JumpHostSpec in its jump_host field: a handler that hands credentials to a tool (the Ansible step does) reads them. A change to JumpHostSpec follows the additions-only rule for that reason.
Step SDK Versions
hegemony-step-sdk has its own version. The other wheels of the hegemony-step-plugins repository carry its release version (the tag vX.Y.Z); the SDK's version changes only when the SDK changes, so a plugin-only release keeps it:
| SDK change | SDK version |
|---|---|
| none | unchanged |
| a fix that leaves the public surface alone | patch |
| an addition (the additions-only rule above) | minor |
| a removal or incompatible change | major, which is SDK_ABI_VERSION |
The SDK's major version is always SDK_ABI_VERSION, so the platform's ABI check and the version range say the same thing. A change to the device-transport interface needs only a minor version: only the built-in transports use it, and they pin the SDK exactly.
What each side declares:
- Step-handler and probe wheels require
hegemony-step-sdk>=X.Y,<X+1, the SDK minor they were built with up to the next major. - Device-transport wheels and
hegemony-transport-supportrequire one exact SDK version. - The platform declares a one-minor window on the SDK version (
hegemony-step-sdk>=X.Y.Z,<X.(Y+1).0), like every other plugin package;task release:floors:syncwrites it from the pinned SDK version. CI's Lint & Test job runstests/core/test_step_sdk_contract.pyagainst the newest SDK the window admits (the pinned one, with every other test) and against the oldest (the floor), installed from the plugin release that published it (scripts/release/sdk-range.py;task release:sdk:rangeprints both).
hegemony-step-plugins releases up to v0.55.0 gave the SDK the release version; from the release that introduced its own version, the SDK version is in the name of that release's hegemony_step_sdk-*.whl.
Internal API
Workers call the API's internal routes (apps/api/auth/internal_access.yaml lists them). The rule: a worker on the API's minor release or one minor release behind keeps working against the newer API. It holds only one way: upgrade the API first, then the workers. A newer worker may call a route an older API does not have yet. So, on an internal route:
- add routes, query parameters and request fields freely, as long as they are optional; add answer fields freely;
- never remove or rename a route, a parameter or a field, and never make one required that was optional or absent;
- never remove or rename a field of an answer: an older worker reads it (for example
artifactsofGET /internal/runs/{run_id}); - when a route is superseded, keep the old one until no supported worker uses it, and say in its docstring when it can go. (Before 1.0.0 the unscoped
GET /internal/notification-destinations/{id}went this way: kept while the pinned step plugins used it, removed with the pin that stopped.)
tests/api/test_internal_api_contract.py keeps a snapshot of every internal route's parameters, request fields and, for a typed answer, the fields of its success answer (tests/api/fixtures/internal_api_contract.json). It fails on a removal or a new required request field. It also fails when something was added, until the snapshot is regenerated on purpose:
UPDATE_INTERNAL_API_CONTRACT=1 uv run pytest tests/api/test_internal_api_contract.pyThe snapshot cannot see inside an untyped request body or answer (a route that takes or returns a plain JSON object). For those, the rule applies by review.
A write that a worker may send again carries an Idempotency-Key header, so the API applies it once (Repeated Writes). The header is optional: a worker from before it keeps working, and a new internal write route must be listed as kept or no_store in tests/api/test_internal_idempotency.py.
Temporal Workflows
A run in progress keeps its workflow history across an upgrade, and the new worker replays that history through the new code. A change that alters the order or kind of commands a workflow issues (activities, timers, child workflows, signals) breaks replay of runs started before it.
- Guard such a change with
workflow.patched("<id>"): the new path for runs that reach it on the new code, the old path for runs that replay old history.apps/worker/graph_engine/engine.pyhas an example (_PATCH_UNTIL_JOIN_MONITOR_START_RESULT). - Remove the old path, and later the patch call, only after no run that can still replay it is in progress.
- Activity inputs and results follow the internal-API rule: add optional fields, never remove or rename one. Read new fields with a default (
dict.get(...)), as the workflow input's organization fields are read. - Task queue names are part of the contract: renaming one strands the runs waiting on it.
Database
The 1.0.0 release starts from a single baseline migration, which is never edited. Migrations after it only add (new tables, new nullable columns, new indexes), and a rename or drop goes through an additive step first. See Database Migrations.
Settings
A setting that is renamed keeps its old environment variable as a deprecated alias until the next major release, and the reference says so.