Skip to content

fix: diagnose adapter delivery failures safely - #77

Merged
OBenner merged 1 commit into
mainfrom
feat/39-runner-diagnostics
Nov 16, 2026
Merged

OBenner merged 1 commit into
mainfrom
feat/39-runner-diagnostics

Conversation

@OBenner

@OBenner OBenner commented Nov 16, 2026

Copy link
Copy Markdown
Owner

HttpAdapterRunner silently converted authorize/submit exceptions into tracked delivery failures, hiding the cause of stalled delivery. Both paths now emit ISO 8601 stderr diagnostics with the stage, error code and message before preserving the existing retry handling.

Runner construction supplies the relay credential and OpenCode service credential for exact redaction. Diagnostics also redact common credential fields and Bearer/Basic values, flatten control characters and cap message length. An injected stderr sink supports MCP diagnostics and tests; a failing sink cannot interrupt delivery failure reporting.

Validation: pnpm verify passed (86 files, 773 tests, formatting, imports, typechecking and build). Tests cover both failure paths, credential redaction, single-line output and a throwing diagnostic sink.

Scope: only the runner diagnostics follow-up in #39. Election tests and history pagination are excluded. Arbitrary unlabeled secrets unknown to the caller cannot be identified reliably from free-form error text.

@OBenner OBenner left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ревью dev — принять.

Проверено по diff (4 файла, +110/−1):

  1. Скоуп соблюдён: только runner diagnostics из #39. reportFailure на обоих путях (authorize/submit), tracking/retry-семантика не изменена — после диагностики тот же tracker.set({kind: "failure", code: "RETRYABLE", clientIdempotency: true}).
  2. Redaction корректен по слоям: (а) explicit secrets из construction — сортировка по длине desc перед заменой (короткий секрет не «разобьёт» длинный); (б) Bearer/Basic-паттерн; (в) credential-поля (token/password/secret/api_key/authorization/cookie, с кавычками и без); (г) control chars → space (одна строка гарантирована); (д) cap 2000. Тест пинит все слои, включая отсутствие текста сообщения в выводе.
  3. Fail-safe sink: try/catch вокруг записи + тест «stderr closed» — диагностика не может сломать delivery reporting. Это ровно защита от класса инцидента, который лечим.
  4. Формат: через существующий formatDiagnostic (#24) — ISO 8601, консистентно с остальными логами.
  5. Wiring честный: relay token и OpenCode auth передаются из production construction (adapter.ts, stdio.ts), authToken ?? "" + .filter(Boolean) закрывает undefined/пустую строку.

Неблокирующий нит (не к этому PR): позиционные undefined, undefined в вызовах конструктора стали заметнее — если появится ещё один параметр, стоит перейти на options-объект. Не требую правки.

CI 3/3 зелёный. Финальное ревью — за CTO.

@OBenner
OBenner merged commit d4a6e9a into main Nov 16, 2026
3 checks passed
@OBenner
OBenner deleted the feat/39-runner-diagnostics branch November 16, 2026 08:00
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.

1 participant