Repository navigation
feat(swift): rutis-host 的 runtimes.swift、dev、check、new --lang swift 与指南(#387) - #495
Merged
Merged
Conversation
#387) - rutis-host:语言注册表加 Swift(languages/swift.rs);编译型语言(Go、Swift)共用的宿主部分抽到 languages/binary.rs(BinaryHost、DevBuild),Host.go 改为 Host.binaries;config 的 GoRuntime 改名 BinaryRuntime(GoRuntime / SwiftRuntime 为别名) - runtimes.swift:与 runtimes.go 同样的设置与语义(按需启动、空闲停止、eager、restart) - dev:据 Package.swift 认出 Swift 项目,swift build 后复制到 .rutis/swift/<产品>-<n>,改代码只重启这个运行时 - check:列出 Swift 二进制;插件 API 低于 3 的旧 SDK 二进制失败并提示重新构建(Go 同样) - new --lang swift:Package.swift(rutis 依赖、Info.plist 经 linkerSettings 链入)、@RutisConfig / @RutisClient / @RutisService 示例、Swift Testing + RutisTest 测试、发布通用二进制的工作流 - Swift SDK:serve 时让运行时为自己负责(posix_spawn SETEXEC + disclaim),TCC 授权提示指向插件二进制 - 测试:swift_rows 加按需 / 空闲停止 / on-failure / exit;rutis-host tests/swift.rs;e2e dev_loop 加 Swift - 文档:Swift 插件指南(中英)、rutis-host 指南、plugin-api 的 Swift 列去掉预览、README
This was referenced Oct 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#387(Swift S2)的第一部分:按需启动与重启策略的 Swift 测试、rutis-host 的
runtimes.swift、dev、check、new --lang swift,以及 Swift 插件指南。设计:Swift SDK §3.4、§八、§十、§十一、§十五 S2。rutis-host
languages/swift.rs(一个文件 +LANGUAGES一行)。Go 原来独有的宿主部分(GoHost、go_restart、dev的重建循环、check的二进制列表、状态行)抽到languages/binary.rs:BinaryHost(按语言擦除类型的 resolver + runtimes 句柄)与DevBuild(项目自己的构建),Language::dev_build默认None。Host.go改为Host.binaries+binaries_of(key);Followed.go同样。config.rs:GoRuntime改名BinaryRuntime(GoRuntime/SwiftRuntime为别名,GoStart为BinaryStart的别名),新增runtimes.swift,字段与runtimes.go相同;validate(key)的消息带语言键。runtimes.swift:按需启动、空闲停止、eager、restart(no/on-failure/exit,每个运行时各自)全部走binary.rs,与 Go 同一份代码。远程language: "swift"也随注册表接受。dev:没有rutis.dev.json时据Package.swift判定 Swift 项目;产品是Sources/<包名>/main.swift的目标,否则第一个带main.swift的目标。swift build --product <产品>后复制到.rutis/swift/<产品>-<n>(新文件:运行中被原地改写的二进制不再符合签名),替换后只重启这个运行时;构建失败打印编译器错误,旧的继续运行。check:swift binaries:与go binaries:同格式;插件 API 低于 3 的二进制(0.13 以前的 SDK,会话会被拒)报incompatible: built with an SDK older than rutis 0.13; rebuild it with the 0.13 SDK or later并失败(Go 同样适用)。首行改为plugin API for Go and Swift binaries: 3 …。new --lang swift:Package.swift(依赖https://github.com/arcships/rutis,linkerSettings用-sectcreate __TEXT __info_plist链入Info.plist)、Info.plist(CFBundleIdentifier/CFBundleName,注释列出常用用途说明键)、Sources/<Type>Plugin/Plugin.swift(@RutisConfig、@RutisClient、@RutisService)、Sources/<name>/main.swift、Swift Testing +RutisTest的测试、rutis.dev.json、发布工作流(macOS runner 上swift build --arch arm64 --arch x86_64出通用二进制,有 secrets 时 Developer ID 签名 + 公证)。new新增占位{{Type}}/__Type__(net-probe→NetProbe)。Swift SDK
Rutis.serve开始服务前让运行时为自己负责:若 macOS 认定的负责进程不是自己,用posix_spawn(POSIX_SPAWN_SETEXEC)+responsibility_spawnattrs_setdisclaim原地重新执行自己(同一 pid、同样的描述符和通道)。这样 TCC 的授权提示与授权记在插件二进制上(设计 §八),不论谁启动它;两个函数是 libsystem 的(10.14 起),运行时查找,找不到就不变。实测:经 rutis-host 启动的 Swift 运行时负责进程就是它自己(tests/swift.rs断言)。ping加responsible()(pid 与负责进程的 pid)。测试(本机 macOS 26.6 / Swift 6.3.2)
swift_rows(新 3 个)on-failure:崩溃后重启、行恢复,之后空闲停止不算结束、不重启;exit:报告结束、保持停止rutis-host --test swift(新)runtimes.swift的行在它的二进制里运行,restart: on-failure崩溃后回来,负责进程是运行时自己;check列出 Swift 二进制并让旧 SDK 二进制失败rutis-e2e --test dev_loopthe_swift_plugin_development_loop:new --lang swift→swift test→check→dev→ 改代码(swift-demo: rebuilt and restarted)→ 写坏(报Plugin.swift:5:,旧的继续)→ 修好 → Ctrl-C;只保留正在运行的构建,Python 运行时(探针)没有重启rutis-host全部node, bun, python, go or swift、… go.mod or Package.swift、runtimes未知字段列表)随之更新RutisSelfTest32、runtime_conformance/value_roundtrip/session_matrix的 Swift 列、swift_runtime、multilang_swift、caller_rows、sync_cyclese2e 的残留检查新增放行 SwiftPM / swift-driver 留在 TMPDIR 的
TemporaryDirectory.*、swift-generated-sources、_<路径>.lock(工具自己的,不是宿主的)。CI
runtimes-swift加cargo test -p rutis-host --test swift与rutis-e2e的 Swift 开发循环;路径过滤加tests/e2e/tests/dev_loop.rs。文档
docs/guide/swift-plugin.md/.en.md:创建、写(方法、同步、使用服务、调用链、并发、取消、值表含Decimal/Date说明、错误)、事件、测试、dev、系统权限(TCC)、发布通用二进制、被宿主使用。指南里的代码已在一个用本仓库 SDK 的包里编译并跑过测试。远程(listen:/dial:)一节随下一个 PR。rutis-host指南(中英):runtimes.swift、dev/check/new、重启、行名。plugin-api(中英):Swift 列去掉“预览”;指南索引、包表、环境;README 的语言列表与包说明;swift/README去掉预览说明。与设计稿的出入(实现时定的)
dev用 debug 配置构建(设计 §十一 写的是-c release):开发循环要快;发布工作流用 release。serve时原地重新执行自己来解决(见上),宿主不用改。S2 剩下的:WebSocket
listen:/dial:与一致性 Swift 列(下一个 PR),EventKit 的 TCC e2e 与 agent skill(最后一个 PR,Closes #387)。