Skip to content

fix(OMN-11318): refresh Pattern B terminal metadata - #1681

Merged
jonahgabriel merged 1 commit into
mainfrom
jonah/omn-11318-pattern-b-metadata-refresh
May 21, 2026
Merged

jonahgabriel merged 1 commit into
mainfrom
jonah/omn-11318-pattern-b-metadata-refresh

Conversation

@jonahgabriel

@jonahgabriel jonahgabriel commented May 21, 2026 •

Copy link
Copy Markdown
Collaborator

Evidence-Source: OCC#1243
Evidence-Ticket: OMN-11318

Summary

  • refresh AIOKafkaConsumer topic metadata before assigning direct terminal partitions
  • add regression coverage for the cached-metadata failure that timed out before worker command publish

Verification

  • uv run pytest tests/unit/runtime/test_service_pattern_b_broker.py tests/integration/test_pattern_b_broker_terminal_waiter.py -q
  • uv run ruff format --check src/omnibase_infra/runtime/service_pattern_b_broker.py tests/unit/runtime/test_service_pattern_b_broker.py tests/integration/test_pattern_b_broker_terminal_waiter.py
  • uv run ruff check src/omnibase_infra/runtime/service_pattern_b_broker.py tests/unit/runtime/test_service_pattern_b_broker.py tests/integration/test_pattern_b_broker_terminal_waiter.py
  • uv run validate-yaml contracts/OMN-11318.yaml
  • git diff --check

Runtime Evidence

  • .201 stability smoke after fix(OMN-11318): avoid grouped Pattern B terminal waits #1680 returned HTTP 200 but dispatch_timeout after 30s before worker command publish
  • command topic and terminal topics had no matching correlation event; AIOKafkaConsumer.partitions_for_topic reads cached metadata only, so terminal partition assignment could time out before dispatch

Summary by CodeRabbit

Release Notes

  • Bug Fixes
    • Enhanced Kafka consumer metadata initialization to ensure topic metadata is properly refreshed before partition assignment, improving message broker stability and reducing potential initialization failures during startup and message dispatch operations.

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 21, 2026 •

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

The PR adds a topic metadata refresh step to RuntimePatternBBroker's terminal partition assignment by calling the consumer's topics() method before partition discovery. Unit and integration test infrastructure are enhanced to track and verify this new metadata refresh behavior.

Changes

Topic Metadata Refresh in Pattern B Broker Terminal Waiter

Layer / File(s) Summary
Topic metadata refresh in terminal partition assignment
src/omnibase_infra/runtime/service_pattern_b_broker.py
RuntimePatternBBroker._assign_terminal_topic_partitions now calls the consumer's topics() method (if callable) before partition assignment to refresh Kafka metadata.
Unit test fake consumer with metadata refresh support
tests/unit/runtime/test_service_pattern_b_broker.py
_FakeAIOKafkaConsumer tracks metadata refresh state via require_metadata_refresh flag, metadata_refreshed state, and topics_calls counter. A topics() method marks metadata as refreshed and returns partition info. partitions_for_topic() gates partition availability until metadata is refreshed when enabled. A new test test_service_pattern_b_broker_kafka_waiter_refreshes_topic_metadata verifies dispatch completes successfully with metadata refresh triggered.
Integration test consumer stub with metadata tracking
tests/integration/test_pattern_b_broker_terminal_waiter.py
_TerminalConsumer gains a topics_calls counter and async topics() method returning the expected terminal event topic. Test assertion verifies topics() was called at least once before dispatch completes.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

  • OmniNode-ai/omnibase_infra#1680: Both PRs modify RuntimePatternBBroker's one-shot terminal waiter flow around ungrouped/manual consumer partition assignment (including preparing partition metadata via topics()), with corresponding unit/integration test coverage for the same broker waiter behavior.

Poem

🐰 A waiter calls for topics fresh,
Before the partitions mesh,
Metadata now stands ready true,
With tests to prove what brokers do! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically identifies the main change: refreshing Pattern B terminal metadata. It directly relates to the primary objective and file modifications.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch jonah/omn-11318-pattern-b-metadata-refresh

Comment @coderabbitai help to get the list of available commands and usage tips.

@jonahgabriel
jonahgabriel merged commit b8a2347 into main May 21, 2026
77 of 83 checks passed
@jonahgabriel
jonahgabriel deleted the jonah/omn-11318-pattern-b-metadata-refresh branch May 21, 2026 01:23
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