fix(#20): heid-bug-hunt fixups — probe ConnectFailed + adapter finite-PAD (slice-3)
The slice-3 heid-bug-hunt panel (3/3) caught a real regression the cutover introduced, plus a chokepoint-invariant gap: - ConnectFailed escaped both rewired CLI probes. When --set-persona-pad and --seed-first-message moved off raw httpx onto the wt adapter, transport failures changed class: the SDK normalizes any pre-response transport error to worldtree_sdk.ConnectFailed (request.py), a WorldtreeError (not ApiError), so it passed the adapter unmapped AND the probes' httpx-only except tuples → an uncaught traceback instead of the graceful [network_error] exit 21. _amain (slice-2) already handled it; the probes lagged. Fix: add ConnectFailed to both probe except tuples (mirrors _amain). Live-verified at a refused host → [network_error] exit 21. - Finite-PAD enforced only at the CLI, not the adapter chokepoint. wt.set_persona_state delegated finiteness to the caller (documented), so a direct/non-CLI caller passing nan/inf got a raw SDK ConfigurationError. Fix: assert finiteness in the adapter precondition (consistent with its other precondition asserts) so the invariant holds at the chokepoint in ratatoskr's own terms; the CLI pre-check stays for the friendly usage error. Triaged-and-declined (all correct per the panel + Heid's source-check): the deleted sessions.py exports (intended no-shim cutover, zero un-migrated importers), the session["session_id"] index (accept-known-risk, matches --new), and Regin's "web indefinite block" (refuted — the seed is asyncio.wait_for-bounded). The concurrent heid-code-review panel returned zero drift, no code change. TDD: 3 RED tests (both probes' ConnectFailed → exit 21; adapter nan/inf/-inf → AssertionError, never reaches the SDK) → GREEN. Suite 469; ruff clean; mypy no new errors.
This commit is contained in:
@@ -482,6 +482,16 @@ class TestSetPersonaState:
|
||||
await set_persona_state(_wt(fake), "s", pleasure=0.0, arousal=0.0, dominance=0.0)
|
||||
assert ei.value.status == 500
|
||||
|
||||
async def test_non_finite_pad_rejected_at_the_chokepoint(self) -> None:
|
||||
# The finite-PAD invariant is enforced at the adapter (not only the CLI): a
|
||||
# non-finite axis would serialize to null and corrupt the injection, so a
|
||||
# direct caller is rejected pre-SDK — never a leaked SDK ConfigurationError.
|
||||
fake = _FakeSessions(result=None)
|
||||
for bad in (float("nan"), float("inf"), float("-inf")):
|
||||
with pytest.raises(AssertionError):
|
||||
await set_persona_state(_wt(fake), "s", pleasure=bad, arousal=0.0, dominance=0.0)
|
||||
assert fake.calls == [] # never reached the SDK
|
||||
|
||||
|
||||
class TestWriteAuthoredHistory:
|
||||
"""slice-3: write_authored_history → SDK sessions.write_history. Builds the
|
||||
|
||||
Reference in New Issue
Block a user