diff --git a/.woodpecker/verify.yml b/.woodpecker/verify.yml
index b8b2958..c9b527e 100644
--- a/.woodpecker/verify.yml
+++ b/.woodpecker/verify.yml
@@ -23,4 +23,4 @@ steps:
environment:
NUGET_PACKAGES: /home/justme/.nuget/packages
commands:
- - cd backend && dotnet test --solution Monitor.slnx -c Release
+ - cd backend && dotnet test --solution MoShiro.slnx -c Release
diff --git a/AGENTS.md b/AGENTS.md
index 5925e03..4b59fea 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -2,7 +2,7 @@
## Project
-Monitor is a self-hosted network path quality monitor. Backend coordinates Agents and Probes, stores measurements, and serves the REST/SSE API. `web/display` is the read-only overview; `web/admin` manages nodes, tests, and settings.
+MoShiro is a self-hosted network path quality monitor. Backend coordinates Agents and Probes, stores measurements, and serves the REST/SSE API. `web/display` is the read-only overview; `web/admin` manages nodes, tests, and settings.
## Branch and workspace safety
@@ -10,12 +10,12 @@ Monitor is a self-hosted network path quality monitor. Backend coordinates Agent
- A push to `main` builds images only if its commit message contains `[CI]` (for a merged PR, put it in the PR or merge commit title). Without `[CI]` nothing is built; use `[CI SKIP]` to skip the pipeline entirely. When squashing or pushing to `main`, add `[CI]` unless a build is explicitly not wanted.
- Before editing, inspect `git status`. Preserve pre-existing user changes: do not reset, clean, stash, or include unrelated files in a commit.
- Do not commit credentials, API keys, registry passwords, or generated runtime data. CI credentials belong in Woodpecker secrets (`zot_secret`, `gitea_token`, `release_signing_key` for signing release manifests, `release_api_token` with the `release` scope). The release signing private key never goes into the repository or the panel; only the public key in `packaging/update/` does.
-- Keep development OCI images in the `monitor-dev/` repository path and release images in `monitor/`. Do not let a development build overwrite release tags such as `latest`.
+- Keep development OCI images in the `moshiro-dev/` repository path and release images in `moshiro/`. Do not let a development build overwrite release tags such as `latest`.
## Project layout
-- `backend/src/Monitor.Backend/`: service entry point and composition.
-- `backend/src/Monitor.Backend.Api/`: REST endpoints, contracts, and OpenAPI.
+- `backend/src/MoShiro.Backend/`: service entry point and composition.
+- `backend/src/MoShiro.Backend.Api/`: REST endpoints, contracts, and OpenAPI.
- `backend/agent/`, `backend/probe/`: node applications and their READMEs.
- `backend/fleet/`, `backend/shared/`: reusable node framework, measurement engine, protocols, and data formats.
- `web/display/`, `web/admin/`: Vite applications; `web/shared/`: API client, generated types, charts, and shared UI.
@@ -25,12 +25,12 @@ Monitor is a self-hosted network path quality monitor. Backend coordinates Agent
Requirements: .NET SDK 10 and Node.js/npm. The SDK selection is defined by the root `global.json`; NuGet package versions are centralized in the root `Directory.Packages.props`.
-- All .NET projects: `dotnet build Monitor.slnx -c Release` from the repository root.
-- Backend build: `cd backend && dotnet build Monitor.slnx -c Release`
-- Backend tests: `cd backend && dotnet test --solution Monitor.slnx -c Release`
+- All .NET projects: `dotnet build MoShiro.slnx -c Release` from the repository root.
+- Backend build: `cd backend && dotnet build MoShiro.slnx -c Release`
+- Backend tests: `cd backend && dotnet test --solution MoShiro.slnx -c Release`
- Frontend dependencies/build: `npm ci --prefix web && npm run build --prefix web`
- Frontend style check: `npm run lint:css --prefix web`
-- Local backend: from `backend/`, run `dotnet run --project src/Monitor.Backend -- --urls http://localhost:5000`.
+- Local backend: from `backend/`, run `dotnet run --project src/MoShiro.Backend -- --urls http://localhost:5000`.
- Local web apps: from the repository root, run `npm ci --prefix web` then `npm run dev --prefix web`. The current dev config uses display port 5173 and admin port 5175; `/admin/` is proxied through the display server. Check the Vite configs when working on another branch because ports can differ.
- After changing API contracts, regenerate/check `backend/openapi/v1.json` and run `npm run gen:api --prefix web` so frontend API types stay aligned.
diff --git a/Directory.Packages.props b/Directory.Packages.props
index 55fb462..b6b6d54 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -2,9 +2,9 @@
true
- 3530400
- 2026
- 1e71ddf93849c6a6ecf58b827c0692073d2dd7ee40196158068f7b29f422e87d
+ 3530400
+ 2026
+ 1e71ddf93849c6a6ecf58b827c0692073d2dd7ee40196158068f7b29f422e87d
diff --git a/Monitor.slnx b/MoShiro.slnx
similarity index 55%
rename from Monitor.slnx
rename to MoShiro.slnx
index 8a5c58c..f15c43c 100644
--- a/Monitor.slnx
+++ b/MoShiro.slnx
@@ -17,36 +17,36 @@
-
-
+
+
-
-
+
+
-
+
-
+
-
+
-
-
-
-
-
-
+
+
+
+
+
+
-
-
-
+
+
+
-
+
diff --git a/README.md b/README.md
index 96b9d39..da70858 100644
--- a/README.md
+++ b/README.md
@@ -1,18 +1,36 @@
-# Monitor
+# MoShiro
-Monitor 是一个自托管的网络线路质量观测工具。它在 Probe 与多个 Agent 之间执行主动网络测量,记录逐包和逐事件结果;Backend 保存原始数据并生成可查询的线路指标,Web 界面用于查看、比较和管理节点。
+MoShiro 是一个自托管的**网络线路质量观测工具**。它在若干 Probe(例如家宽出口)与多台 Agent(例如海外 VPS)之间做主动网络测量,只记录逐包、逐事件的原始数据;Backend 保存这些原始数据,推算延迟、丢包、抖动、吞吐等指标,并回答「如果在这条线路上部署某类服务,体验会怎样」;Web 界面用来查看、比较和管理。
-它面向需要比较不同网络出口、评估线路稳定性,或观察特定网络服务体验的场景。Agent 与 Probe 专注于测量和上报;它们不提供远程终端、命令执行或文件管理能力。
+## 项目边界
-## 能力概览
+**它做什么**
-- **主动测量**:组合 TCP、UDP 等测量模块,采集延迟、丢包、抖动、吞吐和连接事件。
-- **线路分析**:从原始测量数据生成时间序列指标,并比较线路在不同服务模型下的体验。
-- **节点管理**:通过 Fleet 节点框架处理身份、注册、连接、任务同步和数据上报。
-- **实时面板**:展示端查看线路状态和历史趋势;管理端负责节点、任务和系统配置。
-- **线路管理**:Backend 决定哪些 Probe 连哪些 Agent(自动连接开关加手动选择),在管理端的线路矩阵里一键开关。
-- **节点信息与更新**:节点自报系统、架构和构建信息(版本、tag、提交、构建时间),国家和运营商由 Backend 查询;容器节点的更新由 CI 签名、Backend 转发、节点宿主机上的更新器验签并执行,失败自动回滚,管理端可以看状态和点「更新」。
-- **自托管**:Backend 使用段文件和 SQLite 保存数据;提供 Linux、systemd 和 OpenWrt 相关部署文件。
+- 主动测量:组合 TCP、UDP、TLS、ICMP 等采集积木,只记录时间、序号、大小这类原始事实,**不转发也不记录业务内容**。
+- 线路分析:Backend 从原始数据生成时间序列指标,按服务模型(REALITY、Hysteria2、Minecraft 等)评分并对多条线路排序、对比;模型和指标可以事后重算。
+- 管理:节点注册与审批、Probe 和 Agent 之间连哪些线路、任务与按需测试、节点版本与更新,都在管理端完成。
+
+**它不做什么**
+
+- **节点是纯采集器**:Agent 和 Probe 没有终端、命令执行、文件读写和自更新能力,也不加载外部代码。更新由节点宿主机上的更新器完成,节点进程只放面板转来的发布清单。
+- **不是主机监控**:Agent 只上报 CPU、内存、磁盘、网卡流量和运行时长这类只读的汇总数字,不采集型号、主机名、进程和任何 IP;Probe 不上报主机资源。
+- **不暴露地址**:公开接口里没有 IP、城市、ASN;国家和运营商只由 Backend 查询(节点自己不访问任何外部服务)。
+- 暂不包含告警(见文末待办)。
+
+## 信任关系
+
+```text
+ 管理员 ── 账号密码(Cookie 会话 + CSRF)或 API 令牌(read · admin · release)──▶ Backend
+ 访客 ── 匿名只读,站点设为公开时才可用(没有 IP、城市、ASN)──────────────▶ Backend 公开接口
+
+ 节点 ── 加入令牌一次性注册,之后用自己的 ECDSA P-256 密钥签名认证 ───────▶ Backend(只存公钥)
+ Probe ── 用同一把密钥签名建立测量会话 ───────────────────────────────────▶ Agent(只放行面板名单里的 Probe 公钥)
+ CI ── 发布私钥对「镜像 digest 清单」签名 ──▶ Backend 原样转发 ──▶ 节点宿主机的更新器用本机公钥验签
+```
+
+- **Backend 不信任节点上报的内容**:数据按线路隔离存放;节点的身份靠签名,数据库泄露也无法冒充节点。
+- **节点不信任 Backend 的下发**:任务超出节点本机的硬上限(目标网段、码率、包速率、监听端口)就被拒绝;节点不执行任何「执行类」指令。
+- **更新不依赖面板的诚实**:清单必须由发布私钥签名;节点宿主机的更新器用本机公钥验签、只认本机配置的镜像仓库、按 digest 拉取、拒绝旧的 `seq`。面板被攻破也推不出恶意镜像。
## 架构
@@ -35,99 +53,68 @@ Monitor 是一个自托管的网络线路质量观测工具。它在 Probe 与
测量会话:TLS 控制通道 + UDP/TCP 数据通道,由 Probe 主动拨出
```
-两种连接:**Probe 和 Agent 都用长连接连 Backend**(身份、任务、状态、更新通知),**测量只走 Probe → Agent**(Probe 主动拨出,不需要入站端口)。哪些 Probe 连哪些 Agent 由 Backend 决定:默认自动全连,也可以在管理端手动选择。数据存储:段文件保存原始数据,SQLite 保存索引、指标与配置。
+两种连接:**Probe 和 Agent 都用长连接连 Backend**(身份、任务、状态、更新通知),**测量只走 Probe → Agent**(Probe 主动拨出,Agent 不需要连 Probe,家宽也不需要入站端口)。哪些 Probe 连哪些 Agent 由 Backend 决定:默认自动全连,也可以在管理端手动选择。
-## 快速开始
-
-### 环境要求
-- .NET SDK 10;项目使用 `global.json` 指定 SDK 版本和滚动策略。
-- Node.js 与 npm,用于构建 Web 前端。
-
-### 构建
-
-从仓库根目录构建全部 .NET 项目(Backend、Agent、Probe、Fleet、测试和 CI 工具):
-
-```sh
-dotnet build Monitor.slnx -c Release
+```text
+ 采集(只记录) 传输(有界、至少一次) 分析(注册制、可重算) 展示
+ Probe / Agent 积木 ──▶ 原始列块(10 秒一块)──▶ Backend 段文件 ──▶ 指标与服务模型 ──▶ REST / SSE ──▶ Web
```
-NuGet 包版本统一在根目录 `Directory.Packages.props` 管理,项目中的 `PackageReference` 不写版本号。AotAnywhere 的 MSBuild SDK 版本在根目录 `global.json` 的 `msbuild-sdks` 中管理。`backend/Monitor.slnx` 保留用于只构建后端目录内的项目。
+Backend 用段文件保存原始数据,用 SQLite 保存索引、指标与配置。**完整的架构、数据链路、安全边界和设计决策见 [`docs/architecture.md`](docs/architecture.md)。**
-安装前端依赖并构建展示端和管理端(在仓库根目录运行):
+## 协议
+
+- **控制链路(Fleet)**:节点到 Backend 的 `wss` 长连接(`/api/agent/v1/rpc`),JSON-RPC 2.0 信封加二进制通道;挑战加签名认证,`hello` 协商版本和能力,心跳;**期望状态同步**(Backend 下发完整快照,节点调和并回报已应用的版本和被拒绝的条目);**可靠发件箱**(原始块至少一次投递,按 id 去重)。Fleet 与业务无关,放在 `backend/fleet/`。
+- **业务方法**:`moshiro.*`(按需测试、Probe 断开、事件、主机汇总、更新通知等),状态文档有 `task_set`(Agent 的任务集)和 `probe_agents`(Probe 的 Agent 列表)。
+- **测量数据面**:Probe 到 Agent 的 TLS 控制通道、UDP 和 TCP 数据通道(默认 `7443/tcp`、`7443/udp`、`7444/tcp`);会话用 `session_id` 和 MAC 认证、不绑定五元组,NAT 映射变化后自动跟随。
+- **REST + SSE**:`/api/public`(展示,可匿名)、`/api/admin`(管理);OpenAPI 在 `backend/openapi/v1.json`,前端据此生成类型。
+
+细节见 [`docs/protocol.md`](docs/protocol.md)、[`docs/fleet/link.md`](docs/fleet/link.md)、[`docs/api.md`](docs/api.md)、[`docs/enrollment.md`](docs/enrollment.md)。
+
+## 如何构建
+
+环境:.NET SDK 10(`global.json` 指定版本)、Node.js 与 npm。在仓库根目录:
```sh
-npm ci --prefix web
-npm run build --prefix web
-npm run gen:api --prefix web # API schema changed after Backend edits
-npm run lint:css --prefix web
+dotnet build MoShiro.slnx -c Release # Backend、Agent、Probe、Fleet、测试和 CI 工具
+npm ci --prefix web && npm run build --prefix web # 展示端和管理端,产物在 web/display/dist、web/admin/dist
```
-前端产物位于 `web/display/dist/` 和 `web/admin/dist/`。NativeAOT 目标平台和 Windows 上使用 AotAnywhere 交叉构建的说明见 [`docs/deployment.md`](docs/deployment.md)。
+本地运行:先在 `backend/` 里 `dotnet run --project src/MoShiro.Backend -- --urls http://localhost:5000`,再 `npm run dev --prefix web`,展示端是 ,管理端是 。
-Backend、Agent 和 Probe 均以 OCI 镜像发布,支持 Linux/amd64 与 Linux/arm64;Agent 和 Probe 另外提供 Linux glibc/musl、macOS 与 Windows 二进制包。容器部署配置见 [`compose.yaml`](compose.yaml),发布说明见 [`docs/deployment.md`](docs/deployment.md)。
-
-### 本地运行
-
-1. **启动 Backend。** 在仓库根目录运行:
+测试和检查:
```sh
-cd backend
-dotnet run --project src/Monitor.Backend -- --urls http://localhost:5000
+dotnet test --solution MoShiro.slnx # 后端和节点的测试
+npm run lint:css --prefix web # 前端样式(颜色只能写在主题令牌里)
+npm run gen:api --prefix web # 后端改了接口之后重新生成前端类型
```
-2. **启动前端。** 保持 Backend 运行,在另一个终端的仓库根目录运行:
+Backend、Agent、Probe 以 OCI 镜像发布(Linux amd64、arm64),Agent 和 Probe 另有 Linux glibc/musl、macOS、Windows 的二进制包。NativeAOT 的构建细节、CI 触发规则(`[CI]`、`[SKIP TESTS]`、版本 tag)、镜像路径、容器节点的运行和更新见 [`docs/deployment.md`](docs/deployment.md);前端见 [`web/README.md`](web/README.md),后端见 [`backend/README.md`](backend/README.md)。
-```sh
-npm ci --prefix web
-npm run dev --prefix web
-```
+## 文档
-打开 使用展示端,或访问 进入管理端。依赖安装和前端配置见 [`web/README.md`](web/README.md);Backend 的首次启动与配置见 [`backend/README.md`](backend/README.md)。
-
-### CI 构建规则
-
-- Pull request 和 `dev` 分支 push:先跑 Backend tests,通过后再构建前端。
-- 在需要跳过 Backend tests 的提交信息后加 `[SKIP TESTS]`;Gitea pull request 需要把标记写进 PR 标题。前端构建仍会运行。
-- `main` 上的提交信息包含 `[CI]` 时,并行构建 Backend、Agent、Probe 的 Linux/amd64 镜像,推送到 Zot 的 `monitor-dev/` 仓库;普通 main push 不构建。
-- 推送 `vMAJOR.MINOR.PATCH` tag 会触发全平台正式构建和 Release 发布。
-
-完整触发条件、开发镜像标签和发布路径见 [`docs/deployment.md`](docs/deployment.md)。
-
-## 项目布局
-
-| 路径 | 说明 |
+| 文档 | 内容 |
| --- | --- |
-| [`backend/`](backend/README.md) | Backend 服务、Fleet 框架、共享测量代码与 .NET 测试 |
-| [`backend/agent/`](backend/agent/README.md) | Agent 节点:注册到 Backend,接受 Probe 测量并上报数据 |
-| [`backend/probe/`](backend/probe/README.md) | Probe 节点:发起线路测量并将采集数据交给 Agent |
-| `backend/fleet/` | 可复用的节点身份、注册和连接框架 |
-| `backend/shared/` | 测量引擎、协议和原始数据格式 |
-| `web/display/`、`web/admin/` | 展示端和管理端 |
-| `web/shared/` | 前端 API、图表、组件与主题 |
-| `packaging/`、`scripts/` | 部署、构建与维护脚本 |
-| `docs/` | [架构](docs/architecture.md)、[测量模型](docs/measurement.md)、[API](docs/api.md)、[部署](docs/deployment.md)等文档 |
+| [`docs/architecture.md`](docs/architecture.md) | 架构、数据链路、安全边界、设计决策 |
+| [`docs/protocol.md`](docs/protocol.md)、[`docs/fleet/`](docs/fleet/overview.md) | 线协议、Fleet 节点框架(身份、连接、更新) |
+| [`docs/enrollment.md`](docs/enrollment.md) | 注册、身份、Probe 与 Agent 的接入 |
+| [`docs/measurement.md`](docs/measurement.md)、[`docs/analysis.md`](docs/analysis.md) | 采集引擎与任务模型、分析层与指标 |
+| [`docs/storage.md`](docs/storage.md)、[`docs/query.md`](docs/query.md) | 存储、展示数据查询 |
+| [`docs/api.md`](docs/api.md)、[`docs/api-guidelines.md`](docs/api-guidelines.md) | API 规范与约束 |
+| [`docs/deployment.md`](docs/deployment.md) | 构建、发布、CI、部署与更新 |
+| [`docs/project-layout.md`](docs/project-layout.md)、[`docs/coding-style.md`](docs/coding-style.md) | 仓库结构与依赖规则、代码风格 |
+
+代码目录:`backend/`(Backend、`fleet/` 节点框架、`shared/` 测量引擎和协议、`agent/`、`probe/`、`tests/`)、`web/`(`display` 展示端、`admin` 管理端、`shared`)、`packaging/` 和 `scripts/`(部署与维护)、`ci/` 和 `.woodpecker/`(流水线)。
## 待办
-已实现的能力见上面的概览和 `docs/`;还没做的:
-
-- **纯二进制节点的更新**:`fleet-updater`、`fleet-release`、Windows 服务和 OpenWrt(procd)适配器;设计见 [`docs/fleet/update.md`](docs/fleet/update.md)。容器节点(Agent、Probe)的签名发布和宿主机更新已经实现,见 [`docs/deployment.md`](docs/deployment.md)。
+- **纯二进制节点的更新**:`fleet-updater`、`fleet-release`、Windows 服务和 OpenWrt(procd)适配器;设计见 [`docs/fleet/update.md`](docs/fleet/update.md)。容器节点的签名发布和宿主机更新已经实现。
- **更新的灰度和自动策略**:按标签分批发布;`POLICY=auto` 的线上验证;后端自身的更新。
- **OpenWrt 打包**:procd 脚本、ipk/apk 包、sysupgrade 保留列表,在 aarch64 路由器上长时间运行验证。
- **安全加固**:对 UDP 包、控制帧、RawChunk、JSON-RPC 做模糊测试;伪造签名和重放的专项测试。
- **以后**:告警(Webhook)、真实 QUIC 握手积木、pcap/eBPF 采集。
-## 测试
-
-```sh
-dotnet test --solution Monitor.slnx
-```
-
-```sh
-# 前端样式检查(仓库根目录)
-npm run lint:css --prefix web
-```
-
## 许可证
本项目采用 [Apache License 2.0](LICENSE)。
diff --git a/backend/Monitor.slnx b/backend/MoShiro.slnx
similarity index 58%
rename from backend/Monitor.slnx
rename to backend/MoShiro.slnx
index c69c642..e453cc3 100644
--- a/backend/Monitor.slnx
+++ b/backend/MoShiro.slnx
@@ -17,33 +17,33 @@
-
-
+
+
-
-
+
+
-
+
-
+
-
+
-
-
-
-
-
-
+
+
+
+
+
+
-
-
-
+
+
+
diff --git a/backend/README.md b/backend/README.md
index aae510d..7e0021f 100644
--- a/backend/README.md
+++ b/backend/README.md
@@ -1,17 +1,17 @@
# Backend
-Backend 是 Monitor 的控制面和数据服务,负责 Agent 注册与连接、任务编排、原始测量数据持久化、指标分析,以及供前端使用的 REST API 和 SSE 实时数据流。
+Backend 是 MoShiro 的控制面和数据服务,负责 Agent 注册与连接、任务编排、原始测量数据持久化、指标分析,以及供前端使用的 REST API 和 SSE 实时数据流。
## 组件
| 路径 | 职责 |
| --- | --- |
-| `src/Monitor.Backend/` | 应用入口与依赖组合 |
-| `src/Monitor.Backend.Api/` | Public、Admin API 和 OpenAPI |
-| `src/Monitor.Backend.Gateway/` | Fleet RPC、节点状态与测量数据接收 |
-| `src/Monitor.Backend.Application/` | 业务用例、查询、任务和后台服务 |
-| `src/Monitor.Backend.Analysis/` | 指标计算、累加器和服务模型 |
-| `src/Monitor.Backend.Storage.Sqlite/` | 段文件与 SQLite 存储 |
+| `src/MoShiro.Backend/` | 应用入口与依赖组合 |
+| `src/MoShiro.Backend.Api/` | Public、Admin API 和 OpenAPI |
+| `src/MoShiro.Backend.Gateway/` | Fleet RPC、节点状态与测量数据接收 |
+| `src/MoShiro.Backend.Application/` | 业务用例、查询、任务和后台服务 |
+| `src/MoShiro.Backend.Analysis/` | 指标计算、累加器和服务模型 |
+| `src/MoShiro.Backend.Storage.Sqlite/` | 段文件与 SQLite 存储 |
| `fleet/` | 通用节点身份、注册和连接框架 |
| `shared/` | 测量引擎、协议和数据格式 |
| `tests/` | 集成测试和测试支持代码 |
@@ -26,14 +26,14 @@ Backend 是 Monitor 的控制面和数据服务,负责 Agent 注册与连接
```sh
cd backend
-dotnet build Monitor.slnx -c Release
-dotnet test --solution Monitor.slnx
+dotnet build MoShiro.slnx -c Release
+dotnet test --solution MoShiro.slnx
```
发布当前平台的 NativeAOT Backend:
```sh
-dotnet publish src/Monitor.Backend -c Release -r -p:PublishAot=true
+dotnet publish src/MoShiro.Backend -c Release -r -p:PublishAot=true
```
例如 `` 可为 `win-x64`、`linux-x64` 或 `linux-arm64`。NativeAOT 发布需要对应平台的 C/C++ 工具链。仓库根目录的 `scripts/publish.sh backend ` 可构建单个平台的 Backend 可执行文件;容器发布由 Woodpecker tag 流水线完成,详见 [`../docs/deployment.md`](../docs/deployment.md)。
@@ -46,9 +46,9 @@ dotnet publish src/Monitor.Backend -c Release -r -p:PublishAot=true
```sh
cd backend
-dotnet run --project src/Monitor.Backend -- --urls http://localhost:5000
+dotnet run --project src/MoShiro.Backend -- --urls http://localhost:5000
```
-首次启动时可用 `Monitor__InitialAdminUser` 和 `Monitor__InitialAdminPassword` 设置初始管理员。数据目录、公开地址、Cookie 和 CORS 等设置通过 `Monitor` 配置节传入;完整配置说明见 [`../docs/deployment.md`](../docs/deployment.md)。站点默认需要登录,可在管理端修改公开设置。
+首次启动时可用 `MoShiro__InitialAdminUser` 和 `MoShiro__InitialAdminPassword` 设置初始管理员。数据目录、公开地址、Cookie 和 CORS 等设置通过 `MoShiro` 配置节传入;完整配置说明见 [`../docs/deployment.md`](../docs/deployment.md)。站点默认需要登录,可在管理端修改公开设置。
OpenAPI 文档由构建生成到 `openapi/v1.json`。API 设计和端点说明见 [`../docs/api.md`](../docs/api.md);项目总览见仓库根目录的 [`README.md`](../README.md)。
diff --git a/backend/agent/README.md b/backend/agent/README.md
index c52e71a..b70a50b 100644
--- a/backend/agent/README.md
+++ b/backend/agent/README.md
@@ -1,4 +1,4 @@
-# Monitor Agent
+# MoShiro Agent
Agent 是部署在 VPS 或其他可达网络节点上的采集进程。它向 Backend 注册并保持连接,接受 Probe 的测量会话,执行线路任务中的 Agent 侧工作,再将两端数据合并后上报。
@@ -18,14 +18,14 @@ Probe ──TLS 控制 / UDP、TCP 测量──> Agent ──长连接与数据
```sh
cd backend
-dotnet build agent/src/Monitor.Agent -c Release
+dotnet build agent/src/MoShiro.Agent -c Release
dotnet build fleet/tools/fleet-enroll -c Release
```
发布 NativeAOT 程序需要对应平台的 C/C++ 工具链;`` 应与构建环境和目标平台匹配:
```sh
-dotnet publish agent/src/Monitor.Agent -c Release -r -p:PublishAot=true
+dotnet publish agent/src/MoShiro.Agent -c Release -r -p:PublishAot=true
dotnet publish fleet/tools/fleet-enroll -c Release -r -p:PublishAot=true
```
@@ -36,7 +36,7 @@ dotnet publish fleet/tools/fleet-enroll -c Release -r -p:PublishAot=true
先在管理端创建加入令牌,然后在 Agent 主机上运行一次性注册工具:
```sh
-fleet-enroll --server https:// --join --name --identity-dir /etc/monitor
+fleet-enroll --server https:// --join --name --identity-dir /etc/moshiro
```
注册工具会在身份目录写入节点身份和证书。准备本地 `agent.json`,其中 `fleet.server` 指向 Backend,`fleet.identity_dir` 指向上述目录;`listen`、`limits` 和 `reporting` 可按节点环境调整。配置文件不会由 Backend 修改。限制目标网段和测量预算时,应按实际网络与机器能力配置;`allowed_target_cidrs` 默认为空,不允许 Agent 执行目标探测任务。
@@ -44,12 +44,12 @@ fleet-enroll --server https:// --join --name --ide
启动 Agent:
```sh
-monitor-agent --config /etc/monitor/agent.json
+moshiro-agent --config /etc/moshiro/agent.json
```
-容器节点的运行方式(podman + systemd)和宿主机更新器见 [`../../docs/deployment.md`](../../docs/deployment.md)。也可使用 OCI 镜像 `registry.oeo.one/monitor/monitor-agent:`,自动选择 Linux amd64 或 arm64 镜像。镜像同时包含 `fleet-enroll`;可通过 `--entrypoint /usr/local/bin/fleet-enroll` 执行首次注册。容器默认读取命名 volume 中的 `/etc/monitor/agent.json` 与身份文件;建议使用宿主网络,并按 ICMP 测量需求添加 `NET_RAW` 能力。镜像以 UID/GID 1654 运行,新命名 volume 由引擎按镜像目录初始化权限。
+容器节点的运行方式(podman + systemd)和宿主机更新器见 [`../../docs/deployment.md`](../../docs/deployment.md)。也可使用 OCI 镜像 `registry.oeo.one/moshiro/moshiro-agent:`,自动选择 Linux amd64 或 arm64 镜像。镜像同时包含 `fleet-enroll`;可通过 `--entrypoint /usr/local/bin/fleet-enroll` 执行首次注册。容器默认读取命名 volume 中的 `/etc/moshiro/agent.json` 与身份文件;建议使用宿主网络,并按 ICMP 测量需求添加 `NET_RAW` 能力。镜像以 UID/GID 1654 运行,新命名 volume 由引擎按镜像目录初始化权限。
-不传 `--config` 时默认读取 `/etc/monitor/agent.json`。Agent 默认监听控制端口 `7443/tcp`,数据端口 `7443/udp` 和 `7444/tcp`;防火墙和面板中的节点端口配置需与本地配置一致。`reporting.host_stats` 可关闭主机状态上报;启用时只上报资源使用等汇总数据,不包含主机名、进程或 IP。
+不传 `--config` 时默认读取 `/etc/moshiro/agent.json`。Agent 默认监听控制端口 `7443/tcp`,数据端口 `7443/udp` 和 `7444/tcp`;防火墙和面板中的节点端口配置需与本地配置一致。`reporting.host_stats` 可关闭主机状态上报;启用时只上报资源使用等汇总数据,不包含主机名、进程或 IP。
## 设计说明
diff --git a/backend/agent/src/Monitor.Agent/AgentApp.cs b/backend/agent/src/MoShiro.Agent/AgentApp.cs
similarity index 89%
rename from backend/agent/src/Monitor.Agent/AgentApp.cs
rename to backend/agent/src/MoShiro.Agent/AgentApp.cs
index a23f2f8..70d72b6 100644
--- a/backend/agent/src/Monitor.Agent/AgentApp.cs
+++ b/backend/agent/src/MoShiro.Agent/AgentApp.cs
@@ -4,15 +4,15 @@ using Fleet.Core;
using Fleet.Hosting;
using Fleet.Link;
using Fleet.Rpc;
-using Monitor.Measurement;
-using Monitor.Protocol;
+using MoShiro.Measurement;
+using MoShiro.Protocol;
-namespace Monitor.Agent;
+namespace MoShiro.Agent;
/// Agent 的组装点:数据面、点对点监听、与 Backend 的链路都在这里接起来。没有全局状态,测试可以在同一进程里启动多个。
public sealed class AgentApp : IDisposable
{
- public const string Version = Monitor.Protocol.BuildInfo.Version;
+ public const string Version = MoShiro.Protocol.BuildInfo.Version;
private readonly AgentConfig _config;
private readonly LoadedNodeIdentity _identity;
@@ -35,7 +35,7 @@ public sealed class AgentApp : IDisposable
private readonly TestRunner _tests;
private readonly FleetLink _link;
- /// 配置目录(容器里的 /etc/monitor):宿主机更新器和节点在这里交换清单、请求和状态。
+ /// 配置目录(容器里的 /etc/moshiro):宿主机更新器和节点在这里交换清单、请求和状态。
public AgentApp(AgentConfig config, LoadedNodeIdentity identity, string dataDirectory, TimeProvider time, INodeLog log)
{
_update = new UpdateBridge(dataDirectory, new ConfigStore(dataDirectory).Write, log);
@@ -185,48 +185,48 @@ public sealed class AgentApp : IDisposable
HashSet? allowed = _config.Policy.AllowMethods is { } list ? [.. list] : null;
bool Allow(string method) => allowed is null || allowed.Contains(method);
- if (Allow(MonitorMethods.TestRun))
+ if (Allow(MoShiroMethods.TestRun))
{
router.On(
- MonitorMethods.TestRun,
- MonitorJsonContext.Default.TestRunParams,
- MonitorJsonContext.Default.TestRunResult,
+ MoShiroMethods.TestRun,
+ MoShiroJsonContext.Default.TestRunParams,
+ MoShiroJsonContext.Default.TestRunResult,
(_, run, _) => ValueTask.FromResult(_tests.Start(run)));
}
- if (Allow(MonitorMethods.TestCancel))
+ if (Allow(MoShiroMethods.TestCancel))
{
router.On(
- MonitorMethods.TestCancel,
- MonitorJsonContext.Default.TestCancelParams,
- MonitorJsonContext.Default.TestRunResult,
+ MoShiroMethods.TestCancel,
+ MoShiroJsonContext.Default.TestCancelParams,
+ MoShiroJsonContext.Default.TestRunResult,
(_, cancel, _) => ValueTask.FromResult(Result.Ok(new TestRunResult { Accepted = _tests.Cancel(cancel.TestId) })));
}
- if (Allow(MonitorMethods.UpdateOffer))
+ if (Allow(MoShiroMethods.UpdateOffer))
{
- router.OnNotify(MonitorMethods.UpdateOffer, MonitorJsonContext.Default.UpdateOfferParams, (_, offer, _) =>
+ router.OnNotify(MoShiroMethods.UpdateOffer, MoShiroJsonContext.Default.UpdateOfferParams, (_, offer, _) =>
{
_update.WriteOffer(offer);
return ValueTask.CompletedTask;
});
}
- if (Allow(MonitorMethods.UpdateApply))
+ if (Allow(MoShiroMethods.UpdateApply))
{
- router.OnNotify(MonitorMethods.UpdateApply, MonitorJsonContext.Default.UpdateOfferParams, (_, _, _) =>
+ router.OnNotify(MoShiroMethods.UpdateApply, MoShiroJsonContext.Default.UpdateOfferParams, (_, _, _) =>
{
_update.RequestApply();
return ValueTask.CompletedTask;
});
}
- if (Allow(MonitorMethods.ProbeDisconnect))
+ if (Allow(MoShiroMethods.ProbeDisconnect))
{
router.On(
- MonitorMethods.ProbeDisconnect,
- MonitorJsonContext.Default.ProbeDisconnectParams,
- MonitorJsonContext.Default.TestRunResult,
+ MoShiroMethods.ProbeDisconnect,
+ MoShiroJsonContext.Default.ProbeDisconnectParams,
+ MoShiroJsonContext.Default.TestRunResult,
async (_, request, _) => Result.Ok(new TestRunResult { Accepted = await _hub.DisconnectAsync(request.ProbeId.Value) }));
}
@@ -236,11 +236,11 @@ public sealed class AgentApp : IDisposable
Identity = _identity.Identity,
NodeId = _identity.NodeId,
NodeVersion = Version,
- Capabilities = [MonitorCapabilities.Base, MonitorCapabilities.KindsPrefix + string.Join(',', BlockCatalog.AgentKinds)],
+ Capabilities = [MoShiroCapabilities.Base, MoShiroCapabilities.KindsPrefix + string.Join(',', BlockCatalog.AgentKinds)],
HelloMeta = HelloMeta,
HeartbeatExtra = HeartbeatExtra,
};
- var link = new FleetLink(options, router, [new StateHandler(TaskSet.StateType, MonitorJsonContext.Default.TaskSet, _tasks.ApplyAsync)], _outbox, _time, _log);
+ var link = new FleetLink(options, router, [new StateHandler(TaskSet.StateType, MoShiroJsonContext.Default.TaskSet, _tasks.ApplyAsync)], _outbox, _time, _log);
// 链路重新连上之后补报:在线的 Probe 都告诉 Backend(Backend 重启或链路抖动期间错过了 probe_connected)
link.OnConnected = async (_, _) =>
@@ -257,7 +257,7 @@ public sealed class AgentApp : IDisposable
{
var meta = new AgentHelloMeta
{
- Platform = Monitor.Measurement.PlatformDetector.Detect(),
+ Platform = MoShiro.Measurement.PlatformDetector.Detect(),
TlsSpki = _identity.File.TlsSpki,
ProbeTcpPort = ControlPort,
ProbeUdpPorts = [.. UdpPorts],
@@ -269,7 +269,7 @@ public sealed class AgentApp : IDisposable
MaxConcurrentTests = _config.Limits.MaxConcurrentTests,
},
};
- return JsonSerializer.SerializeToElement(meta, MonitorJsonContext.Default.AgentHelloMeta);
+ return JsonSerializer.SerializeToElement(meta, MoShiroJsonContext.Default.AgentHelloMeta);
}
private long _lastIn;
@@ -296,6 +296,6 @@ public sealed class AgentApp : IDisposable
_lastIn = packetsIn;
_lastOut = packetsOut;
_lastAtMs = nowMs;
- return JsonSerializer.SerializeToElement(extra, MonitorJsonContext.Default.AgentHeartbeatExtra);
+ return JsonSerializer.SerializeToElement(extra, MoShiroJsonContext.Default.AgentHeartbeatExtra);
}
}
diff --git a/backend/agent/src/Monitor.Agent/AgentConfig.cs b/backend/agent/src/MoShiro.Agent/AgentConfig.cs
similarity index 96%
rename from backend/agent/src/Monitor.Agent/AgentConfig.cs
rename to backend/agent/src/MoShiro.Agent/AgentConfig.cs
index 16ed3e9..cc89cb3 100644
--- a/backend/agent/src/Monitor.Agent/AgentConfig.cs
+++ b/backend/agent/src/MoShiro.Agent/AgentConfig.cs
@@ -1,6 +1,6 @@
using System.Text.Json.Serialization;
-namespace Monitor.Agent;
+namespace MoShiro.Agent;
///
/// agent.json:节点本地配置,面板无法修改。其中 limits 是本地硬上限:期望任务集超出这些范围时,
@@ -40,7 +40,7 @@ public sealed class FleetSection
public string Server { get; set; } = "";
[JsonPropertyName("identity_dir")]
- public string IdentityDir { get; set; } = "/etc/monitor";
+ public string IdentityDir { get; set; } = "/etc/moshiro";
}
public sealed class ListenSection
diff --git a/backend/agent/src/Monitor.Agent/Chunks/ChunkAssembler.cs b/backend/agent/src/MoShiro.Agent/Chunks/ChunkAssembler.cs
similarity index 95%
rename from backend/agent/src/Monitor.Agent/Chunks/ChunkAssembler.cs
rename to backend/agent/src/MoShiro.Agent/Chunks/ChunkAssembler.cs
index fc0098d..21f050e 100644
--- a/backend/agent/src/Monitor.Agent/Chunks/ChunkAssembler.cs
+++ b/backend/agent/src/MoShiro.Agent/Chunks/ChunkAssembler.cs
@@ -1,9 +1,9 @@
using Fleet.Core;
using Fleet.Link;
-using Monitor.Measurement;
-using Monitor.Protocol;
+using MoShiro.Measurement;
+using MoShiro.Protocol;
-namespace Monitor.Agent;
+namespace MoShiro.Agent;
///
/// Probe 的列块到达之后:找到对应的流 → 与 Agent 在数据面记录的列合并 → 盖章(块头、时钟锚点)→ 编码 → 放进发件箱(通道 16)。
@@ -70,6 +70,6 @@ public sealed class ChunkAssembler
/// Agent 自己采集的块(目标任务)直接发出。
public void Emit(RawChunk chunk)
{
- _outbox.Enqueue(MonitorChannels.RawChunk, chunk.Header.ChunkId.Value, RawChunkCodec.Encode(chunk));
+ _outbox.Enqueue(MoShiroChannels.RawChunk, chunk.Header.ChunkId.Value, RawChunkCodec.Encode(chunk));
}
}
diff --git a/backend/agent/src/Monitor.Agent/DataPlane/Registries.cs b/backend/agent/src/MoShiro.Agent/DataPlane/Registries.cs
similarity index 99%
rename from backend/agent/src/Monitor.Agent/DataPlane/Registries.cs
rename to backend/agent/src/MoShiro.Agent/DataPlane/Registries.cs
index fff6753..5703c4d 100644
--- a/backend/agent/src/Monitor.Agent/DataPlane/Registries.cs
+++ b/backend/agent/src/MoShiro.Agent/DataPlane/Registries.cs
@@ -4,10 +4,10 @@ using System.Net.Sockets;
using Fleet.Core;
using Fleet.Link;
using Fleet.Rpc;
-using Monitor.Measurement;
-using Monitor.Protocol;
+using MoShiro.Measurement;
+using MoShiro.Protocol;
-namespace Monitor.Agent;
+namespace MoShiro.Agent;
/// 进程内计数(只有计数,没有主机信息):用于心跳和面板上的节点状态。数据面的包计数由共享的 提供。
public sealed class AgentCounters
diff --git a/backend/agent/src/Monitor.Agent/Host/HostSampler.cs b/backend/agent/src/MoShiro.Agent/Host/HostSampler.cs
similarity index 99%
rename from backend/agent/src/Monitor.Agent/Host/HostSampler.cs
rename to backend/agent/src/MoShiro.Agent/Host/HostSampler.cs
index b24d775..05e1791 100644
--- a/backend/agent/src/Monitor.Agent/Host/HostSampler.cs
+++ b/backend/agent/src/MoShiro.Agent/Host/HostSampler.cs
@@ -1,7 +1,7 @@
using System.Globalization;
-using Monitor.Protocol;
+using MoShiro.Protocol;
-namespace Monitor.Agent;
+namespace MoShiro.Agent;
///
/// 主机资源占用的只读快照:CPU 占用、内存、根分区、网卡累计流量与瞬时网速、系统运行时长。
diff --git a/backend/probe/src/Monitor.Probe/Monitor.Probe.csproj b/backend/agent/src/MoShiro.Agent/MoShiro.Agent.csproj
similarity index 78%
rename from backend/probe/src/Monitor.Probe/Monitor.Probe.csproj
rename to backend/agent/src/MoShiro.Agent/MoShiro.Agent.csproj
index 6a2dca7..7896c09 100644
--- a/backend/probe/src/Monitor.Probe/Monitor.Probe.csproj
+++ b/backend/agent/src/MoShiro.Agent/MoShiro.Agent.csproj
@@ -4,8 +4,8 @@
Condition="'$(UseAotAnywhere)' == 'true'" />
Exe
- monitor-probe
- Monitor.Probe
+ moshiro-agent
+ MoShiro.Agent
true
true
true
@@ -15,10 +15,10 @@
false
-
+
-
+
Agent → Backend 的上行:事件和测试状态是尽力而为的通知(链路断开时丢弃;列块走发件箱,不会丢)。
public sealed class BackendUplink
@@ -31,7 +31,7 @@ public sealed class BackendUplink
}
var parameters = new AgentEventParams { Kind = kind, AtUtcMs = _time.GetUtcNow().ToUnixTimeMilliseconds(), Detail = detail, Probe = probe };
- await SafeAsync(() => session.NotifyAsync(MonitorMethods.Event, parameters, MonitorJsonContext.Default.AgentEventParams, CancellationToken.None));
+ await SafeAsync(() => session.NotifyAsync(MoShiroMethods.Event, parameters, MoShiroJsonContext.Default.AgentEventParams, CancellationToken.None));
}
public async ValueTask SendHostAsync(HostSnapshot snapshot)
@@ -42,7 +42,7 @@ public sealed class BackendUplink
return;
}
- await SafeAsync(() => session.NotifyAsync(MonitorMethods.Host, snapshot, MonitorJsonContext.Default.HostSnapshot, CancellationToken.None));
+ await SafeAsync(() => session.NotifyAsync(MoShiroMethods.Host, snapshot, MoShiroJsonContext.Default.HostSnapshot, CancellationToken.None));
}
public async ValueTask SendTestStatusAsync(TestId test, string status, int? phase = null, string? errorCode = null)
@@ -54,7 +54,7 @@ public sealed class BackendUplink
}
var parameters = new TestStatusParams { TestId = test, Status = status, Phase = phase, ErrorCode = errorCode };
- await SafeAsync(() => session.NotifyAsync(MonitorMethods.TestStatus, parameters, MonitorJsonContext.Default.TestStatusParams, CancellationToken.None));
+ await SafeAsync(() => session.NotifyAsync(MoShiroMethods.TestStatus, parameters, MoShiroJsonContext.Default.TestStatusParams, CancellationToken.None));
}
private static async ValueTask SafeAsync(Func send)
@@ -115,7 +115,7 @@ public sealed class PeerHub
var order = new Queue();
rpc.OnBinary = async (frame, token) =>
{
- if (!OutboxFrame.TryParse(frame, out byte channel, out Guid id, out ReadOnlyMemory payload) || channel != MonitorChannels.ColumnBlock)
+ if (!OutboxFrame.TryParse(frame, out byte channel, out Guid id, out ReadOnlyMemory payload) || channel != MoShiroChannels.ColumnBlock)
{
return;
}
@@ -251,7 +251,7 @@ public sealed class PeerHub
{
Type = LineTaskSet.StateType,
Version = set.Version,
- Doc = JsonSerializer.SerializeToElement(set, MonitorJsonContext.Default.LineTaskSet),
+ Doc = JsonSerializer.SerializeToElement(set, MoShiroJsonContext.Default.LineTaskSet),
};
try
{
@@ -270,8 +270,8 @@ public sealed class PeerHub
private static RpcRouter BuildRouter() =>
new RpcRouter()
.On(
- MonitorMethods.Clock,
- MonitorJsonContext.Default.ClockParams,
- MonitorJsonContext.Default.ClockResult,
+ MoShiroMethods.Clock,
+ MoShiroJsonContext.Default.ClockParams,
+ MoShiroJsonContext.Default.ClockResult,
(context, _, _) => ValueTask.FromResult(Result.Ok(new ClockResult { AgentMonoUs = context.Clock.NowUs() })));
}
diff --git a/backend/agent/src/Monitor.Agent/Program.cs b/backend/agent/src/MoShiro.Agent/Program.cs
similarity index 93%
rename from backend/agent/src/Monitor.Agent/Program.cs
rename to backend/agent/src/MoShiro.Agent/Program.cs
index fd273c2..096bf85 100644
--- a/backend/agent/src/Monitor.Agent/Program.cs
+++ b/backend/agent/src/MoShiro.Agent/Program.cs
@@ -1,6 +1,6 @@
using Fleet.Core;
using Fleet.Hosting;
-using Monitor.Agent;
+using MoShiro.Agent;
TimeProvider time = TimeProvider.System;
INodeLog log = new ConsoleNodeLog(time);
@@ -11,7 +11,7 @@ if (PlatformCheck.VerifyCrypto() is { } problem)
return 1;
}
-string configPath = "/etc/monitor/agent.json";
+string configPath = "/etc/moshiro/agent.json";
for (int i = 0; i < args.Length - 1; i++)
{
if (args[i] == "--config")
diff --git a/backend/agent/src/Monitor.Agent/Tasks/TargetRunners.cs b/backend/agent/src/MoShiro.Agent/Tasks/TargetRunners.cs
similarity index 98%
rename from backend/agent/src/Monitor.Agent/Tasks/TargetRunners.cs
rename to backend/agent/src/MoShiro.Agent/Tasks/TargetRunners.cs
index 667cab7..a5dbf29 100644
--- a/backend/agent/src/Monitor.Agent/Tasks/TargetRunners.cs
+++ b/backend/agent/src/MoShiro.Agent/Tasks/TargetRunners.cs
@@ -1,10 +1,10 @@
using System.Net;
using System.Text.Json;
using Fleet.Core;
-using Monitor.Measurement;
-using Monitor.Protocol;
+using MoShiro.Measurement;
+using MoShiro.Protocol;
-namespace Monitor.Agent;
+namespace MoShiro.Agent;
///
/// 目标任务(Agent 自己探测一个地址,没有对端):用和线路任务同一套积木( 里的拨号方,例如 icmp_echo、connect),
diff --git a/backend/agent/src/Monitor.Agent/Tasks/TaskManager.cs b/backend/agent/src/MoShiro.Agent/Tasks/TaskManager.cs
similarity index 99%
rename from backend/agent/src/Monitor.Agent/Tasks/TaskManager.cs
rename to backend/agent/src/MoShiro.Agent/Tasks/TaskManager.cs
index 070ed17..a8254a0 100644
--- a/backend/agent/src/Monitor.Agent/Tasks/TaskManager.cs
+++ b/backend/agent/src/MoShiro.Agent/Tasks/TaskManager.cs
@@ -1,10 +1,10 @@
using System.Text.Json;
using Fleet.Core;
using Fleet.Rpc;
-using Monitor.Measurement;
-using Monitor.Protocol;
+using MoShiro.Measurement;
+using MoShiro.Protocol;
-namespace Monitor.Agent;
+namespace MoShiro.Agent;
///
/// 期望任务集(task_set)的调和器:每个任务先经过 (参数校验 + 本地硬上限)。
diff --git a/backend/agent/src/Monitor.Agent/Tests/TestRunner.cs b/backend/agent/src/MoShiro.Agent/Tests/TestRunner.cs
similarity index 90%
rename from backend/agent/src/Monitor.Agent/Tests/TestRunner.cs
rename to backend/agent/src/MoShiro.Agent/Tests/TestRunner.cs
index cfb7017..23c2ddc 100644
--- a/backend/agent/src/Monitor.Agent/Tests/TestRunner.cs
+++ b/backend/agent/src/MoShiro.Agent/Tests/TestRunner.cs
@@ -1,15 +1,15 @@
using System.Collections.Concurrent;
using Fleet.Core;
using Fleet.Rpc;
-using Monitor.Measurement;
-using Monitor.Protocol;
+using MoShiro.Measurement;
+using MoShiro.Protocol;
-namespace Monitor.Agent;
+namespace MoShiro.Agent;
///
-/// 按需测试的编排(monitor.test.run):Agent 是时间的主人。每个阶段:
-/// 登记数据面的流 → monitor.test.phase(Probe 准备好自己一侧的角色)→ 运行(单向数据流由 Agent 发包,回显类等待 Probe 发包)
-/// → monitor.test.phase_end(Probe 收尾,回复它交出的列块个数)→ 等所有列块合并上传 → phase_done。
+/// 按需测试的编排(moshiro.test.run):Agent 是时间的主人。每个阶段:
+/// 登记数据面的流 → moshiro.test.phase(Probe 准备好自己一侧的角色)→ 运行(单向数据流由 Agent 发包,回显类等待 Probe 发包)
+/// → moshiro.test.phase_end(Probe 收尾,回复它交出的列块个数)→ 等所有列块合并上传 → phase_done。
/// 同一时间只能运行 max_concurrent_tests 个测试;Probe 掉线或被取消时测试中止,已经上传的阶段数据保留。
///
public sealed class TestRunner
@@ -43,17 +43,17 @@ public sealed class TestRunner
public int Running => _running.Count;
- /// 校验并接受一个测试(立即返回),实际运行在后台进行,状态通过 monitor.test.status 回报。
+ /// 校验并接受一个测试(立即返回),实际运行在后台进行,状态通过 moshiro.test.status 回报。
public Result Start(TestRunParams run)
{
if (_sessions.Get(run.ProbeId.Value) is not { } probe)
{
- return Result.Fail(MonitorErrors.ProbeOffline, $"probe {run.ProbeId.Value} is not connected to this agent");
+ return Result.Fail(MoShiroErrors.ProbeOffline, $"probe {run.ProbeId.Value} is not connected to this agent");
}
if (run.Phases.Count == 0)
{
- return Result.Fail(MonitorErrors.ValidationFailed, "a test needs at least one phase");
+ return Result.Fail(MoShiroErrors.ValidationFailed, "a test needs at least one phase");
}
var resolved = new List<(TestPhase Phase, TaskDecision Decision)>();
@@ -64,7 +64,7 @@ public sealed class TestRunner
if (!decision.Accepted)
{
return Result.Fail(
- decision.Reason == RejectReasons.Unsupported ? FleetErrors.Unsupported : MonitorErrors.BudgetExceeded,
+ decision.Reason == RejectReasons.Unsupported ? FleetErrors.Unsupported : MoShiroErrors.BudgetExceeded,
$"phase {phase.Kind} refused: {decision.Reason}");
}
@@ -84,7 +84,7 @@ public sealed class TestRunner
if (_running.Count >= _maxConcurrent || !_running.TryAdd(run.TestId.Value, running))
{
running.Dispose();
- return Result.Fail(MonitorErrors.TestBusy, "this agent is already running a test");
+ return Result.Fail(MoShiroErrors.TestBusy, "this agent is already running a test");
}
_ = Task.Run(() => RunAsync(run.TestId, resolved, running), CancellationToken.None);
@@ -154,7 +154,7 @@ public sealed class TestRunner
catch (OperationCanceledException)
{
finalStatus = running.Lost ? TestStatuses.Failed : TestStatuses.Aborted;
- errorCode = running.Lost ? MonitorErrors.ProbeOffline.Value : null;
+ errorCode = running.Lost ? MoShiroErrors.ProbeOffline.Value : null;
await TryAbortProbeAsync(running.Probe, test);
}
catch (TestFailure failure)
@@ -183,7 +183,7 @@ public sealed class TestRunner
_streams.Add(stream);
try
{
- RpcSession rpc = probe.Rpc ?? throw new TestFailure(MonitorErrors.ProbeOffline.Value);
+ RpcSession rpc = probe.Rpc ?? throw new TestFailure(MoShiroErrors.ProbeOffline.Value);
var start = new TestPhaseStartParams
{
TestId = test,
@@ -194,7 +194,7 @@ public sealed class TestRunner
DurationSeconds = durationSeconds,
Port = stream.Port,
};
- Result accepted = await rpc.RequestAsync(MonitorMethods.TestPhase, start, MonitorJsonContext.Default.TestPhaseStartParams, MonitorJsonContext.Default.TestPhaseStartResult, ct);
+ Result accepted = await rpc.RequestAsync(MoShiroMethods.TestPhase, start, MoShiroJsonContext.Default.TestPhaseStartParams, MoShiroJsonContext.Default.TestPhaseStartResult, ct);
if (!accepted.TryGet(out TestPhaseStartResult? started, out FleetError? error) || !started.Accepted)
{
throw new TestFailure(error?.Code.Value ?? FleetErrors.Unsupported.Value);
@@ -209,7 +209,7 @@ public sealed class TestRunner
}
catch (BlockFaultException)
{
- throw new TestFailure(MonitorErrors.ProbeOffline.Value);
+ throw new TestFailure(MoShiroErrors.ProbeOffline.Value);
}
}
else
@@ -219,7 +219,7 @@ public sealed class TestRunner
long sent = stream.Running.Block.Produced;
var end = new TestPhaseEndParams { TestId = test, Phase = index, StreamId = stream.Id, SentCount = sent };
- Result ended = await rpc.RequestAsync(MonitorMethods.TestPhaseEnd, end, MonitorJsonContext.Default.TestPhaseEndParams, MonitorJsonContext.Default.TestPhaseEndResult, ct, s_phaseSlack);
+ Result ended = await rpc.RequestAsync(MoShiroMethods.TestPhaseEnd, end, MoShiroJsonContext.Default.TestPhaseEndParams, MoShiroJsonContext.Default.TestPhaseEndResult, ct, s_phaseSlack);
if (!ended.TryGet(out TestPhaseEndResult? finished, out FleetError? endError))
{
throw new TestFailure(endError.Code.Value);
@@ -254,7 +254,7 @@ public sealed class TestRunner
try
{
- await rpc.NotifyAsync(MonitorMethods.TestAbort, new TestAbortParams { TestId = test }, MonitorJsonContext.Default.TestAbortParams, CancellationToken.None);
+ await rpc.NotifyAsync(MoShiroMethods.TestAbort, new TestAbortParams { TestId = test }, MoShiroJsonContext.Default.TestAbortParams, CancellationToken.None);
}
catch (Exception ex) when (ex is ObjectDisposedException or InvalidOperationException or IOException)
{
diff --git a/backend/fleet/src/Fleet.Core/StringId.cs b/backend/fleet/src/Fleet.Core/StringId.cs
index 87f4058..71371bb 100644
--- a/backend/fleet/src/Fleet.Core/StringId.cs
+++ b/backend/fleet/src/Fleet.Core/StringId.cs
@@ -3,7 +3,7 @@ using System.Text.Json.Serialization;
namespace Fleet.Core;
-/// 节点 ID(带类型前缀的 ULID)。Monitor 中的 AgentId 就是 NodeId。
+/// 节点 ID(带类型前缀的 ULID)。MoShiro 中的 AgentId 就是 NodeId。
[JsonConverter(typeof(NodeIdJsonConverter))]
public readonly record struct NodeId(string Value)
{
diff --git a/backend/fleet/src/Fleet.Link/FleetLink.cs b/backend/fleet/src/Fleet.Link/FleetLink.cs
index 0fdcc5f..5d86ded 100644
--- a/backend/fleet/src/Fleet.Link/FleetLink.cs
+++ b/backend/fleet/src/Fleet.Link/FleetLink.cs
@@ -49,7 +49,7 @@ public sealed class FleetLinkOptions
public string NodeVersion { get; init; } = "0.0.0";
- /// 框架之外的能力,例如 monitor.v1 与 monitor.kinds:udp_echo,tcp_echo。
+ /// 框架之外的能力,例如 moshiro.v1 与 moshiro.kinds:udp_echo,tcp_echo。
public IReadOnlyList Capabilities { get; init; } = [];
/// 附加到 fleet.hello 的产品元数据。
diff --git a/backend/fleet/src/Fleet.Rpc/FleetMethods.cs b/backend/fleet/src/Fleet.Rpc/FleetMethods.cs
index 9053db9..6062ead 100644
--- a/backend/fleet/src/Fleet.Rpc/FleetMethods.cs
+++ b/backend/fleet/src/Fleet.Rpc/FleetMethods.cs
@@ -58,7 +58,7 @@ public sealed class HelloParams
[JsonPropertyName("now_utc_ms")]
public long NowUtcMs { get; set; }
- /// 产品自定义的元数据(例如 Monitor 的 tls_spki、probe_ports、local_limits 摘要)。
+ /// 产品自定义的元数据(例如 MoShiro 的 tls_spki、probe_ports、local_limits 摘要)。
[JsonPropertyName("meta")]
public JsonElement? Meta { get; set; }
}
diff --git a/backend/fleet/src/Fleet.Server.Abstractions/FleetServerOptions.cs b/backend/fleet/src/Fleet.Server.Abstractions/FleetServerOptions.cs
index fd99ac7..0a581bf 100644
--- a/backend/fleet/src/Fleet.Server.Abstractions/FleetServerOptions.cs
+++ b/backend/fleet/src/Fleet.Server.Abstractions/FleetServerOptions.cs
@@ -2,7 +2,7 @@ namespace Fleet.Server;
public sealed class FleetServerOptions
{
- /// 节点 ID 的类型前缀,Monitor 使用 agt。
+ /// 节点 ID 的类型前缀,MoShiro 使用 agt。
public string NodeIdPrefix { get; set; } = "node";
public int MaxFrameBytes { get; set; } = 16 << 20;
diff --git a/backend/fleet/src/Fleet.Server.Abstractions/IFleetStore.cs b/backend/fleet/src/Fleet.Server.Abstractions/IFleetStore.cs
index ed00273..e4d7af0 100644
--- a/backend/fleet/src/Fleet.Server.Abstractions/IFleetStore.cs
+++ b/backend/fleet/src/Fleet.Server.Abstractions/IFleetStore.cs
@@ -2,7 +2,7 @@ using Fleet.Core;
namespace Fleet.Server;
-/// Fleet 服务端需要的存储。产品可以自己实现(Monitor 把它放进 monitor.db)。
+/// Fleet 服务端需要的存储。产品可以自己实现(MoShiro 把它放进 moshiro.db)。
public interface IFleetStore
{
ValueTask FindJoinTokenAsync(ReadOnlyMemory tokenSha256, CancellationToken ct);
diff --git a/backend/fleet/src/Fleet.Server.Link/FleetServerBuilder.cs b/backend/fleet/src/Fleet.Server.Link/FleetServerBuilder.cs
index 7141df9..755deb2 100644
--- a/backend/fleet/src/Fleet.Server.Link/FleetServerBuilder.cs
+++ b/backend/fleet/src/Fleet.Server.Link/FleetServerBuilder.cs
@@ -50,7 +50,7 @@ public sealed class FleetServerBuilder
return this;
}
- /// 注册产品的 RPC 方法(monitor.* 等)。处理函数通过 在调用时解析服务,避免构造期的循环依赖。
+ /// 注册产品的 RPC 方法(moshiro.* 等)。处理函数通过 在调用时解析服务,避免构造期的循环依赖。
public FleetServerBuilder MapMethods(Action, IServiceProvider> configure)
{
_routeConfigurators.Add(configure);
diff --git a/backend/fleet/tools/fleet-enroll/Program.cs b/backend/fleet/tools/fleet-enroll/Program.cs
index 2ede74b..3c31989 100644
--- a/backend/fleet/tools/fleet-enroll/Program.cs
+++ b/backend/fleet/tools/fleet-enroll/Program.cs
@@ -2,7 +2,7 @@ using System.Text.Json.Nodes;
using Fleet.Core;
using Fleet.Enrollment.Client;
-// fleet-enroll --server https://panel --join jt_xxx --name jp-1 --identity-dir /etc/monitor [--meta '{"probe_tcp_port":7443,...}'] [--version 1.0]
+// fleet-enroll --server https://panel --join jt_xxx --name jp-1 --identity-dir /etc/moshiro [--meta '{"probe_tcp_port":7443,...}'] [--version 1.0]
// 一次性运行:生成身份、注册、写入身份目录,然后退出。
string? Arg(string name) => args.SkipWhile(a => a != name).Skip(1).FirstOrDefault();
diff --git a/backend/openapi/v1.json b/backend/openapi/v1.json
index bc9085e..fb33894 100644
--- a/backend/openapi/v1.json
+++ b/backend/openapi/v1.json
@@ -1,7 +1,7 @@
{
"openapi": "3.1.1",
"info": {
- "title": "monitor-backend | v1",
+ "title": "moshiro-backend | v1",
"version": "1.0.0"
},
"paths": {
@@ -3168,7 +3168,7 @@
"tags": [
"admin-data"
],
- "summary": "Download a raw chunk (application/vnd.monitor.rawchunk)",
+ "summary": "Download a raw chunk (application/vnd.moshiro.rawchunk)",
"operationId": "raw_chunks_get",
"parameters": [
{
diff --git a/backend/probe/README.md b/backend/probe/README.md
index 6e764cc..76db344 100644
--- a/backend/probe/README.md
+++ b/backend/probe/README.md
@@ -1,4 +1,4 @@
-# Monitor Probe
+# MoShiro Probe
Probe 是网络测量的发起端,通常运行在家宽或其他需要观测的网络出口。它连接 Backend(身份、Agent 列表、状态)和 Agent(测量),执行线路任务,并把本端采集的原始数据交给 Agent 汇总上报。Probe 不提供远程命令或文件管理功能。
@@ -13,7 +13,7 @@ Backend ──任务──> Agent <──测量会话──> Probe
Probe 使用面板生成的 `probe.json` 读取自身身份、面板地址(`server`)和本地测试限制。连上面板之后,面板下发要连接的 Agent 列表;Probe 将列表缓存到同目录的 `agents.json`,面板暂时连不上时靠它继续测量。`probe.json` 含私钥,请限制文件访问权限,不要提交到版本控制。
-容器节点的运行方式(podman + systemd)和宿主机更新器见 [`../../docs/deployment.md`](../../docs/deployment.md);Probe 也可以用 OCI 镜像 `registry.oeo.one/monitor/monitor-probe:`,容器默认读取 `/etc/monitor/probe.json`,命名 volume 保存身份配置和缓存,镜像以 UID/GID 1654 运行。
+容器节点的运行方式(podman + systemd)和宿主机更新器见 [`../../docs/deployment.md`](../../docs/deployment.md);Probe 也可以用 OCI 镜像 `registry.oeo.one/moshiro/moshiro-probe:`,容器默认读取 `/etc/moshiro/probe.json`,命名 volume 保存身份配置和缓存,镜像以 UID/GID 1654 运行。
## 构建
@@ -21,33 +21,33 @@ Probe 使用面板生成的 `probe.json` 读取自身身份、面板地址(`se
```sh
cd backend
-dotnet build probe/src/Monitor.Probe -c Release
+dotnet build probe/src/MoShiro.Probe -c Release
```
发布 NativeAOT 程序需要对应平台的 C/C++ 工具链;`` 应与构建环境和目标平台匹配:
```sh
-dotnet publish probe/src/Monitor.Probe -c Release -r -p:PublishAot=true
+dotnet publish probe/src/MoShiro.Probe -c Release -r -p:PublishAot=true
```
也可在仓库根目录运行 `bash scripts/publish.sh probe `,再使用 `scripts/package.sh probe ` 生成部署包。支持平台和安装流程见 [`../../docs/deployment.md`](../../docs/deployment.md)。
## 配置与运行
-在管理端创建 Probe 并下载一次性身份配置,将文件保存为目标机上的 `/etc/monitor/probe.json`。随后运行:
+在管理端创建 Probe 并下载一次性身份配置,将文件保存为目标机上的 `/etc/moshiro/probe.json`。随后运行:
```sh
-monitor-probe --config /etc/monitor/probe.json
+moshiro-probe --config /etc/moshiro/probe.json
```
-不传 `--config` 时默认读取 `/etc/monitor/probe.json`。配置中的 `limits` 是本地硬上限,Backend 无法远程放宽;路由器等低性能设备可调低测试码率和包速率,避免 Probe 自身成为测量瓶颈。部署时可使用仓库的 `packaging/` 文件和安装脚本。
+不传 `--config` 时默认读取 `/etc/moshiro/probe.json`。配置中的 `limits` 是本地硬上限,Backend 无法远程放宽;路由器等低性能设备可调低测试码率和包速率,避免 Probe 自身成为测量瓶颈。部署时可使用仓库的 `packaging/` 文件和安装脚本。
-也可使用 OCI 镜像 `registry.oeo.one/monitor/monitor-probe:`,自动选择 Linux amd64 或 arm64 镜像。容器默认读取 `/etc/monitor/probe.json`,并在同一目录维护 `agents.json` 缓存,因此挂载目录必须允许 UID/GID 1654 读写。建议使用宿主网络,并按 ICMP 测量需求添加 `NET_RAW` 能力。
+也可使用 OCI 镜像 `registry.oeo.one/moshiro/moshiro-probe:`,自动选择 Linux amd64 或 arm64 镜像。容器默认读取 `/etc/moshiro/probe.json`,并在同一目录维护 `agents.json` 缓存,因此挂载目录必须允许 UID/GID 1654 读写。建议使用宿主网络,并按 ICMP 测量需求添加 `NET_RAW` 能力。
## 设计说明
- Probe 只执行编译进程序的测量模块。它不落盘测量数据,也不能执行命令或自行更新(更新由宿主机上的更新器完成,Probe 只写清单和请求文件)。
-- 测量模块由 `backend/shared/Monitor.Measurement/` 与 Agent 共用;Probe 负责发起连接、调度任务和记录本端数据。
+- 测量模块由 `backend/shared/MoShiro.Measurement/` 与 Agent 共用;Probe 负责发起连接、调度任务和记录本端数据。
- 测量模型和协议细节见 [`../../docs/measurement.md`](../../docs/measurement.md) 与 [`../../docs/protocol.md`](../../docs/protocol.md);整体架构见 [`../../docs/architecture.md`](../../docs/architecture.md)。
Docker 与 rootless/rootful Podman 共用 `packaging/compose/probe/compose.yaml`,配置、身份和缓存放在命名 volume 中,无需宿主配置目录、keep-id 或手动 chown。首次导入和自动更新见部署文档。
diff --git a/backend/probe/src/Monitor.Probe/Link/AgentConnection.cs b/backend/probe/src/MoShiro.Probe/Link/AgentConnection.cs
similarity index 95%
rename from backend/probe/src/Monitor.Probe/Link/AgentConnection.cs
rename to backend/probe/src/MoShiro.Probe/Link/AgentConnection.cs
index f01ad3d..1a2e621 100644
--- a/backend/probe/src/Monitor.Probe/Link/AgentConnection.cs
+++ b/backend/probe/src/MoShiro.Probe/Link/AgentConnection.cs
@@ -6,10 +6,10 @@ using Fleet.Core;
using Fleet.Identity;
using Fleet.Link;
using Fleet.Rpc;
-using Monitor.Measurement;
-using Monitor.Protocol;
+using MoShiro.Measurement;
+using MoShiro.Protocol;
-namespace Monitor.Probe;
+namespace MoShiro.Probe;
/// 所有连接共用的东西。
public sealed record ConnectionEnv(NodeIdentity Identity, string ProbeId, ProbeLimits Limits, AgentDirectory Directory, MonoClock Clock, TimeProvider Time, INodeLog Log);
@@ -154,7 +154,7 @@ public sealed class AgentConnection
for (int i = 0; i < rounds; i++)
{
long sent = _env.Clock.NowUs();
- Result reply = await rpc.RequestAsync(MonitorMethods.Clock, new ClockParams { ProbeMonoUs = sent }, MonitorJsonContext.Default.ClockParams, MonitorJsonContext.Default.ClockResult, ct);
+ Result reply = await rpc.RequestAsync(MoShiroMethods.Clock, new ClockParams { ProbeMonoUs = sent }, MoShiroJsonContext.Default.ClockParams, MoShiroJsonContext.Default.ClockResult, ct);
if (reply.TryGet(out ClockResult? value, out _))
{
clock.Add(sent, value.AgentMonoUs, _env.Clock.NowUs());
@@ -189,7 +189,7 @@ public sealed class AgentConnection
var result = new StateSyncResult { AppliedVersion = sync.Version };
if (sync.Type == LineTaskSet.StateType)
{
- LineTaskSet? set = sync.Doc.Deserialize(MonitorJsonContext.Default.LineTaskSet);
+ LineTaskSet? set = sync.Doc.Deserialize(MoShiroJsonContext.Default.LineTaskSet);
if (set is null)
{
return Result.Fail(FleetErrors.InvalidParams, "line_task_set could not be parsed");
@@ -201,18 +201,18 @@ public sealed class AgentConnection
return Result.Ok(result);
})
.On(
- MonitorMethods.TestPhase,
- MonitorJsonContext.Default.TestPhaseStartParams,
- MonitorJsonContext.Default.TestPhaseStartResult,
+ MoShiroMethods.TestPhase,
+ MoShiroJsonContext.Default.TestPhaseStartParams,
+ MoShiroJsonContext.Default.TestPhaseStartResult,
(session, start, _) => ValueTask.FromResult(Result.Ok(new TestPhaseStartResult { Accepted = session.StartPhase(start) })))
.On(
- MonitorMethods.TestPhaseEnd,
- MonitorJsonContext.Default.TestPhaseEndParams,
- MonitorJsonContext.Default.TestPhaseEndResult,
+ MoShiroMethods.TestPhaseEnd,
+ MoShiroJsonContext.Default.TestPhaseEndParams,
+ MoShiroJsonContext.Default.TestPhaseEndResult,
async (session, end, ct) => Result.Ok(new TestPhaseEndResult { Fragments = await session.EndPhaseAsync(end, ct) }))
.OnNotify(
- MonitorMethods.TestAbort,
- MonitorJsonContext.Default.TestAbortParams,
+ MoShiroMethods.TestAbort,
+ MoShiroJsonContext.Default.TestAbortParams,
async (session, abort, _) => await session.AbortAsync(abort.TestId))
.OnNotify(
FleetMethods.OutboxAck,
diff --git a/backend/probe/src/Monitor.Probe/Link/AgentDirectory.cs b/backend/probe/src/MoShiro.Probe/Link/AgentDirectory.cs
similarity index 98%
rename from backend/probe/src/Monitor.Probe/Link/AgentDirectory.cs
rename to backend/probe/src/MoShiro.Probe/Link/AgentDirectory.cs
index 4c74202..4a59d2c 100644
--- a/backend/probe/src/Monitor.Probe/Link/AgentDirectory.cs
+++ b/backend/probe/src/MoShiro.Probe/Link/AgentDirectory.cs
@@ -1,9 +1,9 @@
using System.Text.Json;
using Fleet.Core;
using Fleet.Hosting;
-using Monitor.Protocol;
+using MoShiro.Protocol;
-namespace Monitor.Probe;
+namespace MoShiro.Probe;
///
/// Probe 要连接的 Agent 列表:由面板作为期望状态(probe_agents)直接下发;面板连不上时用上一次保存的 agents.json。
diff --git a/backend/probe/src/Monitor.Probe/Link/Support.cs b/backend/probe/src/MoShiro.Probe/Link/Support.cs
similarity index 93%
rename from backend/probe/src/Monitor.Probe/Link/Support.cs
rename to backend/probe/src/MoShiro.Probe/Link/Support.cs
index e593ef6..253be3a 100644
--- a/backend/probe/src/Monitor.Probe/Link/Support.cs
+++ b/backend/probe/src/MoShiro.Probe/Link/Support.cs
@@ -1,13 +1,13 @@
using System.Text.Json;
using Fleet.Core;
using Fleet.Link;
-using Monitor.Measurement;
-using Monitor.Protocol;
+using MoShiro.Measurement;
+using MoShiro.Protocol;
-namespace Monitor.Probe;
+namespace MoShiro.Probe;
///
-/// 估计 Agent 单调时钟 − Probe 单调时钟:每次 monitor.clock 往返取中点,在最近 8 次里取往返最短的一次
+/// 估计 Agent 单调时钟 − Probe 单调时钟:每次 moshiro.clock 往返取中点,在最近 8 次里取往返最短的一次
/// (往返越短,对称性假设的误差越小)。Probe 的列块头里带着这个偏移,Backend 据此对齐两端的时间戳。
///
public sealed class ClockEstimator
@@ -82,6 +82,6 @@ public sealed class FragmentShipper : IFragmentSink
}
}
- _outbox.Enqueue(MonitorChannels.ColumnBlock, header.ChunkId.Value, RawChunkCodec.Encode(new RawChunk(header, streams)));
+ _outbox.Enqueue(MoShiroChannels.ColumnBlock, header.ChunkId.Value, RawChunkCodec.Encode(new RawChunk(header, streams)));
}
}
diff --git a/backend/agent/src/Monitor.Agent/Monitor.Agent.csproj b/backend/probe/src/MoShiro.Probe/MoShiro.Probe.csproj
similarity index 78%
rename from backend/agent/src/Monitor.Agent/Monitor.Agent.csproj
rename to backend/probe/src/MoShiro.Probe/MoShiro.Probe.csproj
index f25af4d..54d4202 100644
--- a/backend/agent/src/Monitor.Agent/Monitor.Agent.csproj
+++ b/backend/probe/src/MoShiro.Probe/MoShiro.Probe.csproj
@@ -4,8 +4,8 @@
Condition="'$(UseAotAnywhere)' == 'true'" />
Exe
- monitor-agent
- Monitor.Agent
+ moshiro-probe
+ MoShiro.Probe
true
true
true
@@ -15,10 +15,10 @@
false
-
+
-
+
/// Probe 的组装点:到面板的长连接(身份、Agent 列表、状态)+ 每个 Agent 一个测量连接(认证、重连、角色)。没有全局状态,测试可以在同一进程里启动多个。
@@ -15,7 +15,7 @@ namespace Monitor.Probe;
///
public sealed class ProbeApp : IDisposable
{
- public const string Version = Monitor.Protocol.BuildInfo.Version;
+ public const string Version = MoShiro.Protocol.BuildInfo.Version;
private readonly ConnectionEnv _env;
private readonly Dictionary _connections = [];
@@ -38,25 +38,25 @@ public sealed class ProbeApp : IDisposable
Identity = identity,
NodeId = new NodeId(file.ProbeId),
NodeVersion = Version,
- Capabilities = [MonitorCapabilities.Base],
- HeartbeatExtra = () => JsonSerializer.SerializeToElement(new ProbeHeartbeatExtra { Update = update.ReadStatus() }, MonitorJsonContext.Default.ProbeHeartbeatExtra),
- HelloMeta = () => JsonSerializer.SerializeToElement(new ProbeHelloMeta { Platform = PlatformDetector.Detect() }, MonitorJsonContext.Default.ProbeHelloMeta),
+ Capabilities = [MoShiroCapabilities.Base],
+ HeartbeatExtra = () => JsonSerializer.SerializeToElement(new ProbeHeartbeatExtra { Update = update.ReadStatus() }, MoShiroJsonContext.Default.ProbeHeartbeatExtra),
+ HelloMeta = () => JsonSerializer.SerializeToElement(new ProbeHelloMeta { Platform = PlatformDetector.Detect() }, MoShiroJsonContext.Default.ProbeHelloMeta),
};
var list = new StateHandler(
ProbeAgentList.StateType,
- MonitorJsonContext.Default.ProbeAgentList,
+ MoShiroJsonContext.Default.ProbeAgentList,
(version, doc, _) =>
{
directory.Apply(doc);
return ValueTask.FromResult(new StateSyncResult { AppliedVersion = version });
});
var router = new RpcRouter()
- .OnNotify(MonitorMethods.UpdateOffer, MonitorJsonContext.Default.UpdateOfferParams, (_, offer, _) =>
+ .OnNotify(MoShiroMethods.UpdateOffer, MoShiroJsonContext.Default.UpdateOfferParams, (_, offer, _) =>
{
update.WriteOffer(offer);
return ValueTask.CompletedTask;
})
- .OnNotify(MonitorMethods.UpdateApply, MonitorJsonContext.Default.UpdateOfferParams, (_, _, _) =>
+ .OnNotify(MoShiroMethods.UpdateApply, MoShiroJsonContext.Default.UpdateOfferParams, (_, _, _) =>
{
update.RequestApply();
return ValueTask.CompletedTask;
diff --git a/backend/probe/src/Monitor.Probe/ProbeConfig.cs b/backend/probe/src/MoShiro.Probe/ProbeConfig.cs
similarity index 98%
rename from backend/probe/src/Monitor.Probe/ProbeConfig.cs
rename to backend/probe/src/MoShiro.Probe/ProbeConfig.cs
index bcaf11e..5bb9aa8 100644
--- a/backend/probe/src/Monitor.Probe/ProbeConfig.cs
+++ b/backend/probe/src/MoShiro.Probe/ProbeConfig.cs
@@ -1,6 +1,6 @@
using System.Text.Json.Serialization;
-namespace Monitor.Probe;
+namespace MoShiro.Probe;
///
/// probe.json:面板 POST /api/admin/probe/identity 生成的文件(只能下载一次)。
diff --git a/backend/probe/src/Monitor.Probe/Program.cs b/backend/probe/src/MoShiro.Probe/Program.cs
similarity index 95%
rename from backend/probe/src/Monitor.Probe/Program.cs
rename to backend/probe/src/MoShiro.Probe/Program.cs
index 2a025ac..cadfb11 100644
--- a/backend/probe/src/Monitor.Probe/Program.cs
+++ b/backend/probe/src/MoShiro.Probe/Program.cs
@@ -1,6 +1,6 @@
using Fleet.Core;
using Fleet.Hosting;
-using Monitor.Probe;
+using MoShiro.Probe;
TimeProvider time = TimeProvider.System;
INodeLog log = new ConsoleNodeLog(time);
@@ -11,7 +11,7 @@ if (PlatformCheck.VerifyCrypto() is { } problem)
return 1;
}
-string configPath = "/etc/monitor/probe.json";
+string configPath = "/etc/moshiro/probe.json";
for (int i = 0; i < args.Length - 1; i++)
{
if (args[i] == "--config")
diff --git a/backend/probe/tests/Monitor.Probe.Tests/Monitor.Probe.Tests.csproj b/backend/probe/tests/MoShiro.Probe.Tests/MoShiro.Probe.Tests.csproj
similarity index 82%
rename from backend/probe/tests/Monitor.Probe.Tests/Monitor.Probe.Tests.csproj
rename to backend/probe/tests/MoShiro.Probe.Tests/MoShiro.Probe.Tests.csproj
index 1367d6a..d27508f 100644
--- a/backend/probe/tests/Monitor.Probe.Tests/Monitor.Probe.Tests.csproj
+++ b/backend/probe/tests/MoShiro.Probe.Tests/MoShiro.Probe.Tests.csproj
@@ -5,7 +5,7 @@
-
+
diff --git a/backend/probe/tests/Monitor.Probe.Tests/ProbeTests.cs b/backend/probe/tests/MoShiro.Probe.Tests/ProbeTests.cs
similarity index 98%
rename from backend/probe/tests/Monitor.Probe.Tests/ProbeTests.cs
rename to backend/probe/tests/MoShiro.Probe.Tests/ProbeTests.cs
index 89d3f20..d8bfa02 100644
--- a/backend/probe/tests/Monitor.Probe.Tests/ProbeTests.cs
+++ b/backend/probe/tests/MoShiro.Probe.Tests/ProbeTests.cs
@@ -1,8 +1,8 @@
using Fleet.Core;
using Fleet.Hosting;
-using Monitor.Protocol;
+using MoShiro.Protocol;
-namespace Monitor.Probe.Tests;
+namespace MoShiro.Probe.Tests;
public sealed class ProbeTests
{
diff --git a/backend/shared/Monitor.Measurement/Blocks/BlockBase.cs b/backend/shared/MoShiro.Measurement/Blocks/BlockBase.cs
similarity index 98%
rename from backend/shared/Monitor.Measurement/Blocks/BlockBase.cs
rename to backend/shared/MoShiro.Measurement/Blocks/BlockBase.cs
index 8463d00..afa65cf 100644
--- a/backend/shared/Monitor.Measurement/Blocks/BlockBase.cs
+++ b/backend/shared/MoShiro.Measurement/Blocks/BlockBase.cs
@@ -1,7 +1,7 @@
using System.Net;
-using Monitor.Protocol;
+using MoShiro.Protocol;
-namespace Monitor.Measurement;
+namespace MoShiro.Measurement;
/// 积木的公共部分:环境、参数、把行切成列块交出去。
public abstract class BlockBase : IBlock
diff --git a/backend/shared/Monitor.Measurement/Blocks/BlockCatalog.cs b/backend/shared/MoShiro.Measurement/Blocks/BlockCatalog.cs
similarity index 97%
rename from backend/shared/Monitor.Measurement/Blocks/BlockCatalog.cs
rename to backend/shared/MoShiro.Measurement/Blocks/BlockCatalog.cs
index 3970f2b..43465ab 100644
--- a/backend/shared/Monitor.Measurement/Blocks/BlockCatalog.cs
+++ b/backend/shared/MoShiro.Measurement/Blocks/BlockCatalog.cs
@@ -1,6 +1,6 @@
-using Monitor.Protocol;
+using MoShiro.Protocol;
-namespace Monitor.Measurement;
+namespace MoShiro.Measurement;
///
/// 一种采集方法(Kind)的两个角色:拨号方(Probe)和监听方(Agent),以及它能不能作为目标任务(Agent 自己探测一个地址,没有对端)运行。
diff --git a/backend/shared/Monitor.Measurement/Blocks/Bulk.cs b/backend/shared/MoShiro.Measurement/Blocks/Bulk.cs
similarity index 99%
rename from backend/shared/Monitor.Measurement/Blocks/Bulk.cs
rename to backend/shared/MoShiro.Measurement/Blocks/Bulk.cs
index 5fc0591..cc08f70 100644
--- a/backend/shared/Monitor.Measurement/Blocks/Bulk.cs
+++ b/backend/shared/MoShiro.Measurement/Blocks/Bulk.cs
@@ -1,7 +1,7 @@
using System.Net.Sockets;
-using Monitor.Protocol;
+using MoShiro.Protocol;
-namespace Monitor.Measurement;
+namespace MoShiro.Measurement;
/// 批量传输的收发循环(两端共用)。
internal static class BulkIo
diff --git a/backend/shared/Monitor.Measurement/Blocks/Echo.cs b/backend/shared/MoShiro.Measurement/Blocks/Echo.cs
similarity index 99%
rename from backend/shared/Monitor.Measurement/Blocks/Echo.cs
rename to backend/shared/MoShiro.Measurement/Blocks/Echo.cs
index 94c51b8..ef639db 100644
--- a/backend/shared/Monitor.Measurement/Blocks/Echo.cs
+++ b/backend/shared/MoShiro.Measurement/Blocks/Echo.cs
@@ -1,8 +1,8 @@
using System.Net;
using System.Net.Sockets;
-using Monitor.Protocol;
+using MoShiro.Protocol;
-namespace Monitor.Measurement;
+namespace MoShiro.Measurement;
///
/// 回显积木的行表(拨号方,行的主导方):发出时记 size、t1,回复到达时按序号回填 t4,到点把已经稳定的行切成列块。
diff --git a/backend/shared/Monitor.Measurement/Blocks/Session.cs b/backend/shared/MoShiro.Measurement/Blocks/Session.cs
similarity index 99%
rename from backend/shared/Monitor.Measurement/Blocks/Session.cs
rename to backend/shared/MoShiro.Measurement/Blocks/Session.cs
index 0e52380..18b96d8 100644
--- a/backend/shared/Monitor.Measurement/Blocks/Session.cs
+++ b/backend/shared/MoShiro.Measurement/Blocks/Session.cs
@@ -1,9 +1,9 @@
using System.Net.NetworkInformation;
using System.Net.Sockets;
using System.Security.Authentication;
-using Monitor.Protocol;
+using MoShiro.Protocol;
-namespace Monitor.Measurement;
+namespace MoShiro.Measurement;
/// 什么也不做的监听方:connect 的另一端就是 TCP 监听器本身(接受连接、认证失败就关闭),不需要积木,但需要占一个流编号。
public sealed class IdleListener : BlockBase
diff --git a/backend/shared/Monitor.Measurement/Blocks/Train.cs b/backend/shared/MoShiro.Measurement/Blocks/Train.cs
similarity index 99%
rename from backend/shared/Monitor.Measurement/Blocks/Train.cs
rename to backend/shared/MoShiro.Measurement/Blocks/Train.cs
index 33a1117..7cfadac 100644
--- a/backend/shared/Monitor.Measurement/Blocks/Train.cs
+++ b/backend/shared/MoShiro.Measurement/Blocks/Train.cs
@@ -1,8 +1,8 @@
using System.Diagnostics;
using System.Net;
-using Monitor.Protocol;
+using MoShiro.Protocol;
-namespace Monitor.Measurement;
+namespace MoShiro.Measurement;
///
/// 单向数据流(UDP train),监听方(Agent,行的主导方):按声明的码率均匀发包,发出的每个包 (seq, size, t_send) 记在按序号的记录里,
diff --git a/backend/shared/Monitor.Measurement/Core/Contracts.cs b/backend/shared/MoShiro.Measurement/Core/Contracts.cs
similarity index 99%
rename from backend/shared/Monitor.Measurement/Core/Contracts.cs
rename to backend/shared/MoShiro.Measurement/Core/Contracts.cs
index 9919324..1dea055 100644
--- a/backend/shared/Monitor.Measurement/Core/Contracts.cs
+++ b/backend/shared/MoShiro.Measurement/Core/Contracts.cs
@@ -1,9 +1,9 @@
using System.Net;
using System.Text.Json;
using Fleet.Core;
-using Monitor.Protocol;
+using MoShiro.Protocol;
-namespace Monitor.Measurement;
+namespace MoShiro.Measurement;
///
/// 数据面会话:session_id 和密钥(由点对点握手里的 ECDH 派生)。两端的数据面包都用它认证。
diff --git a/backend/shared/Monitor.Measurement/Core/MonoClock.cs b/backend/shared/MoShiro.Measurement/Core/MonoClock.cs
similarity index 97%
rename from backend/shared/Monitor.Measurement/Core/MonoClock.cs
rename to backend/shared/MoShiro.Measurement/Core/MonoClock.cs
index ca52868..a316445 100644
--- a/backend/shared/Monitor.Measurement/Core/MonoClock.cs
+++ b/backend/shared/MoShiro.Measurement/Core/MonoClock.cs
@@ -1,4 +1,4 @@
-namespace Monitor.Measurement;
+namespace MoShiro.Measurement;
/// 节点的单调时钟(微秒):t1…t4、t_send、t_recv 都用它;Probe 和 Agent 各自一个,块头里的时钟锚点把它对应到 UTC。
public sealed class MonoClock
diff --git a/backend/shared/Monitor.Measurement/Core/RowStore.cs b/backend/shared/MoShiro.Measurement/Core/RowStore.cs
similarity index 99%
rename from backend/shared/Monitor.Measurement/Core/RowStore.cs
rename to backend/shared/MoShiro.Measurement/Core/RowStore.cs
index 9160195..77845b2 100644
--- a/backend/shared/Monitor.Measurement/Core/RowStore.cs
+++ b/backend/shared/MoShiro.Measurement/Core/RowStore.cs
@@ -1,6 +1,6 @@
-using Monitor.Protocol;
+using MoShiro.Protocol;
-namespace Monitor.Measurement;
+namespace MoShiro.Measurement;
///
/// 一侧记录的行:只含这一侧拥有的列(见 ),按连接键(通常是 seq)索引的环形缓冲,
diff --git a/backend/shared/Monitor.Measurement/Core/RunningBlock.cs b/backend/shared/MoShiro.Measurement/Core/RunningBlock.cs
similarity index 98%
rename from backend/shared/Monitor.Measurement/Core/RunningBlock.cs
rename to backend/shared/MoShiro.Measurement/Core/RunningBlock.cs
index c246ba5..1ba7e7b 100644
--- a/backend/shared/Monitor.Measurement/Core/RunningBlock.cs
+++ b/backend/shared/MoShiro.Measurement/Core/RunningBlock.cs
@@ -1,4 +1,4 @@
-namespace Monitor.Measurement;
+namespace MoShiro.Measurement;
/// 一个运行中的积木:自己的取消令牌和后台任务。Probe 和 Agent 共用。
public sealed class RunningBlock : IDisposable
diff --git a/backend/shared/Monitor.Measurement/Execution/BudgetGuard.cs b/backend/shared/MoShiro.Measurement/Execution/BudgetGuard.cs
similarity index 99%
rename from backend/shared/Monitor.Measurement/Execution/BudgetGuard.cs
rename to backend/shared/MoShiro.Measurement/Execution/BudgetGuard.cs
index f01e5e5..add768e 100644
--- a/backend/shared/Monitor.Measurement/Execution/BudgetGuard.cs
+++ b/backend/shared/MoShiro.Measurement/Execution/BudgetGuard.cs
@@ -1,8 +1,8 @@
using System.Net;
using System.Text.Json;
-using Monitor.Protocol;
+using MoShiro.Protocol;
-namespace Monitor.Measurement;
+namespace MoShiro.Measurement;
/// 节点的本地硬上限(写在本机配置里,Backend 无法修改)。
public sealed class NodeLimits
diff --git a/backend/shared/Monitor.Measurement/Merging/ChunkFinalizer.cs b/backend/shared/MoShiro.Measurement/Merging/ChunkFinalizer.cs
similarity index 98%
rename from backend/shared/Monitor.Measurement/Merging/ChunkFinalizer.cs
rename to backend/shared/MoShiro.Measurement/Merging/ChunkFinalizer.cs
index c91de05..53379cb 100644
--- a/backend/shared/Monitor.Measurement/Merging/ChunkFinalizer.cs
+++ b/backend/shared/MoShiro.Measurement/Merging/ChunkFinalizer.cs
@@ -1,8 +1,8 @@
using System.Text.Json;
using Fleet.Core;
-using Monitor.Protocol;
+using MoShiro.Protocol;
-namespace Monitor.Measurement;
+namespace MoShiro.Measurement;
/// Agent 单调时钟(微秒)与 UTC(毫秒)的对应关系:块头里的时钟锚点。
public readonly record struct ClockAnchor(long AgentMonoUs, long UtcMs);
diff --git a/backend/shared/Monitor.Measurement/Merging/FragmentMerger.cs b/backend/shared/MoShiro.Measurement/Merging/FragmentMerger.cs
similarity index 96%
rename from backend/shared/Monitor.Measurement/Merging/FragmentMerger.cs
rename to backend/shared/MoShiro.Measurement/Merging/FragmentMerger.cs
index e029204..04653d0 100644
--- a/backend/shared/Monitor.Measurement/Merging/FragmentMerger.cs
+++ b/backend/shared/MoShiro.Measurement/Merging/FragmentMerger.cs
@@ -1,8 +1,8 @@
using System.Text.Json;
using Fleet.Core;
-using Monitor.Protocol;
+using MoShiro.Protocol;
-namespace Monitor.Measurement;
+namespace MoShiro.Measurement;
/// Agent 一侧为合并保留的按键记录(由正在运行的积木提供)。
public interface IRecordSource
@@ -29,7 +29,7 @@ public static class FragmentMerger
StreamSpec? streamSpec = spec.FindStream(stream.Name);
if (streamSpec is null)
{
- return Result>.Fail(MonitorErrors.ValidationFailed, $"stream {stream.Name} is not declared by {spec.Id}");
+ return Result>.Fail(MoShiroErrors.ValidationFailed, $"stream {stream.Name} is not declared by {spec.Id}");
}
Result merged = Join(streamSpec, stream, fragment.Header, records.Records(streamId, stream.Name));
@@ -71,7 +71,7 @@ public static class FragmentMerger
RawColumn? key = probe.Find(spec.Key);
if (key is null || probeColumns.Any(c => probe.Find(c.Name) is null))
{
- return Result.Fail(MonitorErrors.ValidationFailed, $"a fragment of stream {spec.Name} needs the columns {string.Join(", ", new[] { spec.Key }.Concat(probeColumns.Select(c => c.Name)))}");
+ return Result.Fail(MoShiroErrors.ValidationFailed, $"a fragment of stream {spec.Name} needs the columns {string.Join(", ", new[] { spec.Key }.Concat(probeColumns.Select(c => c.Name)))}");
}
return spec.Driver == Side.Probe ? JoinOnProbeRows(spec, probe, key, agent) : JoinOnAgentRows(spec, probe, key, header, agent);
@@ -118,7 +118,7 @@ public static class FragmentMerger
{
if (!TryGetRange(header, out uint from, out uint to))
{
- return Result.Fail(MonitorErrors.ValidationFailed, $"a fragment of stream {spec.Name} must declare its sequence range");
+ return Result.Fail(MoShiroErrors.ValidationFailed, $"a fragment of stream {spec.Name} must declare its sequence range");
}
// 行取自 Agent 的记录:范围内发出过的每一个包都有一行,Probe 没有报告到达的就是丢失
diff --git a/backend/shared/Monitor.Measurement/Monitor.Measurement.csproj b/backend/shared/MoShiro.Measurement/MoShiro.Measurement.csproj
similarity index 67%
rename from backend/shared/Monitor.Measurement/Monitor.Measurement.csproj
rename to backend/shared/MoShiro.Measurement/MoShiro.Measurement.csproj
index 8853475..baf3b8d 100644
--- a/backend/shared/Monitor.Measurement/Monitor.Measurement.csproj
+++ b/backend/shared/MoShiro.Measurement/MoShiro.Measurement.csproj
@@ -3,8 +3,8 @@
true
-
+
-
+
diff --git a/backend/shared/Monitor.Measurement/Net/Tcp.cs b/backend/shared/MoShiro.Measurement/Net/Tcp.cs
similarity index 99%
rename from backend/shared/Monitor.Measurement/Net/Tcp.cs
rename to backend/shared/MoShiro.Measurement/Net/Tcp.cs
index f0e6fe4..30adafb 100644
--- a/backend/shared/Monitor.Measurement/Net/Tcp.cs
+++ b/backend/shared/MoShiro.Measurement/Net/Tcp.cs
@@ -5,9 +5,9 @@ using System.Net.Sockets;
using System.Security.Authentication;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
-using Monitor.Protocol;
+using MoShiro.Protocol;
-namespace Monitor.Measurement;
+namespace MoShiro.Measurement;
/// 拨号方的一条数据面 TCP 连接(已经完成 TLS 和首帧认证)。
public sealed class TcpLink : IDisposable
diff --git a/backend/shared/Monitor.Measurement/Net/TcpInfo.cs b/backend/shared/MoShiro.Measurement/Net/TcpInfo.cs
similarity index 98%
rename from backend/shared/Monitor.Measurement/Net/TcpInfo.cs
rename to backend/shared/MoShiro.Measurement/Net/TcpInfo.cs
index d9a60d7..8a2be0c 100644
--- a/backend/shared/Monitor.Measurement/Net/TcpInfo.cs
+++ b/backend/shared/MoShiro.Measurement/Net/TcpInfo.cs
@@ -1,8 +1,8 @@
using System.Buffers.Binary;
using System.Net.Sockets;
-using Monitor.Protocol;
+using MoShiro.Protocol;
-namespace Monitor.Measurement;
+namespace MoShiro.Measurement;
/// 内核对一条 TCP 连接的采样(Linux TCP_INFO)。
public readonly record struct TcpInfoSample(long SrttUs, long RttVarUs, long Cwnd, long TotalRetrans, long SegsOut, long BytesAcked);
diff --git a/backend/shared/Monitor.Measurement/Net/UdpMux.cs b/backend/shared/MoShiro.Measurement/Net/UdpMux.cs
similarity index 99%
rename from backend/shared/Monitor.Measurement/Net/UdpMux.cs
rename to backend/shared/MoShiro.Measurement/Net/UdpMux.cs
index dc03456..9d036af 100644
--- a/backend/shared/Monitor.Measurement/Net/UdpMux.cs
+++ b/backend/shared/MoShiro.Measurement/Net/UdpMux.cs
@@ -2,9 +2,9 @@ using System.Collections.Concurrent;
using System.Net;
using System.Net.Sockets;
using Fleet.Core;
-using Monitor.Protocol;
+using MoShiro.Protocol;
-namespace Monitor.Measurement;
+namespace MoShiro.Measurement;
/// 一个通过校验的 UDP 包,交给按 stream_id 登记的处理函数。处理函数在接收循环里同步执行,不能阻塞。
public readonly ref struct UdpDelivery
diff --git a/backend/shared/Monitor.Measurement/Platform/PlatformDetector.cs b/backend/shared/MoShiro.Measurement/Platform/PlatformDetector.cs
similarity index 98%
rename from backend/shared/Monitor.Measurement/Platform/PlatformDetector.cs
rename to backend/shared/MoShiro.Measurement/Platform/PlatformDetector.cs
index b3e5dd4..39d4fd6 100644
--- a/backend/shared/Monitor.Measurement/Platform/PlatformDetector.cs
+++ b/backend/shared/MoShiro.Measurement/Platform/PlatformDetector.cs
@@ -1,7 +1,7 @@
using System.Runtime.InteropServices;
-using Monitor.Protocol;
+using MoShiro.Protocol;
-namespace Monitor.Measurement;
+namespace MoShiro.Measurement;
///
/// 读出本机的系统名和架构,只用于在面板上展示。故意只取粗粒度的信息:
diff --git a/backend/shared/Monitor.Measurement/Update/UpdateBridge.cs b/backend/shared/MoShiro.Measurement/Update/UpdateBridge.cs
similarity index 96%
rename from backend/shared/Monitor.Measurement/Update/UpdateBridge.cs
rename to backend/shared/MoShiro.Measurement/Update/UpdateBridge.cs
index 255268a..236088c 100644
--- a/backend/shared/Monitor.Measurement/Update/UpdateBridge.cs
+++ b/backend/shared/MoShiro.Measurement/Update/UpdateBridge.cs
@@ -1,12 +1,12 @@
using System.Text;
using System.Text.Json;
using Fleet.Core;
-using Monitor.Protocol;
+using MoShiro.Protocol;
-namespace Monitor.Measurement;
+namespace MoShiro.Measurement;
///
-/// 节点进程和宿主机更新器之间的文件交换(容器里 /etc/monitor,也就是数据目录):
+/// 节点进程和宿主机更新器之间的文件交换(容器里 /etc/moshiro,也就是数据目录):
/// 节点把面板发来的清单和签名写进 update/,把「更新」请求写成 update/apply.request;更新器验签并更新,状态由宿主更新器写在只读挂载的 update-status/status.json。
/// 节点进程不执行任何命令,也不信任清单的内容(验签在宿主机上)。没有安装更新器时目录写不了或没人读,调用只是返回 false。
///
@@ -88,7 +88,7 @@ public sealed class UpdateBridge
return null;
}
- return JsonSerializer.Deserialize(File.ReadAllBytes(_statusFile), MonitorJsonContext.Default.UpdateStatus);
+ return JsonSerializer.Deserialize(File.ReadAllBytes(_statusFile), MoShiroJsonContext.Default.UpdateStatus);
}
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or JsonException)
{
diff --git a/backend/shared/Monitor.Protocol/Catalog/KindSpec.cs b/backend/shared/MoShiro.Protocol/Catalog/KindSpec.cs
similarity index 99%
rename from backend/shared/Monitor.Protocol/Catalog/KindSpec.cs
rename to backend/shared/MoShiro.Protocol/Catalog/KindSpec.cs
index 7345228..01059f9 100644
--- a/backend/shared/Monitor.Protocol/Catalog/KindSpec.cs
+++ b/backend/shared/MoShiro.Protocol/Catalog/KindSpec.cs
@@ -1,4 +1,4 @@
-namespace Monitor.Protocol;
+namespace MoShiro.Protocol;
[Flags]
public enum Scope
diff --git a/backend/shared/Monitor.Protocol/Catalog/Kinds/Kinds.cs b/backend/shared/MoShiro.Protocol/Catalog/Kinds/Kinds.cs
similarity index 99%
rename from backend/shared/Monitor.Protocol/Catalog/Kinds/Kinds.cs
rename to backend/shared/MoShiro.Protocol/Catalog/Kinds/Kinds.cs
index d311e91..f89639a 100644
--- a/backend/shared/Monitor.Protocol/Catalog/Kinds/Kinds.cs
+++ b/backend/shared/MoShiro.Protocol/Catalog/Kinds/Kinds.cs
@@ -1,4 +1,4 @@
-namespace Monitor.Protocol;
+namespace MoShiro.Protocol;
///
/// Kind 目录。新增一种采集方法 = 在这里加一个静态字段并放进 ;
diff --git a/backend/shared/Monitor.Protocol/Catalog/ParamSpec.cs b/backend/shared/MoShiro.Protocol/Catalog/ParamSpec.cs
similarity index 99%
rename from backend/shared/Monitor.Protocol/Catalog/ParamSpec.cs
rename to backend/shared/MoShiro.Protocol/Catalog/ParamSpec.cs
index 0f415cd..133304f 100644
--- a/backend/shared/Monitor.Protocol/Catalog/ParamSpec.cs
+++ b/backend/shared/MoShiro.Protocol/Catalog/ParamSpec.cs
@@ -1,7 +1,7 @@
using System.Globalization;
using System.Text.Json;
-namespace Monitor.Protocol;
+namespace MoShiro.Protocol;
public enum ParamType
{
diff --git a/backend/shared/Monitor.Protocol/Ids/MonitorIds.cs b/backend/shared/MoShiro.Protocol/Ids/MonitorIds.cs
similarity index 98%
rename from backend/shared/Monitor.Protocol/Ids/MonitorIds.cs
rename to backend/shared/MoShiro.Protocol/Ids/MonitorIds.cs
index 2881993..2b9f68e 100644
--- a/backend/shared/Monitor.Protocol/Ids/MonitorIds.cs
+++ b/backend/shared/MoShiro.Protocol/Ids/MonitorIds.cs
@@ -1,7 +1,7 @@
using System.Text.Json.Serialization;
using Fleet.Core;
-namespace Monitor.Protocol;
+namespace MoShiro.Protocol;
[JsonConverter(typeof(ProbeIdJsonConverter))]
public readonly record struct ProbeId(string Value)
diff --git a/backend/shared/Monitor.Protocol/Monitor.Protocol.csproj b/backend/shared/MoShiro.Protocol/MoShiro.Protocol.csproj
similarity index 87%
rename from backend/shared/Monitor.Protocol/Monitor.Protocol.csproj
rename to backend/shared/MoShiro.Protocol/MoShiro.Protocol.csproj
index 1d2bc78..5eb7cd2 100644
--- a/backend/shared/Monitor.Protocol/Monitor.Protocol.csproj
+++ b/backend/shared/MoShiro.Protocol/MoShiro.Protocol.csproj
@@ -7,7 +7,7 @@
@@ -16,14 +16,14 @@
$(IntermediateOutputPath)BuildInfo.g.cs
-
+
-
-
-
+
+
+
diff --git a/backend/shared/Monitor.Protocol/MonitorErrors.cs b/backend/shared/MoShiro.Protocol/MonitorErrors.cs
similarity index 95%
rename from backend/shared/Monitor.Protocol/MonitorErrors.cs
rename to backend/shared/MoShiro.Protocol/MonitorErrors.cs
index 7de2b95..91c7259 100644
--- a/backend/shared/Monitor.Protocol/MonitorErrors.cs
+++ b/backend/shared/MoShiro.Protocol/MonitorErrors.cs
@@ -1,9 +1,9 @@
using Fleet.Core;
-namespace Monitor.Protocol;
+namespace MoShiro.Protocol;
-/// Monitor 的错误码(在 Fleet 错误码之上扩展)。REST、JSON-RPC、OpenAPI 共用同一份。
-public static class MonitorErrors
+/// MoShiro 的错误码(在 Fleet 错误码之上扩展)。REST、JSON-RPC、OpenAPI 共用同一份。
+public static class MoShiroErrors
{
public static readonly ErrorCode ValidationFailed = new("validation_failed");
public static readonly ErrorCode BudgetExceeded = new("budget_exceeded");
diff --git a/backend/shared/Monitor.Protocol/ProtocolLimits.cs b/backend/shared/MoShiro.Protocol/ProtocolLimits.cs
similarity index 75%
rename from backend/shared/Monitor.Protocol/ProtocolLimits.cs
rename to backend/shared/MoShiro.Protocol/ProtocolLimits.cs
index f227b86..90f3c86 100644
--- a/backend/shared/Monitor.Protocol/ProtocolLimits.cs
+++ b/backend/shared/MoShiro.Protocol/ProtocolLimits.cs
@@ -1,4 +1,4 @@
-namespace Monitor.Protocol;
+namespace MoShiro.Protocol;
public static class ProtocolVersion
{
@@ -25,8 +25,8 @@ public static class ProtocolLimits
public const long MaxLineBudgetBitsPerSecond = 100_000;
}
-/// 二进制通道号(0–15 属于 Fleet,Monitor 从 16 开始)。
-public static class MonitorChannels
+/// 二进制通道号(0–15 属于 Fleet,MoShiro 从 16 开始)。
+public static class MoShiroChannels
{
/// Agent → Backend:RawChunk(发件箱)。
public const byte RawChunk = 16;
@@ -35,9 +35,9 @@ public static class MonitorChannels
public const byte ColumnBlock = 17;
}
-public static class MonitorCapabilities
+public static class MoShiroCapabilities
{
- public const string Base = "monitor.v1";
- public const string KindsPrefix = "monitor.kinds:";
- public const string BlocksPrefix = "monitor.blocks:";
+ public const string Base = "moshiro.v1";
+ public const string KindsPrefix = "moshiro.kinds:";
+ public const string BlocksPrefix = "moshiro.blocks:";
}
diff --git a/backend/shared/Monitor.Protocol/Raw/Crc32c.cs b/backend/shared/MoShiro.Protocol/Raw/Crc32c.cs
similarity index 96%
rename from backend/shared/Monitor.Protocol/Raw/Crc32c.cs
rename to backend/shared/MoShiro.Protocol/Raw/Crc32c.cs
index 0a6d0f9..e18bf9e 100644
--- a/backend/shared/Monitor.Protocol/Raw/Crc32c.cs
+++ b/backend/shared/MoShiro.Protocol/Raw/Crc32c.cs
@@ -1,4 +1,4 @@
-namespace Monitor.Protocol;
+namespace MoShiro.Protocol;
/// CRC-32C(Castagnoli),RawChunk 的完整性校验。
public static class Crc32c
diff --git a/backend/shared/Monitor.Protocol/Raw/RawChunk.cs b/backend/shared/MoShiro.Protocol/Raw/RawChunk.cs
similarity index 99%
rename from backend/shared/Monitor.Protocol/Raw/RawChunk.cs
rename to backend/shared/MoShiro.Protocol/Raw/RawChunk.cs
index d6ae3d3..0255d66 100644
--- a/backend/shared/Monitor.Protocol/Raw/RawChunk.cs
+++ b/backend/shared/MoShiro.Protocol/Raw/RawChunk.cs
@@ -2,7 +2,7 @@ using System.Text.Json;
using System.Text.Json.Serialization;
using Fleet.Core;
-namespace Monitor.Protocol;
+namespace MoShiro.Protocol;
/// Agent 单调时钟与 UTC 的锚点,以及 Probe 时钟相对 Agent 时钟的偏移估计。
public sealed class ChunkClock
diff --git a/backend/shared/Monitor.Protocol/Raw/RawChunkCodec.cs b/backend/shared/MoShiro.Protocol/Raw/RawChunkCodec.cs
similarity index 97%
rename from backend/shared/Monitor.Protocol/Raw/RawChunkCodec.cs
rename to backend/shared/MoShiro.Protocol/Raw/RawChunkCodec.cs
index 00c5298..aaaca96 100644
--- a/backend/shared/Monitor.Protocol/Raw/RawChunkCodec.cs
+++ b/backend/shared/MoShiro.Protocol/Raw/RawChunkCodec.cs
@@ -3,18 +3,18 @@ using System.IO.Compression;
using System.Text.Json;
using Fleet.Core;
-namespace Monitor.Protocol;
+namespace MoShiro.Protocol;
///
/// RawChunk 的编解码(Probe、Agent、Backend、离线工具共用同一份代码)。
-/// 布局:"MNRC" | u8 container_version | u32 crc32c(压缩数据) | Brotli( u32 header_len | header JSON | 各列数据 )。
+/// 布局:"MSRC" | u8 container_version | u32 crc32c(压缩数据) | Brotli( u32 header_len | header JSON | 各列数据 )。
/// 列数据:可空列先写有效位图,再写有效值;plain 为无符号 varint(有符号类型用 zigzag),delta 为与上一个有效值之差的 zigzag varint。
///
public static class RawChunkCodec
{
private const int PrefixBytes = 4 + 1 + 4;
- private static ReadOnlySpan Magic => "MNRC"u8;
+ private static ReadOnlySpan Magic => "MSRC"u8;
/// 压缩之前的正文:u32 header_len | header JSON | 各列数据。布局变化时黄金字节测试会失败,提醒升级版本。
public static byte[] EncodeBody(RawChunk chunk)
@@ -40,7 +40,7 @@ public static class RawChunkCodec
header.Streams.Add(streamHeader);
}
- byte[] headerJson = JsonSerializer.SerializeToUtf8Bytes(header, MonitorJsonContext.Default.RawChunkHeader);
+ byte[] headerJson = JsonSerializer.SerializeToUtf8Bytes(header, MoShiroJsonContext.Default.RawChunkHeader);
using var body = new MemoryStream();
Span length = stackalloc byte[4];
@@ -114,7 +114,7 @@ public static class RawChunkCodec
RawChunkHeader? header;
try
{
- header = JsonSerializer.Deserialize(plain.AsSpan(4, (int)headerLength), MonitorJsonContext.Default.RawChunkHeader);
+ header = JsonSerializer.Deserialize(plain.AsSpan(4, (int)headerLength), MoShiroJsonContext.Default.RawChunkHeader);
}
catch (JsonException)
{
@@ -159,7 +159,7 @@ public static class RawChunkCodec
}
private static Result Corrupt(string message) =>
- Result.Fail(MonitorErrors.RawCorrupt, message);
+ Result.Fail(MoShiroErrors.RawCorrupt, message);
private static byte[]? Inflate(ReadOnlySpan payload)
{
diff --git a/backend/shared/Monitor.Protocol/Raw/StreamBuilder.cs b/backend/shared/MoShiro.Protocol/Raw/StreamBuilder.cs
similarity index 98%
rename from backend/shared/Monitor.Protocol/Raw/StreamBuilder.cs
rename to backend/shared/MoShiro.Protocol/Raw/StreamBuilder.cs
index 65a5d38..4c2ec45 100644
--- a/backend/shared/Monitor.Protocol/Raw/StreamBuilder.cs
+++ b/backend/shared/MoShiro.Protocol/Raw/StreamBuilder.cs
@@ -1,4 +1,4 @@
-namespace Monitor.Protocol;
+namespace MoShiro.Protocol;
/// 按 逐行构造一个 (用于测试、模拟器和离线工具,不用于节点热路径)。
public sealed class StreamBuilder
diff --git a/backend/shared/Monitor.Protocol/Rpc/MonitorRpc.cs b/backend/shared/MoShiro.Protocol/Rpc/MonitorRpc.cs
similarity index 94%
rename from backend/shared/Monitor.Protocol/Rpc/MonitorRpc.cs
rename to backend/shared/MoShiro.Protocol/Rpc/MonitorRpc.cs
index d5228e7..83864cc 100644
--- a/backend/shared/Monitor.Protocol/Rpc/MonitorRpc.cs
+++ b/backend/shared/MoShiro.Protocol/Rpc/MonitorRpc.cs
@@ -2,25 +2,25 @@ using System.Text.Json;
using System.Text.Json.Serialization;
using Fleet.Core;
-namespace Monitor.Protocol;
+namespace MoShiro.Protocol;
-/// monitor.* 方法名。新增方法 = 在这里定义名称和 params/result,再在组装处加一行 .On(...)。
-public static class MonitorMethods
+/// moshiro.* 方法名。新增方法 = 在这里定义名称和 params/result,再在组装处加一行 .On(...)。
+public static class MoShiroMethods
{
- public const string TestRun = "monitor.test.run";
- public const string TestCancel = "monitor.test.cancel";
- public const string ProbeDisconnect = "monitor.probe.disconnect";
- public const string TestStatus = "monitor.test.status";
- public const string Event = "monitor.event";
- public const string Host = "monitor.host";
- public const string UpdateOffer = "monitor.update.offer";
- public const string UpdateApply = "monitor.update.apply";
+ public const string TestRun = "moshiro.test.run";
+ public const string TestCancel = "moshiro.test.cancel";
+ public const string ProbeDisconnect = "moshiro.probe.disconnect";
+ public const string TestStatus = "moshiro.test.status";
+ public const string Event = "moshiro.event";
+ public const string Host = "moshiro.host";
+ public const string UpdateOffer = "moshiro.update.offer";
+ public const string UpdateApply = "moshiro.update.apply";
// Probe ↔ Agent(点对点会话)
- public const string Clock = "monitor.clock";
- public const string TestPhase = "monitor.test.phase";
- public const string TestPhaseEnd = "monitor.test.phase_end";
- public const string TestAbort = "monitor.test.abort";
+ public const string Clock = "moshiro.clock";
+ public const string TestPhase = "moshiro.test.phase";
+ public const string TestPhaseEnd = "moshiro.test.phase_end";
+ public const string TestAbort = "moshiro.test.abort";
}
public static class AgentEventKinds
@@ -159,7 +159,7 @@ public sealed class ProbeAgentList
public List Agents { get; set; } = [];
}
-/// 注册元数据(Monitor 定义,经 Fleet 的 meta 字段带上来)。
+/// 注册元数据(MoShiro 定义,经 Fleet 的 meta 字段带上来)。
public sealed class AgentEnrollMeta
{
[JsonPropertyName("probe_tcp_port")]
@@ -220,7 +220,7 @@ public sealed class PlatformInfo
}
///
-/// 面板给节点的更新清单(monitor.update.offer):manifest 是发布清单的原始文本,signature 是 base64 的签名。
+/// 面板给节点的更新清单(moshiro.update.offer):manifest 是发布清单的原始文本,signature 是 base64 的签名。
/// 节点只是把它们原样放进数据目录;验签、拉取、重启都由宿主机上的更新器完成(节点进程不执行任何命令,也不信任清单的内容)。
///
public sealed class UpdateOfferParams
@@ -436,7 +436,7 @@ public sealed class LineTaskSet
public List TcpPorts { get; set; } = [];
}
-/// monitor.clock:Probe 用它估计与 Agent 单调时钟的偏移(对称往返假设)。
+/// moshiro.clock:Probe 用它估计与 Agent 单调时钟的偏移(对称往返假设)。
public sealed class ClockParams
{
[JsonPropertyName("probe_mono_us")]
@@ -543,4 +543,4 @@ public static class FragmentKeys
[JsonSerializable(typeof(AgentHelloMeta))]
[JsonSerializable(typeof(AgentHeartbeatExtra))]
[JsonSerializable(typeof(RawChunkHeader))]
-public sealed partial class MonitorJsonContext : JsonSerializerContext;
+public sealed partial class MoShiroJsonContext : JsonSerializerContext;
diff --git a/backend/shared/Monitor.Protocol/Tasks/TaskSet.cs b/backend/shared/MoShiro.Protocol/Tasks/TaskSet.cs
similarity index 94%
rename from backend/shared/Monitor.Protocol/Tasks/TaskSet.cs
rename to backend/shared/MoShiro.Protocol/Tasks/TaskSet.cs
index 2c320a5..88771f4 100644
--- a/backend/shared/Monitor.Protocol/Tasks/TaskSet.cs
+++ b/backend/shared/MoShiro.Protocol/Tasks/TaskSet.cs
@@ -3,7 +3,7 @@ using System.Text.Json;
using System.Text.Json.Serialization;
using Fleet.Core;
-namespace Monitor.Protocol;
+namespace MoShiro.Protocol;
/// Task = { id, scope, kind, target, params, schedule, enabled }。参数已经按 ParamSpec 校验并补全默认值。
public sealed class TaskSpec
@@ -79,9 +79,9 @@ public static class TaskSchedule
{
return minutes >= 60
? Result.Ok(minutes)
- : Result.Fail(MonitorErrors.ValidationFailed, "every:N requires N >= 60 minutes");
+ : Result.Fail(MoShiroErrors.ValidationFailed, "every:N requires N >= 60 minutes");
}
- return Result.Fail(MonitorErrors.ValidationFailed, "schedule must be continuous, once or every:");
+ return Result.Fail(MoShiroErrors.ValidationFailed, "schedule must be continuous, once or every:");
}
}
diff --git a/backend/shared/Monitor.Protocol/Wire/TcpWire.cs b/backend/shared/MoShiro.Protocol/Wire/TcpWire.cs
similarity index 99%
rename from backend/shared/Monitor.Protocol/Wire/TcpWire.cs
rename to backend/shared/MoShiro.Protocol/Wire/TcpWire.cs
index 6ca01af..b03a5b3 100644
--- a/backend/shared/Monitor.Protocol/Wire/TcpWire.cs
+++ b/backend/shared/MoShiro.Protocol/Wire/TcpWire.cs
@@ -2,7 +2,7 @@ using System.Buffers.Binary;
using System.Security.Cryptography;
using Fleet.Core;
-namespace Monitor.Protocol;
+namespace MoShiro.Protocol;
///
/// 数据面的 TCP 连接(Fleet 之外的线格式)。连接都由 Probe 发起;TLS 是可选的(ClientHello 以 0x16 开头,
diff --git a/backend/shared/Monitor.Protocol/Wire/UdpPacket.cs b/backend/shared/MoShiro.Protocol/Wire/UdpPacket.cs
similarity index 99%
rename from backend/shared/Monitor.Protocol/Wire/UdpPacket.cs
rename to backend/shared/MoShiro.Protocol/Wire/UdpPacket.cs
index 2827ba6..737b57c 100644
--- a/backend/shared/Monitor.Protocol/Wire/UdpPacket.cs
+++ b/backend/shared/MoShiro.Protocol/Wire/UdpPacket.cs
@@ -1,7 +1,7 @@
using System.Buffers.Binary;
using System.Security.Cryptography;
-namespace Monitor.Protocol;
+namespace MoShiro.Protocol;
public enum UdpPacketType : byte
{
diff --git a/backend/shared/tests/Monitor.Measurement.Tests/MeasurementTests.cs b/backend/shared/tests/MoShiro.Measurement.Tests/MeasurementTests.cs
similarity index 99%
rename from backend/shared/tests/Monitor.Measurement.Tests/MeasurementTests.cs
rename to backend/shared/tests/MoShiro.Measurement.Tests/MeasurementTests.cs
index f0875a9..1912f09 100644
--- a/backend/shared/tests/Monitor.Measurement.Tests/MeasurementTests.cs
+++ b/backend/shared/tests/MoShiro.Measurement.Tests/MeasurementTests.cs
@@ -1,8 +1,8 @@
using System.Text.Json;
using Fleet.Core;
-using Monitor.Protocol;
+using MoShiro.Protocol;
-namespace Monitor.Measurement.Tests;
+namespace MoShiro.Measurement.Tests;
public sealed class MeasurementTests
{
diff --git a/backend/shared/tests/Monitor.Measurement.Tests/Monitor.Measurement.Tests.csproj b/backend/shared/tests/MoShiro.Measurement.Tests/MoShiro.Measurement.Tests.csproj
similarity index 82%
rename from backend/shared/tests/Monitor.Measurement.Tests/Monitor.Measurement.Tests.csproj
rename to backend/shared/tests/MoShiro.Measurement.Tests/MoShiro.Measurement.Tests.csproj
index e067df9..c8f64bd 100644
--- a/backend/shared/tests/Monitor.Measurement.Tests/Monitor.Measurement.Tests.csproj
+++ b/backend/shared/tests/MoShiro.Measurement.Tests/MoShiro.Measurement.Tests.csproj
@@ -5,7 +5,7 @@
-
+
diff --git a/backend/shared/tests/Monitor.Measurement.Tests/PlatformDetectorTests.cs b/backend/shared/tests/MoShiro.Measurement.Tests/PlatformDetectorTests.cs
similarity index 97%
rename from backend/shared/tests/Monitor.Measurement.Tests/PlatformDetectorTests.cs
rename to backend/shared/tests/MoShiro.Measurement.Tests/PlatformDetectorTests.cs
index 365c7df..ddb2575 100644
--- a/backend/shared/tests/Monitor.Measurement.Tests/PlatformDetectorTests.cs
+++ b/backend/shared/tests/MoShiro.Measurement.Tests/PlatformDetectorTests.cs
@@ -1,4 +1,4 @@
-namespace Monitor.Measurement.Tests;
+namespace MoShiro.Measurement.Tests;
public sealed class PlatformDetectorTests
{
diff --git a/backend/shared/tests/Monitor.Protocol.Tests/CatalogTests.cs b/backend/shared/tests/MoShiro.Protocol.Tests/CatalogTests.cs
similarity index 93%
rename from backend/shared/tests/Monitor.Protocol.Tests/CatalogTests.cs
rename to backend/shared/tests/MoShiro.Protocol.Tests/CatalogTests.cs
index 2a98537..56cc60e 100644
--- a/backend/shared/tests/Monitor.Protocol.Tests/CatalogTests.cs
+++ b/backend/shared/tests/MoShiro.Protocol.Tests/CatalogTests.cs
@@ -1,8 +1,8 @@
using System.Text.Json;
using Fleet.Core;
-using Monitor.Protocol;
+using MoShiro.Protocol;
-namespace Monitor.Protocol.Tests;
+namespace MoShiro.Protocol.Tests;
public sealed class CatalogTests
{
@@ -101,8 +101,8 @@ public sealed class CatalogTests
Tasks = [new TaskSpec { Id = new TaskId("tsk_1"), Kind = "udp_echo", Params = new Dictionary { ["rate_hz"] = Json("10") } }],
Peers = [new PeerSpec { ProbeId = new ProbeId("prb_1"), PublicKey = "AAAA" }],
};
- string text = JsonSerializer.Serialize(set, MonitorJsonContext.Default.TaskSet);
- TaskSet back = JsonSerializer.Deserialize(text, MonitorJsonContext.Default.TaskSet)!;
+ string text = JsonSerializer.Serialize(set, MoShiroJsonContext.Default.TaskSet);
+ TaskSet back = JsonSerializer.Deserialize(text, MoShiroJsonContext.Default.TaskSet)!;
Assert.Contains("\"id\":\"tsk_1\"", text);
Assert.Equal(7, back.Version);
@@ -114,7 +114,7 @@ public sealed class CatalogTests
[Fact]
public void AgentEnrollMeta_ToleratesUnknownFields_AndKeepsDefaults()
{
- AgentEnrollMeta meta = JsonSerializer.Deserialize("{\"kinds\":[\"udp_echo\"],\"future\":1}", MonitorJsonContext.Default.AgentEnrollMeta)!;
+ AgentEnrollMeta meta = JsonSerializer.Deserialize("{\"kinds\":[\"udp_echo\"],\"future\":1}", MoShiroJsonContext.Default.AgentEnrollMeta)!;
Assert.Equal(7443, meta.ProbeTcpPort);
Assert.Equal(["udp_echo"], meta.Kinds);
}
@@ -122,7 +122,7 @@ public sealed class CatalogTests
[Fact]
public void ErrorCodes_AreSnakeCase()
{
- foreach (System.Reflection.FieldInfo field in typeof(MonitorErrors).GetFields())
+ foreach (System.Reflection.FieldInfo field in typeof(MoShiroErrors).GetFields())
{
string value = ((ErrorCode)field.GetValue(null)!).Value;
Assert.Matches("^[a-z]+(_[a-z]+)*$", value);
diff --git a/backend/shared/tests/Monitor.Protocol.Tests/Monitor.Protocol.Tests.csproj b/backend/shared/tests/MoShiro.Protocol.Tests/MoShiro.Protocol.Tests.csproj
similarity index 65%
rename from backend/shared/tests/Monitor.Protocol.Tests/Monitor.Protocol.Tests.csproj
rename to backend/shared/tests/MoShiro.Protocol.Tests/MoShiro.Protocol.Tests.csproj
index 644ddc0..c7bb997 100644
--- a/backend/shared/tests/Monitor.Protocol.Tests/Monitor.Protocol.Tests.csproj
+++ b/backend/shared/tests/MoShiro.Protocol.Tests/MoShiro.Protocol.Tests.csproj
@@ -5,8 +5,8 @@
-
-
+
+
diff --git a/backend/shared/tests/Monitor.Protocol.Tests/RawChunkCodecTests.cs b/backend/shared/tests/MoShiro.Protocol.Tests/RawChunkCodecTests.cs
similarity index 97%
rename from backend/shared/tests/Monitor.Protocol.Tests/RawChunkCodecTests.cs
rename to backend/shared/tests/MoShiro.Protocol.Tests/RawChunkCodecTests.cs
index 6d65147..1f659ec 100644
--- a/backend/shared/tests/Monitor.Protocol.Tests/RawChunkCodecTests.cs
+++ b/backend/shared/tests/MoShiro.Protocol.Tests/RawChunkCodecTests.cs
@@ -1,10 +1,10 @@
using System.Buffers.Binary;
using System.IO.Compression;
using Fleet.Core;
-using Monitor.Protocol;
-using Monitor.TestSupport;
+using MoShiro.Protocol;
+using MoShiro.TestSupport;
-namespace Monitor.Protocol.Tests;
+namespace MoShiro.Protocol.Tests;
public sealed class RawChunkCodecTests
{
@@ -103,7 +103,7 @@ public sealed class RawChunkCodecTests
byte[] badCrc = (byte[])good.Clone();
badCrc[^1] ^= 0xFF;
- Assert.Equal(MonitorErrors.RawCorrupt, RawChunkCodec.Decode(badMagic).Error.Code);
+ Assert.Equal(MoShiroErrors.RawCorrupt, RawChunkCodec.Decode(badMagic).Error.Code);
Assert.Contains("version", RawChunkCodec.Decode(badVersion).Error.Message);
Assert.Contains("crc", RawChunkCodec.Decode(badCrc).Error.Message);
Assert.False(RawChunkCodec.Decode(good.AsSpan(0, good.Length / 2)).IsSuccess);
@@ -190,7 +190,7 @@ public sealed class RawChunkCodecTests
private static byte[] Wrap(byte[] payload)
{
byte[] result = new byte[9 + payload.Length];
- "MNRC"u8.CopyTo(result);
+ "MSRC"u8.CopyTo(result);
result[4] = ProtocolVersion.Container;
BinaryPrimitives.WriteUInt32LittleEndian(result.AsSpan(5), Crc32c.Compute(payload));
payload.CopyTo(result, 9);
diff --git a/backend/src/Monitor.Backend.Analysis/Accumulators/Accumulator.cs b/backend/src/MoShiro.Backend.Analysis/Accumulators/Accumulator.cs
similarity index 99%
rename from backend/src/Monitor.Backend.Analysis/Accumulators/Accumulator.cs
rename to backend/src/MoShiro.Backend.Analysis/Accumulators/Accumulator.cs
index 06077e3..197ae00 100644
--- a/backend/src/Monitor.Backend.Analysis/Accumulators/Accumulator.cs
+++ b/backend/src/MoShiro.Backend.Analysis/Accumulators/Accumulator.cs
@@ -1,4 +1,4 @@
-namespace Monitor.Backend.Analysis;
+namespace MoShiro.Backend.Analysis;
public enum AccKind : byte
{
diff --git a/backend/src/Monitor.Backend.Analysis/Accumulators/AccumulatorCodec.cs b/backend/src/MoShiro.Backend.Analysis/Accumulators/AccumulatorCodec.cs
similarity index 99%
rename from backend/src/Monitor.Backend.Analysis/Accumulators/AccumulatorCodec.cs
rename to backend/src/MoShiro.Backend.Analysis/Accumulators/AccumulatorCodec.cs
index b0c987a..81af219 100644
--- a/backend/src/Monitor.Backend.Analysis/Accumulators/AccumulatorCodec.cs
+++ b/backend/src/MoShiro.Backend.Analysis/Accumulators/AccumulatorCodec.cs
@@ -2,7 +2,7 @@ using System.Buffers.Binary;
using System.Text;
using Fleet.Core;
-namespace Monitor.Backend.Analysis;
+namespace MoShiro.Backend.Analysis;
/// 一个时间桶里所有指标的累加器:指标 id → 累加器。
public sealed class MetricSet
diff --git a/backend/src/Monitor.Backend.Analysis/Accumulators/HistogramAcc.cs b/backend/src/MoShiro.Backend.Analysis/Accumulators/HistogramAcc.cs
similarity index 99%
rename from backend/src/Monitor.Backend.Analysis/Accumulators/HistogramAcc.cs
rename to backend/src/MoShiro.Backend.Analysis/Accumulators/HistogramAcc.cs
index 4f58669..3027934 100644
--- a/backend/src/Monitor.Backend.Analysis/Accumulators/HistogramAcc.cs
+++ b/backend/src/MoShiro.Backend.Analysis/Accumulators/HistogramAcc.cs
@@ -1,4 +1,4 @@
-namespace Monitor.Backend.Analysis;
+namespace MoShiro.Backend.Analysis;
///
/// 固定对数桶直方图:100 µs ~ 30 s,每 2 倍 8 个桶(相对误差 ≤ 4.5%)。
diff --git a/backend/src/Monitor.Backend.Analysis/Clock/ClockDriftFit.cs b/backend/src/MoShiro.Backend.Analysis/Clock/ClockDriftFit.cs
similarity index 98%
rename from backend/src/Monitor.Backend.Analysis/Clock/ClockDriftFit.cs
rename to backend/src/MoShiro.Backend.Analysis/Clock/ClockDriftFit.cs
index 838ffac..7952041 100644
--- a/backend/src/Monitor.Backend.Analysis/Clock/ClockDriftFit.cs
+++ b/backend/src/MoShiro.Backend.Analysis/Clock/ClockDriftFit.cs
@@ -1,4 +1,4 @@
-namespace Monitor.Backend.Analysis;
+namespace MoShiro.Backend.Analysis;
///
/// 估计两端的时钟偏移和线性漂移:单向时延 x(t) = 偏移 + 漂移·t + 真实的时延变化。
diff --git a/backend/src/Monitor.Backend.Analysis/Engine/ChangePoint.cs b/backend/src/MoShiro.Backend.Analysis/Engine/ChangePoint.cs
similarity index 98%
rename from backend/src/Monitor.Backend.Analysis/Engine/ChangePoint.cs
rename to backend/src/MoShiro.Backend.Analysis/Engine/ChangePoint.cs
index e5e3e67..b061bf9 100644
--- a/backend/src/Monitor.Backend.Analysis/Engine/ChangePoint.cs
+++ b/backend/src/MoShiro.Backend.Analysis/Engine/ChangePoint.cs
@@ -1,4 +1,4 @@
-namespace Monitor.Backend.Analysis;
+namespace MoShiro.Backend.Analysis;
/// 变点检测(均值漂移):找到使前后两段均值差最显著的位置,用来判断 QoS 从什么时候开始限速。
public static class ChangePoint
diff --git a/backend/src/Monitor.Backend.Analysis/Engine/ChunkView.cs b/backend/src/MoShiro.Backend.Analysis/Engine/ChunkView.cs
similarity index 95%
rename from backend/src/Monitor.Backend.Analysis/Engine/ChunkView.cs
rename to backend/src/MoShiro.Backend.Analysis/Engine/ChunkView.cs
index ad7d536..3208a72 100644
--- a/backend/src/Monitor.Backend.Analysis/Engine/ChunkView.cs
+++ b/backend/src/MoShiro.Backend.Analysis/Engine/ChunkView.cs
@@ -1,7 +1,7 @@
using System.Text.Json;
-using Monitor.Protocol;
+using MoShiro.Protocol;
-namespace Monitor.Backend.Analysis;
+namespace MoShiro.Backend.Analysis;
/// 算子把观测值交给这里;窗口评估器负责按时间分桶。
public interface IObservationSink
diff --git a/backend/src/Monitor.Backend.Analysis/Engine/MetricDef.cs b/backend/src/MoShiro.Backend.Analysis/Engine/MetricDef.cs
similarity index 99%
rename from backend/src/Monitor.Backend.Analysis/Engine/MetricDef.cs
rename to backend/src/MoShiro.Backend.Analysis/Engine/MetricDef.cs
index d257f0e..1a60b6a 100644
--- a/backend/src/Monitor.Backend.Analysis/Engine/MetricDef.cs
+++ b/backend/src/MoShiro.Backend.Analysis/Engine/MetricDef.cs
@@ -1,8 +1,8 @@
using System.Security.Cryptography;
using System.Text;
-using Monitor.Protocol;
+using MoShiro.Protocol;
-namespace Monitor.Backend.Analysis;
+namespace MoShiro.Backend.Analysis;
public enum Unit
{
diff --git a/backend/src/Monitor.Backend.Analysis/Engine/TestEvaluator.cs b/backend/src/MoShiro.Backend.Analysis/Engine/TestEvaluator.cs
similarity index 99%
rename from backend/src/Monitor.Backend.Analysis/Engine/TestEvaluator.cs
rename to backend/src/MoShiro.Backend.Analysis/Engine/TestEvaluator.cs
index 14fede2..5988e98 100644
--- a/backend/src/Monitor.Backend.Analysis/Engine/TestEvaluator.cs
+++ b/backend/src/MoShiro.Backend.Analysis/Engine/TestEvaluator.cs
@@ -1,7 +1,7 @@
using System.Text.Json;
-using Monitor.Protocol;
+using MoShiro.Protocol;
-namespace Monitor.Backend.Analysis;
+namespace MoShiro.Backend.Analysis;
public sealed class TestStepResult
{
diff --git a/backend/src/Monitor.Backend.Analysis/Engine/WindowEvaluator.cs b/backend/src/MoShiro.Backend.Analysis/Engine/WindowEvaluator.cs
similarity index 97%
rename from backend/src/Monitor.Backend.Analysis/Engine/WindowEvaluator.cs
rename to backend/src/MoShiro.Backend.Analysis/Engine/WindowEvaluator.cs
index d6f41b0..2b50fa8 100644
--- a/backend/src/Monitor.Backend.Analysis/Engine/WindowEvaluator.cs
+++ b/backend/src/MoShiro.Backend.Analysis/Engine/WindowEvaluator.cs
@@ -1,6 +1,6 @@
-using Monitor.Protocol;
+using MoShiro.Protocol;
-namespace Monitor.Backend.Analysis;
+namespace MoShiro.Backend.Analysis;
///
/// 把原始块按时间分桶算成累加器。流式路径(1s 桶)和持久路径(分钟窗口)调用同一份代码,
diff --git a/backend/src/Monitor.Backend.Analysis/Metrics/LinkMetrics.cs b/backend/src/MoShiro.Backend.Analysis/Metrics/LinkMetrics.cs
similarity index 98%
rename from backend/src/Monitor.Backend.Analysis/Metrics/LinkMetrics.cs
rename to backend/src/MoShiro.Backend.Analysis/Metrics/LinkMetrics.cs
index d76d8b0..090686e 100644
--- a/backend/src/Monitor.Backend.Analysis/Metrics/LinkMetrics.cs
+++ b/backend/src/MoShiro.Backend.Analysis/Metrics/LinkMetrics.cs
@@ -1,4 +1,4 @@
-namespace Monitor.Backend.Analysis;
+namespace MoShiro.Backend.Analysis;
/// 线路基础指标(udp_echo / icmp_echo 的回显流)。新增指标 = 加一行声明。
public static class LinkMetrics
diff --git a/backend/src/Monitor.Backend.Analysis/Metrics/MetricRegistry.cs b/backend/src/MoShiro.Backend.Analysis/Metrics/MetricRegistry.cs
similarity index 99%
rename from backend/src/Monitor.Backend.Analysis/Metrics/MetricRegistry.cs
rename to backend/src/MoShiro.Backend.Analysis/Metrics/MetricRegistry.cs
index 140bd8a..e332a84 100644
--- a/backend/src/Monitor.Backend.Analysis/Metrics/MetricRegistry.cs
+++ b/backend/src/MoShiro.Backend.Analysis/Metrics/MetricRegistry.cs
@@ -1,4 +1,4 @@
-namespace Monitor.Backend.Analysis;
+namespace MoShiro.Backend.Analysis;
public sealed record PresetDef(string Id, string Label, IReadOnlyList MetricIds);
diff --git a/backend/src/Monitor.Backend.Analysis/Metrics/SessionMetrics.cs b/backend/src/MoShiro.Backend.Analysis/Metrics/SessionMetrics.cs
similarity index 98%
rename from backend/src/Monitor.Backend.Analysis/Metrics/SessionMetrics.cs
rename to backend/src/MoShiro.Backend.Analysis/Metrics/SessionMetrics.cs
index 0a164a2..6f5acbb 100644
--- a/backend/src/Monitor.Backend.Analysis/Metrics/SessionMetrics.cs
+++ b/backend/src/MoShiro.Backend.Analysis/Metrics/SessionMetrics.cs
@@ -1,4 +1,4 @@
-namespace Monitor.Backend.Analysis;
+namespace MoShiro.Backend.Analysis;
/// 连接建立、长连接、UDP 压测(udp_train)的指标。
public static class SessionMetrics
diff --git a/backend/src/Monitor.Backend.Analysis/Metrics/TcpMetrics.cs b/backend/src/MoShiro.Backend.Analysis/Metrics/TcpMetrics.cs
similarity index 98%
rename from backend/src/Monitor.Backend.Analysis/Metrics/TcpMetrics.cs
rename to backend/src/MoShiro.Backend.Analysis/Metrics/TcpMetrics.cs
index 83851a2..a4759f1 100644
--- a/backend/src/Monitor.Backend.Analysis/Metrics/TcpMetrics.cs
+++ b/backend/src/MoShiro.Backend.Analysis/Metrics/TcpMetrics.cs
@@ -1,4 +1,4 @@
-namespace Monitor.Backend.Analysis;
+namespace MoShiro.Backend.Analysis;
/// TCP 指标:回显的 RTT 与卡顿、内核采样的重传、批量传输的吞吐。
public static class TcpMetrics
diff --git a/backend/src/Monitor.Backend.Analysis/Monitor.Backend.Analysis.csproj b/backend/src/MoShiro.Backend.Analysis/MoShiro.Backend.Analysis.csproj
similarity index 63%
rename from backend/src/Monitor.Backend.Analysis/Monitor.Backend.Analysis.csproj
rename to backend/src/MoShiro.Backend.Analysis/MoShiro.Backend.Analysis.csproj
index a546806..b2d12ee 100644
--- a/backend/src/Monitor.Backend.Analysis/Monitor.Backend.Analysis.csproj
+++ b/backend/src/MoShiro.Backend.Analysis/MoShiro.Backend.Analysis.csproj
@@ -3,6 +3,6 @@
true
-
+
diff --git a/backend/src/Monitor.Backend.Analysis/Models/Models.cs b/backend/src/MoShiro.Backend.Analysis/Models/Models.cs
similarity index 99%
rename from backend/src/Monitor.Backend.Analysis/Models/Models.cs
rename to backend/src/MoShiro.Backend.Analysis/Models/Models.cs
index 506b574..aeb9825 100644
--- a/backend/src/Monitor.Backend.Analysis/Models/Models.cs
+++ b/backend/src/MoShiro.Backend.Analysis/Models/Models.cs
@@ -1,4 +1,4 @@
-namespace Monitor.Backend.Analysis;
+namespace MoShiro.Backend.Analysis;
/// 线路基础质量:RTT、丢包、抖动、连续丢包。
public sealed class BaseModel : ServiceModelBase
diff --git a/backend/src/Monitor.Backend.Analysis/Models/ServiceModel.cs b/backend/src/MoShiro.Backend.Analysis/Models/ServiceModel.cs
similarity index 99%
rename from backend/src/Monitor.Backend.Analysis/Models/ServiceModel.cs
rename to backend/src/MoShiro.Backend.Analysis/Models/ServiceModel.cs
index d37b2b7..843b318 100644
--- a/backend/src/Monitor.Backend.Analysis/Models/ServiceModel.cs
+++ b/backend/src/MoShiro.Backend.Analysis/Models/ServiceModel.cs
@@ -1,4 +1,4 @@
-namespace Monitor.Backend.Analysis;
+namespace MoShiro.Backend.Analysis;
/// 模型的输入:一个时间段内的导出值(例如 rtt.p95)。没有数据的指标不存在。
public sealed class MetricView
diff --git a/backend/src/Monitor.Backend.Analysis/Ops/EchoOps.cs b/backend/src/MoShiro.Backend.Analysis/Ops/EchoOps.cs
similarity index 99%
rename from backend/src/Monitor.Backend.Analysis/Ops/EchoOps.cs
rename to backend/src/MoShiro.Backend.Analysis/Ops/EchoOps.cs
index 7ac94c4..f160ef9 100644
--- a/backend/src/Monitor.Backend.Analysis/Ops/EchoOps.cs
+++ b/backend/src/MoShiro.Backend.Analysis/Ops/EchoOps.cs
@@ -1,6 +1,6 @@
-using Monitor.Protocol;
+using MoShiro.Protocol;
-namespace Monitor.Backend.Analysis;
+namespace MoShiro.Backend.Analysis;
public enum Dir
{
diff --git a/backend/src/Monitor.Backend.Analysis/Ops/Ops.cs b/backend/src/MoShiro.Backend.Analysis/Ops/Ops.cs
similarity index 98%
rename from backend/src/Monitor.Backend.Analysis/Ops/Ops.cs
rename to backend/src/MoShiro.Backend.Analysis/Ops/Ops.cs
index 4ee101d..ab9ecd1 100644
--- a/backend/src/Monitor.Backend.Analysis/Ops/Ops.cs
+++ b/backend/src/MoShiro.Backend.Analysis/Ops/Ops.cs
@@ -1,4 +1,4 @@
-namespace Monitor.Backend.Analysis;
+namespace MoShiro.Backend.Analysis;
/// 算子工厂:Ops.Rtt、Ops.Loss(Dir.Up) 等,供 MetricDef 声明使用。
public static class Ops
diff --git a/backend/src/Monitor.Backend.Analysis/Ops/SessionOps.cs b/backend/src/MoShiro.Backend.Analysis/Ops/SessionOps.cs
similarity index 99%
rename from backend/src/Monitor.Backend.Analysis/Ops/SessionOps.cs
rename to backend/src/MoShiro.Backend.Analysis/Ops/SessionOps.cs
index fb521fe..2fd97fb 100644
--- a/backend/src/Monitor.Backend.Analysis/Ops/SessionOps.cs
+++ b/backend/src/MoShiro.Backend.Analysis/Ops/SessionOps.cs
@@ -1,6 +1,6 @@
-using Monitor.Protocol;
+using MoShiro.Protocol;
-namespace Monitor.Backend.Analysis;
+namespace MoShiro.Backend.Analysis;
/// tcp_info 流的辅助:side 为 0 表示 Probe 一侧记录(Probe 时钟),否则为 Agent 一侧。
internal static class TcpInfoTime
diff --git a/backend/src/Monitor.Backend.Api/Admin/AgentEndpoints.cs b/backend/src/MoShiro.Backend.Api/Admin/AgentEndpoints.cs
similarity index 97%
rename from backend/src/Monitor.Backend.Api/Admin/AgentEndpoints.cs
rename to backend/src/MoShiro.Backend.Api/Admin/AgentEndpoints.cs
index a9ff75d..9360dd0 100644
--- a/backend/src/Monitor.Backend.Api/Admin/AgentEndpoints.cs
+++ b/backend/src/MoShiro.Backend.Api/Admin/AgentEndpoints.cs
@@ -2,10 +2,10 @@ using Fleet.Core;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Routing;
-using Monitor.Backend.Application;
-using Monitor.Protocol;
+using MoShiro.Backend.Application;
+using MoShiro.Protocol;
-namespace Monitor.Backend.Api;
+namespace MoShiro.Backend.Api;
/// Agent 管理:列表、修改、审批、启停、接管、删除;加入令牌;Probe 身份。
public static class AgentEndpoints
@@ -77,7 +77,7 @@ public static class AgentEndpoints
AgentView? view = await agents.GetAsync(new NodeId(id), ct);
if (view is null)
{
- return Problems.Create(http, MonitorErrors.AgentNotFound, "agent not found");
+ return Problems.Create(http, MoShiroErrors.AgentNotFound, "agent not found");
}
Concurrency.SetETag(http, view.Agent.RowVersion);
@@ -166,7 +166,7 @@ public static class AgentEndpoints
private static async Task GetProbeAsync(HttpContext http, ProbeService probes, string id, CancellationToken ct) =>
await probes.GetAsync(id, ct) is { } view
? TypedResults.Json(Mappers.ToDto(view), ApiJsonContext.Default.ProbeDto)
- : Problems.Create(http, MonitorErrors.ProbeNotFound, "probe not found");
+ : Problems.Create(http, MoShiroErrors.ProbeNotFound, "probe not found");
private static async Task PatchProbeAsync(HttpContext http, ProbeService probes, PatchProbeRequest request, string id, CancellationToken ct)
{
@@ -211,7 +211,7 @@ public static class AgentEndpoints
return Problems.From(http, error);
}
- return dropped ? TypedResults.NoContent() : Problems.Create(http, MonitorErrors.ProbeOffline, "this probe has no session with this agent");
+ return dropped ? TypedResults.NoContent() : Problems.Create(http, MoShiroErrors.ProbeOffline, "this probe has no session with this agent");
}
/// Probe 要连的面板地址:配置的公开地址,没有就用这次请求的地址。
diff --git a/backend/src/Monitor.Backend.Api/Admin/AuthEndpoints.cs b/backend/src/MoShiro.Backend.Api/Admin/AuthEndpoints.cs
similarity index 94%
rename from backend/src/Monitor.Backend.Api/Admin/AuthEndpoints.cs
rename to backend/src/MoShiro.Backend.Api/Admin/AuthEndpoints.cs
index 6294413..54a47d4 100644
--- a/backend/src/Monitor.Backend.Api/Admin/AuthEndpoints.cs
+++ b/backend/src/MoShiro.Backend.Api/Admin/AuthEndpoints.cs
@@ -2,10 +2,10 @@ using Fleet.Core;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Routing;
-using Monitor.Backend.Application;
-using Monitor.Protocol;
+using MoShiro.Backend.Application;
+using MoShiro.Protocol;
-namespace Monitor.Backend.Api;
+namespace MoShiro.Backend.Api;
/// 登录、退出、当前身份。登录接口限流,失败一律返回 401,不区分“用户不存在”和“密码错误”。
public static class AuthEndpoints
@@ -35,7 +35,7 @@ public static class AuthEndpoints
string source = http.Connection.RemoteIpAddress?.ToString() ?? "unknown";
if (!limiter.TryAcquire(source, out int retryAfter))
{
- return Problems.RetryAfter(http, new FleetError(MonitorErrors.TooManyRequests, "too many sign-in attempts"), retryAfter);
+ return Problems.RetryAfter(http, new FleetError(MoShiroErrors.TooManyRequests, "too many sign-in attempts"), retryAfter);
}
Result result = await auth.LoginAsync(request.Username ?? "", request.Password ?? "", http.RequestAborted);
diff --git a/backend/src/Monitor.Backend.Api/Admin/BuildEndpoints.cs b/backend/src/MoShiro.Backend.Api/Admin/BuildEndpoints.cs
similarity index 96%
rename from backend/src/Monitor.Backend.Api/Admin/BuildEndpoints.cs
rename to backend/src/MoShiro.Backend.Api/Admin/BuildEndpoints.cs
index c85ef3f..e59949a 100644
--- a/backend/src/Monitor.Backend.Api/Admin/BuildEndpoints.cs
+++ b/backend/src/MoShiro.Backend.Api/Admin/BuildEndpoints.cs
@@ -2,10 +2,10 @@ using Fleet.Core;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Routing;
-using Monitor.Backend.Application;
-using Monitor.Protocol;
+using MoShiro.Backend.Application;
+using MoShiro.Protocol;
-namespace Monitor.Backend.Api;
+namespace MoShiro.Backend.Api;
/// 构建信息与更新:后端和每个节点的版本、tag、构建时间,CI 签名的发布清单,以及「更新这个节点」的请求。更新本身由节点宿主机上的更新器验签并执行。
public static class BuildEndpoints
@@ -54,7 +54,7 @@ public static class BuildEndpoints
}
private static async Task RequestUpdateAsync(HttpContext http, ReleaseService releases, string id, CancellationToken ct) =>
- await releases.RequestUpdateAsync(new NodeId(id), ct) ? TypedResults.NoContent() : Problems.Create(http, MonitorErrors.AgentOffline, "the node is not connected");
+ await releases.RequestUpdateAsync(new NodeId(id), ct) ? TypedResults.NoContent() : Problems.Create(http, MoShiroErrors.AgentOffline, "the node is not connected");
private static ReleaseDto ToDto(ReleaseOffer offer) => new(offer.Component, offer.Seq, offer.Tag, offer.Version, offer.Digest);
diff --git a/backend/src/Monitor.Backend.Api/Admin/DataEndpoints.cs b/backend/src/MoShiro.Backend.Api/Admin/DataEndpoints.cs
similarity index 94%
rename from backend/src/Monitor.Backend.Api/Admin/DataEndpoints.cs
rename to backend/src/MoShiro.Backend.Api/Admin/DataEndpoints.cs
index d85927a..3dda979 100644
--- a/backend/src/Monitor.Backend.Api/Admin/DataEndpoints.cs
+++ b/backend/src/MoShiro.Backend.Api/Admin/DataEndpoints.cs
@@ -3,10 +3,10 @@ using Fleet.Core;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Routing;
-using Monitor.Backend.Application;
-using Monitor.Protocol;
+using MoShiro.Backend.Application;
+using MoShiro.Protocol;
-namespace Monitor.Backend.Api;
+namespace MoShiro.Backend.Api;
/// 原始数据检索与下载、事件、指标重算进度。
public static class DataEndpoints
@@ -18,8 +18,8 @@ public static class DataEndpoints
group.MapGet("/raw/chunks", ListChunksAsync)
.Api("raw_chunks_list", "Raw chunk metadata", Tag).Returns>().ProducesProblems(400, 401, 403);
group.MapGet("/raw/chunks/{chunk_id}", DownloadChunkAsync)
- .Api("raw_chunks_get", "Download a raw chunk (application/vnd.monitor.rawchunk)", Tag)
- .Produces(StatusCodes.Status200OK, contentType: "application/vnd.monitor.rawchunk").ProducesProblems(401, 403, 404, 410);
+ .Api("raw_chunks_get", "Download a raw chunk (application/vnd.moshiro.rawchunk)", Tag)
+ .Produces(StatusCodes.Status200OK, contentType: "application/vnd.moshiro.rawchunk").ProducesProblems(401, 403, 404, 410);
group.MapGet("/events", ListEventsAsync)
.Api("events_list", "Agent events", Tag).Returns>().ProducesProblems(400, 401, 403);
group.MapGet("/analysis/recompute", RecomputeAsync)
@@ -57,7 +57,7 @@ public static class DataEndpoints
{
if (!Guid.TryParse(chunk_id, out Guid id))
{
- return Problems.Create(http, MonitorErrors.ChunkNotFound, "chunk not found");
+ return Problems.Create(http, MoShiroErrors.ChunkNotFound, "chunk not found");
}
Result<(RawChunkMeta Meta, byte[] Bytes)> result = await raw.GetAsync(new ChunkId(id), http.RequestAborted);
@@ -67,7 +67,7 @@ public static class DataEndpoints
}
http.Response.Headers.CacheControl = "private, max-age=3600";
- return TypedResults.File(found.Bytes, "application/vnd.monitor.rawchunk", chunk_id + ".mnrc");
+ return TypedResults.File(found.Bytes, "application/vnd.moshiro.rawchunk", chunk_id + ".msrc");
}
private static async Task ListEventsAsync(
diff --git a/backend/src/Monitor.Backend.Api/Admin/LinkEndpoints.cs b/backend/src/MoShiro.Backend.Api/Admin/LinkEndpoints.cs
similarity index 92%
rename from backend/src/Monitor.Backend.Api/Admin/LinkEndpoints.cs
rename to backend/src/MoShiro.Backend.Api/Admin/LinkEndpoints.cs
index 5737f62..7ee75d6 100644
--- a/backend/src/Monitor.Backend.Api/Admin/LinkEndpoints.cs
+++ b/backend/src/MoShiro.Backend.Api/Admin/LinkEndpoints.cs
@@ -2,10 +2,10 @@ using Fleet.Core;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Routing;
-using Monitor.Backend.Application;
-using Monitor.Protocol;
+using MoShiro.Backend.Application;
+using MoShiro.Protocol;
-namespace Monitor.Backend.Api;
+namespace MoShiro.Backend.Api;
/// 线路开关:哪些(Probe,Agent)要连。自动连接的总开关是设置 fleet.auto_link;这里看每一对的结果,并且手动强制开、关或取消手动设置。
public static class LinkEndpoints
@@ -40,12 +40,12 @@ public static class LinkEndpoints
{
if (await probes.GetAsync(probe_id, ct) is not { Revoked: false } probe)
{
- return Problems.Create(http, MonitorErrors.ProbeNotFound, "probe not found");
+ return Problems.Create(http, MoShiroErrors.ProbeNotFound, "probe not found");
}
if (await agents.GetAsync(new NodeId(agent_id), ct) is not { } agent)
{
- return Problems.Create(http, MonitorErrors.AgentNotFound, "agent not found");
+ return Problems.Create(http, MoShiroErrors.AgentNotFound, "agent not found");
}
await links.SetAsync(probe_id, agent_id, request.Enabled, ct);
diff --git a/backend/src/Monitor.Backend.Api/Admin/SystemEndpoints.cs b/backend/src/MoShiro.Backend.Api/Admin/SystemEndpoints.cs
similarity index 98%
rename from backend/src/Monitor.Backend.Api/Admin/SystemEndpoints.cs
rename to backend/src/MoShiro.Backend.Api/Admin/SystemEndpoints.cs
index d833295..00a6037 100644
--- a/backend/src/Monitor.Backend.Api/Admin/SystemEndpoints.cs
+++ b/backend/src/MoShiro.Backend.Api/Admin/SystemEndpoints.cs
@@ -3,10 +3,10 @@ using Fleet.Core;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Routing;
-using Monitor.Backend.Application;
-using Monitor.Protocol;
+using MoShiro.Backend.Application;
+using MoShiro.Protocol;
-namespace Monitor.Backend.Api;
+namespace MoShiro.Backend.Api;
/// API 令牌、站点设置与保留期、用户。令牌明文只在创建的响应里出现一次。
public static class SystemEndpoints
diff --git a/backend/src/Monitor.Backend.Api/Admin/TaskEndpoints.cs b/backend/src/MoShiro.Backend.Api/Admin/TaskEndpoints.cs
similarity index 97%
rename from backend/src/Monitor.Backend.Api/Admin/TaskEndpoints.cs
rename to backend/src/MoShiro.Backend.Api/Admin/TaskEndpoints.cs
index eb30c46..66b8c41 100644
--- a/backend/src/Monitor.Backend.Api/Admin/TaskEndpoints.cs
+++ b/backend/src/MoShiro.Backend.Api/Admin/TaskEndpoints.cs
@@ -2,10 +2,10 @@ using Fleet.Core;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Routing;
-using Monitor.Backend.Application;
-using Monitor.Protocol;
+using MoShiro.Backend.Application;
+using MoShiro.Protocol;
-namespace Monitor.Backend.Api;
+namespace MoShiro.Backend.Api;
/// 任务(线路模板、单个 Agent 的覆盖、目标任务)与按需测试。参数按 Kind 的 ParamSpec 校验,并检查带宽预算。
public static class TaskEndpoints
@@ -76,7 +76,7 @@ public static class TaskEndpoints
TaskRecord? task = await tasks.GetAsync(new TaskId(id), ct);
if (task is null)
{
- return Problems.Create(http, MonitorErrors.TaskNotFound, "task not found");
+ return Problems.Create(http, MoShiroErrors.TaskNotFound, "task not found");
}
Concurrency.SetETag(http, task.RowVersion);
diff --git a/backend/src/Monitor.Backend.Api/ApiModule.cs b/backend/src/MoShiro.Backend.Api/ApiModule.cs
similarity index 93%
rename from backend/src/Monitor.Backend.Api/ApiModule.cs
rename to backend/src/MoShiro.Backend.Api/ApiModule.cs
index bbab80b..6cb4d31 100644
--- a/backend/src/Monitor.Backend.Api/ApiModule.cs
+++ b/backend/src/MoShiro.Backend.Api/ApiModule.cs
@@ -5,17 +5,17 @@ using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Json;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.DependencyInjection;
-using Monitor.Backend.Application;
+using MoShiro.Backend.Application;
-namespace Monitor.Backend.Api;
+namespace MoShiro.Backend.Api;
///
-/// Api 层的入口:服务注册、中间件、端点映射。新增资源时在 里加一行。
+/// Api 层的入口:服务注册、中间件、端点映射。新增资源时在 里加一行。
/// Api 只调用 Application;错误码到 HTTP 状态的映射只在这一层做一次()。
///
public static class ApiModule
{
- public static IServiceCollection AddMonitorApi(this IServiceCollection services)
+ public static IServiceCollection AddMoShiroApi(this IServiceCollection services)
{
services.AddSingleton();
services.Configure(options =>
@@ -48,7 +48,7 @@ public static class ApiModule
/// 跨域(可选):只对 /api/public 和 /api/admin 生效,只放行名单里的来源,且不带凭据(Cookie 不会跨域),
/// 所以跨域的前端只能用 Bearer 令牌。需要放在认证和路由之前。
///
- public static IApplicationBuilder UseMonitorCors(this IApplicationBuilder app, string? origins)
+ public static IApplicationBuilder UseMoShiroCors(this IApplicationBuilder app, string? origins)
{
string[] allowed = (origins ?? string.Empty).Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);
if (allowed.Length == 0)
@@ -83,7 +83,7 @@ public static class ApiModule
}
/// 认证中间件:解析 Bearer 令牌或会话 Cookie。需要放在路由之后、端点之前。
- public static IApplicationBuilder UseMonitorApi(this IApplicationBuilder app)
+ public static IApplicationBuilder UseMoShiroApi(this IApplicationBuilder app)
{
app.UseExceptionHandler();
app.UseStatusCodePages();
@@ -91,7 +91,7 @@ public static class ApiModule
return app;
}
- public static IEndpointRouteBuilder MapMonitorApi(this IEndpointRouteBuilder app)
+ public static IEndpointRouteBuilder MapMoShiroApi(this IEndpointRouteBuilder app)
{
RouteGroupBuilder publicGroup = app.MapGroup("/api/public").AddEndpointFilter(PublicGuard.InvokeAsync);
QueryEndpoints.Map(publicGroup);
diff --git a/backend/src/Monitor.Backend.Api/Common/Concurrency.cs b/backend/src/MoShiro.Backend.Api/Common/Concurrency.cs
similarity index 97%
rename from backend/src/Monitor.Backend.Api/Common/Concurrency.cs
rename to backend/src/MoShiro.Backend.Api/Common/Concurrency.cs
index 1916238..60bc8e7 100644
--- a/backend/src/Monitor.Backend.Api/Common/Concurrency.cs
+++ b/backend/src/MoShiro.Backend.Api/Common/Concurrency.cs
@@ -1,7 +1,7 @@
using System.Globalization;
using Microsoft.AspNetCore.Http;
-namespace Monitor.Backend.Api;
+namespace MoShiro.Backend.Api;
/// 并发控制:配置类资源返回 ETag(行版本),PATCH/DELETE 支持 If-Match,不匹配时返回 412。
internal static class Concurrency
diff --git a/backend/src/Monitor.Backend.Api/Common/EndpointConventions.cs b/backend/src/MoShiro.Backend.Api/Common/EndpointConventions.cs
similarity index 96%
rename from backend/src/Monitor.Backend.Api/Common/EndpointConventions.cs
rename to backend/src/MoShiro.Backend.Api/Common/EndpointConventions.cs
index 9158ec2..f749fd0 100644
--- a/backend/src/Monitor.Backend.Api/Common/EndpointConventions.cs
+++ b/backend/src/MoShiro.Backend.Api/Common/EndpointConventions.cs
@@ -1,7 +1,7 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
-namespace Monitor.Backend.Api;
+namespace MoShiro.Backend.Api;
public static class EndpointConventions
{
diff --git a/backend/src/Monitor.Backend.Api/Common/Guards.cs b/backend/src/MoShiro.Backend.Api/Common/Guards.cs
similarity index 90%
rename from backend/src/Monitor.Backend.Api/Common/Guards.cs
rename to backend/src/MoShiro.Backend.Api/Common/Guards.cs
index 9e865c5..0be49b8 100644
--- a/backend/src/Monitor.Backend.Api/Common/Guards.cs
+++ b/backend/src/MoShiro.Backend.Api/Common/Guards.cs
@@ -1,13 +1,13 @@
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
-using Monitor.Backend.Application;
-using Monitor.Protocol;
+using MoShiro.Backend.Application;
+using MoShiro.Protocol;
-namespace Monitor.Backend.Api;
+namespace MoShiro.Backend.Api;
public static class HttpContextPrincipalExtensions
{
- private const string Key = "monitor.principal";
+ private const string Key = "moshiro.principal";
public static Principal GetPrincipal(this HttpContext http) =>
http.Items.TryGetValue(Key, out object? value) && value is Principal principal ? principal : Principal.Anonymous;
@@ -20,7 +20,7 @@ public static class HttpContextPrincipalExtensions
///
public static class PrincipalResolver
{
- public const string SessionCookie = "monitor_session";
+ public const string SessionCookie = "moshiro_session";
public const string CsrfHeader = "X-CSRF-Token";
public static string? BearerOf(HttpContext http)
@@ -63,8 +63,8 @@ public static class AdminGuard
if (!principal.IsAdmin)
{
return principal.Scope != ApiScope.None
- ? Problems.Create(http, MonitorErrors.Forbidden, "the token scope does not allow this operation")
- : Problems.Create(http, MonitorErrors.Unauthorized, "authentication is required");
+ ? Problems.Create(http, MoShiroErrors.Forbidden, "the token scope does not allow this operation")
+ : Problems.Create(http, MoShiroErrors.Unauthorized, "authentication is required");
}
if (principal.Kind == PrincipalKind.Session && !HttpMethods.IsGet(http.Request.Method) && !HttpMethods.IsHead(http.Request.Method) && !HttpMethods.IsOptions(http.Request.Method))
@@ -72,7 +72,7 @@ public static class AdminGuard
string? csrf = http.Request.Headers[PrincipalResolver.CsrfHeader];
if (csrf is null || principal.CsrfToken is null || !AuthService.FixedTimeEquals(csrf, principal.CsrfToken))
{
- return Problems.Create(http, MonitorErrors.CsrfFailed, "a valid X-CSRF-Token header is required");
+ return Problems.Create(http, MoShiroErrors.CsrfFailed, "a valid X-CSRF-Token header is required");
}
}
@@ -95,7 +95,7 @@ public static class PublicGuard
HttpContext http = context.HttpContext;
if (!http.GetPrincipal().CanRead && !await http.RequestServices.GetRequiredService().IsSitePublicAsync(http.RequestAborted))
{
- return Problems.Create(http, MonitorErrors.SitePrivate, "this site is private; sign in or use a read-only token");
+ return Problems.Create(http, MoShiroErrors.SitePrivate, "this site is private; sign in or use a read-only token");
}
return await next(context);
diff --git a/backend/src/Monitor.Backend.Api/Common/Mappers.cs b/backend/src/MoShiro.Backend.Api/Common/Mappers.cs
similarity index 98%
rename from backend/src/Monitor.Backend.Api/Common/Mappers.cs
rename to backend/src/MoShiro.Backend.Api/Common/Mappers.cs
index 98ea0d1..39fd43e 100644
--- a/backend/src/Monitor.Backend.Api/Common/Mappers.cs
+++ b/backend/src/MoShiro.Backend.Api/Common/Mappers.cs
@@ -1,10 +1,10 @@
using System.Text.Json;
using Fleet.Server;
-using Monitor.Backend.Analysis;
-using Monitor.Backend.Application;
-using Monitor.Protocol;
+using MoShiro.Backend.Analysis;
+using MoShiro.Backend.Application;
+using MoShiro.Protocol;
-namespace Monitor.Backend.Api;
+namespace MoShiro.Backend.Api;
/// 应用层模型 → REST DTO。public 层的 DTO 只暴露可以公开的字段。
public static class Mappers
diff --git a/backend/src/Monitor.Backend.Api/Common/Problems.cs b/backend/src/MoShiro.Backend.Api/Common/Problems.cs
similarity index 71%
rename from backend/src/Monitor.Backend.Api/Common/Problems.cs
rename to backend/src/MoShiro.Backend.Api/Common/Problems.cs
index 841ca91..87576e9 100644
--- a/backend/src/Monitor.Backend.Api/Common/Problems.cs
+++ b/backend/src/MoShiro.Backend.Api/Common/Problems.cs
@@ -1,10 +1,10 @@
using System.Diagnostics;
using Fleet.Core;
using Microsoft.AspNetCore.Http;
-using Monitor.Backend.Application;
-using Monitor.Protocol;
+using MoShiro.Backend.Application;
+using MoShiro.Protocol;
-namespace Monitor.Backend.Api;
+namespace MoShiro.Backend.Api;
/// 错误码到 HTTP 状态的映射:只在 Api 层做一次。
public static class ErrorCodeHttpMap
@@ -44,19 +44,19 @@ public static class ErrorCodeHttpMap
}
}
- Add(400, MonitorErrors.ValidationFailed, MonitorErrors.BudgetExceeded, FleetErrors.InvalidParams);
- Add(401, MonitorErrors.Unauthorized, MonitorErrors.CsrfFailed, FleetErrors.Unauthorized);
- Add(403, MonitorErrors.Forbidden, MonitorErrors.SitePrivate, FleetErrors.Forbidden, FleetErrors.ProofInvalid);
+ Add(400, MoShiroErrors.ValidationFailed, MoShiroErrors.BudgetExceeded, FleetErrors.InvalidParams);
+ Add(401, MoShiroErrors.Unauthorized, MoShiroErrors.CsrfFailed, FleetErrors.Unauthorized);
+ Add(403, MoShiroErrors.Forbidden, MoShiroErrors.SitePrivate, FleetErrors.Forbidden, FleetErrors.ProofInvalid);
Add(
- 404, MonitorErrors.NotFound, MonitorErrors.AgentNotFound, MonitorErrors.ProbeNotFound, MonitorErrors.TaskNotFound, MonitorErrors.TestNotFound, MonitorErrors.ChunkNotFound,
- MonitorErrors.TokenNotFound, MonitorErrors.UnknownKind, MonitorErrors.UnknownPlan, FleetErrors.NotFound);
- Add(409, MonitorErrors.NameConflict, MonitorErrors.ProbeRevoked, MonitorErrors.ProbeOffline, MonitorErrors.TestBusy, MonitorErrors.AgentNotActive, MonitorErrors.AgentOffline, FleetErrors.NameConflict, FleetErrors.NodeOffline);
- Add(410, MonitorErrors.RawExpired, MonitorErrors.JoinTokenExpired, FleetErrors.JoinTokenExpired);
- Add(412, MonitorErrors.PreconditionFailed);
- Add(413, MonitorErrors.PayloadTooLarge);
- Add(422, MonitorErrors.ProbeRequired, MonitorErrors.RangeTooLarge, MonitorErrors.InvalidStep, MonitorErrors.InvalidRange, MonitorErrors.UnknownMetric, MonitorErrors.UnknownPreset, MonitorErrors.TooManyMetrics, FleetErrors.Unsupported);
- Add(429, MonitorErrors.TooManyRequests, MonitorErrors.TooManyStreams);
- Add(503, MonitorErrors.StorageUnavailable, FleetErrors.Timeout);
+ 404, MoShiroErrors.NotFound, MoShiroErrors.AgentNotFound, MoShiroErrors.ProbeNotFound, MoShiroErrors.TaskNotFound, MoShiroErrors.TestNotFound, MoShiroErrors.ChunkNotFound,
+ MoShiroErrors.TokenNotFound, MoShiroErrors.UnknownKind, MoShiroErrors.UnknownPlan, FleetErrors.NotFound);
+ Add(409, MoShiroErrors.NameConflict, MoShiroErrors.ProbeRevoked, MoShiroErrors.ProbeOffline, MoShiroErrors.TestBusy, MoShiroErrors.AgentNotActive, MoShiroErrors.AgentOffline, FleetErrors.NameConflict, FleetErrors.NodeOffline);
+ Add(410, MoShiroErrors.RawExpired, MoShiroErrors.JoinTokenExpired, FleetErrors.JoinTokenExpired);
+ Add(412, MoShiroErrors.PreconditionFailed);
+ Add(413, MoShiroErrors.PayloadTooLarge);
+ Add(422, MoShiroErrors.ProbeRequired, MoShiroErrors.RangeTooLarge, MoShiroErrors.InvalidStep, MoShiroErrors.InvalidRange, MoShiroErrors.UnknownMetric, MoShiroErrors.UnknownPreset, MoShiroErrors.TooManyMetrics, FleetErrors.Unsupported);
+ Add(429, MoShiroErrors.TooManyRequests, MoShiroErrors.TooManyStreams);
+ Add(503, MoShiroErrors.StorageUnavailable, FleetErrors.Timeout);
map[NotImplemented.Value] = 501;
return map;
}
diff --git a/backend/src/Monitor.Backend.Api/Common/QueryHelpers.cs b/backend/src/MoShiro.Backend.Api/Common/QueryHelpers.cs
similarity index 93%
rename from backend/src/Monitor.Backend.Api/Common/QueryHelpers.cs
rename to backend/src/MoShiro.Backend.Api/Common/QueryHelpers.cs
index f6e8ef8..f37b141 100644
--- a/backend/src/Monitor.Backend.Api/Common/QueryHelpers.cs
+++ b/backend/src/MoShiro.Backend.Api/Common/QueryHelpers.cs
@@ -3,10 +3,10 @@ using System.Text;
using Fleet.Core;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
-using Monitor.Backend.Application;
-using Monitor.Protocol;
+using MoShiro.Backend.Application;
+using MoShiro.Protocol;
-namespace Monitor.Backend.Api;
+namespace MoShiro.Backend.Api;
internal static class QueryHelpers
{
@@ -22,7 +22,7 @@ internal static class QueryHelpers
}
catch (OperationCanceledException) when (!http.RequestAborted.IsCancellationRequested)
{
- return Problems.Create(http, MonitorErrors.StorageUnavailable, null);
+ return Problems.Create(http, MoShiroErrors.StorageUnavailable, null);
}
}
@@ -81,7 +81,7 @@ internal static class QueryHelpers
return line.Agent.Agent.Status == Fleet.Server.NodeStatus.Active && (line.Agent.Agent.PublicVisible || PublicGuard.CanSeeHidden(http)) && line.Probe.RevokedAtMs is null
? found
- : Result.Fail(MonitorErrors.AgentNotFound, "line not found");
+ : Result.Fail(MoShiroErrors.AgentNotFound, "line not found");
}
/// 找到可以展示的线路:已激活,并且(对外可见,或者访问者已认证)。否则 404(不暴露被隐藏的线路存在与否)。
@@ -90,6 +90,6 @@ internal static class QueryHelpers
AgentView? view = await agents.GetAsync(new NodeId(id), ct);
return view is { Agent.Status: Fleet.Server.NodeStatus.Active } && (view.Agent.PublicVisible || PublicGuard.CanSeeHidden(http))
? Result.Ok(view)
- : Result.Fail(MonitorErrors.AgentNotFound, "agent not found");
+ : Result.Fail(MoShiroErrors.AgentNotFound, "agent not found");
}
}
diff --git a/backend/src/Monitor.Backend.Api/Contracts/AdminDtos.cs b/backend/src/MoShiro.Backend.Api/Contracts/AdminDtos.cs
similarity index 99%
rename from backend/src/Monitor.Backend.Api/Contracts/AdminDtos.cs
rename to backend/src/MoShiro.Backend.Api/Contracts/AdminDtos.cs
index 45236ab..d01021e 100644
--- a/backend/src/Monitor.Backend.Api/Contracts/AdminDtos.cs
+++ b/backend/src/MoShiro.Backend.Api/Contracts/AdminDtos.cs
@@ -1,6 +1,6 @@
using System.Text.Json;
-namespace Monitor.Backend.Api;
+namespace MoShiro.Backend.Api;
/// return_session:跨域的前端用——不设 Cookie,把会话令牌放在响应里,之后用 Authorization: Bearer 带上。
public sealed record LoginRequest(string Username, string Password, bool? ReturnSession);
diff --git a/backend/src/Monitor.Backend.Api/Contracts/ApiJsonContext.cs b/backend/src/MoShiro.Backend.Api/Contracts/ApiJsonContext.cs
similarity index 97%
rename from backend/src/Monitor.Backend.Api/Contracts/ApiJsonContext.cs
rename to backend/src/MoShiro.Backend.Api/Contracts/ApiJsonContext.cs
index 8a355b9..2ce9de8 100644
--- a/backend/src/Monitor.Backend.Api/Contracts/ApiJsonContext.cs
+++ b/backend/src/MoShiro.Backend.Api/Contracts/ApiJsonContext.cs
@@ -1,7 +1,7 @@
using System.Text.Json;
using System.Text.Json.Serialization;
-namespace Monitor.Backend.Api;
+namespace MoShiro.Backend.Api;
///
/// REST 的 JSON 源生成上下文(snake_case,字段始终存在、未知值写 null,枚举与时间的格式见数据表示规则)。
@@ -80,6 +80,6 @@ namespace Monitor.Backend.Api;
[JsonSerializable(typeof(CreateUserRequest))]
[JsonSerializable(typeof(ChangePasswordRequest))]
[JsonSerializable(typeof(RecomputeDto))]
-[JsonSerializable(typeof(Monitor.Protocol.LocalLimits))]
+[JsonSerializable(typeof(MoShiro.Protocol.LocalLimits))]
[JsonSerializable(typeof(List))]
public sealed partial class ApiJsonContext : JsonSerializerContext;
diff --git a/backend/src/Monitor.Backend.Api/Contracts/CommonDtos.cs b/backend/src/MoShiro.Backend.Api/Contracts/CommonDtos.cs
similarity index 97%
rename from backend/src/Monitor.Backend.Api/Contracts/CommonDtos.cs
rename to backend/src/MoShiro.Backend.Api/Contracts/CommonDtos.cs
index 0095b20..ea982a1 100644
--- a/backend/src/Monitor.Backend.Api/Contracts/CommonDtos.cs
+++ b/backend/src/MoShiro.Backend.Api/Contracts/CommonDtos.cs
@@ -2,7 +2,7 @@ using System.Globalization;
using System.Text.Json;
using System.Text.Json.Serialization;
-namespace Monitor.Backend.Api;
+namespace MoShiro.Backend.Api;
/// 时间点统一使用 RFC 3339 UTC,以 Z 结尾,精确到毫秒(唯一例外:列式时序里的时间轴 t 是 Unix 毫秒)。
public sealed class Rfc3339Converter : JsonConverter
diff --git a/backend/src/Monitor.Backend.Api/Contracts/PublicDtos.cs b/backend/src/MoShiro.Backend.Api/Contracts/PublicDtos.cs
similarity index 99%
rename from backend/src/Monitor.Backend.Api/Contracts/PublicDtos.cs
rename to backend/src/MoShiro.Backend.Api/Contracts/PublicDtos.cs
index c52543e..4c1cdf0 100644
--- a/backend/src/Monitor.Backend.Api/Contracts/PublicDtos.cs
+++ b/backend/src/MoShiro.Backend.Api/Contracts/PublicDtos.cs
@@ -1,4 +1,4 @@
-namespace Monitor.Backend.Api;
+namespace MoShiro.Backend.Api;
/// 汇总:整个时间段由累加器精确合并得出的值(不是各点的平均)。
public sealed record SummaryDto(IReadOnlyDictionary Metrics, IReadOnlyDictionary Samples, double Coverage);
diff --git a/backend/src/Monitor.Backend.Api/Monitor.Backend.Api.csproj b/backend/src/MoShiro.Backend.Api/MoShiro.Backend.Api.csproj
similarity index 76%
rename from backend/src/Monitor.Backend.Api/Monitor.Backend.Api.csproj
rename to backend/src/MoShiro.Backend.Api/MoShiro.Backend.Api.csproj
index 95eddf2..0111063 100644
--- a/backend/src/Monitor.Backend.Api/Monitor.Backend.Api.csproj
+++ b/backend/src/MoShiro.Backend.Api/MoShiro.Backend.Api.csproj
@@ -6,6 +6,6 @@
-
+
diff --git a/backend/src/Monitor.Backend.Api/OpsEndpoints.cs b/backend/src/MoShiro.Backend.Api/OpsEndpoints.cs
similarity index 91%
rename from backend/src/Monitor.Backend.Api/OpsEndpoints.cs
rename to backend/src/MoShiro.Backend.Api/OpsEndpoints.cs
index 1e51dbc..75779be 100644
--- a/backend/src/Monitor.Backend.Api/OpsEndpoints.cs
+++ b/backend/src/MoShiro.Backend.Api/OpsEndpoints.cs
@@ -1,10 +1,10 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Routing;
-using Monitor.Backend.Application;
-using Monitor.Protocol;
+using MoShiro.Backend.Application;
+using MoShiro.Protocol;
-namespace Monitor.Backend.Api;
+namespace MoShiro.Backend.Api;
/// 运维端点:/healthz、/metrics(admin 令牌)、安装脚本。
public static class OpsEndpoints
@@ -40,8 +40,8 @@ public static class OpsEndpoints
if (!principal.IsAdmin)
{
return principal.CanRead
- ? Problems.Create(http, MonitorErrors.Forbidden, "an admin token is required")
- : Problems.Create(http, MonitorErrors.Unauthorized, "an admin token is required");
+ ? Problems.Create(http, MoShiroErrors.Forbidden, "an admin token is required")
+ : Problems.Create(http, MoShiroErrors.Unauthorized, "an admin token is required");
}
return TypedResults.Text(await ops.RenderPrometheusAsync(http.RequestAborted), "text/plain; version=0.0.4");
diff --git a/backend/src/Monitor.Backend.Api/Public/CatalogEndpoints.cs b/backend/src/MoShiro.Backend.Api/Public/CatalogEndpoints.cs
similarity index 90%
rename from backend/src/Monitor.Backend.Api/Public/CatalogEndpoints.cs
rename to backend/src/MoShiro.Backend.Api/Public/CatalogEndpoints.cs
index 34f1779..b2f6e9c 100644
--- a/backend/src/Monitor.Backend.Api/Public/CatalogEndpoints.cs
+++ b/backend/src/MoShiro.Backend.Api/Public/CatalogEndpoints.cs
@@ -1,10 +1,10 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Routing;
-using Monitor.Backend.Analysis;
-using Monitor.Protocol;
+using MoShiro.Backend.Analysis;
+using MoShiro.Protocol;
-namespace Monitor.Backend.Api;
+namespace MoShiro.Backend.Api;
/// 目录:由代码里的注册表生成。新增 Kind、方案、指标、分组、模型后,目录自动更新,前端不需要改。
public static class CatalogEndpoints
@@ -27,12 +27,12 @@ public static class CatalogEndpoints
}
private static IResult Kinds(HttpContext http) =>
- QueryHelpers.ApplyCatalogCaching(http, string.Join(',', Monitor.Protocol.Kinds.All.Select(k => k.Id)))
- ?? TypedResults.Json(new PageDto([.. Monitor.Protocol.Kinds.All.Select(Mappers.ToDto)], null), ApiJsonContext.Default.PageDtoKindDto);
+ QueryHelpers.ApplyCatalogCaching(http, string.Join(',', MoShiro.Protocol.Kinds.All.Select(k => k.Id)))
+ ?? TypedResults.Json(new PageDto([.. MoShiro.Protocol.Kinds.All.Select(Mappers.ToDto)], null), ApiJsonContext.Default.PageDtoKindDto);
private static IResult Plans(HttpContext http) =>
- QueryHelpers.ApplyCatalogCaching(http, string.Join(',', Monitor.Backend.Application.Plans.All.Select(p => p.Id)))
- ?? TypedResults.Json(new PageDto([.. Monitor.Backend.Application.Plans.All.Select(Mappers.ToDto)], null), ApiJsonContext.Default.PageDtoPlanDto);
+ QueryHelpers.ApplyCatalogCaching(http, string.Join(',', MoShiro.Backend.Application.Plans.All.Select(p => p.Id)))
+ ?? TypedResults.Json(new PageDto([.. MoShiro.Backend.Application.Plans.All.Select(Mappers.ToDto)], null), ApiJsonContext.Default.PageDtoPlanDto);
private static IResult Metrics(HttpContext http) =>
QueryHelpers.ApplyCatalogCaching(http, string.Join(',', MetricRegistry.All.Select(m => m.Fingerprint)))
diff --git a/backend/src/Monitor.Backend.Api/Public/HostEndpoints.cs b/backend/src/MoShiro.Backend.Api/Public/HostEndpoints.cs
similarity index 95%
rename from backend/src/Monitor.Backend.Api/Public/HostEndpoints.cs
rename to backend/src/MoShiro.Backend.Api/Public/HostEndpoints.cs
index 1430e74..1dc2031 100644
--- a/backend/src/Monitor.Backend.Api/Public/HostEndpoints.cs
+++ b/backend/src/MoShiro.Backend.Api/Public/HostEndpoints.cs
@@ -2,10 +2,10 @@ using Fleet.Core;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Routing;
-using Monitor.Backend.Application;
-using Monitor.Protocol;
+using MoShiro.Backend.Application;
+using MoShiro.Protocol;
-namespace Monitor.Backend.Api;
+namespace MoShiro.Backend.Api;
/// Agent 的主机资源占用:最新值(实时的部分走 SSE 的 hosts 主题)和历史曲线。只有汇总的数字,没有型号和 IP。
public static class HostEndpoints
@@ -44,12 +44,12 @@ public static class HostEndpoints
AgentView? view = await agents.GetAsync(new NodeId(agent_id), ct);
if (view is not { Agent.Status: Fleet.Server.NodeStatus.Active } || !(view.Agent.PublicVisible || PublicGuard.CanSeeHidden(http)))
{
- return Problems.Create(http, MonitorErrors.AgentNotFound, "agent not found");
+ return Problems.Create(http, MoShiroErrors.AgentNotFound, "agent not found");
}
if (!RangeResolver.TryParseSpan(range ?? "1h", out long span) || span < Steps.Hour || span > 30 * Steps.Day)
{
- return Problems.From(http, new FleetError(MonitorErrors.InvalidRange, "range must look like 1h, 6h, 24h or 7d (between 1 hour and 30 days)"));
+ return Problems.From(http, new FleetError(MoShiroErrors.InvalidRange, "range must look like 1h, 6h, 24h or 7d (between 1 hour and 30 days)"));
}
long now = time.GetUtcNow().ToUnixTimeMilliseconds();
diff --git a/backend/src/Monitor.Backend.Api/Public/LiveEndpoints.cs b/backend/src/MoShiro.Backend.Api/Public/LiveEndpoints.cs
similarity index 99%
rename from backend/src/Monitor.Backend.Api/Public/LiveEndpoints.cs
rename to backend/src/MoShiro.Backend.Api/Public/LiveEndpoints.cs
index 8c6f2cb..b2de354 100644
--- a/backend/src/Monitor.Backend.Api/Public/LiveEndpoints.cs
+++ b/backend/src/MoShiro.Backend.Api/Public/LiveEndpoints.cs
@@ -7,10 +7,10 @@ using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Primitives;
-using Monitor.Backend.Application;
-using Monitor.Protocol;
+using MoShiro.Backend.Application;
+using MoShiro.Protocol;
-namespace Monitor.Backend.Api;
+namespace MoShiro.Backend.Api;
///
/// 实时推送(SSE):先推送当前快照,再推送增量(不补发历史)。SSE 只负责“更快地获得变化”,
@@ -67,7 +67,7 @@ public static class LiveEndpoints
string client = http.Connection.RemoteIpAddress?.ToString() ?? "unknown";
if (!limiter.TryAcquire(client))
{
- return Problems.Create(http, MonitorErrors.TooManyStreams, $"at most {options.MaxSsePerClient} live connections per client");
+ return Problems.Create(http, MoShiroErrors.TooManyStreams, $"at most {options.MaxSsePerClient} live connections per client");
}
counters.SseOpened();
diff --git a/backend/src/Monitor.Backend.Api/Public/LiveTopics.cs b/backend/src/MoShiro.Backend.Api/Public/LiveTopics.cs
similarity index 95%
rename from backend/src/Monitor.Backend.Api/Public/LiveTopics.cs
rename to backend/src/MoShiro.Backend.Api/Public/LiveTopics.cs
index d483eff..c9c3e31 100644
--- a/backend/src/Monitor.Backend.Api/Public/LiveTopics.cs
+++ b/backend/src/MoShiro.Backend.Api/Public/LiveTopics.cs
@@ -1,9 +1,9 @@
using System.Collections.Concurrent;
using Fleet.Core;
-using Monitor.Backend.Application;
-using Monitor.Protocol;
+using MoShiro.Backend.Application;
+using MoShiro.Protocol;
-namespace Monitor.Backend.Api;
+namespace MoShiro.Backend.Api;
internal enum LiveTopicKind
{
@@ -46,7 +46,7 @@ internal sealed record LiveTopic(LiveTopicKind Kind, string Raw, string? Range,
if (tokens.Count > maxTopics)
{
- return Result>.Fail(MonitorErrors.TooManyStreams, $"at most {maxTopics} topics per connection");
+ return Result>.Fail(MoShiroErrors.TooManyStreams, $"at most {maxTopics} topics per connection");
}
var topics = new List();
@@ -83,7 +83,7 @@ internal sealed record LiveTopic(LiveTopicKind Kind, string Raw, string? Range,
case "series" when parts.Length == 4:
if (!Steps.TryParse(parts[2], out long step) || step > Steps.Minute)
{
- return Result.Fail(MonitorErrors.InvalidStep, $"{token}: series topics support steps up to 1m; refetch coarser steps over REST");
+ return Result.Fail(MoShiroErrors.InvalidStep, $"{token}: series topics support steps up to 1m; refetch coarser steps over REST");
}
return Result.Ok(new LiveTopic(LiveTopicKind.Series, token, null, step, parts[3], parts[1], null));
diff --git a/backend/src/Monitor.Backend.Api/Public/NodeEndpoints.cs b/backend/src/MoShiro.Backend.Api/Public/NodeEndpoints.cs
similarity index 92%
rename from backend/src/Monitor.Backend.Api/Public/NodeEndpoints.cs
rename to backend/src/MoShiro.Backend.Api/Public/NodeEndpoints.cs
index 35da907..e71ba87 100644
--- a/backend/src/Monitor.Backend.Api/Public/NodeEndpoints.cs
+++ b/backend/src/MoShiro.Backend.Api/Public/NodeEndpoints.cs
@@ -1,9 +1,9 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Routing;
-using Monitor.Backend.Application;
+using MoShiro.Backend.Application;
-namespace Monitor.Backend.Api;
+namespace MoShiro.Backend.Api;
///
/// 节点的展示信息:系统、架构、国家、运营商。只有这几项,没有任何 IP 地址、城市、ASN、经纬度——
@@ -25,7 +25,7 @@ public static class NodeEndpoints
/// 这个后端自己的构建信息;没有(本地构建)的字段是 null。
internal static BuildDto Backend(bool withCommit) =>
- new(Monitor.Protocol.BuildInfo.Version, Empty(Monitor.Protocol.BuildInfo.Tag), withCommit ? Empty(Monitor.Protocol.BuildInfo.Commit) : null, Empty(Monitor.Protocol.BuildInfo.BuiltAt));
+ new(MoShiro.Protocol.BuildInfo.Version, Empty(MoShiro.Protocol.BuildInfo.Tag), withCommit ? Empty(MoShiro.Protocol.BuildInfo.Commit) : null, Empty(MoShiro.Protocol.BuildInfo.BuiltAt));
private static string? Empty(string value) => value.Length == 0 ? null : value;
diff --git a/backend/src/Monitor.Backend.Api/Public/QueryEndpoints.cs b/backend/src/MoShiro.Backend.Api/Public/QueryEndpoints.cs
similarity index 98%
rename from backend/src/Monitor.Backend.Api/Public/QueryEndpoints.cs
rename to backend/src/MoShiro.Backend.Api/Public/QueryEndpoints.cs
index dcadd8d..9c8be7d 100644
--- a/backend/src/Monitor.Backend.Api/Public/QueryEndpoints.cs
+++ b/backend/src/MoShiro.Backend.Api/Public/QueryEndpoints.cs
@@ -3,11 +3,11 @@ using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Routing;
-using Monitor.Backend.Analysis;
-using Monitor.Backend.Application;
-using Monitor.Protocol;
+using MoShiro.Backend.Analysis;
+using MoShiro.Backend.Application;
+using MoShiro.Protocol;
-namespace Monitor.Backend.Api;
+namespace MoShiro.Backend.Api;
/// 展示数据的查询端点:参数解析、校验与缓存头,业务都在 Application.Query。
public static class QueryEndpoints
@@ -211,13 +211,13 @@ public static class QueryEndpoints
TestDetail? detail = await tests.GetAsync(new TestId(test_id), ct);
if (detail is null)
{
- return Problems.Create(http, MonitorErrors.TestNotFound, "test not found");
+ return Problems.Create(http, MoShiroErrors.TestNotFound, "test not found");
}
Result visible = await QueryHelpers.FindVisibleAgentAsync(http, agents, detail.Test.AgentId.Value, ct);
if (!visible.IsSuccess)
{
- return Problems.Create(http, MonitorErrors.TestNotFound, "test not found");
+ return Problems.Create(http, MoShiroErrors.TestNotFound, "test not found");
}
return TypedResults.Json(Mappers.ToDto(detail), ApiJsonContext.Default.TestDto);
diff --git a/backend/src/Monitor.Backend.Application/Admin/EventService.cs b/backend/src/MoShiro.Backend.Application/Admin/EventService.cs
similarity index 91%
rename from backend/src/Monitor.Backend.Application/Admin/EventService.cs
rename to backend/src/MoShiro.Backend.Application/Admin/EventService.cs
index 1c4ff5d..0f59b3b 100644
--- a/backend/src/Monitor.Backend.Application/Admin/EventService.cs
+++ b/backend/src/MoShiro.Backend.Application/Admin/EventService.cs
@@ -1,6 +1,6 @@
using Fleet.Core;
-namespace Monitor.Backend.Application;
+namespace MoShiro.Backend.Application;
public sealed class EventService
{
diff --git a/backend/src/Monitor.Backend.Application/Admin/JoinTokenService.cs b/backend/src/MoShiro.Backend.Application/Admin/JoinTokenService.cs
similarity index 98%
rename from backend/src/Monitor.Backend.Application/Admin/JoinTokenService.cs
rename to backend/src/MoShiro.Backend.Application/Admin/JoinTokenService.cs
index 813bca0..382267e 100644
--- a/backend/src/Monitor.Backend.Application/Admin/JoinTokenService.cs
+++ b/backend/src/MoShiro.Backend.Application/Admin/JoinTokenService.cs
@@ -1,6 +1,6 @@
using Fleet.Core;
-namespace Monitor.Backend.Application;
+namespace MoShiro.Backend.Application;
public sealed record CreateJoinTokenRequest(string? Note, IReadOnlyList? Labels, bool AutoApprove, int MaxUses, int ExpiresInHours);
diff --git a/backend/src/Monitor.Backend.Application/Admin/OpsService.cs b/backend/src/MoShiro.Backend.Application/Admin/OpsService.cs
similarity index 75%
rename from backend/src/Monitor.Backend.Application/Admin/OpsService.cs
rename to backend/src/MoShiro.Backend.Application/Admin/OpsService.cs
index 13ebe0f..913b85a 100644
--- a/backend/src/Monitor.Backend.Application/Admin/OpsService.cs
+++ b/backend/src/MoShiro.Backend.Application/Admin/OpsService.cs
@@ -1,7 +1,7 @@
using System.Globalization;
using System.Text;
-namespace Monitor.Backend.Application;
+namespace MoShiro.Backend.Application;
/// 运维:健康检查和 Prometheus 指标(在线数、块入库速率、分析队列长度、重算进度、磁盘占用、SSE 连接数)。
public sealed class OpsService
@@ -40,17 +40,17 @@ public sealed class OpsService
}
RecomputeProgress progress = _recompute.Progress;
- Metric("monitor_agents_online", "Agents with an open control connection.", _gateway.OnlineAgents.Count);
- Metric("monitor_chunks_ingested_total", "Raw chunks stored.", _counters.ChunksIngested, "counter");
- Metric("monitor_chunks_duplicate_total", "Raw chunks received more than once.", _counters.ChunksDuplicate, "counter");
- Metric("monitor_chunks_discarded_total", "Raw chunks rejected as invalid.", _counters.ChunksDiscarded, "counter");
- Metric("monitor_ingest_bytes_total", "Bytes of raw chunks stored.", _counters.BytesIngested, "counter");
- Metric("monitor_windows_analyzed_total", "Minute windows computed.", _counters.WindowsAnalyzed, "counter");
- Metric("monitor_analysis_queue_length", "Minute windows waiting to be computed.", await _metrics.QueueLengthAsync(ct));
- Metric("monitor_recompute_windows_done", "Windows recomputed by the current backfill.", progress.WindowsDone);
- Metric("monitor_recompute_windows_total", "Windows to recompute in the current backfill.", progress.WindowsTotal);
- Metric("monitor_raw_bytes", "Disk used by raw segment files.", _raw.TotalBytes);
- Metric("monitor_sse_connections", "Open server-sent event connections.", _counters.SseConnections);
+ Metric("moshiro_agents_online", "Agents with an open control connection.", _gateway.OnlineAgents.Count);
+ Metric("moshiro_chunks_ingested_total", "Raw chunks stored.", _counters.ChunksIngested, "counter");
+ Metric("moshiro_chunks_duplicate_total", "Raw chunks received more than once.", _counters.ChunksDuplicate, "counter");
+ Metric("moshiro_chunks_discarded_total", "Raw chunks rejected as invalid.", _counters.ChunksDiscarded, "counter");
+ Metric("moshiro_ingest_bytes_total", "Bytes of raw chunks stored.", _counters.BytesIngested, "counter");
+ Metric("moshiro_windows_analyzed_total", "Minute windows computed.", _counters.WindowsAnalyzed, "counter");
+ Metric("moshiro_analysis_queue_length", "Minute windows waiting to be computed.", await _metrics.QueueLengthAsync(ct));
+ Metric("moshiro_recompute_windows_done", "Windows recomputed by the current backfill.", progress.WindowsDone);
+ Metric("moshiro_recompute_windows_total", "Windows to recompute in the current backfill.", progress.WindowsTotal);
+ Metric("moshiro_raw_bytes", "Disk used by raw segment files.", _raw.TotalBytes);
+ Metric("moshiro_sse_connections", "Open server-sent event connections.", _counters.SseConnections);
return text.ToString();
}
}
diff --git a/backend/src/Monitor.Backend.Application/Admin/RawBrowserService.cs b/backend/src/MoShiro.Backend.Application/Admin/RawBrowserService.cs
similarity index 88%
rename from backend/src/Monitor.Backend.Application/Admin/RawBrowserService.cs
rename to backend/src/MoShiro.Backend.Application/Admin/RawBrowserService.cs
index b69fa06..e3541b3 100644
--- a/backend/src/Monitor.Backend.Application/Admin/RawBrowserService.cs
+++ b/backend/src/MoShiro.Backend.Application/Admin/RawBrowserService.cs
@@ -1,7 +1,7 @@
using Fleet.Core;
-using Monitor.Protocol;
+using MoShiro.Protocol;
-namespace Monitor.Backend.Application;
+namespace MoShiro.Backend.Application;
/// 原始数据的检索与下载(管理员)。块过了保留期返回 raw_expired,从来不存在返回 chunk_not_found。
public sealed class RawBrowserService
@@ -26,7 +26,7 @@ public sealed class RawBrowserService
{
byte[]? bytes = await _raw.ReadAsync(meta, ct);
return bytes is null
- ? Result<(RawChunkMeta, byte[])>.Fail(MonitorErrors.RawExpired, "the raw data has expired")
+ ? Result<(RawChunkMeta, byte[])>.Fail(MoShiroErrors.RawExpired, "the raw data has expired")
: Result<(RawChunkMeta, byte[])>.Ok((meta, bytes));
}
@@ -34,8 +34,8 @@ public sealed class RawBrowserService
int days = await _settings.GetIntAsync(SettingsService.TestRawDays, ct);
long cutoff = _time.GetUtcNow().ToUnixTimeMilliseconds() - (days * 86_400_000L);
return ChunkTimestampMs(id.Value) is { } created && created < cutoff
- ? Result<(RawChunkMeta, byte[])>.Fail(MonitorErrors.RawExpired, "the raw data has expired")
- : Result<(RawChunkMeta, byte[])>.Fail(MonitorErrors.ChunkNotFound, "chunk not found");
+ ? Result<(RawChunkMeta, byte[])>.Fail(MoShiroErrors.RawExpired, "the raw data has expired")
+ : Result<(RawChunkMeta, byte[])>.Fail(MoShiroErrors.ChunkNotFound, "chunk not found");
}
/// UUIDv7 的前 48 位是毫秒时间戳。
diff --git a/backend/src/Monitor.Backend.Application/Admin/SettingsService.cs b/backend/src/MoShiro.Backend.Application/Admin/SettingsService.cs
similarity index 99%
rename from backend/src/Monitor.Backend.Application/Admin/SettingsService.cs
rename to backend/src/MoShiro.Backend.Application/Admin/SettingsService.cs
index eb05808..1577ec3 100644
--- a/backend/src/Monitor.Backend.Application/Admin/SettingsService.cs
+++ b/backend/src/MoShiro.Backend.Application/Admin/SettingsService.cs
@@ -2,7 +2,7 @@ using System.Globalization;
using System.Text.Json;
using Fleet.Core;
-namespace Monitor.Backend.Application;
+namespace MoShiro.Backend.Application;
public sealed record SettingSpec(string Key, string Type, string Default, long Min, long Max, string Description);
diff --git a/backend/src/Monitor.Backend.Application/Agents/AgentEventService.cs b/backend/src/MoShiro.Backend.Application/Agents/AgentEventService.cs
similarity index 93%
rename from backend/src/Monitor.Backend.Application/Agents/AgentEventService.cs
rename to backend/src/MoShiro.Backend.Application/Agents/AgentEventService.cs
index 957624c..8f50d8b 100644
--- a/backend/src/Monitor.Backend.Application/Agents/AgentEventService.cs
+++ b/backend/src/MoShiro.Backend.Application/Agents/AgentEventService.cs
@@ -1,9 +1,9 @@
using Fleet.Core;
-using Monitor.Protocol;
+using MoShiro.Protocol;
-namespace Monitor.Backend.Application;
+namespace MoShiro.Backend.Application;
-/// monitor.event:Agent 报告的事件(Probe 连上/断开、端点变化、时钟跳变、缺口、CPU 饱和)。
+/// moshiro.event:Agent 报告的事件(Probe 连上/断开、端点变化、时钟跳变、缺口、CPU 饱和)。
public sealed class AgentEventService
{
private readonly AgentRuntime _runtime;
diff --git a/backend/src/Monitor.Backend.Application/Agents/AgentRuntime.cs b/backend/src/MoShiro.Backend.Application/Agents/AgentRuntime.cs
similarity index 98%
rename from backend/src/Monitor.Backend.Application/Agents/AgentRuntime.cs
rename to backend/src/MoShiro.Backend.Application/Agents/AgentRuntime.cs
index 98e7738..6fe7134 100644
--- a/backend/src/Monitor.Backend.Application/Agents/AgentRuntime.cs
+++ b/backend/src/MoShiro.Backend.Application/Agents/AgentRuntime.cs
@@ -1,8 +1,8 @@
using System.Collections.Concurrent;
using Fleet.Core;
-using Monitor.Protocol;
+using MoShiro.Protocol;
-namespace Monitor.Backend.Application;
+namespace MoShiro.Backend.Application;
/// Agent 眼中的一个已连接 Probe(Agent 在事件和心跳里上报)。
public sealed record ConnectedProbeInfo(string Id, string? Version, string? Remote, long SinceMs);
diff --git a/backend/src/Monitor.Backend.Application/Agents/AgentService.cs b/backend/src/MoShiro.Backend.Application/Agents/AgentService.cs
similarity index 99%
rename from backend/src/Monitor.Backend.Application/Agents/AgentService.cs
rename to backend/src/MoShiro.Backend.Application/Agents/AgentService.cs
index 8c95cc2..5b09036 100644
--- a/backend/src/Monitor.Backend.Application/Agents/AgentService.cs
+++ b/backend/src/MoShiro.Backend.Application/Agents/AgentService.cs
@@ -1,9 +1,9 @@
using System.Text.RegularExpressions;
using Fleet.Core;
using Fleet.Server;
-using Monitor.Protocol;
+using MoShiro.Protocol;
-namespace Monitor.Backend.Application;
+namespace MoShiro.Backend.Application;
public sealed record AgentView(AgentRecord Agent, bool Online, IReadOnlyList Probes, AgentHeartbeatExtra? Heartbeat, int EndpointChanges, long? HeartbeatAtMs = null, HostSnapshot? Host = null)
{
diff --git a/backend/src/Monitor.Backend.Application/Agents/HostStatusService.cs b/backend/src/MoShiro.Backend.Application/Agents/HostStatusService.cs
similarity index 94%
rename from backend/src/Monitor.Backend.Application/Agents/HostStatusService.cs
rename to backend/src/MoShiro.Backend.Application/Agents/HostStatusService.cs
index 284fa15..2c7c0df 100644
--- a/backend/src/Monitor.Backend.Application/Agents/HostStatusService.cs
+++ b/backend/src/MoShiro.Backend.Application/Agents/HostStatusService.cs
@@ -1,10 +1,10 @@
using Fleet.Core;
-using Monitor.Protocol;
+using MoShiro.Protocol;
-namespace Monitor.Backend.Application;
+namespace MoShiro.Backend.Application;
///
-/// monitor.host:Agent 每隔几秒上报的主机资源占用快照。最新值放在内存里并实时推给订阅者;每个 Agent 每分钟存一个样本做历史。
+/// moshiro.host:Agent 每隔几秒上报的主机资源占用快照。最新值放在内存里并实时推给订阅者;每个 Agent 每分钟存一个样本做历史。
/// 快照里没有 CPU 型号、主机名、网卡名和 IP(Agent 根本不采集它们)。
///
public sealed class HostStatusService
diff --git a/backend/src/Monitor.Backend.Application/Agents/LinkService.cs b/backend/src/MoShiro.Backend.Application/Agents/LinkService.cs
similarity index 98%
rename from backend/src/Monitor.Backend.Application/Agents/LinkService.cs
rename to backend/src/MoShiro.Backend.Application/Agents/LinkService.cs
index 63347d9..0ee14ea 100644
--- a/backend/src/Monitor.Backend.Application/Agents/LinkService.cs
+++ b/backend/src/MoShiro.Backend.Application/Agents/LinkService.cs
@@ -1,4 +1,4 @@
-namespace Monitor.Backend.Application;
+namespace MoShiro.Backend.Application;
/// 某一时刻的「线路」开关:自动连接的总开关,加上每一对(Probe,Agent)的手动设置。
public sealed class LinkSnapshot
diff --git a/backend/src/Monitor.Backend.Application/Agents/MonitorFleetHooks.cs b/backend/src/MoShiro.Backend.Application/Agents/MonitorFleetHooks.cs
similarity index 90%
rename from backend/src/Monitor.Backend.Application/Agents/MonitorFleetHooks.cs
rename to backend/src/MoShiro.Backend.Application/Agents/MonitorFleetHooks.cs
index 380b9e6..492bc1f 100644
--- a/backend/src/Monitor.Backend.Application/Agents/MonitorFleetHooks.cs
+++ b/backend/src/MoShiro.Backend.Application/Agents/MonitorFleetHooks.cs
@@ -2,17 +2,17 @@ using System.Text.Json;
using Fleet.Core;
using Fleet.Rpc;
using Fleet.Server;
-using Monitor.Protocol;
+using MoShiro.Protocol;
-namespace Monitor.Backend.Application;
+namespace MoShiro.Backend.Application;
-/// Monitor 在 Fleet 之上的接入点:注册之后补全公开地址与端口。
-public sealed class MonitorEnrollmentHook : IEnrollmentHook
+/// MoShiro 在 Fleet 之上的接入点:注册之后补全公开地址与端口。
+public sealed class MoShiroEnrollmentHook : IEnrollmentHook
{
private readonly IAgentStore _agents;
private readonly AgentService _service;
- public MonitorEnrollmentHook(IAgentStore agents, AgentService service)
+ public MoShiroEnrollmentHook(IAgentStore agents, AgentService service)
{
_agents = agents;
_service = service;
@@ -25,7 +25,7 @@ public sealed class MonitorEnrollmentHook : IEnrollmentHook
{
try
{
- meta = raw.Deserialize(MonitorJsonContext.Default.AgentEnrollMeta) ?? meta;
+ meta = raw.Deserialize(MoShiroJsonContext.Default.AgentEnrollMeta) ?? meta;
}
catch (JsonException)
{
@@ -44,7 +44,7 @@ public sealed class MonitorEnrollmentHook : IEnrollmentHook
}
/// 节点上线、下线、hello、心跳:更新运行时状态,补全 Agent 信息,并推送给 SSE。
-public sealed class MonitorNodeEventSink : INodeEventSink
+public sealed class MoShiroNodeEventSink : INodeEventSink
{
private readonly IAgentStore _agents;
private readonly AgentRuntime _runtime;
@@ -54,7 +54,7 @@ public sealed class MonitorNodeEventSink : INodeEventSink
private readonly NodeInfoService _nodes;
private readonly ReleaseService _releases;
- public MonitorNodeEventSink(IAgentStore agents, AgentRuntime runtime, IEventStore events, LiveHub live, AgentService service, NodeInfoService nodes, ReleaseService releases)
+ public MoShiroNodeEventSink(IAgentStore agents, AgentRuntime runtime, IEventStore events, LiveHub live, AgentService service, NodeInfoService nodes, ReleaseService releases)
{
_releases = releases;
_nodes = nodes;
@@ -93,7 +93,7 @@ public sealed class MonitorNodeEventSink : INodeEventSink
try
{
AgentRuntimeState state = _runtime.Get(id);
- AgentHeartbeatExtra? beat = extra.Deserialize(MonitorJsonContext.Default.AgentHeartbeatExtra);
+ AgentHeartbeatExtra? beat = extra.Deserialize(MoShiroJsonContext.Default.AgentHeartbeatExtra);
state.LastHeartbeat = beat;
state.LastHeartbeatAtMs = nodeEvent.AtMs;
_releases.RecordStatus(id, beat?.Update);
@@ -128,7 +128,7 @@ public sealed class MonitorNodeEventSink : INodeEventSink
{
try
{
- ProbeHelloMeta? meta = raw.Deserialize(MonitorJsonContext.Default.ProbeHelloMeta);
+ ProbeHelloMeta? meta = raw.Deserialize(MoShiroJsonContext.Default.ProbeHelloMeta);
await _nodes.SetPlatformAsync(id.Value, NodeKinds.Probe, meta?.Platform, ct);
}
catch (JsonException)
@@ -146,7 +146,7 @@ public sealed class MonitorNodeEventSink : INodeEventSink
case NodeEventKind.Heartbeat when nodeEvent.Extra is { } extra:
try
{
- _releases.RecordStatus(id, extra.Deserialize(MonitorJsonContext.Default.ProbeHeartbeatExtra)?.Update);
+ _releases.RecordStatus(id, extra.Deserialize(MoShiroJsonContext.Default.ProbeHeartbeatExtra)?.Update);
}
catch (JsonException)
{
@@ -162,9 +162,9 @@ public sealed class MonitorNodeEventSink : INodeEventSink
var kinds = new List();
foreach (string capability in hello.Capabilities)
{
- if (capability.StartsWith(MonitorCapabilities.KindsPrefix, StringComparison.Ordinal))
+ if (capability.StartsWith(MoShiroCapabilities.KindsPrefix, StringComparison.Ordinal))
{
- kinds.AddRange(capability[MonitorCapabilities.KindsPrefix.Length..].Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries));
+ kinds.AddRange(capability[MoShiroCapabilities.KindsPrefix.Length..].Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries));
}
}
@@ -173,7 +173,7 @@ public sealed class MonitorNodeEventSink : INodeEventSink
{
try
{
- meta = raw.Deserialize(MonitorJsonContext.Default.AgentHelloMeta) ?? meta;
+ meta = raw.Deserialize(MoShiroJsonContext.Default.AgentHelloMeta) ?? meta;
}
catch (JsonException)
{
diff --git a/backend/src/Monitor.Backend.Application/Agents/ProbeService.cs b/backend/src/MoShiro.Backend.Application/Agents/ProbeService.cs
similarity index 93%
rename from backend/src/Monitor.Backend.Application/Agents/ProbeService.cs
rename to backend/src/MoShiro.Backend.Application/Agents/ProbeService.cs
index 8b24e6c..e47df2b 100644
--- a/backend/src/Monitor.Backend.Application/Agents/ProbeService.cs
+++ b/backend/src/MoShiro.Backend.Application/Agents/ProbeService.cs
@@ -2,9 +2,9 @@ using System.Text.RegularExpressions;
using Fleet.Core;
using Fleet.Identity;
using Fleet.Server;
-using Monitor.Protocol;
+using MoShiro.Protocol;
-namespace Monitor.Backend.Application;
+namespace MoShiro.Backend.Application;
/// 本地硬上限:写在 Probe 本机的配置里,面板无法修改(在路由器上建议调低)。
public sealed record ProbeLimits(double MaxTestMbps, long MaxTotalPps);
@@ -56,7 +56,7 @@ public sealed partial class ProbeService
if ((await _probes.ListAsync(ct)).Any(p => string.Equals(p.Name, finalName, StringComparison.OrdinalIgnoreCase)))
{
- return Result.Fail(MonitorErrors.NameConflict, $"a probe named {finalName} already exists");
+ return Result.Fail(MoShiroErrors.NameConflict, $"a probe named {finalName} already exists");
}
using NodeIdentity identity = NodeIdentity.Generate();
@@ -80,7 +80,7 @@ public sealed partial class ProbeService
{
if (await _probes.GetAsync(id, ct) is not { } probe)
{
- return Result.Fail(MonitorErrors.ProbeNotFound, "probe not found");
+ return Result.Fail(MoShiroErrors.ProbeNotFound, "probe not found");
}
string trimmed = name.Trim();
@@ -91,7 +91,7 @@ public sealed partial class ProbeService
if ((await _probes.ListAsync(ct)).Any(p => p.Id != id && string.Equals(p.Name, trimmed, StringComparison.OrdinalIgnoreCase)))
{
- return Result.Fail(MonitorErrors.NameConflict, $"a probe named {trimmed} already exists");
+ return Result.Fail(MoShiroErrors.NameConflict, $"a probe named {trimmed} already exists");
}
await _probes.SaveAsync(probe with { Name = trimmed }, ct);
@@ -103,12 +103,12 @@ public sealed partial class ProbeService
{
if (await _probes.GetAsync(id, ct) is not { } probe)
{
- return Result.Fail(MonitorErrors.ProbeNotFound, "probe not found");
+ return Result.Fail(MoShiroErrors.ProbeNotFound, "probe not found");
}
if (probe.RevokedAtMs is not null)
{
- return Result.Fail(MonitorErrors.ProbeRevoked, "a revoked probe cannot get a new key; create a new probe instead");
+ return Result.Fail(MoShiroErrors.ProbeRevoked, "a revoked probe cannot get a new key; create a new probe instead");
}
using NodeIdentity identity = NodeIdentity.Generate();
@@ -124,7 +124,7 @@ public sealed partial class ProbeService
{
if (await _probes.GetAsync(id, ct) is null)
{
- return Result.Fail(MonitorErrors.ProbeNotFound, "probe not found");
+ return Result.Fail(MoShiroErrors.ProbeNotFound, "probe not found");
}
await _probes.RevokeAsync(id, _time.GetUtcNow().ToUnixTimeMilliseconds(), ct);
@@ -151,12 +151,12 @@ public sealed partial class ProbeService
{
if (await _probes.GetAsync(probeId, ct) is null)
{
- return Result.Fail(MonitorErrors.ProbeNotFound, "probe not found");
+ return Result.Fail(MoShiroErrors.ProbeNotFound, "probe not found");
}
if (await _agents.GetAsync(agentId, ct) is null)
{
- return Result.Fail(MonitorErrors.AgentNotFound, "agent not found");
+ return Result.Fail(MoShiroErrors.AgentNotFound, "agent not found");
}
return await _gateway.DisconnectProbeAsync(agentId, new ProbeId(probeId), ct);
diff --git a/backend/src/Monitor.Backend.Application/Analysis/AnalysisScheduler.cs b/backend/src/MoShiro.Backend.Application/Analysis/AnalysisScheduler.cs
similarity index 98%
rename from backend/src/Monitor.Backend.Application/Analysis/AnalysisScheduler.cs
rename to backend/src/MoShiro.Backend.Application/Analysis/AnalysisScheduler.cs
index e29a1f1..3259509 100644
--- a/backend/src/Monitor.Backend.Application/Analysis/AnalysisScheduler.cs
+++ b/backend/src/MoShiro.Backend.Application/Analysis/AnalysisScheduler.cs
@@ -1,9 +1,9 @@
using Fleet.Core;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
-using Monitor.Backend.Analysis;
+using MoShiro.Backend.Analysis;
-namespace Monitor.Backend.Application;
+namespace MoShiro.Backend.Application;
///
/// 持久路径:分钟窗口就绪(窗口结束 + 宽限,或迟到的块到达)之后从原始块计算 → 写入 metric_1m → 标记降采样脏桶;
diff --git a/backend/src/Monitor.Backend.Application/Analysis/MetricRecompute.cs b/backend/src/MoShiro.Backend.Application/Analysis/MetricRecompute.cs
similarity index 98%
rename from backend/src/Monitor.Backend.Application/Analysis/MetricRecompute.cs
rename to backend/src/MoShiro.Backend.Application/Analysis/MetricRecompute.cs
index 0214343..50893d8 100644
--- a/backend/src/Monitor.Backend.Application/Analysis/MetricRecompute.cs
+++ b/backend/src/MoShiro.Backend.Application/Analysis/MetricRecompute.cs
@@ -1,9 +1,9 @@
using Fleet.Core;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
-using Monitor.Backend.Analysis;
+using MoShiro.Backend.Analysis;
-namespace Monitor.Backend.Application;
+namespace MoShiro.Backend.Application;
public sealed record RecomputeProgress(string State, IReadOnlyList Metrics, long WindowsDone, long WindowsTotal, long? FromMs, long? ToMs);
diff --git a/backend/src/Monitor.Backend.Application/Analysis/WindowComputer.cs b/backend/src/MoShiro.Backend.Application/Analysis/WindowComputer.cs
similarity index 95%
rename from backend/src/Monitor.Backend.Application/Analysis/WindowComputer.cs
rename to backend/src/MoShiro.Backend.Application/Analysis/WindowComputer.cs
index f5328f2..0d33caa 100644
--- a/backend/src/Monitor.Backend.Application/Analysis/WindowComputer.cs
+++ b/backend/src/MoShiro.Backend.Application/Analysis/WindowComputer.cs
@@ -1,8 +1,8 @@
using Fleet.Core;
-using Monitor.Backend.Analysis;
-using Monitor.Protocol;
+using MoShiro.Backend.Analysis;
+using MoShiro.Protocol;
-namespace Monitor.Backend.Application;
+namespace MoShiro.Backend.Application;
///
/// 从原始块重新计算一个窗口(持久路径与回填共用):读取与窗口重叠的块 → 评估 → 取出窗口对应的累加器。
diff --git a/backend/src/Monitor.Backend.Application/ApplicationServiceCollectionExtensions.cs b/backend/src/MoShiro.Backend.Application/ApplicationServiceCollectionExtensions.cs
similarity index 91%
rename from backend/src/Monitor.Backend.Application/ApplicationServiceCollectionExtensions.cs
rename to backend/src/MoShiro.Backend.Application/ApplicationServiceCollectionExtensions.cs
index 2ad95a9..569f932 100644
--- a/backend/src/Monitor.Backend.Application/ApplicationServiceCollectionExtensions.cs
+++ b/backend/src/MoShiro.Backend.Application/ApplicationServiceCollectionExtensions.cs
@@ -2,7 +2,7 @@ using Fleet.Server;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
-namespace Monitor.Backend.Application;
+namespace MoShiro.Backend.Application;
public static class ApplicationServiceCollectionExtensions
{
@@ -10,7 +10,7 @@ public static class ApplicationServiceCollectionExtensions
/// 注册 Application 层的全部服务。需要事先注册端口的实现(存储、)和 。
/// 后台任务按这里的顺序启动: 必须在最前面。
///
- public static IServiceCollection AddMonitorApplication(this IServiceCollection services, BackendOptions options)
+ public static IServiceCollection AddMoShiroApplication(this IServiceCollection services, BackendOptions options)
{
services.AddSingleton(options);
services.AddHostedService();
@@ -47,8 +47,8 @@ public static class ApplicationServiceCollectionExtensions
services.AddSingleton();
services.AddSingleton();
- services.AddSingleton();
- services.AddSingleton();
+ services.AddSingleton();
+ services.AddSingleton();
services.AddSingleton();
services.AddHostedService(provider => provider.GetRequiredService());
diff --git a/backend/src/Monitor.Backend.Application/Auth/AuthModels.cs b/backend/src/MoShiro.Backend.Application/Auth/AuthModels.cs
similarity index 96%
rename from backend/src/Monitor.Backend.Application/Auth/AuthModels.cs
rename to backend/src/MoShiro.Backend.Application/Auth/AuthModels.cs
index 9caf89d..9f438c5 100644
--- a/backend/src/Monitor.Backend.Application/Auth/AuthModels.cs
+++ b/backend/src/MoShiro.Backend.Application/Auth/AuthModels.cs
@@ -1,4 +1,4 @@
-namespace Monitor.Backend.Application;
+namespace MoShiro.Backend.Application;
public enum PrincipalKind
{
diff --git a/backend/src/Monitor.Backend.Application/Auth/AuthService.cs b/backend/src/MoShiro.Backend.Application/Auth/AuthService.cs
similarity index 97%
rename from backend/src/Monitor.Backend.Application/Auth/AuthService.cs
rename to backend/src/MoShiro.Backend.Application/Auth/AuthService.cs
index 81e4086..30cad19 100644
--- a/backend/src/Monitor.Backend.Application/Auth/AuthService.cs
+++ b/backend/src/MoShiro.Backend.Application/Auth/AuthService.cs
@@ -2,9 +2,9 @@ using System.Security.Cryptography;
using System.Text;
using System.Text.RegularExpressions;
using Fleet.Core;
-using Monitor.Protocol;
+using MoShiro.Protocol;
-namespace Monitor.Backend.Application;
+namespace MoShiro.Backend.Application;
/// 面板用户、Cookie 会话、API 令牌。密码用 PBKDF2-SHA256,令牌和会话只保存 SHA-256。
public sealed partial class AuthService
@@ -34,7 +34,7 @@ public sealed partial class AuthService
byte[] hash = Hash(password, salt, iterations);
if (user is null || !CryptographicOperations.FixedTimeEquals(hash, user.PasswordHash))
{
- return Result.Fail(MonitorErrors.Unauthorized, "invalid credentials");
+ return Result.Fail(MoShiroErrors.Unauthorized, "invalid credentials");
}
byte[] token = RandomNumberGenerator.GetBytes(32);
@@ -111,7 +111,7 @@ public sealed partial class AuthService
var user = new UserRecord(Ulid.NewPrefixed("usr", _time), username, Hash(password, salt, _options.Pbkdf2Iterations), salt, _options.Pbkdf2Iterations, _time.GetUtcNow().ToUnixTimeMilliseconds());
return await _store.CreateUserAsync(user, ct)
? Result.Ok(user)
- : Result.Fail(MonitorErrors.NameConflict, "username already exists");
+ : Result.Fail(MoShiroErrors.NameConflict, "username already exists");
}
public async ValueTask> ChangePasswordAsync(string userId, string newPassword, CancellationToken ct)
diff --git a/backend/src/Monitor.Backend.Application/Auth/LoginRateLimiter.cs b/backend/src/MoShiro.Backend.Application/Auth/LoginRateLimiter.cs
similarity index 97%
rename from backend/src/Monitor.Backend.Application/Auth/LoginRateLimiter.cs
rename to backend/src/MoShiro.Backend.Application/Auth/LoginRateLimiter.cs
index 134cce6..ca7fede 100644
--- a/backend/src/Monitor.Backend.Application/Auth/LoginRateLimiter.cs
+++ b/backend/src/MoShiro.Backend.Application/Auth/LoginRateLimiter.cs
@@ -1,6 +1,6 @@
using System.Collections.Concurrent;
-namespace Monitor.Backend.Application;
+namespace MoShiro.Backend.Application;
/// 登录限流:每个来源在滑动的一分钟内最多尝试若干次。
public sealed class LoginRateLimiter
diff --git a/backend/src/Monitor.Backend.Application/BackendCounters.cs b/backend/src/MoShiro.Backend.Application/BackendCounters.cs
similarity index 97%
rename from backend/src/Monitor.Backend.Application/BackendCounters.cs
rename to backend/src/MoShiro.Backend.Application/BackendCounters.cs
index 032831f..28c1036 100644
--- a/backend/src/Monitor.Backend.Application/BackendCounters.cs
+++ b/backend/src/MoShiro.Backend.Application/BackendCounters.cs
@@ -1,4 +1,4 @@
-namespace Monitor.Backend.Application;
+namespace MoShiro.Backend.Application;
/// 进程内计数器,用于 /metrics(Prometheus 格式)。
public sealed class BackendCounters
diff --git a/backend/src/Monitor.Backend.Application/BackendOptions.cs b/backend/src/MoShiro.Backend.Application/BackendOptions.cs
similarity index 96%
rename from backend/src/Monitor.Backend.Application/BackendOptions.cs
rename to backend/src/MoShiro.Backend.Application/BackendOptions.cs
index f38727d..4fb34a2 100644
--- a/backend/src/Monitor.Backend.Application/BackendOptions.cs
+++ b/backend/src/MoShiro.Backend.Application/BackendOptions.cs
@@ -1,9 +1,9 @@
-namespace Monitor.Backend.Application;
+namespace MoShiro.Backend.Application;
/// Backend 的可调参数(保留期等也可以通过 settings 改,这里是默认值与硬上限)。
public sealed class BackendOptions
{
- /// 数据目录:monitor.db 与 raw/。
+ /// 数据目录:moshiro.db 与 raw/。
public string DataDirectory { get; set; } = "data";
/// 面板的对外地址(用于生成安装命令)。
diff --git a/backend/src/Monitor.Backend.Application/Ingest/IngestService.cs b/backend/src/MoShiro.Backend.Application/Ingest/IngestService.cs
similarity index 98%
rename from backend/src/Monitor.Backend.Application/Ingest/IngestService.cs
rename to backend/src/MoShiro.Backend.Application/Ingest/IngestService.cs
index 4bbc381..5b6b8ae 100644
--- a/backend/src/Monitor.Backend.Application/Ingest/IngestService.cs
+++ b/backend/src/MoShiro.Backend.Application/Ingest/IngestService.cs
@@ -1,9 +1,9 @@
using Fleet.Core;
using Microsoft.Extensions.Logging;
-using Monitor.Backend.Analysis;
-using Monitor.Protocol;
+using MoShiro.Backend.Analysis;
+using MoShiro.Protocol;
-namespace Monitor.Backend.Application;
+namespace MoShiro.Backend.Application;
///
/// 和 都会让节点把消息从发件箱里移除。
diff --git a/backend/src/Monitor.Backend.Application/Live/HotLayer.cs b/backend/src/MoShiro.Backend.Application/Live/HotLayer.cs
similarity index 97%
rename from backend/src/Monitor.Backend.Application/Live/HotLayer.cs
rename to backend/src/MoShiro.Backend.Application/Live/HotLayer.cs
index 2b921b7..747cf7d 100644
--- a/backend/src/Monitor.Backend.Application/Live/HotLayer.cs
+++ b/backend/src/MoShiro.Backend.Application/Live/HotLayer.cs
@@ -1,9 +1,9 @@
using System.Collections.Concurrent;
using Fleet.Core;
-using Monitor.Backend.Analysis;
-using Monitor.Protocol;
+using MoShiro.Backend.Analysis;
+using MoShiro.Protocol;
-namespace Monitor.Backend.Application;
+namespace MoShiro.Backend.Application;
///
/// 1 秒精度的内存热层:最近 1 小时的累加器。桶以 编码后的字节保存,
diff --git a/backend/src/Monitor.Backend.Application/Live/HotLayerBackfill.cs b/backend/src/MoShiro.Backend.Application/Live/HotLayerBackfill.cs
similarity index 97%
rename from backend/src/Monitor.Backend.Application/Live/HotLayerBackfill.cs
rename to backend/src/MoShiro.Backend.Application/Live/HotLayerBackfill.cs
index 73dd177..917509c 100644
--- a/backend/src/Monitor.Backend.Application/Live/HotLayerBackfill.cs
+++ b/backend/src/MoShiro.Backend.Application/Live/HotLayerBackfill.cs
@@ -1,9 +1,9 @@
using Fleet.Core;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
-using Monitor.Protocol;
+using MoShiro.Protocol;
-namespace Monitor.Backend.Application;
+namespace MoShiro.Backend.Application;
/// 重启后热层为空:从原始块回填最近 1 小时(低优先级、逐块让出)。完成之前查询规划器不会选用热层。
public sealed partial class HotLayerBackfill : BackgroundService
diff --git a/backend/src/Monitor.Backend.Application/Live/LiveHub.cs b/backend/src/MoShiro.Backend.Application/Live/LiveHub.cs
similarity index 97%
rename from backend/src/Monitor.Backend.Application/Live/LiveHub.cs
rename to backend/src/MoShiro.Backend.Application/Live/LiveHub.cs
index f0dc7cc..7f5a1d2 100644
--- a/backend/src/Monitor.Backend.Application/Live/LiveHub.cs
+++ b/backend/src/MoShiro.Backend.Application/Live/LiveHub.cs
@@ -1,9 +1,9 @@
using System.Collections.Concurrent;
using System.Threading.Channels;
using Fleet.Core;
-using Monitor.Protocol;
+using MoShiro.Protocol;
-namespace Monitor.Backend.Application;
+namespace MoShiro.Backend.Application;
/// 发布到 SSE 订阅者的信号。SSE 只负责“更快地获得变化”,推送的内容都能由 REST 查询重建。
public abstract record LiveSignal;
diff --git a/backend/src/Monitor.Backend.Application/Monitor.Backend.Application.csproj b/backend/src/MoShiro.Backend.Application/MoShiro.Backend.Application.csproj
similarity index 81%
rename from backend/src/Monitor.Backend.Application/Monitor.Backend.Application.csproj
rename to backend/src/MoShiro.Backend.Application/MoShiro.Backend.Application.csproj
index 611afa2..02dcdf9 100644
--- a/backend/src/Monitor.Backend.Application/Monitor.Backend.Application.csproj
+++ b/backend/src/MoShiro.Backend.Application/MoShiro.Backend.Application.csproj
@@ -4,7 +4,7 @@
-
+
diff --git a/backend/src/Monitor.Backend.Application/Models/AgentModels.cs b/backend/src/MoShiro.Backend.Application/Models/AgentModels.cs
similarity index 94%
rename from backend/src/Monitor.Backend.Application/Models/AgentModels.cs
rename to backend/src/MoShiro.Backend.Application/Models/AgentModels.cs
index 2b7dd90..b44c53e 100644
--- a/backend/src/Monitor.Backend.Application/Models/AgentModels.cs
+++ b/backend/src/MoShiro.Backend.Application/Models/AgentModels.cs
@@ -1,7 +1,7 @@
using Fleet.Core;
using Fleet.Server;
-namespace Monitor.Backend.Application;
+namespace MoShiro.Backend.Application;
public sealed record AgentRecord(
NodeId Id,
@@ -45,7 +45,7 @@ public sealed record AgentHello(
int? ProbeTcpPort,
IReadOnlyList? ProbeUdpPorts);
-/// 注册之后 Monitor 的补充:公开地址和端口。
+/// 注册之后 MoShiro 的补充:公开地址和端口。
public sealed record AgentEnrollment(string PublicHost, int ProbeTcpPort, IReadOnlyList ProbeUdpPorts, IReadOnlyList Kinds);
public sealed record JoinTokenInfo(
diff --git a/backend/src/Monitor.Backend.Application/Models/RawModels.cs b/backend/src/MoShiro.Backend.Application/Models/RawModels.cs
similarity index 96%
rename from backend/src/Monitor.Backend.Application/Models/RawModels.cs
rename to backend/src/MoShiro.Backend.Application/Models/RawModels.cs
index 4f2be36..52f133b 100644
--- a/backend/src/Monitor.Backend.Application/Models/RawModels.cs
+++ b/backend/src/MoShiro.Backend.Application/Models/RawModels.cs
@@ -1,7 +1,7 @@
using Fleet.Core;
-using Monitor.Protocol;
+using MoShiro.Protocol;
-namespace Monitor.Backend.Application;
+namespace MoShiro.Backend.Application;
/// 原始块的索引信息(块本身在段文件里)。
public sealed record RawChunkMeta(
diff --git a/backend/src/Monitor.Backend.Application/Models/TaskAndTestModels.cs b/backend/src/MoShiro.Backend.Application/Models/TaskAndTestModels.cs
similarity index 93%
rename from backend/src/Monitor.Backend.Application/Models/TaskAndTestModels.cs
rename to backend/src/MoShiro.Backend.Application/Models/TaskAndTestModels.cs
index 7e732a1..6502332 100644
--- a/backend/src/Monitor.Backend.Application/Models/TaskAndTestModels.cs
+++ b/backend/src/MoShiro.Backend.Application/Models/TaskAndTestModels.cs
@@ -1,8 +1,8 @@
using System.Text.Json;
using Fleet.Core;
-using Monitor.Protocol;
+using MoShiro.Protocol;
-namespace Monitor.Backend.Application;
+namespace MoShiro.Backend.Application;
public sealed record TaskRecord(
TaskId Id,
diff --git a/backend/src/Monitor.Backend.Application/Nodes/IspClassifier.cs b/backend/src/MoShiro.Backend.Application/Nodes/IspClassifier.cs
similarity index 98%
rename from backend/src/Monitor.Backend.Application/Nodes/IspClassifier.cs
rename to backend/src/MoShiro.Backend.Application/Nodes/IspClassifier.cs
index 46205d9..c0c45c4 100644
--- a/backend/src/Monitor.Backend.Application/Nodes/IspClassifier.cs
+++ b/backend/src/MoShiro.Backend.Application/Nodes/IspClassifier.cs
@@ -1,4 +1,4 @@
-namespace Monitor.Backend.Application;
+namespace MoShiro.Backend.Application;
///
/// 把「ASN 和组织名」归成几个常见的国内运营商:mobile / telecom / unicom / broadnet;别的是 other(显示组织名)。
diff --git a/backend/src/Monitor.Backend.Application/Nodes/NodeInfo.cs b/backend/src/MoShiro.Backend.Application/Nodes/NodeInfo.cs
similarity index 97%
rename from backend/src/Monitor.Backend.Application/Nodes/NodeInfo.cs
rename to backend/src/MoShiro.Backend.Application/Nodes/NodeInfo.cs
index b5212d1..af23b65 100644
--- a/backend/src/Monitor.Backend.Application/Nodes/NodeInfo.cs
+++ b/backend/src/MoShiro.Backend.Application/Nodes/NodeInfo.cs
@@ -1,4 +1,4 @@
-namespace Monitor.Backend.Application;
+namespace MoShiro.Backend.Application;
///
/// 一个节点(Agent 或 Probe)用来展示的信息:系统和架构、国家、运营商,以及它自己上报的构建信息(版本、tag、提交、构建时间)。
diff --git a/backend/src/Monitor.Backend.Application/Nodes/NodeInfoService.cs b/backend/src/MoShiro.Backend.Application/Nodes/NodeInfoService.cs
similarity index 99%
rename from backend/src/Monitor.Backend.Application/Nodes/NodeInfoService.cs
rename to backend/src/MoShiro.Backend.Application/Nodes/NodeInfoService.cs
index 9a9d3ea..09930ab 100644
--- a/backend/src/Monitor.Backend.Application/Nodes/NodeInfoService.cs
+++ b/backend/src/MoShiro.Backend.Application/Nodes/NodeInfoService.cs
@@ -1,9 +1,9 @@
using System.Collections.Concurrent;
using System.Net;
using System.Net.Sockets;
-using Monitor.Protocol;
+using MoShiro.Protocol;
-namespace Monitor.Backend.Application;
+namespace MoShiro.Backend.Application;
///
/// 节点的展示信息:系统和架构(节点自报),国家和运营商(Backend 用节点的来源地址查一次)。
diff --git a/backend/src/Monitor.Backend.Application/Ports/IAgentGateway.cs b/backend/src/MoShiro.Backend.Application/Ports/IAgentGateway.cs
similarity index 96%
rename from backend/src/Monitor.Backend.Application/Ports/IAgentGateway.cs
rename to backend/src/MoShiro.Backend.Application/Ports/IAgentGateway.cs
index a022297..ed855df 100644
--- a/backend/src/Monitor.Backend.Application/Ports/IAgentGateway.cs
+++ b/backend/src/MoShiro.Backend.Application/Ports/IAgentGateway.cs
@@ -1,7 +1,7 @@
using Fleet.Core;
-using Monitor.Protocol;
+using MoShiro.Protocol;
-namespace Monitor.Backend.Application;
+namespace MoShiro.Backend.Application;
///
/// Application 通往 Agent 连接的端口(由 Gateway 实现):下发状态变化、发起按需测试。
diff --git a/backend/src/Monitor.Backend.Application/Ports/IAuthStore.cs b/backend/src/MoShiro.Backend.Application/Ports/IAuthStore.cs
similarity index 97%
rename from backend/src/Monitor.Backend.Application/Ports/IAuthStore.cs
rename to backend/src/MoShiro.Backend.Application/Ports/IAuthStore.cs
index 02c7e35..235dcf3 100644
--- a/backend/src/Monitor.Backend.Application/Ports/IAuthStore.cs
+++ b/backend/src/MoShiro.Backend.Application/Ports/IAuthStore.cs
@@ -1,4 +1,4 @@
-namespace Monitor.Backend.Application;
+namespace MoShiro.Backend.Application;
public sealed record UserRecord(string Id, string Username, byte[] PasswordHash, byte[] PasswordSalt, int Iterations, long CreatedAtMs);
diff --git a/backend/src/Monitor.Backend.Application/Ports/StorePorts.cs b/backend/src/MoShiro.Backend.Application/Ports/StorePorts.cs
similarity index 98%
rename from backend/src/Monitor.Backend.Application/Ports/StorePorts.cs
rename to backend/src/MoShiro.Backend.Application/Ports/StorePorts.cs
index b600021..a126798 100644
--- a/backend/src/Monitor.Backend.Application/Ports/StorePorts.cs
+++ b/backend/src/MoShiro.Backend.Application/Ports/StorePorts.cs
@@ -1,8 +1,8 @@
using Fleet.Core;
using Fleet.Server;
-using Monitor.Protocol;
+using MoShiro.Protocol;
-namespace Monitor.Backend.Application;
+namespace MoShiro.Backend.Application;
public interface IAgentStore
{
@@ -137,7 +137,7 @@ public interface IEventStore
/// 主机资源占用的历史:每个 Agent 每分钟一个样本。
public interface IHostStore
{
- ValueTask SaveAsync(NodeId agent, long minuteMs, Monitor.Protocol.HostSnapshot snapshot, CancellationToken ct);
+ ValueTask SaveAsync(NodeId agent, long minuteMs, MoShiro.Protocol.HostSnapshot snapshot, CancellationToken ct);
ValueTask> ReadAsync(NodeId agent, long fromMs, long toMs, CancellationToken ct);
diff --git a/backend/src/Monitor.Backend.Application/Query/Bucketing.cs b/backend/src/MoShiro.Backend.Application/Query/Bucketing.cs
similarity index 96%
rename from backend/src/Monitor.Backend.Application/Query/Bucketing.cs
rename to backend/src/MoShiro.Backend.Application/Query/Bucketing.cs
index b959fd3..0eaae6d 100644
--- a/backend/src/Monitor.Backend.Application/Query/Bucketing.cs
+++ b/backend/src/MoShiro.Backend.Application/Query/Bucketing.cs
@@ -1,6 +1,6 @@
-using Monitor.Backend.Analysis;
+using MoShiro.Backend.Analysis;
-namespace Monitor.Backend.Application;
+namespace MoShiro.Backend.Application;
/// 把源行合并成查询步长的桶:计数相加、直方图逐桶相加,所以结果是精确的,不是各点的平均。
public sealed class BucketedRows
diff --git a/backend/src/Monitor.Backend.Application/Query/Lines.cs b/backend/src/MoShiro.Backend.Application/Query/Lines.cs
similarity index 92%
rename from backend/src/Monitor.Backend.Application/Query/Lines.cs
rename to backend/src/MoShiro.Backend.Application/Query/Lines.cs
index 53240c1..8c07a0b 100644
--- a/backend/src/Monitor.Backend.Application/Query/Lines.cs
+++ b/backend/src/MoShiro.Backend.Application/Query/Lines.cs
@@ -1,7 +1,7 @@
using Fleet.Core;
-using Monitor.Protocol;
+using MoShiro.Protocol;
-namespace Monitor.Backend.Application;
+namespace MoShiro.Backend.Application;
/// 一条线路 = 一对(Agent,Probe)。存储里它的序列是 line:<probe_id>,对外的 id 是 <agent_id>~<probe_id>。
public readonly record struct LineKey(NodeId Agent, ProbeId Probe)
@@ -68,7 +68,7 @@ public sealed class LineService
{
if (!LineKey.TryParse(id, out LineKey key))
{
- return Result.Fail(MonitorErrors.AgentNotFound, "line not found");
+ return Result.Fail(MoShiroErrors.AgentNotFound, "line not found");
}
agentPart = key.Agent.Value;
@@ -78,7 +78,7 @@ public sealed class LineService
AgentView? agent = await _agents.GetAsync(new NodeId(agentPart), ct);
if (agent is null)
{
- return Result.Fail(MonitorErrors.AgentNotFound, "line not found");
+ return Result.Fail(MoShiroErrors.AgentNotFound, "line not found");
}
IReadOnlyList probes = await _probes.ListAsync(ct);
@@ -88,7 +88,7 @@ public sealed class LineService
probe = probes.FirstOrDefault(p => p.Id == probePart);
if (probe is null)
{
- return Result.Fail(MonitorErrors.ProbeNotFound, "probe not found");
+ return Result.Fail(MoShiroErrors.ProbeNotFound, "probe not found");
}
}
else
@@ -96,7 +96,7 @@ public sealed class LineService
ProbeRecord[] active = [.. probes.Where(p => p.RevokedAtMs is null)];
if (active.Length != 1)
{
- return Result.Fail(MonitorErrors.ProbeRequired, active.Length == 0 ? "there is no active probe" : "several probes exist: use ~ as the line id");
+ return Result.Fail(MoShiroErrors.ProbeRequired, active.Length == 0 ? "there is no active probe" : "several probes exist: use ~ as the line id");
}
probe = active[0];
diff --git a/backend/src/Monitor.Backend.Application/Query/MetricSelection.cs b/backend/src/MoShiro.Backend.Application/Query/MetricSelection.cs
similarity index 89%
rename from backend/src/Monitor.Backend.Application/Query/MetricSelection.cs
rename to backend/src/MoShiro.Backend.Application/Query/MetricSelection.cs
index ca74d91..e3b34f1 100644
--- a/backend/src/Monitor.Backend.Application/Query/MetricSelection.cs
+++ b/backend/src/MoShiro.Backend.Application/Query/MetricSelection.cs
@@ -1,8 +1,8 @@
using Fleet.Core;
-using Monitor.Backend.Analysis;
-using Monitor.Protocol;
+using MoShiro.Backend.Analysis;
+using MoShiro.Protocol;
-namespace Monitor.Backend.Application;
+namespace MoShiro.Backend.Application;
/// 请求的指标:导出 id(rtt.p95)与评分 id(score.mc)。
public sealed record MetricSelection(IReadOnlyList ExportIds, IReadOnlyList ScoreModelIds)
@@ -21,7 +21,7 @@ public sealed record MetricSelection(IReadOnlyList ExportIds, IReadOnlyL
PresetDef? preset = MetricRegistry.FindPreset(presetId);
if (preset is null)
{
- return Result.Fail(MonitorErrors.UnknownPreset, $"unknown preset {presetId}");
+ return Result.Fail(MoShiroErrors.UnknownPreset, $"unknown preset {presetId}");
}
ids.AddRange(preset.MetricIds);
@@ -36,7 +36,7 @@ public sealed record MetricSelection(IReadOnlyList ExportIds, IReadOnlyL
ids = [.. ids.Distinct(StringComparer.Ordinal)];
if (ids.Count > maxMetrics)
{
- return Result.Fail(MonitorErrors.TooManyMetrics, $"at most {maxMetrics} metrics per request");
+ return Result.Fail(MoShiroErrors.TooManyMetrics, $"at most {maxMetrics} metrics per request");
}
var exports = new List();
@@ -48,7 +48,7 @@ public sealed record MetricSelection(IReadOnlyList ExportIds, IReadOnlyL
string model = id["score.".Length..];
if (ModelRegistry.Find(model) is null)
{
- return Result.Fail(MonitorErrors.UnknownMetric, $"unknown metric {id}");
+ return Result.Fail(MoShiroErrors.UnknownMetric, $"unknown metric {id}");
}
scores.Add(model);
@@ -59,7 +59,7 @@ public sealed record MetricSelection(IReadOnlyList ExportIds, IReadOnlyL
}
else
{
- return Result.Fail(MonitorErrors.UnknownMetric, $"unknown metric {id}");
+ return Result.Fail(MoShiroErrors.UnknownMetric, $"unknown metric {id}");
}
}
diff --git a/backend/src/Monitor.Backend.Application/Query/QueryResults.cs b/backend/src/MoShiro.Backend.Application/Query/QueryResults.cs
similarity index 95%
rename from backend/src/Monitor.Backend.Application/Query/QueryResults.cs
rename to backend/src/MoShiro.Backend.Application/Query/QueryResults.cs
index 996a527..6392195 100644
--- a/backend/src/Monitor.Backend.Application/Query/QueryResults.cs
+++ b/backend/src/MoShiro.Backend.Application/Query/QueryResults.cs
@@ -1,7 +1,7 @@
using Fleet.Core;
-using Monitor.Backend.Analysis;
+using MoShiro.Backend.Analysis;
-namespace Monitor.Backend.Application;
+namespace MoShiro.Backend.Application;
public sealed record SummaryResult(
IReadOnlyDictionary Values,
diff --git a/backend/src/Monitor.Backend.Application/Query/QueryService.cs b/backend/src/MoShiro.Backend.Application/Query/QueryService.cs
similarity index 98%
rename from backend/src/Monitor.Backend.Application/Query/QueryService.cs
rename to backend/src/MoShiro.Backend.Application/Query/QueryService.cs
index a082026..d484acb 100644
--- a/backend/src/Monitor.Backend.Application/Query/QueryService.cs
+++ b/backend/src/MoShiro.Backend.Application/Query/QueryService.cs
@@ -1,9 +1,9 @@
using System.Text.Json;
using Fleet.Core;
-using Monitor.Backend.Analysis;
-using Monitor.Protocol;
+using MoShiro.Backend.Analysis;
+using MoShiro.Protocol;
-namespace Monitor.Backend.Application;
+namespace MoShiro.Backend.Application;
///
/// 展示数据查询:任意时间段、自动步长、数据分层与现场合并、精确汇总、列式结果。
@@ -185,7 +185,7 @@ public sealed class QueryService
if (!MetricRegistry.TryFindExport(exportId, out _, out _))
{
- return Result.Fail(MonitorErrors.UnknownMetric, $"unknown metric {exportId}");
+ return Result.Fail(MoShiroErrors.UnknownMetric, $"unknown metric {exportId}");
}
Result<(QueryRange Range, SourcePlan Plan)> planned = Plan(request, "1h");
@@ -229,7 +229,7 @@ public sealed class QueryService
MetricDef? def = MetricRegistry.Find(metricId);
if (def is null || def.Kind != AccKind.Histogram)
{
- return Result.Fail(MonitorErrors.UnknownMetric, $"{metricId} is not a histogram metric");
+ return Result.Fail(MoShiroErrors.UnknownMetric, $"{metricId} is not a histogram metric");
}
Result<(QueryRange Range, SourcePlan Plan)> planned = Plan(request, "15m");
@@ -273,7 +273,7 @@ public sealed class QueryService
MetricDef? def = MetricRegistry.Find(metricId);
if (def is null || def.Kind != AccKind.Histogram)
{
- return Result.Fail(MonitorErrors.UnknownMetric, $"{metricId} is not a histogram metric");
+ return Result.Fail(MoShiroErrors.UnknownMetric, $"{metricId} is not a histogram metric");
}
Result<(QueryRange Range, SourcePlan Plan)> planned = Plan(request, "6h");
diff --git a/backend/src/Monitor.Backend.Application/Query/RangeResolver.cs b/backend/src/MoShiro.Backend.Application/Query/RangeResolver.cs
similarity index 92%
rename from backend/src/Monitor.Backend.Application/Query/RangeResolver.cs
rename to backend/src/MoShiro.Backend.Application/Query/RangeResolver.cs
index b5a0558..68e0921 100644
--- a/backend/src/Monitor.Backend.Application/Query/RangeResolver.cs
+++ b/backend/src/MoShiro.Backend.Application/Query/RangeResolver.cs
@@ -1,9 +1,9 @@
using System.Globalization;
using System.Text.RegularExpressions;
using Fleet.Core;
-using Monitor.Protocol;
+using MoShiro.Protocol;
-namespace Monitor.Backend.Application;
+namespace MoShiro.Backend.Application;
/// now(默认)或 latest:相对时间段(range=)以当前时间还是以这条线路最后一个样本为终点。后者让离线的线路显示它最后一段数据,而不是空图。
public sealed record RangeRequest(string? Range, DateTimeOffset? From, DateTimeOffset? To, string? Step, string? TimeZone, string? Anchor = null);
@@ -63,7 +63,7 @@ public sealed partial class RangeResolver
{
if (!TryParseSpan(request.Range ?? defaultRange, out long span))
{
- return Result.Fail(MonitorErrors.InvalidRange, "range must look like 5m, 6h or 7d");
+ return Result.Fail(MoShiroErrors.InvalidRange, "range must look like 5m, 6h or 7d");
}
to = nowMs;
@@ -73,12 +73,12 @@ public sealed partial class RangeResolver
if (from >= to)
{
- return Result.Fail(MonitorErrors.InvalidRange, "from must be earlier than to");
+ return Result.Fail(MoShiroErrors.InvalidRange, "from must be earlier than to");
}
if (to - from > MaxSpanMs)
{
- return Result.Fail(MonitorErrors.RangeTooLarge, "the range is longer than 400 days");
+ return Result.Fail(MoShiroErrors.RangeTooLarge, "the range is longer than 400 days");
}
long step;
@@ -88,14 +88,14 @@ public sealed partial class RangeResolver
}
else if (!Steps.TryParse(request.Step, out step))
{
- return Result.Fail(MonitorErrors.InvalidStep, "step must be one of: " + string.Join(", ", Steps.Common.Select(Steps.Format)));
+ return Result.Fail(MoShiroErrors.InvalidStep, "step must be one of: " + string.Join(", ", Steps.Common.Select(Steps.Format)));
}
var range = new QueryRange(Steps.FloorTo(from, step), Steps.CeilTo(to, step), step, relative, from, to);
if (range.Points > _options.MaxPointsPerSeries)
{
long suggested = Steps.Common.FirstOrDefault(s => (Steps.CeilTo(to, s) - Steps.FloorTo(from, s)) / s <= _options.MaxPointsPerSeries, Steps.Day);
- return Result.Fail(MonitorErrors.RangeTooLarge, $"{range.Points} points exceed the limit of {_options.MaxPointsPerSeries}; use step={Steps.Format(suggested)} or a shorter range");
+ return Result.Fail(MoShiroErrors.RangeTooLarge, $"{range.Points} points exceed the limit of {_options.MaxPointsPerSeries}; use step={Steps.Format(suggested)} or a shorter range");
}
return Result.Ok(range);
diff --git a/backend/src/Monitor.Backend.Application/Query/RowLoader.cs b/backend/src/MoShiro.Backend.Application/Query/RowLoader.cs
similarity index 97%
rename from backend/src/Monitor.Backend.Application/Query/RowLoader.cs
rename to backend/src/MoShiro.Backend.Application/Query/RowLoader.cs
index e9f397e..4f29b51 100644
--- a/backend/src/Monitor.Backend.Application/Query/RowLoader.cs
+++ b/backend/src/MoShiro.Backend.Application/Query/RowLoader.cs
@@ -1,8 +1,8 @@
using Fleet.Core;
-using Monitor.Backend.Analysis;
-using Monitor.Protocol;
+using MoShiro.Backend.Analysis;
+using MoShiro.Protocol;
-namespace Monitor.Backend.Application;
+namespace MoShiro.Backend.Application;
public readonly record struct SourceRow(long Start, MetricSet Set, bool Partial);
@@ -92,7 +92,7 @@ public sealed class RowLoader
case DataSource.Raw:
if (!_gate.TryEnter())
{
- return Result>.Fail(MonitorErrors.TooManyRequests, "too many queries are reading raw data; retry shortly or use a coarser step");
+ return Result>.Fail(MoShiroErrors.TooManyRequests, "too many queries are reading raw data; retry shortly or use a coarser step");
}
try
diff --git a/backend/src/Monitor.Backend.Application/Query/SourcePlanner.cs b/backend/src/MoShiro.Backend.Application/Query/SourcePlanner.cs
similarity index 98%
rename from backend/src/Monitor.Backend.Application/Query/SourcePlanner.cs
rename to backend/src/MoShiro.Backend.Application/Query/SourcePlanner.cs
index 4e3df11..4e4de46 100644
--- a/backend/src/Monitor.Backend.Application/Query/SourcePlanner.cs
+++ b/backend/src/MoShiro.Backend.Application/Query/SourcePlanner.cs
@@ -1,4 +1,4 @@
-namespace Monitor.Backend.Application;
+namespace MoShiro.Backend.Application;
public enum DataSource
{
diff --git a/backend/src/Monitor.Backend.Application/Query/Steps.cs b/backend/src/MoShiro.Backend.Application/Query/Steps.cs
similarity index 98%
rename from backend/src/Monitor.Backend.Application/Query/Steps.cs
rename to backend/src/MoShiro.Backend.Application/Query/Steps.cs
index b1830f1..a0f250e 100644
--- a/backend/src/Monitor.Backend.Application/Query/Steps.cs
+++ b/backend/src/MoShiro.Backend.Application/Query/Steps.cs
@@ -1,6 +1,6 @@
using System.Globalization;
-namespace Monitor.Backend.Application;
+namespace MoShiro.Backend.Application;
/// 常用步长:1s 2s 5s 10s 15s 30s 1m 2m 5m 10m 15m 30m 1h 2h 3h 6h 12h 1d。
public static class Steps
diff --git a/backend/src/Monitor.Backend.Application/Retention/RetentionService.cs b/backend/src/MoShiro.Backend.Application/Retention/RetentionService.cs
similarity index 98%
rename from backend/src/Monitor.Backend.Application/Retention/RetentionService.cs
rename to backend/src/MoShiro.Backend.Application/Retention/RetentionService.cs
index 2b2db9c..85448fb 100644
--- a/backend/src/Monitor.Backend.Application/Retention/RetentionService.cs
+++ b/backend/src/MoShiro.Backend.Application/Retention/RetentionService.cs
@@ -1,7 +1,7 @@
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
-namespace Monitor.Backend.Application;
+namespace MoShiro.Backend.Application;
/// 保留清理:原始段文件(持续任务与按需测试保留期不同)、各层指标、事件。保留期来自 settings,可以在线修改。
public sealed partial class RetentionService : BackgroundService
diff --git a/backend/src/Monitor.Backend.Application/StartupTasks.cs b/backend/src/MoShiro.Backend.Application/StartupTasks.cs
similarity index 96%
rename from backend/src/Monitor.Backend.Application/StartupTasks.cs
rename to backend/src/MoShiro.Backend.Application/StartupTasks.cs
index 318fe29..3716e30 100644
--- a/backend/src/Monitor.Backend.Application/StartupTasks.cs
+++ b/backend/src/MoShiro.Backend.Application/StartupTasks.cs
@@ -1,6 +1,6 @@
using Microsoft.Extensions.Hosting;
-namespace Monitor.Backend.Application;
+namespace MoShiro.Backend.Application;
///
/// 启动时最先执行:截断没有索引记录的段文件尾部、创建初始管理员、创建默认的线路任务模板。
diff --git a/backend/src/Monitor.Backend.Application/Tasks/EffectiveTasks.cs b/backend/src/MoShiro.Backend.Application/Tasks/EffectiveTasks.cs
similarity index 98%
rename from backend/src/Monitor.Backend.Application/Tasks/EffectiveTasks.cs
rename to backend/src/MoShiro.Backend.Application/Tasks/EffectiveTasks.cs
index 504ce09..ae996ef 100644
--- a/backend/src/Monitor.Backend.Application/Tasks/EffectiveTasks.cs
+++ b/backend/src/MoShiro.Backend.Application/Tasks/EffectiveTasks.cs
@@ -1,7 +1,7 @@
using System.Text.Json;
-using Monitor.Protocol;
+using MoShiro.Protocol;
-namespace Monitor.Backend.Application;
+namespace MoShiro.Backend.Application;
public sealed record EffectiveTask(
TaskId Id,
diff --git a/backend/src/Monitor.Backend.Application/Tasks/TaskPlanner.cs b/backend/src/MoShiro.Backend.Application/Tasks/TaskPlanner.cs
similarity index 96%
rename from backend/src/Monitor.Backend.Application/Tasks/TaskPlanner.cs
rename to backend/src/MoShiro.Backend.Application/Tasks/TaskPlanner.cs
index 526bb98..8a21a96 100644
--- a/backend/src/Monitor.Backend.Application/Tasks/TaskPlanner.cs
+++ b/backend/src/MoShiro.Backend.Application/Tasks/TaskPlanner.cs
@@ -2,9 +2,9 @@ using System.Security.Cryptography;
using System.Text.Json;
using Fleet.Core;
using Fleet.Server;
-using Monitor.Protocol;
+using MoShiro.Protocol;
-namespace Monitor.Backend.Application;
+namespace MoShiro.Backend.Application;
public sealed record DesiredTaskSet(long Version, TaskSet Document);
@@ -65,7 +65,7 @@ public sealed class TaskPlanner : IDisposable
document.Peers.Add(new PeerSpec { ProbeId = new ProbeId(probe.Id), PublicKey = Convert.ToBase64String(probe.PublicKey) });
}
- string hash = Convert.ToHexStringLower(SHA256.HashData(JsonSerializer.SerializeToUtf8Bytes(document, MonitorJsonContext.Default.TaskSet)));
+ string hash = Convert.ToHexStringLower(SHA256.HashData(JsonSerializer.SerializeToUtf8Bytes(document, MoShiroJsonContext.Default.TaskSet)));
await _gate.WaitAsync(ct);
try
diff --git a/backend/src/Monitor.Backend.Application/Tasks/TaskService.cs b/backend/src/MoShiro.Backend.Application/Tasks/TaskService.cs
similarity index 96%
rename from backend/src/Monitor.Backend.Application/Tasks/TaskService.cs
rename to backend/src/MoShiro.Backend.Application/Tasks/TaskService.cs
index 00547e9..6bafbfd 100644
--- a/backend/src/Monitor.Backend.Application/Tasks/TaskService.cs
+++ b/backend/src/MoShiro.Backend.Application/Tasks/TaskService.cs
@@ -2,9 +2,9 @@ using System.Net;
using System.Text.Json;
using Fleet.Core;
using Fleet.Server;
-using Monitor.Protocol;
+using MoShiro.Protocol;
-namespace Monitor.Backend.Application;
+namespace MoShiro.Backend.Application;
public sealed record TaskInput(
string Scope,
@@ -97,7 +97,7 @@ public sealed class TaskService
TaskRecord? current = await _tasks.GetAsync(id, ct);
if (current is null)
{
- return Result.Fail(MonitorErrors.TaskNotFound, "task not found");
+ return Result.Fail(MoShiroErrors.TaskNotFound, "task not found");
}
IReadOnlyDictionary parameters = patch.Params ?? current.Params;
@@ -178,7 +178,7 @@ public sealed class TaskService
KindSpec? spec = Kinds.Find(kind);
if (spec is null)
{
- return Result.Fail(MonitorErrors.UnknownKind, $"unknown kind {kind}");
+ return Result.Fail(MoShiroErrors.UnknownKind, $"unknown kind {kind}");
}
Scope wanted = scope == EffectiveTasks.LineScope ? Scope.Line : Scope.Target;
@@ -206,7 +206,7 @@ public sealed class TaskService
if (agentId is { } id && await _agents.GetAsync(id, ct) is null)
{
- return Result.Fail(MonitorErrors.AgentNotFound, "agent not found");
+ return Result.Fail(MoShiroErrors.AgentNotFound, "agent not found");
}
if (scope == EffectiveTasks.TargetScope)
@@ -259,7 +259,7 @@ public sealed class TaskService
long bits = EffectiveTasks.ContinuousLineBudget(EffectiveTasks.Compute(after, agent with { Kinds = [] }, filterByAgentKinds: false));
if (bits > ProtocolLimits.MaxLineBudgetBitsPerSecond)
{
- return Result.Fail(MonitorErrors.BudgetExceeded, $"continuous tasks for {agent.Name} would use {bits / 1000} kbps (limit {ProtocolLimits.MaxLineBudgetBitsPerSecond / 1000} kbps)");
+ return Result.Fail(MoShiroErrors.BudgetExceeded, $"continuous tasks for {agent.Name} would use {bits / 1000} kbps (limit {ProtocolLimits.MaxLineBudgetBitsPerSecond / 1000} kbps)");
}
}
@@ -270,7 +270,7 @@ public sealed class TaskService
long bits = EffectiveTasks.ContinuousLineBudget(EffectiveTasks.Compute(after, virtualAgent, filterByAgentKinds: false));
if (bits > ProtocolLimits.MaxLineBudgetBitsPerSecond)
{
- return Result.Fail(MonitorErrors.BudgetExceeded, $"continuous line templates would use {bits / 1000} kbps (limit {ProtocolLimits.MaxLineBudgetBitsPerSecond / 1000} kbps)");
+ return Result.Fail(MoShiroErrors.BudgetExceeded, $"continuous line templates would use {bits / 1000} kbps (limit {ProtocolLimits.MaxLineBudgetBitsPerSecond / 1000} kbps)");
}
}
diff --git a/backend/src/Monitor.Backend.Application/Tests/Plans.cs b/backend/src/MoShiro.Backend.Application/Tests/Plans.cs
similarity index 97%
rename from backend/src/Monitor.Backend.Application/Tests/Plans.cs
rename to backend/src/MoShiro.Backend.Application/Tests/Plans.cs
index 31a6a87..2d4d1e1 100644
--- a/backend/src/Monitor.Backend.Application/Tests/Plans.cs
+++ b/backend/src/MoShiro.Backend.Application/Tests/Plans.cs
@@ -1,8 +1,8 @@
using System.Text.Json;
-using Monitor.Protocol;
+using MoShiro.Protocol;
-namespace Monitor.Backend.Application;
+namespace MoShiro.Backend.Application;
public sealed record PhaseSpec(string Kind, IReadOnlyDictionary Overrides, int DurationSeconds);
diff --git a/backend/src/Monitor.Backend.Application/Tests/TestFinalizer.cs b/backend/src/MoShiro.Backend.Application/Tests/TestFinalizer.cs
similarity index 97%
rename from backend/src/Monitor.Backend.Application/Tests/TestFinalizer.cs
rename to backend/src/MoShiro.Backend.Application/Tests/TestFinalizer.cs
index c095a2d..def6e09 100644
--- a/backend/src/Monitor.Backend.Application/Tests/TestFinalizer.cs
+++ b/backend/src/MoShiro.Backend.Application/Tests/TestFinalizer.cs
@@ -1,10 +1,10 @@
using Fleet.Core;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
-using Monitor.Backend.Analysis;
-using Monitor.Protocol;
+using MoShiro.Backend.Analysis;
+using MoShiro.Protocol;
-namespace Monitor.Backend.Application;
+namespace MoShiro.Backend.Application;
///
/// 后台任务:给已成功结束的测试算结果(所有阶段的块到达之后,或结束一分钟后以现有的块为准),
diff --git a/backend/src/Monitor.Backend.Application/Tests/TestModels.cs b/backend/src/MoShiro.Backend.Application/Tests/TestModels.cs
similarity index 94%
rename from backend/src/Monitor.Backend.Application/Tests/TestModels.cs
rename to backend/src/MoShiro.Backend.Application/Tests/TestModels.cs
index c983179..e41669c 100644
--- a/backend/src/Monitor.Backend.Application/Tests/TestModels.cs
+++ b/backend/src/MoShiro.Backend.Application/Tests/TestModels.cs
@@ -1,8 +1,8 @@
using System.Text.Json;
using System.Text.Json.Serialization;
-using Monitor.Backend.Analysis;
+using MoShiro.Backend.Analysis;
-namespace Monitor.Backend.Application;
+namespace MoShiro.Backend.Application;
public sealed class StoredTestMetrics
{
diff --git a/backend/src/Monitor.Backend.Application/Tests/TestService.cs b/backend/src/MoShiro.Backend.Application/Tests/TestService.cs
similarity index 94%
rename from backend/src/Monitor.Backend.Application/Tests/TestService.cs
rename to backend/src/MoShiro.Backend.Application/Tests/TestService.cs
index d0dfaad..b0af831 100644
--- a/backend/src/Monitor.Backend.Application/Tests/TestService.cs
+++ b/backend/src/MoShiro.Backend.Application/Tests/TestService.cs
@@ -1,10 +1,10 @@
using System.Text.Json;
using Fleet.Core;
using Fleet.Server;
-using Monitor.Backend.Analysis;
-using Monitor.Protocol;
+using MoShiro.Backend.Analysis;
+using MoShiro.Protocol;
-namespace Monitor.Backend.Application;
+namespace MoShiro.Backend.Application;
/// 按需测试(once):校验与排队、下发给 Agent、状态更新、结果查询。
public sealed class TestService
@@ -33,18 +33,18 @@ public sealed class TestService
PlanSpec? plan = Plans.Find(request.Plan);
if (plan is null)
{
- return Result.Fail(MonitorErrors.UnknownPlan, $"unknown plan {request.Plan}");
+ return Result.Fail(MoShiroErrors.UnknownPlan, $"unknown plan {request.Plan}");
}
AgentRecord? agent = await _agents.GetAsync(agentId, ct);
if (agent is null)
{
- return Result.Fail(MonitorErrors.AgentNotFound, "agent not found");
+ return Result.Fail(MoShiroErrors.AgentNotFound, "agent not found");
}
if (agent.Status != NodeStatus.Active)
{
- return Result.Fail(MonitorErrors.AgentNotActive, "agent is not active");
+ return Result.Fail(MoShiroErrors.AgentNotActive, "agent is not active");
}
// Agent 在 hello 里声明了它支持的采集方法:方案里有它不支持的就不下发(否则要等到阶段开始才失败)
@@ -62,17 +62,17 @@ public sealed class TestService
if (!_gateway.IsOnline(agentId))
{
- return Result.Fail(MonitorErrors.AgentOffline, "agent is offline");
+ return Result.Fail(MoShiroErrors.AgentOffline, "agent is offline");
}
if (!(_runtime.TryGet(agentId, out AgentRuntimeState? state) && state.IsConnected(probeId.Value)))
{
- return Result.Fail(MonitorErrors.ProbeOffline, $"probe {probeId.Value} has no session with this agent");
+ return Result.Fail(MoShiroErrors.ProbeOffline, $"probe {probeId.Value} has no session with this agent");
}
if (await _tests.HasActiveAsync(agentId, probeId, ct))
{
- return Result.Fail(MonitorErrors.TestBusy, "another test is already running on this line");
+ return Result.Fail(MoShiroErrors.TestBusy, "another test is already running on this line");
}
var testId = new TestId(Ulid.NewPrefixed(TestId.Prefix, _time));
@@ -96,7 +96,7 @@ public sealed class TestService
TestRecord? test = await _tests.GetAsync(id, ct);
if (test is null)
{
- return Result.Fail(MonitorErrors.TestNotFound, "test not found");
+ return Result.Fail(MoShiroErrors.TestNotFound, "test not found");
}
if (IsTerminal(test.Status))
@@ -115,7 +115,7 @@ public sealed class TestService
return Result.Ok(await _tests.GetAsync(id, ct) ?? test);
}
- /// monitor.test.status:只接受该测试所属 Agent 的汇报。
+ /// moshiro.test.status:只接受该测试所属 Agent 的汇报。
public async ValueTask OnStatusAsync(NodeId agent, TestStatusParams status, CancellationToken ct)
{
TestRecord? test = await _tests.GetAsync(status.TestId, ct);
@@ -244,7 +244,7 @@ public sealed class TestService
long bits = kind.BudgetBitsPerSecond(resolved.Values!);
if (limitMbps is > 0 && bits > limitMbps * 1_000_000)
{
- return Result>.Fail(MonitorErrors.BudgetExceeded, $"{phase.Kind} needs {bits / 1_000_000.0:0.#} Mbit/s but the agent allows {limitMbps} Mbit/s");
+ return Result>.Fail(MoShiroErrors.BudgetExceeded, $"{phase.Kind} needs {bits / 1_000_000.0:0.#} Mbit/s but the agent allows {limitMbps} Mbit/s");
}
int duration = resolved.Values!.Values.TryGetValue("duration_s", out JsonElement d) && d.TryGetInt64(out long seconds) ? (int)seconds : Math.Max(1, (int)Math.Round(phase.DurationSeconds * phaseScale));
diff --git a/backend/src/Monitor.Backend.Application/Updates/ReleaseService.cs b/backend/src/MoShiro.Backend.Application/Updates/ReleaseService.cs
similarity index 98%
rename from backend/src/Monitor.Backend.Application/Updates/ReleaseService.cs
rename to backend/src/MoShiro.Backend.Application/Updates/ReleaseService.cs
index ad1e055..39cc37b 100644
--- a/backend/src/Monitor.Backend.Application/Updates/ReleaseService.cs
+++ b/backend/src/MoShiro.Backend.Application/Updates/ReleaseService.cs
@@ -3,9 +3,9 @@ using System.Diagnostics.CodeAnalysis;
using System.Text.Json;
using System.Text.RegularExpressions;
using Fleet.Core;
-using Monitor.Protocol;
+using MoShiro.Protocol;
-namespace Monitor.Backend.Application;
+namespace MoShiro.Backend.Application;
/// 面板记下的、CI 签名的发布清单(只留每个组件最新的一份)。Manifest 是签名对象的原始文本,面板一个字节也不改。
public sealed record ReleaseOffer(string Component, long Seq, string Tag, string Version, string Digest, string Manifest, string Signature);
@@ -42,7 +42,7 @@ public sealed partial class ReleaseService
ReleaseOffer? current = await GetAsync(offer.Component, ct);
if (current is not null && offer.Seq <= current.Seq)
{
- return Result.Fail(MonitorErrors.NameConflict, $"a release with seq {current.Seq} or newer is already registered");
+ return Result.Fail(MoShiroErrors.NameConflict, $"a release with seq {current.Seq} or newer is already registered");
}
await _settings.SetAsync(Key(offer.Component, "manifest"), offer.Manifest, ct);
diff --git a/backend/src/Monitor.Backend.Application/ValidationError.cs b/backend/src/MoShiro.Backend.Application/ValidationError.cs
similarity index 85%
rename from backend/src/Monitor.Backend.Application/ValidationError.cs
rename to backend/src/MoShiro.Backend.Application/ValidationError.cs
index c1468f9..fb2d2a7 100644
--- a/backend/src/Monitor.Backend.Application/ValidationError.cs
+++ b/backend/src/MoShiro.Backend.Application/ValidationError.cs
@@ -1,11 +1,11 @@
using Fleet.Core;
-using Monitor.Protocol;
+using MoShiro.Protocol;
-namespace Monitor.Backend.Application;
+namespace MoShiro.Backend.Application;
/// 校验失败,带逐字段的原因(键是 JSON 字段路径)。Api 层把它映射成 problem+json 的 errors。
public sealed record ValidationError(string Message, IReadOnlyDictionary Fields)
- : FleetError(MonitorErrors.ValidationFailed, Message)
+ : FleetError(MoShiroErrors.ValidationFailed, Message)
{
public static ValidationError Single(string field, string message) =>
new("Validation failed", new Dictionary { [field] = message });
diff --git a/backend/src/Monitor.Backend.Gateway/ConnectionShutdown.cs b/backend/src/MoShiro.Backend.Gateway/ConnectionShutdown.cs
similarity index 97%
rename from backend/src/Monitor.Backend.Gateway/ConnectionShutdown.cs
rename to backend/src/MoShiro.Backend.Gateway/ConnectionShutdown.cs
index 83227d4..07a6c56 100644
--- a/backend/src/Monitor.Backend.Gateway/ConnectionShutdown.cs
+++ b/backend/src/MoShiro.Backend.Gateway/ConnectionShutdown.cs
@@ -2,7 +2,7 @@ using Fleet.Server;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
-namespace Monitor.Backend.Gateway;
+namespace MoShiro.Backend.Gateway;
///
/// 宿主开始停止时先关闭所有 Agent 的长连接(Close 握手,不发 revoked:Agent 会重连)。
diff --git a/backend/src/Monitor.Backend.Gateway/FleetGateway.cs b/backend/src/MoShiro.Backend.Gateway/FleetGateway.cs
similarity index 72%
rename from backend/src/Monitor.Backend.Gateway/FleetGateway.cs
rename to backend/src/MoShiro.Backend.Gateway/FleetGateway.cs
index 89aaa98..d8fae4d 100644
--- a/backend/src/Monitor.Backend.Gateway/FleetGateway.cs
+++ b/backend/src/MoShiro.Backend.Gateway/FleetGateway.cs
@@ -1,10 +1,10 @@
using Fleet.Core;
using Fleet.Server;
using Microsoft.Extensions.DependencyInjection;
-using Monitor.Backend.Application;
-using Monitor.Protocol;
+using MoShiro.Backend.Application;
+using MoShiro.Protocol;
-namespace Monitor.Backend.Gateway;
+namespace MoShiro.Backend.Gateway;
///
/// Application 通往 Agent 连接的端口的实现,建立在 Fleet.Server.Link 的在线表之上。
@@ -37,26 +37,26 @@ public sealed class FleetGateway : IAgentGateway
public async ValueTask> RunTestAsync(NodeId agent, TestRunParams run, CancellationToken ct)
{
Result result = await Connections.RequestAsync(
- agent, MonitorMethods.TestRun, run, MonitorJsonContext.Default.TestRunParams, MonitorJsonContext.Default.TestRunResult, ct);
+ agent, MoShiroMethods.TestRun, run, MoShiroJsonContext.Default.TestRunParams, MoShiroJsonContext.Default.TestRunResult, ct);
if (!result.TryGet(out TestRunResult? accepted, out FleetError? error))
{
- return Result