Skip to content

fix(haiku): a marker outside the scanned fields read as no marker at all (#320) - #321

Merged
fdaviddpt merged 1 commit into
mainfrom
fix/320
Aug 8, 2026
Merged

fdaviddpt merged 1 commit into
mainfrom
fix/320

Conversation

@fdaviddpt

Copy link
Copy Markdown
Contributor

Closes #320

The assumption that was never pinned

_failure_haystack scans a fixed set of fields on the terminal record. The set was three string literals inside a loop — never named, never asserted, and documented as something it is not: the docstring claimed the fallback covers unrecognised payloads, and it does not when a recognised field is non-empty.

So a deciding token arriving in a field nobody listed reads as no marker present, which is the same render as a genuinely clean record. The classic shape here: an absence produced by the scan, read as an absence in the world.

Verified before building: the issue's own claim that this is not a present defect holds — today's terminal-record schema has no unrecognised diagnostic field. Fixed anyway, because nothing stopped the next schema addition from reintroducing it silently.

Three states, not a wider net

The issue offered widening the fallback — re-scan the raw payload when the authored text holds no marker. Rejected, and this is the judgment call worth reading:

on a failing call the authored fields hold no marker in the ordinary case. So that branch re-enables the full raw scan for essentially every non-auth failure, and the conversation regains the un-isolated-retry decision — which is the entirety of what #318 closed.

Instead: retry / silence / decline and say so. On "no marker found", _marker_missed_by_the_scan re-reads only the record's unrecognised keys, and if a deciding token sits there it emits a warning naming the token, the field, the scanned set and the fix — then returns False unchanged. It reports; it does not decide.

Scoped to the terminal record's unrecognised keys and deliberately not to the conversation: otherwise the notice fires on every ordinary network failure in a session that happened to discuss a login problem, and a warning that fires on the common case stops carrying information.

unknown option is covered alongside the auth markers — same scan, same decision, same blindness.

Tests

RED, before the implementation:

FAILED tests/test_auth_marker_blind_spot_320.py::test_a_marker_outside_the_scanned_fields_does_not_silently_read_as_clean
FAILED tests/test_auth_marker_blind_spot_320.py::test_the_report_names_the_marker_and_the_fields_that_were_scanned
FAILED tests/test_auth_marker_blind_spot_320.py::test_a_flag_rejection_outside_the_scanned_fields_is_reported_too
FAILED tests/test_auth_marker_blind_spot_320.py::test_the_recognised_field_set_is_pinned
4 failed, 4 passed in 0.35s

The four passing are controls that must hold against the unfixed code.

GREEN, full suite:

1505 passed, 43 skipped in 852.76s
Total coverage: 94.27%

Platform

Pure str/json — no paths, no separators, no subprocess, no platform-divergent exception types. pipeline/haiku.py carries from __future__ import annotations, so the new tuple[str, str] | None return annotation is not evaluated on the 3.9 floor, and tests/test_pep604_floor_guard.py passes.

Green on macOS. Windows and the 3.9 leg unverified locally — CI is the check.

…no marker

`_failure_haystack` scans error/result/message, the errors list and stderr, and falls back to the raw stdout scan only `if not authored` — which needs every recognised field to be empty. A terminal record carrying an auth failure in a field it does not read, while one it does read holds something benign, was scanned, found clean, and reported as "not an isolation problem": the un-isolated retry never runs and nothing says why. #316 through the field set instead of the spelling list.

The haystack is deliberately not widened. Scanning the raw blob whenever the authored text holds no marker hands the retry decision back to conversation content for essentially every non-auth failure, which is the whole of what #318 closed. Three states instead of two: a marker in an authored field retries, no marker anywhere is silence, and a marker in the terminal record outside the scanned set declines and says so — naming the token, the field, the set that was read, and what to do.

Scoped to the terminal record only, so assistant content cannot make the notice fire on every ordinary network failure. The field set is now a named constant pinned by a test.

Co-Authored-By: Max <noreply>
@fdaviddpt
fdaviddpt merged commit dd59077 into main Aug 8, 2026
12 checks passed
@fdaviddpt
fdaviddpt deleted the fix/320 branch August 8, 2026 00:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

_failure_haystack's recognised field set is assumed exhaustive, and the fallback that would cover a new one cannot fire

1 participant