Repository navigation
Install the recommended plugins by default in mesh-llm setup #3219
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
Open
ethanyzhang
wants to merge
19
commits into
Mesh-LLM:main
Choose a base branch
from
ethanyzhang:claude/plugin-sets-only
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+3,190
−64
Open
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
17f0e69
feat(plugins): install the recommended plugin set by default in setup
ethanyzhang f0d34a7
fix(plugins): list the available sets when an unknown set is requested
ethanyzhang 729ee0b
fix(plugins): report members unavailable on this platform and survive…
ethanyzhang f0d23d0
feat(plugins): offer the recommended set once per machine
ethanyzhang 3719e63
fix(plugins): retry a failed recommended-set member at the next setup
ethanyzhang 7738935
fix(plugins): keep later-added members out of a retried set offer and…
ethanyzhang 5c4b87f
fix(plugins): use a per-process temp file for the offer record and do…
ethanyzhang a95e481
fix(plugins): keep setup's plugin result when the offer record cannot…
ethanyzhang 27b2c25
docs(plugins): keep every install path in the plugin architecture page
ethanyzhang 7da780f
docs(plugins): say the recommended set is offered once per plugin store
ethanyzhang 26cc4c2
fix(plugins): keep concurrent plugin changes and install into the ser…
ethanyzhang 7e47a52
fix(plugins): complete a merged set offer only when its snapshot is o…
ethanyzhang ed1de3b
fix(setup): name the service's plugin store and keep reporters off th…
ethanyzhang 7d1b3d8
fix(setup): refuse mixed quoting in service.env and isolate catalog t…
ethanyzhang d83634c
fix(setup): resolve a relative service plugin store against the servi…
ethanyzhang 6b7eb21
test(setup): use a host-absolute store path in the service.env test
ethanyzhang 9c90148
fix(setup): keep setup's plugin install inside its deadline and offer…
ethanyzhang 0a32c99
feat(setup): keep capsules checkpoints local when a plugin set instal…
ethanyzhang 1373538
docs(plugins): describe capsules v0.1.26's witness default and why se…
ethanyzhang 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,147 @@ | ||
| //! Keeps checkpoint delivery off for a capsules install made through a plugin | ||
| //! set. | ||
| //! | ||
| //! Capsules v0.1.25 and earlier send signed checkpoints to Action State's | ||
| //! hosted witness when the `witness` setting is unset; v0.1.26 and later | ||
| //! default to off. A plugin set installs capsules without the operator | ||
| //! choosing it (`mesh-llm setup` installs the `recommended` set with no | ||
| //! prompt), so a set install writes `witness = "off"` into the plugin's | ||
| //! settings whichever release the catalog pins, and an operator who wants a | ||
| //! witness sets it. Agreed on Mesh-LLM/mesh-llm#3219. | ||
|
|
||
| use std::io::Write; | ||
|
|
||
| use anyhow::{Context, Result}; | ||
| use mesh_llm_config::ConfigStore; | ||
| use toml_edit::{ArrayOfTables, DocumentMut, Item, Table, value}; | ||
|
|
||
| const CAPSULES: &str = "capsules"; | ||
| const WITNESS_SETTING: &str = "witness"; | ||
|
|
||
| /// For each newly installed set member that is capsules, keep its checkpoints | ||
| /// local. Never fails the install: a config that cannot be written is | ||
| /// reported with how to set it by hand. | ||
| pub fn keep_installed_capsules_local(installed: &[String]) { | ||
| if !installed.iter().any(|name| name == CAPSULES) { | ||
| return; | ||
| } | ||
| let mut err = mesh_llm_events::console_err(); | ||
| let outcome = ConfigStore::default_path().and_then(|store| keep_witness_off(&store)); | ||
| let _ = match outcome { | ||
| Ok(true) => writeln!( | ||
| err, | ||
| "Capsules keeps its checkpoints on this node: its witness is set to off. To send them to a witness, set `witness` in the capsules plugin settings (Configuration tab or `[plugin.settings]` in config.toml)." | ||
| ), | ||
| Ok(false) => Ok(()), | ||
| Err(error) => writeln!( | ||
| err, | ||
| "⚠️ Could not set the capsules witness to off ({error:#}). Until `witness = \"off\"` is set under `[plugin.settings]` for `capsules`, a capsules release before v0.1.26 sends signed checkpoints to Action State's hosted witness." | ||
| ), | ||
| }; | ||
| } | ||
|
|
||
| /// Set `[[plugin]] name = "capsules"` `settings.witness = "off"` unless the | ||
| /// operator already set a witness. True when the file changed. | ||
| fn keep_witness_off(store: &ConfigStore) -> Result<bool> { | ||
| let mut changed = false; | ||
| store | ||
| .edit_preserving(|doc| { | ||
| changed = set_witness_off(doc)?; | ||
| Ok(()) | ||
| }) | ||
| .with_context(|| format!("update {}", store.path().display()))?; | ||
| Ok(changed) | ||
| } | ||
|
|
||
| fn set_witness_off(doc: &mut DocumentMut) -> Result<bool> { | ||
| if doc.get("plugin").is_none() { | ||
| doc["plugin"] = Item::ArrayOfTables(ArrayOfTables::new()); | ||
| } | ||
| let plugins = doc["plugin"] | ||
| .as_array_of_tables_mut() | ||
| .context("`plugin` in the config is not a list of [[plugin]] tables")?; | ||
| let index = plugins | ||
| .iter() | ||
| .position(|plugin| plugin.get("name").and_then(Item::as_str) == Some(CAPSULES)); | ||
| let plugin = match index { | ||
| Some(index) => plugins.get_mut(index).context("capsules plugin entry")?, | ||
| None => { | ||
| let mut entry = Table::new(); | ||
| entry["name"] = value(CAPSULES); | ||
| plugins.push(entry); | ||
| let last = plugins.len() - 1; | ||
| plugins.get_mut(last).context("capsules plugin entry")? | ||
| } | ||
| }; | ||
| if plugin.get("settings").is_none() { | ||
| plugin["settings"] = Item::Table(Table::new()); | ||
| } | ||
| let settings = plugin["settings"] | ||
| .as_table_like_mut() | ||
| .context("capsules `settings` in the config is not a table")?; | ||
| if settings.contains_key(WITNESS_SETTING) { | ||
| return Ok(false); | ||
| } | ||
| settings.insert(WITNESS_SETTING, value("off")); | ||
| Ok(true) | ||
| } | ||
|
|
||
| #[cfg(test)] | ||
| mod tests { | ||
| use super::*; | ||
|
|
||
| fn run(initial: Option<&str>) -> (bool, String) { | ||
| let dir = tempfile::tempdir().unwrap(); | ||
| let path = dir.path().join("config.toml"); | ||
| if let Some(initial) = initial { | ||
| std::fs::write(&path, initial).unwrap(); | ||
| } | ||
| let store = ConfigStore::open(&path); | ||
| let changed = keep_witness_off(&store).unwrap(); | ||
| (changed, std::fs::read_to_string(&path).unwrap()) | ||
| } | ||
|
|
||
| #[test] | ||
| fn a_missing_config_gets_a_capsules_entry_with_the_witness_off() { | ||
| let (changed, text) = run(None); | ||
| assert!(changed); | ||
| let config = mesh_llm_config::parse_config_toml(&text).unwrap(); | ||
| assert_eq!(config.plugins.len(), 1); | ||
| assert_eq!(config.plugins[0].name, "capsules"); | ||
| assert_eq!(config.plugins[0].settings["witness"].as_str(), Some("off")); | ||
| } | ||
|
|
||
| #[test] | ||
| fn an_operator_chosen_witness_is_left_alone() { | ||
| let initial = "[[plugin]]\nname = \"capsules\"\n\n[plugin.settings]\nwitness = \"https://witness.example.org\"\n"; | ||
| let (changed, text) = run(Some(initial)); | ||
| assert!(!changed); | ||
| assert_eq!(text, initial); | ||
| } | ||
|
|
||
| #[test] | ||
| fn other_settings_and_comments_survive_and_other_plugins_are_untouched() { | ||
| let initial = "# my node\n[[plugin]]\nname = \"other\"\n\n[[plugin]]\nname = \"capsules\"\nenabled = true\n\n[plugin.settings]\nshare_record_at_completion = \"off\"\n"; | ||
| let (changed, text) = run(Some(initial)); | ||
| assert!(changed); | ||
| assert!(text.starts_with("# my node\n"), "{text}"); | ||
| let config = mesh_llm_config::parse_config_toml(&text).unwrap(); | ||
| assert_eq!(config.plugins.len(), 2); | ||
| let capsules = &config.plugins[1]; | ||
| assert_eq!(capsules.enabled, Some(true)); | ||
| assert_eq!(capsules.settings["witness"].as_str(), Some("off")); | ||
| assert_eq!( | ||
| capsules.settings["share_record_at_completion"].as_str(), | ||
| Some("off") | ||
| ); | ||
| assert!(config.plugins[0].settings.is_empty()); | ||
| } | ||
|
|
||
| #[test] | ||
| fn a_second_run_changes_nothing() { | ||
| let (_, once) = run(None); | ||
| let (changed, twice) = run(Some(&once)); | ||
| assert!(!changed); | ||
| assert_eq!(once, twice); | ||
| } | ||
| } |
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.
[P3]
plugins install --setnow emits--set [REDACTED], but the command-summary grammars don't recognize that option, so the new command loses its operational log summary. Add the redacted option to both the Rust and console grammars and cover it with an acceptance case.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.
(Ethan's agent) Fixed in 4f211c7.
--setis now a redacted option ofplugins installin both the Rust (mesh-llm-events) and console grammars, and it conflicts withreference,--archive,--nameand--version, as the CLI does.--skip-plugin-installhad the same gap in the setup flags and is added in both grammars too. Acceptance cases:plugin_set_install_and_setup_plugin_opt_out_survive_producer_sanitization(producer to sanitizer round trip, plus the conflicting shapes rejected) and the matching console test incommand-summary.test.ts.