chore: 新增项目规则文档、构建别名及忽略规则

添加 AGENTS.md 项目规则文件,涵盖语言与工具链、模块设计、
Git 提交规范及验证流程等内容。

变更要点:
- .cargo/config.toml 新增 xtask 命令别名
- .gitignore 忽略运行时地图缓存、接收器配置文件、
  构建锁文件及本地 docs/ 目录
- 新增 AGENTS.md 定义项目编码、提交与审查规则
```
This commit is contained in:
2026-10-21 16:23:47 +08:00
parent 19d4b6de29
commit 7d2e37a0ef
75 changed files with 13196 additions and 2939 deletions
+68
View File
@@ -0,0 +1,68 @@
//! Versioned synthetic telemetry contract. This is not a device wire protocol.
use serde::{Deserialize, Serialize};
pub const PROTOCOL_VERSION: u16 = 1;
pub const MAX_BATCH: usize = 4096;
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
pub struct Observation {
pub target_id: String,
pub receiver_id: String,
/// Monotonically increasing receiver boot/session number.
pub source_epoch: u64,
pub sequence: u64,
pub longitude: f64,
pub latitude: f64,
/// WGS84 ellipsoid altitude in metres, not height above ground.
pub altitude_m: f32,
pub heading_deg: f32,
}
impl Observation {
pub fn validate(&self) -> bool {
fn identity(s: &str) -> bool {
!s.is_empty()
&& s.len() <= 64
&& s.bytes()
.all(|b| b.is_ascii_alphanumeric() || b == b'-' || b == b'_')
}
identity(&self.target_id)
&& identity(&self.receiver_id)
&& self.longitude.is_finite()
&& (-180.0..=180.0).contains(&self.longitude)
&& self.latitude.is_finite()
&& (-90.0..=90.0).contains(&self.latitude)
&& self.altitude_m.is_finite()
&& (-1000.0..=100000.0).contains(&self.altitude_m)
&& self.heading_deg.is_finite()
&& (0.0..360.0).contains(&self.heading_deg)
}
}
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
pub struct Target {
pub observation: Observation,
pub received_at_ms: u64,
}
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
pub struct Frame {
pub version: u16,
pub epoch: u64,
pub sequence: u64,
pub snapshot: bool,
pub server_time_ms: u64,
pub targets: Vec<Target>,
pub removed: Vec<String>,
}
#[derive(Default, Clone, Debug, Serialize)]
pub struct Metrics {
pub active_targets: usize,
pub accepted: u64,
pub stale: u64,
pub rejected: u64,
pub expired: u64,
pub capacity: usize,
pub sequence: u64,
}