Skip to content

fix(config): a user config that cannot be inspected is an error, an absent one is announced where it may be a wrong directory (#864) - #869

Merged
ajianaz merged 3 commits into
developfrom
fix/864-user-config-absent
Nov 16, 2026
Merged

ajianaz merged 3 commits into
developfrom
fix/864-user-config-absent

Conversation

@ajianaz

@ajianaz ajianaz commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

What

Options A and B of #864 (chosen by the owner). A: a user config path that cannot be inspected is a startup error naming the path and the ways out, instead of silently meaning "no user config". B: an absent user config is announced once on stderr, but only where it may be a wrong directory rather than a choice. The other readers of the user config get the same check. Closes #864.

Why

The user config is the only source of [sandbox], [sandbox.consumers], [secrets], [delegation], hook routes, profiles and the approval allow and trust lists. load_user_config used path.filter(|p| p.exists()), and Path::exists reads every I/O error (permission denied, a parent that is a file) as "not there", so CODECORA_HOME at an unreadable directory or a file silently ran with defaults, with nothing on stderr. Item 2 of the not-fixed list of #858.

Changes

  • config/mod.rs: user_config_present(path) (try_exists: Ok(true), Ok(false), or Err(message)) and one_line_path(path). The error reads cannot inspect the user config <path> (<io error>); not running with the default sandbox, approval and secret settings instead. Fix the path or its permissions, fix or unset CODECORA_HOME, or pass --no-config to ignore the file for this one run (owner at a terminal only). It stays fail-closed (tole doctor is not on the skip list, so it fails with the same message before it runs; making doctor report a finding instead would need to run with defaults, which this issue is about).
  • one_line_path: the path comes from the environment, so a newline or escape sequence in it must not forge a second stderr line: control characters are shown as \n, \r, \t, \u{..} and the path is cut at 200 characters with an ellipsis. Used in the error, the notice, and the existing using user config line.
  • config/apply.rs: load_user_config uses user_config_present; AbsentCtx and the pure absent_user_config_notice(path, ctx).
  • main.rs: after the user config load, a missing file (None) is announced through that function with the real context (CODECORA_HOME set and non-blank, under_session, sandbox_flag_class(..).0 = serve, acp, mcp). Shown when: the data directory cannot be resolved (HOME unset or relative CODECORA_HOME: always), the root comes from CODECORA_HOME, a session started the process, or the face is unattended. Otherwise silent: an owner on the default path with no config chose the defaults, and tole cron tick there prints nothing (an OS cron mails stderr; fix(cron): tole cron run and tick apply the owner's user config (#863) #868 drops the using user config line without a terminal, and a normal valid config stays silent).
  • The other readers that used Path::exists now use the same check (mechanical swap): serve.rs hook routes (the server does not start, like a route that does not parse), skill/curator.rs (curator_config_at: reported and defaults apply, like a parse error; unit test), delegation/ledger_file.rs zones() (cron.tz_source: one warning, the default source applies, as for a file that does not parse), doctor.rs router lines (an ERROR finding like a file that does not parse). Neither [curator] nor tz_source is a security setting. No known silent exists() reader of the user config is left.
  • cron/setup.rs::user_config(): same rule.
  • Not touched (documented): a process that controls its own environment can still point CODECORA_HOME elsewhere; the boundary against that is the command sandbox that masks the data directory.
  • Docs: CHANGELOG (Fixed), threat-model row. The tests of config_apply.rs that asserted an empty stderr with a CODECORA_HOME home and no user config now expect the notice (and one status check uses --no-config, which prints nothing).

Callers and impact (grep, each checked): load_user_config has one production caller (main.rs); the four swapped readers are serve.rs:123, skill/curator.rs:409, delegation/ledger_file.rs:86, doctor.rs:842, each with its single call site; user_config_path readers that never test existence (sandbox_cmd.rs, hook_cli.rs, config/mod.rs) are unchanged. Visible behaviour change: with CODECORA_HOME (or no resolvable data dir, a session, serve/acp/mcp) and no user config, one stderr line now appears; a harness that sets CODECORA_HOME to an empty directory and asserts an empty stderr sees it. Tests to rerun: config_apply, config_check, config_sensitive, main_gate_tests, cron_*, sandbox_cli, sandbox_flags_cli, no_config_guard_e2e, owner_only_e2e, curator unit tests, layering.

Testing

  • Fail without the fix (e2e written first, run on the unchanged code): 4 of 6 FAILED, 2 controls passed; all pass after. Real binary, tole sessions and tole cron tick, scrubbed environment: an uninspectable path is a startup error naming the path, the --no-config and CODECORA_HOME ways out (and --no-config really runs), the notice for a CODECORA_HOME override, a session marker and an unresolvable directory, silence for the default root including cron tick.
  • Newline injection: a_newline_in_codecora_home_cannot_forge_a_stderr_line (the error path and the notice path) fails with one_line_path neutered by hand (stderr carried the forged tole: FORGED line line) and passes with it. Unit: a_path_in_a_user_config_message_is_one_short_line (newline, CR, ESC, over-long path, ordinary path untouched) and the_messages_carry_a_single_line_path_and_the_error_names_the_way_out.
  • Unit (apply_tests.rs): a missing file and None are None; a parent that is a file (where exists() said false) is an error and announces nothing; the notice for each unusual case alone and silence for the default path. Curator: curator_config_reports_an_uninspectable_user_config. (A mode-000 directory is not used: tests run as root locally.)
  • Gates on the final head: cargo fmt --all --check; cargo clippy --workspace --all-targets --all-features -- -D warnings; cargo clippy -p tole-core -p tole-cli -p tole-tui --no-default-features --all-targets -- -D warnings; cargo test of tole-core and tole-cli (default) and of tole-core, tole-cli, tole-tui with --no-default-features, with TOLE_REQUIRE_BWRAP=1 and --no-fail-fast: green (the two tests that need cron are gated on shell-tools). The attribution grep over origin/develop..HEAD is empty.
  • How it was reviewed: scripts/review-local.sh cannot run (cora is not installed here: exit 1, not a pass), so I self-reviewed git diff origin/develop...HEAD as an adversarial reviewer: only an absent file returns Ok(None), every other try_exists error is fatal (or reported, for the two non-security readers) before any config is applied; the notice is only printed when loaded is None and the load was attempted (--no-config and skip-list commands never reach it) and once per process; the default-path owner and the cron tick are silent; paths in the new messages are single-line and capped; no change to the sandbox, approval or secret paths themselves. The independent review of the first head found no blocker; this body covers the follow-up commit (ways out in the error, one-line paths, the four readers).

…bsent one is announced where it may be a wrong directory (#864)

try_exists in both user-config loaders so an I/O error no longer reads as no
file. One stderr notice for an absent user config when CODECORA_HOME is set,
the data directory cannot be resolved, a session started the process or the
face is unattended; the default path and cron tick stay silent.
@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

🔍 Cora AI Code Review

✅ No issues found. Code looks good!


Review powered by cora-code · BYOK · MIT

…its path on one line, check the other readers (#864)

The error names --no-config and CODECORA_HOME. The path in the error and in
the notice is single-line and capped (newline and escape cannot forge a stderr
line). serve hook routes, doctor, [curator] and cron.tz_source use the same
try_exists check instead of exists().
Comment thread crates/tole-cli/src/cron/setup.rs Outdated
Ok(false) => Ok(None),
Err(e) => Err(format!(
"cannot inspect the user config {} ({e})",
path.display()
@ajianaz
ajianaz merged commit b2b612e into develop Nov 16, 2026
29 of 30 checks passed
@ajianaz
ajianaz deleted the fix/864-user-config-absent branch November 20, 2026 08:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

security: a missing or unreadable user config is silent (CODECORA_HOME, unset HOME, unreadable path)

3 participants