Repository navigation
feat(security): let a host turn the prompt screen off explicitly #8533
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 20 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
2645bd7
chore(vendor): bump tiny submodule pins
senamakel bf81805
chore(vendor): bump tinybus, tinychannels and tinycomputer submodules
senamakel aa79dec
chore(vendor): bump tinyconnectors and tinydocs submodules
senamakel ee74a2a
chore(vendor): bump tinyflows submodule
senamakel 9b12b15
test(config): add prompt screen schema tests
senamakel 9a0c2dc
feat(config): add prompt_screen config section
senamakel 61bec33
feat(security): honour prompt_screen mode off in injection detector
senamakel 73ecbce
test(prompt_injection): cover prompt screen enforcement config paths
senamakel b13ab2a
chore(runtime): log prompt screen mode during context boot
senamakel c05d354
feat(embed): add prompt_screen knob to the runtime builder
senamakel a585076
feat(embed): expose prompt screen enforcement in configuration info
senamakel 5bc02bd
chore(vendor): bump tinyhumans-sdk and tinyjuice submodules
senamakel 8108d3b
test(embed): add coverage for prompt screen off behaviour
senamakel 5e0d6a8
test(embed): cover prompt screen enforcement reporting
senamakel 31cff9e
docs(config): document prompt_screen config section
senamakel 7868692
chore(vendor): bump tinymcp and tinymemory submodules
senamakel 0dcfd09
chore(vendor): bump tinysearch, tinysecurity, tinyskills, tinystorage…
senamakel d9cb31e
chore: apply rustfmt formatting to prompt screen code
senamakel 5ca1cff
test(embed): surface the error when an unscreened turn fails
senamakel bca3408
docs(embed): update builder setter line references in api index
senamakel b18b043
test(config): cover prompt screen table parsing and round-trip
senamakel a9d1055
test(embed): reformat unscreened turn assertion
senamakel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| //! Prompt screen configuration: whether untrusted input is checked for prompt | ||
| //! injection by TinySecurity before a turn, a tool result or an inbound | ||
| //! message is processed. | ||
| //! | ||
| //! The screen fails closed. With the default [`PromptScreenMode::Enforce`], | ||
| //! input is held for review whenever TinySecurity cannot give a verdict: the | ||
| //! module is not compiled in (no `security-module` feature), it is not loaded, | ||
| //! it errors, or it times out. A host that screens input somewhere else, or that | ||
| //! ships without the TinySecurity module on purpose, opts out with | ||
| //! [`PromptScreenMode::Off`]; nothing turns the screen off implicitly. | ||
|
|
||
| use schemars::JsonSchema; | ||
| use serde::{Deserialize, Serialize}; | ||
|
|
||
| /// Whether the prompt screen runs. | ||
| /// | ||
| /// Serializes as snake_case (`enforce` / `off`). A config missing the | ||
| /// `[prompt_screen]` block, or its `mode` key, deserializes to | ||
| /// [`PromptScreenMode::Enforce`]. | ||
| #[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Serialize, Deserialize, JsonSchema)] | ||
| #[serde(rename_all = "snake_case")] | ||
| pub enum PromptScreenMode { | ||
| /// Screen every input through TinySecurity, holding it for review when no | ||
| /// verdict can be had. | ||
| #[default] | ||
| Enforce, | ||
| /// Do not screen: every input is allowed without consulting TinySecurity. | ||
| /// For a host that screens input itself or runs without the module. | ||
| Off, | ||
| } | ||
|
|
||
| /// The `[prompt_screen]` config block. | ||
| #[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Serialize, Deserialize, JsonSchema)] | ||
| #[serde(default)] | ||
| pub struct PromptScreenConfig { | ||
| /// Whether the screen runs. Missing key → [`PromptScreenMode::Enforce`]. | ||
| pub mode: PromptScreenMode, | ||
| } | ||
|
|
||
| impl PromptScreenConfig { | ||
| /// The screen turned off: [`PromptScreenMode::Off`]. | ||
| #[must_use] | ||
| pub fn off() -> Self { | ||
| Self { | ||
| mode: PromptScreenMode::Off, | ||
| } | ||
| } | ||
|
|
||
| /// Whether input is screened. False only when the config says | ||
| /// [`PromptScreenMode::Off`]. | ||
| #[must_use] | ||
| pub fn enforces(&self) -> bool { | ||
| self.mode == PromptScreenMode::Enforce | ||
| } | ||
| } | ||
|
|
||
| #[cfg(test)] | ||
| #[path = "prompt_screen_tests.rs"] | ||
| mod tests; |
33 changes: 33 additions & 0 deletions
33
crates/openhuman-core/src/config/schema/prompt_screen_tests.rs
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| use super::*; | ||
|
|
||
| #[test] | ||
| fn a_missing_block_enforces_the_screen() { | ||
| let config: PromptScreenConfig = toml::from_str("").unwrap(); | ||
| assert_eq!(config.mode, PromptScreenMode::Enforce); | ||
| assert!(config.enforces()); | ||
| assert!(PromptScreenConfig::default().enforces()); | ||
| } | ||
|
|
||
| #[test] | ||
| fn mode_serializes_snake_case() { | ||
| assert_eq!( | ||
| serde_json::to_string(&PromptScreenMode::Enforce).unwrap(), | ||
| "\"enforce\"" | ||
| ); | ||
| assert_eq!( | ||
| serde_json::to_string(&PromptScreenMode::Off).unwrap(), | ||
| "\"off\"" | ||
| ); | ||
| } | ||
|
|
||
| #[test] | ||
| fn off_parses_from_toml_and_stops_enforcing() { | ||
| let config: PromptScreenConfig = toml::from_str("mode = \"off\"").unwrap(); | ||
| assert_eq!(config, PromptScreenConfig::off()); | ||
| assert!(!config.enforces()); | ||
| } | ||
|
|
||
| #[test] | ||
| fn an_unknown_mode_is_rejected_rather_than_read_as_off() { | ||
| assert!(toml::from_str::<PromptScreenConfig>("mode = \"disabled\"").is_err()); | ||
| } |
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
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
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
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
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
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
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For a normal
openhuman-core serveruntime (ConfigSource::Discovered), setting[prompt_screen] mode = "off"inconfig.tomldoes not disable the guards that callenforce_prompt_input(). That wrapper reads onlyCoreContext::current_embedder_config(), whilecore/runtime/context_boot.rs:187-198leaves that snapshot absent for discovered-config boots outsideSecretPreflight. Consequently,agent_runs/agent_chat/guards.rs:49passesNonehere and rejects otherwise validinference.agent_chatrequests asscreen.unavailable, even though boot logs that screening is disabled. Resolve the owning dispatch's persisted configuration through the existing config operations, asenforce_prompt_input_in()does, or pass the caller's already-loaded config to these guards.AGENTS.md reference: AGENTS.md:L252-L253
Useful? React with 👍 / 👎.