Skip to content

[ApplicationState] ApplicationState derives Clone over 20+ Arc fields, violating single-source-of-truth; SCM handle counter misdelegated to MarkerState #68

@NikolaRHristov

Description

@NikolaRHristov

Problem

1. Clone derive contradicts design

ApplicationState, ExtensionState::State, and FeatureState::State all #[derive(Clone)]. Cloning ApplicationState propagates through all five domain states, calling Arc::clone on approximately 20–30 shared fields. Each Arc::clone is an atomic fetch_add. The module header explicitly states "Single Source of Truth: All state lives in one place" — but Clone allows an arbitrary number of handles to exist, making ownership opaque.

Files:

  • Source/ApplicationState/State/ApplicationState.rs
  • Source/ApplicationState/State/ExtensionState/State.rs
  • Source/ApplicationState/State/FeatureState/State.rs

2. SCM handle counter in wrong subsystem

FeatureState::State::GetNextSourceControlManagementProviderHandle delegates to self.Markers.GetNextSourceControlManagementProviderHandle(). The SCM provider handle counter lives inside MarkerState, which has no conceptual relationship to Source Control Management providers.

Fix

  1. Remove #[derive(Clone)] from ApplicationState, ExtensionState::State, and FeatureState::State.
  2. Add a type alias: pub type SharedApplicationState = Arc<ApplicationState>.
  3. Update all call sites that currently clone state to hold Arc<ApplicationState> instead.
  4. Move the SCM provider handle counter out of MarkerState into a new Arc<AtomicU32> field directly on FeatureState::State, or into a new SCMState sub-module consistent with the existing Debug, Decorations, Diagnostics pattern.

Additional Scope for Same PR

  • Verify ExtensionState::State.ScanReady: Arc<Notify> uses notify_waiters() vs notify_one() correctly at its call site. If multiple concurrent callers await ScanReady at startup (e.g., multiple extension activation tasks), notify_one() would wake only one and leave the rest blocked indefinitely.

Metadata

Metadata

Labels

bugSomething isn't workingrefactor

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions