Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
806e273
fix(userconfig): expand environment placeholders in defaults
karanb192 Nov 16, 2026
5ad1dce
chore: merge main into user-config env expansion
karanb192 Nov 17, 2026
7058ae1
chore: merge upstream main into env expansion fix
karanb192 Nov 17, 2026
4e6b376
fix(userconfig): restrict env expansion to trusted layers
karanb192 Nov 17, 2026
86508de
chore: sync main after Windows environment fix
karanb192 Nov 17, 2026
143360d
test(userconfig): cover CLI trust and document remaining limits
karanb192 Nov 17, 2026
ddd9ecc
test(cli): pin config trust exception for init
karanb192 Nov 17, 2026
d6d332d
chore: merge main after resumed prompt fix
karanb192 Nov 17, 2026
ea4ec35
fix(config): require explicit trust for project defaults
karanb192 Nov 18, 2026
ee2aba4
test(config): separate trust fixtures from assertions
karanb192 Nov 18, 2026
a0272bf
fix(config): explain project trust migration at initialization
karanb192 Nov 18, 2026
31603db
docs(config): clarify project config opt-in lifecycle
karanb192 Nov 18, 2026
614eb56
chore: merge upstream main into config trust
karanb192 Nov 19, 2026
667f444
fix(userconfig): preserve project defaults with safe OTLP expansion
karanb192 Nov 23, 2026
f43e3df
fix(userconfig): satisfy env defaults lint checks
karanb192 Nov 23, 2026
8f60435
fix(userconfig): guard expanded OTLP headers per signal and on TLS roots
karanb192 Nov 25, 2026
e7c4634
Merge remote-tracking branch 'upstream/main' into fix/expand-user-con…
karanb192 Nov 25, 2026
f9c3b98
fix(userconfig): judge signal overrides by their resolved values
karanb192 Nov 25, 2026
6c1672b
test(userconfig): count empty and blank project OTLP options as routing
karanb192 Nov 25, 2026
dc48217
chore: sync with upstream main
karanb192 Nov 27, 2026
2cb6f89
fix(userconfig): withhold expanded headers on exporter fallback
karanb192 Nov 27, 2026
500cc6f
test(userconfig): cover trusted process and config overrides together
karanb192 Nov 27, 2026
9856410
fix(userconfig): narrow endpoint overrides to portable HTTP URLs
karanb192 Nov 27, 2026
397ec5f
fix(userconfig): apply transport defaults before expanded headers
karanb192 Nov 27, 2026
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
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

- Expand environment placeholders only in trusted user or explicit config
defaults. Keep automatic project defaults, but withhold a newly expanded OTLP
header when project defaults can control the route, proxy or TLS roots of a
signal that would carry it. Withhold the header when an exporter can fall
back to a shared project option, including when loading TLS files.
Reject repeated `--config` and ignore relative `XDG_CONFIG_HOME` in
discovery and initialization.
- `skill-up run --dry-run` now prints the planned case executions as cases
times configurations times iterations. A benchmark over four cases with
`--iteration 5` previously reported only `Would run 4 case(s)` for 40
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ embed (empty) < user (~/.config/skill-up/config.yaml) < project ($PWD/.skill-up.
| `project` | `$PWD/.skill-up.yaml` |
| `explicit` | `--config <path>` (must exist) |

Missing files at the `user` and `project` layers are silently skipped; a missing `--config` path is a hard error. A corrupt config at any layer also fails the run.
Missing files at the `user` and `project` layers are silently skipped; a missing `--config` path is a hard error. Specify `--config` at most once. Relative `XDG_CONFIG_HOME` values are ignored for discovery and the default `init` write target.

### Quickstart

Expand Down Expand Up @@ -391,7 +391,7 @@ For `runtime_kwargs`: explicit `--runtime-kwarg` on `run` > `eval.yaml` `environ

### Secrets

Prefer `${ENV_VAR}` references inside the config file rather than baking secret literals. The redaction mechanism (`userconfig.Redact`) masks fields tagged `secret:"true"` when printing; currently no Config field carries the tag, but the mechanism is in place for future fields.
Use `${ENV_VAR}` in `env` values from user-level or explicitly selected config files instead of storing secret literals. Automatically discovered project defaults still apply, but their values remain literal. Newly expanded OTLP headers are withheld when project defaults control telemetry routing. See [User Configuration](docs/guide/user-config.md#credential-boundary) for the scope of this protection.

## Importing `evals.json`

Expand Down
2 changes: 1 addition & 1 deletion docs/guide/cli-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ skill-up init [flags]
| `--print` | `false` | Print to stdout instead of writing to disk |
| `--force` | `false` | Overwrite an existing target |

> Note: for `init`, `--config` names the *source* to read. For every other subcommand (`run`, `validate`, …) it is the *load-path override* sitting at the top of the discovery chain.
> Specify `--config` at most once. For `init`, it names the copy source only. For other subcommands it selects an explicit layer trusted for variable expansion. See the [credential boundary](./user-config#credential-boundary). A relative `XDG_CONFIG_HOME` does not change the default write target.

### Examples

Expand Down
13 changes: 8 additions & 5 deletions docs/guide/user-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ embed (empty)
| `project` | `$PWD/.skill-up.yaml` | skipped |
| `explicit` | `--config <path>` passed to any command | error |

A missing or corrupt `user`/`project` file is downgraded to a `warning:` on
stderr — the command keeps running with whatever layers loaded. A missing or
invalid `--config` path is a hard error.
Missing `user` and `project` files are skipped. Optional files that cannot be read or parsed produce a warning. A missing or invalid `--config` path is a hard error. Specify `--config` at most once. The XDG path is used only when `XDG_CONFIG_HOME` is absolute; otherwise discovery and the default `init` write target fall back to the home directory.

Higher-precedence layers overlay non-zero fields onto lower layers; map fields
(`telemetry.resource_attributes`, `env`, `runtime_kwargs`) are merged key-wise
Expand Down Expand Up @@ -68,12 +66,17 @@ Semantics:
environment variable. Values are only applied **if the corresponding env var
is not already set**, so a value on the command line or in your shell
always wins.
- **`${VAR}` placeholders** in `env` values are expanded from the process
environment at load time, so secrets stay out of the file.
- **`${VAR}` placeholders** expand only in `env` values supplied by the user or explicit layer, in one pass against the process environment before any defaults are applied. Unset references remain literal, and automatically discovered project values are never expanded.
- **`runtime_kwargs`** — defaults for `run` keyed by `environment.type` (e.g.
`opensandbox`). `eval.yaml` values take precedence; missing keys fall back
here. Keys mirror the environment provider's kwargs schema.

### Credential boundary

Automatically discovered project files still supply defaults. A newly expanded OTLP header is withheld when project defaults can control where the exporter that carries it sends data, or which peer that exporter accepts. The check is per signal: `OTEL_EXPORTER_OTLP_TRACES_HEADERS` follows the traces route, meaning the traces endpoint, protocol and TLS options, then the shared `OTEL_EXPORTER_OTLP_*` options that no trusted traces setting overrides. A project that only sets a metrics endpoint therefore does not withhold it. The shared `OTEL_EXPORTER_OTLP_HEADERS` can reach every signal, so any project route setting withholds it. Project proxy settings and TLS root settings (`SSL_CERT_FILE`, `SSL_CERT_DIR`) count for every signal. This protection applies only to headers produced by expansion; it does not change the treatment of literal headers, headers already in the process environment, or evaluation execution. Review any config before selecting it with `--config`, which trusts the file for expansion. For `init`, `--config` is only a copy source and is not used to supply defaults.

A trusted per-signal HTTP(S) endpoint must parse as an absolute URL with a host before it can override a project-supplied shared endpoint for this check. A signal-specific certificate or key path cannot establish that a shared project TLS setting has been displaced. Exporters read those files at initialization, possibly in a child process, and can fall back to the shared setting if loading fails. In that combination the expanded header is withheld. These rules apply equally to trusted config and process environment overrides.

---

## Bootstrapping with `skill-up init`
Expand Down
2 changes: 1 addition & 1 deletion docs/zh/guide/cli-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ skill-up init [flags]
| `--print` | `false` | 输出到 stdout,而不是写盘 |
| `--force` | `false` | 覆盖已存在的目标文件 |

> 注意:对 `init` 子命令,`--config` 是**读取源**;对其他子命令(`run`、`validate` …),`--config` 是加载链最顶层的覆盖路径。
> `--config` 只能指定一次。对 `init`,它仅指定拷贝来源;对其他子命令,它选择可信任变量展开的显式配置层。见[凭据信任边界](./user-config.md#凭据信任边界)。相对路径的 `XDG_CONFIG_HOME` 不影响默认写入位置。

### 示例

Expand Down
23 changes: 20 additions & 3 deletions docs/zh/guide/user-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ embed (空)
| `project` | `$PWD/.skill-up.yaml` | 跳过 |
| `explicit` | 任意子命令的 `--config <path>` | 报错 |

`user` / `project` 层文件不存在或解析失败会降级为 stderr 上的 `warning:`,命令
继续执行。`--config` 显式路径如果缺失或不合法则直接报错。
`user` / `project` 层文件不存在时会跳过;无法读取或解析时会输出警告。
`--config` 显式路径如果缺失或不合法则直接报错,且只能指定一次。只有绝对路径的
`XDG_CONFIG_HOME` 才会生效;否则配置发现和 `init` 的默认写入位置都回退到用户主目录。

高优先级层只**覆盖非零字段**;map 类字段(`telemetry.resource_attributes`、
`env`、`runtime_kwargs`)按 key 逐项合并,而不是整体替换。
Expand Down Expand Up @@ -62,11 +63,27 @@ runtime_kwargs: # 按 environment.type 提

- **`telemetry` 与 `env`**:每个 key 对应一个 `OTEL_*` 或自定义环境变量,**仅在
对应环境变量未被设置时才会注入**——命令行或 shell 中已有的值优先。
- **`env` 中的 `${VAR}`** 在加载时从当前进程环境展开,密钥不会被写进文件本身。
- **`env` 中的 `${VAR}`** 只在值来自用户层或显式配置层时展开。在应用任何默认值前,
使用进程环境展开一次。未设置的引用保留原样;自动发现的项目配置值不展开。
- **`runtime_kwargs`**:`run` 命令按 `environment.type`(如 `opensandbox`)查找
默认值。`eval.yaml` 中显式给的值优先;未提供的字段在这里兜底。Key 的形态与
对应 environment provider 的 kwargs 一致。

### 凭据信任边界

自动发现的项目配置仍然提供默认值。如果项目默认值可以控制某个导出器的发送目标或
它所信任的对端,由该导出器携带的、通过变量展开生成的 OTLP 请求头不会被应用。检查按
信号进行:`OTEL_EXPORTER_OTLP_TRACES_HEADERS` 只取决于 traces 的生效路由,即 traces
自身的端点、协议和 TLS 选项,以及未被可信的 traces 设置覆盖的通用
`OTEL_EXPORTER_OTLP_*` 选项,因此只设置 metrics 端点的项目不会影响它。通用的
`OTEL_EXPORTER_OTLP_HEADERS` 可能被每个信号使用,只要项目提供了任一路由设置就不会被
应用。项目提供的代理设置和 TLS 根证书设置(`SSL_CERT_FILE`、`SSL_CERT_DIR`)对所有
信号生效。这仅约束新展开的请求头,不改变字面量
请求头、进程环境中已有的请求头或评测执行的处理方式。通过 `--config` 选择文件会
信任其变量展开,请先审阅文件。对于 `init`,`--config` 仅指定拷贝来源,不提供默认值。

要在此检查中覆盖项目提供的通用端点,可信的信号级 HTTP(S) 端点必须能解析为包含主机名的绝对 URL。信号级证书或密钥路径不能证明项目提供的通用 TLS 设置已被覆盖。导出器会在初始化时读取文件,有时会在子进程中读取。如果加载失败,导出器可能会回退到通用设置,因此这种组合不会应用展开后的请求头。可信配置和进程环境变量遵循相同的规则。

---

## 用 `skill-up init` 初始化
Expand Down
71 changes: 71 additions & 0 deletions internal/cli/configflag_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package cli

import (
"os"
"path/filepath"
"strings"
"testing"
)

func TestResolveConfigFlag(t *testing.T) {
for _, tc := range []struct {
name string
args []string
want string
}{
{name: "absent", args: []string{"run", "eval.yaml"}},
{name: "space before command", args: []string{"--config", "trusted.yaml", "run", "eval.yaml"}, want: "trusted.yaml"},
{name: "equals after command", args: []string{"run", "eval.yaml", "--config=trusted.yaml"}, want: "trusted.yaml"},
{name: "literal after separator", args: []string{"run", "--", "--config=literal.yaml"}},
{name: "second literal after separator", args: []string{"run", "--config=trusted.yaml", "--", "--config=literal.yaml"}, want: "trusted.yaml"},
{name: "another flag consumes lookalike", args: []string{"run", "--api-key", "--config=literal.yaml", "--config", "trusted.yaml"}, want: "trusted.yaml"},
{name: "delimiter consumed by a flag", args: []string{"run", "--api-key", "--", "--config=trusted.yaml"}, want: "trusted.yaml"},
{name: "short option and normalizer", args: []string{"run", "-vv", "--rk", "name=value", "--config=trusted.yaml"}, want: "trusted.yaml"},
{name: "source named init", args: []string{"--config", "init", "run"}, want: "init"},
{name: "completion flags are invocation data", args: []string{"__complete", "run", "--config=proposed.yaml", ""}},
{name: "init copy source before command", args: []string{"--config", "source.yaml", "init", "--print"}},
{name: "init copy source after command", args: []string{"init", "--config=source.yaml", "--print"}},
} {
t.Run(tc.name, func(t *testing.T) {
got, err := resolveConfigFlag(tc.args)
if err != nil || got != tc.want {
t.Fatalf("resolveConfigFlag(%q) = %q, %v; want %q", tc.args, got, err, tc.want)
}
})
}
}

func TestResolveConfigFlagRejectsRepeated(t *testing.T) {
for _, args := range [][]string{
{"run", "--config=one.yaml", "--config", "two.yaml"},
{"--config", "one.yaml", "run", "--config=two.yaml"},
{"--config=", "run", "--config=two.yaml"},
{"init", "--print", "--config=one.yaml", "--config=two.yaml"},
} {
got, err := resolveConfigFlag(args)
if err == nil || !strings.Contains(err.Error(), "--config may only be specified once") || got != "" {
t.Errorf("resolveConfigFlag(%q) = %q, %v; want duplicate error", args, got, err)
}
}
}

func TestExecuteArgsRejectsRepeatedConfigBeforeApplyingDefaults(t *testing.T) {
const marker = "SKILL_UP_TEST_CONFIG_PREFLIGHT"
t.Setenv(marker, "")
if err := os.Unsetenv(marker); err != nil {
t.Fatal(err)
}
t.Chdir(t.TempDir())
user := filepath.Join(t.TempDir(), "config.yaml")
if err := os.WriteFile(user, []byte("env:\n "+marker+": user-default\n"), 0o600); err != nil {
t.Fatal(err)
}
t.Setenv("SKILL_UP_CONFIG", user)
err := ExecuteArgs("test-version", []string{"--config", user, "--config=" + user, "--version"})
if err == nil || !strings.Contains(err.Error(), "--config may only be specified once") {
t.Fatalf("ExecuteArgs = %v, want duplicate error", err)
}
if _, present := os.LookupEnv(marker); present {
t.Fatalf("duplicate flag must be rejected before applying environment defaults")
}
}
37 changes: 20 additions & 17 deletions internal/cli/init.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cli

import (
"errors"
"fmt"
"os"
"path/filepath"
Expand All @@ -25,14 +26,17 @@ reads that file (validating it as a skill-up config) and writes its raw
contents to the target, preserving comments and formatting.

Target selection:
default $XDG_CONFIG_HOME/skill-up/config.yaml (or ~/.config/...)
default absolute $XDG_CONFIG_HOME/skill-up/config.yaml (or ~/.config/...)
--local $PWD/.skill-up.yaml
--print stdout (no file written)`,
--print stdout (no file written)

Project defaults are loaded automatically. To enable environment expansion in
a project file after reviewing it, select it explicitly with --config ./.skill-up.yaml.`,
RunE: runInit,
}

func init() {
initCmd.Flags().Bool("local", false, "Write target is $PWD/.skill-up.yaml instead of the XDG path")
initCmd.Flags().Bool("local", false, "Write $PWD/.skill-up.yaml (loaded automatically as project defaults)")
initCmd.Flags().Bool("print", false, "Print to stdout instead of writing to disk")
initCmd.Flags().Bool("force", false, "Overwrite an existing file")
rootCmd.AddCommand(initCmd)
Expand Down Expand Up @@ -74,6 +78,9 @@ func runInit(cmd *cobra.Command, _ []string) error {
return err
}
_, _ = fmt.Fprintf(cmd.OutOrStdout(), "wrote %s\n", target)
if local {
_, _ = fmt.Fprintln(cmd.OutOrStdout(), "Project defaults load automatically. After reviewing this file, use --config ./.skill-up.yaml to enable env expansion.")
}
return nil
}

Expand All @@ -95,8 +102,7 @@ func resolveInitContent(sourcePath string) (string, error) {
return string(data), nil
}

// resolveProjectConfigTarget returns $PWD/.skill-up.yaml — the per-project
// config layer.
// resolveProjectConfigTarget returns $PWD/.skill-up.yaml.
func resolveProjectConfigTarget() (string, error) {
wd, err := os.Getwd()
if err != nil {
Expand All @@ -105,26 +111,22 @@ func resolveProjectConfigTarget() (string, error) {
return filepath.Join(wd, userconfig.ProjectConfigFile), nil
}

// resolveUserConfigTarget returns the XDG-aware user config path
// ($XDG_CONFIG_HOME/skill-up/config.yaml, falling back to
// ~/.config/skill-up/config.yaml).
// resolveUserConfigTarget uses the same absolute-XDG rule as config discovery.
func resolveUserConfigTarget() (string, error) {
if xdg := os.Getenv("XDG_CONFIG_HOME"); xdg != "" {
return filepath.Join(xdg, userconfig.UserConfigDir, userconfig.UserConfigFile), nil
}
home, err := os.UserHomeDir()
if err != nil {
return "", err
target := userconfig.DefaultConfigPath("", os.Getenv)
if target == "" {
return "", errors.New("cannot determine the default user config path: home directory unavailable")
}
return filepath.Join(home, ".config", userconfig.UserConfigDir, userconfig.UserConfigFile), nil
return target, nil
}

// initTemplateContent is the commented YAML template used by `init` when no
// --config source is given. All optional knobs are commented out so the
// default behavior is a no-op.
const initTemplateContent = `# skill-up user config -- auto-loaded by every command.
# Discovery order (lowest to highest precedence):
# embedded defaults < ~/.config/skill-up/config.yaml < $PWD/.skill-up.yaml < --config
# embedded defaults < user config < .skill-up.yaml < --config
# User config uses SKILL_UP_CONFIG, absolute XDG_CONFIG_HOME, or ~/.config.
# Use ` + "`skill-up init --print`" + ` to regenerate this template.

schema_version: v1alpha1
Expand Down Expand Up @@ -157,7 +159,8 @@ telemetry:
# verbose: false

# Arbitrary additional env vars. Same only-if-unset semantics as telemetry.
# Use ${VAR} placeholders for secrets so they are not baked into the file.
# ${VAR} expands only in user-level or explicitly selected (--config) files.
# Automatically loaded project env values remain literal.
# env:
# OTEL_EXPORTER_OTLP_HEADERS: authorization=${OTLP_TOKEN}

Expand Down
28 changes: 27 additions & 1 deletion internal/cli/init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,15 @@ func TestInit_LocalWritesTemplate(t *testing.T) {
t.Chdir(tmp)

cmd := newInitCmdForTest()
cmd.SetOut(&bytes.Buffer{})
var out bytes.Buffer
cmd.SetOut(&out)
cmd.SetArgs([]string{"--local"})
if err := cmd.Execute(); err != nil {
t.Fatalf("init --local: %v", err)
}
if !strings.Contains(out.String(), "--config ./.skill-up.yaml") {
t.Fatalf("missing local config opt-in hint: %q", out.String())
}
target := filepath.Join(tmp, ".skill-up.yaml")
got, err := os.ReadFile(target)
if err != nil {
Expand Down Expand Up @@ -169,3 +173,25 @@ func TestInit_ConfigSourceInvalid(t *testing.T) {
t.Fatal("expected error for invalid source")
}
}

func TestInit_DefaultTargetIgnoresRelativeXDG(t *testing.T) {
home := t.TempDir()
t.Setenv("HOME", home)
t.Setenv("USERPROFILE", home)
t.Setenv("XDG_CONFIG_HOME", "relative-xdg")
t.Chdir(t.TempDir())

cmd := newInitCmdForTest()
cmd.SetOut(&bytes.Buffer{})
cmd.SetArgs([]string{})
if err := cmd.Execute(); err != nil {
t.Fatalf("init: %v", err)
}
want := filepath.Join(home, ".config", "skill-up", "config.yaml")
if _, err := os.Stat(want); err != nil {
t.Fatalf("init did not write %s: %v", want, err)
}
if _, err := os.Stat("relative-xdg"); !os.IsNotExist(err) {
t.Fatalf("init unexpectedly used relative XDG (stat error: %v)", err)
}
}
Loading
Loading