Network/security posture & Licensing: the zero-outbound guard and local-file-only license state
engine/network_posture.py and engine/license_server.py implement a zero-outbound posture: no outbound dependency at all in production, achieved through the offline signed-license-file mechanism. The appliance stands alone, and its license state is internal to it.
There are two independent halves:
build_guarded_client: a general allowlisted-outbound mechanism. See section 2 for its current, caller-less status.LicenseManager: a pure function of an already-verified license file and the wall clock, with no network call anywhere.
1. What counts as "outbound"
"Outbound" means reaching the public internet or Kindred's own infrastructure, and never the site's own LAN. Calling other machines on-site is not "outbound" under this posture. That covers an Ollama server, a target system's REST, OPC UA or MQTT endpoint, and a peer Kindred node over the Communication Interface.
No existing connector in this codebase (engine/connector.py, engine/inference.py, engine/embedding.py) ever reaches outside the LAN, so nothing needed retrofitting. The mechanism exists to keep it that way going forward. Licensing itself makes no network call at all, so it has no bearing on this posture either way.
2. Building a guarded client
from engine.network_posture import build_guarded_client
client = build_guarded_client(
allowed_targets=frozenset({("mes-node.internal", 8090)}),
enforce=settings.production_mode,
)
allowed_targets is a set of (host, port) pairs, not bare hostnames. A host that also happens to run other services on other ports doesn't get all of them waved through as if they were sanctioned. Both the allowlist and every incoming request's host are lowercased before comparison, so a differently-cased configured hostname can never block its own sanctioned request.
enforce is normally Settings.production_mode (engine/config.py). False in dev and test leaves the posture unenforced entirely, because it is deliberately scoped to production only.
Enforcement is per httpx.Client, not process-wide. This codebase never monkeypatches the socket layer or httpx globally, so only callers that build their client through build_guarded_client are protected. A disallowed target raises OutboundConnectionBlockedError before the request ever reaches the real transport.
No active caller. Nothing in the engine is wired through build_guarded_client. A caller isn't expected to reach for it just because it is on the LAN. The peer-query client in engine/communication_interface.py deliberately builds a plain httpx.Client instead: peer traffic is same-LAN (not "outbound" under this posture at all), and a dynamically discovered peer registry doesn't fit a static allowlist's shape. The guard is the sanctioned path for code that does need to reach a fixed, known target outside the LAN.
3. Issuing an offline license file
poetry run python -m engine.license_issuer generate-keypair \
--private-key license_signing_key.pem --public-key license_public_key.pem
poetry run python -m engine.license_issuer issue \
--private-key license_signing_key.pem \
--site-id site-001 \
--licensed-node-type mes --licensed-node-type plc_generic_device \
--expires-at 2027-01-01 \
--out license.json
Keypair. generate-keypair refuses to overwrite an existing keypair, mirroring the re-run guard in deployment/install_age.sh. Every license.json already signed against the old key would otherwise be silently orphaned.
license_signing_key.pemnever leaves the issuing workstation.license_public_key.pemis the half baked into a site's appliance, forverify_license_fileto check against.
Where signing runs. Both the key storage and the run-at-a-connected-window model (never a live signing service) keep signing entirely off the appliance. Neither half of this tool has any home in Settings in engine/config.py. It is issuance tooling run on the issuer's own workstation, not appliance-side code.
Issuing. issue signs a LicenseFilePayload through engine.license_server.canonical_payload_bytes, the same canonical serialization that verify_license_file checks against. A file this tool signs is therefore guaranteed to verify against the matching public key. --issued-at sets issued_at (default today).
4. Verifying an offline signed license file
from engine.license_server import verify_license_file
with open("license.json") as f:
raw = json.load(f) # {"payload": {...}, "signature": "<base64>"}
license_file = verify_license_file(raw, public_key) # LicenseFilePayload
public_key is the Ed25519 public key baked into the appliance.
It fails closed, exactly like decrypt_config in engine/secrets.py. Each of these raises LicenseFileInvalidError:
- a missing field;
- invalid base64;
- a signature that doesn't verify;
- a payload that fails
LicenseFilePayload's own pydantic validation.
There is no fallback path that treats an unverifiable file as licensed. A file that is simply absent is a different case: the Node runs ungated (see section 6).
Node Type coverage. At Node startup, build_mes_runtime adds one more check after verification. The Node Type's name, lowercased, must be in the file's licensed_node_types (lowercased by LicenseFilePayload). Otherwise it raises LicenseFileInvalidError ("does not cover node type"). A signed file for other node types cannot license this one.
The payload. LicenseFilePayload has the fields site_id, licensed_node_types, issued_at and expires_at. There is no grace period field.
The signature covers the canonical JSON serialization of payload: json.dumps(payload, sort_keys=True, separators=(",", ":")). Whatever process issues a license file at a connected window must serialize the same way before signing, or verification will fail regardless of correctness.
5. Reading license state
from engine.license_server import LicenseManager, LicenseState
manager = LicenseManager(license_file)
state = manager.state # recomputed fresh on every access - no sync call, no caching
Two states, nothing between:
LICENSED:license_file.expires_athasn't passed.UNLICENSED:license_file.expires_athas passed.
Two related cases are not LicenseManager states:
LicenseManagerhas no "no file" mode. With no license file configured,build_mes_runtimebuilds no manager and treats the state asLICENSED.- The one other route to
UNLICENSEDis the licensed prompt asset being absent. That is decided innode_main.py, not byLicenseManager.
A long-lived process that stays up across the expiry date sees the transition on its very next state access. Nothing needs to re-check or re-sync it, since there is no network state to keep current.
6. Gating a task on the license state
A task can take a license_state callable and branch on it, so licensed behaviour is decided by LicenseManager.state. See docs/operations/shift-handoff-live-license-gating.md for a worked example that runs inside a real MES Node process through build_mes_runtime in engine/node_main.py.
from engine.license_server import LicenseState
task = ShiftHandoffTask(
inference_client,
summary_prompt,
signoff_store,
activity_log,
node_type,
node_instance_id,
license_state=lambda: license_manager.state,
precedent_retriever=case_precedent_retriever, # only ever consulted on the LICENSED path
)
Both license_state and precedent_retriever default to always-LICENSED and None. A caller not exercising the gating needs no LicenseManager or embeddings infrastructure just to build a ShiftHandoffTask.
UNLICENSED never calls the model at all. _build_unlicensed_summary (engine/shift_handoff.py) builds a deterministic, hardcoded, still-complete summary straight from already-computed counts. This matches Unlicensed Mode's own design: degrade gracefully, never crash, and never silently behave as if licensed.
Pitfalls
production_modegates a guard with nothing routed through it.deployment/provision_node.sh's generated.envsetsPRODUCTION_MODE=Trueunconditionally, so the flag itself is correctly enforced end to end on a provisioned appliance. But per section 2,build_guarded_clienthas no active caller, so no real outbound request is blocked by this enforcement. Zero-outbound is not being actively enforced against live traffic by this guard.- The allowlist is
(host, port), not scheme._target()(engine/network_posture.py) resolves a missing port against the URL's own scheme default (80 or 443) before comparing, but doesn't check the scheme itself.http://peer.internal:80and a hypotheticalsome-other-protocol://peer.internal:80would compare equal. Remember this whenever a caller routes through the guard. - A license file update requires a rebuild, not a hot-swap.
LicenseManageris constructed once, at process startup, over whateververify_license_filereturns at that moment. A new signed file dropped onto a running appliance's disk has no effect until the process restarts and re-reads it. This matches the Appliance's own "sealed release, rebuild don't patch" model, and is not treated as a gap.
Release: v0.11.0