diff --git a/rust/contracts/rust-core-api.md b/rust/contracts/rust-core-api.md index c6d40cfb..18c1a0f6 100644 --- a/rust/contracts/rust-core-api.md +++ b/rust/contracts/rust-core-api.md @@ -5285,7 +5285,7 @@ user to trust the workspace before an action the user started. | Command | Request | Result | | --- | --- | --- | -| `build.detect` | `{ workspaceRoot, plugins: [{ manifest }], options?: { : { : value } }, instanceOptions?: { : { : { : value } } }, instanceDefaults?: { : { : value } }, emptySelections?: { : { : [optionID] } }, ignoredPaths?: [pattern] }` | `detection`: `{ instances, rejected: [{ index, error }], shadowed: [{ pluginID, buildSystemID, by }] }`; each instance is `{ id, pluginID, buildSystemID, displayName, root, markers, modelSource, optionFingerprint, options, droppedOptions }` plus `model` or `modelError` for `static` and `hostIntegration` sources; a `provider` source has neither. `options` contains accepted stored values after Core scope/root merging, including explicit empty selections; `droppedOptions` names rejected stored values without rewriting the source document. The scan does not enter a directory `ignoredPaths` names; omitted (or `null`), it is Core's default `[".*"]`, every directory whose name starts with a dot, and `[]` ignores nothing beyond the shared scan policy. Hosts pass `storage.ignoredPaths.patterns` from `build.resolveStoredOptions`. An unusable list rejects with `plugin.build.invalidIgnoredPath` (see `build.editIgnoredPaths`). | +| `build.detect` | `{ workspaceRoot, plugins: [{ manifest }], options?: { : { : value } }, instanceOptions?: { : { : { : value } } }, instanceDefaults?: { : { : value } }, emptySelections?: { : { : [optionID] } }, ignoredPaths?: [pattern] }` | `detection`: `{ instances, rejected: [{ index, error }], shadowed: [{ pluginID, buildSystemID, by }] }`; each instance is `{ id, pluginID, buildSystemID, displayName, root, markers, modelSource, optionFingerprint, options, droppedOptions }` plus `model` or `modelError` for `static` and `hostIntegration` sources; a `provider` source has neither. `options` contains accepted stored values after Core scope/root merging, including explicit empty selections; `droppedOptions` names rejected stored values without rewriting the source document: a value a declared option does not accept, and a value saved for an option ID the build system no longer declares (in `options`, the root's `instanceOptions` or `instanceDefaults`), which contributes nothing to `options`, the model or the fingerprint. The scan does not enter a directory `ignoredPaths` names; omitted (or `null`), it is Core's default `[".*"]`, every directory whose name starts with a dot, and `[]` ignores nothing beyond the shared scan policy. Hosts pass `storage.ignoredPaths.patterns` from `build.resolveStoredOptions`. An unusable list rejects with `plugin.build.invalidIgnoredPath` (see `build.editIgnoredPaths`). | | `build.localizeOptions` | `{ language?, plugins: [{ manifest, localizations? }] }`, without the standard manifest/build-system wrapper | `{ manifests, localizations }`: one manifest per plugin in request order, with the `buildOptions` part of the first accepted translation file applied to `buildSystems[].options[]` (`displayName`, `description`, choice `title`), else as sent; one report per plugin that declares a build option when `language` is set, `{ pluginID, language, candidates, maximumBytes, readRequired, applied, rejected }` as in `plugins.settings`. Hosts send it without `localizations`, read the named candidates from the installed package, send it again with them, and detect with the returned manifests. A file that does not fit is refused whole as `plugin.build.invalidLocalization` | | `build.projectOptions` | `{ document }`, host-read persisted v1 Build options, without a manifest | `document`: validated storage with version 1, systems and optional `ignoredPaths`; options, instance defaults, root values, explicit empty selections and saved custom choices are retained. Missing system fields normalize to empty maps; malformed, unsupported or oversized documents reject with `plugin.build.invalidOptionsDocument`. This pure operation never reads or writes a file and does not replace declared option resolution. | | `build.resolveStoredOptions` | `{ document, local: { version: 1, document, emptySelections?: { : { : [optionID] } } } }`, without a manifest | `storage: { document, local, emptySelections, ignoredPaths: { patterns, source } }`: checked team/local merge; local values override matching keys, unrelated systems/roots/choices stay intact. `ignoredPaths` is the list `build.detect` uses: a local list replaces the team's whole (`source: "local"`), then the team's (`"team"`), then Core's default `[".*"]` (`"default"`). No filesystem I/O. Local documents are machine/workspace preferences, not team files or plugin-native configuration. Their storage syntax is [build-local-options-v1.schema.json](build-local-options-v1.schema.json), with additional cross-field membership and byte limits checked by Core. | diff --git a/rust/crates/build/src/detect.rs b/rust/crates/build/src/detect.rs index a823bb82..53fd733c 100644 --- a/rust/crates/build/src/detect.rs +++ b/rust/crates/build/src/detect.rs @@ -279,6 +279,20 @@ pub(crate) fn detect(request: DetectRequest) -> Validation(json!({ + "workspaceRoot": workspace.root(), "plugins": [{"manifest": manifest.clone()}], + "options": {"cargo": options}, + "instanceOptions": {"cargo": {"a": instances}}, + "instanceDefaults": {"cargo": defaults} + })) + .unwrap(); + assert_eq!(result["status"], "ok", "{result}"); + instance(&result["detection"], "cargo:a").clone() + }; + let kept = detect( + json!({"offline": true}), + json!({"settingsFile": "/fixture/a.xml"}), + json!({}), + ); + let dropped = detect( + json!({"offline": true, "javaHome": "/jdk/21"}), + json!({"settingsFile": "/fixture/a.xml", "oldInstance": "x"}), + json!({"oldDefault": ["y"]}), + ); + assert_eq!(kept["droppedOptions"], json!([])); + assert_eq!( + dropped["droppedOptions"], + json!(["javaHome", "oldDefault", "oldInstance"]) + ); + // The values are named, never applied: options, model and fingerprint + // are those of the instance without them. + assert_eq!(dropped["options"], kept["options"]); + assert_eq!(dropped["model"], kept["model"]); + assert_eq!(dropped["optionFingerprint"], kept["optionFingerprint"]); +} + #[test] fn instance_options_drive_static_run_entries_without_crossing_roots_or_scopes() { let workspace = TemporaryWorkspace::new("build-instance-options");