Commit Graph
129 Commits
Author SHA1 Message Date
Qiu Yuzhou b7a2a6a524 test: 为 Agent 系统代理测试复用小规则夹具 2026-10-04 00:30:43 +08:00
Qiu Yuzhou 7fb736f53e test: 为代理控制集成测试注入小规则夹具 2026-10-04 00:22:45 +08:00
Qiu Yuzhou 0235e64ad1 test: 拆分运行时测试类并缩短健康等待窗口 2026-10-04 00:06:47 +08:00
Qiu Yuzhou 9322184310 refactor(ui): 状态卡呈现政策收进 StatusCardModel,壳只挂薄视图 2026-10-03 22:57:04 +08:00
Qiu Yuzhou a504171c18 refactor(ui): 激活反馈收成共享状态模块,三入口单飞 2026-10-03 22:39:41 +08:00
Qiu Yuzhou 868cfe66ad refactor(catalog): 激活拒绝结果自含 typed 原因 2026-10-03 22:08:37 +08:00
Qiu Yuzhou b48e4158b6 refactor(sysproxy): 健康观察任务柄归属观察机,循环体经闭包注入 2026-10-03 20:35:36 +08:00
Qiu Yuzhou 31e9f6e95f refactor(sysproxy): 观察机写面收成意图命令,字段退回实现 2026-10-03 20:29:15 +08:00
Qiu Yuzhou 5c24b65227 refactor(rules): 删 RuleSet 死类型与 updateCustomRules 前文档时代缝 2026-10-03 19:11:30 +08:00
Qiu Yuzhou edb2c08933 refactor(rules): outcome→文案映射移出视图文件,落回 outcome 类型旁 2026-10-03 19:04:40 +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 57ce356573 refactor(catalog): 目录树投影收进 CatalogTreeSnapshot
visibleRows(collapsed:)、serverLeafCount 与共享行类型 CatalogTreeRow
移入树快照,服务器管理侧栏、首页目标树与工作区角标三处各自重走的
遍历归一;HomeServerListState.visibleRows 保留为委托门面,视图与
测试零改动。嵌套菜单构造(TargetCascade)与政策查询
(moveDestinations)非投影重复,有意不动。
2026-10-03 14:29:12 +08:00
Qiu Yuzhou b24029acab refactor(sysproxy): 操作互斥改等待队列,cleanup 静默窗可注入
waitForSystemProxyOperation 的 10ms 忙轮询换成 continuation 等待队列:操作
收尾时唤醒全部等待者,等待者再经既有二次门禁竞争下一轮,取消者照旧得到
false 中止——语义与轮询版一致,去掉固定 10ms 延迟与空转。cleanup 每轮
扫描后的 SystemConfiguration 排空静默窗提为注入参数(默认仍 100ms)。

观察机现在可从自身 interface 驱动(策略机抽取的直接收益),新增两个不经
控制器夹具的用例:cleanup-until-quiet 重扫循环(清理期内网络变化触发整轮
重扫,安静后收敛)与并发收敛互斥(进行中操作等收尾而非被跳过)。快车道
779 全绿。
2026-10-03 12:52:04 +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 21259dde2a refactor(ui): 主窗口壳停止观察 ProxyRuntimeController,守卫固化
服务器分区活动目标标记改从 control.snapshot.activeTarget 取值(out-of-tree
目标仍带 id,值恒等;与首页/状态菜单同一 snapshot 口径)。MainWindowView/
MainApp 删除对 controller 的直接传递,视图层 controller 依赖清零;MainApp
的 @StateObject 保留为组合根寿命锚点。

顺带把「新 UI 禁依赖 controller」固化为 SkeletonTests 禁令 token
(控制器家族按前缀豁免,ProxyRuntimeFacts 为适配器侧 facts 映射豁免);
删除 ErrorPresentation 的 AgentRunState 呈现 overload(生产零调用),
四处测试断言迁到 RuntimeFailureFacts 路径。
2026-10-03 12:00:04 +08:00
Qiu Yuzhou 14fdd493a3 fix(rules-smoke): adapt smoke fixtures to sourceless ProxyRule
fcd5645「slim built-in snapshots」移除了 ProxyRule 的 source 字段后 Smoke
target 未同步,构造器多传 source: 导致冒烟编译失败(先于收敛脊柱重构就
存在的破损)。移除冒烟夹具中的 source 实参与不再使用的 RuleSourceIdentity
局部值;来源身份属于浏览集合层,运行时文档与 ACL 只消费 action+match,
夹具语义不变。
2026-10-03 11:21:37 +08:00
Qiu Yuzhou 1fed58c903 refactor(rules): drop the dead rule-mode validation seam
ruleModeCandidateRules / ruleModeValidation 零生产调用者——生产校验经由
RulesWorkflow 预检与 RuleRuntimeCompiler.compile;控制器内这份薄复制删除。
相关测试断言改为直接调用领域层 RuleRuntimeCompiler.validation(与被删缝
同参同义),遮蔽关系与重排不变性断言原样保留。
2026-10-03 11:13:10 +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 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 3aae39799a fix(rules): convert root URL paths to exact domains 2026-10-03 09:56:00 +08:00
Qiu Yuzhou 6e69d92449 feat(rules): convert pathless URL prefixes to exact domains 2026-10-03 09:52:42 +08:00
Qiu Yuzhou 619121a36c fix(route): decouple sidebar selection write-back from route publish
The same-value guard only stopped same-value selection re-syncs.
After an external navigation (add menu, rule editor dismissal,
manage-servers/show-runtime actions) the sidebar List still held
its stale cached selection and wrote it back into the custom
selection binding during a view update; the resulting publish
warned and would bounce the navigation back. Route the sidebar
selection through a SwiftUI-managed @State with onChange hops in
both directions (selection -> navigate, route -> backfill), anchor
the seed on WorkspaceRoute.initialDestination, and pin the
alignment with a regression test.
2026-10-03 03:38:07 +08:00
Qiu Yuzhou a5d96dc990 refactor(rules): keep one conversion path 2026-10-03 02:55:48 +08:00
Qiu Yuzhou fcd5645b68 refactor(rules): slim built-in snapshots 2026-10-03 02:34:04 +08:00
Qiu Yuzhou 5b7a522b7a fix(route): make same-destination navigation a no-op
The sidebar List selection binding can be written back during view
updates (macOS List/NavigationSplitView selection re-sync on row
content changes); publishing from the setter then triggered the
"Publishing changes from within view updates" runtime warning. Guard
navigate(to:) against same-value writes and pin the no-publish
invariant with a regression test.
2026-10-03 01:17:16 +08:00
Qiu Yuzhou 589345f484 feat(rules): add batch custom rule deletion (#80) 2026-10-03 01:06:02 +08:00
Qiu Yuzhou 17672ff655 feat(rules): add custom rule editor (#79)
Add versioned sheet-local drafts, normalized previews, custom identity validation,
and explicit saves through the existing rule-document transaction. Preserve UUIDs,
builtin memberships, disabled identities, and deployment recovery outcomes.

Include approved Chinese and English editor copy. Verify public Workflow commands,
the production Controller adapter with hostless tests, and compiled bilingual
resources. Visual acceptance remains manual.
2026-10-03 00:47:06 +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 73f8358aa2 perf(rules): precompute collection sort keys 2026-10-02 23:04:04 +08:00
Qiu Yuzhou 63cb42da2a fix(rules): keep enablement feedback stable and accurate (#78)
Reserve one toolbar status area through saving, deployment, and collection
refresh. Show counted transient success and persistent actionable failures,
with distinct applied, unchanged-runtime, and deferred-save results.

Keep cached rows when collection reload fails. Require explicit refresh
and fresh selection after a version conflict.

Validation: 774 hostless tests passed with local ad-hoc signing. Format,
lint, two-axis review, and isolated Chinese/English view rendering checked.
2026-10-02 22:37:02 +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 beaa92781a feat(rules): add independent offline address tests
Implement #77 using the complete saved versioned rule collection. Normalize domain, IP, and URL hosts; preserve three outcomes and all deciding identities, source memberships, and other target-specific matches without DNS or runtime dependencies.

Invalidate results when the target changes or refresh starts, and reject late asynchronous publication. Add the native address test panel and approved Chinese/English copy.

Validation: 760 hostless tests and 2 fixed-sslocal semantics smoke tests passed; ad-hoc Debug build passed. Changed-file format/lint clean; existing repository warnings remain. Standards and Spec reviews found no issues. Visual acceptance remains manual.
2026-10-02 20:59:26 +08:00
Qiu Yuzhou cb5a535297 feat(rules): simplify details and open conversion reports in a window 2026-10-02 20:38:23 +08:00
Qiu Yuzhou b8958957f0 fix(rules): stabilize report expansion and window layout
Bound source metadata and conversion reports to a scrolling region so expansion does not compete with the native table for window constraints. Replace the nested split with a fixed source list and flexible table to keep the rules page inside the main window.

Defer native binding writes until after the current view update, merge filter edits into the latest query, and suppress unchanged query and selection publications.

Validated with 744 hostless tests, an unsigned Debug build, and isolated native window checks at 920x738 and 920x580, including real source selection and disclosure clicks.
2026-10-02 18:10:00 +08:00
Qiu Yuzhou 3db66f5fff feat(rules): add read-only rule browsing (#76) 2026-10-02 17:18:08 +08:00
Qiu Yuzhou 280a3fe6fe fix(rules): make validation and ACL order independent (#75)
Normalize source-independent match/action identities while preserving custom UUIDs. Analyze complete valid candidates for same-action coverage and full or partial opposite-action shadowing without dropping saved intent. Keep duplicate and fixed-local conflicts blocking, including mapped IPv6.

Canonicalize ACL entries without changing runtime source selection or proxy-default skeleton. Verify persistence and no-restart reordering through the Controller, collection permutations, and pinned sslocal loopback comparisons.

Validation: 728 hostless tests and 2 pinned-binary smoke tests passed with ad-hoc arm64 signing; format, lint (3 existing warnings, 0 errors), and diff checks passed. No real system-proxy writes or automatic visual checks.
2026-10-02 16:34:52 +08:00
Qiu Yuzhou 4a0a72c6cf feat: observe and repair system proxy configuration (#73) 2026-10-01 23:29:56 +08:00
Qiu Yuzhou 1c706aa65f feat: redesign home server activation tree
Preserve catalog hierarchy and order, separate selection from activation, and mark active targets and ancestors. Persist independent home expansion preferences and support explicit locate and keyboard navigation.

Show server names only and surface activation eligibility, skipped members, and failures. Refine row status visibility and use semantic selection colors for outlined activation buttons, including hover, pressed, disabled, contrast, and inactive-window states.

Validation: 695 hostless macOS arm64 tests passed for the tree implementation; 7 focused tests and ad-hoc app compilation passed after the semantic button refinement. Format and lint checks passed. Native UI interactions and theme changes remain unverified.
2026-10-01 19:03:48 +08:00
Qiu Yuzhou a7465154d2 ui(app): show selected address details as caption lines for #72
收起状态按钮只显示当前选中 IP;接口名称(接口:…)与地址类型
(地址类型:…)以说明行展示在按钮下方,与菜单项的 title/subtitle
结构对应。模型移除不再被呈现层使用的 label 组合字段。
2026-10-01 16:06:53 +08:00
Qiu Yuzhou 149cf39ea4 ui(app): render command address annotation as menu subtitle for #72
按 ifconfig 同源的 IPv6 类型注记改为次要文本行呈现:

- 菜单项用两个 Text 桥接 NSMenuItem 原生 subtitle(macOS 14+ 官方机制,
  Apple adaptive controls technote),主行 {IP} - {name} 不再内联注记
- 选择器下方新增说明行「地址类型:{注记}」——无论菜单桥接行为如何,
  当前选中地址的类型始终可见
- TerminalCommandAddress.label 收回纯主行,注记保持独立呈现事实;
  地址身份与命令内容不受影响
2026-10-01 15:43:31 +08:00
Qiu Yuzhou 111fa93131 feat(app): annotate and filter IPv6 command addresses by kernel flags for #72
经 SIOCGIFAFLAG_IN6 逐地址查询内核 IPv6 标志(与 ifconfig 的注记同源,
Darwin 模块不导出该 ioctl 请求宏,手工展开 _IOWR 编码):

- IN6_IFF_TEMPORARY(RFC 4941 隐私临时地址,会轮换)不进候选
- 其余 IPv6 候选在标签 IP 后附类型注记(位于中段):
  autoconf secured / autoconf / dynamic;标志查询失败不注记也不过滤
- 注记只进标签不进命令;地址身份仍为 BSD 接口名 + 规范化 IP

真实主机非视觉验证扩展:每 IPv6 地址标志查询非空、候选注记属 ifconfig
同源闭集、临时地址被过滤;替身用例覆盖 temporary 过滤与标签格式。
2026-10-01 15:19:26 +08:00
Qiu Yuzhou d647a4a859 refactor(app): address code review for #72
- 回环候选清单上收到 ListenerMode.compatibleLoopbackAddresses(Domain
  单点),proxyLoopbackAddress 派生为首项;策略不再复刻 mode→回环映射
- refreshCommandAddresses 更名 refreshTerminalCommands(返回命令的语义)
- 监视创建失败注明为尽力而为增强(进入首页/复制前刷新兜底)
- HTTPExportCapability 注释与首页完整命令的地址选择划清边界
2026-10-01 10:16:00 +08:00
Qiu Yuzhou b26954dd20 feat(app): home terminal command address picker for #72
非「仅本机」监听方式下,首页命令卡在复制按钮上方提供单选 IP 下拉框:
候选仅含回环与当前启用 Wi‑Fi/Ethernet 接口单播地址(严格 SCNetworkInterface
类型白名单,排除 VPN/虚拟/未知类型),按监听地址族过滤(双栈含两个回环,
127.0.0.1 置顶;仅 IPv6 默认 ::1),标签 {IP} - {name}(本地化名称缺失回退
BSD 名)。两种 shell 的 HTTP/HTTPS/SOCKS 端点共用选中地址,端口取已保存
监听事实,IPv6 URL 方括号;选择会话内有效(跨首页返回保留、重启重置),
失效自动回退默认回环。进入首页、网络变化(SCDynamicStore 监视+去抖)与
复制前刷新。

- 新缝 LocalInterfaceFactsReading:原始接口事实(地址/类型/名称)+ 变化
  通知;生产适配器封装 getifaddrs/SCNetworkInterface/SCDynamicStore 细节
- 运行时缝以 listenFacts 替换 terminalProxyEnvironmentCommands;命令派生
  移至工作流层(监听事实 + 生效选择)
- 替身测试证明策略行为;真实主机非视觉验证证明系统适配器整合
  (回环识别/类型映射/地址规范化/链路本地判定)
2026-10-01 10:06:52 +08:00
Qiu Yuzhou 2f8c4dbc2a fix(app): keep server tree collapse state across destinations
Both server trees held collapse state inside the destination
subtree — ServersView relied on OutlineGroup's built-in expansion
state and the home target tree kept a local @State set — so every
destination switch destroyed it. Hoist a shared
CatalogExpansionState to the composition root; the servers sidebar
and the home target tree now read and write one collapse set.

ServersView replaces OutlineGroup with a manual collapse tree
(flattened visible rows, .tag keeps List selection), trading away
OutlineGroup's arrow-key expand/collapse. MainApp extracts
makeRuntimeController to stay within the function-body lint budget.
2026-09-30 21:50:09 +08:00
Qiu Yuzhou 7d0ebc79b4 refactor(tests): drop TEST_HOST by linking tests against app-source static lib
单测不再以 app 可执行为宿主:新增 ShadowsocksX-NG2Core 静态库 target 同源
编译 App/(除 @main)与 Domain/,模块名沿用 ShadowsocksX_NG2 使全部测试的
@testable import 零改动;app target 模块改名 ShadowsocksX_NG2App 避免共享
Products 目录 swiftmodule 撞名。两个测试 target 改链 Core 后 xcodegen 不再
生成 TEST_HOST,xcodebuild test 只构建不启动 app——与安装版运行实例零接触
(pgrep 全程验证无 app 进程)。同源双编译沿用 Agent/Helper 共享 Domain 文件
的既定模式,Core 只被测试 target 依赖,发布链不编译它。

随之删除 MainApp.swift 的整套测试宿主脚手架(isUnitTesting/makeTesting/
Noop 服务/Ephemeral 存储,-142 行),app 在测试下不再启动,守卫失去存在
理由。宿主移除暴露三处 Bundle.main 依赖,改为显式缝:控制器新增 appBundle
注入(内置规则快照 BuiltinRuleCatalog 与 LaunchDaemon 清单指纹
launchDaemonPlistData(in:) 均按 bundle 读取,生产默认 .main 不变);XPC
listener delegate 期望客户端身份改为可注入(测试按本进程 SecCode 自查)。
测试经 AppArtifact.bundle(沿测试包落盘位置向上查找 app 产物,兼容
TEST_HOST 内嵌与平级两种布局)统一取产物。

665 单测 + 11 冒烟全绿,task build 生产构建不受影响。
2026-09-30 20:44:13 +08:00
Qiu Yuzhou ac60d14099 refactor(tests): locate app product via bundle ancestor walk, not Bundle.main
测试需要 app 产物(嵌入二进制、打包面断言)时改经 AppArtifact 沿测试包
落盘位置向上查找 ShadowsocksX-NG2.app,覆盖两种布局:TEST_HOST 过渡期
.xctest 嵌于 Contents/PlugIns/,去宿主化后与 .app 平级。接触点:
AgentLifecycleTests wrapper、BundleManagedPluginProviderTests 组合根事实
断言、smoke 三处 sslocal/wrapper/plugin 定位、SkeletonTests 改读产物
Info.plist。行为等价(665 单测 + 11 冒烟全绿),为去 TEST_HOST 铺路。
2026-09-30 20:05:37 +08:00
Qiu Yuzhou ec92628939 fix(system-proxy): wait out launchd throttle before re-registering drifted job
实测(BTM uuid 不变、runs 持续累加):注销后立即重注会命中 launchd 尚未移除
的旧 job 定义,SMAppService 照常返回成功但定义不刷新,EX_CONFIG 循环继续。
注销后等过 minimum runtime(10s)节流窗再重注,launchd 才导入新定义
(program identifier + parent bundle 形态)并以新定义拉起 daemon。间隔经
controller 注入,生产 15s、用例 10ms。

已在实机验证全链路:BundleProgram 定义导入 → launchd 按需拉起 root daemon →
客户端签名校验 → apply 写入 SystemConfiguration(scutil --proxy 呈现
SOCKS/HTTP/HTTPS 指向本地入口,PAC 与自动发现关闭)→ 应答返回 → 二次收敛走
等价零写入路径。
2026-09-30 19:15:06 +08:00
Qiu Yuzhou 43ea00cb44 fix(system-proxy): use BundleProgram in daemon plist and refresh stale registration
launchd 对 ProgramArguments[0] 的相对路径按 _PATH_STDPATH(PATH)解析而非
bundle:系统域 daemon 的 job 因此永远 spawn 失败(EX_CONFIG 节流循环,
launchctl print 显示 job state = spawn failed、runs 持续累加),客户端 XPC
调用只能等到超时。agent 之所以正常,是 GUI 域导入时被解析成绝对路径,system
域 submitted job 没有这一步。SMAppService 清单的正确键是 BundleProgram
(bundle 相对,launchd.plist(5)),改用之。

launchd 同时沿用注册提交时的定义快照:app 更新改动 LaunchDaemon 清单后旧
定义不会自动刷新(register() 对已注册服务返回 alreadyRegistered),必须注销
重注。门禁在已批准分支按清单内容 SHA-256 指纹(UserDefaults)检测漂移,漂移
才注销重注——审批与 bundle 签名绑定,重注不重新弹授权;首次注册成功即记指
纹,失败不记(下次启动重试),指纹一致为一次哈希比对的 no-op。
2026-09-30 18:54:19 +08:00