Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions Docs/ASLM/content/docs/ASLM/Models/AppData.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ draft: false
| --- | --- | --- |
| `firstRunCompleted` | `bool` | Setup wizard finished |
| `user` | `AppUserData` | Display name |
| `ports` | `AppPortConfig` | Official / third-party port ranges |
| `ports` | `AppPortConfig` | Module start port |
| `api` | `AppApiConfig` | Local API mirror server toggle |
| `consoles` | `AppConsoleConfig` | Consoles page preferences |
| `updates` | `AppUpdateSettings` | ASLM and module update policy |
Expand Down Expand Up @@ -59,10 +59,11 @@ Port assignment is handled at runtime by **`PortRegistry`**, not stored here.

| Property | JSON | Default |
| --- | --- | --- |
| `OfficialStart` | `officialStart` | `20000` |
| `OfficialCount` | `officialCount` | `100` |
| `ThirdPartyStart` | `thirdPartyStart` | `21000` |
| `ThirdPartyCount` | `thirdPartyCount` | `1000` |
| `ModulesStart` | `modulesStart` | `20000` |

#### `void Normalize()`

**Purpose:** Migrates legacy official/third-party port settings and clamps the start port.

---

Expand Down
4 changes: 2 additions & 2 deletions Docs/ASLM/content/docs/ASLM/Pages/SettingsView.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ Style resource keys: `FooterButtonStyleKey`, `FooterPrimaryButtonStyleKey`, `Foo
| `SettingsScroll` / `SettingsContentContainer` | Right pane scroll host |
| `AslmSettingsContainer` | Profile + ports (account/ASLM categories) |
| `UserProfileSection` | `UsernameEntry` |
| `PortsSection` | `OfficialPortEntry`, `ThirdPartyPortEntry`, `PortErrorLabel` |
| `PortsSection` | `ModulePortEntry`, `PortErrorLabel` |
| `ModuleSettingsContainer` | Dynamic module / updates / personalization / Ollama content |
| `EmptyCategoryState` / `EmptyCategoryLabel` | No settings placeholder |
| `DefaultButton` | `OnDefaultClicked` |
Expand Down Expand Up @@ -704,7 +704,7 @@ Lightweight switch used instead of native `Switch` for consistent sizing.

---

#### `private string GetCurrentOfficialPortDraft()` / `GetCurrentThirdPartyPortDraft()`
#### `private string GetCurrentPortStartDraft()`

**Purpose:** Reads ports from visible entries or cached drafts.

Expand Down
6 changes: 3 additions & 3 deletions Docs/ASLM/content/docs/ASLM/Pages/SetupWizardPage.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ Three-row grid: **header** | **content** | **footer**.
| `Step1Panel` | Display name |
| `DisplayNameTitleLabel`, `UsernameEntry` | **`SettingsService.TryValidateDisplayName`** |
| `Step2Panel` | Port ranges |
| `PortAllocationTitleLabel`, `OfficialPortsLabel`, `ThirdPartyPortsLabel` | |
| `OfficialPortEntry`, `ThirdPartyPortEntry`, `PortErrorLabel` | **`SettingsService.TryParsePorts`** |
| `PortAllocationTitleLabel`, `ModulePortLabel` | |
| `ModulePortEntry`, `PortErrorLabel` | **`SettingsService.TryParsePortStart`** |
| `Step3Panel` | Module list + install UI |
| `ModuleListScroll` / `ModuleList` | Dynamic checkboxes |
| `InstallPanel` | Progress + log |
Expand Down Expand Up @@ -148,7 +148,7 @@ Three-row grid: **header** | **content** | **footer**.

#### `private bool ValidatePorts()`

**Purpose:** **`SettingsService.TryParsePorts`**; **`ShowPortError`** on failure.
**Purpose:** **`SettingsService.TryParsePortStart`**; **`ShowPortError`** on failure.

---

Expand Down
2 changes: 1 addition & 1 deletion Docs/ASLM/content/docs/ASLM/Services/AslmApiServer.md
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ Converts a mirror-prefixed path back into the backend root-relative path.

#### `private int GetAssignedPort()`

**Purpose:** Gets or reserves the ASLM API port from the shared official module pool.
**Purpose:** Gets or reserves the ASLM API port from the shared module port pool.

---

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ Unknown routes → **404** JSON error. Unhandled exceptions → **500**.

#### `private int GetAssignedPort()`

**Purpose:** **`PortRegistry.GetOrAssignInternalServicePort`** for interop service id/key.
**Purpose:** **`PortRegistry.GetOrAssignInternalServicePort`** and **`EnsurePortsAvailable`** for interop service id/key.

---

Expand Down
2 changes: 1 addition & 1 deletion Docs/ASLM/content/docs/ASLM/Services/ModuleRunner.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Implements **`IDisposable`**. Subscribes to **`PortRegistry.PortsRedistributed`*

#### `public async Task<bool> ExecuteRunAsync(ModuleConfig module, IProgress<string> log, CancellationToken ct)`

**Purpose:** Synchronizes settings, starts each **`Commands.Run`** entry in background with **`trackProcess: true`**.
**Purpose:** Allocates and ensures ports are available, synchronizes settings, and starts each **`Commands.Run`** entry in background with **`trackProcess: true`**.

---

Expand Down
18 changes: 12 additions & 6 deletions Docs/ASLM/content/docs/ASLM/Services/PortRegistry.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,15 @@ Internal owners use id prefix **`__`**.

---

#### `public bool EnsurePortsAvailable(string ownerId)`

**Purpose:** Verifies all assigned ports for an owner are free on the system, reallocating any that are in use and returning whether the map was changed.

---

#### `public int GetOrAssignInternalServicePort(string serviceId, string portKey)`

**Purpose:** Official-pool allocation for internal services (e.g. API mirror, interop).
**Purpose:** Shared-pool allocation for internal services (e.g. API mirror, interop).

---

Expand Down Expand Up @@ -112,25 +118,25 @@ Internal owners use id prefix **`__`**.

#### `private bool IsPortValid(string ownerId, int port)`

**Purpose:** In configured official/third-party range, or legacy **40000–49999** fallback band.
**Purpose:** Checks whether an assigned port is valid for the current start port.

---

#### `private int AllocatePort(string ownerId)`

**Purpose:** Next free port in owner category using global used set.
**Purpose:** Allocates the next available port from the shared module pool.

---

#### `private int AllocatePort(string ownerId, HashSet<int> usedPorts)`

**Purpose:** Explicit used-port set for redistribution.
**Purpose:** Allocates using an explicit used-port set.

---

#### `private static int AllocatePort(string ownerId, HashSet<int> usedPorts, int start, int count)`
#### `private static int AllocatePort(string ownerId, HashSet<int> usedPorts, int start)`

**Purpose:** Linear scan in range, then deterministic **40000+** hash fallback; throws when exhausted.
**Purpose:** Linear scan from start port, then deterministic **40000+** hash fallback; throws when exhausted.

---

Expand Down
14 changes: 7 additions & 7 deletions Docs/ASLM/content/docs/ASLM/Services/SettingsService.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ draft: false

---

#### `public sealed record AslmBaseline(string UserName, string OfficialPort, string ThirdPartyPort, bool ApiServerEnabled)`
#### `public sealed record AslmBaseline(string UserName, string PortStart, bool ApiServerEnabled)`

**Purpose:** Stores the initial ASLM values loaded for the current page session.

Expand All @@ -49,7 +49,7 @@ draft: false

---

#### `public sealed record AslmDraftSnapshot( string UserName, string OfficialPort, string ThirdPartyPort, bool ApiServerEnabled, ConsoleBaseline ConsoleBaseline, UpdateBaseline UpdateBaseline)`
#### `public sealed record AslmDraftSnapshot( string UserName, string PortStart, bool ApiServerEnabled, ConsoleBaseline ConsoleBaseline, UpdateBaseline UpdateBaseline)`

**Purpose:** Snapshot of editable ASLM drafts derived from persisted app data and runtime state.

Expand Down Expand Up @@ -89,7 +89,7 @@ draft: false

---

#### `public static PortParseResult TryParsePorts(string officialDraft, string thirdPartyDraft)`
#### `public static PortParseResult TryParsePortStart(string draft)`

**Purpose:** Validates the port draft values and returns parsed integers when valid.

Expand Down Expand Up @@ -119,7 +119,7 @@ draft: false

---

#### `public static void ApplyDraftsToAppData( AppDataStore appData, string userName, int officialPort, int thirdPartyPort, ConsoleBaseline consoleDraft, AppUpdateSettings updateSettings)`
#### `public static void ApplyDraftsToAppData( AppDataStore appData, string userName, int modulesStart, ConsoleBaseline consoleDraft, AppUpdateSettings updateSettings)`

**Purpose:** Writes ASLM and update drafts to persisted app data.

Expand All @@ -137,7 +137,7 @@ draft: false

---

#### `public static (string OfficialPort, string ThirdPartyPort, bool ApiServerEnabled, ConsoleBaseline ConsoleDefaults) BuildDefaultAslmDrafts()`
#### `public static (string PortStart, bool ApiServerEnabled, ConsoleBaseline ConsoleDefaults) BuildDefaultAslmDrafts()`

**Purpose:** Builds ASLM defaults for ports, API and console sections.

Expand All @@ -149,7 +149,7 @@ draft: false

---

#### `public static bool HasUnsavedPortChanges(string officialPort, string thirdPartyPort, AslmBaseline baseline)`
#### `public static bool HasUnsavedPortChanges(string portStart, AslmBaseline baseline)`

**Purpose:** Checks whether ports draft differs from baseline.

Expand All @@ -173,7 +173,7 @@ draft: false

---

#### `public static bool HasUnsavedAslmSettingsChanges( string officialPort, string thirdPartyPort, bool apiServerEnabled, ConsoleBaseline consoleDraft, UpdateBaseline updateDraft, AslmBaseline aslmBaseline, ConsoleBaseline consoleBaseline, UpdateBaseline updateBaseline)`
#### `public static bool HasUnsavedAslmSettingsChanges( string portStart, bool apiServerEnabled, ConsoleBaseline consoleDraft, UpdateBaseline updateDraft, AslmBaseline aslmBaseline, ConsoleBaseline consoleBaseline, UpdateBaseline updateBaseline)`

**Purpose:** Checks whether non-account ASLM settings differ from baseline.

Expand Down
25 changes: 19 additions & 6 deletions Docs/ASLM/content/docs/ASLM/Tests/Services/PortRegistryTests.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,29 @@ draft: false

---

#### `public void GetOrAssignPorts_allocates_within_official_range()`
#### `public void GetOrAssignPorts_allocates_from_modules_start()`

**Purpose:** Official module `http` port is allocated inside configured official range.
**Purpose:** Module `http` port is allocated starting from the configured modules start port.

| Step | Action |
| --- | --- |
| 1 | Layout + `AppDataStore`; set `OfficialStart = 25000`, `OfficialCount = 50` |
| 2 | `new PortRegistry(appData)`; module `id: "official-module"` |
| 1 | Layout + `AppDataStore`; set `ModulesStart = 25000` |
| 2 | `new PortRegistry(appData)`; module `id: "sample-module"` |
| 3 | `GetOrAssignPorts(module)` |
| 4 | Assert `ports` contains `http` in range `25000`…`25049` |
| 4 | Assert `ports` contains `http` equal to `25000` |

---

#### `public void EnsurePortsAvailable_keeps_free_ports_unchanged()`

**Purpose:** Validates that already-free ports are kept when `EnsurePortsAvailable` is called.

| Step | Action |
| --- | --- |
| 1 | Layout + `AppDataStore`; set `ModulesStart = 30000` |
| 2 | `new PortRegistry(appData)`; module `id: "availability-module"` |
| 3 | `GetOrAssignPorts(module)` |
| 4 | Assert `EnsurePortsAvailable(module.Id)` returns `false` |

---

Expand All @@ -44,7 +57,7 @@ draft: false

| Step | Action |
| --- | --- |
| 1 | Layout + app data; `OfficialStart = 26000`, `OfficialCount = 100` |
| 1 | Layout + app data; `ModulesStart = 26000` |
| 2 | Two calls with `AslmApiServiceId` / `AslmApiPortKey` |
| 3 | Assert second equals first; `TryGetInternalServicePort` matches |

Expand Down
28 changes: 14 additions & 14 deletions Docs/ASLM/content/docs/ASLM/Tests/Services/SettingsServiceTests.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,22 @@ draft: false

## Test methods

#### `public void TryParsePorts_validates_ranges_and_overlap(string official, string thirdParty, bool expectedSuccess)`
#### `public void TryParsePortStart_validates_range(string draft, bool expectedSuccess)`

**Purpose:** Port draft strings must parse, sit in valid ranges, and not overlap official/third-party bands.
**Purpose:** Port start draft string must parse and sit in valid range.

| `official` | `thirdParty` | `expectedSuccess` |
| --- | --- | --- |
| `20000` | `30000` | `true` |
| `abc` | `30000` | `false` |
| `20000` | `99999` | `false` |
| `20050` | `20000` | `false` |
| `draft` | `expectedSuccess` |
| --- | --- |
| `20000` | `true` |
| `abc` | `false` |
| `99999` | `false` |
| `1023` | `false` |

| Step | Action |
| --- | --- |
| 1 | `TryParsePorts(official, thirdParty)` |
| 1 | `TryParsePortStart(draft)` |
| 2 | Assert `Success == expectedSuccess` |
| 3 | On success: parsed ports match integers; on failure: non-empty `ErrorMessage` |
| 3 | On success: parsed port matches integer; on failure: non-empty `ErrorMessage` |

---

Expand Down Expand Up @@ -89,8 +89,8 @@ draft: false

| Step | Action |
| --- | --- |
| 1 | `ApplyDraftsToAppData(store, "Bob", 22000, 32000, console, updates)` |
| 2 | Assert user name, port starts, console flags, `AutoCheckPeriodHours` |
| 1 | `ApplyDraftsToAppData(store, "Bob", 22000, console, updates)` |
| 2 | Assert user name, port start, console flags, `AutoCheckPeriodHours` |

---

Expand All @@ -100,9 +100,9 @@ draft: false

| Step | Action |
| --- | --- |
| 1 | Baseline `AslmBaseline("Alice", "20000", "30000", true)` |
| 1 | Baseline `AslmBaseline("Alice", "20000", true)` |
| 2 | `HasUnsavedAccountChanges("Bob", …)` → `true` |
| 3 | `HasUnsavedPortChanges("20001", "30000", …)` → `true` |
| 3 | `HasUnsavedPortChanges("20001", …)` → `true` |
| 4 | `HasUnsavedApiServerChanges(false, …)` → `true` |

---
Expand Down
Loading