feat: publish Dever core with project scaffolding and versioned AI skills
This commit is contained in:
1 parent
70fa73cdc2
commit
ac458ffa7f
960 files changed
+221319
-1163
No files matched your search
@@ -0,0 +1,4 @@
|
||||
{"file":".trellis/spec/backend/quality-guidelines.md","reason":"核对允许的离线定向检查和测试入口兼容性"}
|
||||
{"file":".trellis/tasks/09-29-build-cache-storage/research/cache-boundaries.md","reason":"复核 clean 与机器级 cache clean 的安全边界"}
|
||||
{"file":".trellis/spec/backend/error-handling.md","reason":"复核失败清理、符号链接拒绝和原始错误保留"}
|
||||
{"file":".trellis/spec/backend/directory-structure.md","reason":"复核 owner 唯一性并避免平行缓存实现"}
|
||||
@@ -0,0 +1,76 @@
|
||||
# Design
|
||||
|
||||
## Boundaries
|
||||
|
||||
本任务只修改编译器仓库构建策略、native runtime 准备路径和 CLI 临时产物清理。Cargo 开发产物由 Cargo profile 管理;native runtime 依赖由 `dever-core::native::build` 管理;项目命令解析由 `dever-cli` 管理。机器级缓存继续归 `deverd` 合同所有。
|
||||
|
||||
## Cargo Profiles
|
||||
|
||||
根 `Cargo.toml` 增加 dev/test profile:
|
||||
|
||||
```toml
|
||||
[profile.dev]
|
||||
debug = 0
|
||||
incremental = false
|
||||
|
||||
[profile.test]
|
||||
debug = 0
|
||||
incremental = false
|
||||
```
|
||||
|
||||
这把多个任务已经稳定使用的命令级覆盖固化成仓库默认值。release profile 不变。测试目标、文件和选择命令全部保留。
|
||||
|
||||
## Native Runtime Layout
|
||||
|
||||
当前每个 profile 都有完整 target:
|
||||
|
||||
```text
|
||||
target/native-runtime/<profile>/release/...
|
||||
```
|
||||
|
||||
改为一个共享 Cargo target 和不可变的精确输入视图:
|
||||
|
||||
```text
|
||||
target/native-runtime/
|
||||
cargo/ shared Cargo target
|
||||
inputs/<identity>/ exact runtime/dependency files for one build identity
|
||||
operations/ build locks/staging
|
||||
```
|
||||
|
||||
`runtime_library` 根据 database、api、crypto、wire、external 得到规范化 feature 集。Cargo 使用 `--message-format=json-render-diagnostics` 报告本次图中的产物;代码通过结构化 JSON 解析收集当前 `dever-runtime` 及其依赖的 rlib/dylib,不扫描并吞入整个历史 `release/deps`。
|
||||
|
||||
收集后的文件先写入同一文件系统的 staging,再按内容身份原子发布到 `inputs/<identity>`。相同文件优先使用硬链接以复用共享 target 的磁盘块;不支持或失败时复制。已发布输入视图只读且不可变,`RuntimeInputs` 继续对精确文件集合计算身份并在编译前复核。并发操作使用 create-new 锁和 staging,失败只清理本次 staging。
|
||||
|
||||
## Temporary Directory Contract
|
||||
|
||||
`BuildDirectory` 保留 RAII 清理。创建目录时增加固定格式 owner marker,至少包含格式版本、创建时间、进程 ID 和当前编译器身份。清理逻辑集中在 `native/build`,不在 CLI 复制一套删除规则。
|
||||
|
||||
自动清理和显式 clean 共同调用这一逻辑:
|
||||
|
||||
1. 只枚举系统临时目录直属的 `dever-build-<pid>-<id>`。
|
||||
2. 使用 `symlink_metadata`,拒绝符号链接和非真实目录。
|
||||
3. marker 必须完整匹配且创建时间达到 24 小时过期阈值。
|
||||
4. 当前进程目录永不删除;不满足任一条件即跳过。
|
||||
5. 删除前统计普通文件字节数,返回结构化 summary。
|
||||
|
||||
24 小时阈值避免误删并发或长时间构建;正常流程仍由 `Drop` 立即清理,因此阈值只影响异常退出遗留物。
|
||||
|
||||
## Run Flow
|
||||
|
||||
`NativeProgram` 已拥有可执行文件和临时目录,`run_native` 直接执行 `native.executable()`。借用在子进程退出前持续有效,随后 `NativeProgram` 的 `BuildDirectory` 统一回收。删除 `StagedExecutable` 和项目根二次复制路径。
|
||||
|
||||
## Clean Command
|
||||
|
||||
CLI 增加 `Action::Clean` 和 `clean <project-root>` 参数合同。launcher 把它视为普通项目命令,用项目的 `config/setting.json` 选择版本后原样分派。
|
||||
|
||||
核心不解析或修改项目源码,只调用 native build 的限定清理 API,并兼容清理项目根中符合旧 `.dever-run-<pid>` 命名、普通文件、当前用户和 24 小时阈值的历史遗留物。输出固定摘要,不把未删除的未知文件当作成功删除。
|
||||
|
||||
该命令不接触 `target/debug`;编译器贡献者仍使用 `cargo clean` 管理 Cargo 开发产物。它也不接触机器共享缓存;后者仍是 `dever cache clean`。
|
||||
|
||||
## Compatibility And Rollback
|
||||
|
||||
- Dever 源码、配置、语言行为和 release 构建参数不变。
|
||||
- 现有测试目标名与定向命令不变。
|
||||
- 旧 `target/native-runtime/<profile>` 不再读取;可由 `cargo clean` 删除,不提供双路径兼容。
|
||||
- 共享 runtime target 若出现问题,可回滚 `native/build` 布局而不迁移项目数据;所有相关内容均可重建。
|
||||
- clean 只删除严格识别的过期临时产物,回滚不需要恢复数据。
|
||||
@@ -0,0 +1,4 @@
|
||||
{"file":".trellis/spec/backend/directory-structure.md","reason":"确认 native build、CLI、测试目录和单一 owner 边界"}
|
||||
{"file":".trellis/tasks/09-29-build-cache-storage/research/cache-boundaries.md","reason":"保持 locked/offline 工具链、launcher 与机器共享缓存合同"}
|
||||
{"file":".trellis/spec/backend/error-handling.md","reason":"保持临时目录生命周期、原子发布和清理错误合同"}
|
||||
{"file":".trellis/spec/backend/quality-guidelines.md","reason":"遵守定向测试与低磁盘验证约束"}
|
||||
@@ -0,0 +1,67 @@
|
||||
# Implementation Plan
|
||||
|
||||
## 1. Cargo Development Footprint
|
||||
|
||||
- [x] 在根 `Cargo.toml` 固化 dev/test 的 `debug = 0` 与 `incremental = false`,保留 release profile。
|
||||
- [x] 增加静态回归,确认 profile 合同及所有既有 `[[test]]` 目标仍存在,不移动或合并测试源码。
|
||||
|
||||
## 2. Shared Native Runtime Target
|
||||
|
||||
- [x] 把 runtime feature/profile 规范化为单一 build key,复用现有 runtime 身份与 native cache owner。
|
||||
- [x] 使用一个 `target/native-runtime/cargo` 执行 locked/offline Cargo build,并解析 Cargo JSON 产物消息。
|
||||
- [x] 原子发布只包含当前构建图精确文件的不可变 `inputs/<identity>`;复用公共文件且拒绝符号链接、缺失文件和不完整 staging。
|
||||
- [x] 让 `RuntimeInputs` 消费显式文件清单,不再扫描整个 `release/deps`。
|
||||
- [x] 增加 base、API、SQLite、PostgreSQL、component/external profile 隔离、复用、失败和并发定向测试。
|
||||
|
||||
## 3. Temporary Build Cleanup
|
||||
|
||||
- [x] 为 `BuildDirectory` 增加 owner marker 与统一 cleanup summary;正常 `Drop` 行为保持。
|
||||
- [x] 在创建 native build 前执行有界的 24 小时过期清理,跳过当前、未知、未过期和符号链接目录。
|
||||
- [x] `run_native` 直接执行 `NativeProgram::executable()`,移除项目根 staging 和 `StagedExecutable`。
|
||||
- [x] 增加成功、编译错误、子进程失败、过期目录和恶意同名路径的定向回归。
|
||||
|
||||
## 4. Clean Command
|
||||
|
||||
- [x] 给版本核心增加 `clean <project-root>` 解析和执行;输出删除目录、文件及字节汇总。
|
||||
- [x] 给稳定 launcher 增加项目根识别和帮助文本,保持 `dever cache clean` 的认证服务失败合同。
|
||||
- [x] 兼容回收严格匹配且过期的旧 `.dever-run-*` 普通文件,不删除显式 output 或其它隐藏文件。
|
||||
- [x] 增加 CLI 参数、版本分派、限定删除和重复 clean 幂等测试。
|
||||
|
||||
## 5. Documentation And Verification
|
||||
|
||||
- [x] 更新 README、backend directory/toolchain/error/quality 规范,说明三种清理边界与默认低磁盘 profile。
|
||||
- [x] 运行 `git diff --check`。
|
||||
- [x] 运行 core/CLI/runtime 的 offline focused check,不运行 workspace 全量测试。
|
||||
- [x] 分别选择 default、API、SQLite、PostgreSQL、component 的最小定向编译或测试;PostgreSQL 只编译,不连接数据库。
|
||||
- [x] 测量 fresh target 和重复执行后的占用,验证低于 16 GiB 基线的 40% 且无变化重复增长不超过 5%。
|
||||
- [x] 复查磁盘空间、临时目录和项目根,确认没有遗留本轮测试产物。
|
||||
|
||||
## Completion Evidence (2026-09-29)
|
||||
|
||||
- `cargo check --offline --locked -p dever-core -p dever-cli` passed.
|
||||
- `deverc` argument tests passed 5/5; local clean, selected-version launcher dispatch and authenticated `cache clean` refusal regressions passed.
|
||||
- Exact runtime input publication/reuse/concurrency regression passed. Actual native base, API, SQLite, PostgreSQL and external/component profile checks passed; PostgreSQL was compile-only and opened no database.
|
||||
- The runtime layout contains one `target/native-runtime/cargo` plus content-addressed `inputs`; no per-feature Cargo target remains. Repeating the external native check changed target usage from 1,625,111,299 bytes to 1,625,111,299 bytes (0%).
|
||||
- The final focused matrix used 1,642,122,909 bytes (about 1.64 GB), 10.2% of the former 16 GiB baseline and below the 6.4 GiB budget. `target/debug/incremental` is an empty Cargo-created directory (0 files, 4 KiB), not an incremental object cache.
|
||||
- No `/tmp/dever-build-*` or project `.dever-run-*` artifact remained. Final filesystem availability was about 17 GiB.
|
||||
- `cargo fmt --all --check` and `cargo clippy ...` were unavailable because the installed toolchain lacks rustfmt and clippy. Workspace-wide tests, real PostgreSQL, frontend builds and performance/RSS benchmarks were not run by scope.
|
||||
- Two pre-existing source fixtures were not counted as task verification: `rest_model::rest_field_bindings_are_checked_and_emit_static_search_sql` references missing generated `api_require_components`/`job_migrate_tenant`, and `sqlite_orm::database_failures_are_captured_after_transaction_rollback_and_task_wait` exposes a private `ReadResult` from `public main`. The selected SQLite and PostgreSQL profile checks passed through independent valid fixtures.
|
||||
|
||||
## Final Review Evidence (2026-09-29)
|
||||
|
||||
- Final review found and fixed three correctness gaps: runtime publication now selects the current `dever-runtime` manifest's hashed `release/deps` rlib instead of the mutable top-level Cargo alias; runtime input views reject symbolic links and unknown entries; stale cleanup preserves artifacts owned by any still-active recorded PID, not only the current process.
|
||||
- The clean regression now keeps both a marked build directory and legacy `.dever-run-*` file for a live child process. Input-view regressions cover concurrent publication, exact dependency sets, unknown files and symbolic links.
|
||||
- `cargo check --offline --locked -p dever-core -p dever-cli` passed after the fixes.
|
||||
- `cargo test --offline --locked -p dever-tests --test native_cache runtime_input_views -- --nocapture` passed 2/2; the real concurrent native publication test passed twice and left no temporary artifact.
|
||||
- `cargo test --offline --locked -p dever-cli --test cms_project clean_removes_only_stale_owned_dever_artifacts -- --exact --nocapture` passed 1/1.
|
||||
- Selected-version launcher dispatch and authenticated `cache clean` refusal passed 1/1 each; `deverc` argument tests passed 5/5; the Cargo profile/test-target contract passed 1/1.
|
||||
- Repeating the same concurrent native check left `target/` at exactly 1,689,816,322 bytes (0% growth). Final follow-up checks left it at 1,689,817,710 bytes (about 1.69 GB, 10.6% of the former 16 GiB baseline). Only `cargo` and `inputs` exist directly under `target/native-runtime`; `target/debug/incremental` contains zero files.
|
||||
- No `/tmp/dever-build-*` or repository-root `.dever-run-*` remained. `git diff --check` passed and about 17 GiB remained available.
|
||||
- `rustfmt` and `clippy` remain unavailable because those toolchain components are not installed. Workspace-wide tests, real PostgreSQL, frontend builds and performance/RSS benchmarks remain not run by scope.
|
||||
|
||||
## Risks And Rollback Points
|
||||
|
||||
- Runtime input discovery depends on Cargo's JSON artifact contract. Missing or ambiguous current-manifest runtime artifacts fail explicitly instead of scanning historical files.
|
||||
- Process-state detection is conservative: an inspection failure preserves the candidate, so cleanup may leave an old artifact rather than risk deleting an active one.
|
||||
- The shared target and input views are rebuildable. Rollback removes this layout through `cargo clean`; no project data migration is involved.
|
||||
- Native test linking can still consume significant time and space even with deduplicated runtime inputs, so broad matrices remain opt-in.
|
||||
@@ -0,0 +1,74 @@
|
||||
# Dever 构建缓存与磁盘占用治理
|
||||
|
||||
## Goal
|
||||
|
||||
在不改变 Dever 程序语义、发布构建性能和现有定向测试入口的前提下,显著降低编译器开发与原生运行时构建的磁盘占用,并让 Dever 自有临时产物可以可靠回收。
|
||||
|
||||
## Background
|
||||
|
||||
- 2026-09-29 清理前,仓库 `target/` 占用约 16 GiB:`target/debug/deps` 约 11 GiB、`target/debug/incremental` 约 2.3 GiB、`target/native-runtime` 约 2.3 GiB。
|
||||
- `test/dever-tests` 有 67 个独立集成测试目标。每个目标都会单独链接 Dever runtime;清理前单个 debug 测试程序约 120-173 MiB。
|
||||
- 多个既有任务已经通过命令行反复使用 `profile.dev.debug=0`、`profile.test.debug=0` 和 `build.incremental=false` 避免磁盘耗尽,说明这些设置是已验证的仓库开发约束,但尚未固化。
|
||||
- `crates/dever-core/src/native/build.rs` 当前按 `base/database/sqlite/postgres` 与 `api/crypto/wire` 组合创建独立 Cargo target;公共依赖因此被完整复制到每个 profile 目录。
|
||||
- `BuildDirectory` 已在正常返回和普通错误时通过 `Drop` 清理,但进程被强制终止或链接器崩溃时仍会留下 `/tmp/dever-build-<pid>-<id>`。
|
||||
- `dever cache clean` 已属于机器级共享缓存合同,必须等待认证 `deverd` IPC;本任务不得以本地直写方式绕过该安全边界。
|
||||
|
||||
## Requirements
|
||||
|
||||
### R1. Cargo Development Profiles
|
||||
|
||||
- 在仓库 Cargo 配置中固化 dev/test 的低磁盘设置,不再依赖每条验证命令重复传入临时覆盖项。
|
||||
- dev/test 不生成完整调试信息且禁用增量对象;release 的 `fat LTO`、优化级别和最终程序行为保持不变。
|
||||
- 保留现有独立测试目标及 `cargo test --test <name>` 合同;本阶段不通过合并测试文件换取空间。
|
||||
|
||||
### R2. Shared Native Runtime Build Target
|
||||
|
||||
- 所有 runtime feature profile 共享一个 Cargo 构建 target,公共依赖只保存一份。
|
||||
- 每次 native 编译只消费当前 Cargo 调用实际报告的 runtime 与依赖产物,不把其它 profile 的历史依赖混入缓存身份或链接输入。
|
||||
- 不同数据库/API/加密/wire/external profile 仍有独立、完整且可验证的 runtime 身份;并发构建不得读到正在改写的半成品。
|
||||
- 继续使用 locked/offline Cargo,不引入网络、环境配置或第二套构建协议。
|
||||
|
||||
### R3. Temporary Build Ownership
|
||||
|
||||
- 正常成功、编译失败和运行结束继续即时清理本次临时目录。
|
||||
- `run` 直接执行 `NativeProgram` 已拥有的临时可执行文件,不再向项目根复制 `.dever-run-<pid>`。
|
||||
- 临时目录写入 Dever 自有标记;启动构建和显式清理只处理名称、标记、类型、属主和年龄均符合合同的目录。
|
||||
- 清理拒绝符号链接、未知目录、活跃或未达到过期阈值的目录;清理失败不得掩盖原始编译或运行错误。
|
||||
|
||||
### R4. Local Clean Command
|
||||
|
||||
- 版本核心提供 `clean <project-root>`,开发入口 `deverc` 与正式 launcher 分派后的 `dever` 使用同一实现。
|
||||
- 命令只回收当前用户的 Dever 过期临时构建目录和旧版遗留的过期 `.dever-run-*`,并输出删除数量与字节数。
|
||||
- 命令不得删除显式 build 输出、项目源码/配置/data、Cargo registry、Lib 缓存、机器共享缓存或其它项目文件。
|
||||
- `dever cache clean` 的名称、失败合同和认证 IPC 边界保持不变。
|
||||
|
||||
### R5. Documentation And Regression Coverage
|
||||
|
||||
- README 和 toolchain 规范明确区分 `clean`、`cache clean` 与编译器仓库维护用的 `cargo clean`。
|
||||
- 测试覆盖参数解析、限定删除、符号链接拒绝、未过期目录保留、runtime profile 隔离和共享依赖复用。
|
||||
|
||||
## Acceptance Criteria
|
||||
|
||||
- [ ] dev/test profile 默认不生成完整 debuginfo,也不创建 incremental 目录;release profile 保持原值。
|
||||
- [ ] 现有 `cargo test --test <name>` 入口不变,至少一个默认、API、SQLite、PostgreSQL 和 component 定向目标可以继续被单独选择。
|
||||
- [ ] 连续准备至少两个不同 runtime profile 时只存在一个 Cargo target,公共依赖不再按 profile 复制;每个 profile 链接到自身准确的 runtime 产物。
|
||||
- [ ] 并发或失败的 runtime 准备不会发布半成品,也不会让一个 profile 复用另一个 profile 的 runtime 身份。
|
||||
- [ ] `run` 不再创建项目根 `.dever-run-*`;成功和普通失败后本次临时目录不存在。
|
||||
- [ ] `clean <project-root>` 只删除符合 Dever 标记和过期规则的自有临时产物,并报告回收结果;未知文件、符号链接、未过期目录及显式输出保持不变。
|
||||
- [ ] `dever cache clean` 仍明确走机器共享缓存服务,未实现认证 IPC 时不允许本地回退。
|
||||
- [ ] 在全新 target 上完成允许的代表性 feature 定向检查后,`target/` 总占用不超过清理前 16 GiB 基线的 40%;重复同一组检查且源码不变时占用增长不超过 5%。
|
||||
- [ ] `git diff --check` 和受影响 crate 的离线定向检查通过;不运行 workspace 全量测试、真实 PostgreSQL、前端构建或性能压测。
|
||||
|
||||
## Out Of Scope
|
||||
|
||||
- 实现或绕过尚未完成的认证 `deverd` IPC 和跨用户共享缓存清理。
|
||||
- 删除用户业务数据、显式构建输出、第三方包缓存或正在使用的缓存。
|
||||
- 改变 release 优化、最终程序语义、Dever 语言语法或应用配置格式。
|
||||
- 本阶段合并 67 个测试目标;只有 profile 与 runtime 去重后仍不能达到磁盘预算时再单独评估。
|
||||
- 把 Cargo 开发目标暴露成 Dever 应用运行时配置。
|
||||
|
||||
## Key Decisions
|
||||
|
||||
- 根因是完整 debuginfo、增量对象、独立测试链接和 profile target 重复,不是源码本身或最终 Dever 二进制达到 16 GiB。
|
||||
- 保留小而可定向的测试目标比合并成少量巨大 runner 更有维护价值;先使用低磁盘 Cargo profile 解决体积。
|
||||
- 本地 `clean` 和机器级 `cache clean` 是不同安全边界,不能为了“一个命令”让普通项目进程直接写共享缓存。
|
||||
@@ -0,0 +1,14 @@
|
||||
# Cache Boundary Evidence
|
||||
|
||||
## Existing Owners
|
||||
|
||||
- `.trellis/spec/backend/toolchain-and-library.md`:正式 `dever` launcher 统一选择版本并分派项目命令;机器共享缓存只能通过认证 `deverd` 服务访问,服务不可用时必须明确失败,不能退回普通用户可写目录。
|
||||
- `.trellis/tasks/09-28-shared-toolchain/prd.md`:`dever cache status/clean` 属于跨项目、跨用户的机器级缓存合同,运行条目使用租约,清理与构建必须互斥。
|
||||
- `crates/dever-cli/src/toolchain/launcher.rs:58`:当前 `cache status/clean` 调用统一返回认证缓存服务尚不可用,未直接构造 `CacheStore`。
|
||||
- `crates/dever-cli/src/toolchain/cache.rs:157`:`CacheStore::clean` 是未来特权服务内部的文件系统引擎,不是项目进程可调用的公开回退路径。
|
||||
|
||||
## Task Boundary
|
||||
|
||||
- 新的 `clean <project-root>` 只能清理当前用户、当前 Dever 版本严格识别的过期临时构建目录和旧项目 staging 文件。
|
||||
- `clean` 不读取、修改或删除机器共享缓存条目,不改变 `dever cache clean` 的命令和失败合同。
|
||||
- 编译器仓库的 `target/debug` 继续由 Cargo 管理;普通 Dever 项目不会通过应用配置控制 Cargo 开发缓存。
|
||||
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"id": "build-cache-storage",
|
||||
"name": "build-cache-storage",
|
||||
"title": "Dever 构建缓存与磁盘占用治理",
|
||||
"description": "降低 Rust 测试和原生运行时构建占用,可靠清理临时产物并提供统一清理命令",
|
||||
"status": "in_progress",
|
||||
"dev_type": null,
|
||||
"scope": null,
|
||||
"package": null,
|
||||
"priority": "P2",
|
||||
"creator": "Antigravity",
|
||||
"assignee": "Antigravity",
|
||||
"createdAt": "2026-09-29",
|
||||
"completedAt": null,
|
||||
"branch": "main",
|
||||
"base_branch": "main",
|
||||
"worktree_path": null,
|
||||
"commit": null,
|
||||
"pr_url": null,
|
||||
"subtasks": [],
|
||||
"children": [],
|
||||
"parent": null,
|
||||
"relatedFiles": [],
|
||||
"notes": "",
|
||||
"meta": {}
|
||||
}
|
||||
Reference in new issue
Block a user