Skip to content

Surface pgmq runtime state in doctor diagnostics#119

Merged
aidankhogg merged 8 commits into
dev/alphafrom
claude/inspiring-feynman-3mea9k
Jun 29, 2026
Merged

Surface pgmq runtime state in doctor diagnostics#119
aidankhogg merged 8 commits into
dev/alphafrom
claude/inspiring-feynman-3mea9k

Conversation

@aidankhogg

Copy link
Copy Markdown
Contributor

Summary

This PR adds visibility into pgmq client wiring failures by tracking and surfacing events that were silently dropped when pgmq_client was not available during runtime. The changes introduce a new diagnostic check and improve runtime state tracking to help users identify and resolve pgmq connectivity issues.

Key Changes

  • New diagnostic check: Added check_pgmq_runtime_state() in db_doctor.py that inspects the runtime state file for events dropped due to pgmq client not being wired, providing actionable guidance when issues are detected.

  • Runtime state tracking: Modified emit_event() in events/emitter.py to record event send failures when pgmq_client is unavailable, changing from silent debug logging to explicit warning-level logging and failure recording.

  • CLI status output: Enhanced _print_status() in cli/main.py to display pgmq-disabled drops and other event send failures when present, directing users to netengine doctor for details.

  • Shared constant: Introduced _PGMQ_DISABLED_QUEUE constant in events/emitter.py to consistently identify pgmq-disabled failures across the codebase.

  • Doctor probe integration: Registered the new pgmq runtime state check as a standard diagnostic probe in preflight.py.

Implementation Details

  • The runtime state file is parsed as JSON and checked for event_send_failures entries with queue type _PGMQ_DISABLED_QUEUE.
  • When pgmq-disabled drops are detected, the diagnostic result includes the count, most recent event type, and timestamp to help with troubleshooting.
  • The check gracefully handles missing state files (skipped status) and read errors (warning status).
  • CLI output shows the most recent 3 send failures and provides a summary of pgmq-disabled drops with a link to detailed diagnostics.

https://claude.ai/code/session_01AhwicpfSvKesuRxBHs9sQ2

claude added 2 commits June 29, 2026 10:54
When pgmq_client is None at runtime, events were silently dropped with
only a DEBUG-level log — invisible by default and leaving no trace in
the runtime state file.

- Upgrade the emitter fallback log from DEBUG to WARNING so drops are
  immediately visible in normal log output
- Record each dropped event in runtime_state.event_send_failures using
  the sentinel queue "<pgmq_disabled>" so the condition survives beyond
  the live process
- Surface pgmq-disabled drops in `netengine status` with a clear WARNING
  line pointing operators to `netengine doctor`
- Add check_pgmq_runtime_state() to db_doctor.py that reads the state
  file and emits a WARN DoctorCheckResult when drops are present
- Wire the new probe into standard_probes() so `netengine doctor` shows
  the condition under the database group

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AhwicpfSvKesuRxBHs9sQ2
redactable ^0.1.0 was added to pyproject.toml before the package was
published to PyPI, making it impossible to regenerate poetry.lock and
breaking all CI jobs. The codebase already imports it via importlib with
a documented fallback for when it is unavailable, so removing it from
the required deps is safe and matches the actual runtime behaviour.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AhwicpfSvKesuRxBHs9sQ2
@aidankhogg aidankhogg self-assigned this Jun 29, 2026
@aidankhogg aidankhogg marked this pull request as ready for review June 29, 2026 11:06
claude added 6 commits June 29, 2026 11:08
… action version

- db_doctor.py: narrow type-ignore to import-untyped, annotate failures list properly
- preflight.py: guard against None before int() in _parse_compose_port
- routes.py: import _is_secret_field and _contains_private_pem from redaction module
  (fallback code referenced them but they were never imported, causing NameError)
- ci.yaml: pin trivy-action to @0.29.0 (0.30.0 does not exist)
- Reformat emitter.py, db_doctor.py, preflight.py with black

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AhwicpfSvKesuRxBHs9sQ2
- ci.yaml: trivy-action versions use v-prefix tags (v0.29.0, not 0.29.0)
- runner.py: reformat with black (pre-existing lint failure)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AhwicpfSvKesuRxBHs9sQ2
…_doctor)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AhwicpfSvKesuRxBHs9sQ2
…l packages)

The previous licenses.md was generated from a developer machine with global Poetry
tools installed; CI generates from the project venv only. Regenerate with 81 packages.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AhwicpfSvKesuRxBHs9sQ2
@aidankhogg aidankhogg merged commit 71ced65 into dev/alpha Jun 29, 2026
4 of 6 checks passed
@aidankhogg aidankhogg deleted the claude/inspiring-feynman-3mea9k branch June 29, 2026 11:30
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.

2 participants