Plugin Development: EventSubscriber Prompts¶
This file collects six end-to-end prompts for building a new EventSubscriberPlugin, the 10th plugin type. Subscribers consume any of the 81 event types that flow through src/fcc/messaging/bus.py. Each prompt pins personas, R.I.S.C.E.A.R. slots, and the deliverable shape.
Table of Contents¶
- Scope the Subscriber
- Skeleton the Plugin
- Filter and Replay
- Handle Failures
- Test the Subscriber
- Governance and Ops
1. Scope the Subscriber¶
Personas/subsystems invoked. dal, sre. R.I.S.C.E.A.R. slot: Role + Input.
You are the Data Analyst Lead (dal). Site Reliability Engineer (sre)
reviews.
TASK: Produce a scoping doc for a new EventSubscriberPlugin named
"sla_heartbeat_subscriber" that watches simulation and compliance
events to detect stalled runs.
Include:
1. Event types subscribed (pick 3 to 5 from
src/fcc/messaging/events.py).
2. Stall definition (e.g., no SIMULATION_STEP_COMPLETED for >= N
seconds).
3. Output side-effect (log entry, metric increment, outbound event).
4. Non-goals (explicit; at least 3).
CONSTRAINTS:
- Do not invent event types.
- Subscriber must be side-effect-isolated; no direct DB writes.
Deliverable: 4-section Markdown, 200 to 350 words.
Expected output notes. Real event types, explicit non-goals, no DB side effects.
2. Skeleton the Plugin¶
Personas/subsystems invoked. tr. R.I.S.C.E.A.R. slot: Expected Output.
You are the Technical Reviewer (tr).
TASK: Produce the Python skeleton at src/fcc/plugins/
sla_heartbeat_subscriber.py:
1. Subclass EventSubscriberPlugin (src/fcc/messaging/plugin_bridge.py).
2. Declare an EventFilter that selects the 3 to 5 subscribed event
types.
3. Implement handle(event) with a 30-line body max.
4. Add module docstring + class docstring.
CONSTRAINTS:
- Use dataclasses, no Pydantic.
- No sleep/spin loops; rely on the bus.
Deliverable: .py file body, 50 to 90 lines.
Expected output notes. Subclasses real base, EventFilter declared, body under limits.
3. Filter and Replay¶
Personas/subsystems invoked. dal, tr. R.I.S.C.E.A.R. slot: Constraints.
You are the Data Analyst Lead (dal). Technical Reviewer (tr) reviews.
TASK: Wire the subscriber into EventReplay (src/fcc/messaging/
serialization.py) so operators can replay a prior session to debug
stalls.
Requirements:
1. Support replay from a recorded JSON file emitted by SessionRecorder.
2. Preserve ordering.
3. Provide a dry-run mode that does not emit outbound events.
CONSTRAINTS:
- Replay must not duplicate metric writes; gate via dry-run.
- No new public APIs beyond what serialization.py exposes.
Deliverable: a code snippet showing replay invocation plus 3 bullets on
idempotency guarantees.
Expected output notes. Dry-run guarded, idempotency bullets, real serialization API.
4. Handle Failures¶
Personas/subsystems invoked. sre, tr. R.I.S.C.E.A.R. slot: Constraints + Responsibilities.
You are the Site Reliability Engineer (sre). Technical Reviewer (tr)
reviews.
TASK: Document failure modes and the recovery posture for the
sla_heartbeat_subscriber.
Failure modes to cover:
- handle() raises.
- Downstream metric sink unavailable.
- EventBus backpressure (queue > 100).
- Subscriber process crash and restart.
CONSTRAINTS:
- The bus must continue delivering to other subscribers when handle()
raises. Confirm that semantics and reference the bus code.
- No retry storms; cap at 3 attempts with exponential backoff.
Deliverable: a 4-row table: failure, detection, recovery, observability
signal.
Expected output notes. Bus resilience confirmed, retry cap present, 4 rows.
5. Test the Subscriber¶
Personas/subsystems invoked. tr. R.I.S.C.E.A.R. slot: Expected Output.
You are the Technical Reviewer (tr).
TASK: Produce pytest tests at tests/plugins/
test_sla_heartbeat_subscriber.py.
Cases:
1. Receives subscribed event types only.
2. Detects stall after N seconds (use a fake clock).
3. Raising handler does not halt the bus (other subscribers still
receive).
4. Replay produces deterministic output in dry-run.
CONSTRAINTS:
- pytest fixtures only.
- >= 98% line, >= 80% branch coverage.
- No sleep; inject clock.
Deliverable: pytest file body, 80 to 150 lines.
Expected output notes. Fake clock, 4 cases, coverage gate met.
6. Governance and Ops¶
Personas/subsystems invoked. ra, sre. R.I.S.C.E.A.R. slot: Role Adoption Checklist.
You are the Risk Analyst (ra). Site Reliability Engineer (sre) reviews.
TASK: Produce the governance and ops bundle for shipping this
subscriber:
1. ConstitutionRegistry entry (3 tiers).
2. Runbook section: how an operator reacts when the subscriber fires.
3. Semver impact (MINOR).
4. Rollback: disable via plugin registry toggle; describe toggle path.
5. 6-item Role Adoption Checklist.
CONSTRAINTS:
- Rollback must not require a redeploy; use the plugin toggle.
Deliverable: Markdown with 5 sections, total 300 to 500 words.
Expected output notes. 3-tier governance, runbook present, 6-item checklist, rollback without redeploy.