Skip to content

refactor: arbitrate the single instance before the bootstrap - #984

Merged
albertospelta merged 2 commits into
mainfrom
refactor/single-instance-arbitration
Oct 20, 2026
Merged

albertospelta merged 2 commits into
mainfrom
refactor/single-instance-arbitration

Conversation

@albertospelta

Copy link
Copy Markdown
Member

A secondary Bravo process now forwards its startup arguments to the primary
and exits before any directory setup, bootstrap service (logger factory,
policies, settings, telemetry) or host exists.

  • BravoSingleInstance.ClaimOrRedirect runs right after the exception
    handler: it claims the pipe or redirects the activation.
  • Program.Main owns the SingleInstanceServer and releases it last, after
    the bootstrap services; the host receives it as an existing instance.
  • BravoApplicationInstance only raises activation events and is registered
    as IInstanceEvents; IBravoApplicationInstance is removed.
  • The activation payload no longer reads usersettings.json.
  • A redirect failure is logged to the Event Log only. It is no longer tracked
    in telemetry: consent needs the bootstrap, which a secondary never builds.
    The user-facing message comes in a later change.
  • Known cost: a relaunch while the primary shuts down is redirected to it and
    lost, because the pipe is held until the bootstrap services are disposed.

Docs: architecture.md (ownership, single-instance contract), diagnostics.md
(startup coverage), ADR 0004 (consequences).

AppInstanceStartupMessage.CreateFrom wrote a verbose diagnostic, which
read UserPreferences.Current and therefore usersettings.json. A secondary
instance built its payload through it and lost the diagnostic on exit.
The diagnostic moves to AppWindow, the only caller in the primary.
A secondary process now forwards its startup arguments and exits before
any directory setup, bootstrap service or host exists.

- BravoSingleInstance.ClaimOrRedirect claims the pipe or redirects, right
  after the exception handler is installed.
- Program.Main owns the SingleInstanceServer and releases it last; the
  host receives it as an existing instance.
- BravoApplicationInstance only raises activation events and is
  registered as IInstanceEvents; IBravoApplicationInstance is removed.
- A redirect failure is logged to the Event Log only, through a logger
  factory with the Event Log provider alone; no telemetry, since consent
  needs the bootstrap. AddBravoEventLog keeps the Event Log setup shared
  with the bootstrap logger factory.
- InstancePipeName reads the session from the process, not AppEnvironment.
@albertospelta
albertospelta merged commit d054f23 into main Oct 20, 2026
1 check passed
@albertospelta
albertospelta deleted the refactor/single-instance-arbitration branch October 20, 2026 13:38
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