refactor(framework): 移除 resolveBootstrap 下游兜底,立第二准则

- CLAUDE.md 新增「第二准则:数据源权威、唯一,下游不兜底」
- bootstrap 删除 fallbackServers 选项与 ?? DEFAULT_GAMESERVER 猜默认
- 无 server/gameserver、远程失败、解析不出地址 → 一律抛 ConfigFetchError 显式暴露
- 同步 guide + 两篇 spec(删 fallback/降级措辞)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-28 18:59:15 +08:00
co-authored by Claude Opus 4.8
parent 39bb964a49
commit 51a4ee57ac
6 changed files with 42 additions and 29 deletions
@@ -93,7 +93,6 @@ export interface BootstrapOptions {
search: string; // location.search(测试可注入)
fetcher: ConfigFetcher; // 远程配置抓取(测试注入 fake)
isNative: boolean; // 环境判定结果(URL 含 index.html → true)
fallbackServers?: string[]; // 远程失败时降级
}
export interface BootstrapResult {
identity: ChannelIdentity;
@@ -134,7 +133,7 @@ export function resolveActiveProfile(search: string): DebugProfile;
## 6. 错误处理
- 远程抓取失败:无 `fallbackServers` 时抛 `ConfigFetchError`,交调用方重试(重连归 net,不在本层重复造轮子);有 fallback 则降级使用;
- 远程抓取失败 / 解析不出任何地址 / profile 既无 server 又无 gameserver:一律抛 `ConfigFetchError` **显式暴露**,不猜默认、不降级(CLAUDE.md 第二准则)。重试/重连归 net,不在本层造兜底;
- `getParam`:某层匹配不到 → 返回已找到的最具体值或顶层 `data[key]`,最终可能 `null`(忠实原语义);
- 原生 settings 缺失:`try/catch` → source 返回 `{}`(不覆盖),等价原 `try/catch return ""`;
- 远程 txt JSON 解析失败:抛 `ConfigParseError`。