Skip to content

[CTX-0298] fix(config): honor terminal.shell at startup spawn (Closes #495) - #497

Merged
Xuepoo merged 1 commit into
mainfrom
ctx-0298/fix-shell-knob
Sep 10, 2026
Merged

Xuepoo merged 1 commit into
mainfrom
ctx-0298/fix-shell-knob

Conversation

@Xuepoo

@Xuepoo Xuepoo commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Priority: P1 | Area: config | Labels: fix,area:config,P1 | Milestone: v0.1.0 | Task: CTX-0298

Closes #495

Summary

terminal.shell was parse/validate/merge/attribution/reload/trust-complete but dead: the startup spawn path resolved only the CLI program or $SHELL, so the accepted config value had no effect (CTX-0295 verification matrix, row 9).

Root cause: crates/bitty-app/src/main.rs resolve_spawn_program / resolve_default_shell / SpawnSpec::resolve never consulted app_config.effective.terminal.shell; only bitty config check read it for display.

Fix

  • Precedence at spawn: explicit CLI program > configured terminal.shell > $SHELL > /bin/sh.
  • The frozen SpawnSpec (split panes, headless fallback) carries and replays the configured shell, so every leaf gets the same resolution.
  • Direct argv[0] throughout: no shell interpolation, no word splitting.
  • Fail-closed: terminal.shell validation rejects control characters; the spawn-time resolver defensively trims and skips blank/oversized/control-laden values, falling through to the next layer. A configured shell that fails to spawn retries /bin/sh, exactly like the existing $SHELL failure path.
  • The project-layer trust gate (trust::validate_project_plan rejects terminal.shell in project config) is unchanged.

Security (process authority)

  • No new authority: the value can only come from trusted user/profile layers; project layers remain denied by the trust gate.
  • No sh -c, no argument construction, no interpolation; the bitty-pty builder execs the direct argv[0].
  • Unusable configured values are ignored fail-closed; /bin/sh remains the terminal fallback.
  • Focused security review requested on this diff.

Tests

  • Pure unit coverage (crates/bitty-app/src/main.rs): precedence, trimming, fail-closed blank/oversized/control values, explicit-program precedence, SpawnSpec replay.
  • Config validation: control chars and overlong terminal.shell fail closed (crates/bitty-config/src/types.rs).
  • Live-spawn effect tests (#[cfg(unix)], real PTY): configured fake shell writes a marker; blank config falls to $SHELL; missing configured shell falls back to /bin/sh.
  • New end-to-end binary test crates/bitty-app/tests/shell_knob.rs: isolated XDG_CONFIG_HOME init.lua sets terminal.shell; bitty --headless with a hostile $SHELL must log effective program "<fake>" (explicit=false, configured_shell=true) / spawned default shell "<fake>" and run the configured shell as argv[0]; the unconfigured control case keeps spawning $SHELL.

Documentation

  • bitty-docs has no terminal.shell reference (configuration docs are candidate schema only), so no cross-repository docs update is required.
  • In-repo CHANGELOG.md Unreleased entry added.

Verification

  • just check (fmt-check, clippy, workspace tests, scratch-paths, pty-gate, actionlint, markdownlint)
  • cargo test --workspace --all-targets --locked
  • cargo check --target x86_64-pc-windows-gnu --workspace --all-targets
  • CI (Quality gates / MSRV / Windows / Linux / macOS / Supply chain / CodeQL)

@Xuepoo Xuepoo added this to the v0.1.0 milestone Sep 10, 2026
@Xuepoo Xuepoo added fix Bug fix P1 Priority: high area:config Area: configuration labels Sep 10, 2026
@Xuepoo
Xuepoo force-pushed the ctx-0298/fix-shell-knob branch from cf88855 to 12996dd Compare September 10, 2026 15:04
@Xuepoo
Xuepoo merged commit 70291b4 into main Sep 10, 2026
10 checks passed
@Xuepoo
Xuepoo deleted the ctx-0298/fix-shell-knob branch September 10, 2026 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:config Area: configuration fix Bug fix P1 Priority: high

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(config): honor terminal.shell at startup spawn (CTX-0295 finding)

1 participant