Repository navigation
Add cross-platform process resource and termination action - #1797
Conversation
Replace the experimental process fixture with Microsoft.System/Process get and filtered export operations. Add the TerminateProcess action, migrate engine tests to dsctest, document the new contracts, and include both manifests in release packages. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved process-handling bugs can reject valid empty Linux process names, break synthetic command-line tests, and treat threads as independent processes.
3 open issues
What changed in this PR
Replaces the experimental process fixture with a read-only, cross-platform Microsoft.System/Process resource and a separate termination action, while moving engine tests to deterministic fixtures.
Changes:
- Adds real process queries, filtered export, and termination by PID or exact name.
- Adds resource tests and migrates engine tests away from live process enumeration.
- Packages both manifests and the executable for Windows, Linux, and macOS, with reference documentation and examples.
| File | Description |
|---|---|
| resources/process/tests/process_terminate.tests.ps1 | Tests action discovery, termination, and invalid targets. |
| resources/process/tests/process_get.tests.ps1 | Tests PID queries and input validation. |
| resources/process/tests/process_export.tests.ps1 | Tests enumeration and combined export filters. |
| resources/process/terminateprocess.dsc.action.json | Defines the termination action and its schemas. |
| resources/process/src/process_info.rs | Implements process snapshots, filtering, and termination. |
| resources/process/src/main.rs | Dispatches operations and handles JSON input and errors. |
| resources/process/process.dsc.resource.json | Defines the renamed, read-only resource. |
| resources/process/locales/en-us.toml | Adds localized diagnostics. |
| resources/process/ExportTest.dsc.yaml | Updates the export example to the new resource. |
| resources/process/Cargo.toml | Adds regex and localization dependencies. |
| resources/process/.project.data.json | Includes the action manifest in build output. |
| lib/dsc-lib/src/configure/config_doc.rs | Migrates parser test data to Test/Export. |
| dsc/tests/other/dsc_resource_get.tests.ps1 | Uses a deterministic export fixture. |
| dsc/tests/other/dsc_actions.tests.ps1 | Limits discovery assertions to test actions. |
| dsc/tests/config/dsc_export.tests.ps1 | Replaces process-dependent tests with fixtures. |
| docs/reference/resources/Microsoft/System/Process/index.md | Documents query behavior, properties, and migration. |
| docs/reference/resources/Microsoft/System/Process/examples/query-processes.md | Demonstrates queries and filtered exports. |
| docs/reference/resources/Microsoft/System/Action/TerminateProcess/index.md | Documents termination behavior and safety constraints. |
| docs/reference/resources/Microsoft/System/Action/TerminateProcess/examples/terminate.config.dsc.yaml | Provides a PID-targeted configuration example. |
| docs/reference/resources/Microsoft/System/Action/TerminateProcess/examples/terminate-process.md | Explains how to invoke termination. |
| docs/reference/cli/config/export.md | Updates the process resource type in an example. |
| docs/get-started/index.md | Updates the resource listing and capabilities. |
| docs/concepts/resources/overview.md | Updates the resource listing and capabilities. |
| data.build.json | Adds process artifacts to platform packages. |
| Cargo.lock | Records the added process dependencies. |
Review effort: Balanced
Allow empty operating-system names in returned state, ignore expected command lines during get, and exclude Linux tasks from process snapshots. Add regression coverage and update CI assertions for the new resource and action. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
😁 Code Coverage ReportChanged Code Coverage95% (90%+ coverage)
🔵 Full Codebase Coverage83% (good)
|
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🔵 Needs a closer look
The destructive termination action was validated only on Windows, leaving Linux/macOS target selection, isolation, and permission or partial-failure behavior requiring runtime validation and platform-owner review.
No open issues 🎉
3 resolved since last review
Review effort: Balanced
Mikey Lombardi (He/Him) (michaeltlombardi)
left a comment
There was a problem hiding this comment.
Ergonomics and schema look good to me!
| pub fn validate(&self) -> Result<(), String> { | ||
| if self.name.as_ref().is_some_and(String::is_empty) { | ||
| return Err(t!("input.emptyName").to_string()); | ||
| } | ||
| Ok(()) | ||
| } | ||
|
|
||
| pub fn validate_identity(&self) -> Result<(), String> { | ||
| self.validate()?; | ||
| if self.pid.is_none() && self.name.is_none() { | ||
| return Err(t!("input.missingIdentity").to_string()); | ||
| } | ||
| if self.name.as_ref().is_some_and(|name| name.contains('*')) { | ||
| return Err(t!("input.wildcardOnlyExport").to_string()); | ||
| } | ||
| Ok(()) | ||
| } | ||
| } |
There was a problem hiding this comment.
Nit: Generally, prefer to make it impossible to create an invalid instance of the type over implementing validation functions called on an existing instance.
This is a bit tough with the serde model, but maybe if we refactor as validate_value(input: &serde_json::Value) and call the validation prior to deserializing from value?
More realistically, we need a higher level abstraction for this pattern to be able to use across our own types/crates. We do a lot of adhoc validation between JSON Schema, serde, and struct impls.
There was a problem hiding this comment.
Let's think about this more broadly and apply the pattern across the resources later

The experimental process resource echoes input for state operations and limits export to four processes. Replace it with useful cross-platform process queries, while keeping engine tests deterministic by moving them to existing dsctest resources.
Changes
Microsoft/ProcesswithMicrosoft.System/Process, supporting realgetandexporton Windows, Linux, and macOS. Export combines optional PID, name, and command-line filters; process names support*wildcards.Microsoft.System.Action/TerminateProcessfor configurationset. It accepts either a PID or an exact process name, terminates every name match, and reports missing targets and partial failures. Wildcards are intentionally rejected for termination.Migration considerations
The resource type changes to
Microsoft.System/Process. It is read-only and no longer implementssetor nativetest; termination is exposed separately as an action.cmdlinenow contains an array of individual arguments rather than a debug-formatted string. Get requires a PID or an unambiguous exact name; export returns all matching processes without the previous enumeration limit.Validation
Validated on Windows using the repository-root
build.ps1:Linux and macOS runtime validation was not performed locally.