fix(m193): 复审 r1 三条 P2——版本史还原、retry_limit 0 有诚实语义、装配点措辞更正

- P2-2:keys.rs 的 schema 版本史按原文逐字还原(1.4.0/1.5.0 的键名、1.2.0 的迁移口径、
  旧读新的完整结论),不再用版本文档换行数;腾行改从我自己新加的注释里出。
- P2-1:download.retry_limit 范围恢复 0~10,并把 0 的语义定成「只试一次」(attempts = max(1, 0)):
  老配置合法、零迁移、ull config get 读到的 0 与引擎真做的事一致(不再回落出厂 3)。
  schema 描述与 presenter/iced 两处 UI 都写清「0 与 1 都 = 只试一次,不代表不下载」。
- P2-3:shared.rs 的「唯一一处装配」更正为「presenter 侧唯一一处」(CLI 还有三处自建),
  docs 加「哪些路径吃这套设置」表,并立 finding(CLI install/java/pack 不读设置、并发 64→8)。
- P3-3:mirrors.rs 的 gh_proxies 注释改成「无生产读者,仅解析留档」。
- P3-4(presenter 侧):并发/重试描述的出厂值与上限改用常量 format!,不再是第二处字面量。
- 出图重拍(含 0/1 = 只试一次)。
This commit is contained in:
worker-dlmsettings authored and AskaEth committed 2026-11-09 05:24:12 +08:00
1 parent e8544b19a7
commit 94f56f9d9c
10 files changed
+173 -130

No files matched your search

+24 -27
View File
@@ -136,11 +136,10 @@ pub fn constructions(cache_root: impl AsRef<Path>) -> usize {
.unwrap_or(0)
}
/// 真实构造(**唯一**一处 `DownloadEngine::new` 的宿主侧装配)。装配参数从该数据根的
/// [`wanted`] 取,不用裸 `EngineConfig::default()`(M193):并发 → `Semaphore` 容量、尝试次数 →
/// `attempts_for()` 上限、gh_proxy → 地区档案(`MirrorTable::expand()` 只认档案里那个前缀,所以
/// 内容库 / 版本清单 / 字体 / 安装**所有**路径一起生效)。值由宿主翻译后经 [`set_tuning`] 灌入——
/// core 不认识设置键名,也不依赖 `core::setting`。
/// 真实构造(**presenter 侧**唯一一处 `DownloadEngine::new` 的宿主侧装配;CLI 还有三处自建,
/// 见 `docs/download-settings.md` §3 的「哪些路径吃这套设置」)。装配参数从该数据根的 [`wanted`] 取,
/// 不用裸 `EngineConfig::default()`(M193):并发 → `Semaphore` 容量、尝试次数 → `attempts_for()`
/// 上限、gh_proxy → 地区档案(`expand()` 只认档案里那个前缀)。值由宿主经 [`set_tuning`] 灌入。
fn build(cache_root: &Path) -> DownloadEngine {
let now = now_ms();
let tune = wanted(cache_root);
@@ -179,7 +178,7 @@ pub fn set_tuning(cache_root: impl AsRef<Path>, next: DownloadTuning) -> bool {
mod tests {
use super::*;
/// 每个用例一个独立数据根(登记处是进程级的,键撞了会互相干扰)。
/// 每个用例一个独立数据根(登记处与调优都是进程级、按根存,键撞了会互相干扰)。
fn root(tag: &str) -> PathBuf {
static SEQ: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicUsize::new(0);
let seq = SEQ.fetch_add(1, std::sync::atomic::Ordering::SeqCst);
@@ -325,17 +324,16 @@ mod tests {
std::fs::remove_dir_all(&dir).ok();
}
/// **守门①②**:设置说 2 ⇒ 引擎**真实的并发闸门**就是 2(探针读 `Semaphore`,不是读配置);
/// 同一口装配点上的 gh-proxy 三档也真的改变 `plan()` 的候选链。
/// **守门①②**:设置说 2 ⇒ 引擎**真实的并发闸门**就是 2(探针读 `Semaphore` 而非配置);gh-proxy
/// 三档也真的改变 `plan()` 的候选链;`retry_limit = 0` 落成「只试一次」。
///
/// 变异证明(只改实现侧):① `build` 的 `tune.apply_to(...)` 换回裸 `EngineConfig::default()`
/// ⇒ 探针 8,红;② `tune.apply_gh_proxy(region)` 换回 `region` ⇒ `off` 档仍有候选,红;
/// ③ 删掉 `set_tuning` 里那条 `remove` ⇒ 换参数后交回旧引擎(探针 2 ≠ 5),红。
/// gh-proxy 的**端到端**一半(schema 键 → 调优)要等 M197 登记该键,这里只守「调优 → 候选链」。
/// 变异证明(只改实现侧):① `build` 换回裸 `EngineConfig::default()` ⇒ 探针 8 红;②
/// `apply_gh_proxy(region)` 换回 `region` ⇒ `off` 档仍有候选,红;③ 删 `set_tuning` 的
/// `remove` ⇒ 换参数后交回旧引擎,红。gh-proxy 的端到端(schema 键 → 调优)等 M197 登记该键。
#[test]
fn the_setting_and_the_gh_proxy_override_reach_the_engine() {
use super::super::types::{DownloadRequest, ResourceKind};
use super::super::RegionProfile;
use super::super::{config, RegionProfile};
let dir = root("tune");
// 镜像优先的档案:gh-proxy 只在这个模式下才生成候选。
@@ -363,13 +361,8 @@ mod tests {
set(Some(2), Some(1), "off");
let engine = engine_for(&dir);
assert_eq!(engine.concurrency_probe(), 2, "闸门必须真是 2 张许可");
assert_eq!(
engine.config().max_attempts_per_source,
1,
"尝试次数同一条路"
);
let off = chain(&dir);
assert!(!off.iter().any(|url| url.contains("gh-proxy")), "{off:?}");
assert!(!off.iter().any(|u| u.contains("gh-proxy")), "{off:?}");
set(Some(5), None, "https://gh.example/");
let rebuilt = engine_for(&dir);
@@ -377,23 +370,27 @@ mod tests {
assert_eq!(rebuilt.concurrency_probe(), 5, "新闸门吃新值");
let over = chain(&dir);
assert!(
over.iter()
.any(|url| url.starts_with("https://gh.example/")),
"覆盖前缀必须出现在候选链里:{over:?}"
over.iter().any(|u| u.starts_with("https://gh.example/")),
"{over:?}"
);
// 硬上限(纵深防御):宿主绕开 `from_settings` 直接塞 9999,闸门也只能开到 64。
// P2-1:`retry_limit = 0`(旧配置里真有)不许回落出厂 3。硬上限:塞 9999 也只开 64。
set(Some(8), Some(0), "");
let zero = engine_for(&dir);
assert_eq!(zero.config().max_attempts_per_source, 1);
assert_eq!(
zero.attempts_for("official", ResourceKind::Other, now_ms()),
1
);
let wild = DownloadTuning {
max_concurrency: 9_999,
..DownloadTuning::default()
..Default::default()
};
set_tuning(&dir, wild);
assert_eq!(
engine_for(&dir).concurrency_probe(),
super::super::config::MAX_CONCURRENCY,
"9999 张许可不能真开"
config::MAX_CONCURRENCY
);
std::fs::remove_dir_all(&dir).ok();
}
}