Repair app-server daemon packages with update --from-cli (#65046)

## Why

A daemon with a dangling package selection or a missing executable can
fail to start, and leftover logs can make an absent installation look
like an existing one.

## What changed

- Let `codex app-server daemon update --from-cli` install or repair and
  pin the daemon from a complete CLI package. Point missing-executable
  errors to that command. Repair checks that the daemon and updater are
  stopped and that the package selection has stayed unchanged.
- Let `codex app-server daemon start` bootstrap a missing installation
  even when old daemon logs remain. Use legacy logs to infer a stopped
  standalone installation only when its package selection still exists
  and dedicated daemon logs are absent.
- Allow repair to replace a dangling Windows junction whose target is
  directly under the daemon's releases directory.

## Testing

Extend coverage for startup with leftover logs, package repair after
losing the selection or executable, repair blocked by a starting
daemon or updater, and replacement of a dangling Windows junction.

GitOrigin-RevId: 679266cc22b7ff7a34bbd41c2bf0659d3068eb75
This commit is contained in:
Eric Traut
2026-12-01 17:56:54 +00:00
committed by copyberry
parent 09984ca85d
commit b6087365cd
9 changed files with 188 additions and 64 deletions
@@ -69,6 +69,11 @@ fn packaged_daemon_launch(action: &str, initial: InitialDaemon) -> Result<()> {
let state = daemon.home.path().join("app-server-daemon");
if initial == InitialDaemon::Missing {
std::fs::remove_file(state.join("app-server.stderr.log"))?;
if action == "start" {
for log in ["daemon.stderr.log", "daemon-updater.stderr.log"] {
std::fs::write(state.join(log), b"previous launch")?;
}
}
}
std::fs::write(
state.join("settings.json"),