Skip to content

fix(server): refuse to share a T3 home with a pre-lock background service - #14

Closed
arun279 wants to merge 1 commit into
maria-rcks:fix/6097-state-ownership-safe-rollbackfrom
arun279:fix/ownership-legacy-boot-service
Closed

arun279 wants to merge 1 commit into
maria-rcks:fix/6097-state-ownership-safe-rollbackfrom
arun279:fix/ownership-legacy-boot-service

Conversation

@arun279

@arun279 arun279 commented Oct 9, 2026

Copy link
Copy Markdown

Follow-up to pingdotgg#16102.

A pre-lock owner is only detected through server-runtime.json. Pre-lock servers overwrite that record on start and delete it on shutdown, so a pre-lock background service that no longer owns the record is invisible, and a lock-aware desktop or CLI server starts next to it on the same T3 home. The usual way to get there is a service installed once with npx t3, which nothing updates afterwards, plus the desktop app on the same ~/.t3.

Before claiming ownership, acquireServerOwnership now looks at the boot service installed for the same home (canonical path from the unit's T3CODE_HOME). It refuses with exit 78 when the service is loaded or will load at login, and its runtime fails the launcher's existing __service-preflight ownership probe. The message asks the user to run t3 update or t3 service uninstall. The fixed exit-78 dialogs in the desktop and WSL backends name the same two commands.

  • A booted-out and disabled launch agent, or an inactive and disabled systemd unit, does not block.
  • The service's own launcher and server processes and update trials skip the check.
  • Probe failures, missing files and unsupported platforms never block startup. Nothing is stopped or signalled.
  • The check runs only after the SQLite lock is acquired and the existing record check passes, so lock-aware owners never trigger the probes.

The unit constants and T3CODE_HOME parser move to cloud/bootServiceConfig.ts because bootService.ts already imports serverOwnership.ts. The preflight arguments and result check move to servicePreflight.ts so the launcher and this check share them.

Verification

  • vp test run apps/server/src/serverOwnership.test.ts apps/server/src/cloud/bootService.test.ts apps/server/src/serviceLauncher.test.ts: 79 passed. The new tests use real temporary homes and the real SQLite lock, with fakes only at the process boundary. They cover both macOS 13+ (=> disabled) and macOS 12 (=> true) launchctl print-disabled output.
  • Server and desktop typecheck, scoped lint and format pass.
  • macOS 26.6, real launchctl: with HOME pointed at a temporary directory whose plist serves a temporary T3 home with activeVersion 0.0.42, and the real com.t3tools.t3code.service booted out and disabled, the server starts.
  • A real 0.0.42 runtime answers the probe with {"status":"ready","version":"0.0.42","launcherProtocol":2} (no ownershipProtocol), so it is treated as pre-lock. service-state.json and __service-preflight both first shipped in 0.0.32, so every runtime this check reads answers the probe rather than falling through to starting a server.

Not verified: the refusal path against a real loaded launchd job or a real systemd unit (it would replace the machine's real service), and the desktop dialog. Services installed by 0.0.29 to 0.0.31 have no service-state.json and are not detected. A pre-lock server started by hand after a lock-aware one is still undetectable.

Implemented with gpt-6.1-sol through Codex and Claude Opus 5.5 in T3 Code.

…vice

A pre-lock owner is only detected through server-runtime.json, which pre-lock
servers overwrite on start and delete on shutdown. A pre-lock boot service that
no longer owns that record is invisible, so a lock-aware desktop or CLI server
starts next to it on the same T3 home.

Before claiming ownership, check the boot service installed for this home. If
it is loaded or will load at login, and its runtime fails the existing
__service-preflight ownership probe, refuse with exit 78 and ask the user to
run `t3 update` or `t3 service uninstall`. A booted-out and disabled service
does not block. Probe failures never block startup.
@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:L labels Oct 9, 2026
@arun279

arun279 commented Oct 9, 2026

Copy link
Copy Markdown
Author

Superseded by #15.

@arun279 arun279 closed this Oct 9, 2026
@arun279
arun279 deleted the fix/ownership-legacy-boot-service branch October 22, 2026 01:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant