Refactor Windows sandbox setup and service helpers (#45455)

## What changed

- Extract helper copying, token-user SID queries, provisioning pipe ownership, and service runtime lifecycle into dedicated modules.
- Simplify command-runner resolution and extract setup configuration loading, payload execution, provisioning request exchange, and response handling into helpers.
- Parameterize installation-record registry access and return the saved installation record from authenticated user registration.

## Testing

Add tests for explicit setup `cwd` selection and effective workspace roots, plus valid and invalid token-user SID queries. Move existing helper-copy and freshness tests alongside the extracted copy implementation.

GitOrigin-RevId: ffb39adae7611baa95e85c89f9a31ef7a779e217
This commit is contained in:
zm-oai authored and copyberry committed 2026-09-14 16:05:40 +00:00
1 parent 7a48b95c6c
commit 1a02867bd1
19 files changed
+640 -486

No files matched your search

@@ -68,7 +68,7 @@ impl PackageLifecycle {
&self,
mut record: InstallationRecord,
user_token: OwnedHandle,
) -> Result<()> {
) -> Result<InstallationRecord> {
let mut active = self.installation.borrow_mut();
let previous = match active.as_ref() {
Some(installation) => Some(installation.record.clone()),
@@ -91,10 +91,11 @@ impl PackageLifecycle {
&& installation.codex_home.is_some()
{
// A restored watcher must immediately use newly registered desktop ownership.
installation.record = record;
return Ok(());
installation.record = record.clone();
return Ok(record);
}
let saved_record = record.clone();
with_owner_impersonation(user_token.0, || {
let mut directory_handles = Vec::new();
let codex_home = match crate::ipc::pin_existing_ancestors(
@@ -163,7 +164,8 @@ impl PackageLifecycle {
token,
});
Ok(())
})
})?;
Ok(saved_record)
}
pub(crate) fn restore_logged_in_owner(&self, recorded_session_id: u32) -> Result<()> {
@@ -231,6 +233,7 @@ impl PackageLifecycle {
},
token,
)
.map(|_| ())
}
pub(crate) fn clean_up(&self) -> Result<()> {