Commit e7518f2
committed
release(0.13.0): drift-fixes — idempotency_key on /track + status_code on decisions + patch coverage
Three SDK-side fixes per docs/drift.md (2026-07-04) P1 items + open
Q4. The remaining drift items (P0-1 / P0-2 / P0-3 / P0-4 / P1-3 /
P1-4) are README-only — SDK code is correct, SDK_README.md is
wrong. Those go in a separate README rewrite PR; do not block this
release.
Plus a 4th fix that was missing on 0.12.2: this commit also closes
the codecov/patch-coverage gap that dragged PR #52 below the 70%
floor.
1. Idempotency-key propagation to /track v3 single-event (P1-5 + Q4)
* `_capture_server_minted_execution_id` now also reads
`response["operation_id"]` (which equals the /check
`idempotency_key`, runtime.py:1260).
* `_enrich_event` stamps the value onto `wire_event` for `llm_call`.
* `_build_v3_track_payload` propagates it onto the v3 /track body
with a contextvar fallback for tests + direct callers.
Why: without this, transport-level retry on the same event either
(a) re-runs CONSUME_SCRIPT -> 503 RESERVATION_NOT_FOUND since the
reservation key was DEL-ed after the first consume per CLAUDE.md
§25, or (b) double-bills the underlying budget.
2. status_code preserved on every decision exception (P1-1)
* NullRunBlockedException / NullRunBudgetError / NullRunChainError
/ NullRunWorkflowInactiveError / NullRunConsumeOverbudgetError
now accept status_code: int | None = None.
* _parse_v3_error_envelope populates it from response.status_code
for every branch: 402 budget, 403 workflow/chain cross-org, 422
CONSUME_OVERBUDGET, 503 RATE_LIMIT_REDIS_UNAVAILABLE, etc.
Why: FastAPI exception handlers reading `exc.status_code` previously
got None / 500 for budget blocks — the backend's 402 was lost in
the NullRunBudgetError -> NullRunBlockedException constructor chain.
3. fail-CLOSED / fail-OPEN honesty in the runtime.py module docstring
(P1-2)
Distinguishes SDK-side transport failure (network / 5xx / breaker
open -> fail-OPEN on the /check path) from wire 4xx/5xx that names
an enforcement failure (BUDGET_REDIS_UNAVAILABLE -> 402 fail-CLOSED;
RATE_LIMIT_REDIS_UNAVAILABLE -> 503 fail-CLOSED). The README had
conflated the two with a single "Fail-OPEN on infra failures"
claim; README rewrite is tracked separately under drift.md P0-1.
4. Patch-coverage gap (regression fix from 0.12.2)
* tests/test_v3_wire_contract.py::TestGateCacheRuntimeFlow — 3
runtime-level chain-mode cache tests that drive
NullRunRuntime.check_workflow_budget inside
`with workflow(...) + with chain(...)`. Covers
runtime.py:1287-1310 (cache_enabled predicate, cache key, cache
hit/miss branches, NULLRUN_GATE_CACHE_DISABLE=1 bypass).
* These cover the exact range that dragged PR #52 codecov/patch
below 70%.
Files in this commit
* src/nullrun/__version__.py — bumped 0.12.2 -> 0.13.0 + 0.13.0
release block in the docstring.
* pyproject.toml — version = "0.13.0" + drift-release comment
(drift-prevention, same pattern as #50).
* CHANGELOG.md — new [0.13.0] - 2026-07-04 section preceding
[0.12.2].
* docs/drift.md — NEW audit document (the file referenced by the
fix(sdk) commit message).
* tests/test_v3_wire_contract.py — 190 lines of TestGateCacheRuntimeFlow
(3 tests) appended to the existing TestGateCache class block.
Tests: 140+70 critical-path tests pass (test_v3_server_minted,
test_error_envelope, test_handle, test_protect, test_capabilities,
test_drift_fixes_2026_07_04, test_runtime_branches,
test_transport_branches, test_integration_contract,
test_high_reliability_fixes). The 3 new TestGateCacheRuntimeFlow
tests are confirmed green on local pytest pre-commit. No regression
on test_drift_fixes_2026_07_04 (15 fix(sdk) tests).
Backends on 1.0.0 keep working unchanged. Pinning unchanged:
SDK_MIN_VERSION_FOR_V3 = "0.12.0". Recommended upgrade path:
0.12.2 -> 0.13.0 (no on-wire breaking change).1 parent 5cd7349 commit e7518f2
5 files changed
Lines changed: 356 additions & 7 deletions
File tree
- docs
- src/nullrun
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
11 | 38 | | |
12 | 39 | | |
13 | 40 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
86 | | - | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
87 | 145 | | |
0 commit comments