Skip to content

Add status change topic#155

Open
kevinwallimann wants to merge 5 commits into
masterfrom
feature/151-add-status-change-topic
Open

Add status change topic#155
kevinwallimann wants to merge 5 commits into
masterfrom
feature/151-add-status-change-topic

Conversation

@kevinwallimann
Copy link
Copy Markdown

@kevinwallimann kevinwallimann commented May 20, 2026

Overview

See

Release Notes

  • Add status change topic

Related

Closes #151

Summary by CodeRabbit

  • New Features

    • Introduced status-change event topic with comprehensive validation schema to ensure data consistency and proper event handling.
  • Chores

    • Updated system configuration and tests to support the new status-change event topic.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 20, 2026

Warning

Rate limit exceeded

@kevinwallimann has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 51 minutes and 20 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 2452b43f-3956-4d62-84da-e69786b717f4

📥 Commits

Reviewing files that changed from the base of the PR and between a6dc8b4 and 0c8deb2.

📒 Files selected for processing (1)
  • conf/topic_schemas/status_change.json

Walkthrough

This PR adds a new status_change topic to EventGate by introducing a topic constant, defining a JSON Schema with typed fields and conditional validation rules for status-change events, configuring access control, and integrating topic discovery and loading into the existing handler and config loader systems. Test coverage is updated to verify the integration.

Changes

Status Change Topic Support

Layer / File(s) Summary
Topic constant and schema definition
src/utils/constants.py, conf/topic_schemas/status_change.json, conf/access.json
Topic constant TOPIC_STATUS_CHANGE is defined with value public.cps.za.status-change. The JSON Schema defines typed properties (UUID/epoch-millisecond formats), constrains event_type to lifecycle values, and adds conditional validation via allOf blocks: created events require source/platform/input fields, and finished events require and restrict status_type to SUCCEEDED | FAILED | KILLED. Access control maps the topic to TestUser.
Handler and config loader integration
src/handlers/handler_topic.py, src/utils/config_loader.py
HandlerTopic imports the new constant and loads status_change.json during schema initialization. config_loader.py imports the constant and adds status_change.json to the topic filename-to-topic mapping in load_topic_names(), enabling automatic discovery.
Test coverage
tests/unit/handlers/test_handler_topic.py, tests/unit/utils/test_config_loader.py
Handler tests add status_change.json to mocked schemas and verify the parsed topic and endpoint response include public.cps.za.status-change. Config loader tests update fixtures and expectations to verify discovery and exclusion behavior with the additional schema.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 A new topic hops into the registry,
With schema fields dancing in harmony,
Access control standing guard,
Integration tests keeping watch—
Status changes now flow through EventGate! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% 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 'Add status change topic' directly describes the main change: introducing a new status_change topic to EventGate with schema definition and access configuration.
Description check ✅ Passed The description includes all required template sections: Overview (with documentation links), Release Notes (stating the key change), and Related (linking to issue #151). However, the overview is minimal and relies heavily on external links.
Linked Issues check ✅ Passed All five acceptance criteria from issue #151 are met: topic defined and available [constants, handler], schema supports required fields [topic_schemas], producers can publish via existing API [no API changes needed], consumers can subscribe via existing mechanism [no changes needed], and topic is documented in registry [config, schema files].
Out of Scope Changes check ✅ Passed All changes are directly aligned with issue #151 objectives: topic constant, schema definition, access configuration, and supporting updates to loaders and tests. No extraneous modifications detected.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/151-add-status-change-topic

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
tests/unit/handlers/test_handler_topic.py (1)

90-90: ⚡ Quick win

Add one POST-path test for public.cps.za.status-change schema validation.

Current additions validate discovery/listing only. A valid + invalid POST case for the new topic would protect the end-to-end contract (load + validate + reject bad payloads) from regressions.

Also applies to: 103-107, 117-117

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/unit/handlers/test_handler_topic.py` at line 90, Add a new test
function (e.g., test_post_status_change_schema_validation) in the existing
test_handler_topic suite that exercises the POST path for the schema named
"public.cps.za.status-change": send one valid POST payload (matching the schema,
e.g., including execution_id as string) and assert the handler accepts it
(status accepted/success), then send an obviously invalid payload (e.g.,
execution_id missing or wrong type) and assert the handler rejects it with a
validation error (400 or rejection response and an error message referencing the
schema/field); place both assertions in the same test to ensure load+validate
behavior is covered end-to-end.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@conf/topic_schemas/status_change.json`:
- Around line 20-33: The schema currently treats tenant_id as optional and lacks
explicit previous_state/new_state fields; update status_change.json to make the
application identifier required (mark "tenant_id" as required in the root
"required" array or otherwise add a required "application_id" equivalent), add
"previous_state" and "new_state" properties (type "string", non-nullable) to the
schema, and include those two fields in the schema's "required" array so every
status_change event must carry tenant_id plus previous_state and new_state;
apply the same changes to the other schema blocks noted (lines referenced in the
review).
- Around line 52-55: The schema defines "timestamp_event" as epoch milliseconds
but uses "type": "number" which allows fractions; change the "timestamp_event"
field in the JSON schema to use "type": "integer" (and add "minimum": 0 if you
want to enforce non-negative timestamps) so the schema enforces
whole-millisecond epoch values.

---

Nitpick comments:
In `@tests/unit/handlers/test_handler_topic.py`:
- Line 90: Add a new test function (e.g.,
test_post_status_change_schema_validation) in the existing test_handler_topic
suite that exercises the POST path for the schema named
"public.cps.za.status-change": send one valid POST payload (matching the schema,
e.g., including execution_id as string) and assert the handler accepts it
(status accepted/success), then send an obviously invalid payload (e.g.,
execution_id missing or wrong type) and assert the handler rejects it with a
validation error (400 or rejection response and an error message referencing the
schema/field); place both assertions in the same test to ensure load+validate
behavior is covered end-to-end.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 469ed8af-1aad-4a69-aa28-c2f10a0eb96a

📥 Commits

Reviewing files that changed from the base of the PR and between a0b6f6f and a6dc8b4.

📒 Files selected for processing (7)
  • conf/access.json
  • conf/topic_schemas/status_change.json
  • src/handlers/handler_topic.py
  • src/utils/config_loader.py
  • src/utils/constants.py
  • tests/unit/handlers/test_handler_topic.py
  • tests/unit/utils/test_config_loader.py

Comment on lines +20 to +33
"job_ref": {
"type": [
"string",
"null"
],
"description": "Identifier of the job in it's respective system (e.g. Spark Application Id, Glue Job Id, EMR Step Id, etc)."
},
"tenant_id": {
"type": [
"string",
"null"
],
"description": "Application ID or ServiceNow identifier"
},
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | 🏗️ Heavy lift

Schema contract does not enforce the required status-transition payload.

The objective says status_change must include an application identifier plus previous and new state. In this schema, tenant_id is optional, and there are no explicit previous_state / new_state fields, so producers can publish events that don’t carry a real transition.

Also applies to: 142-156, 179-185

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@conf/topic_schemas/status_change.json` around lines 20 - 33, The schema
currently treats tenant_id as optional and lacks explicit
previous_state/new_state fields; update status_change.json to make the
application identifier required (mark "tenant_id" as required in the root
"required" array or otherwise add a required "application_id" equivalent), add
"previous_state" and "new_state" properties (type "string", non-nullable) to the
schema, and include those two fields in the schema's "required" array so every
status_change event must carry tenant_id plus previous_state and new_state;
apply the same changes to the other schema blocks noted (lines referenced in the
review).

Comment thread conf/topic_schemas/status_change.json
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.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.

Add status_change topic support to EventGate

1 participant