Skip to content

refactor(events): consolidate outbox-relay Kafka wiring into @fuzefront/core - #530

Open
izzywdev wants to merge 4 commits into
masterfrom
claude/microservice-event-architecture-qk0zzt
Open

refactor(events): consolidate outbox-relay Kafka wiring into @fuzefront/core#530
izzywdev wants to merge 4 commits into
masterfrom
claude/microservice-event-architecture-qk0zzt

Conversation

@izzywdev

@izzywdev izzywdev commented Aug 3, 2026

Copy link
Copy Markdown
Owner

📋 Description

Follow-up to #520. Moves the generic outbox-relay wiring — topic→schema validation, partition-key derivation, and the Kafka publish/DLQ adapter — out of security-service and into the shared backend package, so every backend service (and the planned Python fuzefront-events mirror, FFRNT-176) shares one install-and-go surface: startOutboxRelayFromEnv({ db }).

No behaviour change — pure consolidation. The contract package owns the schema lookup, @fuzefront/core owns the transport, the service owns only its own emit/consume logic.

🔄 Type of Change

  • 🔧 Refactoring (no functional changes)
  • 🧪 Test addition or improvement

🧪 Testing

  • Unit tests
Package Verified
@fuzefront/shared tsc -p tsconfig.kafka.json clean; registry tests (6) — schema resolution, unmapped→undefined, key derivation
@fuzefront/core tsc --noEmit clean; publisher tests (11 total) — envelope+key, schema-validated vs raw path, DLQ, and no-broker no-op — via an injectable producer seam
security-service tsc --noEmit clean against the new core surface

🔧 Implementation Details

Changes Made

  • @fuzefront/shared: new SCHEMA_BY_TOPIC registry + schemaForTopic() + partitionKeyForPayload() — the contract now owns schema lookup and the ordering-key rule (so language bindings derive them identically).
  • @fuzefront/core: createKafkaOutboxPublisher(config) + startOutboxRelayFromEnv({ db, … }), with an injectable makeOutboxPublisher(getProducer) seam for unit tests. Adds a @fuzefront/shared dependency — safe: the only core consumers (applications, security) build shared's kafka barrel before core in their Dockerfiles; the backend monolith doesn't use core.
  • security-service: services/outboxRelay.ts collapses to a thin delegate calling startOutboxRelayFromEnv({ db }); the duplicated schema map + key derivation + producer are deleted. Bootstrap (index.ts) is unchanged.

Code Quality

  • Self-review completed
  • No debugging statements left in code

🔗 Related Issues and PRs

📝 Additional Notes

Deployment Notes

  • No config/schema change — same KAFKA_BROKERS / OUTBOX_RELAY_INTERVAL_MS behaviour, same event_outbox table.

Future Work

  • FFRNT-174 consumer reactions (now a small addition on this surface); FFRNT-175 broker-integration QA; FFRNT-176 Python fuzefront-events.

🤖 Generated with Claude Code


Generated by Claude Code

…nt/core

Follow-up to #520. Moves the generic relay wiring out of security-service so
every backend service (and the future Python fuzefront-events mirror) shares one
install-and-go surface.

- @fuzefront/shared: SCHEMA_BY_TOPIC registry + schemaForTopic + partitionKeyForPayload
  (the contract owns schema lookup and key derivation).
- @fuzefront/core: createKafkaOutboxPublisher + startOutboxRelayFromEnv, plus an
  injectable makeOutboxPublisher seam for unit testing. Adds @fuzefront/shared dep
  (both core consumers — applications, security — build shared's kafka barrel first).
- security-service: outboxRelay collapses to a thin delegate calling
  startOutboxRelayFromEnv({ db }); schema map + key derivation + producer deleted.

Tests: shared registry (6), core publisher incl. envelope/key/schema-vs-raw/DLQ/
no-broker no-op (11 total). shared/core/security type-check clean.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HxwMXu8tusGrFcZe6iC9j8
@izzywdev izzywdev added the auto-merge Enable squash auto-merge once CI passes label Aug 3, 2026 — with Claude
@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Automated code review (gate-code-review)

Credit balance is too low

Report-only — this check never blocks merge.

@github-actions
github-actions Bot enabled auto-merge (squash) August 3, 2026 17:36
claude and others added 2 commits August 4, 2026 12:05
The consolidation added the first @fuzefront/core -> @fuzefront/shared/kafka
import; the 'Identity UI + Security (unit)' job built core before shared, so tsc
resolved shared from its stale committed dist and failed on the new registry
exports (schemaForTopic/partitionKeyForPayload). Build shared first.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HxwMXu8tusGrFcZe6iC9j8
@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Automated code review (gate-code-review)

Credit balance is too low

Report-only — this check never blocks merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auto-merge Enable squash auto-merge once CI passes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants