Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .agents/skills/develop-lithe/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ description: 在 Lithe 仓库进行实现、重构、缺陷修复、审查、调
4. **难以理解的配置和功能必须用 ⓘ 解释。**(第五节“用 ⓘ 解释”)
5. **用户可修改的配置不得只显示“自动”**,必须显示为“自动(实际生效值)”。(第五节“显示实际生效值”)
6. **发现无用代码或可重构之处,提交 `refactor` Issue**,不在当前 PR 中顺手处理。(第九节)
7. **警告、错误和被丢弃的失败必须走日志。** 显示给用户的警告和错误、功能降级、回退、自动恢复、重试耗尽和被丢弃的错误,都必须在处理边界记录一条目录事件;只有封闭清单里的例外可以不记录,并且必须写 `// log-exempt: <类别>:<原因>`。日志用法门禁没有存量额度,任何违规都直接失败;新增的 `logSink` 参数必须在每个生产构造处传入真实 sink。([日志接入](references/logging.md))
7. **警告、错误和被丢弃的失败必须走日志。** 显示给用户的警告和错误、功能降级、回退、自动恢复、重试耗尽和被丢弃的错误,都必须在处理边界记录一条目录事件;只有封闭清单里的例外可以不记录,并且必须写 `// log-exempt: <类别>:<原因>`。事件只用 Core 目录里声明的,事件 ID、级别和字段键写成常量,由目录测试校验;新增的记录回调必须在每个生产构造处接上真实实现。([日志接入](references/logging.md))
8. **插件的内容只在插件仓库,宿主对具体插件零依赖。** 插件的代码、测试(包括端到端测试)、功能矩阵、界面文案翻译和构建资源说明只在该插件的仓库维护;本仓库和 Core 仓库的代码、测试、CI、功能矩阵和 i18n 词条不得依赖或收录任何具体插件。(第三节“插件归属与宿主零依赖”)

## 二、开始前:按任务读取资料
Expand Down Expand Up @@ -400,7 +400,7 @@ macOS app bundle 和 Windows 安装目录是发行基线。Sparkle 增量更新

### 显式处理失败

- 不得静默吞掉错误。在有足够上下文的层返回、转换或记录错误;丢弃错误的写法(`try?`、只有 `return`/`break`/`continue` 的 `catch`、`.ok();`、`let _ =`)必须记录目录事件,或属于[日志接入](references/logging.md)第二节的例外并写豁免标记。
- 不得静默吞掉错误。在有足够上下文的层返回、转换或记录错误;丢弃错误的写法(Go 的 `_ =`、只有 `return`/`continue`/`break` 的 `if err != nil`;Rust Core 的 `.ok();`、`let _ =`)必须记录目录事件,或属于[日志接入](references/logging.md)第二节的例外并写豁免标记。
- 跨 Rust、Swift、TypeScript、Tauri 或进程边界时,保留稳定的契约错误分类。
- 面向用户的失败信息必须告诉用户可以怎么做,不得泄漏凭据、环境变量内容或不必要的内部细节。
- 注释解释不明显的约束和取舍,不复述代码的执行过程。
Expand Down
297 changes: 149 additions & 148 deletions .agents/skills/develop-lithe/references/logging.md

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions desktop/cmd/lithe/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ func main() {
if err != nil {
fmt.Fprintln(os.Stderr, "lithe: log:", err)
} else {
// Core holds one waker for the process; this client's log is the one that drains it.
logs.ObserveCoreFacts()
options.Logs = logs
}
err = workbench.New(options).Run()
Expand Down
13 changes: 11 additions & 2 deletions desktop/internal/contractfixture/contractfixture.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Package contractfixture locates the contract files that tests read. The plugin contract
// (shared/plugins/contract/v1/) and the application fixtures (rust/fixtures/) each have a single
// source in the Lithe-core-rust checkout this client links, and this repository keeps no copy.
// (shared/plugins/contract/v1/), the application fixtures (rust/fixtures/) and the log event
// catalog (rust/logging/events/) each have a single source in the Lithe-core-rust checkout this
// client links, and this repository keeps no copy.
// scripts/desktop/desktop-go.sh exports LITHE_PLUGIN_CONTRACT_DIR and LITHE_CORE_FIXTURE_DIR for
// the same checkout it builds: the pinned clone, or LITHE_CORE_RUST_DIR when that is set.
package contractfixture
Expand Down Expand Up @@ -32,6 +33,14 @@ func CoreFixture(rel string) string {
return join(CoreFixtureEnvironmentVariable, rel)
}

// CoreEventCatalog returns the directory of the kernel's log event catalog, rust/logging/events,
// which sits beside rust/fixtures in the same checkout. Tests read the declared field types from
// it; whether an event is accepted is still the kernel's answer, not the test's. It panics when
// the variable is unset, for the same reason as Path.
func CoreEventCatalog() string {
return join(CoreFixtureEnvironmentVariable, "../logging/events")
}

func join(variable, rel string) string {
dir := os.Getenv(variable)
if dir == "" {
Expand Down
3 changes: 3 additions & 0 deletions desktop/internal/core/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ type requestEnvelope struct {
Payload any `json:"payload"`
// GitExecution is the request's Git policy, nil for Core's defaults.
GitExecution *gitExecution `json:"gitExecution,omitempty"`
// Origin is the user action the request belongs to, nil for none (see Origin).
Origin *requestOrigin `json:"origin,omitempty"`
}

// gitExecution is the part of a request's Git policy the client sets (GitExecutionOptions in
Expand Down Expand Up @@ -105,6 +107,7 @@ func (c *Client) execute(ctx context.Context, command string, payload, result an
Command: command,
Payload: payload,
GitExecution: gitExecutionOf(ctx, command),
Origin: requestOriginOf(ctx),
})
if err != nil {
return nil, &Error{
Expand Down
Loading
Loading