M205: gh-proxy 键绑定断言、外层重试预算判据、UA 版本号来源、下载设置文档更正

- setting/keys/proxy: 新增断言把 KEY_GH_PROXY 常量与 schema 登记绑起来(键名 / Text{max_len:256} / 默认空串)
- addon/online/download: RETRY_ATTEMPTS 与引擎每源次数是两件事(层级相乘、管的失败类型不同),写清判据并用两条编译期断言钉住 3 与 3x3=9 的边界
- presenter/host/addon/http: UA 版本号改为从 CARGO_PKG_VERSION 拼出,补断言钉住版本 == CARGO_PKG_VERSION 且联系方式段不丢
- docs/download-settings: §3.1 四条 CLI 命令都吃设置(update 是自更新路径),§6 补 M11-M13 三条 CLI 变异,§1/§7 里 gh_proxy 已合入的事实
This commit is contained in:
tower-worker committed 2026-11-09 11:12:59 +08:00
1 parent 4c29cbac3e
commit d4aa3b23f4
4 files changed
+119 -16

No files matched your search

+19
View File
@@ -74,4 +74,23 @@ mod tests {
assert!(gh.doc.contains("留空 = 跟随内置默认"), "{}", gh.doc);
assert!(gh.doc.contains("填 off 关闭"), "{}", gh.doc);
}
/// **`KEY_GH_PROXY` 与 schema 登记的绑定**(M205):`download/config.rs` 那个常量是宿主读数用的
/// 唯一键名,本文件 `specs()` 里是 schema 的登记——两侧各写一个字符串,此前没有任何断言把它们
/// 绑在一起,常量被改名/写错时全绿,行为只在宿主侧静默退化成 `Builtin`(用户填的 `off` 被忽略)。
///
/// 抓得住:常量值写错(如 `download.ghproxy`)⇒ 找不到登记项,第一句红;登记的 `max_len` 从 256
/// 改掉、或默认值从空串改成别的 ⇒ 各自红(类型/默认值是宿主的读侧契约)。
/// 抓不住:两侧**同时**改名(那是一次公开改名,本用例判断不了它对不对,只能保证两侧一致)。
#[test]
fn the_gh_proxy_key_is_bound_to_the_schema_registration() {
use crate::download::config::KEY_GH_PROXY;
use crate::setting::spec::ValueKind;
let Some(gh) = specs().into_iter().find(|spec| spec.key == KEY_GH_PROXY) else {
panic!("下载键常量 {KEY_GH_PROXY:?} 在 schema 里没有登记项(常量值与 specs() 的键名不一致)");
};
assert_eq!(gh.kind, ValueKind::Text { max_len: 256 }, "{}", gh.key);
assert_eq!(gh.default, serde_json::json!(""), "{}", gh.key);
}
}