Skip to content

fix: behavior/robustness audit cluster (F2-10, F1-03, F1-04, F1-06, F3-02) - #92

Merged
lesnik512 merged 1 commit into
mainfrom
fix/f-behavior-robustness-batch
Jun 14, 2026
Merged

lesnik512 merged 1 commit into
mainfrom
fix/f-behavior-robustness-batch

Conversation

@lesnik512

Copy link
Copy Markdown
Member

What

PR 3 of the tail program — the real code-behavior fixes from the pass-3 audit. Each test-first.

  • F2-10validate_schema now probes pg_index.indisunique. A same-named but non-unique timer_id_uq (with the correct partial predicate) passes the existing predicate check yet breaks the producer's ON CONFLICT (queue, timer_id) arbiter at publish time; it's now flagged with not UNIQUE. Integration test recreates the index non-unique.
  • F1-03OutboxBroker.stop sets running=False before the asyncio.gather of subscriber stops, so an external cancellation of stop() mid-gather can't leave running=True over already-stopped subscribers (ping() would lie). Test spies a subscriber's stop and asserts it observes running is False.
  • F1-04 — a drain that exceeds graceful_timeout now emits a WARNING + a drain_timeout recorder metric instead of silently abandoning in-flight rows (still left to lease-expiry retry). Fake-mode test wedges a handler and asserts both fire.
  • F1-06_run_with_reconnect captures started only after open_resources succeeds, so a slow pool checkout that then fails no longer counts as "healthy uptime" and resets the backoff (defeating escalation under a connection storm). Test: a failing open keeps the backoff escalating [1,2,3] (the pre-fix code reset to [1,1,1]).
  • F3-02 — extract validate_table_identifiers in schema.py and call it from OutboxClient.__init__, so a directly-constructed or reflected over-long Table can't bypass the 63-byte identifier guard (previously only make_outbox_table enforced it).

Verification

  • just test514 passed, 100% coverage
  • just lint clean (ruff + ty)

Pass-3 findings doc updated. The new drain_timeout recorder event is forward-compatible (the bundled Prometheus/OTel adapters ignore unknown events).

🤖 Generated with Claude Code

…3-02)

- F2-10: validate_schema now probes pg_index.indisunique — a same-named but NON-unique
  timer_id_uq (correct predicate) breaks the producer's ON CONFLICT arbiter at publish
  time and is now flagged. Integration test recreates the index non-unique.
- F1-03: OutboxBroker.stop sets running=False BEFORE the subscriber-stop gather, so an
  external cancellation of stop() can't leave running=True over already-stopped subs.
- F1-04: a drain that exceeds graceful_timeout now emits a WARNING + drain_timeout metric
  instead of silently abandoning in-flight rows (they're left to lease-expiry retry).
- F1-06: _run_with_reconnect captures `started` only after open_resources succeeds, so a
  slow pool checkout that then fails no longer counts as healthy and resets the backoff.
- F3-02: extract validate_table_identifiers in schema.py and call it from
  OutboxClient.__init__, so a directly-constructed/reflected over-long Table can't bypass
  the 63-byte identifier guard.

Each test-first. just test -> 514 passed, 100% coverage; just lint clean. Findings doc updated.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@lesnik512
lesnik512 merged commit 7b1d8d2 into main Jun 14, 2026
3 checks passed
@lesnik512
lesnik512 deleted the fix/f-behavior-robustness-batch branch June 14, 2026 13:56
lesnik512 added a commit that referenced this pull request Jun 14, 2026
)

#92 added the drain_timeout recorder event but only the raw recorder seam saw it —
the bundled adapters ignored it (forward-compatible) and the docs didn't mention it,
so operators got no out-of-the-box metric. Complete the feature:

- Prometheus: faststream_outbox_drain_timeout_total counter (consume labels).
- OTel: messaging.outbox.drain_timeout meter counter (operation=process).
- Docs: observability.md recorder-event table + event set; CLAUDE.md and
  architecture/metrics.md emission lists.

Added PLR0911 to the two adapters' __call__ noqa (one more event branch in the flat
event-dispatch dispatch, same shape as the existing C901/PLR0912 suppressions).

Tests: test_{prometheus,otel}_drain_timeout_* assert the counter increments.
just test -> 518 passed, 100% coverage; just lint clean; mkdocs --strict builds.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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