{"record":{"id":"043a3a15f860d70a","repo":"Hmbown/CodeWhale","slug":"shell-commands-are-restricted-by","errorCode":null,"errorMessage":"shell commands are restricted by {}","messagePattern":"shell commands are restricted by (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"crates/tui/src/runtime_threads.rs","lineNumber":11216,"sourceCode":"        #[cfg(test)]\n        let env_ticket = crate::test_support::env_scope_ticket();\n        tokio::task::spawn_blocking(move || {\n            #[cfg(test)]\n            let _membership = crate::test_support::join_env_scope(env_ticket);\n            let control = config.allow_shell_control(\n                config_path.as_deref(),\n                config_profile.as_deref(),\n                &workspace,\n            );\n            let denied = match control {\n                ShellAccessControl::Unset | ShellAccessControl::RootConfig => false,\n                ShellAccessControl::ProjectConfig | ShellAccessControl::Ambiguous => true,\n                ShellAccessControl::Profile\n                | ShellAccessControl::Environment\n                | ShellAccessControl::ManagedConfig => !config.allow_shell(),\n            };\n            if denied {\n                bail!(\"shell commands are restricted by {}\", control.label());\n            }\n            Ok(())\n        })\n        .await\n        .context(\"shell policy inspection worker failed\")?\n    }\n\n    /// The sandbox policy an API-created job inherits — the same posture\n    /// projection a turn applies to its shell calls, so a client terminal\n    /// cannot run looser than the thread's own tools would.\n    pub(crate) async fn thread_job_sandbox_policy(\n        &self,\n        thread: &ThreadRecord,\n    ) -> crate::sandbox::SandboxPolicy {\n        let policy = RuntimePolicyProjection::from_persisted(\n            &thread.mode,\n            thread.permission_posture.as_deref(),\n            thread.auto_approve,","sourceCodeStart":11198,"sourceCodeEnd":11234,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/runtime_threads.rs#L11198-L11234","documentation":"Shell command execution is gated by a ShellAccessControl policy (ProjectConfig, Profile, Environment, ManagedConfig, Ambiguous). When the resolved policy denies shell access, the worker bails with the policy label so the user knows which control blocked the command. This is deliberate permission enforcement, not a bug.","triggerScenarios":"Invoking a shell tool on a thread whose effective shell policy resolves to Profile, Environment, or ManagedConfig while config.allow_shell() is false (or policy is Ambiguous with default-deny).","commonSituations":"Fresh checkout where the project config has shell disabled; enterprise-managed config restricting shell; profile selected without shell permission; ambiguous settings after config migration.","solutions":["Enable shell in the owning configuration (project config, profile, or environment) that the label names","Check config.allow_shell() and the ShellAccessControl resolution for the thread before invoking shell tools","If ManagedConfig blocks it, contact the administrator managing that config"],"exampleFix":"// before (fails under Profile policy with allow_shell=false)\nruntime.run_shell(thread_id, \"cargo test\").await?;\n// after\nif runtime.shell_policy_allows(thread_id).await {\n    runtime.run_shell(thread_id, \"cargo test\").await?;\n}","handlingStrategy":"try-catch","validationCode":"if !config.allow_shell() { return Err(anyhow!(\"shell disabled by policy\")); }","typeGuard":null,"tryCatchPattern":"match runtime.run_shell(thread_id, cmd).await {\n    Err(e) if e.to_string().starts_with(\"shell commands are restricted by\") => {\n        eprintln!(\"Enable shell in {}: {}\", e, hint);\n    }\n    other => other?,\n}","preventionTips":["Check config.allow_shell() before issuing shell commands","Surface the policy label in UI before running shell tools","Document which config source (profile/env/managed) controls shell"],"tags":["security","permission","shell","policy"],"backgroundTag":"permission-denied","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}