Skip to main content

Module task

Module task 

Source
Expand description

The one Windows login task that keeps a managed WSL distribution alive, and the four operations on it: render, register, query, remove.

§What the task promises, and what it does not

WSL distributions are registered per user, so nothing that runs before a user logs on can start one. The 2026-09-06 review closed exactly this defect: an earlier design promised boot availability that Windows cannot deliver. So this is a LogonTrigger task for one named principal, and 02-target-architecture.md states the consequence in the product’s own words — “unattended Linux availability after that user’s logon, not before any interactive logon after a Windows reboot”.

§There is no shell text in the action, at any layer

The other half of that review closed a design that composed systemctl and a keep-alive through a shell string. The action here is

<Command>C:\Windows\System32\wsl.exe</Command>
<Arguments>--distribution Ubuntu --user root --exec /usr/local/bin/runner-manager wsl-host hold</Arguments>

Task Scheduler has no Arguments vector — the element is a single string that Windows splits with CommandLineToArgvW — so LifecycleTask::action_arguments builds the vector and LifecycleTask::rendered_arguments quotes each element with the same function the service installer uses. A distribution called My Ubuntu is therefore "My Ubuntu" in the document and one argument again on the way out. What is not there is a cmd /c, a &&, a ;, or anything else a shell would interpret, and no_shell_text_reaches_the_task_document is the test that keeps it that way.

wsl-host hold is a hidden Linux-only command that starts the existing systemd unit by argument-vector process execution and then stays alive. Naming it here is this crate’s whole contribution to the lifecycle: the Linux side of it belongs to the CLI.

§A task this did not create is never touched

The name is derived from the distribution, so two workstations agree on it and a re-run updates the task rather than accumulating copies. That same determinism means the name could collide with something an operator made by hand — and on the target workstation there is a hand-created task doing this job today (01-current-architecture.md). So every mutating operation reads the task back first and refuses unless its description carries PRODUCT_MARKER. wsl detach removing somebody else’s keep-alive task would be precisely the destructive behaviour the review renamed the command to avoid.

Structs§

Detached
What LifecycleTaskControl::detach did, and what it deliberately did not.
LifecycleTask
Everything needed to render the task.
LifecycleTaskControl
Registering, reading and removing the product’s lifecycle task.
LifecycleTaskIdentity
The stable, per-distribution name of the product’s lifecycle task.
RegisteredTask
What Task Scheduler says about a task that is registered.

Constants§

HOLD_ARGUMENTS
The hidden Linux command the task runs.
LIFECYCLE_TASK_PREFIX
The prefix every product-owned lifecycle task name starts with.
PRODUCT_MARKER
The string that says a task is this product’s.