Skip to content

app: one engine on a home; a second waits for the first to end - #2274

Merged
santoshkumarradha merged 5 commits into
app/v3from
c52/one-engine-lock
Nov 3, 2026
Merged

santoshkumarradha merged 5 commits into
app/v3from
c52/one-engine-lock

Conversation

@santoshkumarradha

Copy link
Copy Markdown
Member

A second desktop engine on the same home now waits for the first to end, so two engines can't pay for the same work.

Before, an engine that was still closing (for example during an update) could run beside its replacement. Both sent the paid model call for the same Factory read. Job steps were already protected and did not run twice.

  • codeaf app holds an OS lock on its home until the process ends. A crash releases it.
  • A second engine waits before saying hello. It starts no recovery, Factory work or clock, makes no requests and leaves the home untouched. It starts as soon as the first ends.
  • If the first is still there after the wait (longest careful wrap-up plus 10 seconds), the second exits and logs another codeaf app is still closing this home. It has started nothing.
  • Terminal codeaf, headless runs and other --home folders don't take this lock. The new app.lock file doesn't stop a fresh home from joining an organization.
  • Wrap-up time, history saves and charge flushes are unchanged.

No wire method or feature changes.

Tests

Red first, through the real command in separate processes: second engine admitted while the first lives: {"event":"hello",....

Green: TestAppOneEngine, 3 of 3 runs, plus internal/identity, internal/manual and internal/appwire.

On macOS, engine only: with the old engine stopped mid-close, the new one had no hello after 5 s and made no provider requests; it said hello 0.1 s after the old one ended, and one engine remained. Relaunch after a crash took 0.05 s.

On macOS, real app: old engine held for 40 s, one engine served afterwards. Crash then relaunch showed jobs at the 2 s check.

Limits

  • The desktop app's own hello limit is 15 s, and it opens its window after the hello or that limit. During a long wait a person sees no window for 15 s, then a window that says it is loading. The app replaces the waiting engine every 15 s, which loses nothing because it holds no work.
  • When the old engine took about 40 s to end, the All jobs page showed "The jobs couldn't be read" and was still showing it at the 60 s check. When it took about 22 s, jobs loaded with no error. That is one run each. It looks like a desktop-side read that isn't repeated, and it is tracked separately.
  • The desktop app gives up restarting after about 105 s of retries, shorter than the old engine's longest wrap-up of 120 s. If an old engine takes longer than that, the person may need to reopen the app. Nothing has spent.
  • Paid calls were not run in the macOS proofs. With one engine, the duplicate shown earlier can't come from a second engine, but two explicit reads at once inside one engine can still each make a paid call. Not changed here.
  • Older engines don't take this lock.
  • What stopped the old clock child in the original report is unknown. The clock is unchanged.

🤖 Generated with Claude Code

@santoshkumarradha
santoshkumarradha marked this pull request as ready for review November 3, 2026 03:13
@santoshkumarradha
santoshkumarradha merged commit ade1233 into app/v3 Nov 3, 2026
@santoshkumarradha
santoshkumarradha deleted the c52/one-engine-lock branch November 3, 2026 03:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant