1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
//! Events - 行動イベントの定義と配信
//!
//! Worker が実行した行動を ActionEvent として記録・配信する。
//!
//! # Event → Record の流れ
//!
//! **全ての Record は Event から変換される。** Builder で直接 Record を作らない。
//!
//! ```text
//! [Production Runtime]
//!
//! ActionEvent ─────────────────────┐
//! LearningEvent::StrategyAdvice ───┼──▶ ActionEventSubscriber ──▶ Record::Action
//! LearningEvent::DependencyGraph ──┼──▶ (同上) ──▶ Record::DependencyGraph
//! LlmDebugEvent ───────────────────┘
//! ↓
//! LearningDaemon ──▶ Episode ──▶ Learn
//! ```
//!
//! # Event 追加時の Checklist
//!
//! 1. `events/` に Event 型を定義(または既存 enum に variant 追加)
//! 2. `LearningEventChannel` で配信可能にする(該当する場合)
//! 3. `learn/record/` に対応する `*Record` 型を定義
//! 4. `From<&Event> for *Record` を record ファイルに実装
//! 5. `record/mod.rs` で `From<&Event> for Record` にルーティング追加
//! 6. Subscriber が新 Event を処理できることを確認
//!
//! # モジュール構成
//!
//! | モジュール | 責務 |
//! |-----------|------|
//! | `action` | ActionEvent の定義 |
//! | `learning_channel` | LearningEvent の定義と配信 |
//! | `publisher` | イベント配信(broadcast) |
//! | `persistence` | JSONL 永続化 |
//! | `lifecycle` | Orchestrator ライフサイクルフック |
//!
//! # Hook vs Sink の命名規則
//!
//! | 名前 | 実行モデル | 例 |
//! |------|----------|-----|
//! | **Hook** | 同期 callback | `LifecycleHook` - Orchestrator 終了時に呼ばれる |
//! | **Sink** | async trait | `EventSink` (pipeline) - 非同期でデータを消費 |
//!
//! # 使用例
//!
//! ```ignore
//! use swarm_engine_core::events::{
//! ActionEventPublisher, ActionEventBuilder, ActionEventResult,
//! JsonlWriter,
//! };
//!
//! // Publisher を作成
//! let (publisher, rx) = ActionEventPublisher::new(1024);
//!
//! // JSONL 永続化を起動
//! let writer = JsonlWriter::new(publisher.subscribe(), "events.jsonl");
//! tokio::spawn(writer.run());
//!
//! // イベントを配信
//! let event = ActionEventBuilder::new(tick, worker_id, "CheckStatus")
//! .target("user-service")
//! .result(ActionEventResult::success())
//! .build();
//! publisher.publish(event);
//! ```
pub use ;
pub use ;
pub use ;
pub use JsonlWriter;
pub use ;
pub use ;