Skip to content

Enums & Constants

How to use this page: The first part (imports + per-type reference tables) is for looking up specific enum members and their values. The second part — Use-Case Guide — groups enums by development task with code examples and common pitfalls. Start there when you're not sure which enum to use.

Enums are spread across nnrp.core.enums and nnrp.core.messages submodules, unified re-exported through the top-level nnrp namespace.

Import

python
from nnrp import (
    MessageType, HeaderFlags, FrameClass, ErrorCode,
    TransportId, TransportPolicy, LossTolerance, PayloadKind,
    FlowUpdateScopeKind, FlowUpdateReason, FlowUpdateBackpressureLevel, FlowUpdateFlags,
    ResultHintBudgetPolicy, ResultHintCongestionState, ResultHintReason,
)

Wire Format

WireFormat(IntEnum)

MemberValueDescription
CURRENT0Only supported wire format (NNRP/1)

Message Types

MessageType(IntEnum)

MemberValueDirectionDescription
CLIENT_HELLO0x01C→SConnection setup, carries client capability set
SERVER_HELLO_ACK0x02S→CHandshake acknowledgement
SESSION_PATCH0x03C→SSession parameter update request
SESSION_PATCH_ACK0x04S→CSession parameter update result
CLOSE0x05BothGraceful close
ERROR0x06BothProtocol error notification
FRAME_SUBMIT0x10C→SSubmit a frame
FRAME_CANCEL0x11C→SCancel a frame
RESULT_PUSH0x12S→CPush inference result
RESULT_DROP0x13S→CNotify result dropped
CACHE_PUT0x14C→SStore a cache object
CACHE_ACK0x15S→CCache store result
CACHE_INVALIDATE0x16C→SInvalidate cache
FLOW_UPDATE0x17BothFlow control window update
RESULT_HINT0x18S→CServer hint (backpressure/queue state)
TRANSPORT_PROBE0x19BothTransport path probe
TRANSPORT_PROBE_ACK0x1ABothPath probe acknowledgement
SESSION_MIGRATE0x1BS→CSession migration notification
SESSION_MIGRATE_ACK0x1CC→SSession migration confirmation
PING0x20BothKeep-alive probe
PONG0x21BothKeep-alive response

Header Flags

HeaderFlags(IntFlag)

MemberMaskDescription
NONE0x00No flags
ACK_REQUIRED0x01Receiver must acknowledge
CAN_DROP0x02May be dropped under backpressure
STALE0x04Data is stale
EOS0x08End of stream
RETRANSMIT0x10Retransmitted packet
KEYFRAME0x20Keyframe

Frame Classification

FrameClass(IntEnum)

MemberValueDescription
KEYFRAME0Complete keyframe
DELTA1Delta frame, depends on previous keyframe
RETRANSMIT2Retransmit frame
DISCARDABLE3May be skipped under high server load

Error Codes

ErrorCode(IntEnum)

MemberValueDescription
UNSUPPORTED_VERSION0x0001Unsupported protocol version
AUTH_FAILED0x0002Authentication failed
INVALID_STATE0x0003Operation not allowed in current state
MALFORMED_HEADER0x0004Malformed header
MALFORMED_BODY0x0005Malformed body
UNSUPPORTED_CAPABILITY0x0006Unsupported capability
LIMIT_EXCEEDED0x0007Limit exceeded
FRAME_EXPIRED0x0008Frame expired (over latency budget)
FRAME_CANCELLED0x0009Frame cancelled by client
CACHE_MISS0x000ACache object not found
SERVER_BUSY0x000BServer temporarily unable to process
INTERNAL_ERROR0x000CServer internal error

Error Scope

ErrorScope(IntEnum)

MemberValueDescription
CONNECTION0Connection-level (fatal, requires reconnect)
SESSION1Session-level
FRAME2Frame-level (recoverable)

Transport & Connection

TransportId(IntEnum)

MemberValueDescription
UNSPECIFIED0Unspecified, server chooses
QUIC1QUIC transport
TCP2TCP transport

TransportPolicy(IntEnum)

MemberValueDescription
AUTO0No preference, automatic selection
PREFER_QUIC1Prefer QUIC
PREFER_TCP2Prefer TCP
FORCE_QUIC3Force QUIC
FORCE_TCP4Force TCP

LossTolerance(IntEnum)

MemberValueDescription
STRICT0No packet loss allowed
BEST_EFFORT1Best effort
LOW_LATENCY2Low latency preferred, minor loss tolerated
FIRE_AND_FORGET3High loss tolerance

ControlExtensionFlags(IntFlag)

MemberMaskDescription
NONE0x0000No flags
CRITICAL0x0001Critical extension; receiver must reject if unrecognized

Payload Types

PayloadKind(IntFlag)

MemberMaskDescription
NONE0x00None
TENSOR0x01Tensor payload (neural rendering)
TOKEN_CHUNK0x02Token stream chunk (LLM)
AUDIO_CHUNK0x04Audio chunk
VIDEO_CHUNK0x08Video chunk
STRUCTURED_EVENT0x10Structured event
TOOL_DELTA0x20Tool call delta
OPAQUE_BYTES0x40Opaque binary

Data-plane Enums

InputProfile(IntEnum)

MemberValueDescription
UNSPECIFIED0Unspecified
CHANGED_TILES_LUMA1Luma data for changed tiles only
DENSE_LUMA_FRAME2Full-frame luma data

TileIndexMode(IntEnum)

MemberValueDescription
DENSE_RANGE0Dense contiguous range
RAW_U161Raw uint16 list
DELTA_U162Delta-encoded uint16
BITSET3Bitset encoding

TensorDType(IntEnum)

MemberValueDescription
FP160Half-precision float
FP321Single-precision float
FP8_E4M32FP8 E4M3
FP8_E5M23FP8 E5M2
INT84Signed 8-bit integer
UINT85Unsigned 8-bit integer
INT166Signed 16-bit integer
UINT167Unsigned 16-bit integer

SubmitMode(IntEnum)

MemberValueDescription
INLINE0All objects inlined in body
REFERENCE1Objects referenced via cache keys
MIXED2Mix of inline and reference

BudgetPolicy(IntFlag)

MemberMaskDescription
NONE0x00Strict; no degradation allowed
ALLOW_PARTIAL0x01Allow partial results
ALLOW_STALE_REUSE0x02Allow stale cache reuse
ALLOW_DEGRADED0x04Allow degraded quality
ALLOW_DROP0x08Allow dropping the frame

ResultClass(IntEnum)

MemberValueDescription
COMPLETE0Complete result
PARTIAL1Partial result
STALE_REUSE2Reused stale cached result
DEGRADED3Quality-degraded result

ResultFlags(IntFlag)

MemberMaskDescription
NONE0x0000No flags
STALE0x0001Result from stale/cached data
FALLBACK0x0002Degraded fallback path used
PARTIAL0x0004Incomplete result

Cache Enums

CacheObjectKind(IntEnum)

MemberValueDescription
CAMERA_BLOCK0x0001Camera parameter block
TILE_INDEX_BLOCK0x0002Tile index block (alias: TILE_INDEX_TEMPLATE)
TENSOR_SECTION_TABLE0x0003Tensor section table
CODEC_TABLE0x0004Codec auxiliary table (alias: CODEC_AUX_BLOCK)
REUSABLE_RESULT_OBJECT0x0005Reusable result (alias: FALLBACK_RESOURCE)
PAYLOAD_LAYOUT_TEMPLATE0x0006Payload layout template
PROMPT_SEGMENT0x0007Prompt segment (LLM)
TOOL_SCHEMA0x0008Tool schema
STRUCTURED_EVENT_SCHEMA0x0009Structured event schema

CachePutFlags(IntFlag)

MemberMaskDescription
NONE0x00Default
PINNED0x01Pinned; exempt from LRU eviction
REUSABLE0x02Cross-frame reusable

Flow Control Enums

FlowUpdateScopeKind(IntEnum)

MemberValueDescription
CONNECTION0Connection level
SESSION1Session level
OPERATION2Operation level

FlowUpdateReason(IntEnum)

MemberValueDescription
GRANT0Grant more credit
REDUCE1Reduce credit
PAUSE2Pause
RESUME3Resume
CONGESTION4Congestion notification

FlowUpdateBackpressureLevel(IntEnum)

MemberValueDescription
NONE0No backpressure
SOFT1Soft (advisory)
HARD2Hard (mandatory)

FlowUpdateFlags(IntFlag)

MemberMaskDescription
NONE0x00None
CREDIT_VALID0x01Credit field is valid
RETRY_AFTER_VALID0x02retry_after_ms is valid
BACKGROUND_ONLY0x04Applies only to background operations
DRAIN_IN_FLIGHT_ONLY0x08Takes effect after in-flight ops drain

Result Hint Enums

ResultHintBudgetPolicy(IntEnum)

MemberValueDescription
NONE0No suggestion
FULL1Use full budget
PARTIAL2Accept partial result
STALE_REUSE3Accept stale cache reuse
DROP4Client should drop the frame

ResultHintCongestionState(IntEnum)

MemberValueDescription
NONE0No congestion
STEADY1Steady state
ELEVATED2Elevated congestion
SATURATED3Severely saturated

ResultHintReason(IntEnum)

MemberValueDescription
NONE0None
QUEUE_FULL1Queue is full
SERVER_BUSY2Server busy
BUDGET_EXCEEDED3Budget exceeded
SUPERSEDED4Superseded by later submit

Extension Type Constants

python
# Control extension block type IDs (uint16)
CLIENT_HELLO_TRANSPORT_POLICY_EXTENSION     = 0x0101
SERVER_HELLO_ACK_TRANSPORT_POLICY_EXTENSION = 0x0102
CLIENT_HELLO_LOSS_TOLERANCE_EXTENSION       = 0x0103
SERVER_HELLO_ACK_LOSS_TOLERANCE_EXTENSION   = 0x0104
CLIENT_HELLO_PAYLOAD_CAPABILITIES_EXTENSION = 0x0105
SERVER_HELLO_ACK_PAYLOAD_CAPABILITIES_EXTENSION = 0x0106

Use-Case Guide

Scenario 1: Connecting and Negotiating Transport

Relevant enums: TransportId, TransportPolicy, LossTolerance, WireFormat

python
from nnrp import TransportId, TransportPolicy, LossTolerance
from nnrp.client import ClientProfile, ClientDialPolicy, dial_client

profile = ClientProfile(
    transport_policy=TransportPolicy.PREFER_QUIC,
    loss_tolerance=LossTolerance.LOW_LATENCY,
)
dial_policy = ClientDialPolicy(
    preferred_transport=TransportId.QUIC,
    fallback_transport=TransportId.TCP,
)
session = await dial_client("render.example.com", 4433,
                             profile=profile, dial_policy=dial_policy,
                             config=quic_cfg)

Pitfalls

  • FORCE_QUIC fails immediately in TCP-only firewalls. Use PREFER_QUIC in production.
  • LossTolerance.FIRE_AND_FORGET does not guarantee ordering. Only use it for telemetry/stats, never for the main frame submission path.
  • Always use WireFormat.CURRENT symbolically; do not hardcode 0.

Scenario 2: Submitting Frames

Relevant enums: InputProfile, SubmitMode, BudgetPolicy, PayloadKind, TileIndexMode

python
from nnrp import InputProfile, SubmitMode, BudgetPolicy, TileIndexMode
from nnrp.client import SubmitRequest, TensorSectionData

request = SubmitRequest(
    frame_id=42,
    tile_ids=(3, 7, 12),
    sections=(TensorSectionData(...),),
    input_profile=InputProfile.CHANGED_TILES_LUMA,
    submit_mode=SubmitMode.MIXED,
    budget_policy=BudgetPolicy.ALLOW_PARTIAL | BudgetPolicy.ALLOW_STALE_REUSE,
    inference_budget_ms=8,
    tile_index_mode=TileIndexMode.RAW_U16,
)
await session.submit_frame(request)

Pitfalls

  • BudgetPolicy is a bitmask (IntFlag). Combine multiple policies with |, not with commas. BudgetPolicy.NONE is strict mode.
  • SubmitMode.REFERENCE requires a prior session.put_cache() call; otherwise the server returns ErrorCode.CACHE_MISS.

Scenario 3: Handling Results

Relevant enums: ResultClass, ResultFlags

python
from nnrp import ResultClass, ResultFlags

result = await session.receive_result(frame_id=42, timeout=0.05)
match result.metadata.result_class:
    case ResultClass.COMPLETE:
        apply_full_result(result)
    case ResultClass.PARTIAL:
        apply_partial_result(result)
    case ResultClass.STALE_REUSE:
        pass  # reuse previous frame
    case ResultClass.DEGRADED:
        log_degraded(result.metadata.applied_budget_policy)

if result.metadata.result_flags & ResultFlags.FALLBACK:
    metrics.increment("degraded_fallback")

Pitfalls

  • Do not treat non-COMPLETE results as errors. STALE_REUSE and DEGRADED are normal under load.
  • ResultFlags.STALE and ResultClass.STALE_REUSE overlap in meaning but differ in granularity; prefer checking result_class in business logic.

Scenario 4: Error Handling

Relevant enums: ErrorCode, ErrorScope

python
from nnrp import ErrorCode
from nnrp.core.enums import ErrorScope
from nnrp.errors import NnrpProtocolError

try:
    await session.submit_frame(request)
except NnrpProtocolError as e:
    if e.error_scope == ErrorScope.CONNECTION:
        # Fatal — must reconnect
        await session.close()
        session = await dial_client(...)
    elif e.error_code == ErrorCode.FRAME_EXPIRED:
        pass  # skip this frame
    elif e.error_code == ErrorCode.SERVER_BUSY:
        await asyncio.sleep(0.05)  # back off

Pitfalls

  • ErrorScope.CONNECTION errors are fatal. Do not retry on the same session.
  • ErrorCode.LIMIT_EXCEEDED may be a patch rate-limit (see SessionPatchRejectReason.RATE_LIMITED), not necessarily a hardware resource exhaustion.

Scenario 5: Cache Operations

Relevant enums: CacheObjectKind, CachePutFlags, CacheAckStatus, CacheInvalidateScope

python
from nnrp import CacheObjectKind, CachePutFlags, CacheAckStatus

ack = await session.put_cache(
    kind=CacheObjectKind.TENSOR_SECTION_TABLE,
    key=b"tst-v1",
    data=payload,
    flags=CachePutFlags.PINNED | CachePutFlags.REUSABLE,
)
match ack.status:
    case CacheAckStatus.ACCEPTED: pass
    case CacheAckStatus.REJECTED: use_inline_submit = True

Pitfalls

  • PINNED objects are not subject to LRU eviction but still count against the total cache quota. Too many pinned objects will cause subsequent CACHE_PUT requests to be REJECTED.
  • CacheObjectKind.TILE_INDEX_BLOCK and TILE_INDEX_TEMPLATE are aliases (same value). Pick one and use it consistently.

Scenario 6: Flow Control and Backpressure

Relevant enums: FlowUpdateReason, FlowUpdateBackpressureLevel, FlowUpdateFlags, ResultHintCongestionState, ResultHintBudgetPolicy

python
from nnrp import ResultHintCongestionState, FlowUpdateBackpressureLevel

async def monitor_hints(session):
    async for hint in session.result_hints():
        if hint.congestion_state == ResultHintCongestionState.SATURATED:
            await session.pause_submit()
        elif hint.congestion_state == ResultHintCongestionState.NONE:
            await session.resume_submit()

Pitfalls

  • ResultHint is advisory, not a command, but ignoring SATURATED will cause the server queue to overflow, eventually triggering RESULT_DROP (server drops frames silently).
  • FlowUpdateFlags.CREDIT_VALID must be set before the credit field is meaningful.
  • FlowUpdateFlags.RETRY_AFTER_VALID must be set before retry_after_ms is meaningful; reading it unconditionally can give zero, causing no back-off.

Scenario 7: Dynamic Session Adjustment

Relevant enums: SessionPatchField, SessionPatchAckStatus, SessionPatchRejectReason

python
from nnrp import SessionPatchField, SessionPatchAckStatus

ack = await session.patch(
    fields=SessionPatchField.TARGET_CADENCE | SessionPatchField.QUALITY_TIER,
    target_cadence=30,
    quality_tier=1,
)
match ack.status:
    case SessionPatchAckStatus.ACCEPTED: pass
    case SessionPatchAckStatus.PARTIALLY_APPLIED:
        # Some fields accepted, some rejected — check ack.rejected_fields
        pass

Pitfalls

  • SessionPatchField is a bitmask. Combine fields with |; do not send multiple single-field patches (each counts against the rate limit).
  • On PARTIALLY_APPLIED, accepted fields are not rolled back. Track the effective state on the client side.

NNRP Documentation