Commit Graph
18 Commits
Author SHA1 Message Date
Qiu Yuzhou 868cfe66ad refactor(catalog): 激活拒绝结果自含 typed 原因 2026-10-03 22:08:37 +08:00
Qiu Yuzhou 31e9f6e95f refactor(sysproxy): 观察机写面收成意图命令,字段退回实现 2026-10-03 20:29:15 +08:00
Qiu Yuzhou 16a2384498 fix(runtime): 收敛票据恒查全部失效事实,agent 关闭不再被旧收敛复活
mode/catalog 路径的票据子集缺 .flow/.agentEnabled:agent 关闭落在
mode 切换健康门 await 窗口内会被误分类为失败并触发 restore,把用户
显式的 off 意图静默撤销。删除逐 call site 挑子集的 Checks 政策,
convergenceIsCurrent 恒查 flow/mode/preparation/agentEnabled 四事实;
deployPrepared 的手工 preparation 守卫随之删除。

restore 门禁先行:agent 意图与票据时效先于回滚载荷持久化——竞态下
不再把旧 mode 写回持久层(内存/持久层分叉、用户切换被无声撤销)。

轮询写入守卫对齐同一票据词汇:防火墙轮询 await 恢复后补查代际
(cancel 后不得把 .firewallBlocked 盖回 .off);系统代理健康 Task
post-await 守卫补 agentEnabled。

新增 5 个交错/门禁测试(BlockingProbe/BlockingFirewallChecker 暂停
缝;修复前实测全红:agent 重注册、running 复活、.direct 意图被改回
.global、载荷写回、.failed 误分类);CONTEXT.md 增补 Convergence
ticket 词条。全量 792 测试通过。
2026-10-03 18:44:58 +08:00
Qiu Yuzhou 2f670a4c6b refactor(rules): decouple saved intent from runtime application 2026-10-03 17:40:05 +08:00
Qiu Yuzhou eac30c4abd refactor(sysproxy): 系统代理策略机抽为 SystemProxyObserver 模块
ADR-0022 的观察/修复/挂起策略此前溶解在控制器 15 个可变字段里、由
Gate/Inspection/Commands/Health/Mode 五个文件交叉读写。现在策略机独立为
SystemProxyObserver:意图开关、出口可用性、期望配置与健康循环调度以
@MainActor 闭包注入,模块不反向依赖控制器;底层继续只依赖
SystemProxyControlling / helper 注册缝 / 网络变化监视三条既有缝。

- 3 个 @Published 呈现事实随迁,控制器留同名只读门面(测试与诊断面零改动);
  adapter 再发布链 merge 观察机 objectWillChange,主队列 hop 语义不变
- 健康循环留在控制器(循环体含运行时健康呈现),任务柄归观察机;
  cleanup-until-quiet、网络变化 inspection 调度与操作互斥全部内聚
- 方法体逐字搬运(settings.systemProxyEnabled→isIntentEnabled() 等机械替换),
  语义零改动;既有 777 测试全绿
2026-10-03 12:44:20 +08:00
Qiu Yuzhou d7169d9f01 refactor(runtime): route catalog sync through the convergence spine
- catalogDidCommit 的 deployed 分支体(派生 + 幂等跳过 + deployPrepared)
  与 deploy() 逐语义等价,改走 deploy();runtimeAlreadyConverged 独立机制
  删除,plan 空判定由 apply 层的 convergencePlanIsEmpty 统一承担。
- deploy/deployPrepared 返回 ConvergenceResult:被取代的派生按 .superseded
  呈现为 .revalidated,其余路径仍由状态面映射。
- reexpand 三-case 开关收敛为 convergeToReexpanded:convergeAgent /
  updateSettings / resyncOnLaunch 各变一行;catalogDidCommit 保留按 case
  的结构化 outcome 映射。
- 统一设置持久化 epilogue 为 persistSettings:setAgentEnabled /
  setSystemProxyEnabled / transitionMode 三处相同 save-fail 语义折叠
  (updateSettings 的 throw 变体与级联关闭的 return-nil 变体语义不同,
  保持原样)。
- SkeletonTests 运行时适配器豁免名单登记 +Convergence.swift。
2026-10-03 11:08:24 +08:00
Qiu Yuzhou 8587b2e80c refactor(runtime): unify apply/restore into the convergence spine
三份「执行 → 健康门 → 失败回滚」编排骨架(mode 切换 / rules 提交 /
deployPrepared)统一为收敛脊柱的 apply 层:

- apply:幂等跳过(派生契约与运行中运行时逐字节相同 → .unchanged,
  不闪 starting、不重走健康门)→ 计划执行 → 健康门(requiresReceipt /
  convergeProxyOnSuccess / preserveProxyOnFailure 逐路径参数照旧)→
  成功后按 proxyTail 收敛系统代理。
- restore:单一回滚例程 + RollbackPlan 两种载荷 policy(mode 的
  settings/mode 回退 + 意图变化强制重收敛;rules 的规则文档恢复)。
  restoreRuntimeDocument/relaunchPreviousInstance 删除——计划层对
  写契约/信号/注销重注的裁决与旧例程逐场景等价。
- 票据 inout 传参:execute 后的 flow 推进对调用方可见,rules 提交在
  apply 之后的时效检查使用推进过的票据。
- ModeTransitionSnapshotForRules 删除,rules 回滚计划在部署入口构建。

行为保持:.run 计划动作全部同步执行,starting 前置不可观测;mode/rules
路径到 apply 时计划必非空,幂等跳过只对 deploy 路径生效(与「有效值未
变的提交不做运行时收敛」不变量一致)。
2026-10-03 10:56:23 +08:00
Qiu Yuzhou dc35e70798 refactor(runtime): capture convergence tickets instead of hand-checked generations
execute 现在返回 RuntimeExecutionOutcome(成功与否 + 本次占用的并发流
代际),mode 与 rules 路径的 24 处手写代际 guard 收拢为 ConvergenceTicket
的 convergenceIsCurrent 检查;两处 flowGeneration + 1 手算随之消失。
行为逐字节保持:mode 路径的 mode 代际仍在派生前捕获、preparation 分量
在派生后推进;rules 路径四个代际事实全查不变。
2026-10-03 10:30:47 +08:00
Qiu Yuzhou e345d772eb fix(runtime): make ACL deployment transactional 2026-10-03 00:09:42 +08:00
Qiu Yuzhou e5de11a5fe perf(rules): share snapshots and reuse commit results 2026-10-02 23:50:59 +08:00
Qiu Yuzhou 09686a80db feat(rules): persist cross-source enablement and recover deployments (#78) 2026-10-02 21:38:03 +08:00
Qiu Yuzhou 4a0a72c6cf feat: observe and repair system proxy configuration (#73) 2026-10-01 23:29:56 +08:00
Qiu Yuzhou d2a8d6105c feat(system-proxy): route writes through privileged LaunchDaemon helper
Implements issue #71 with ADR-0020 (supersedes ADR-0019's endpoint-signature
cleanup, startup cleanup, and health-gate cleanup).

- New ShadowsocksX-NG2SystemProxyHelper target: app-bundled root LaunchDaemon
  (SMAppService.daemon, on-demand via MachServices) that mechanically applies
  a closed typed configuration or executes an unconditional clear. Clients are
  accepted by code-signing bundle identifier only; requests run serially on a
  shared queue (last-writer-wins).
- SystemProxyConfiguration is now the closed typed apply payload (Codable over
  JSON XPC): explicit SOCKS/HTTP/HTTPS enable + endpoints, PAC and
  auto-discovery disabled with URL/JS removed, explicit simple-hostname
  exclusion, complete ExceptionsList. Unmodeled Proxies keys are preserved and
  equivalent values skip the commit.
- Cleanup is a side effect of a persisted system-proxy intent on-to-off
  transition only: the switch itself, or the agent-off cascade (persist both
  intents off, clear, then stop listeners; failed cascade persistence records
  no transition and clears nothing). Launch with the switch off, health-gate
  closure, invalid targets, and passive events never clear. Failed clears are
  surfaced without deferred retry.
- Endpoint-signature store, ownership migration, and direct Authorization
  Services writes are removed; old signature files stay inert. Helper
  unavailability or pending approval keeps an enabled intent pending and
  surfaces the Login Items approval path (HomeView button + menu label).
2026-09-30 12:26:40 +08:00
Qiu Yuzhou 08682724c9 fix(system-proxy): reconcile configuration across network changes 2026-09-29 23:39:25 +08:00
Qiu Yuzhou 5a05b8a661 refactor(ng2): use sslocal runtime defaults 2026-09-27 17:51:34 +08:00
Qiu Yuzhou 8aedf8c42e perf(acl): per-variant ACL files behind a stable active link
Stop rewriting the whole ACL on every proxy-mode switch: materialize one
file per routing shape (acl-<summary>.ini), keep acl-active.ini as a stable
symlink the contract points at, and skip unchanged writes via a digest
manifest. The contract carries only path/summary/sha256 — the agent checks
the link stays inside the runtime directory and never reads ACL bytes.

Agent switch now defaults to off (no server config on a fresh install) and
survives preferences reset, which also returns any held system proxy and
converges a still-running agent onto the factory runtime. See ADR-0011.
2026-09-27 03:14:38 +08:00
Qiu Yuzhou a8cd6262c2 feat(proxy): remove PAC and accept ACL system proxy path
Remove the PAC product feature entirely: PAC HTTP service, port, health
probe, runtime extension, PAC URL system proxy projection, PAC rule
editing, and GFWList URL settings. The product now exposes rule / global /
direct modes only, all projected as a local SOCKS system-proxy target.

First-run defaults are rule + proxyWhenUnmatched, agent on, system proxy
off. Homepage and status menu share one ProxyControlSnapshot showing the
three modes and rule sub-options. Manual servers, subscriptions, Legacy
import, and independent SOCKS/HTTP inbounds are retained.

Fix: include verbose in SslocalListenFingerprint so a verbose-only
contract change restarts sslocal instead of leaving RUST_LOG stale.

Revise CONTEXT.md vocabulary, ADR-0007, and ADR-0009. Record GFWList
exception shadowing, IPv6 system-exception, DNS, and traffic-coverage
boundaries. Add host acceptance evidence document.

Closes #67
2026-09-26 21:58:12 +08:00
Qiu Yuzhou 827fb98be3 refactor(ng2): fix all swiftlint warnings
77 → 0 warnings. Split oversized functions and files: controller and
agent extension files, standalone RuleSet/ProxySettingsFileStore/
SslocalListenSettings/LegacyImportService, test classes into topic
extensions. Regroup activation options into RuntimeDocumentOptions and
converter metadata into Provenance.

Runtime controller DI seams widen private → internal so the extension
files stay cohesive; new controller files are registered in the
architecture guard exemption list; Agent target adds RuleSet and
SslocalListenSettings to project.yml. Test JSON literals wrap inside
the string literal only.
2026-09-26 17:13:31 +08:00