Skip to content

env.json writers can silently overwrite concurrent updates #2322

Description

@Danielalnajjar

Attempted workflow

A BB CLI process and an authorized plugin both update different keys in the managed env.json file.

Actual result

Each writer can read a whole document, project its change, and atomically rename that projection later. The rename is atomic but not conditional at the commit boundary, so the last writer can silently erase an unrelated concurrent update.

Evidence:

  • packages/bb-app/src/launcher.ts:1183-1211 performs whole-document merge and temp-file rename with no expected revision or shared writer lock.
  • packages/bb-app/src/launcher.ts:1905-1938 routes both env set and env unset through that read-then-write shape.

Expected result

BB owns one transactional env.json mutation surface used by CLI, server, and authorized plugins. A stale writer receives a conflict and performs no rename or partial mutation.

Acceptance criteria

  • Set and unset share the same transaction path.
  • Successful mutation preserves unrelated top-level fields, unrelated environment keys, and private file mode.
  • Tests coordinate two real concurrent writers and prove only one stale whole-file projection can commit, the loser receives a conflict, and unrelated keys are never silently lost.
  • Plugins can configure non-secret launcher paths without editing env.json through a private file protocol.

AGENT GENERATED: by GPT-5.6 Sol

Metadata

Metadata

Assignees

No one assigned

    Labels

    clibb CLIdesktopDesktop app, install, update, packaging

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions