Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions rust/contracts/application-boundary.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,20 @@ verification scripts are the executable source of boundary checks.
- Every asynchronous operation exposes `idle`, `loading`, `ready`, and `failed` outcomes.
- Failures contain a stable `code` and user-facing `message`; platform details belong in `details`.

## Source-backed plugin settings

Source-backed plugin settings use `sourceSettings: 0` and the three
`plugins.settings.source*` commands. Plugins supply only allowlisted non-sensitive
fields from their upstream configuration; Core validates and projects the form,
inheritance and confirmed edits. Native adapters capture workspace identity,
reject installation roots and source aliases, verify exact revisions, create
private existing staging files and publish with guarded atomic replacement.
Opening or cancelling a page never writes sources. A failed read-back retains
drafts and cannot announce that settings took effect. Closing or replacing the
workspace or plugin revokes pending publication and cleans staging files.
See [source-editor protocol](../../shared/plugins/contract/v1/README.md#source-backed-settings-editors)
and [the inert fixture](../fixtures/plugins/settings-sources.json).

## Shared built-in translations

[Shared i18n](https://github.com/1lck/Lithe-IDEA/blob/preview/shared/i18n/README.md) owns migrated semantic keys, typed named parameters,
Expand Down
14 changes: 14 additions & 0 deletions rust/contracts/rust-core-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,9 @@ or removing a command fails until the table changes in the same commit.
| `plugins.settings.catalog` | Project enabled plugin settings pages from installed manifests |
| `plugins.settings.navigation` | Project searched settings navigation without platform policy |
| `plugins.settings.delivery` | Route committed preference effects using native ownership facts |
| `plugins.settings.sourceState` | Validate a source-editor function result and project inherited native control inputs |
| `plugins.settings.sourceEdit` | Validate explicit confirmation and derive changed source-bound values without file I/O |
| `plugins.settings.sourceReceipt` | Bind a private staged-file receipt to a confirmed source and exact byte revision |
| `plugins.declarative.settingsState` | Read complete plugin preference documents and packaged translations into Core-normalized rows, sources, and bounded native read plans |
| `plugins.declarative.settingsActionPlan` | Resolve an installed settings action and its native confirmation requirement |
| `plugins.installed.select` | Select numeric installed versions from native facts without reading paths |
Expand Down Expand Up @@ -6495,3 +6498,14 @@ state or diagnostic payload.
executes through the rule dispatcher, the Core JSON envelope and the desktop
bridge. It covers repeats, either history entry point, clearing, visible
arrivals, non-prefix display order, read/unread eviction and invalid inputs.

### Build runtime resolution

`build.invocation` includes declared `runtimeDependencies` before its primary
executable candidates. Each requirement supplies its candidate plans, minimum
version and `pathVariable` (`LITHE_<NORMALIZED_ID>_PATH`). The native adapter
resolves and validates these runtimes first, applies Core-selected environment
and executable exports, then resolves/probes the main build tool in that same
environment. User-configured invocation environment retains its existing
precedence. Host-managed runtime candidates are explicit `runtime` plans; hosts
must not infer executable names from opaque runtime IDs.
3 changes: 3 additions & 0 deletions rust/crates/build/src/invocation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,16 @@ fn runtime(
// definition with the same ID; resolving it checks `minimumVersion`.
let executables = if runtime.names_tool_definition() {
vec![json!({ "kind": "toolchain", "toolchainID": runtime.id, "root": root })]
} else if runtime.is_host_managed() {
vec![json!({"kind":"runtime","runtime":runtime.id})]
} else {
candidates(&runtime.executables, root, platform, manifest, settings)?
};
Ok(json!({
"id": runtime.id,
"displayName": runtime.display_name,
"hostManaged": runtime.is_host_managed(),
"pathVariable":format!("LITHE_{}_PATH",runtime.id.to_ascii_uppercase().replace('-',"_")),
"minimumVersion": runtime.minimum_version,
"executables": executables,
"version": version,
Expand Down
15 changes: 15 additions & 0 deletions rust/crates/core/src/protocol/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,12 @@ pub enum PluginsCommand {
SettingsNavigation,
/// Routes committed preference effects using native ownership facts.
SettingsDelivery,
/// Validates a plugin's native workspace settings projection.
SettingsSourceState,
/// Plans confirmed changes without copying source documents into RPC.
SettingsSourceEdit,
/// Binds a plugin's private staging receipt to its confirmed source.
SettingsSourceReceipt,
/// Resolves an installed settings action and its native confirmation requirement.
DeclarativeSettingsActionPlan,
/// Selects numeric installed versions and reports malformed native facts.
Expand Down Expand Up @@ -1038,6 +1044,15 @@ impl CoreCommand {
Some(Self::Plugins(PluginsCommand::SettingsNavigation))
}
"plugins.settings.delivery" => Some(Self::Plugins(PluginsCommand::SettingsDelivery)),
"plugins.settings.sourceState" => {
Some(Self::Plugins(PluginsCommand::SettingsSourceState))
}
"plugins.settings.sourceEdit" => {
Some(Self::Plugins(PluginsCommand::SettingsSourceEdit))
}
"plugins.settings.sourceReceipt" => {
Some(Self::Plugins(PluginsCommand::SettingsSourceReceipt))
}
"plugins.declarative.settingsState" => {
Some(Self::Plugins(PluginsCommand::DeclarativeSettingsState))
}
Expand Down
15 changes: 15 additions & 0 deletions rust/crates/core/src/runtime/dispatcher/plugins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,21 @@ pub(super) fn dispatch(
PluginsCommand::SettingsCatalog => {
plugin_response(id, payload, lithe_plugin_manifest::settings_catalog_command)
}
PluginsCommand::SettingsSourceState => plugin_response(
id,
payload,
lithe_plugin_model::settings::sources::state_command,
),
PluginsCommand::SettingsSourceEdit => plugin_response(
id,
payload,
lithe_plugin_model::settings::sources::edit_command,
),
PluginsCommand::SettingsSourceReceipt => plugin_response(
id,
payload,
lithe_plugin_model::settings::sources::receipt_command,
),
PluginsCommand::SettingsNavigation => plugin_response(
id,
payload,
Expand Down
12 changes: 11 additions & 1 deletion rust/crates/core/src/tests/build_runtime_versions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,16 @@ fn host_runtime_probe_arguments_are_portable_across_platforms() {
.enumerate()
{
assert_eq!(runtimes[index]["hostManaged"], true, "{platform}");
assert_eq!(runtimes[index]["executables"], json!([]), "{platform}");
let id = if index == 0 { "node" } else { "go" };
assert_eq!(
runtimes[index]["executables"],
json!([{"kind":"runtime","runtime":id}]),
"{platform}"
);
assert_eq!(
runtimes[index]["pathVariable"],
format!("LITHE_{}_PATH", id.to_ascii_uppercase())
);
assert_eq!(
runtimes[index]["version"]["arguments"], arguments,
"{platform}"
Expand Down Expand Up @@ -77,6 +86,7 @@ fn runtime_without_executables_becomes_a_toolchain_candidate() {
"id": "vm",
"displayName": null,
"hostManaged": false,
"pathVariable":"LITHE_VM_PATH",
"executables": [
{ "kind": "toolchain", "toolchainID": "vm", "root": "." }
],
Expand Down
1 change: 1 addition & 0 deletions rust/crates/core/src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ mod notification_read;
mod plugin_editor_resources;
mod plugin_run_debug;
mod plugin_settings_documents;
mod plugin_source_settings;
mod process_memory;
mod project;
mod project_generators;
Expand Down
57 changes: 57 additions & 0 deletions rust/crates/core/src/tests/plugin_source_settings.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
//! Public-dispatch coverage for the shared source-backed settings fixture.

use serde_json::{json, Value};

#[test]
fn native_source_settings_fixture_is_available_through_the_public_boundary() {
let fixture: Value = serde_json::from_str(include_str!(concat!(
env!("CARGO_MANIFEST_DIR"),
"/../../fixtures/plugins/settings-sources.json"
)))
.unwrap();
let response: Value = serde_json::from_str(&crate::execute_json(
&json!({"command":"plugins.settings.sourceState","payload":{"result":fixture["snapshot"]}})
.to_string(),
))
.unwrap();
assert_eq!(response["ok"], true, "{response}");
assert_eq!(response["data"]["status"], "ok", "{response}");
assert_eq!(
response["data"]["state"]["inputs"]["root"]["target"]["inherit"],
true
);
}

#[test]
fn source_editor_actions_require_explicit_host_capability_and_keep_their_binding() {
let manifest: Value = serde_json::from_str(include_str!(concat!(
env!("CARGO_MANIFEST_DIR"),
"/../../../shared/plugins/contract/v1/fixtures/settings/source-editor.plugin.json"
)))
.unwrap();
let run = |command: &str, payload: Value| -> Value {
serde_json::from_str(&crate::execute_json(
&json!({"command":command,"payload":payload}).to_string(),
))
.unwrap()
};
let old_host = json!({"backend":[0],"languages":[0],"settings":[0]});
let refused = run(
"plugins.declarative.validate",
json!({"manifest":manifest,"hostCapabilities":old_host}),
);
assert_eq!(
refused["data"]["error"]["code"], "plugin.api.unsupported",
"{refused}"
);
let plan = run(
"plugins.declarative.settingsActionPlan",
json!({
"manifest":manifest,"owner":{"pluginID":"dev.lithe.test.source-settings","version":"1.0.0"},
"actionID":"compiler","enabled":true,"confirmed":false,"workspaceAvailable":true
}),
);
assert_eq!(plan["data"]["plan"]["sourceEditor"], true, "{plan}");
assert_eq!(plan["data"]["plan"]["function"], "compiler.settings");
assert_eq!(plan["data"]["plan"]["params"], json!({}));
}
29 changes: 29 additions & 0 deletions rust/crates/plugin-manifest/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,35 @@ impl DeclarativePluginManifest {
for (index, action) in self.setting_actions.iter().enumerate() {
let field = format!("settingActions[{index}]");
action.validate(&field)?;
if let Some(editor) = &action.source_editor {
if self.backend.is_none() {
return Err(invalid(
&field,
"A source editor requires the plugin's own backend.",
));
}
if editor
.build_system_id
.as_ref()
.is_some_and(|id| !self.build_systems.iter().any(|system| &system.id == id))
{
return Err(invalid(
&field,
"A source editor may reference only a declared build system.",
));
}
if editor.language_id.as_ref().is_some_and(|id| {
!self
.language_servers
.iter()
.any(|server| &server.language_id == id)
}) {
return Err(invalid(
&field,
"A source editor may reference only a declared language server.",
));
}
}
if !ids.insert(action.id.clone()) {
return Err(invalid(
format!("{field}.id"),
Expand Down
2 changes: 1 addition & 1 deletion rust/crates/plugin-manifest/src/settings_surfaces.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ pub fn settings_catalog_command(payload: Value) -> Result<Value, CoreError> {
let key = page["key"].as_str().unwrap_or_default().to_owned();
let target = pages.entry(key.clone()).or_insert_with(|| json!({
"key":key,"kind":page["kind"],"id":page["id"],
"title":titles.get(&key).cloned().unwrap_or_else(|| page["id"].as_str().unwrap_or_default().to_owned()),"contributors":[]
"title":titles.get(&key).or_else(|| titles.get(&format!("language:{}",page["id"].as_str().unwrap_or_default()))).or_else(|| titles.get(&format!("buildSystem:{}",page["id"].as_str().unwrap_or_default()))).cloned().unwrap_or_else(|| page["id"].as_str().unwrap_or_default().to_owned()),"contributors":[]
}));
target["contributors"].as_array_mut().expect("catalog array").push(json!({
"pluginID":id,"version":manifest.version,"title":manifest.display_name,"sections":page["sections"]
Expand Down
12 changes: 11 additions & 1 deletion rust/crates/plugin-manifest/src/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,11 @@ impl DeclarativePluginManifest {
// when the host asks it for the server's command line; an
// exported function starts it when another plugin calls it.
// Neither needs a page, command or workspace event.
provider_query_trigger: !self.toolchain_providers.is_empty()
provider_query_trigger: self
.setting_actions
.iter()
.any(|action| action.source_editor.is_some())
|| !self.toolchain_providers.is_empty()
|| !self.keymap_import_providers.is_empty()
|| self
.language_servers
Expand Down Expand Up @@ -301,6 +305,12 @@ impl DeclarativePluginManifest {
capabilities::SETTINGS,
!self.settings.is_empty() || !self.setting_actions.is_empty(),
),
(
capabilities::SOURCE_SETTINGS,
self.setting_actions
.iter()
.any(|action| action.source_editor.is_some()),
),
(capabilities::UI, self.ui.is_some()),
(capabilities::BUILD_SYSTEMS, !self.build_systems.is_empty()),
(
Expand Down
4 changes: 4 additions & 0 deletions rust/crates/plugin-model/src/capabilities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ pub const EXECUTION_PROVIDERS: &str = "executionProviders";
/// `settings[]`: scopes, effects, settings pages, and the multiSelect, text,
/// file, and directory types; see [`crate::settings`].
pub const SETTINGS: &str = "settings";
/// Source-backed workspace editors returned by settings actions, including
/// compiler pages and guarded native staging receipts.
pub const SOURCE_SETTINGS: &str = "sourceSettings";
/// `ui`: tool windows with text, web, or host-rendered native content, and
/// commands.
pub const UI: &str = "ui";
Expand Down Expand Up @@ -121,6 +124,7 @@ pub const SUPPORTED_CAPABILITIES: &[(&str, &[u32])] = &[
(PLUGIN_FUNCTIONS, &[0]),
(PROJECT_GENERATORS, &[0]),
(SETTINGS, &[0]),
(SOURCE_SETTINGS, &[0]),
(TOOL_DEFINITIONS, &[0]),
(TOOLCHAIN_PROVIDERS, &[0]),
(UI, &[0]),
Expand Down
49 changes: 49 additions & 0 deletions rust/crates/plugin-model/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ pub use localization::{
};
mod pages;
pub use pages::page_sections;
pub mod sources;

use crate::rejection::{invalid, PluginRejection, Validation};
use regex::Regex;
Expand Down Expand Up @@ -97,6 +98,9 @@ pub enum SettingPage {
/// Build Tools › *build system*.
#[serde(rename = "buildSystemID")]
BuildSystem(String),
/// Build, Execution, Deployment › Compilers › *compiler*.
#[serde(rename = "compilerID")]
Compiler(String),
}

/// A button the host draws on a settings page that invokes one of the same
Expand Down Expand Up @@ -126,6 +130,25 @@ pub struct SettingAction {
/// Ask before invoking, for actions that discard state.
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
confirm: bool,
/// The read result is a typed native-source form; saves invoke its distinct
/// staging function only after native confirmation.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub source_editor: Option<SourceEditorDeclaration>,
}

/// Explicit read/edit roles allow frequent read successes to be suppressed
/// while SDKs record confirmed edit outcomes at their ordinary boundary.
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
pub struct SourceEditorDeclaration {
/// Same-plugin function that writes only the host's private staging file.
pub edit_function: String,
/// Optional declared build system whose native tool and stored options accompany reads.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub build_system_id: Option<String>,
/// Optional declared language server made ready before a source query.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub language_id: Option<String>,
}

/// Resolves one declared action without native I/O or runtime admission. Only
Expand Down Expand Up @@ -161,6 +184,12 @@ pub fn plan_action(
plan["kind"] = json!("invoke");
plan["function"] = json!(action.function);
plan["params"] = json!({});
if let Some(editor) = &action.source_editor {
plan["sourceEditor"] = json!(true);
plan["editFunction"] = json!(editor.edit_function);
plan["buildSystemID"] = json!(editor.build_system_id);
plan["languageID"] = json!(editor.language_id);
}
}
Ok(plan)
}
Expand All @@ -171,6 +200,22 @@ pub const MAX_SETTING_ACTIONS: usize = 16;
impl SettingAction {
/// Checks the action as the manifest entry at `field`.
pub fn validate(&self, field: &str) -> Validation<()> {
if matches!(self.page, Some(SettingPage::Compiler(_))) && self.source_editor.is_none() {
return Err(invalid(
field,
"Compiler pages require a native source-editor action.",
));
}
if let Some(editor) = &self.source_editor {
if !crate::is_function_id(&editor.edit_function)
|| editor.edit_function == self.function
{
return Err(invalid(
format!("{field}.sourceEditor.editFunction"),
"A source editor names a distinct same-plugin staging function.",
));
}
}
if !is_setting_identifier(&self.id) {
return Err(invalid(
format!("{field}.id"),
Expand Down Expand Up @@ -216,6 +261,7 @@ fn check_page(page: &SettingPage, field: &str) -> Validation<()> {
let (key, id) = match page {
SettingPage::Language(id) => ("languageID", id),
SettingPage::BuildSystem(id) => ("buildSystemID", id),
SettingPage::Compiler(id) => ("compilerID", id),
};
if !is_setting_option_value(id) {
return Err(invalid(
Expand Down Expand Up @@ -470,6 +516,9 @@ impl SettingDeclaration {

/// Checks the declaration against the `settings` capability contract.
pub fn validate(&self, field: &str) -> Validation<()> {
if matches!(self.page, Some(SettingPage::Compiler(_))) {
return Err(invalid(field,"Compiler pages contain native source-editor actions, not stored plugin preferences."));
}
if !is_setting_identifier(&self.id) {
return Err(invalid(
format!("{field}.id"),
Expand Down
Loading
Loading