Skip to content

fix(cron): tole cron run and tick apply the owner's user config (#863) - #868

Merged
ajianaz merged 2 commits into
developfrom
fix/863-cron-user-config
Nov 16, 2026
Merged

ajianaz merged 2 commits into
developfrom
fix/863-cron-user-config

Conversation

@ajianaz

@ajianaz ajianaz commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

What

tole cron run and tole cron tick, the two commands that execute cron jobs in the process, now load the USER config (never the project config) and take the normal startup path, so a cron agent run gets the owner's [sandbox], [sandbox.consumers], [secrets] release and [sensitive_files]. A user config that does not parse stops them. Without a terminal on stderr they print nothing about the config on success (an OS cron mails stderr). Every other cron subcommand and the other skip-list commands are unchanged. Closes #863.

Why

cron is on the config skip list, so main.rs loaded no config and applied defaults for everything the user config provides. A cron agent run (cron/agent.rs::run_agent: stdio MCP servers, run_command, job_start) was unsandboxed even when the owner set required, while the same job through tole run or tole serve was sandboxed; the OS-cron path (crontab calling tole cron tick) was affected. Item 5 of the not-fixed list of #858.

Changes

  • main.rs: new runs_cron_jobs(cmd), an exhaustive match over every CronAction variant with no wildcard (a new variant does not compile until it is classified): true for Run and Tick, false for the nine that only edit or read files. The user-config load is skipped for the skip list only when it is false. The project config is still never loaded for cron (gate_policy is untouched). load_user_config(...)? makes a broken file a startup error for these two commands.
  • Quiet on success: load_user_config announces the file with tole: using user config <path> on stderr. An OS cron launches tole cron tick every minute, so under MAILTO that line would be one mail a minute (it did not exist before). For these two commands the line is dropped when stderr is not a terminal (StartupIo::quiet_inform); an owner at a terminal still sees it like in tole run, and every error, including a broken config, stays on stderr. Other commands are unchanged.
  • main_gate_tests.rs: unit test of the classification (every variant listed) and that gate_policy still says Skip for them.
  • tests/cron_user_config_e2e.rs (new, real binary, mock provider, PATH without bwrap).
  • Docs: docs/sandbox-design.md §9.3, threat-model row, CHANGELOG (Fixed, including the stderr behavior). --no-config is unchanged (owner at a terminal; refused under a session, security: --no-config (and CODECORA_HOME) drop the owner's sandbox and approval policy for a child of an agent session #855; the no-terminal case is security: the session marker is an environment variable; a child can clear or forge it #867).

Callers and impact (grep, each checked): gate_policy has one caller (main.rs, startup) and is unchanged; runs_cron_jobs is new and has two uses (the load decision and the quiet decision, both in main.rs); load_user_config still has one production caller (main.rs); StartupIo::new callers keep quiet_inform = false (the new builder method is only called for cron); cron/setup.rs::user_config() (profiles, [cron] caps) is untouched and still reads the file itself; tole serve (which also ticks cron, serve_ticker) is NoPrompt and already loaded the config. Command::Hook runs no agent and stays on the skip path. Tests to rerun: cron_* (cron_agent, cron_cli, cron_control, cron_delivery, cron_profile_e2e, cron_trust, cron_timezones, cron_tz_default), main_gate_tests, config_check, config_apply, sandbox_cli, layering.

Testing

  • Fail without the fix (written first, run on the unchanged main.rs): cron_run_applies_the_owner_sandbox_consumers FAILED (the model's run_command ran: tool result status 0, ran-marker created) and a_broken_user_config_fails_cron_run_closed_but_not_cron_list FAILED (cron run exited 0 with the job in error); after the fix both pass. The broken-config test also asserts the error is on stderr, covers cron tick (fails closed, says why) and cron list (still works with a broken file).
  • Quiet on success: a_successful_tick_or_run_with_a_valid_user_config_is_silent_on_stderr (no terminal): cron tick with a valid user config writes exactly nothing to stderr, cron run writes no config line. Fails without the quiet change (verified by hand: stderr was tole: using user config <path>). The terminal side has no pty in the harness; it is the unchanged line in config::apply.
  • Controls: cron_run_without_a_sandbox_config_runs_the_command (with no sandbox config the command runs) and regression_guard_a_project_config_is_never_read_for_cron (an unparsable project config in the workdir does not stop a run; it passes with and without the fix, on purpose, and is named as such).
  • A cron tick e2e that waits for a job to become due was not added (it needs a minute boundary); tick is covered by the classification unit test, the fail-closed check and the silent-stderr test, and shares the startup path with run.
  • 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: green. 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: the skip-list exception is a whitelist of two actions; the project layer cannot enter (project_config is computed from policy == Skip alone, untouched); --no-config still yields None first; a missing user file is still "no config" (the silent case is security: a missing or unreadable user config is silent (CODECORA_HOME, unset HOME, unreadable path) #864); a broken file fails the two job-running commands before any job or provider call; the quiet flag only drops inform (warnings and errors are untouched) and only for these two commands without a terminal. An independent reviewer found no blocker on the first head; this body covers the follow-up commit (quiet stderr, exhaustive classification, regression-guard name).

The commands that execute cron jobs now load the user layer (never the
project config) although cron is on the config skip list, so a cron agent run
gets the owner's sandbox, consumers, secret release and sensitive files. A
user config that does not parse stops them. The other cron subcommands keep
skipping it.
@github-actions

Copy link
Copy Markdown

🔍 Cora AI Code Review

✅ No issues found. Code looks good!


Review powered by cora-code · BYOK · MIT

…sify every cron action (#863)

An OS cron runs tole cron tick every minute and mails stderr: the using user
config line is dropped when stderr is not a terminal for the two job-running
commands, errors stay loud. runs_cron_jobs matches every CronAction variant
without a wildcard, and the project-config test is named as the regression
guard it is.
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: tole cron run and tole cron tick run agents and scripts without the owner's user config applied

2 participants