Conversation
明确服务端模块装配、生命周期资源释放及未来定制版演进边界。 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
提供与业务无关的类型安全应用装配和统一资源生命周期,为不同 Profile 组合保留稳定边界。 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
将社区路由和启动链收敛到单一过渡模块,使进程入口只负责配置、监听与退出策略,并保持现有行为边界。 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
固定跨平台文本规范,并清除阻塞全仓静态检查的既有 Biome 警告。 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
背景
原
src/index.ts同时承担环境配置、Elysia 路由装配、业务资源启动、listen、signal 和 shutdown。模块顺序依赖入口中的代码位置,应用也无法在不启动真实外部资源的情况下完整构造。本 PR 引入代码级 App Builder,把“应用如何组合”与“进程如何启动”分离,同时保持社区默认应用与改造前完整等价。
设计与评审文档
建议按以下顺序评审:
docs/design/2026-09-04-app-builder-design.mddocs/adr/0001-application-profile-composition.mddocs/arch/24-application-bootstrap.md三类文档职责有意分离:Design 回答“准备怎样设计”,ADR 回答“为何长期采用”,Arch 回答“代码现在如何运行”。
前置稳定性修复与合并顺序
本 PR 依赖前置修复 #260。#260 不包含 App Builder 实现,而是修复
main中既有的跨测试全局状态泄漏与异步清理逃逸。#259 增加测试文件后改变了 fresh checkout 中未排序文件列表的枚举结果,从而暴露这些既有缺陷;失败不由 App Builder 的 Runtime、Profile 或 route 装配行为引起。为避免扩大本 PR 的架构评审范围,相关修复已独立到 #260。
本地已验证以下最终组合:
该组合在默认 Bun 1.4.2 和 CI Bun 1.3.14 下执行
precheck均为 8236 pass / 0 fail,build:web、docs:build、App Builder 定向测试和@fenix/server-runtime测试均通过。建议维护者按以下顺序处理:
main;feat/app-builder-foundation同步最新main;legacy-communitydisposer 对正式stopHermesClient()的实现与当前态文档接入;最终组合目前只存在于本地临时集成分支,尚未推送到 #259,避免在 #260 合并前产生重叠提交。
主要变更
@fenix/server-runtimeworkspace package:ApplicationBuilderApplicationRuntimeApplicationProfileServerModulesrc/application/:createCommunityBaseApp()负责固定横切能力community-defaultProfile 负责默认组合legacy-community过渡 Module 承接全部既有业务 routes、启动顺序和资源释放src/index.ts只保留环境、listen、signal 与退出策略.use(module)惰性累积~Routes,大型默认 route tree 从同一有序 tuple 推导静态类型和运行时顺序。设计边界
app.stop() → abort signal → reverse Module disposers。legacy-community仅是无行为变化接入 Runtime 的过渡边界,不代表已经确认的领域模块或企业扩展 API。如何试用
最小自定义 Profile(无需生产数据库或 API key):
命令只监听
127.0.0.1的系统分配端口,并输出/example页面地址。页面展示当前 Profile、Module、复用的 Community base app、已省略的legacy-community,以及可访问的 health/ping routes;Ctrl+C 经 Runtime stop 关闭 listener。完整默认应用仍使用:
bun run dev # 或 bun run start完整调用链为:
验证
在干净 tracked-source 快照中,使用与 upstream CI 相同的 Bun 1.3.14 验证:
bun install --frozen-lockfile:2452 packages;package.json与bun.lock安装前后哈希不变bun run precheck:8232 pass / 0 fail(format、import-sort、server/web tsc、lint、tests 全绿)bun run --cwd packages/server-runtime typecheckbun run --cwd packages/server-runtime test:15 pass / 0 failbun run --cwd packages/server-runtime examplebun run docs:build/example200,/example/ping200,无 Better Auth /DATABASE_URL/RCS_API_KEYS告警兼容性
/api/*、/web/*、ACP、MCP 或 WebSocket 对外协议。🤖 Generated with Claude Code