#![allow(dead_code)]
use mineral_protocol::Request;
use mineral_script::ScriptCmd;
use mineral_stats::{BehaviorEvent, SystemEvent};
use mineral_task::{ChannelFetchKind, PlaylistWriteOp};
enum TrackingDecision {
Recorded(&'static str),
NotAnEvent(&'static str),
}
fn audit_request(req: &Request) -> TrackingDecision {
use TrackingDecision::{NotAnEvent, Recorded};
match req {
Request::Pause => Recorded("pauses"),
Request::Resume => Recorded("pauses"),
Request::Stop => Recorded("plays"),
Request::Seek(..) => Recorded("seeks"),
Request::AudioOutputs => NotAnEvent("read: audio output devices"),
Request::SetAudioOutput(..) => {
NotAnEvent("session control: recorded in audio structured logs")
}
Request::SetVolume(..) => Recorded("volume_changes"),
Request::SubmitTask(..) => {
NotAnEvent("任务提交;取数事件在 task 终态记,见 audit_fetch_kind")
}
Request::PlaySong(..) => Recorded("plays"),
Request::PlayQueue { .. } => Recorded("queue_ops"),
Request::QueueInsertNext { .. } => Recorded("queue_ops"),
Request::QueueAppend { .. } => Recorded("queue_ops"),
Request::QueueEdit { .. } => Recorded("queue_ops"),
Request::Playlist { .. } => Recorded("playlist_ops"),
Request::ChannelCaps => NotAnEvent("读:channel 能力查询"),
Request::ServiceInfo => NotAnEvent("读:daemon 服务能力查询"),
Request::CyclePlayMode => Recorded("mode_changes"),
Request::SetPlayMode(..) => Recorded("mode_changes"),
Request::PrevOrRestart => Recorded("plays"),
Request::NextSong => Recorded("plays"),
Request::DaemonInfo => NotAnEvent("读:daemon 信息"),
Request::ToggleLove(..) => Recorded("love_changes"),
Request::QuerySongStats(..) => NotAnEvent("读:单曲统计查询,事实来自 stats.db"),
Request::Download(..) => Recorded("downloads"),
Request::StopDownload(..) => NotAnEvent("session control:只写 structured log"),
Request::StoreGet { .. } => NotAnEvent("读:per-song KV 读"),
Request::StoreSet { .. } => Recorded("store_writes"),
Request::TerminalState { .. } => Recorded("fullscreen_changes"),
Request::Shutdown => Recorded("app_lifecycle"),
}
}
fn audit_script_cmd(cmd: &ScriptCmd) -> TrackingDecision {
use TrackingDecision::{NotAnEvent, Recorded};
match cmd {
ScriptCmd::Toggle => Recorded("pauses"),
ScriptCmd::Next => Recorded("plays"),
ScriptCmd::Prev => Recorded("plays"),
ScriptCmd::Stop => Recorded("plays"),
ScriptCmd::SeekRel(..) => Recorded("seeks"),
ScriptCmd::SeekTo(..) => Recorded("seeks"),
ScriptCmd::SetVolume(..) => Recorded("volume_changes"),
ScriptCmd::SetMode(..) => Recorded("mode_changes"),
ScriptCmd::Play(..) => Recorded("plays"),
ScriptCmd::Download(..) => Recorded("downloads"),
ScriptCmd::StoreGet { .. } => NotAnEvent("读:脚本 KV 读"),
ScriptCmd::StoreSet { .. } => Recorded("store_writes"),
ScriptCmd::QueueList { .. } => NotAnEvent("读:队列查询"),
ScriptCmd::QueueSet { .. } => Recorded("queue_ops"),
ScriptCmd::LibraryPlaylists { .. } => {
NotAnEvent("触发取数 task;fetches 在终态记,见 audit_fetch_kind")
}
ScriptCmd::LibraryTracks { .. } => NotAnEvent("触发取数 task;fetches 在终态记"),
ScriptCmd::LibrarySearch { .. } => {
NotAnEvent("触发搜索 task;searches 在终态记,见 audit_fetch_kind")
}
ScriptCmd::LibrarySongUrl { .. } => {
NotAnEvent("查询 direct media capability;stream_resolutions 在 provider resolve 终态记")
}
ScriptCmd::SetLoved { .. } => Recorded("love_changes"),
ScriptCmd::ConfigOverride { .. } => Recorded("config_overrides"),
}
}
fn audit_fetch_kind(kind: &ChannelFetchKind) -> TrackingDecision {
use TrackingDecision::Recorded;
match kind {
ChannelFetchKind::Search { .. } => Recorded("searches"),
ChannelFetchKind::MyAlbums { .. } | ChannelFetchKind::MyPlaylists { .. } => {
Recorded("fetches")
}
ChannelFetchKind::PlaylistDetail { .. } => Recorded("fetches"),
ChannelFetchKind::Lyrics { .. } => Recorded("fetches"),
ChannelFetchKind::RemotePlayCount { .. } => Recorded("fetches"),
ChannelFetchKind::ArtistDetail { .. } => Recorded("fetches"),
ChannelFetchKind::ArtistAlbums { .. } => Recorded("fetches"),
ChannelFetchKind::AlbumDetail { .. } => Recorded("fetches"),
}
}
fn audit_playlist_op(op: &PlaylistWriteOp) -> TrackingDecision {
use TrackingDecision::Recorded;
match op {
PlaylistWriteOp::Create { .. } => Recorded("playlist_ops"),
PlaylistWriteOp::Delete { .. } => Recorded("playlist_ops"),
PlaylistWriteOp::AddSongs { .. } => Recorded("playlist_ops"),
PlaylistWriteOp::RemoveSongs { .. } => Recorded("playlist_ops"),
PlaylistWriteOp::Rename { .. } => Recorded("playlist_ops"),
PlaylistWriteOp::SetDescription { .. } => Recorded("playlist_ops"),
}
}
fn audit_behavior_emitters(event: &BehaviorEvent) -> &'static str {
match event {
BehaviorEvent::Search { .. } => "channel_fetch 终态 + script_bridge library.search",
BehaviorEvent::Seek { .. } => "PlayerCore::seek_playback(client / 脚本 / 媒体键统一出口)",
BehaviorEvent::Pause { .. } => {
"PlayerCore::pause_playback / resume_playback(client / 脚本 / 媒体键统一出口)"
}
BehaviorEvent::VolumeChange { .. } => "PlayerCore::set_playback_volume(统一出口)",
BehaviorEvent::ModeChange { .. } => {
"PlayerCore::record_mode_change(cycle / 直设 / 脚本共用)"
}
BehaviorEvent::LoveChange { .. } => {
"PlayerCore::record_love_change(set_favorite / toggle_favorite / sync import 共用)"
}
BehaviorEvent::QueueOp { .. } => "ClientHandle 的 play_queue / insert_next / append",
BehaviorEvent::PlaylistOp { .. } => {
"playlist 写 task 终态(events.rs) 与 playlists::playlist_operation"
}
BehaviorEvent::Fetch { .. } => "channel_fetch 终态(events.rs)",
BehaviorEvent::Download { .. } => "download.rs record_download(三种结局)",
BehaviorEvent::CopyRender { .. } => "仅历史数据:复制模板在 client 本地执行",
BehaviorEvent::ActionInvocation { .. } => "仅历史数据:具名脚本动作入口已删除",
BehaviorEvent::ConfigOverride { .. } => "script_bridge ConfigOverride",
BehaviorEvent::StoreWrite { .. } => {
"ipc dispatch 的 StoreSet / script_bridge 的 StoreSet(Inc 仅历史数据)"
}
BehaviorEvent::Spawn { .. } => "仅历史数据:脚本子进程能力已删除",
BehaviorEvent::BusMessage { .. } => "仅历史数据:脚本事件总线已删除",
BehaviorEvent::FullscreenChange { .. } => "ipc dispatch 的 TerminalState",
BehaviorEvent::ConnectionReject { .. } => "ipc::handshake record_connection_reject",
BehaviorEvent::ClientConnection { .. } => "ipc::ConnGuard drop",
BehaviorEvent::AppLifecycle { .. } => "recorder.daemon_lifecycle + ipc 会话生命周期",
}
}
fn audit_system_emitters(event: &SystemEvent) -> &'static str {
match event {
SystemEvent::StreamResolution { .. } => "playback.rs provider resolve success / failure",
SystemEvent::HookFire { .. } => "hook_bridge 各提交点裁决回来处",
SystemEvent::GaplessBoundary { .. } => "gapless.rs check_advance 边界裁决",
SystemEvent::Prefetch { .. } => {
"gapless.rs 武装 + hook_bridge.rs 否决 + playback.rs 改写 / 失败"
}
SystemEvent::CacheHarvest { .. } => "download.rs harvest_capture 收割终态",
SystemEvent::CacheEviction { .. } => "media_cache 淘汰点",
SystemEvent::ScriptLifecycle { .. } => "script_reload + script_bridge 生命周期回调",
SystemEvent::ConfigReload => "config_host 重载成功处",
}
}