Skip to content
Merged
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
2 changes: 1 addition & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="coverlet.collector" Version="10.1.1" />
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="10.0.11" />
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="11.0.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.12.0" />
<PackageVersion Include="System.Management" Version="11.0.0" />
<PackageVersion Include="WixToolset.UI.wixext" Version="5.0.2" />
Expand Down
49 changes: 43 additions & 6 deletions docs/DEPENDENCY-MAINTENANCE-2026-11.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ and the separately refreshed runtime proposals.
previous-public-updater and compatibility-choice upgrade checks.
- System.Management 11 in PR #10 passed
[the same full pipeline](https://github.com/alphasixtyfive/ResoDrive/actions/runs/46130092758).
Its original lock-file failure is repaired. Keep this optional major runtime
change open for a planned application release; main retains 10.0.11.
Its original lock-file failure was repaired. It was initially kept open as an
optional major runtime change, with main still on 10.0.11.
- Microsoft.Extensions.Hosting 11 in PR #8 passed locked restore and compilation,
then [failed two diagnostic/shutdown cases](https://github.com/alphasixtyfive/ResoDrive/actions/runs/46130089348).
`RealGenericHostBackgroundServiceFailureIsReportedAsFatal` fails with both
Expand All @@ -89,7 +89,44 @@ and the separately refreshed runtime proposals.
two cases passed with version 10. This is a changed host exception contract,
not a remaining NuGet restore error. The production outer fatal catch already
exists; these results alone do not establish lost diagnostics or account data.
Keep the proposal unmerged until that contract and its diagnostics are reviewed.

The original shutdown/diagnostic assertions remain intact. The final acceptance
record is documentation only. No runtime upgrade or new public release was made.
The proposal was initially held pending review of that contract and its diagnostics.

The initial shutdown/diagnostic assertions remained intact. The initial acceptance
record was documentation only; no runtime upgrade or new public release was made
in that maintenance pass.

## Subsequent runtime adoption

The maintainer then authorized merging #10 and completing the Hosting 11
compatibility work in #8, without publishing a release just for the updates.
System.Management #10 was merged after its full compatibility CI passed.

The package's source-linked
[Hosting 11 implementation](https://github.com/dotnet/dotnet/blob/297acf930fb0f5c07fd4e51d78e521b4ad2e5d1f/src/runtime/src/libraries/Microsoft.Extensions.Hosting/src/Internal/Host.cs)
retains worker failures, waits for monitoring/service shutdown, then propagates
the original failure or an aggregate from StopAsync. ResoDrive now uses this
contract directly. Its outer fatal handler still records and rethrows failures;
the old logger-owned exception cache and duplicate post-RunAsync throw were removed.
The logger remains synchronous, bounded and sanitized, and no longer owns host
lifecycle decisions.

The regression cases require exact original-exception propagation after cleanup
with both normal and externally disabled logging, redacted diagnostic content,
multiple observable worker failures, normal cancellation, and successful shutdown
after recoverable operation errors. Logged errors alone cannot stop a healthy
host. The 13 focused cases passed locally. The target framework and SDK remain
.NET 10; adopting the library does not require a .NET 11 installation.

Installer IPC authentication, upload protection, account-data guards and wipe
ordering were not changed. Further full-build, constrained-CPU, process and
hosted installer/update results are retained with this PR's validation evidence.
Published 0.3.53 artifacts remain immutable; these source changes are for a future
planned application release.

The first compatibility CI run passed the new Hosting cases but timed out in
three existing startup fixtures together. The migration fixture synchronously
blocked on an asynchronous child-process pipe read. It now awaits readiness,
leaving workers available to the parallel host/activation fixtures. Its five-second
readiness deadline, process-identity assertions and fail-closed checks are intact.
All 448 App tests passed locally with two available CPUs after this fixture change;
the fresh full hosted pipeline remains the merge gate.
348 changes: 197 additions & 151 deletions src/ResoDrive.App/packages.lock.json

Large diffs are not rendered by default.

7 changes: 3 additions & 4 deletions src/ResoDrive.Host/HostApplication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ public static async Task RunAsync(string[] args, CancellationToken cancellationT
// Default console/event-log providers can retain unsanitized account details.
// Use the same bounded, guarded local policy for every host diagnostic.
builder.Logging.ClearProviders();
var provider = new HostDiagnosticLoggerProvider(diagnostics);
builder.Logging.AddProvider(provider);
builder.Logging.AddProvider(new HostDiagnosticLoggerProvider(diagnostics));
builder.Logging.AddFilter<HostDiagnosticLoggerProvider>(static (_, level) =>
level >= LogLevel.Information && level != LogLevel.None);
builder.Services.Configure<HostOptions>(static options =>
Expand All @@ -36,9 +35,9 @@ public static async Task RunAsync(string[] args, CancellationToken cancellationT
var worker = host.Services.GetServices<IHostedService>().OfType<Worker>().Single();
using var started = host.Services.GetRequiredService<IHostApplicationLifetime>()
.ApplicationStarted.Register(() => diagnostics.Information("host.started"));
// Hosting 11 completes service shutdown, then propagates worker faults.
// The outer fatal handler records and rethrows the original failure.
await host.RunAsync(cancellationToken).ConfigureAwait(false);
if (provider.FatalBackgroundException is { } fatal)
throw new InvalidOperationException("The ResoDrive background host failed unexpectedly.", fatal);
if (!worker.CanResumeRemoteWipe || !worker.RestartForRemoteWipe) break;
// A new lifetime must capture the current wipe generation. Old guards
// deliberately refuse to recreate deleted account diagnostics.
Expand Down
18 changes: 4 additions & 14 deletions src/ResoDrive.Host/HostDiagnosticLoggerProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,10 @@ namespace ResoDrive.Host;
internal sealed class HostDiagnosticLoggerProvider(ProcessDiagnosticLog diagnostics) : ILoggerProvider
{
private readonly ProcessDiagnosticLog _diagnostics = diagnostics;
private Exception? _fatalBackgroundException;
public Exception? FatalBackgroundException => Volatile.Read(ref _fatalBackgroundException);

public ILogger CreateLogger(string categoryName) => new FileLogger(this, categoryName);
public ILogger CreateLogger(string categoryName) => new FileLogger(_diagnostics, categoryName);
public void Dispose() { }

private sealed class FileLogger(HostDiagnosticLoggerProvider provider, string category) : ILogger
private sealed class FileLogger(ProcessDiagnosticLog diagnostics, string category) : ILogger
{
public IDisposable? BeginScope<TState>(TState state) where TState : notnull => null;
public bool IsEnabled(LogLevel logLevel) => logLevel >= LogLevel.Information && logLevel != LogLevel.None;
Expand All @@ -21,13 +18,6 @@ public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Except
Func<TState, Exception?, string> formatter)
{
if (!IsEnabled(logLevel)) return;
// The generic host catches BackgroundService failures, logs them, and stops
// with a successful exit. Preserve the fatal failure for RunAsync to rethrow.
if (category == "Microsoft.Extensions.Hosting.Internal.Host" &&
eventId.Id == 10 && eventId.Name == "BackgroundServiceStoppingHost" &&
logLevel == LogLevel.Critical && exception is not null)
Interlocked.CompareExchange(ref provider._fatalBackgroundException, exception, null);

#pragma warning disable CA1031 // Formatting diagnostic data must not break host execution.
string message;
try { message = formatter(state, exception); }
Expand All @@ -37,9 +27,9 @@ public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Except
if (exception is not null)
{
// Only one sanitized exception formatter and persistence policy for all roles.
provider._diagnostics.Exception("host.exception", exception);
diagnostics.Exception("host.exception", exception);
}
provider._diagnostics.Write(logLevel switch
diagnostics.Write(logLevel switch
{
LogLevel.Critical => "CRITICAL",
LogLevel.Error => "ERROR",
Expand Down
Loading