Commit 00b0b6c
committed
Align SDK 0.1.5 with TRACE 0.5.x runtime + handler
This is the alignment audit follow-up: the SDK now matches the
canonical TRACE wire schema and the RunPod handler envelope
field-for-field on every shape that production callers consume
(groundedness scoring, redaction, compression, memory, rollup).
Key fixes that callers see immediately:
* RunPod handler error envelope ({error_code, error, hint, status_code,
docs_url}) is now decoded into the structured _Envelope used by
LatenceTraceAPIError. Prior versions only matched {code, message}
and silently degraded RunPod failures to "HTTP {status}".
* GroundednessRequest accepts `language` as the canonical field
(with `locale` as a deprecated alias). The server reads `language`
to pick the per-class calibration bundle; older SDK calls that
set `locale` were silently dropped on the server.
* RunPod transports now default response_format=canonical so the
typed GroundednessResponse populates nested scores / runtime_decision
blocks instead of receiving the flat compact dict (which left most
typed fields at None).
* score_groundedness exposes profile, response_format,
include_triangular_diagnostics, evidence_limit, heatmap_format,
auto_decide as first-class kwargs alongside the existing extra
fall-through.
* rollup() normalizes the RunPod {success, action, rollup: {...}}
envelope into the same metrics dict REST returns, and gains an
as_model=True flag returning the new typed RollupResponse.
Typed model parity bumps:
* GroundednessScores gains nli_aggregate, primary_score/name,
reverse_context*, semantic_entropy_*, literal_*, structured_*,
context_*_ratio, support_units_usage_*, and the AST/phantom
channels emitted by the code lane.
* GroundednessResponse adds top-level band/score/groundedness_v2,
corpus_route, heatmap, warnings, scoring_mode, profile,
effective_profile, session_id, *_diagnostics, and the
next_session_state / next_memory_state lanes.
* RuntimeDecision adds band, policy_version/policy_sha256,
head_registry_sha256/head_version, reason_codes, evidence,
unsupported_spans, allow/block_disabled, allow/block_threshold,
rollback_safe -- covering the full RuntimeDecisionRecord, including
the new calibration_band_coercion reason code.
* MemoryUpdateResponse.hot_context becomes required (server
contract); CompressionResponse.provider stays Optional[str].
* RollupResponse mirrors the FastAPI shape so as_model=True works
for both REST and RunPod transports.
Helper updates:
* GroundednessResponse.fill_native_risk_band promotes risk_band
from scores.risk_band -> top-level band -> runtime_decision.band
(in that priority order), matching the new backend coercion.
* integrations._band_utils.resolve_band/resolve_score prefer the
calibration risk_band / trace_score over the head-driven
runtime_decision.band / decision.score, so adapter consumers
render the same band the event log shows.
Deferred to a separate release: typed RunPod action mappings for
the nine /v1/trace/sessions* paths. Those require typed session
models and live outside the groundedness/rollup hot path.
Bumps version 0.1.4 -> 0.1.5 (pyproject.toml + DEFAULT_USER_AGENT).
All 41 unit tests green (27 existing + 14 new alignment regressions).1 parent 36b1380 commit 00b0b6c
9 files changed
Lines changed: 1113 additions & 140 deletions
File tree
- src/latence
- integrations
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| 35 | + | |
35 | 36 | | |
36 | 37 | | |
| 38 | + | |
37 | 39 | | |
38 | 40 | | |
39 | 41 | | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
40 | 45 | | |
| 46 | + | |
| 47 | + | |
41 | 48 | | |
42 | 49 | | |
43 | 50 | | |
| |||
49 | 56 | | |
50 | 57 | | |
51 | 58 | | |
52 | | - | |
| 59 | + | |
53 | 60 | | |
54 | 61 | | |
55 | 62 | | |
| |||
64 | 71 | | |
65 | 72 | | |
66 | 73 | | |
| 74 | + | |
67 | 75 | | |
68 | 76 | | |
69 | 77 | | |
| 78 | + | |
70 | 79 | | |
71 | 80 | | |
72 | 81 | | |
| |||
79 | 88 | | |
80 | 89 | | |
81 | 90 | | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
82 | 94 | | |
| 95 | + | |
| 96 | + | |
83 | 97 | | |
84 | 98 | | |
85 | 99 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
| 28 | + | |
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| |||
106 | 106 | | |
107 | 107 | | |
108 | 108 | | |
109 | | - | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
110 | 127 | | |
111 | 128 | | |
112 | 129 | | |
| |||
138 | 155 | | |
139 | 156 | | |
140 | 157 | | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
141 | 163 | | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
142 | 181 | | |
143 | 182 | | |
144 | 183 | | |
145 | 184 | | |
146 | 185 | | |
| 186 | + | |
| 187 | + | |
147 | 188 | | |
148 | 189 | | |
149 | | - | |
150 | | - | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
151 | 203 | | |
| 204 | + | |
152 | 205 | | |
153 | | - | |
154 | | - | |
| 206 | + | |
| 207 | + | |
155 | 208 | | |
156 | 209 | | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
| 210 | + | |
162 | 211 | | |
163 | 212 | | |
164 | 213 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
| |||
41 | 42 | | |
42 | 43 | | |
43 | 44 | | |
44 | | - | |
45 | 45 | | |
46 | 46 | | |
| 47 | + | |
47 | 48 | | |
48 | 49 | | |
49 | 50 | | |
| |||
344 | 345 | | |
345 | 346 | | |
346 | 347 | | |
| 348 | + | |
347 | 349 | | |
348 | 350 | | |
349 | 351 | | |
350 | 352 | | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
351 | 360 | | |
352 | 361 | | |
353 | 362 | | |
| |||
361 | 370 | | |
362 | 371 | | |
363 | 372 | | |
| 373 | + | |
364 | 374 | | |
365 | 375 | | |
366 | 376 | | |
367 | 377 | | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
368 | 385 | | |
369 | 386 | | |
370 | 387 | | |
| |||
428 | 445 | | |
429 | 446 | | |
430 | 447 | | |
| 448 | + | |
| 449 | + | |
431 | 450 | | |
432 | | - | |
433 | | - | |
| 451 | + | |
| 452 | + | |
434 | 453 | | |
435 | 454 | | |
436 | 455 | | |
437 | 456 | | |
438 | 457 | | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
439 | 462 | | |
440 | 463 | | |
441 | 464 | | |
| |||
470 | 493 | | |
471 | 494 | | |
472 | 495 | | |
| 496 | + | |
473 | 497 | | |
474 | 498 | | |
475 | 499 | | |
476 | 500 | | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
477 | 508 | | |
478 | 509 | | |
479 | | - | |
480 | | - | |
481 | | - | |
482 | | - | |
483 | | - | |
484 | | - | |
485 | | - | |
486 | | - | |
487 | | - | |
488 | | - | |
489 | | - | |
490 | | - | |
491 | | - | |
492 | | - | |
493 | | - | |
494 | | - | |
495 | | - | |
496 | | - | |
497 | | - | |
498 | | - | |
499 | | - | |
500 | | - | |
501 | | - | |
502 | | - | |
503 | | - | |
504 | | - | |
505 | | - | |
506 | | - | |
507 | | - | |
508 | | - | |
509 | | - | |
510 | | - | |
511 | | - | |
512 | | - | |
513 | | - | |
514 | | - | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
515 | 536 | | |
516 | 537 | | |
517 | 538 | | |
| |||
0 commit comments