nodus-state
Execution state vocabulary for AI-native systems. A shared, typed language for describing what an execution is doing, what it's waiting for, how to resume it, and what it produced. Zero required dependencies — pure Python stdlib.
Install
pip install nodus-state
Modules
Status constants
from nodus_state import FlowStatus, UnitStatus, AgentStatus, UnitType, WaitType
assert FlowStatus.WAITING in FlowStatus.ALL
assert UnitStatus.COMPLETED in UnitStatus.TERMINAL
assert AgentStatus.PENDING_APPROVAL in AgentStatus.ACTIVE
Wait conditions
from nodus_state import WaitCondition
# Event-based wait
wc = WaitCondition.for_event("job.completed", correlation_id="run-1")
assert wc.is_event_based
assert wc.resume_event == "job.completed"
# Time-based wait
from datetime import datetime, timezone
wc = WaitCondition.for_time(datetime(2030, 1, 1, tzinfo=timezone.utc))
assert wc.is_time_based
# Round-trip through JSON/JSONB
wc2 = WaitCondition.from_dict(wc.to_dict())
assert wc2 == wc
Resume specs
from nodus_state import (
ResumeSpec, spec_to_json, spec_from_json,
register_resume_callback_builder, build_callback_from_spec,
RESUME_HANDLER_EU,
)
# Register at startup
def my_eu_builder(spec: ResumeSpec):
def _resume():
with my_db() as db:
my_service(db).resume(spec.eu_id)
return _resume
register_resume_callback_builder(RESUME_HANDLER_EU, my_eu_builder)
# Persist and restore
spec = ResumeSpec(handler=RESUME_HANDLER_EU, eu_id="eu-1", tenant_id="t1", run_id="r1")
raw = spec_to_json(spec) # persist to DB / Redis
callback = build_callback_from_spec(spec_from_json(raw))
callback() # execute the resume
Envelopes
from nodus_state import success, error, unified
# Legacy two-status shapes
env = success({"result": 42}, [], "trace-abc")
# → {"status": "SUCCESS", "data": {...}, "trace_id": "trace-abc", ...}
env = error("something broke", [], "trace-abc")
# → {"status": "ERROR", "data": {"message": "..."}, ...}
# Canonical unified shape (recommended for new code)
env = unified(eu_id="eu-1", trace_id="t1", status="success", output={"x": 1}, error=None)
Execution context
from nodus_state import ExecutionContext, ExecutionResult
ctx = ExecutionContext.new("flow.run", user_id="user-123")
# ... pipeline stages attach to ctx.metadata ...
result = ExecutionResult(success=True, data={"steps": 5}, eu_status="success")
response = result.to_response()
# → {"status": "success", "data": {...}, "trace_id": "...", "metadata": {...}}
Execution records
from nodus_state import build_execution_record, record_from_flow_run
# Pure function — pass any serialisable values
rec = build_execution_record(
run_id="r1", trace_id="t1", workflow_type="my_flow",
status="completed", actor="flow",
)
# Duck-typed adapter — works with ORM models or plain objects
rec = record_from_flow_run(flow_run_obj, status="completed")
Extracted from
AINDY/core/execution_envelope.py, AINDY/core/execution_pipeline/context.py, AINDY/core/wait_condition.py, AINDY/kernel/resume_spec.py, and AINDY/core/execution_record_service.py in the A.I.N.D.Y. runtime.
Metadata
Release files for nodus-state 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| nodus_state-0.1.0.tar.gz | 20.2 kB | Without provenance | Details for nodus_state-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| nodus_state-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for nodus_state-0.1.0-py3-none-any.whl |
Total release size: 36.1 kB
Release files / nodus_state-0.1.0.tar.gz
| Download URL | nodus_state-0.1.0.tar.gz |
|---|---|
| Size | 20.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fcb6c761725fa1ede2f68a5d397b85fc99135a801a9778ca8f5d7063e26bc3d3
|
|
BLAKE2b-256 checksum How to use checksums |
4c587d02e1f4b48435e4117ae3894e0c0dbf34383f4b5cde8240fe096b88ffef
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.9
|
Release files / nodus_state-0.1.0-py3-none-any.whl
| Download URL | nodus_state-0.1.0-py3-none-any.whl |
|---|---|
| Size | 15.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
05afd24b07dfaae3598a1f4f7f6f670bef37fec51aceeceb3e81822947619ae8
|
|
BLAKE2b-256 checksum How to use checksums |
5e45572041d1c4b332c48568b0fbc83f24b33b36bddb569e9fc262baa24be5fc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.9
|
Security for nodus-state 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.