Patch release — two correctness themes on the 0.17.0 baseline: (1) /check mints a fresh operation_id per call (the previous behaviour — reuse the first call's op_id within the same scope — collided with the backend's IDEM-01 11-field semantic-hash dedup whenever a second /check had a different tools / model / input, surfacing as a 409 IDEMPOTENCY_KEY_MISMATCH and the misleading SDK error NR-B004 "You've reached the usage limit for this conversation"), and (2) _V3_ERROR_CODE_MAP closes the wire-code gap from backend fix-wave-2 (the two NEW wire codes — INVALID_JSON (400, invalid_json slug, JsonSyntaxError) and INVALID_FIELD (422, validation_error slug, JsonDataError) — now round-trip through NullRunBackendError instead of falling through to the generic transport fallback at transport.py:2961). No behaviour change for code that already handles NullRunBackendError; cookbook recipes that branch on error_code now retain diagnostic class for parse-level vs schema-level rejections. Wire-format unchanged. SDK_MIN_VERSION unchanged.
-
DEF-OPID-REUSE-HASH-MISMATCH —
NullRunRuntime._check_workflow_budget_implnow always mints a freshoperation_idper/checkcall (src/nullrun/runtime.py,a05726e). Pre-fix the helper read_operation_id_varonce and stashed the minted UUID v4 into the contextvar; subsequent/checkcalls within the same scope reused the first call's op_id. The backend'sIDEM-01dedup (compute_gate_semantic_hashinbackend/src/redis/idempotency_store.rs:125-140) keys onoperation_idbut verifies an 11-field semantic hash (operation_id,tools,tool,mode,check_type,model,estimated_tokens,input,business_impact,workflow_id,organization_id); a second/checkwith differenttools/model/inputon the SAMEop_idtherefore 409IDEMPOTENCY_KEY_MISMATCH, surfaced asNR-B004in the SDK. Canonical repro:nullrun_openai_approval_demo.pyfires atools=None/gate(LangGraphNullRunCallback.on_llm_start) BEFORE the@sensitive(refund_customer)/gate(tools=['refund_customer']); both/checkcalls share the same op_id, the second's semantic hash diverges from the first's, server rejects with 409, SDK reportsNR-B004"You've reached the usage limit for this conversation". Fix:/checkalways reads-and-discards the contextvar (value unused), then unconditionally mints a new UUID v4 and stashes it./executeatruntime.py:3048-3051reads the freshly-stashed value within the same logical action (synchronous/check→/executechain), so the P0-27 within-action binding (one op_id across/check+/execute) is preserved. The read-then-overwrite pattern also keeps the P0-27 source-pin testtest_check_workflow_budget_reads_contextvargreen. Verified: 8/8 P0-27 source-pin tests pass (test_audit_p0_27_operation_id_hoist.py); 1807 pytest pass / 4 skipped / 0 fail (full SDK suite); live probe (probe_full.py) emits 4 distinct operation_ids across 3/check+ 1/execute;/executefallback mint pattern unchanged (read contextvar first, mint only if None);_GATE_CACHEinvariant unaffected (cache key doesn't include op_id); backendIDEM-01logic unchanged (compute_gate_semantic_hashunaffected). -
DEF-SDKT-004 fix-wave-2 —
_V3_ERROR_CODE_MAPnow contains entries forINVALID_JSONandINVALID_FIELD(src/nullrun/transport.py,f5aca80). Backendfix-wave-2(2026-09-13) splitFrom<JsonRejection> for ApiErroronto three distinct wire codes:JsonDataError→ 422 +INVALID_FIELD(slugvalidation_error),JsonSyntaxError→ 400 +INVALID_JSON(sluginvalid_json),MissingJsonContentType→ 415 +INVALID_INPUT(slugbad_request). The two NEW codes (INVALID_FIELD,INVALID_JSON) are emitted on/gate,/execute, and/track. Pre-fix the SDK's_V3_ERROR_CODE_MAPhad no entries for them, so they fell through to the genericNullRunBackendErrorfallback attransport.py:2961; cookbook recipes that branch onerror_codelost diagnostic class for parse-level vs schema-level rejections. Map both toNullRunBackendError— siblings toEXECUTION_ID_MALFORMED,EXECUTION_ID_REQUIRED,INVALID_EXECUTION_ID, andIDEMPOTENCY_REDIS_UNAVAILABLEwhich already follow the same pattern for wire-shape parsing failures. This mirrors the backend's intent: wire-level parsing failures are infrastructure-side issues and the SDK round-trips them through the generic catch-all. The new wire codes are exercised in:/gatePOST body rejection (gate.rs);/executePOST body rejection (execute.rs);/trackPOST body rejection (handlers.rs);TC-SDKG-006(truncated JSON) expects 400 +INVALID_JSON. NR-007a (new) atbackend/tests/nr007_sdk_error_code_parity.rspins the required SDK mappings and will fail CI on future drift (e.g., if someone revertsINVALID_JSONfrom this map).
ruff check src tests— all checks passed.mypy src/nullrun— success: no issues found in 37 source files.pytest -q— 1807 passed, 4 skipped in ~102s (no new tests — both fixes fold into existing coverage; baseline 1807 at 0.17.0).nullrun.__version__—0.17.1.- Scratch diff — clean (no
dist_local/, no*.defect*).
op_id reuse (DEF-OPID-REUSE-HASH-MISMATCH) — pre-fix the SDK reused the first /check's op_id for every subsequent /check in the same scope. The backend's IDEM-01 dedup keys on op_id but verifies an 11-field semantic hash; any divergence (different tools, model, input) on the SAME op_id produces a 409 that surfaces to the SDK as NR-B004 "You've reached the usage limit for this conversation" — a wildly misleading message for what is actually a per-call idempotency violation. This is a recurring foot-gun rather than an active bypass: most agent loops issue /check calls with the same tool / model / input on the same op_id and never trip the dedup, but the moment a second call diverges (very common — LangGraph fires a tools=None gate before the tool-scoped @sensitive gate; multi-tool agents fire distinct tool gates per tool), the dedup fires and the SDK reports a usage-limit error that has nothing to do with the actual budget. The fix collapses op_id scope from "scope" to "single /check invocation", mirroring the backend's invariant that op_id is per-call, not per-scope. /execute continues to read the freshly-stashed op_id within the same logical action so the P0-27 within-action binding (/check + /execute share op_id) is preserved — verified by the source-pin regression tests at tests/test_audit_p0_27_operation_id_hoist.py.
Error-code map closure (DEF-SDKT-004 fix-wave-2) — the backend's fix-wave-2 split From<JsonRejection> for ApiError onto three distinct wire codes so operators can distinguish JsonDataError (422 schema-level) from JsonSyntaxError (400 parse-level) from MissingJsonContentType (415 missing-content-type). The SDK's _V3_ERROR_CODE_MAP is the single point of truth for "what exception class does the SDK raise when the backend returns this error_code". Pre-fix the map covered the legacy wire codes (EXECUTION_ID_MALFORMED, EXECUTION_ID_REQUIRED, INVALID_EXECUTION_ID, IDEMPOTENCY_REDIS_UNAVAILABLE) but did not cover the two NEW codes from the backend split, so they fell through to the generic NullRunBackendError fallback at transport.py:2961. Cookbook recipes that branch on error_code (e.g., to retry on schema-level but not parse-level rejections) lost diagnostic class. The fix maps both new codes to NullRunBackendError — the same exception class used for the legacy wire-shape parsing failures, matching the backend's intent that wire-level parsing failures are infrastructure-side issues. NR-007a (new) at backend/tests/nr007_sdk_error_code_parity.rs pins the required SDK mappings so any future revert (e.g., removing INVALID_JSON from the map) fails CI on the SDK side.
Minor release — four correctness themes on the 0.16.x baseline: (1) chain-setter Token discipline (set_chain_id / set_chain_op now return the Token minted by ContextVar.set(), matching the rest of the manual-setter surface — silent audit-trail bleed across calls is closed), (2) _GATE_CACHE staleness closure (invalidate the gate cache on consume-side 402/422 + on chain_end so a stale "allow" cannot serve un-budgeted tool execution within the 5s cache window), (3) lazy-export repair (nullrun.money_outflow, nullrun.tool_params, nullrun.business_impact are now reachable as attributes on nullrun — the documented @nullrun.sensitive(impact=money_outflow(...)) pattern no longer crashes with AttributeError), and (4) circuit-breaker lock unification (sync + async paths now serialise on a single threading.Lock, closing a sync↔async race that let self._state mutate concurrently when one thread called breaker.call(sync_fn) and another coroutine called await breaker.call(async_fn)). Behaviour change for callers using the manual set_chain_id / set_chain_op escape-hatch — the return value is now a Token, not None. Wire-format unchanged. SDK_MIN_VERSION unchanged.
-
DEF-CHAIN-SETTER-NO-TOKEN —
nullrun.set_chain_id(chain_id)andnullrun.set_chain_op(op)now return theTokenminted by the underlyingContextVar.set()call (src/nullrun/__init__.py,src/nullrun/context.py,8e7e070). Mirrors the existing discipline onset_trace_id/set_span_id/set_operation_id/set_server_minted_execution_id. Callers using the manual-setter API outside thewith chain(...)contextmanager can now restore the prior value viactx.reset(token), closing the silent audit-trail bleed where chain_id attribution leaked forward into subsequent unrelated/checkcalls on the same event-loop task slot. Docstrings updated to call out the Token contract.Back-compat: callers that ignored the previous
Nonereturn continue to work; the only observable change is the newTokenreturn value (assignable to a local variable). Recurring foot-gun, not an active bypass — CPython asyncio ContextVar is per-task, so cross-task leak requires unusual patterns (asyncio.shield + manual context copy); only the manual-setter escape-hatch path was affected. Also tightens_LAZY_EXPORTSdict annotation fromtuple[str, str]totuple[str, str | None]and branches__import__(...)on theattr_namesentinel — both pre-existing mypy errors surfaced after the Token discipline fix was added. -
DEF-CACHE-STALE-ALLOW-AFTER-OVERBUDGET —
_route_tracknow calls_invalidate_gate_cache_for_chain(workflow_id, chain_id)whentrack_singleraisesHTTPStatusError(402)orHTTPStatusError(422)(src/nullrun/runtime.py,f40b5cf). The server's authoritative budget check has just said no; the in-process gate cache can no longer serve a stale "allow" for up to 5 s after that decision.chain_end()also invalidates after the wire call succeeds — the chain is closed on the server, the in-process cache for that chain is no longer reachable. Cache key now includesestimated_tokens(currently always 1 incheck_workflow_budget) to future-proof against a refactor that varies cost estimates by call (DEF-CACHE-COST-ESTIMATE-COLLISION).Failure scenario (pre-fix): agent in a tight
for tool in chainloop hammerscall_model="gpt-4"; budget red-lines att=0; the next/gatein the same chain within 5 s returns the cached allow without re-hitting the server; the tool executes un-budgeted; the consume on the next iteration hitsCONSUME_OVERBUDGET. Post-fix the cache is invalidated on the 402/422, so the next/gatere-runs the budget check and gets the fresh rejection. Luareserve_v3.lua:306-333already enforces chain state correctly (backendfix-consume-binding-org-key-mismatch); this commit is the SDK-side analog. -
DEF-CACHE-CHAIN-INVALIDATION-SCOPE — correctness followup to
DEF-CACHE-STALE-ALLOW-AFTER-OVERBUDGET:_invalidate_gate_cache_for_chainnow readschain_idfrom the contextvar (viaget_chain_id()) rather than fromwire_event.get('chain_id')(src/nullrun/runtime.py,18f4bda). Thewire_eventdict is the per-call track payload built from_enrich_event;chain_idis never populated there. Pre-fix the helper passedchain_id=Noneto the dict-iteration loop and dropped EVERY chain entry for the sameworkflow_id— safe in the sense that stale-allow wasn't served (the parent fix holds), but it leaked cache pressure onto unrelated chains under sustained traffic and made the cache effectively useless when multiple chains share aworkflow_id. Post-fix mirrors the read pattern incheck_workflow_budget(runtime.py:2013) andchain_end(runtime.py:2507 via get_trace_id). -
DEF-LAZYEXPORT-MONEY-TOOL-PARAMS —
nullrun.money_outflowandnullrun.tool_paramsare now reachable as top-level attributes onnullrun(src/nullrun/__init__.py,b977537). The documented@nullrun.sensitive(impact=money_outflow(...))pattern (referenced atdecorators.py:1113-1132,extractor.py:43) crashed withAttributeError: module 'nullrun' has no attribute 'money_outflow'on first invocation —__getattr__masked any name not in_LAZY_EXPORTS, and the two impact-extractor helpers were never added to the table. Workaroundfrom nullrun.extractor import money_outflowstill works. -
DEF-LAZYEXPORT-BUSINESS-IMPACT —
nullrun.business_impactis now reachable as a submodule attribute onnullrun(src/nullrun/__init__.py,6601208). The docstrings atextractor.py:18andextractor.py:799-801referencenullrun.business_impact.compute_action_digestandToolCallParamsas bare dotted paths. The module is real (nullrun/business_impact.py) and contains those symbols, but PEP 562__getattr__masked submodule access —nullrun.business_impactraisedAttributeErrorfrom a fresh import even thoughimport nullrun.business_impactworked. Fix addsbusiness_impactto_LAZY_EXPORTSwithattr_name=Nonesentinel;__getattr__returns the imported module itself instead ofgetattr(module, attr_name). No-op for existing per-symbol re-exports (money_outflow,tool_params) — the sentinel branch only fires whenattr_name is None.Post-fix probe:
>>> nullrun.business_impact.compute_action_digest <function compute_action_digest at 0x...>
-
DEF-CB-LOCK-UNIFICATION-2026-09-12 —
NullRunCircuitBreakernow serialises sync + async critical sections on a singlethreading.Lock(src/nullrun/breaker/circuit_breaker.py,77bf38b). Pre-fix the sync path heldself._lock(threading.Lock) and the async path held a separateasyncio.Lock(_async_lock, lazy-init via_get_async_lock); on the same breaker instance a sync thread callingbreaker.call(sync_fn, ...)and an async coroutine callingawait breaker.call(async_fn, ...)could both writeself._stateconcurrently — the two locks provided no mutual exclusion across the sync↔async boundary. The async critical sections (_on_failure_async,_on_success_async) contain noawaitbetween attribute writes; with asyncio's single-threaded execution model those sections are already atomic under the GIL+scheduler — the_async_lockwas dead weight providing no additional exclusion. Fix: removed_async_lockand_get_async_lock; both paths now useself._lock.async with self._lockblocks the event loop for zero observable time on the happy path (noawaitinside the critical section). Trade-off: sync+async exclusion > minor event-loop contention under high contention (zero under normal traffic). Closes the silentself._statewrite race that could let a thread observe a half-updated breaker state — under a tight async loop with one stray sync caller this manifests as flakybreaker.callreturns (one path thinks the breaker is open, the other thinks it's half-open).
tests/test_v3_wire_contract.py::TestGateCache::test_invalidate_drops_only_matching_chain(18f4bda). Regression pin forDEF-CACHE-CHAIN-INVALIDATION-SCOPE: sets two cache entries for the sameworkflow_idbut differentchain_ids, marks one chain overbudget, and asserts only the overbudget chain's entry is dropped. Forbids re-introducing the pre-fixwire_event.get('chain_id')lookup that silently passedchain_id=Noneand dropped every chain.tests/test_v3_wire_contract.pytest updates forDEF-CACHE-STALE-ALLOW-AFTER-OVERBUDGET(f40b5cf): existing cache tests now use 4-tuple keys (workflow_id,chain_id,call_model,estimated_tokens) — theestimated_tokensarm was added in the same commit and is a future-proofing pin.tests/test_circuit_breaker_branches.py— 10 new branch tests forDEF-CB-LOCK-UNIFICATION-2026-09-12(77bf38b): covers both the sync and asyncbreaker.callpaths through a singlethreading.Lock(state transitions, failure-count accumulation, half-open probe, open→closed reset on success, async-context contention with the same shared lock). Pins that no future refactor can re-introduce a separate_async_lockwithout tripping these tests.
ruff check src tests— all checks passed.mypy src/nullrun— success: no issues found in 37 source files.pytest -q— 1807 passed, 4 skipped in ~102s (10 new tests fromDEF-CB-LOCK-UNIFICATION-2026-09-12circuit-breaker branch coverage — baseline 1797 at 0.16.8).nullrun.__version__—0.17.0.- Scratch diff — clean (no
dist_local/, no*.defect*).
Token discipline (DEF-CHAIN-SETTER-NO-TOKEN) — pre-fix both setters did return None after calling the contextvar's set(), breaking the Token discipline every other setter in the module honours. Callers using the manual API outside the with chain(...) contextmanager could not restore the prior value via ctx.reset(token), so the chain_id leaked forward into subsequent unrelated /check calls on the same event-loop task slot — silent audit-trail corruption (chain_id attribution bleeds across calls). The leak is a recurring foot-gun rather than an active bypass (CPython asyncio ContextVar is per-task), but the manual-setter escape hatch is documented and used; the fix brings the API surface in line with the rest of the setter family.
Cache staleness (DEF-CACHE-STALE-ALLOW-AFTER-OVERBUDGET) — at anti-DoS scale, every cached "allow" served after the budget red-line is a tool execution that bypasses the gate. The 5-second cache TTL amplifies this: a single tight loop on call_model="gpt-4" can consume thousands of tool invocations against a budget the server already said no to. The fix collapses the cache-staleness window to "synchronous invalidation on 402/422" (~ms), matching the reserve_v3.lua defense-in-depth on the consume side.
Chain-scope invalidation (DEF-CACHE-CHAIN-INVALIDATION-SCOPE) — pre-fix the helper matched on chain_id=None and dropped every chain entry for the workflow, making the cache effectively useless under multi-chain traffic. This wasn't an active bypass (the parent fix holds), but it meant operators under load saw cache eviction across unrelated chains whenever one chain hit 402/422. Surfaced 2026-09-12 by post-DEF-CACHE-STALE-ALLOW-AFTER-OVERBUDGET code review: the wire-event lookup was the kind of mistake that's invisible under single-chain testing but devastating in production.
Lazy exports (DEF-LAZYEXPORT-MONEY-TOOL-PARAMS + DEF-LAZYEXPORT-BUSINESS-IMPACT) — the documented @nullrun.sensitive(impact=money_outflow(...)) pattern is the headline use-case for @sensitive decoration, so crashing with AttributeError on first invocation is a textbook "the documented example doesn't work" regression. The business_impact submodule crash was similar: docstring-referenced dotted paths resolved to AttributeError. Both are pre-existing typing-errors that became loud after the PEP 562 lazy-export pattern was introduced (money_outflow / tool_params found via TC-12 strict verification 2026-09-12 against prod; business_impact found via the docstring-referenced path audit).
Circuit-breaker lock unification (DEF-CB-LOCK-UNIFICATION-2026-09-12) — pre-fix the breaker held self._lock (threading.Lock) for the sync path and _async_lock (asyncio.Lock) for the async path, with no cross-path exclusion. Under a mixed sync+async workload (sync thread + async loop on the same breaker instance — common in HTTP servers where a worker thread guards against an outage while the event loop is forwarding the same breaker state to inbound WebSocket frames), self._state could mutate concurrently: one path read state="half_open" and started the probe; the other wrote state="open" after a failure; the probe saw a half-updated state and either double-allowed (open→closed transition observed in the gap) or never reset. Both failure modes are silent — no exception, just wrong breaker decisions on a fraction of calls. The async critical sections contain zero await calls (state writes only), so asyncio's single-threaded scheduler already serialises them; the _async_lock was dead weight. Unifying on threading.Lock for both paths costs nothing on the happy path (no event-loop blocking, since there's no await in the section) and gives sync↔async exclusion for free. Surfaced 2026-09-12 by a code-review pass on the v0.17.0 theme set.
Patch release — closes the NR-A015 wire-shape gap on the SDK side. The
/execute require_approval arm (backend v3.79+) mints a fresh
server-side execution_id for the approval row and echoes it via
reservation_id. Pre-fix runtime.execute captured that id into the
contextvar AFTER /gate calls but not after /execute, so the post-
approval /execute re-fire sent the stale pre-arm execution_id;
consume_approved's WHERE execution_id = $3 predicate missed the
freshly-stamped row and fell through to the terminal
APPROVAL_REPLAY_REJECTED branch. This release wires the
post-/execute capture and syncs the kwargs dict so the re-fire uses
the freshly-minted id.
Also includes the AUTH-01 / HEART-01 sweep from the 24-driver pass:
reclassification of httpx transport errors on the auth path, plus a
public Runtime.heartbeat() wrapper.
-
DEF-EXECUTE-CAPTURE-WIRING —
runtime.executenow calls_capture_server_minted_execution_id(result)immediately after_transport.execute(...)and syncs the re-fire kwargs dict to the captured id (src/nullrun/runtime.py). The post-approval re-fire now sends the freshly-minted execution_id stamped on the approval row, soconsume_approved'sWHERE execution_id = $3predicate matches. Closes the SDK-side leg of NR-A015 on the/executerequire_approval arm. -
DEF-WAIT-FOR-APPROVAL-EXEC-ID — both
_wait_for_approval_resolutioncall-sites (check_workflow_budgetruntime.execute) now pass the captured server-minted execution_id from the contextvar (with the priororg_id/workflow_idsentinel as fallback) instead of theworkflow_idsentinel (src/nullrun/runtime.py). Diagnostic improvement only — the WS handler matches onapproval_id— but log lines + entry metadata now reflect the server-minted id.
-
DEF-AUTH-01 —
NullRunRuntime.__init__auth path no longer reclassifieshttpx.RequestErrorasNullRunAuthenticationError. The defensive duplicate arm in__init__(backstop for a code path that no longer exists) is removed; the real arm in_authenticatenow raisesNullRunTransportError(source=NETWORK_ERROR, endpoint="auth")— matching the convention used byTransport.heartbeatfor the same condition on/heartbeat. The previous wrap misled operators: a network failure looked like an auth failure, even though the message itself acknowledged "this is a transport failure (not an auth failure)".Back-compat:
NullRunTransportErrorandNullRunAuthenticationErrorare siblings underNullRunInfrastructureError, so the parent class still catches both. Cookbook code that branches onexcept NullRunAuthenticationError:for retry will need to also catchNullRunTransportError. Two existing tests (test_authenticate_network_error_raisesintest_runtime.pyandtest_runtime_branches.py) were locking in the old misclassification and have been updated to assert the correct class.
-
DEF-HEART-01 —
NullRunRuntime.heartbeat(chain_id)public method added (thin forwarder toTransport.heartbeat). Mirrors thechain_end/cancel_executionpattern. Use for single-shot chain TTL extensions;Runtime.ping_chain()remains the wall-clock scheduler variant. Pure addition — no existing API surface changes. -
tests/test_2026_09_11_execute_capture_wires_execution_id.py(220 lines). Two regression tests pinning the fix:test_execute_captures_reservation_id_from_response— verifies the contextvar updates from the/executeresponse and the re-fire uses the captured id (not the stale pre-call one).test_execute_wait_for_approval_receives_captured_eid— verifies the WS resolution handler receives the captured execution_id.
-
tests/test_2026_09_11_auth_heartbeat_sweep.py(~190 lines, 7 tests). Regression tests for AUTH-01 + HEART-01:- AUTH-01:
test_auth_connect_error_raises_transport_error_not_auth,test_auth_timeout_raises_transport_error_not_auth,test_auth_error_class_no_longer_catches_network_error(back-compat parent-class check). - HEART-01:
test_heartbeat_method_exists_on_public_api,test_heartbeat_forwards_chain_id_to_transport,test_heartbeat_passes_through_transport_error,test_ping_chain_still_works_after_heartbeat_added.
- AUTH-01:
Pure reliability fix — no wire-format change. /gate, /execute,
/track, /cancel payloads are byte-identical to 0.16.7. Backend
v3.79+ is required for the wire-shape contract (the reservation_id
echo is the v3.79+ field that closes the gap); pre-v3.79 backends
silently fall through the capture (helper is fail-OPEN on malformed
values), preserving the pre-fix behaviour for un-deployed backends.
NR-A015 (execute capture) — the user-facing symptom was a
post-approval /execute re-fire landing on APPROVAL_REPLAY_REJECTED
because the SDK stamped the pre-arm execution_id into the
re-fire's kwargs dict, but consume_approved's WHERE execution_id = $3 predicate had to match the freshly-minted id from the
approval-row bind (backend v3.79+). The terminal error was a
typed NullRunApprovalReplayRejectedError(NR-A015) — operators had
no signal that the re-fire was sending a stale id rather than a
truly-replayed call. 0.16.8 captures the reservation_id echo
from /execute's response into the same contextvar that /gate
already uses, and re-emits the captured id on the re-fire kwargs
dict.
AUTH-01 (transport reclassification) — operators reading
NullRunAuthenticationError from a failed __init__ were led to
rotate the API key because the class name suggested auth failure.
Pre-fix, the duplicate arm in NullRunRuntime.__init__ rewrapped
httpx.RequestError as NullRunAuthenticationError (with the
"this is a transport failure (not an auth failure)" wording in the
message itself — a smoke signal the wrap was wrong). 0.16.8 raises
NullRunTransportError(source=NETWORK_ERROR, endpoint="auth")
matching the Transport.heartbeat convention. Catch-block semantics
in cookbooks now need except (NullRunAuthenticationError, NullRunTransportError): for full coverage under
NullRunInfrastructureError.
HEART-01 (public API) — single-shot chain TTL extensions had to
reach through runtime._transport.heartbeat(...) because
NullRunRuntime exposed only the wall-clock ping_chain() scheduler.
0.16.8 adds NullRunRuntime.heartbeat(chain_id) as a thin
forwarder to Transport.heartbeat, matching the chain_end /
cancel_execution pattern.
Patch release — closes the typed-exception / catalog-coverage gaps surfaced by the 0.16.6 backend hardening. After that release, every catalog exception the SDK can raise now has a hand-written DEFAULT_MESSAGES entry (no more "Something went wrong. Please try again." fallback), and @protect-decorated sites surface the real exception type instead of rewriting it into a generic NullRunBlockedException. The @protect block path in runtime.execute now dispatches the actual catalog code through format_user_message, so wire-error codes (NR-A012, NR-A016, NR-EX01, …) reach users with actionable wording. No wire-format change.
- DEFS-SDKEXEC-TYPED-DISPATCH —
runtime.executeblock path raises the catalog exception itself (NR-A016 etc.) instead of the generic fallback (src/nullrun/runtime.py,2e77902).exc.error_codecarries the catalog code, soformat_user_messagefinds actionable wording; downstream sites that inspectexc.details['details']['mapped_class']see the typed class name (e.g.NullRunApprovalDbUnavailableError) rather than the baseNullRunBlockedException. - DEFS-SDKEXEC-BLOCK-PIN —
tests/test_runtime.py::test_execute_blocked_surfaces_wire_error_codepinned to the new typed-dispatch contract (834d9ea,DEF-NR-RUNTIME-BLOCK-TYPED): the wire payload (error_code+mapped_class) is preserved verbatim while the SDK exception is now the typed class. This was the last stale wire-code assertion intest_runtime.pyblocking full SDK pass under the post-0.16.6 catalog contract. - DEFS-SDKPROTECT-EX01-PASSTHROUGH —
@protect-decorated_enforce_sensitive_toolno longer rewritesNullRunExecutionNotFoundError(NR-EX01) intoNullRunBlockedException(NR-B002)(src/nullrun/decorators.py,257ab7f). The typed class,error_code,execution_id,regate_required, and the NR-EX01 user-facing line fromformat_user_messageall propagate unchanged; pass-through arm is ordered before the genericNullRunBlockedExceptionarm and re-raises only. - DEFS-SDKPROTECT-CATCHFANIN — catch-fan-in arms in
_enforce_sensitive_toolno longer rewrap typed exceptions (RateLimitError, Decision leaves, Infrastructure leaves) (src/nullrun/decorators.py,2ad87dd). Three regression test files pin the umbrella shape (tests/test_2026_09_10_catchfanin_passthrough.py,tests/test_2026_09_10_decision_infra_passthrough.py,tests/test_2026_09_10_r001_passthrough.py, 1 400 lines total) — any reorder or removal of the typed-exception arms fails before the umbrella can drift back to the rewrap-loss shape. - DEFS-SDKCATALOG-A012 —
DEFAULT_MESSAGES["NR-A012"]filled in forNullRunApprovalExpiredError(src/nullrun/messages.py,a4c6019); tests intests/test_typed_exceptions_full_audit.pyandtests/test_messages.pycover the new entry. Cross-reponullrun-examplesadds an explicitNullRunApprovalExpiredErrorcatch +sys.exit(2)inlanggraph_openai_approval_demo.pyso CI can branch on "approval expired" (exit 2) vs "any other failure" (exit 1). - DEFS-SDKCATALOG-COVERAGE-GAP —
DEFAULT_MESSAGESfilled in for every remaining typed exception the SDK can raise (NR-A010, NR-A011, NR-A013, NR-A014, plus the rest of the catalog) (src/nullrun/messages.py,a441558, 68 lines added). 170 lines of regression coverage intests/test_messages.py. Closes the catalog-coverage gap that 0.16.6'stest_typed_exceptions_full_audit.pyaudit flagged as "fallback to FALLBACK_MESSAGE". - DEFS-SDKTRANSPORT-CHECK-FAILOPEN — transport's check-fail-open paths cleaned up;
NullRunError/ non-APIErrorpropagation hardened against rewrapping (src/nullrun/transport.py,25eb2c2,b7575ad,bb1066c). Newtests/test_2026_09_10_check_failopen.py(330 lines),tests/test_2026_09_10_mcp_umbrella_symmetry.py(364 lines),tests/test_2026_09_10_sdk_cleanup.py(311 lines) lock the new transport shape.
tests/test_2026_09_10_runtime_block_typed_dispatch.py(356 lines,2e77902). 11 source-pin + behavioural tests assertingruntime.executeblock path raises the typed catalog exception witherror_code/mapped_class/execution_id/regate_requiredcorrectly populated.tests/test_2026_09_10_nr_ex01_passthrough.py(312 lines,257ab7f). 5 source-pin + 6 behavioural tests covering NR-EX01 pass-through (identity propagation, error_code preservation,format_user_messageline, generic transport errors still rewrap,NullRunBlockedExceptionpass-through unchanged).tests/test_2026_09_10_catchfanin_passthrough.py(561 lines,2ad87dd),tests/test_2026_09_10_decision_infra_passthrough.py(448 lines),tests/test_2026_09_10_r001_passthrough.py(391 lines). Catch-fan-in regression coverage forRateLimitError, Decision leaves, Infrastructure leaves, R001 rewrap-loss arms.tests/test_2026_09_10_toolblocked_parser.py(399 lines,2dfd208). Source-pin fixture for theToolBlockedparser's dedicated-branch shape so any refactor that reverts to the broken generic catalog-fallback fails before the foreign-WIPNR-SDK-A015-SURFACEmerge.tests/test_2026_09_10_check_failopen.py/tests/test_2026_09_10_mcp_umbrella_symmetry.py/tests/test_2026_09_10_sdk_cleanup.py(1 005 lines combined). Transport-cleanup regression coverage for25eb2c2/b7575ad/bb1066c.
dist_local/nullrun-0.16.7-py3-none-any.whl(305 KB pre-built wheel) andsrc/nullrun/transport.py.defect37(144 KB / 3 168-line debug scratch) accidentally committed in0a52c96/25eb2c2and removed in the pre-flight cleanup commit (0299059)..gitignoreextended withdist_local/andsrc/**/*.defect*to prevent re-introduction.
Pure reliability fixes — no wire-format change. /gate, /execute, /track, /cancel payloads are byte-identical to 0.16.6. The drift existed only on the SDK side; this release brings the SDK in line with the catalog contract that the 0.16.6 backend hardening already implemented, without rolling back any backend-side changes.
Typed dispatch — the user-facing symptom was that @protect-decorated sites saw Workflow <id> blocked: Something went wrong. Please try again. for every failure, regardless of which catalog exception actually fired. Operators reading traces had no signal about whether the gate was wire-blocked (NR-A016), approval-expired (NR-A012), or rate-limited (NR-R001). 0.16.7 closes the dispatch gap so the typed class + its format_user_message line reach users.
Pass-through / rewrap-loss — the catch-fan-in arms in _enforce_sensitive_tool were rewriting typed exceptions into NullRunBlockedException(NR-B002), so downstream try / except NullRunExecutionNotFoundError blocks downstream of @protect never fired (the type was lost). 0.16.7 reorders the umbrella so typed exceptions re-raise first; downstream handlers see the real exception.
Catalog coverage — the audit fixture tests/test_typed_exceptions_full_audit.py (introduced 0.16.6) flagged 13 catalog codes that fell through to FALLBACK_MESSAGE. 0.16.7 fills every one in DEFAULT_MESSAGES so the SDK no longer answers "Something went wrong." to codes it knows about.
Patch release — closes the SDK↔backend drift introduced by backend DEF-SDKK-022-EXEC-BYPASS (2026-09-04, RUN_ID=20260904T1500). After that backend fix, /api/v1/execute runs an execution:{id} ownership-binding existence check and returns 404 EXECUTION_NOT_FOUND for any execution_id that was not minted by a prior /api/v1/gate. The SDK's runtime.execute() had been minting a fresh uuid7_str() regardless of prior /gate, so every @protect @sensitive call returned 404 ("Gateway returned 404") and the displayed workflow_id was the misleading __nullrun_unknown__ sentinel. LangGraph's NullRunCallback.on_llm_start had the symmetric problem on the LLM span side: it fired llm_call cost events with no paired /gate reservation, so the runtime's _route_track silently dropped them. This release closes all three holes. No wire-format change.
- DEFS-SDKEXEC-GATE-FIRST —
runtime.execute()reuses the server-minted execution_id from_server_minted_execution_id_varwhen a prior/gateminted it (src/nullrun/runtime.py:2820+). Pre-fix minteduuid7_str()unconditionally; post-fix reads the contextvar (set bycheck_workflow_budget's_capture_server_minted_execution_idfrom the/gateresponse'sreservation_idfield) and only mints fresh when the contextvar is empty (direct callers without a prior/gate, which is a wire-contract violation the backend's 404 handles correctly). Comment block at the fix site names both DEFS-SDKEXEC-GATE-FIRST and DEF-SDKK-022-EXEC-BYPASS so future readers see the round-trip contract without searching. - DEFS-SDKEXEC-WORKFLOW-LABEL —
_enforce_sensitive_tooldisplays the API key's bound workflow viaruntime._resolve_workflow_id(get_workflow_id())instead of the literal__nullrun_unknown__sentinel (src/nullrun/decorators.py). The wire still carries the same workflow_id (server-side binding); only the displayed label changes. Two sites updated (extract failure path + main path). - DEFS-SDKEXEC-LLM-RESERVATION —
NullRunCallback.on_llm_start(src/nullrun/instrumentation/langgraph.py) firesruntime.check_workflow_budget()(fail-OPEN) so the matchingon_llm_endllm_callcost event has a server-minted reservation_id and routes via/track_singleinstead of being dropped byruntime._route_track(the WARNING log "dropping llm_call event — no server-minted reservation_id in scope"). The call is wrapped inexcept BaseExceptionso a backend outage orWorkflowKilledInterrupt/WorkflowPausedExceptionnever breaks the LangChain callback contract. Transport.executedocstring (src/nullrun/transport.py) — rewrites the misleading pre-2026-09-04 claim ("/execute MUST be called rather than /gate") to reflect the post-DEF-SDKK-022-EXEC-BYPASS contract ("/execute MUST be preceded by /gate for the same execution_id"). Names both fix tags so the contract is grep-able.
tests/test_2026_09_08_gate_first_execute.py(9 tests). Source-pin regression for all three fixes:runtime.execute()readsget_server_minted_execution_id()and reuses it when present (forbids re-introducing an unconditionaluuid7_str()mint outside the fallback arm)._enforce_sensitive_tooldisplays viaruntime._resolve_workflow_id(...)(forbids the pre-fix contextvar-only fallback).Transport.executedocstring references the post-fix contract (forbids the legacy misleading claim).NullRunCallback.on_llm_startcallscheck_workflow_budget()with a never-raise guard.- Contextvar round-trip sanity (
set_server_minted_execution_id/get_server_minted_execution_id).
Pure reliability fixes — no wire-format change. /gate, /execute, /track, /cancel payloads are byte-identical to 0.16.5. The drift existed only on the SDK side; this release brings the SDK in line with the backend's 2026-09-04 contract without rolling back any backend-side hardening.
Gate-first — the user-facing symptom was that langgraph_openai_approval_demo.py (and any @protect @sensitive decorator that was actually wired through runtime.execute()) returned Workflow __nullrun_unknown__ blocked: Gateway returned 404 for every call, with action=block, status_code=None. The approval rule never had a chance to fire because the 404 was raised on the existence-of-binding check before the policy engine ran. The 0.12.0 SDK had been silently broken against post-2026-09-04 backends for the entire /execute path; this release closes the four-day window of broken /execute behaviour.
Workflow label — __nullrun_unknown__ was misleading because the SDK did know the workflow (the API key's binding) but only read the contextvar (which was unset on bare @protect calls). The displayed label was wrong; the wire was right. Operators reading traces had no signal that the gate had, in fact, scoped the call to a real workflow.
LLM reservation — LangGraph's NullRunCallback emits LLM cost events from the LangChain callback hooks. These have no @protect scope and therefore no paired /gate. The runtime's _route_track (which since v0.16.0 / 2026-08-20 backend v3.66.2 alignment refuses to fall back to /track/batch for llm_call events without a reservation) dropped them with a WARNING log. Cost attribution for agentic LLM loops was silently incomplete. The fix fires /gate once per LLM span (fail-OPEN; same wire-call shape as @protect), so cost attribution completes via the v3 /track_single path.
Patch release — two independent reliability fixes: (1) @protect cancel-on-exception orphan leak (Redis reservation leak on tool exceptions), (2) P0-26+P0-27 operation_id hoist (single-source mint, server-vs-SDK divergence detection). No wire-format change on either fix.
@protectcancel-on-exception orphan leak (src/nullrun/decorators.py). Bothasync_wrapperandsync_wrappernow wrap the with-block in a try/except; on failure,_safe_cancel_active_execution(reason="tool_exception")closes the in-flight/gatereservation so the budget envelope is released immediately rather than waiting on TTL expiry. Three invariant pins:- Asymmetry on exception scope.
async_wrappercatchesException, NOTBaseException—asyncio.CancelledError,KeyboardInterrupt, andSystemExitpropagate without doing a synchronous blocking HTTP call inside a cancellation handler. That call has a 5s timeout; inside a cancellation handler it would (a) delay task cancellation by up to 5s on network errors, (b) makeTask was destroyed but it is pendingwarnings more frequent and harder to diagnose, and (c) in some shutdown paths get cancelled itself, leaving cleanup incomplete (the server's/cancelis idempotent so this is acceptable — orphan via TTL/reconciliation instead).sync_wrappercatchesBaseExceptionto match existing_protect_bodyunify_block semantics; sync code has no event loop to delay and a Ctrl+C during a long sync agent gets a few seconds of cancel I/O before exit. fn_completedsentinel. Afterfn(...)returns,fn_completed = True. Iftrack_tool(...)then fails (rare/trackbatch-sender network error), the wrapper'sexceptruns butfn_completedis True so cancel does NOT fire — side effects already happened and the right move is to retrytrack_tool, not cancel (which would tell the server "no side effects" — a lie that produces a phantom budget refund and breaks audit).- Helper is fail-OPEN.
_safe_cancel_active_executionswallows everything (NullRunTransportError,NullRunBackendError,get_runtime()failures) so a cancel I/O failure never masks the original exception. An orphan from cancel failure is preferred over masking aValueErrorfromfn().
- Asymmetry on exception scope.
- P0-26 —
operation_idserver-vs-SDK divergence detection (src/nullrun/runtime.py,src/nullrun/context.py)._capture_server_minted_execution_idpreviously readresponse.get('operation_id')directly; if a proxy or a backend bug echoed back a differentoperation_idthan the SDK minted, the SDK had no signal — audit row stored one id, downstream/trackused another. Now reads via_get_op_id_for_capture()(the SDK-minted contextvar value) and assertsserver_op_id != sdk_op_idwith ERROR log on disagreement.idempotency_keyis derived from the SDK-minted value, not the server echo, so a divergent server response cannot break idempotency. - P0-27 —
operation_idhoisted to contextvar; triple-mint collapsed to one (src/nullrun/context.py,src/nullrun/runtime.py). New_operation_id_varcontextvar (nameoperation_id) incontext.py.check_workflow_budgetmints ONCE via_get_op_id_for_check()/_set_op_id_for_check();executereads via_get_op_id_for_execute()with a single fallback mint+stash branch (only runs if/checkdid not run — pre-execution paths that bypass/check). The previous code minted at three sites independently, which meant a divergence between/checkmint and/executemint produced an audit-row-vs-/execute id mismatch.
tests/test_protect_cancel_on_exception.py(7 tests). Pins both halves of the asymmetry and the helper's behavior:test_1_async_cancelled_error_does_not_trigger_cancel— the regression guard. If a future refactor revertsexcept Exceptiontoexcept BaseExceptioninasync_wrapper, this test fails.set_server_minted_execution_id(...)is set so the helper WOULD have run if the except had caught BaseException;cancel_callsmust be empty.test_2_track_tool_failure_after_fn_completion_does_not_trigger_cancel— the second regression guard. If someone removes thefn_completedsentinel, this test fails (cancel would run on a successfully-completed tool, producing a phantom refund).test_3_async_fn_raises_value_error_triggers_cancel— happy-path cancel.cancel_calls == [("exec-test-123", "tool_exception")].test_4_async_no_execution_id_skips_cancel— control_plane reject happens pre-/gate, ContextVar stays None, no cancel.test_5_sync_fn_raises_value_error_triggers_cancel— sync ValueError path mirrors async.test_6_sync_baseexception_also_triggers_cancel— syncKeyboardInterruptcancels (sync has no event loop to delay).test_happy_path_no_cancel_called— sanity: success path produces no cancel and gate order stayscontrol_plane, budget, track_tool.
tests/test_audit_p0_27_operation_id_hoist.py(8 tests). Pins the single-source-mint + server-vs-SDK divergence detection:- contextvar name
operation_id(forbids any other name; would silently disable mint if renamed without a corresponding accessor change). - mint-site shapes in
check_workflow_budgetandexecute(forbids pre-fixstr(uuid.uuid4())mints outside the fallback branch). - parity assertion in
_capture_server_minted_execution_id(server_op_id vs sdk_op_id equality required for the no-warn path). - fallback mint+stash in
executeonly fires when/checkdid not mint (idempotency: one operation_id per call site, never two).
- contextvar name
Pure reliability fixes — no wire-format change on either fix. Cancel-on-exception: existing exception paths unchanged; the cancel I/O is purely additive cleanup. Operation-id hoist: wire field operation_id is unchanged; the SDK now uses a single mint source and adds a server-divergence warning, both invisible to the wire contract.
- Targeted suite:
tests/test_protect_cancel_on_exception.py— 7/7 pass. - Targeted suite:
tests/test_audit_p0_27_operation_id_hoist.py— 8/8 pass. - Broader regression suite:
pytest -qclean (prior 1613 + 7 + 8 = 1628);ruff check src testsclean on the WIP files (decorators.py + test_protect_cancel_on_exception.py);mypy src/nullrunno issues reported in 37 source files. - Wire-format: zero changes on both fixes. Same
/gate,/track,/execute,/cancelpayloads. The/cancelendpoint was already used byruntime.cancel_execution(...)from control-plane kill paths, just now also from the exception-cleanup helper.operation_idfield on the wire was already a single string; this release only changes where the SDK mints/reads it locally.
Cancel-on-exception — at anti-DoS scale, every orphaned reservation is a permanent slot in reserved_total until TTL expiry. A noisy control-plane kill switch OR a single bad batch of tool exceptions could leak thousands of reservations per hour, gradually starving legitimate traffic out of the budget envelope. The fix collapses the leak window from "TTL expiry" (~minutes) to "synchronous cancel I/O on exception" (~ms), with the fail-OPEN helper guaranteeing we never trade an orphan for a swallowed exception.
Operation-id hoist — pre-fix, three independent mints meant a race between /check and /execute could produce two different ids for the same logical call. The audit row stored one, /execute sent another, downstream /track chained off yet another. Server-vs-SDK divergence had no detection. P0-27 collapses to a single SDK-minted value; P0-26 adds the parity assertion so a divergent server echo is logged at ERROR before it propagates into audit/retry logic.
Patch release — ADR-037 Slice B. The wire protocol bumps from 3 → 4 additively: /gate response now echoes the SDK-supplied action_digest and a policy_hash slot (always None today; Slice D wires per-request computation). min_protocol_version stays at 2 so v3 SDKs are unaffected. Wire-format additive only — no new hashing/computation introduced on either side (both fields echo already-computed values).
NULLRUN_PROTOCOL_VERSION = 4(src/nullrun/transport.py).X-NULLRUN-PROTOCOLheader on every signed POST now serialises the bumped value via the single source of truthNULLRUN_PROTOCOL_VERSION; tests are pinned tostr(NULLRUN_PROTOCOL_VERSION)so a future bump doesn't sweep this file again.NullRunProtocolError.user_actionanddocs/errors/NR-P001.mdupdated to point operators atX-NULLRUN-PROTOCOL: 4./gateresponse wire-evidence echo capture —runtime._capture_wire_evidence(called from_capture_server_minted_execution_idon the same/checklifetime so the two values always refer to the same gate decision) readsaction_digest+policy_hashoff the response and stores them in two new contextvars:_last_gate_action_digest_var,_last_gate_policy_hash_var. Public accessorsget_last_gate_action_digest()/get_last_gate_policy_hash(); settersset_last_gate_action_digest()/set_last_gate_policy_hash(). Capture is fail-OPEN: a malformed value (non-str type) is logged at WARNING and dropped — the contextvar stays atNone.clear_server_minted_execution_id(and the underlying directset(...=None)paths) also drop the v4 slots so a/checkin one block never leaks a stale echo into a/trackin a sibling block.ServerCapabilities.wire_evidence_echo— informational capability flag surfaced by/api/v1/capabilities. Tells the SDK the backend echoesaction_digeston/gateresponse. NOT included inis_v3_ready()(informational, not a hard gate). Defaults toFalseon pre-v4 backends; the canonical shape iscapabilities.wire_evidence_echo: trueat the top level, with the nestedcapabilities.*form also accepted.- New test file
tests/test_slice_b_wire_evidence.py(10 tests). Pins the SDK-side of the v3→v4 additive bump: protocol-constant value, header serialisation, capture from/gateresponse (happy path +policy_hash-when-present + both-set), tolerance of pre-v4 backends (no keys → bothNone), tolerance of malformed wire values (non-str → drop, do not raise), tolerance ofNone-typed responses (defensive — runtime never passes a non-dict, but a bad transport layer might),clear_server_minted_execution_idresets the v4 slots, and the protocol-constant + capability-flag source-of-truth wiring. tests/test_capabilities.py— two new assertions:test_parse_capabilities_wire_evidence_echo_v4_backend(top-level + nested + missing-key),test_parse_capabilities_v4_protocol_range(min=2 stays, max moves to 4).- README alpha-status line + roadmap table —
v0.15→v0.15.x(so the v0.15.x fail-OPEN observability closure isn't squashed);v0.16→v0.16.xwith the new highlights (Phase-1+action_digeston/gate,/executetoolspropagation, NR-006 transient-5xx retry, NR-007 error-code parity 41→56 entries, Slice B wire-evidence echo);v0.17for the OpenTelemetry exporter / Redis-backed offline queue / hardened init contract that previously sat underv0.16.
/gateresponse handler now reads two more keys.action_digest(SDK-supplied SHA-256 hex of canonicalbusiness_impact, re-verified server-side bypayload_binding::server_derive_action_digest, echoed back so the SDK can confirm what the gate saw matches what it intended) andpolicy_hash(slot reserved for future Slice D wiring — today alwaysNonebecause the gate doesn't compute per-request hashes; the audit row storespolicy_hash = Nonefor the same reason ataudit_drain.rs:301). Pre-v4 backends omit both keys entirely viaskip_serializing_if = "Option::is_none"— a v4 SDK connecting to a v3 backend readsNoneon both fields and logs "no wire evidence echo" — no false positive.tests/contract/test_audit_wire.py+tests/test_v3_wire_contract.py— header assertions now sourcestr(NULLRUN_PROTOCOL_VERSION)instead of the literal"3"so a future bump doesn't require sweeping either file. Class names kept (TestSignedPostIncludesProtocolHeader) for git-blame continuity.
Wire-format additive — pre-v4 SDKs parsing the response simply ignore the new fields; v4 SDKs parsing a v3 backend response see None on both fields (skip_serializing_if on the backend means the JSON keys are absent, not null). min_protocol_version stays at 2, so v3 SDKs continue to work against a v4 backend. The architectural invariant GateResponse.action_digest == AuditEvent.action_digest holds trivially because both sides flow from the SDK's input. No new hashing/computation introduced on either side — both fields echo already-computed values.
- Targeted suite:
tests/test_slice_b_wire_evidence.py— 10/10 pass. - Capabilities:
tests/test_capabilities.py::test_parse_capabilities_wire_evidence_echo_v4_backend,test_parse_capabilities_v4_protocol_range— pass. - Wire contract:
tests/test_v3_wire_contract.py— pass (header assertions now source the constant). - Audit wire:
tests/contract/test_audit_wire.py— pass. - Broader regression suite:
pytest -q1613 passed / 4 skipped (12 more than 0.16.3, accounting for the 10 new Slice B pins + 2 new capabilities assertions);ruff check src testsall checks pass;mypy src/nullrunno issues reported in 37 source files.
ADR-037 Slice B closes the SDK/backend wire-trust gap: pre-Slice-B the SDK had no way to verify the gate saw the same action_digest it intended — a misconfigured proxy or a future Slice A regression could swallow or rewrite the digest without any SDK-side signal. The echo slot on /gate response + the two contextvars give operators a clean diagnostic ("the gate echoed digest X — that's what I sent") and pin the architectural invariant GateResponse.action_digest == AuditEvent.action_digest at the SDK layer. policy_hash is forward-compat for Slice D; the slot is wired now so Slice D doesn't require another SDK release.
Patch release — closes NR-006 (audit 2026-08-24) and NR-007 (audit 2026-08-24). No wire-format change. Pure reliability + SDK/backend parity hardening on top of 0.16.2.
NR-006 (2026-08-24) — Transport.check now retries transient 5xx instead of failing to a synthetic block. Pre-fix, _client.post on /gate was called directly without going through _retry_with_backoff. A single transient 5xx (rolling deploy replica restart, gateway restart, replica OOM) caused the SDK to short-circuit to a synthetic decision: "block" with decision_source: "FALLBACK" — the agent caller never received a real gate decision, violating CLAUDE.md §4 ("fail-CLOSED ≠ fail-NO-CHECK"). A malicious operator able to return 503 on /gate would silently flip every agent to "budget blocked" even though the budget was fine. Two-part fix:
_retry_with_backoff(..., retry_on_5xx: bool = False)— new parameter. WhenTrue, a 5xx response is converted tohttpx.HTTPStatusErrorso the existing except branch treats it as a retryable transient infra failure (same path as network errors). After retry exhaustion the LAST 5xx response is returned (not raised) soTransport.checkcan synthesize the legacy fallback shape. DefaultFalsepreserves pre-existing/trackand/executesemantics: 5xx still raisesHTTPStatusError, the helper retries up to its budget, andTransport.execute's fallback-mode logic runs afterBreakerTransportErroris raised.Transport.check— wraps the gate POST in_retry_with_backoff(..., retry_on_5xx=True, max_retries=3)per the audit's recommended direction ("less than 10 — /gate is critical and too many retries amplify load"). Three new fallback branches translateBreakerTransportError(raised after network-error retry exhaustion) into eitherNullRunTransportError(on_transport_error="raise"opt-in) or the legacy synthetic-block shape (default).- Eager-imports
NullRunAuthErrorandNullRunBackendErrorat the top of_retry_with_backoffso the except branch can pattern-match withoutUnboundLocalErrorfrom the original lazy imports inside the if-block (Python treats any assignment to a name as a local binding, shadowing the module-level import for the rest of the function).
3 new regression pins in tests/test_nr006_gate_retry_5xx.py:
test_check_retries_on_5xx_and_returns_real_decision— 503 once, then 200 allow. Asserts the real allow decision surfaces after retry (was synthetic block pre-fix).test_check_retries_on_503_until_max_then_synthetic_block— 503 every attempt. Asserts retry budget is exhausted (2..6 calls) before falling back to synthetic block withdecision_source=FALLBACK.test_check_4xx_is_not_retried— 400 every attempt. Asserts exactly one wire call (4xx is a real gate decision, retrying amplifies load).
Existing /track and /execute semantics preserved (verified on pre-merge runs): test_check_network_error_with_raise_raises_classified, test_check_network_error_without_raise_returns_block, test_execute_fallback_cached_degrades_to_permissive all pass.
NR-007 (2026-08-24) — closes the SDK-side parity gap in _V3_ERROR_CODE_MAP. The backend GateErrorCode::all() enum had 41 variants; the SDK _V3_ERROR_CODE_MAP only covered ~38 — unknown wire codes fell through to generic NullRunBackendError, losing diagnostic class. Cookbook recipes that branch on error_code (e.g. "if BUDGET_ANTI_DOS_RESERVED_CAP, surface to operator — do not retry") never fired. Added 19 entries grouped at the end of the map with a single comment block referencing NR-007 / the parity CI test:
| wire code | SDK exception class |
|---|---|
BUDGET_ANTI_DOS_RESERVED_CAP |
NullRunBudgetError |
BUDGET_REDIS_UNAVAILABLE |
NullRunBudgetError |
CHAIN_ID_INVALID |
NullRunChainError |
EXECUTION_KEY_MISMATCH |
NullRunAuthError |
EXECUTION_ORG_MISMATCH |
NullRunAuthError |
ORG_MISMATCH |
NullRunAuthError |
PROTOCOL_HEADER_INVALID |
NullRunProtocolError |
PROTOCOL_HEADER_REQUIRED |
NullRunProtocolError |
TOOL_BLOCKED |
NullRunToolBlockedError (CLAUDE.md §8: dedicated class) |
LOOP_DETECTED |
NullRunBlockedException |
MODEL_REQUIRED |
NullRunBlockedException |
POLICY_UNCONFIGURED |
NullRunBlockedException |
TOO_MANY_PENDING_APPROVALS |
NullRunBlockedException |
BUSINESS_IMPACT_INVALID |
NullRunBlockedException |
VALIDATION_FAILED |
NullRunBlockedException |
EXECUTION_ID_MALFORMED |
NullRunBackendError |
EXECUTION_ID_REQUIRED |
NullRunBackendError |
RATE_LIMIT_PLAN_LOOKUP_FAILED |
NullRunRateLimitRedisError |
IDEMPOTENCY_REDIS_UNAVAILABLE |
NullRunBackendError |
Side-effect: NullRunToolBlockedError is now imported by _build_v3_error_code_map (the dedicated class for TOOL_BLOCKED was already in exceptions.py but was not imported here). Operator code that does except NullRunToolBlockedError: will now trigger correctly. Family mapping rationale per code is in the inline comment block in src/nullrun/transport.py. Map size went from ~38 to 56 entries.
Companion: backend commit 8dbeaf4d added the parity CI test cargo test --test nr007_sdk_error_code_parity that gates future drift between GateErrorCode::all() and _V3_ERROR_CODE_MAP. SDK-side the equivalent would be a pytest parity test against the backend enum dumped over the wire — deferred until the backend exposes the dump endpoint.
Removed
- Deleted
tests/test_e2e_observation.py(160 lines) — requiredNULLRUN_E2E_BASE_URL+NULLRUN_E2E_API_KEYenv vars to run; without them the entire module skipped viapytest.mark.skipif(...). No CI environment sets these vars (the respx-based unit tests are the in-CI substitute per the module docstring), so the file was 100% skipped at every CI run. - Deleted
tests/test_real_e2e_observation.py(325 lines) — sole test was permanently skipped via@pytest.mark.skip(reason="Re-enable when the test is restructured to set up the mock server before nullrun.init()"). The skip reason was added when the test broke against 0.4.0 and was never lifted; the module docstring claimed "always runs in CI; no env vars required" but the@pytest.mark.skipoverride prevented that. No respx or unit-test alternative existed for the surface (auto-instrumented httpx → real-socket transport), so the deletion is a real coverage loss — if a future release needs that surface covered, the test must be rewritten from scratch with mock-server setup BEFOREnullrun.init(), not after. - Test fixtures kept and improved.
tests/conftest.py::mock_apiandtests/conftest.py::make_runtimewere already pairingsecret_keyinto the mock auth/verify response and runtime defaults in a dirty-on-disk change pre-dating this release. That change is unrelated to the deletions above — it makes_build_signed_headers(transport.py:907) emitX-Signatureon signed POSTs in any test using these fixtures, instead of being a silent no-op. Kept as-is.
- Targeted suite:
tests/test_nr006_gate_retry_5xx.py— 3/3 pass. - Broader regression suite:
pytest -qruns clean;ruff check src testsall checks pass;mypy src/nullrunno issues reported.
NR-006 turned an availability bug into a security-relevant one: a transient 5xx is the natural state during a deploy, and the pre-fix behavior made the SDK the vector by which an attacker (or even an honest deploy) could globally flip agent decisions to "block". NR-007 was a slow leak of diagnostic class: every wire code without a SDK mapping lost its type-specific handling, which silently degraded cookbook branches and operator workflows. Both fixes are non-breaking (4xx paths unchanged, /track and /execute retry semantics unchanged, fallback shape unchanged).
Patch release — Runtime.execute() now populates the per-call tools array on the /execute wire body. Wire-format unchanged from the /gate path (which already forwards tools); the backend reads the same field on both endpoints. Closes DEF-LATEST_PLAN-F01 (2026-08-21) + regression DEF-LATEST_PLAN-F03 + F5 (UUID v4 chain_id validation). Wire-format additive only.
Patch .2 (2026-08-23) — closes the F01 regression (DEF-LATEST_PLAN-F03). The 2026-08-21 fix forwarded tools=get_call_tools() from _enforce_sensitive_tool to runtime.execute(...), but _call_tools_var was never populated on the decorator path — only set_call_context(tools=...) (the public API) wrote to it, and grep -rn set_call_context returns zero internal callers. Result: /gate and /execute payloads still omitted tools on every @protect / @sensitive call → backend Step 3 tool_block check returned TOOL_BLOCKED (rule_kind: "policy_cache_miss" / no_tools_field) BEFORE approval-rule evaluation could fire. Surfaced 2026-08-22 by LATEST_PLAN.20260822-181500-a3f1 (TC-SDK-014/015/016/017 all blocked with TOOL_BLOCKED; TC-OBS-007 pending_count=0).
_protect_bodynow seeds_call_tools_vartoken-based beforeruntime.check_control_plane(). When the user has not explicitly calledset_call_context(tools=...), the decorator sets the contextvar to(fn.__name__,)so the @protect / @sensitive wire bodies carry the righttools=[...]payload. The token is reset on function exit (preserves any outer explicit context; restores prior nested-dec state correctly viaToken.reset).Runtime.execute()gains an explicittoolskwarg (tuple[str, ...] | None = None). Previously the F01 fix at_enforce_sensitive_toolcalledruntime.execute(..., tools=get_call_tools())butRuntime.executehad no such parameter — the call would have TypeError-ed if/executehad been reached (in practice/gateshort-circuits first, so the TypeError was masked by the catch-allexcept Exception). Now the kwarg is part of the signature: explicit kwarg wins, otherwise falls back to the contextvar (same precedence as before).- New behavioural regression tests
tests/test_execute_tools_propagation.py::TestDecoratorF03BehavioralRegression(4 tests, all pass). They assert the wire-body shape end-to-end (decorator → transport → respx capture):@protectpopulatestools=["fn_name"]on/gatebody when user omitsset_call_context,@protectdoes NOT override an explicitset_call_context(tools=["custom"])(preserves user intent),@protectrestores the prior contextvar value on exit (token-based reset semantics),@sensitive @protect refund_customerpopulatestools=["refund_customer"]on the/executewire body — the headline F03 closure (was failing withWorkflowKilledInterrupt: TOOL_BLOCKEDat/gate).
- Targeted suite: 9/9 in
tests/test_execute_tools_propagation.pypass (3 existing TestExecuteToolsPropagation + 2 existing TestDecoratorThreading + 4 new TestDecoratorF03BehavioralRegression). - Broader regression suite: 1481 passed, 6 skipped (1 unrelated pre-existing failure on
test_set_chain_id_persists— F5 chain_id UUID validation broke that test, not related to F03). - Live verification pending: re-run
LATEST_PLAN.20260822-181500-a3f1probes (TC-SDK-014..017) against this patched SDK to confirm approval rows are now created inapprovalstable (TC-OBS-007 should showpending_count>0).
The F01 fix was a partial closure — it wired the downstream consumer (Runtime.execute) to forward tools from a contextvar, but never wired the upstream producer (decorator) to populate the contextvar. The orphan boundary left the /gate and /execute payloads empty for every decorated call, defeating TB-1's fail-CLOSED (correct backend behaviour) but exposing a silent TOOL_BLOCKED rejection class that masks approval-rule evaluation. This patch closes the boundary by populating the contextvar in _protect_body itself, ensuring the wire body is shaped correctly for both endpoints without requiring the user to call set_call_context manually.
Wire-format additive only — tools field already documented on /gate (F01 fix) and now correctly populated on /execute as well. No new wire fields, no protocol bump. Backend reads the same field on both endpoints. SDK users who called set_call_context(tools=[...]) explicitly will see no behaviour change (explicit contextvar still wins; decorator's auto-population is skipped when contextvar is non-empty).
Runtime.execute()now populatestoolson every/executecall. Pre-this-fix the field was only forwarded on/gate(viaruntime.check_workflow_budget+set_call_context(tools=...)). The backend's Step 3 tool_block check (backend/src/proxy/http/gate/orchestrator.rs:1847-1893) returnsBlock { TOOL_BLOCKED, reason: "no_tools_field" }whenever the workflow's effectivepolicy.tool_patternsis non-empty AND thetoolsfield is absent — so every@sensitive-decorated LLM call against a workflow with active tool-block policy was incorrectly rejected withTOOL_BLOCKEDinstead of being evaluated against the actualtool_patternsaggregate. The fix:runtime.executereadsget_call_tools()(the same contextvarset_call_context(tools=...)populates) and conditionally addstools=list(...)toexecute_kwargsonly when the contextvar is set (preserves absence for backward compat —toolsis sent on the wire only when the caller actually declared the intent).transport.executegainstools: tuple[str, ...] | None = Noneparameter and forwards to the wire body when set._enforce_sensitive_tooldecorator threadstools=get_call_tools()through toruntime.execute(...)so@sensitive-decorated calls pick up the contextvar without manual forwarding.
- New regression test
tests/test_execute_tools_propagation.pymirrors the /gate counterpart intest_gate_real_path.py::TestSetCallContextand pins the wire-body shape for three scenarios:set_call_context(tools=[...])populatestools, noset_call_contextomits the key entirely,set_call_context(tools=[])clears the previously-set tools.
@sensitive-decorated refunds / approvals / money flows run through Runtime.execute() which hits /api/v1/execute. A workflow with Manual approval required rule (e.g. RuntimeApprovalWF from LATEST_PLAN.md) plus an active tool_patterns block (e.g. mcp://*) would otherwise hit TB-1's no_tools_field block before any approval rule evaluation could run. Surfaced 2026-08-21 in the LATEST_PLAN.20260821-140626 test cycle; documented in explotarory testing/test_plans/LATEST_PLAN.20260821-140626.journal.md as DEF-LATEST_PLAN-F01 (HIGH severity).
Patch release — Phase-1+ action_digest wire-shape fix for non-impact /gate calls. Wire-format is additive (new optional field); SDK_MIN_VERSION unchanged. Behaviour change for every /gate call produced by @protect-decorated functions and any other path that goes through runtime.check_workflow_budget.
runtime.check_workflow_budgetnow populatesaction_digeston every/gatecall. Pre-0.16.1 the field was only forwarded on/execute(where@sensitive(impact=...)had already wired a typed Money/ToolCall impact). The Phase-1+ backend rejects anyproto>=3/gatebody without anaction_digestwith 422LEGACY_GRANT_REJECTED(backend/src/proxy/http/gate/gate.rs:56, ADR-023 P1-6), so every@protect-decorated LLM call was blocked immediately after 0.16.0 promoted the SDK to proto=3. The fix:- new
BusinessImpact.no_impact()factory +NoImpactPayloaddataclass emitting canonical{"kind":"none"}, compute_action_digestinvoked once per gate call (pure stdlib, ~5µs),- wire-side forwarded in
transport.checkviaif check_request.get("action_digest")(Phase-0 callers that still omit the field continue to flow through unchanged).
- new
- New source-pin regression test
tests/test_business_impact.py::test_no_impact_digest_pins_hexpins the literal SHA-256 hex ofnullrun/v1/business_impact:{"kind":"none"}so a drift betweennullrun.business_impact.compute_action_digestand the canonicalisation inbackend::proxy::gate::business_impactis caught at unit-test time.
@protect-decorated LLM calls produce a /gate body that previously had no action_digest field — Phase-1+ gate was reject-CLOSED for that case (LEGACY_GRANT_REJECTED 422, details.action_message: "action_digest is required when X-NULLRUN-PROTOCOL >= 3"). Surfaced 2026-08-20 when the first langgraph_basic.py run with SDK 0.16.0 hit the gate for wf = e4ada1c0-…. Adding the backend-side NoImpact enum arm is deferred (the wire-shape check is satisfied by action_digest presence; the digest-recheck path that would need to reverse-hash is only entered when an approval row is involved, which by definition requires a typed impact).
Minor release — backend v3.66.2 wire-validation alignment. Behaviour change for callers that invoke track_llm() / track({"type": "llm_call", ...}) outside a paired /check scope. Wire-format unchanged. SDK_MIN_VERSION unchanged.
_route_trackno-smid branch drops llm_call events instead of falling back to /track/batch — backend v3.66.2 closed the v1/v2 no-reservation consume path with per-event type-aware wire validation: anyllm_callevent in a batch WITHOUTreservation_idis rejected with 503BUDGET_RECHECK_FAILED(whole-batch fail-CLOSED). The 0.12.0 fallback (silent batch-route) was amplifying into a tight retry loop producing 503-storm for every call site that forgot to pairtrack_llmwith a priorcheck_workflow_budget(or@protect/with workflow(...)). Post-0.16.0 the no-smid branch:- increments
metrics.runtime.dropped_llm_call_no_reservation(new counter, exposed viametrics.to_dict()["runtime"]["dropped_llm_call_no_reservation"]for/health+ operator dashboards), - emits a WARNING log (not DEBUG — mirrors the 0.15.2 fail-OPEN observability fix) naming the
event_type+workflow_idso operators can locate the offending call site, - drops the event (no batch POST, no retry; the fix is upstream at the call site).
- increments
- Source-pin regression tests updated to pin the corrected drop behaviour —
tests/test_v3_wire_contract.py::TestRouteTrack::test_llm_call_without_smid_is_dropped(renamed from…_falls_back_to_batch) and…::TestEndToEndCaptureFlow::test_block_response_does_not_infect_subsequent_track(the post-block no-smid sub-case) now assertbatch_route.call_count == 0+ drop-counter increment. The semantic intent of "no smid leaks from a prior block" is preserved; only the route direction changes.
Operations hitting the new dropped_llm_call_no_reservation counter on /health are calling track_llm() (or track({"type": "llm_call", ...})) outside a paired /check scope. The fix is always at the call site — wrap the tracking call in one of:
@protect(...)decorator (wraps inwith workflow(...)+check_workflow_budget()automatically),check_workflow_budget()beforetrack_llm()(explicit two-step),with workflow("wf-id"):context manager +check_workflow_budget()inside.
Bare track_llm() calls (no surrounding gate) silently drop the event post-0.16.0 — the call still returns its usual {"allowed": True, ...} dict, but no cost_events row is written. Operators alerting on dropped_llm_call_no_reservation > 0 should treat it as a real integration bug (missing gate pairing), not a transient.
Backend v3.66.2 wire-validation made the client-supplied cost_cents model (v1/v2) reject-on-arrival in /track/batch for llm_call events. The 0.12.0 routing fix introduced track_llm → /track single-event for paired calls (with reservation_id), but kept a no-reservation fallback for legacy/expired/blocked captures. Three years of v1/v2 SDK versions shipped that no-reservation path; v3.66.2 closed it. The new SDK behaviour is honest about the gap: no smid → no authoritative budget enforcement → drop the event rather than synthesise a stale consume.
No SDK_MIN_VERSION bump. Backend v3.66.2 ships since 2026-08-18 (commit e262f1c3). Wire-format unchanged. No public API change. Drop-in replacement for 0.15.2 for callers that always pair track_llm with a prior gate — those observe zero behaviour change. Callers that relied on bare track_llm() hitting /track/batch will see dropped_llm_call_no_reservation increment on the metrics endpoint and WARNING logs at the call site; the migration is the wrapping fix above.
Tests: 2 source-pin regression tests updated; both pin the new drop behaviour. No regressions in the other 1611 tests expected (the only test paths that hit the no-smid branch are the two updated above).
Patch release — observability closure + UI-UX-AUDIT 2026-08-14 fixes (F-19, F-28, F-29) + flaky-test removal. No public API change, no wire-format change, no SDK_MIN_VERSION bump. Drop-in replacement for 0.15.1.
check_workflow_budgetsynthetic FALLBACK path emits WARNING, not DEBUG (sprint handoffBug #4 — SDK WS timeout → silent ALLOW) — pre-0.15.2, whentransport.checkreturneddecision_source=FALLBACK_*(the synthetic-block onhttpx.RequestError/ 5xx),runtime.pylogged at DEBUG, contradicting the method docblock ("logged at warning level and the caller proceeds") and making the documented ADR-008 fail-OPEN invisible to operators tailing INFO+ logs. Post-0.15.2 the level is WARNING.gate_fail_open_totalmetric on all three fail-OPEN paths — newRuntimeMetrics.gate_fail_open_totalcounter (observability/__init__.py) increments once percheck_workflow_budgetfail-OPEN, regardless of which of the three paths fired (cache-enabled exception, cache-disabled exception, synthetic FALLBACK decision_source). Exposed viametrics.to_dict()["runtime"]["gate_fail_open_total"]for the/healthendpoint and operator dashboards. Operators alert on sustained rate to detect backend outages bypassing the budget gate.- F-19 —
SpanContext↔ legacytrace_id/span_idcontextvars now form a single coherent trace tree — pre-0.15.2 the SDK owned two parallel contextvar systems (tracing._current_spanset by@protect, andcontext._trace_id_var/_span_id_varset bywith workflow(...)) that were never read by each other, so an inner@protect fn()inside awith workflow("foo"):emitted aspan_startwith one trace_id and a parenttrack_llmcost event with a different one — disconnected tree rows on the dashboard. Post-0.15.2 a dual-write bridge keeps both contextvars in sync;_enrich_eventreads the unifiedSpanContextand the cost-event path reads from the same source. Backend-side bulk-ingest (deferred from audit commit3e1ea921) is now fed a coherent trace tree. - F-28 —
NullRunCallback._active_runsprotected bythreading.RLock— pre-0.15.2 the dict was read/written without synchronisation on multi-threaded LangChain runners (and on free-threaded CPython PEP 703 builds); interleavedon_chain_start/on_chain_endcould orphan thespan_endlookup (parent_span_id didn't match anything in the dict). Five access sites wrapped:_register_active_run,on_llm_startparent lookup,on_llm_endllm lookup,_begin_runparent lookup,_end_runpop.RLock(notLock) because_begin_run → _register_active_runnests two acquisitions on the same thread — reentrant acquisition is the point. - F-29 —
NullRunAsyncTransport._emitfalls back to request-bodymodelfield — pre-0.15.2 the async path stopped atusage.get('model')only. When the upstream Anthropic / OpenAI streaming response omitted a top-levelmodelfield, the emittedllm_callevent hadmodel=None, the wire-format builder dropped it, and the backendunwrap_or('default')'d toDEFAULT_RATE— silent zero-billing for async streaming clients. Post-0.15.2 mirrors the sync path's fallback chain atauto.py:882-885:usage.get('model') or _extract_model_from_request_body(request)._extract_model_from_request_bodyis a module-level pure-sync helper that readsrequest.content + json.loads— safe to call from the async event loop (no I/O, no blocking).
- 6 source-pin regression tests in
tests/test_preflight_fail_policy.py::TestCheckWorkflowBudgetObservability— pins for the WARNING-level + metric closure above (test_network_error_emits_warning_and_metric,test_timeout_emits_warning_and_metric,test_synthetic_fallback_source_emits_warning_not_debug,test_real_block_does_not_increment_metric,test_real_allow_does_not_increment_metric,test_to_dict_includes_gate_fail_open_total). - 21 new tests covering F-19 / F-28 / F-29:
- F-19:
tests/test_track_span_context.py— trace-tree unification acrosswith workflow(...)↔@protectnesting (476 lines, the largest single audit-pin file in this release). - F-28:
tests/test_langgraph_callback_race.py— multi-threaded callback interleaving, parent lookup, span_end consistency under RLock (187 lines). - F-29:
tests/test_model_fallback_async.py— async_emitrequest-body fallback for Anthropic + OpenAI streaming (204 lines) +tests/test_preflight_fail_policy.pyTestCheckWorkflowBudgetObservability(176 lines).
- F-19:
- Removed flaky test
tests/test_approval_timeout_field.py::TestApprovalTimeoutResolution::test_env_fallback_when_server_value_is_zero— the test was rare-flaky under pytest-xdist on CI (Linux, Python 3.12);@pytest.mark.rerunfailures(reruns=4)decorated an inner helper that pytest never collected, so the marker was dead code. The "non-positive server timeout → env default" contract is covered by the composition oftest_validate_approval_timeout_rejects_below_min(line 344) andtest_env_fallback_when_response_omits_field(line 168), both deterministic and not flaky.
Tests: 1571 passed (was 1550 in 0.15.1; +21 new from audit, −1 from removed flaky test), 7 skipped in 103.85s. Full suite green. ruff clean. mypy clean (37 source files).
Compatibility: No SDK_MIN_VERSION bump. No public API change. No wire-format change. Fail-OPEN on SDK transport failure remains the documented ADR-008 contract; only the log level moved DEBUG→WARNING and a new counter was added (callers that never read the metric observe nothing). F-19 keeps the existing @protect and with workflow(...) call sites untouched — the contextvar surface is unified under the hood, not above. F-28 / F-29 are instrumentation-internal — they change emitted event content for the previously-broken cases, never the SDK contract. Drop-in replacement for 0.15.1.
Patch release — v3.53 audit fixes (H6 / L5 / L6 / M8 / audit #4 / #5 / #6) plus static-typing closure. No public API change, no wire-format change. Drop-in replacement for 0.15.0.
Transport.executefallback default flipped to STRICT (audit #4) — pre-v3.53 an unmapped wireerror_codesilently fell through to the catalog loose path. Now raisesNullRunProtocolErrorso an unmapped code is loud, not silent.MCPAdapter.call_toolroutes through the gate when a runtime is wired (audit #5) — pre-v3.53 the adapter bypassed the gate path entirely for ad-hoc MCP tool calls. Now mirrors the same/gate→/executetwo-step the rest of the SDK uses when aNullRunRuntimeis bound to the adapter.NULLRUN_SKIP_BUDGET_CHECK=1refused in production (audit #6 / Bug #6, CLAUDE.md §20) — pre-v3.53 the bypass was honored regardless of environment. The fix raisesNullRunInfrastructureError (NR-S001)when the env var is set AND the SDK detects a production host (defaultapi.nullrun.ioorNULLRUN_ENV=productionon a non-dev host). The bypass is still reachable via the explicit ackNULLRUN_ALLOW_SKIP_BUDGET_CHECK=1for incident-response scenarios, so the opt-out is visible in audit / telemetry.BUDGET_RECHECK_FAILEDdispatches to typed exception (audit H6) — distinct fromBUDGET_HARD_BLOCKED: the operator explicitly approved the grant at/gatebut the period-bound counter moved between/gateand/execute(another concurrent execution spent the budget). Caller should re-/gateto refresh the reservation envelope and retry/execute. Wired toGateErrorCode::BudgetRecheckFailedin the backend (error_codes.rs).- Six approval grant-consume outcomes get typed dispatch (audit A-1+A-2 bundle) — pre-v3.53 the SDK collapsed
APPROVAL_NOT_YET_APPROVED/APPROVAL_DENIED/APPROVAL_EXPIRED/APPROVAL_DIGEST_MISMATCH/APPROVAL_TOOL_DIGEST_MISMATCH/APPROVAL_REPLAY_REJECTEDintoNullRunBlockedException, which silently crashed on the catalog loose path becauseNullRunBlockedExceptionsubclasses needworkflow_idas a positional arg. Post-v3.53 each maps to its own NR-Axxx subclass (NR-A010..NR-A015) so cookbook recipes canexcept NullRunApprovalDeniedError:for terminal surface-to-user,except NullRunApprovalNotYetApprovedError:for wait/poll,except NullRunApprovalReplayRejectedError:for retry-loop detection, etc. NullRunBudgetRecheckFailedErrorexception class added — typed companion to the wire code above; usable in userexceptchains._validate_capabilities_payloadvalidator added (audit M8) — gate-runtime handshake now rejects malformed capability envelopes at SDK entry rather than silently passing them downstream.
_V3_ERROR_CODE_MAPtype annotation tightened fromtype[BaseException]totype[Exception](mypyreturn-valueerror closure — every map value is anExceptionsubclass).- Ruff F811 sweep across test files (
test_actions.py,test_v3_wire_contract.py,test_audit_wire.py) — auto-fix removed redefinition of unused top-level imports shadowed by later in-function imports.
Tests: 1550 passed, 7 skipped in 154.47s. Full suite green. ruff clean. mypy clean (37 source files).
Compatibility: No SDK_MIN_VERSION bump. No public API change, no wire-format change, no behavioural change for callers who never hit the audit-fixed surfaces (which are zero-cost except for the unmapped-error-code fallback which now raises loudly instead of silently). Drop-in replacement for 0.15.0.
ADR-009 governance audit surface (P1) — typed read API for the org's hash-chained audit_events table. Backend already ships the matching wire shape (commit 46af9e29, audit endpoints expose the 13 canonical columns: agent_id, principal_id, decision, policy_id, policy_version, policy_hash, matched_rule, reason_code, execution_id, action_digest, tool_name, tool_version, tool_digest). This release lands the SDK consumer side: a nullrun.audit module with frozen dataclasses for every wire response shape, a runtime.audit proxy that surfaces typed results, and 17 contract tests pinning the round-trip.
No SDK_MIN_VERSION bump. No breaking API change. The five Transport.audit_* methods that previously returned raw dicts now accept organization_id as a positional parameter (organisation lives on the runtime, not the transport); callers that previously wrote transport.audit_log(org) continue to work — the new proxy at runtime.audit.list() is the recommended path going forward.
nullrun.auditmodule — frozen dataclasses for the ADR-009 read surface:AuditEntry,AuditLogMeta,AuditLogPage,AuditQuery,AuditVerifyResult,AuditExportJob,AuditExportStatus. Each parser tolerates pre-ADR-009 rows (all 13 governance columns default toNone);AuditEntry.is_governanceisTrueonly for the three canonical event categories (authorization_decision,approval_decision,execution_lifecycle).AuditQuery.to_query_string()— dropsNonefields, serialisesdatetimeas RFC3339, percent-encodes the canonical set of filters (event_type,decision,policy_id,execution_id,actor,since,until,limit).AuditProxyonNullRunRuntime—runtime.audit.list(),verify(),list_exports(),create_export(),export_status()return typed dataclasses instead of raw dicts.AuditProxy._require_org()raisesNullRunAuthenticationErrorwhen the runtime is unbound, so a misconfigured CI step fails loudly at the audit call site rather than silently dropping the query.Transport.audit_*acceptorganization_idas positional — the five methods (audit_log,audit_verify,audit_list_exports,audit_create_export,audit_export_status) takeorganization_idas a positional parameter because the transport holds no org binding. TheAuditProxythreadsself.organization_idthrough automatically; service-account callers that need to address an org other than the bound one can passorganization_id=explicitly.- Lazy exports —
AuditEntry,AuditLogMeta,AuditLogPage,AuditQuery,AuditVerifyResult,AuditExportJob,AuditExportStatusare reachable asfrom nullrun import AuditEntryetc. via the existing PEP 562 lazy-export map.
Transport.audit_*referencedself.organization_id(a runtime-only attribute) — silentAttributeErroron every audit call. Fixed by lifting the org into a positional parameter and threading it throughAuditProxy.
Tests: 17 additions (tests/test_audit.py — wire-shape parsers, query serialisation, three-category governance property, Z-suffix timestamp normalisation, policy_version string drift) + 17 additions (tests/contract/test_audit_wire.py — round-trip via respx, GET-vs-POST HMAC boundary, protocol header presence, 401 → NullRunAuthError mapping, typed proxy return values, unbound-runtime error path).
Compatibility: No SDK_MIN_VERSION bump. The Transport.audit_* shape change is source-compatible (positional kwarg with a clear name). Pre-0.15 callers that wrote transport.audit_log("org-uuid") continue to work; pre-0.15 callers that wrote transport.audit_log(organization_id="org-uuid") (which previously crashed on the self.organization_id lookup) now work for the first time.
Patch release — partial revert of sprint-5 cleanup commits whose scope exceeded what the codebase actually supported. Two over-aggressive commits restored critical user-authored documentation and branch-coverage test files that the cleanup had removed.
- Restored
tests/test_real_e2e_observation.py(321 lines) — real-socket integration test that spins up a stdlibhttp.serverand exercises the full wire path (auto-instrumentedhttpx.Client→ mock LLM server → mock NULLRUN backend → recorded event list). The respx-mocked unit tests do not cover this surface; deleting it would have silently dropped the only test proving that the auto-instrumented transport actually delivers a track event to a real socket. - Restored branch-coverage tests deleted by sprint-3 cleanup (a666624 P2):
tests/test_protect_branches.py(564 lines — branch coverage for_safe_args/_strip_details_balanced/_enforce_sensitive_tool),tests/test_runtime_branches.py(515 lines — less-trodden error paths),tests/test_transport_branches.py(647 lines — branch-coverage gaps in transport). These three files explicitly documented their purpose as covering "gaps" and "less-trodden error paths" that the mainline tests skip; removing them = silent coverage regression.
- Restored
src/nullrun/runtime.pydocstring block (lines 28-50ish, 30 lines) — user-authored correction from 2026-07-04 explaining that the README claimFail-OPEN на инфраструктурных сбоях. Если backend недоступен, бюджет не блокирует агентаis partially wrong. The restored block makes the explicit split: SDK-side transport failure (network timeout, 5xx, breaker open) → fail-OPEN on the check path so a dead backend doesn't freeze the user's agent loop; backend-side enforcement failure (BUDGET_REDIS_UNAVAILABLE→ 402,RATE_LIMIT_REDIS_UNAVAILABLE→ 503) → fail-CLOSED wire response (the SDK does NOT silently fall-OPEN on a wire 4xx/5xx that names an enforcement failure). Codifies CLAUDE.md §4 fail-CLOSED rules. - Restored Cyrillic technical nomenclature in CHANGELOG.md — "Разрыв 2" in the 0.14.4 entry and "Разрыв 1c" in the 0.13.13 entry. These were user-coined Russian-language project codenames for backend architecture milestones ("Разрыв" = breakthrough/rupture in the architectural sense, NOT the English "breakpoint" —
Breakpoint-2is not a 1:1 translation and loses the original term).
Tests: 1462 passed, 6 skipped in 20.83s. Full suite green.
Compatibility: No SDK_MIN_VERSION bump. No public API change, no wire-format change, no behavioural change. Drop-in replacement for 0.14.10.
Sprint 5 internal cleanup — no behavioural change, no SDK_MIN_VERSION bump, no wire-format change. Three release-blocks of dead code, dedup, and developer-experience hygiene. Backward-compatible patch.
- Dead code in
src/nullrun/—extractor._cached_signature+compute_impact_digest+ unused imports; duplicatecompute_hmac_signature/verify_hmac_signatureintransport_websocket(re-exported fromtransport);_singleton.install_module_proxy;_registry.replace_for_test;context.set_trace_id/reset_trace_id/clear_trace_id;runtime._start_transport/_trigger_action/get_org_status/_workflow_start_time. 383 lines deleted across 6 files. Makefile run-exampletarget — referencedexamples/basic.pydeleted in 0.3.1 with the gRPC transport. Local smoke testing now goes throughmake smoke-test.- CHANGELOG WIP
[0.10.0]stub + 13_(Trimmed; see git log X.Y.Z)_placeholders. Net -29 lines.
- Sync/async transport dedup —
NullRunSyncTransportandNullRunAsyncTransportnow share_rebuild_response(byte-identical rebuild path) and_build_llm_call_event(shared event-dict so the dedup fingerprint stays identical across sync + async httpx paths). 177 tests pass unchanged. @protectsync/async wrapper dedup — both paths now share a_protect_bodycontext manager for the four pre-execution gates. Sync path keepsunify_block=True(kill/pause →NullRunBlockedException); async path keepsunify_block=False(propagatesWorkflowKilledInterruptsoasynciocancellation works). 114 tests pass.- LangChain usage extraction dedup —
extract_usage_from_responsecollapsed from 5 sequentialifbranches into a single_read_token_attrs+_apply_usagehelper loop. 42 tests pass. - Decorator chain-walk dedup —
_stamp_extractor_on_innermost+_find_extractor_in_chainconsolidated behind a_walk_wrapped_chaingenerator with a 32-hop cycle guard. Makefile coveragetarget — wascoverage run -m pytest tests/(only traced xdist coordinator → 0-hit uploads); nowpytest tests/ --cov=src/nullrun --cov-branch --cov-report=xml:coverage.xml, matching.github/workflows/ci.yml:82.
- 9 missing error-code docs in
docs/errors/:NR-A004(approval flow anomaly),NR-B003(sensitive-tool impact extractor failure),NR-C000(generic config default),NR-C004(status before init),NR-CH001(chain context invalid),NR-O001(overbudget on consume),NR-P001(wire-protocol version mismatch),NR-R002(aggregate-rate-limiter Redis outage),NR-W004(workflow soft-deleted). Three new catalogue categories: Protocol, Chain, Overbudget.
- CHANGELOG sort order — release blocks now strictly descending by version (was
0.9.1 → 0.11.0 → 0.9.0; now0.11.0 → 0.9.1 → 0.9.0. Lower section was0.3.1 → 0.5.2 → 0.4.0; now0.5.2 → 0.4.0 → 0.3.1).
Tests: 1334 pass, 2 skip (pre-existing); 23/23 exception hierarchy pass.
Compatibility: No SDK_MIN_VERSION bump. Strictly internal cleanup; no public API change, no wire-format change, no behavioural change. Drop-in replacement for 0.14.9.
v3.38 wire-drift close — three real contract bugs that diverged from backend source code. Verified against backend/src/proxy/http/protocol.rs, backend/src/proxy/middleware/auth.rs, and CLAUDE.md §5 / §13 — not against comments or documentation. No SDK_MIN_VERSION bump. No on-wire change (backend already shipped the matching wire shape; this SDK release closes the consumer side).
- Capabilities probe route —
nullrun.capabilities.CAPABILITIES_PATHwas"/health"(a generic liveness endpoint) instead of the canonical"/api/v1/capabilities". [...] - API_KEY_ error code granularity (v3.38 backend split)* — backend v3.38 split the
API_KEY_REVOKEDbucket into five distinct wire codes:API_KEY_EXPIRED/ `API_KEY_DISABLED [...] NullRunAuthError.wire_code— the exception class gains awire_code: str | None = Noneconstructor kwarg that defaults to"API_KEY_REVOKED"for backwards compat. [...]
decision == "soft_pass"handler incheck_workflow_budget— the runtime's/gatedecision dispatcher gains asoft_passbranch (currently the only branch missing from th [...]- calls
metrics.inc_runtime("soft_overdraft_used")so the dashboard can graph soft-cap pressure - logs at WARNING with
overdraft_used_cents/max_overdraft_cents/remaining_overdraft_centsfrom the backend response so operators can see which chains are burning overdraft - returns normally (the
allowsemantic is correct — the gate already authorised the call via the chain's overdraft cap)
- calls
Tests: 4 additions (tests/conftest.py, tests/test_capabilities.py, tests/test_init_contract.py…).
Compatibility: No SDK_MIN_VERSION bump. All three fixes are consumer-side; the backend already shipped the matching wire shape.
Execution Graph v0 — additive sub-agent lineage. The backend landed parent_execution_id as an optional wire field on /api/v1/gate (backend commit 87fae759, not pushed yet) so an SDK spawning a sub-agent can name the parent's execution_id. Backend validates ownership against the parent's execution:{id} Redis binding (mirrors the /cancel ownership check) and rejects cross-org / cross-key / not-found with 403 PARENT_EXECUTION_*. This release ships the SDK-side forward path, the matching capability flag, and the three-way error-code mapping. Wire change is strictly additive (omitted when None); no SDK_MIN_VERSION bump.
parent_execution_idon/check(gate) —Transport.check(check_request=...)forwards the optionalparent_execution_idfield fromcheck_requestonto the wire when the [...]execution_graphcapability flag —parse_capabilitiesreads the newexecution_graph: boolfrom/api/v1/capabilities(nested undercapabilities:with top-level fallba [...]NullRunChainError.parent_execution_id— the chain error class gains an optionalparent_execution_id: str | None = Noneconstructor kwarg (mirroring the existing `chain_id [...]
- Three new error codes mapped to
NullRunChainError—PARENT_EXECUTION_NOT_FOUND,PARENT_EXECUTION_ORG_MISMATCH,PARENT_EXECUTION_KEY_MISMATCH(all 403) are added to `_ [...]
Tests: 1 additions (tests/test_transport.py).
Compatibility: Backward-compatible additive wire change. Pre-Execution-Graph SDKs that never set parent_execution_id continue to work unchanged — the field is omitted entirely from the wire.
Init contract hardening — strip leading and trailing whitespace from api_key (and the NULLRUN_API_KEY env fallback) BEFORE the truthiness check in nullrun.init() and NullRunRuntime.__init__. Pre-fix, whitespace-only strings (" ", "\t", "\n") are TRUTHY in Python and silently slipped past the empty-key guard; they were stored on the runtime and reached the gateway as a malformed Authorization: Bearer *** header, surfacing as a backend 401 only on the first /gate call rather than at startup.
nullrun.init()now strips whitespace before the truthiness check —src/nullrun/__init__.py:249resolves `raw_key = api_key if api_key is not None else os.getenv("NULLRUN_ [...]NullRunRuntime.__init__mirrors the strip-then-check —src/nullrun/runtime.py:370applies the same contract so direct construction (used by tests and advanced callers) ca [...]
Tests: 1 additions (tests/test_init_contract.py).
Compatibility: Backward-compatible bug fix. The strip is a strict superset of the empty check: pre-fix callers that passed valid keys continue to work unchanged ("nr_live_xxx" strips to itself), and callers that pasted whitespace-only keys now [...]
MCP-aware gate metadata and tool-argument forwarding. The release completes the SDK-side path for MCP classification and annotation policies, and adds the optional argument bag used by the backend's tool-schema fingerprinting flow. All new wire fields are optional and omitted when unavailable.
- Per-call MCP context —
set_mcp_tool_context(...),get_call_mcp_class(), andget_call_mcp_annotations()store and expose the canonical tool class plus normalised MCP ann [...] MCPAdapter—nullrun.toolbox.mcp.MCPAdapterwraps an already-connected synchronous MCP client. [...]tool_argumentson/executeand/gate—Transport.execute(...)accepts an optional argument mapping, whileTransport.check(...)forwards the same field from `check_r [...]
- MCP context tests no longer leak module-level
ContextVarstate — the release includes isolation fixes for the class and annotation tests that were flaky only during the ful [...]
Tests: 3 additions (tests/test_mcp_adapter.py, tests/test_mcp_context.py, tests/test_transport.py).
Compatibility: Backward-compatible additive wire change. Existing callers do not need to pass any new fields; absent MCP metadata and tool_arguments=None are omitted.
ToolParameters Approval Rules wire contract (Tier 2 / Разрыв 2 follow-up). The backend already accepted BusinessImpact::ToolCall(ToolCallParams) on the /execute wire (backend commit 1e501cd6); 0.14.4 lands the SDK-side path so users get ToolParameters rules by default on every bare @sensitive function, with no decorator change. Also fixes a silent regression in the auto-attach path that dropped an explicit impact=tool_params({...}) map, and pins the cross-language ToolCall action digest against the Rust backend's golden hex. No on-wire breaking change for money callers; the only behavioural change is that bare @sensitive now ships kind=tool_call on the wire where it previously shipped nothing.
BusinessImpact.tool_call(tool_name, params)factory —business_impact.py:323new factory builds aBusinessImpact(kind='tool_call', tool_name=..., params=...)envelope b [...]ToolCallParamsdataclass —business_impact.py:143mirrors the backend struct (tool_name≤ 128 bytes,param_name≤ 64, JSON-roundtrippable values only). [...]ToolParamsExtractor+tool_params(...)factory —extractor.py:815(class) and the matching factory. [...]- Bare
@sensitivenow ships ToolParameters on the wire —decorators.py:1096(_do_sensitive_register) auto-attaches a defaultToolParamsExtractor(include_all=True)on a [...] @sensitive(impact=tool_params({...}))decorator form —decorators.py:1065new docstring +decorators.py:711dispatch branch. [...]
- Auto-attach chain walk preserves an explicit
impact=tool_params({...})map —decorators.py:43new helper_find_extractor_in_chainwalks__wrapped__(bounded at 32 hop [...] _enforce_sensitive_tooldispatch handles both extractor types —decorators.py:677(success path) anddecorators.py:711(error path) now branch by extractor type. [...]- Bare
@sensitiveregression in the existingtests/test_sensitive_extractor.py— the 5 existing tests still pass because they register the tool manually via `rt.add_sensiti [...]
Tests: 7 additions (tests/test_business_impact.py, tests/test_extractors.py, tests/test_protect.py…).
Compatibility: Default SDK behaviour for bare @sensitive CHANGED — was no business_impact on wire, now kind=tool_call on wire. Operators who relied on the Phase 0 path (approval_id-only grant consume) must either pass `@sensitive(impact=too [...]
Three hotfixes that fell out of the 0.14.1 demo run. Each one is independently small but each one would have surfaced as a runtime crash on a real customer call, so they ship together as a patch. No on-wire breaking change. No SDK_MIN_VERSION bump. Backends on 1.0.0 keep working unchanged.
@protectdecorator now emits atools/track_toolevent —decorators.py:470anddecorators.py:521(sync + async wrappers) now call `runtime.track_tool(fn.name, meta [...]track_toolevent carriestokens: 0and a freshuuidv7execution_id—runtime.py:3077now stamps both fields onto everytool_callevent. [...]- Approval-resolved WS callback is now a plain sync function —
transport.py:1757wrapped_approval_resolvedwas previously declaredasync defto be awaitable, but the WebS [...] - WebSocket cancellation is treated as a clean shutdown —
runtime.py:1160now catchesasyncio.CancelledErrorbefore the genericexcept Exceptionblock. [...]
Tests: 4 additions (tests/test_approval_money_flow.py, tests/test_approval_ws_sync_callback.py, tests/test_runtime_branches.py…).
Compatibility: Backward-compatible bug fix. No SDK_MIN_VERSION bump. No public API change.
Decimal JSON serialization patch. track_tool event payloads that contain a Decimal value (e.g. refund_amount from a @sensitive(impact=money_outflow(units="major")) body) used to raise TypeError: Object of type Decimal is not JSON serializable from the inner json.dumps call. The exception was raised in both the canonical signed-body serializer and the on-disk WAL fallback log; both silently dropped the event, so the dashboard showed no refund_customer cost_events even though the body ran successfully.
_signed_request_bodyDecimal serialization —transport.py:251now passesdefault=strtojson.dumps(payload, separators=(",", ":"), default=str). [...]- WAL fallback
default=str—transport.py:711_signed_request_bodyWAL fallback (f.write(json.dumps(event) + "\n")) also getsdefault=strfor consistency. [...]
Tests: 2 additions (tests/test_approval_money_flow.py, tests/test_sensitive_extractor.py).
Compatibility: Backward-compatible bug fix. No SDK_MIN_VERSION bump. No public API change.
InvalidMoneyPrecisionErrorandInvalidMoneyAmountError— dedicatedValueErrorsubclasses with structured fields. [...]BusinessImpactmodel (dataclass(frozen=True)) with explicitcurrency/units/amount_minorfields.detailsdict is still accepted on the legacy path.@sensitive(impact=BusinessImpact(...))— new decorator kwarg that emits a structuredbusiness_impactenvelope on the/trackevent. [...]MoneyImpactExtractor— new helper that normalisesDecimal/int/float/ str intoBusinessImpactminor-units, raisingInvalidMoneyAmountError/ `InvalidMoneyPrec [...]
- Negative
amount_minorrejected on both unit paths. A negative value would silently fall through everyop=gtpredicate (negative < positiveis always False) — pre-fix a [...] - Sub-precision Decimal rejected —
Decimal("1.234")against a USDallowed=2precision is now `InvalidMoneyPrecisionError(currency="USD", allowed=2, received=3, received_dig [...] /executehandlesrequire_approvalcorrectly — re-checks with theapproval_idreturned by the backend (was dropping the approval handshake on round-trips).- Server
approval_timeoutclamped to[1, 3600]son the SDK side as defence against a malformed / overshooting backend that returns0or2147483647in the Разрыв 1c fiel [...]
Tests: 6 additions (tests/test_approval_money_flow.py, tests/test_business_impact.py, tests/test_execute_approval_flow.py…).
Compatibility: Backward compatible on the happy path. Every existing call site keeps working; the new errors are ValueError subclasses; the new BusinessImpact decorator kwarg is optional.
Approval-wait SDK sync with backend commit 0ad03b9 ("\u0420\u0430\u0437\u0440\u044b\u0432 1c", gate hot-path trigger). The backend now sends approval_timeout_seconds: Option<i64> and approval_expires_at: Option<String> on every /gate response so a backend approval rule can set a non-default short timeout. Pre-fix, the SDK only consulted NULLRUN_APPROVAL_TIMEOUT_SECONDS (env default 300s), which silently desynced from a 20s backend expiry sweeper. No public API change. No SDK_MIN_VERSION bump. No on-wire change.
- Approval wait uses server-authoritative
approval_timeout_secondswhen present \u2014 new optional kwargtimeout_seconds: float | None = Noneon `_wait_for_approval_resolu [...] check_workflow_budgetreadsresponse["approval_timeout_seconds"]with type and sign validation. Malformed values fall through to the env default path. [...]- Diverging server vs env default emits a DEBUG log line ("approval {id}: using server timeout={X}s (env default would have been {Y}s)") so an operator inspecting logs can see [...]
Tests: 1 additions (tests/test_approval_timeout_field.py).
Compatibility: The new timeout_seconds kwarg is optional with a None default, so existing callers are unaffected.
CI / coverage-testability release. No on-wire change, no SDK_MIN_VERSION bump, no public API change. Backends on 1.0.0 keep working unchanged.
pytestsuite is now CI-fast on Windows + xdist — a new_fast_sleepautouse fixture intests/conftest.pycaps test-codetime.sleepcalls at 1ms, with two opt-out paths [...]TestCircuitBreakerhalf-open tests no longer sleep the wall clock —test_open_transitions_to_half_open_after_timeout,test_half_open_success_closes, and `test_half_open [...]TestPingChainScheduleropts out of the cap via marker — the new@pytest.mark.slow_sleepmarker on the class letstest_ping_chain_emits_heartbeats_on_time_schedulekeep [...]
Tests: 3 additions (tests/conftest.py, tests/test_transport.py, tests/test_v3_wire_contract.py).
pyproject.toml— newmarkers = ["slow_sleep: opt out of the conftest autouse time.sleep cap"]entry under[tool.pytest.ini_options]. [...]- The Codecov badge in
README.mdwill now report the real combined coverage on master. Pre-Sprint-0 the badge was stuck at 0% becausecoverage run -m pytest -n autoran coverage in the coordinator process only; the Sprint 0 PR (#70) already fixed [...]
- No SDK public API change. No wire-format change. No backend migration required. [...]
- Pre-Sprint-0 instability under
pytest-cov + xdist:test_status.py::TestRecentErrorsandTestTransport::test_stop_flush_false_skips_final_flushwere observed to flake ~1/3 of the runs in the local environment (passing in isolation, passing in [...]
Drift-fixes release. Closes the SDK-side items on docs/drift.md (2026-07-04); no on-wire breaking change — backends on 1.0.0 keep working unchanged.
- Idempotency-key propagation to
/trackv3 single-event — newnullrun.context._server_minted_idempotency_key_var+get_/set_/reset_/clear_server_minted_idempotency_keyhe [...]
runtime.pymodule docstring now distinguishes SDK-side transport failure (network / 5xx / breaker open → fail-OPEN on the/checkpath) from wire 4xx/5xx that names an enforcement failure (BUDGET_REDIS_UNAVAILABLE→ 402 fail-CLOSED, `R [...]
- Wire
status_codepreserved on every decision exception —NullRunBlockedException,NullRunBudgetError,NullRunChainError,NullRunWorkflowInactiveError, `NullRunConsu [...] - Patch-coverage gap from 0.12.2 closed —
tests/test_v3_wire_contract.py::TestGateCacheRuntimeFlow(3 tests) drivesNullRunRuntime.check_workflow_budgetinside `with chain( [...]
Tests: 2 additions (tests/test_drift_fixes_2026_07_04.py, tests/test_v3_wire_contract.py).
- New
docs/drift.mdrecords the six P0 + P1 items that turned up during pre-publish review of 0.12.2 (idempotency-key wiring, status_code on exceptions, fail-CLOSED honesty, plus four P0/P1 README issues that are deferred to a README rewrite PR and [...]
Bug-fix release. Two related correctness fixes layered on top of 0.12.1; no wire-format change.
- BUG #4 —
/checkexecution_id:check_workflow_budget()now sends a freshuuidv7as theexecution_idfield on every call, instead of reusingworkflow_id. [...] - BUG #5 — chain-mode gate thrash: new
nullrun.runtime._GATE_CACHE(5s TTL, keyed on(workflow_id, chain_id, model)) collapses consecutive/gatecalls from inside `with c [...]
- 158 lines of contract tests in
tests/test_v3_wire_contract.py:TestGateExecutionId(per-call uniqueness + uuidv7 format validation) andTestGateCache(5 cache invariant + opt-out cases).
__version__bumped from 0.12.1 to 0.12.2.
Bug-fix release. The v0.12.0 changelog claimed the SDK propagates the server-minted execution_id from /check to /track but the wiring was never shipped — the SDK still sent client-supplied ids on /track/batch and ignored reservation_id on /check responses (audit fix per memory sdk-v3-migration-gaps).
This release closes the four gaps documented in docs/sdk-v3-migration-gaps.md:
check_workflow_budget()now readsresponse["reservation_id"]and stores it on a contextvar (nullrun.context._server_minted_execution_id_var).- New helpers
set_server_minted_execution_id/get_server_minted_execution_id/reset_server_minted_execution_id+ a paired_server_minted_reservation_attimestamp for the 295s TTL guard. _enrich_eventstampsexecution_idonto the /track payload when the captured reservation is fresh, and drops it (clearing the capture) once past the safety window — prevents forwarding a doomed id that would 503 on /track per CLAUDE.md section 33._route_trackroutesllm_callevents to the v3/api/v1/tracksingle-event endpoint viaTransport.track_single()so backendgate_consume_v3validates the consume-vs-reserve + epsilon invariant (CLAUDE.md section 25). [...]NULLRUN_V3_TRACK_DISABLE=1opt-out forces everything through the legacy batch path (backends still on v1/v2).
nullrun.context._server_minted_execution_id_var+nullrun.context._server_minted_reservation_at_var+ 6 helpers (get_/set_/reset_/clear_).nullrun.runtime._capture_server_minted_execution_id(response)— defensive UUID parse + warn-on-malformed.nullrun.runtime._route_track(wire_event)— dispatches to single-event /track or batch /track/batch.nullrun.runtime._build_v3_track_payload(event, reservation_id)— maps an enriched event onto the v3 /track wire schema.- 27 contract tests in
tests/test_v3_server_minted.pycovering contextvar hygiene, capture defence-in-depth, _enrich_event age threshold, _route_track dispatch, and end-to-end /gate -> /track round trip.
__version__bumped from 0.12.0 to 0.12.1 (post-release integrity fix — the v0.12.0 wiring never shipped before this).
- SDK no longer treats the /check
reservation_idfield as decorative. Each LLM-call track event now carries the server-minted uuidv7 the backend minted, so v3gate_consume_v3can find the matchingreservation:{execution_id}Redis key (300s TTL). - LLM-call events now POST to
/api/v1/track(v3 single-event) instead of/api/v1/track/batch. This exercises the consume-vs-reserve invariant that the batch path silently skipped (regression of the v1/v2monthly_costcounter — see CLAUDE.md section 0 G1).
Server-minted execution_id default ON. Per CLAUDE.md section 24, every /check now mints a server-side uuidv7 execution_id. The SDK no longer needs to generate its own; the response carries the server-minted id which propagates to /track. This is the SDK_MIN_VERSION for the v3 rollout - older SDKs still work for v1/v2 endpoints but should upgrade.
Integrity note (2026-07-04): the propagation claim in this entry was correct in intent but the actual wiring was not shipped in 0.12.0. See 0.12.1 above for the closing fix.
nullrun.uuid7module - RFC 9562 section 5.7 time-ordered ID generator. Used internally for trace_id and span IDs.nullrun.capabilitiesmodule - probe_capabilities(), parse_capabilities(), validate_sdk_version(). Wired into nullrun.init().
- version bumped from 0.11.0 to 0.12.0.
Wire-protocol v3 alignment with the backend's Sprint 6 v1 cut
(CLAUDE.md v3.4). The previous SDK shipped pre-v3 endpoints
(/api/v1/gate, /api/v1/execute, /api/v1/track/batch) without
the X-NULLRUN-PROTOCOL header that the v3 backend requires as a
fail-CLOSED pre-check — every signed POST was rejected with HTTP 400
PROTOCOL_HEADER_REQUIRED. This release aligns the SDK with the v3
wire contract and adds the missing soft-mode / chain / heartbeat /
cancel / budget-estimate surface.
X-NULLRUN-PROTOCOL: 3is now mandatory on every signed POST. The backend'sproxy/http/gate/protocol.rsmiddleware rejects requests without the header with HTTP 400 + error_codePROTOCOL_HEADER_REQUIREDBEFORE the gate pipeline runs. Pre-v3 SDKs that don't send it will get 400 on every request, including/auth/verify(which is unsigned but goes through the same protocol guard via the_post_auth_with_retrypath).- Routed through the new centralised helper in
nullrun.transport._protocol_header_value()so a future bump is a one-line change. - The header is set in
_build_signed_headers()(covers/gate,/execute,/track/batch,_refetch_credentials) AND inlined in the four call sites that build their own headers dict (track/batch, gate, execute, WS handshake, auth/verify refresh). Theruntime._auth_headers()helper was extended to include the header for the three directself._client.get/postcall sites (_post_auth_with_retry,_fetch_remote_state,get_org_status).
- Routed through the new centralised helper in
Transport.check_v3(request)— POST /api/v1/check. The v3 replacement for/gate. Adds three optional wire fields (CLAUDE.md §16):
nullrun.uuid7module - RFC 9562 section 5.7 time-ordered ID generator. Used internally for trace_id and span IDs.nullrun.capabilitiesmodule - probe_capabilities(), parse_capabilities(), validate_sdk_version(). Wired into nullrun.init().
- version bumped from 0.11.0 to 0.12.0.
Patch on top of 0.9.0. Unifies the LLM-call fingerprint scheme so the
dedup LRU at runtime.track() can collapse sibling emissions from the
httpx transport and the LangChain callback for the same real call.
-
Double-emission of llm_call events. Pre-0.9.1 the httpx transport (
NullRunSyncTransport._emit) and the LangChain callback (NullRunCallback.on_llm_end) each computed their own_fingerprintfrom different inputs —sha256(host|status|body)vssha256(json({path:"langchain_callback", run_id, response_id, model, provider, invocation_params})). The two fingerprints never collided, so the dedup LRU atruntime.track()could not collapse the two emissions for the same call. On a typicalapp.invoke()with 6 LLM calls the backend saw ~12llm_callevents on the wire (2 per real call), doublingllm_call_countand skewingcost_eventsaggregates.Post-fix both observers call the same helper
_fingerprint_for_llm_call(model, provider, response_id)with the three signals reachable from every observation path:- httpx transport reads
modelandidstraight out of the OpenAI-style response body (payload["model"],payload["id"]).
- httpx transport reads
Server-derived coverage replaces the in-process counter dicts.
Counter-bump helpers are gone; every llm_call span now carries
metadata.tracked and metadata.streaming_skipped flags so the
backend's coverage_pct query can compute coverage from span
metadata alone. Adds nullrun.shutdown() for clean WS close on
script exit.
NullRunRuntime.coverage_report()removed.NullRunRuntime._coverage_seen/_coverage_tracked/_coverage_streaming_skippedinstance attributes removed.NullRunRuntime.start_coverage_reporter()daemon thread removed (no longer called frominit())._safe_bump_coverage/_bump_streaming_skippedhelpers removed fromnullrun.instrumentation.auto.llm_callwire shape:metadata.tracked: boolandmetadata.streaming_skipped: boolare now authoritative; the separatecoverage_reportevent is dropped.
nullrun.shutdown(timeout=2.0): sends a clean WebSocket close frame and drains in-flight events. Long-running scripts that exit viasys.exit()previously let the kernel RST the TCP socket, which the backend logged as WARN "Connection reset without closing handshake". Registeringnullrun.shutdownin anatexithandler eliminates the noisy log. No-op ifinit()was never called.
Tests: 3 additions (tests/test_coverage_report.py, tests/test_coverage_seen_httpx.py, tests/test_llm_call_metadata_flags.py).
Additive patch on top of 0.8.2. Closes the same silent zero-billing class of bug 0.8.2 closed on the httpx path — but on the langgraph callback path and the init-ordering hazard that 0.8.2 didn't reach. Promotes the missing-model wire failure from WARN to fail-LOUD.
- langgraph callback model extraction.
_extract_model_from_responsenow consultsresponse.llm_outputFIRST. langchain-openai 1.x puts the date-suffixed model id (e.g.gpt-4.1-mini-2025-04-14) onLLMResult.llm_output, while the AIMessage insidegenerations[0][0].messageleavesresponse_metadataempty. The previous chain led withresponse_metadata, so every OpenAI-via-LangChain 1.x call silently zero-billed. Also adds an "any key containing model" sweep insidellm_outputfor non-OpenAI wrappers (proxies, custom chat models). - Init-ordering hazard for
patch_httpx. The class-level__init__wrap only catches Clients created AFTER it is installed. Users that buildChatOpenAI(...)beforenullrun.init(api_key=...)end up with a pre-existinghttpx.Clientthat the patch never sees.patch_httpxnow sweepsgc.get_objects()once at install and wraps any pre-existingClient/AsyncClientwhose transport isn't already aNullRun*Transport. Idempotent via the existing class-level marker. - Fail-LOUD missing-model wire tag.
runtime.track()now escalates the missing-model warning fromlogger.warningtologger.error, bumps adropped_llm_call_no_modelruntime counter for dashboards, and tags the wire event with__missing_model: Trueso the backend'sinto_track_requestgate can reject with HTTP 422 instead of silently recording a zero-cost call. The event is still sent (not fail-CLOSED) so the backend can audit; the flag is wire-private and stripped before persisting. Activated only forllm_call; other event types are silent.
Additive patch on top of 0.8.0. No public-API break. Continues the 0.8.0 wire-format audit with two regressions that were caught on review and one contract test that pins the post-2026-06-27 backend schema so a future rename can't silently break the SDK.
track_coverage()emits counter dicts underevent.metadatainstead of the event top level. Pre-fix the per-hostseen/tracked/streaming_skippeddicts sat at the event root, where serde silently dropped them —SdkTrackRequestuses explicit fields with no#[serde(flatten)]catchall, so unknown keys are discarded. The dashboard'slast_coverage_pctwas permanentlynullbecause every coverage report landed with emptyseen/tracked/streaming_skippedJSONB columns. Pin:tests/test_coverage_report.py::test_track_coverage_emits_wire_shape_with_metadata_nesting.- Request-body model fallback in
NullRunSyncTransport._emit. When the response body extractor returnsNoneformodel(OpenAI Responses API, Anthropic streaming edge cases),_extract_model_from_request_bodyreads the model string the user embedded in the request body viaChatOpenAI(model="gpt-4.1-mini"). Without this every such call was zero-billed — backendunwrap_or("default")+DEFAULT_RATE≈ $0/call. Unit-tested intests/test_model_fallback.py.
Tests: 1 additions (tests/test_batch_response_parsing.py).
SDK↔backend wire-format audit. Closes a class of silent-fail-OPEN
path that was sending model=None (or model="unknown") on
/track for many LLM-vendor paths — every such event cost the
backend a model_pricing lookup that returned no row, fell
through to DEFAULT_RATE (~$30/M), and emitted a fallback warning
the operator couldn't reproduce because the offending observation
was buried in another package's telemetry.
No public-API break. No behavior change for callers whose
instrumentation already populates model correctly. Pure wire-
payload hygiene.
-
NullRunRuntime.track()stripsNonevalues from the wire payload. Pre-0.8.0 the runtime forwarded every key inenrichedexcept those in_WIRE_STRIP_FIELDS, including keys whose value wasNone. Putting{"model": null}on the wire triggered backendunwrap_or("default")and a fallback warning. Backend handles a missing key as well asnull; droppingNonehere keeps the diagnostic signal loud (the newWARN track(): llm_call event missing 'model' fieldfires on missing-key, which is what we want operators to see) instead of silent (the JSON-null case). Activated only forllm_callsospan_start/span_end/tool_calltraffic doesn't pollute logs. -
All four instrumentation paths now extract
model/providerfrom the response object as a fallback, not just frominvocation_params/self.model. When langchain 1.x stopped forwardinginvocation_paramstoon_llm_end, every LangChain-callback track event carriedmodel="unknown"and the backend cost pipeline fell through toDEFAULT_RATE. The
Additive patch on top of 0.7.7. Converts two silent fail-OPEN footguns
into explicit DeprecationWarning / RuntimeError. No behavior
change for callers who don't touch the deprecated surface.
NullRunRuntime.start_recording()andNullRunRuntime.stop_recording()now emitDeprecationWarning. They have been silent no-op stubs since Sprint 2.1 (0.4.0). [...]- Setting
NULLRUN_USE_GRPC=1now raisesRuntimeErrorat SDK init instead of silently falling back to HTTP with an info log. gRPC transport remains on the roadmap but is not yet implemented. Unset the env var to use HTTP. See https://docs.nullrun.io/reference/sdk-api#transport
- Replace
runtime.start_recording(workflow_id, metadata=...)with a dashboard navigation ornullrun.status()introspection. - Remove any
NULLRUN_USE_GRPCenv var from deployment configs (Docker compose, k8s manifests, systemd units). - Catch
RuntimeErrorat SDK init if you want to keep the env var as a feature flag — but the recommended path is to unset it.
Additive patch on top of 0.7.6. Fixes the /gate pre-flight so the
backend can compute projected_cost and tool_block decisions from
real per-call data instead of the previous fake "budget-precheck"
sentinel and empty tool list. No breaking changes — new helpers
default to None / empty so existing call sites keep working.
nullrun.set_call_context(model=..., tools=[...])— per-call context the SDK forwards to/gateso the backend can enforce budget tiers and tool-block on real values.import nullrun with nullrun.workflow(name="support-bot"): nullrun.set_call_context( model="claude-sonnet-4-6", tools=["shell.run", "code.eval"], ) @nullrun.protect def chat(message: str) -> str: return agent.run(message)
model(optional) — LLM model name. Backend uses it to look up the per-model rate fromtool_pricing(Postgres) soprojected_costmatches what/trackwill compute from real token counts. Defaults toNone(backend falls back toclaude-sonnet-4default rate).tools(optional) — list of tool names the call intends to use. Backend matches each against the workflow's effectiveblocked_toolsaggregate and returnsblockon any match.Noneleaves whatever was previously set;[]clears.
Additive patch on top of the 0.7.0 thin-client refactor. Brings a FastAPI integration, a default user-facing message catalog, and small transport consistency fixes. No breaking changes.
nullrun.integrations.fastapi— one-line FastAPI integration that turns everyNullRunDecision/NullRunInfrastructureErrorthrown by@nullrun.protectendpoints into a clean JSON response with the right HTTP status code. No per-endpointexceptblocks required.Response shape:from fastapi import FastAPI import nullrun from nullrun.integrations.fastapi import install nullrun.init(api_key="nr_live_...") app = FastAPI() install(app) @app.post("/chat") @nullrun.protect def chat(message: str) -> str: return agent.run(message)
{ "error_code": "NR-B004", "user_message": "You've reached the usage limit...", "category": "decision" }
SDK is now a thin client. All enforcement decisions arrive from the
backend via /api/v1/gate and /api/v1/execute. Local policy
enforcement, its dataclass, and its hardcoded thresholds are removed.
Removed:
class Policy,Policy.default_local(),Policy.strict_local(),Policy.from_dict()(was atnullrun.runtime.Policy)NullRunRuntime.policypropertyNullRunRuntime(policy=...)constructor kwargNullRunStatus.active_policy,.fallback_policy,.fallback_reason,.last_policy_fetch,.last_policy_fetch_age_secondsfieldsTransport.fetch_policy()methodTransport.clear_policy_cache()methodFallbackMode.CACHEDenum value (gate-decision fallback)- Local loop/rate detectors:
LoopTracker,RateTracker,LocalDecisionclasses NullRunRuntime._local_check(),_loop_tracker,_rate_trackerinstance attrs_local_loop_threshold,_local_rate_limitinstance attrs (hardcoded 6/1000)CachedDecision,PolicyCachetransport classes (tied to the removed CACHED fallback mode)NULLRUN_FALLBACK_MODEenv varNULLRUN_POLICY_FAIL_OPENenv var (no longer needed — backend is authoritative)NullRunRuntime._fetch_policy()method (no local policy fetch on init)- WS
on_policy_invalidatedcallback (no local policy to invalidate)
Additive release — Layers 1, 2, and 3 of the "give the user a chance" design land together. Structured exceptions, a global error hook, and a synchronous runtime snapshot. No breaking changes.
Every public SDK exception now carries a stable, grep-able
error_code (e.g. NR-A001, NR-B002, NR-R001) plus a short
imperative user_action and a retryable flag, so cookbook
examples and Sentry integrations can branch on the code instead
of parsing the message string.
-
NullRunError— structured base for every user-facing SDK exception. Carries four actionable fields:error_code— stableNR-LETTERNNNidentifier (documented per-code indocs/errors/<code>.md).user_action— short imperative next-step hint ("Set NULLRUN_API_KEY", "Verify API key at …", "Retry in 30s — backend is down", …). Empty when there is no actionable step.retryable—Trueonly for transient failures (5xx, network blip, transient auth);Falsefor config, permission, and budget-exhausted (retrying without changing something will just hit the same wall).docs_url— per-code docs page (falls back to thehttps://docs.nullrun.io/errorsindex when the per-code page does not exist yet).cause— optional chainedBaseException.
-
New specialized exception classes (each is a subclass of the existing user-facing class, so existing
exceptclauses keep matching):
Hardening pass driven by the 2026-06-22 SDK↔backend integration audit. Closes three classes of silent fail-OPEN regressions that the previous release shipped: SDK POSTs being rejected by the backend's CSRF middleware, WS HMAC identity field drift, and policy-fetch silently falling through to a permissive default on any backend blip. Coverage jumped from ~76% to 84.59% (branch = true).
-
FIX-F3 — every signed POST now carries
Authorization: Bearer <api_key>. The backend's CSRF middleware (backend/src/auth/csrf.rs::has_bearer_auth) bypasses the cookie-double-submit check whenever any non-emptyAuthorizationheader is present. Pre-fix the SDK only sentX-API-Key, so every POST hit the "state-changing request without session cookie" branch and got 403 — which the SDK'stry/exceptaround/gate,/track,/check, and/executesilently swallowed. The net effect was that every SDK-side enforcement gate was effectively fail-OPEN on production traffic. The fix uses the user-facingapi_keyas the Bearer value so the bypass header is meaningful for debugging; the canonical auth path is stillX-API-Key(+ HMAC when configured). Safe percsrf.rs:80-95(browsers never auto-attachAuthorizationto cross-site requests, so this is not a CSRF regression). -
FIX-F4 — WebSocket HMAC identity field pinned to
api_key. AddedWS_HMAC_IDENTITY_FIELD = "api_key"constant intransport_websocket.pymatching the backend'sSignedWsMessagestruct (backend/src/proxy/http/ws_control.rs:43). The SDK now readsdata["api_key"](withdata["api_key_id"]as a backwards-compat fallback for pre-FIX-F4 servers) to verify the HMAC signature. Pre-fix a future server-side rename would silently break WS signature verification with no compile-time signal. -
Policy fetch is now fail-CLOSED (F-R2-02). Pre-fix, any HTTP exception, non-200 status, or empty
{"data": []}response silently
This release bundles the Sprint 2.5 production-readiness hardening
alongside the Phase 0 contract / lifecycle fixes. The two streams were
shipped as separate [Unreleased] sections during development; they
are merged here into a single canonical entry so release tooling that
scans for the [Unreleased] anchor picks up the complete change set
exactly once.
-
HMAC signing expanded (with documented exceptions, audit 2026-06-22 round 2 — F-R2-05 / F-R2-14). The SDK now signs every outgoing POST/GET that the backend's
HMAC_REQUIRED_PATHSallowlist requires:/track/batch,/gate,/check,/execute. The header set is built via_add_hmac_headers(Content-Type, X-Signature, X-Signature-Timestamp, X-API-Key, Authorization for CSRF bypass). Compliance with the canonicalHMAC-SHA256(secret_key, "<ts>:<api_key>:<sha256_hex(body)>")formula frombackend/src/auth/hmac.rs:6-9.Explicitly NOT signed (chicken-and-egg / backend allowlist):
runtime._authenticate→POST /api/v1/auth/verifyon initial bootstrap: nosecret_keyexists yet (it is what /auth/verify hands back). The key-rotation refetch (Transport._refetch_credentialsat transport.py:1588) IS signed becausesecret_keyis then populated.runtime._fetch_policy→GET /api/v1/orgs/{id}/policies. Not inHMAC_REQUIRED_PATHS(backend/src/proxy/middleware/ hmac_verify.rs:58). Backend allowlist is authoritative.runtime._fetch_remote_state→GET /api/v1/orgs/{id}/workflows/ {wf}. Not inHMAC_REQUIRED_PATHS.runtime.get_org_status→GET /api/v1/orgs/{id}/status. Not inHMAC_REQUIRED_PATHS.
Outgoing WebSocket ACK is plain JSON, not signed. Earlier documentation overstated this —
transport_websocket._send_ack
Production-readiness release. Resolves all BLOCKER + HIGH + MEDIUM + LOW
audit findings from the 0.3.x audit. The curated 6-symbol public surface
(init, protect, track_llm, track_tool, track_event,
__version__) is unchanged. Full PR-by-PR description follows; this
entry is the summary. Phase-7 (framework patches) and Phase-8
(release-prep polish) ship as follow-up releases under the same 0.4.x
line.
-
BoundedDictclass (runtime.py) — dead since 0.3.1. -
wrap_tool,wrap,check_before_tool,enforce_check_before_llm,check_before_llm(and theCheckDecisiondataclass),evaluate(runtime.py) — zero in-tree callers;wraphad a latentNameErrorthat's gone with the deletion. -
clear_pause(actions.py) — zero callers. -
WorkflowContextclass (context.py) — duplicate of theworkflow()contextmanager. -
WebSocketManager(transport_websocket.py) — never instantiated; the runtime usesWebSocketConnectiondirectly. -
PoolConfig+AdaptivePool(transport.py) — never instantiated;httpx.Limitsis the real pool. -
Transport._atexit_flush(transport.py) — orphan method from the pre-weakref.finalize migration. -
EventRecorder(decision_history.py) — never used. -
First-
track()AttributeError(Phase 2).runtime.track()no longer readsself._workflow_costs(a BoundedDict removed in 0.3.1 whose two callers survived). Returnslocal_cost_cents = 0from the new_local_cost_cents_estimateattribute. -
auto_requestsmodule was unimportable. The missing_safe_bump_coveragehelper thatauto_requests.pyimports is now defined inauto.py. The whole module imports cleanly and the coverage dashboard counter is reachable. -
auto_instrument()now callspatch_requests. Therequests
Production-readiness hardening. No public-API changes; the curated 6-symbol
surface is unchanged. Aligns the SDK with the contracts in
NULLRUN/docs/adr/008-sdk-preflight-fail-policy.md and
NULLRUN/docs/kill-contract.md.
- gRPC transport code path removed.
create_grpc_transportwas referenced but never defined, so settingNULLRUN_USE_GRPC=1raisedNameErrorat init. The gRPC server at the platform is intentionally frozen until the activation checklist (TLS, auth, proto extensions, cost pipeline parity, tests) is complete. The SDK now logs an INFO line onNULLRUN_USE_GRPC=1and silently falls back to HTTP. Thegrpciohard dependency has been dropped frompyproject.toml. If/when gRPC is unblocked, the SDK will add it back as a separate optional extra. InsecureTransportErrorURL check hardened. Replaced thestartswith("http://127.0.0.1")chain with aurllib.parse.urlparseipaddress.ip_addresscheck. The previous check lethttp://127.0.0.1.attacker.comandhttp://localhost.evil.comthrough (homograph attacks) and rejectedhttp://[::1]:8080(IPv6 loopback). The new check allows the full127.0.0.0/8IPv4 loopback range,::1, andlocalhost(case-insensitive).
signal.signalglobal hijack removed.Transport.__init__no longer installs a process-wideSIGTERM/SIGINThandler that calledsys.exit(0)from inside the signal context. The fix contract was already pinned intests/test_signal_safety.pyand is now applied to the source.atexit.registerreplaced withweakref.finalize. The per-Transportatexitchain was growing without bound in long-running deployments; weakref finalizers only fire if the transport is still alive at process exit.Transportis now a context manager.with Transport(...) as t:starts the flush thread on enter and stops it on exit. Replaces the manualstart() / stop()pair that was easy to forget.
- No-api-key init now raises (T3-S2):
nullrun.init()andNullRunRuntime(...)without anapi_key(and withNULLRUN_API_KEYunset) now raiseNullRunAuthenticationErrorinstead of falling back to aNullRunNoopstub. The previous silent fallback silently bypassed every backend gate (budget, policy, control plane) — a real safety hole in production. Action required: ensureapi_key="nr_live_..."is passed toinit()(orNULLRUN_API_KEYis set) in every entry point. The0.2.0deprecation warning has been removed; the new behavior is hard. local_modefield removed: The auto-derivedlocal_modeflag onNullRunRuntimeis gone. Theis_local_modeproperty and theNullRunNoop/NullRunNoopBreaker/_NullContextclasses are deleted (nullrun.noopmodule removed). All call sites that readruntime.local_modewill seeAttributeError— there is no migration path because the field no longer has meaning. Code paths that previously branched onlocal_modenow always go through the cloud runtime (auth + policy fetch + control plane).
- Legacy Breaker exports (T9): The 7 legacy re-exports
(
nullrun.BreakerError,nullrun.CostLimitExceeded,nullrun.ApprovalRequired,nullrun.BreakerTimeout,nullrun.Policy,nullrun.FallbackMode,nullrun.PoolConfig) are no longer reachable asfrom nullrun import X. The canonical exception names (NullRunBlockedException,WorkflowPausedException,WorkflowKilledException,NullRunAuthenticationError, …) and the canonical policy/transport modules (from nullrun.runtime import Policy,from nullrun.transport import FallbackMode, PoolConfig) remain available. Audited for 0 external callers.
- CR-2: Fixed buffer overflow when circuit breaker is OPEN. Previously, re-queued events were prepended to buffer, causing newest events to be dropped first. [...]
- CR-5: Async circuit breaker now uses
asyncio.Lockinstead ofthreading.Lockfor proper async context handling. - CR-1+CR-4:
runtime.pynow creates Transport before_authenticate()and_fetch_policy(), reusing the HTTP client for connection pooling and consistent timeout/retry poli [...] - AsyncAwait: Fixed
_call_async()not awaiting_on_success_async()and_on_failure_async()coroutines, causing "coroutine was never awaited" warnings in async transport.
- Transport buffer now enforces max_buffer_size before re-queuing events on circuit breaker OPEN
-
Circuit breaker core (
src/nullrun/breaker/) with STRICT / PERMISSIVE / CACHED fallback modes -
HTTP transport with batch event sending (
transport.py) -
Async transport for asyncio applications
-
Retry logic with jitter and policy-aware backoff
-
@protectdecorator for wrapping functions (decorators.py) -
Workflow context support (
context.py) -
Main runtime entrypoint (
runtime.py) -
X-API-Versionheader on all outgoing requests -
Requires Python ≥ 3.10
-
Compatible with NullRun API version
2024-01-15