Skip to content

Commit 7125480

Browse files
1lckclaude
andcommitted
fix(build): name options the build system no longer declares in droppedOptions
build.detect copied only declared options into each instance's stored values, so a value saved for an option a plugin update removed never reached option resolution and droppedOptions stayed empty. Detection now passes those values on too; resolution names them in droppedOptions and they still contribute nothing to options, the model or the fingerprint. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent f27352f commit 7125480

3 files changed

Lines changed: 58 additions & 1 deletion

File tree

‎rust/contracts/rust-core-api.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5285,7 +5285,7 @@ user to trust the workspace before an action the user started.
52855285

52865286
| Command | Request | Result |
52875287
| --- | --- | --- |
5288-
| `build.detect` | `{ workspaceRoot, plugins: [{ manifest }], options?: { <buildSystemID>: { <optionID>: value } }, instanceOptions?: { <buildSystemID>: { <root>: { <optionID>: value } } }, instanceDefaults?: { <buildSystemID>: { <optionID>: value } }, emptySelections?: { <buildSystemID>: { <root>: [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`). |
5288+
| `build.detect` | `{ workspaceRoot, plugins: [{ manifest }], options?: { <buildSystemID>: { <optionID>: value } }, instanceOptions?: { <buildSystemID>: { <root>: { <optionID>: value } } }, instanceDefaults?: { <buildSystemID>: { <optionID>: value } }, emptySelections?: { <buildSystemID>: { <root>: [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`). |
52895289
| `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` |
52905290
| `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. |
52915291
| `build.resolveStoredOptions` | `{ document, local: { version: 1, document, emptySelections?: { <systemID>: { <root>: [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. |

‎rust/crates/build/src/detect.rs‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,20 @@ pub(crate) fn detect<M: BuildManifest>(request: DetectRequest) -> Validation<Val
279279
values.insert(option.id.clone(), json!([]));
280280
}
281281
}
282+
// A value saved for an option the build system no longer
283+
// declares (a plugin update dropped it) is passed on too: it
284+
// contributes nothing, and option resolution names it in the
285+
// instance's droppedOptions so the host can show and clear it.
286+
let defaults = request.instance_defaults.get(&owner.declaration.id);
287+
for (id, value) in stored
288+
.iter()
289+
.chain(local.into_iter().flatten())
290+
.chain(defaults.into_iter().flatten())
291+
{
292+
if owner.declaration.option(id).is_none() {
293+
values.entry(id.clone()).or_insert_with(|| value.clone());
294+
}
295+
}
282296
instances.push(instance(owner, &workspace, &root, markers, &values));
283297
}
284298
}

‎rust/crates/core/src/tests/build_systems.rs‎

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,49 @@ fn resolved_tool_environment_reaches_providers_with_option_precedence_and_bounde
282282
}
283283
}
284284

285+
#[test]
286+
fn detection_names_saved_options_the_build_system_no_longer_declares() {
287+
let workspace = TemporaryWorkspace::new("build-dropped-options");
288+
workspace
289+
.write(
290+
"a/Cargo.toml",
291+
"[package]\nname = \"a\"\nversion = \"1.0.0\"\n",
292+
)
293+
.write("a/src/main.rs", "fn main() {}\n");
294+
let manifest = fixture("build-instance-options.plugin.json");
295+
let detect = |options: Value, instances: Value, defaults: Value| {
296+
let result = build_detect_command::<Manifest>(json!({
297+
"workspaceRoot": workspace.root(), "plugins": [{"manifest": manifest.clone()}],
298+
"options": {"cargo": options},
299+
"instanceOptions": {"cargo": {"a": instances}},
300+
"instanceDefaults": {"cargo": defaults}
301+
}))
302+
.unwrap();
303+
assert_eq!(result["status"], "ok", "{result}");
304+
instance(&result["detection"], "cargo:a").clone()
305+
};
306+
let kept = detect(
307+
json!({"offline": true}),
308+
json!({"settingsFile": "/fixture/a.xml"}),
309+
json!({}),
310+
);
311+
let dropped = detect(
312+
json!({"offline": true, "javaHome": "/jdk/21"}),
313+
json!({"settingsFile": "/fixture/a.xml", "oldInstance": "x"}),
314+
json!({"oldDefault": ["y"]}),
315+
);
316+
assert_eq!(kept["droppedOptions"], json!([]));
317+
assert_eq!(
318+
dropped["droppedOptions"],
319+
json!(["javaHome", "oldDefault", "oldInstance"])
320+
);
321+
// The values are named, never applied: options, model and fingerprint
322+
// are those of the instance without them.
323+
assert_eq!(dropped["options"], kept["options"]);
324+
assert_eq!(dropped["model"], kept["model"]);
325+
assert_eq!(dropped["optionFingerprint"], kept["optionFingerprint"]);
326+
}
327+
285328
#[test]
286329
fn instance_options_drive_static_run_entries_without_crossing_roots_or_scopes() {
287330
let workspace = TemporaryWorkspace::new("build-instance-options");

0 commit comments

Comments
 (0)