refactor: split pipeline_state.rs into 4 sub-modules with co-located tests
The 1411-line pipeline_state.rs is split into: - mod.rs: types, transition(), execution_transition(), labels + transition tests (885 lines) - events.rs: TransitionFired, EventBus, TransitionSubscriber + event-bus tests (114 lines) - projection.rs: ProjectionError, TryFrom<&PipelineItemView>, read_typed + projection tests (379 lines) - subscribers.rs: 5 concrete TransitionSubscriber stubs (95 lines) Tests stay co-located. No behaviour change. All 42 pipeline_state tests pass; full suite green.
This commit is contained in:
@@ -0,0 +1,94 @@
|
||||
//! Concrete subscriber stubs for the event bus.
|
||||
|
||||
use super::Stage;
|
||||
use super::events::{TransitionFired, TransitionSubscriber};
|
||||
use super::{event_label, stage_dir_name, stage_label};
|
||||
|
||||
|
||||
// ── Subscriber stubs (real dispatch uses these as the interface) ─────────────
|
||||
//
|
||||
// These are ready to wire into the event bus but not yet connected to the
|
||||
// actual subsystems. Suppress dead_code until consumers are migrated.
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub struct MatrixBotSubscriber;
|
||||
#[allow(dead_code)]
|
||||
impl TransitionSubscriber for MatrixBotSubscriber {
|
||||
fn name(&self) -> &'static str {
|
||||
"matrix-bot"
|
||||
}
|
||||
fn on_transition(&self, f: &TransitionFired) {
|
||||
crate::slog!(
|
||||
"[pipeline/matrix-bot] #{}: {} → {}",
|
||||
f.story_id,
|
||||
stage_label(&f.before),
|
||||
stage_label(&f.after)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub struct FileRendererSubscriber;
|
||||
#[allow(dead_code)]
|
||||
impl TransitionSubscriber for FileRendererSubscriber {
|
||||
fn name(&self) -> &'static str {
|
||||
"filesystem"
|
||||
}
|
||||
fn on_transition(&self, f: &TransitionFired) {
|
||||
crate::slog!(
|
||||
"[pipeline/filesystem] re-rendering work/{}/{}",
|
||||
stage_dir_name(&f.after),
|
||||
f.story_id
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub struct PipelineItemsSubscriber;
|
||||
#[allow(dead_code)]
|
||||
impl TransitionSubscriber for PipelineItemsSubscriber {
|
||||
fn name(&self) -> &'static str {
|
||||
"pipeline-items"
|
||||
}
|
||||
fn on_transition(&self, f: &TransitionFired) {
|
||||
crate::slog!(
|
||||
"[pipeline/items] UPDATE stage = '{}' WHERE id = '{}'",
|
||||
stage_dir_name(&f.after),
|
||||
f.story_id
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub struct AutoAssignSubscriber;
|
||||
#[allow(dead_code)]
|
||||
impl TransitionSubscriber for AutoAssignSubscriber {
|
||||
fn name(&self) -> &'static str {
|
||||
"auto-assign"
|
||||
}
|
||||
fn on_transition(&self, f: &TransitionFired) {
|
||||
if matches!(f.after, Stage::Done { .. } | Stage::Archived { .. }) {
|
||||
crate::slog!(
|
||||
"[pipeline/auto-assign] story {} reached {}; checking for promotable backlog items",
|
||||
f.story_id,
|
||||
stage_label(&f.after)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub struct WebUiBroadcastSubscriber;
|
||||
#[allow(dead_code)]
|
||||
impl TransitionSubscriber for WebUiBroadcastSubscriber {
|
||||
fn name(&self) -> &'static str {
|
||||
"web-ui-broadcast"
|
||||
}
|
||||
fn on_transition(&self, f: &TransitionFired) {
|
||||
crate::slog!(
|
||||
"[pipeline/web-ui] broadcasting #{} transition to connected clients",
|
||||
f.story_id
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user