Repository navigation
fix(cron): tole cron run and tick apply the owner's user config (#863) - #868
Merged
Merged
Conversation
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.
🔍 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
tole cron runandtole 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 othercronsubcommand and the other skip-list commands are unchanged. Closes #863.Why
cronis on the config skip list, somain.rsloaded 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 setrequired, while the same job throughtole runortole servewas sandboxed; the OS-cron path (crontabcallingtole cron tick) was affected. Item 5 of the not-fixed list of #858.Changes
main.rs: newruns_cron_jobs(cmd), an exhaustive match over everyCronActionvariant with no wildcard (a new variant does not compile until it is classified): true forRunandTick, 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_policyis untouched).load_user_config(...)?makes a broken file a startup error for these two commands.load_user_configannounces the file withtole: using user config <path>on stderr. An OS cron launchestole cron tickevery minute, so underMAILTOthat 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 intole 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 thatgate_policystill saysSkipfor them.tests/cron_user_config_e2e.rs(new, real binary, mock provider, PATH withoutbwrap).docs/sandbox-design.md§9.3, threat-model row, CHANGELOG (Fixed, including the stderr behavior).--no-configis 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_policyhas one caller (main.rs, startup) and is unchanged;runs_cron_jobsis new and has two uses (the load decision and the quiet decision, both inmain.rs);load_user_configstill has one production caller (main.rs);StartupIo::newcallers keepquiet_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) isNoPromptand already loaded the config.Command::Hookruns 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
main.rs):cron_run_applies_the_owner_sandbox_consumersFAILED (the model'srun_commandran: tool resultstatus 0,ran-markercreated) anda_broken_user_config_fails_cron_run_closed_but_not_cron_listFAILED (cron runexited 0 with the job in error); after the fix both pass. The broken-config test also asserts the error is on stderr, coverscron tick(fails closed, says why) andcron list(still works with a broken file).a_successful_tick_or_run_with_a_valid_user_config_is_silent_on_stderr(no terminal):cron tickwith a valid user config writes exactly nothing to stderr,cron runwrites no config line. Fails without the quiet change (verified by hand: stderr wastole: using user config <path>). The terminal side has no pty in the harness; it is the unchanged line inconfig::apply.cron_run_without_a_sandbox_config_runs_the_command(with no sandbox config the command runs) andregression_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).cron ticke2e that waits for a job to become due was not added (it needs a minute boundary);tickis covered by the classification unit test, the fail-closed check and the silent-stderr test, and shares the startup path withrun.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 testof tole-core and tole-cli (default) and of tole-core, tole-cli, tole-tui with--no-default-features, withTOLE_REQUIRE_BWRAP=1: green. The attribution grep overorigin/develop..HEADis empty.scripts/review-local.shcannot run (cora is not installed here: exit 1, not a pass), so I self-reviewedgit diff origin/develop...HEADas an adversarial reviewer: the skip-list exception is a whitelist of two actions; the project layer cannot enter (project_configis computed frompolicy == Skipalone, untouched);--no-configstill yieldsNonefirst; 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 dropsinform(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).