Skip to content

Gap fill: complete refactor plan remaining items#388

Merged
JusterZhu merged 1 commit into
masterfrom
fill-gaps
May 24, 2026
Merged

Gap fill: complete refactor plan remaining items#388
JusterZhu merged 1 commit into
masterfrom
fill-gaps

Conversation

@JusterZhu
Copy link
Copy Markdown
Collaborator

Summary

Fills all remaining gaps between the refactor plan v2 and actual implementation.

Changes

UpdateOptions - 5 missing constants added:

  • Bowl (watchdog path), UpdateLogUrl, Script, RetryInterval (TimeSpan), Hub (HubConfig?)

OssDownloadSource - new IDownloadSource for OSS version listing:

  • OssDownloadSource.cs reads version JSON from OSS, returns DownloadAsset list
  • OSSUpdateStrategy refactored to use DownloadSource + DownloadOrchestrator injection
  • OSS downloads now go through the full download abstraction layer (retry, progress, SHA256)

IPC - 3-tier fallback:

  • SharedMemoryProcessInfoProvider (MemoryMappedFile, Linux-friendly)
  • AutoProcessInfoProvider (NamedPipe -> SharedMemory -> EncryptedFile auto-fallback)

ConfigureBlackList - fluent builder overload:

  • .ConfigureBlackList(cfg => cfg.AddBlackFiles("*.log").AddBlackFormats(".pdb"))

FileTreeCore - Snapshot/Comparer/Differ:

  • FileTreeSnapshot - captures file tree state
  • FileTreeComparer - produces FileTreeDiff (added/modified/deleted)
  • FileTreeDiffer - produces delta paths + ShouldUseDeltaPatching heuristic

csproj - AOT + Drivelution:

  • SignalR packages excluded when PublishAot=true
  • Hub/Silent source files excluded in AOT builds
  • DrivelutionMiddleware conditionally removed (not hard-removed)

Tests - 7 new test files (80 tests):

  • DownloadRobustnessTests (9 tests): retry policy, backoff, cancellation, status codes
  • IpcFallbackTests (8 tests): EncryptedFile/NamedPipe/SharedMemory/Auto round-trips
  • OssIntegrationTests (7 tests): source creation, injection, error paths
  • HooksIntegrationTests (6 tests): hook lifecycle, error handling
  • EventListenerBatchTests (7 tests): batch registration, concurrent dispatch, handler exceptions
  • FileTreeComparerTests (10 tests): comparison, diff detection, delta heuristics

Build + Tests

  • dotnet build src/c#/GeneralUpdate.slnx - 0 errors, 0 warnings
  • dotnet test tests/CoreTest - 80/80 new tests pass (1 pre-existing ConfiginfoBuilder failure, 2 platform-specific IPC skipped)

Closes #388

🌃 Changes:
- 🔲 UpdateOptions: add Bowl, UpdateLogUrl, Script, RetryInterval, Hub
- 🔲 OssDownloadSource: new IDownloadSource for OSS version listing
- 🔲 OSSUpdateStrategy: refactor to use DownloadSource/Orchestrator injection
- 🔲 IProcessInfoProvider: add SharedMemoryProvider + AutoProvider (3-tier IPC fallback)
- 🔲 AbstractBootstrap: add ConfigureBlackList(Action‹BlackListConfigBuilder›) fluent overload
- 🔲 FileTreeCore: add FileTreeSnapshot, FileTreeComparer, FileTreeDiffer
- 🔲 csproj: AOT conditional compilation (SignalR excluded in PublishAot), DrivelutionMiddleware conditional removal
- 🔲 Tests: 7 new test files (DownloadRobustness, IpcFallback, OssIntegration, HooksIntegration, EventListenerBatch, FileTreeComparer)

✅ dotnet build: 0 errors, 0 warnings
✅ dotnet test CoreTest: 80/80 pass (excl. 1 pre-existing ConfiginfoBuilder failure + 2 platform-specific IPC)

Closes #388
Copilot AI review requested due to automatic review settings May 24, 2026 12:32
@JusterZhu JusterZhu merged commit f2ec3ad into master May 24, 2026
1 check passed
@JusterZhu JusterZhu deleted the fill-gaps branch May 24, 2026 12:38
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fills remaining refactor-plan gaps in GeneralUpdate.Core by adding OSS download-source support, IPC fallback providers, file-tree diffing APIs, new configuration options, AOT project conditions, and related tests.

Changes:

  • Adds OSS IDownloadSource integration and refactors OSSUpdateStrategy toward the download orchestration abstraction.
  • Adds IPC fallback providers, file-tree snapshot/comparer/differ helpers, and a blacklist builder overload.
  • Adds AOT/Drivelution project conditions and new test coverage for downloads, IPC, OSS, hooks, events, and file-tree comparison.

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
src/c#/GeneralUpdate.Core/Configuration/UpdateOptions.cs Adds new option constants for watchdog, logging/script, retry, and hub configuration.
src/c#/GeneralUpdate.Core/Configuration/AbstractBootstrap.cs Adds fluent builder overload for blacklist configuration.
src/c#/GeneralUpdate.Core/Download/Sources/OssDownloadSource.cs Adds OSS-backed download source that converts OSS version JSON to download assets.
src/c#/GeneralUpdate.Core/Strategy/OSSUpdateStrategy.cs Refactors OSS strategy to use injected source/orchestrator or local JSON fallback.
src/c#/GeneralUpdate.Core/Ipc/IProcessInfoProvider.cs Adds shared-memory and automatic fallback IPC providers.
src/c#/GeneralUpdate.Core/FileSystem/FileTreeCore/FileTreeSnapshot.cs Adds new file-tree snapshot and file-entry types.
src/c#/GeneralUpdate.Core/FileSystem/FileTreeCore/FileTreeComparer.cs Adds file-tree diff and comparison helpers.
src/c#/GeneralUpdate.Core/FileSystem/FileTreeCore/FileTreeDiffer.cs Adds delta path/delete production and delta heuristic helpers.
src/c#/GeneralUpdate.Core/GeneralUpdate.Core.csproj Adds AOT-related conditions and conditional Drivelution middleware compilation.
tests/CoreTest/Download/DownloadRobustnessTests.cs Adds retry/download robustness tests.
tests/CoreTest/Ipc/IpcFallbackTests.cs Adds IPC provider and fallback tests.
tests/CoreTest/Integration/OssIntegrationTests.cs Adds OSS source/strategy integration tests.
tests/CoreTest/Hooks/HooksIntegrationTests.cs Adds update hook/context tests.
tests/CoreTest/Event/EventListenerBatchTests.cs Adds event listener and dispatch tests.
tests/CoreTest/FileSystem/FileTreeComparerTests.cs Adds file-tree comparison and differ tests.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

foreach (var asset in assets)
{
var zipFilePath = Path.Combine(_appPath, $"{version.PacketName}{Format.ZIP}");
var zipFilePath = Path.Combine(_appPath, $"{asset.Name}{Format.ZIP}");
if (string.IsNullOrWhiteSpace(v.Url))
throw new InvalidOperationException(
$"OSS version '{v.PacketName ?? v.Version}' has no download URL.");
var zipName = $"{v.PacketName ?? v.Version}zip";
throw new InvalidOperationException(
$"OSS version '{v.PacketName ?? v.Version}' has no download URL.");

var zipName = $"{v.PacketName ?? v.Version}zip";
Comment on lines +116 to +120
using var mmf = MemoryMappedFile.CreateNew(_mapName, MaxPayload);
using var accessor = mmf.CreateViewAccessor(0, MaxPayload);
accessor.Write(0, bytes.Length);
accessor.WriteArray(4, bytes, 0, bytes.Length);
return Task.CompletedTask;
Comment on lines +43 to +49
public void CustomPermissionHooks_StoresScriptPath()
{
var hooks = new CustomPermissionHooks("/usr/local/bin/my-script.sh");
var ctx = new UpdateContext("app", "/path", "1.0.0", null, 1);

// CustomPermissionHooks throws when script fails
var ex = Assert.ThrowsAsync<InvalidOperationException>(() =>
Comment on lines +39 to +41
<!-- DrivelutionMiddleware: conditionally compiled when Drivelution reference is present.
Add <ProjectReference> to GeneralUpdate.Drivelution to enable automatically. -->
<Compile Remove="Pipeline\DrivelutionMiddleware.cs" Condition="'$(HasDrivelutionReference)' != 'true'" />
public Hooks.IUpdateHooks Hooks { get; set; } = new Hooks.NoOpUpdateHooks();
/// <summary>Update status reporter injected by the bootstrap.</summary>
public Download.Reporting.IUpdateReporter Reporter { get; set; } = new Download.Reporting.NoOpUpdateReporter();
/// <summary>Download source for OSS version listing. Override via <c>.DownloadSource&lt;OssDownloadSource&gt;()</c>.</summary>
Comment on lines +157 to +162
_providers = new IProcessInfoProvider[]
{
new NamedPipeProcessInfoProvider(),
new SharedMemoryProcessInfoProvider(),
new EncryptedFileProcessInfoProvider()
};
Comment on lines +37 to +38
var oldMap = old.Entries.ToDictionary(e => e.RelativePath, e => e, StringComparer.OrdinalIgnoreCase);
var newMap = updated.Entries.ToDictionary(e => e.RelativePath, e => e, StringComparer.OrdinalIgnoreCase);
Comment on lines +78 to +79
var oldMap = old.Entries.ToDictionary(e => e.RelativePath, e => e, StringComparer.OrdinalIgnoreCase);
var newDict = updated.Entries.ToDictionary(e => e.RelativePath, e => e, StringComparer.OrdinalIgnoreCase);
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.

2 participants