Skip to content
Open
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
8 changes: 8 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ jobs:
8.0.x
10.0.x
- run: dotnet build Bowl.slnx -c Release
- if: runner.os == 'Windows'
shell: pwsh
run: |
& .\src\Bowl.Host\bin\Release\net8.0\Applications\Windows\procdump64.exe -accepteula -?
if ((Get-ItemProperty 'HKCU:\Software\Sysinternals\ProcDump').EulaAccepted -ne 1) {
throw 'ProcDump license acceptance was not recorded.'
}
$global:LASTEXITCODE = 0
- run: dotnet test Bowl.slnx -c Release --no-build
- if: runner.os == 'Windows'
shell: pwsh
Expand Down
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ This repository contains two independently usable components:
| `src\Bowl.Host` | .NET 8 | Versioned disk protocol, updater/application supervision, optional rollback and persistent HTTP outbox |
| `src\GeneralUpdate.Bowl` | .NET Standard 2.0 | Existing diagnostic library, platform strategies, procdump integration and `BowlContext.OnCrash` callback |

The host has no GeneralUpdate project/source dependency and does not depend on
procdump. It records metadata by default and never collects or uploads dumps.
The library remains available for applications explicitly opting into richer
diagnostics; its tool-success result does **not** establish application health.
The host records metadata by default. An explicit v1 request option enables
best-effort Windows mini-dump capture using GeneralUpdate.Bowl and the bundled
procdump; the host never uploads crash artifacts. The diagnostic tool result
does **not** establish application health.

## Build, test and deploy

Expand Down Expand Up @@ -43,7 +43,9 @@ GeneralUpdate's `Monitoring.Enabled` is opt-in. Set `ExecutablePath` to the host
`DiagnosticsDirectory` to a durable protected state root, and explicitly choose
`AutoRollback` and `VerifyLaunch`. If enabled monitoring cannot become ready,
the updater aborts before file modification. No dump is required to detect an
abnormally terminated updater or failed application startup.
abnormally terminated updater or failed application startup. Crash collection is
a separate opt-in and requires a GeneralUpdate client configured to scan the
state-root crash outbox.

See [the complete protocol and operations guide](docs/protocol-v1.md).

Expand Down
2 changes: 1 addition & 1 deletion docs/migration-manifest.csv
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"src/GeneralUpdate.Bowl/Strategies/IBowlStrategy.cs","f18d0ece481e04867ba731f8711520123b97fc30","1253","ce0708f309c9056d29fe6161d53ef46a7e9f7fb5cbd81feb09b5a85a1041a510","ce0708f309c9056d29fe6161d53ef46a7e9f7fb5cbd81feb09b5a85a1041a510"
"src/GeneralUpdate.Bowl/Strategies/LinuxBowlStrategy.cs","c72a75bd24f7717159c574670b9e0def1aa9e7b2","9944","02dfe4fe9598c8872251da6f9fec3a3a0135d939f699e5e17e5ae70ca12a7fa7","02dfe4fe9598c8872251da6f9fec3a3a0135d939f699e5e17e5ae70ca12a7fa7"
"src/GeneralUpdate.Bowl/Strategies/ProcessExitResult.cs","26615802a835e19a96d2b6b9a5a38a0454020612","436","236bfb4043711d3ee223f39fa229e3465eec1156056694c5d3ceb3b33a50c1d4","236bfb4043711d3ee223f39fa229e3465eec1156056694c5d3ceb3b33a50c1d4"
"src/GeneralUpdate.Bowl/Strategies/ProcessRunner.cs","e988378c3a01ffa7df899c7364a2be49c254a0d1","3874","7f8588283b884bcd760b677fe2d3dd19aceb3b181a32e3a1d5080cb0e36cbe7a","7f8588283b884bcd760b677fe2d3dd19aceb3b181a32e3a1d5080cb0e36cbe7a"
"src/GeneralUpdate.Bowl/Strategies/ProcessRunner.cs","e988378c3a01ffa7df899c7364a2be49c254a0d1","3874","7f8588283b884bcd760b677fe2d3dd19aceb3b181a32e3a1d5080cb0e36cbe7a","2f3e04c3dca0dd0a286871b00c7d123d44598fe5cbf09357eb70c2b9e22f3aae"
"src/GeneralUpdate.Bowl/Strategies/StrategyFactory.cs","a38ef0f67de6739740c57e235959cc0958ccb4ce","917","2dc189b4059b6c0de62379bc4e5fc01c3ea9383ce5b1989e445b73aded7ecc6a","0eba66e306d30bad882399f2b08399b2a00e24c57cb2b9b4ddb081e12ba6bff6"
"src/GeneralUpdate.Bowl/Strategies/WindowsBowlStrategy.cs","52c321de7be274bf27bb77d11939ee8c1e70e0e0","2395","67c5296557666ca63cf7f8f3ac846fda5bedc03532051a0dc1e543b35d781c15","0c8fd298c17db75472c1628b08d75470a490d0c55f2dc140de6c0128fe447d31"
"src/GeneralUpdate.Bowl/Tracer/GeneralTracer.cs","11084795534480d2426faedf7e486b70c8053c0e","4963","411e4bd5db32487102b418d690ed04c395531d2d18e56066f530b59b95cad25e","9ff850c6c2ca5a704765d016d8becc8e92f66b6f7128a51e1b882e10b14cd64b"
Expand Down
10 changes: 6 additions & 4 deletions docs/migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Intentional edits to imported files:
| `src\GeneralUpdate.Bowl\BowlContext.cs` | `Normalize()` default work model is now `"Normal"` — recovery semantics (`Upgrade` + `AutoRestore`) are an explicit opt-in; the restore decision belongs to the update pipeline (Core RollbackManager) |
| `src\GeneralUpdate.Bowl\Strategies\StrategyFactory.cs` | Added `CreateWithFallback(out WatcherTier)` three-tier watcher probing (procdump → runtime createdump → exit-code fallback) for the console supervisor; `Create()` and the embedded single-shot API are unchanged |
| `src\GeneralUpdate.Bowl\Strategies\WindowsBowlStrategy.cs` | Resolve procdump from the watchdog directory before the target installation |
| `src\GeneralUpdate.Bowl\Strategies\ProcessRunner.cs` | Drain asynchronous output handlers before returning the process output |
| `src\GeneralUpdate.Bowl\Applications\Windows\export.bat` | Accept the evidence directory via a per-process environment variable or manual argument |
| `src\GeneralUpdate.Bowl\Internal\WindowsSystemInfoProvider.cs` | Launch export with a child-specific working directory and environment |
| `src\GeneralUpdate.Bowl\Tracer\GeneralTracer.cs` | Fall back to console logging when file initialization or rotation fails |
Expand All @@ -47,7 +48,7 @@ Intentional edits to imported files:

New files added alongside the import (not part of the 61 migrated entries):
`src\GeneralUpdate.Bowl\InternalsVisibleTo.cs` (friend assemblies `bowl` and
`Bowl.Console.Tests`), `src\GeneralUpdate.Bowl\Strategies\WatcherTier.cs`,
`Bowl.Console.Tests` and `Bowl.Host`), `src\GeneralUpdate.Bowl\Strategies\WatcherTier.cs`,
`src\GeneralUpdate.Bowl\Strategies\ExitCodeWatcherStrategy.cs`,
`src\GeneralUpdate.Bowl\Strategies\CreatedumpStrategy.cs`, and the console
project `src\GeneralUpdate.Bowl.Console` with its test project
Expand All @@ -67,9 +68,10 @@ references. The original .NET Standard library, callbacks, strategies and tests
remain compatible. `Bowl.slnx`, independent test dependency versions, host tests,
CI and root documentation provide standalone build/test/publish entry points.

The host's default metadata-only diagnostics intentionally do not run bundled
procdump or export system information. Optional legacy diagnostics remain an
explicit caller choice; no-dump results do not establish health.
The host's default metadata-only diagnostics do not run bundled procdump or
export system information. The separate opt-in Windows capture now uses the
library and bundled procdump as described in `protocol-v1.md`; no-dump results
do not establish health.

## Validation and removal gate

Expand Down
57 changes: 52 additions & 5 deletions docs/protocol-v1.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Each attempt uses `<state-root>\attempts\<GUID>\`:
| `result.json` | Bowl | Durable decision and recovery journal |
| `outbox.json` | Bowl | One stable terminal event and delivery state |
| `host.lock` | Bowl | Exclusive attempt owner, held open |
| `capture-status.json` | Bowl | Optional local capture status, not an update verdict |

`locks\<SHA256-of-canonical-install-path>.lock` coordinates attempts for the same
installation. Its `.owner.json` sidecar records the latest owning attempt
Expand Down Expand Up @@ -66,6 +67,7 @@ and staging locations). Never include it in packages or restoration scopes.
"healthTimeoutSeconds": 5,
"updateTimeoutSeconds": 600,
"autoRollback": false,
"crashCollectionEnabled": false,
"report": {
"url": "https://updates.example.test/report",
"recordId": 42,
Expand Down Expand Up @@ -105,6 +107,12 @@ Stages: `preparing`, `filesApplying`, `filesApplied`, `launching`,
- Invalid/missing protocol data or inaccessible observation is
`monitorUnavailable`, not an application failure.

`crashCollectionEnabled` defaults to false. When true, `targetVersion` must be a
nonempty safe single directory name (at most 128 characters; no separators,
control characters, Windows reserved characters or device names, or trailing
space/dot). Invalid configuration is rejected before readiness. Collection and
upload must be separately authorized; enabling supervision alone does neither.

`processAlive` means process survival, **not business health**. No `health.json`
signal is part of v1. No dump is ever used as success evidence.

Expand All @@ -122,7 +130,7 @@ signal is part of v1. No dump is ever used as success evidence.
| `currentVersion`, `targetVersion` | Copied immutable request versions |
| `observedAtUtc` | Decision timestamp |
| `error` | Original structured producer failure, or monitoring exception type |
| `diagnostics` | `metadataOnly`; no implicit dump/system-information capture |
| `diagnostics` | `metadataOnly`; describes this result record, not the separate opt-in crash outbox |
| `rollback` | `notRequested`, `pending`, `inProgress`, `deferred`, `succeeded`, `failed` |
| `rollbackError` | Bounded error classification, never credentials or response body |

Expand Down Expand Up @@ -180,7 +188,7 @@ Only after recovery settles does Bowl create `outbox.json`:
`monitorUnavailable` are local-only, never fake network acknowledgements.
The HTTP JSON shape is exactly `recordId`, `status`, `type`; status remains
2 Success / 3 Failure, type remains 1 poll / 2 push. Structured diagnostics and
dumps are never uploaded. `Idempotency-Key` carries the stable event ID; a
dumps are never uploaded by this HTTP outbox. `Idempotency-Key` carries the stable event ID; a
legacy server can ignore it, so delivery is **at least once**, not exactly once.

Each invocation sends at most once per eligible attempt. Before sending, persist
Expand Down Expand Up @@ -216,9 +224,48 @@ fragment. Never put secrets on the command line, in a URL or in the request.
Provision host credentials separately; Update's in-process HTTP callbacks
cannot cross the process boundary.

Protect local paths, stack traces and binaries with ACLs. The existing diagnostic
library and bundled procdump tools are a separate explicit opt-in, not a host
startup dependency. No full dump upload option is enabled by this protocol.
## Optional crash evidence

Only when `crashCollectionEnabled` is true, the Windows host asks the bundled
GeneralUpdate.Bowl procdump strategy to attach to the exact updater identity and,
once available, the exact application identity. It checks PID and start time
and holds a process handle, never searches by name. Capture is best-effort:
attach can miss a fast exit, require permissions or a previously accepted tool
license, or fail because the tool is unavailable. The host monitors only the
v1 update and startup-survival window, not the application's later lifetime.
Other platforms explicitly report capture unavailable. A missing dump is not
proof of health, a crash or a failed update. No system-info export, automatic
restore or crash hook is run by the diagnostic library.

A successful, nonempty **mini dump** and GeneralUpdate.Bowl crash report are
flushed into a staging directory beneath
`<state-root>\crash-outbox\<targetVersion>`; a schema 2 manifest is written
last, then the whole directory is atomically renamed to a new canonical GUID.
The manifest has `schema`, `guid`, `kind:"crash"`, `targetName`, `version`,
`exitCode:null`, `createdAtUtc`, `files:["crash.json","crash.dmp"]`,
`state:"pending"` and `attempts:0`. No case is published without both complete
files. Core Client owns uploading, retries and acknowledged-case deletion;
the host neither uploads nor mutates a published case. The state root is outside
the installation and backup trees, so rollback cannot erase pending cases.

The attempt's `capture-status.json` records per-target `capturing`, `published`,
`noDump`, `unavailable` or `interrupted`. `noDump` does not distinguish a normal
exit from tool failure. Capture errors are also logged to stderr and
never change the v1 outcome or rollback. The host waits at most three seconds
for evidence after a failed observation, then sends a console interrupt to each
owned ProcDump so it can detach without terminating the monitored process; an owned
Windows job closes them if the host exits. An abrupt host exit or failed graceful
detach can therefore terminate a process that ProcDump is debugging. A crash or failure before publication
can leave a non-GUID `.partial` directory: it is not scanned or automatically
retried or deleted. Operators must inspect it and securely remove or archive it;
restarting an already completed attempt cannot recreate an unattached dump.
Published cases remain pending until Client succeeds; configure and monitor
Client's retry schedule and disk capacity. No host GC evicts pending evidence.

Mini dumps and crash reports can contain sensitive memory, paths and process
details. Protect the entire state root with restrictive ACLs, provision enough
disk space, and disclose both collection and Client upload to the operator.
These guarantees assume trusted local writers and atomic rename on local storage.

For `--attempt`, exit 0 means supervised application/file success; exit 1 means
a recorded non-success; exit 2 means invocation/ownership/storage failure or
Expand Down
1 change: 1 addition & 0 deletions scripts/Verify-Migration.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ try {
'src/GeneralUpdate.Bowl/Applications/Windows/export.bat',
'src/GeneralUpdate.Bowl/Internal/WindowsSystemInfoProvider.cs',
'src/GeneralUpdate.Bowl/Strategies/WindowsBowlStrategy.cs',
'src/GeneralUpdate.Bowl/Strategies/ProcessRunner.cs',
'src/GeneralUpdate.Bowl/Strategies/StrategyFactory.cs',
'src/GeneralUpdate.Bowl/Tracer/GeneralTracer.cs',
'src/GeneralUpdate.Bowl/Tracer/TextTraceListener.cs',
Expand Down
1 change: 1 addition & 0 deletions src/Bowl.Host/Bowl.Host.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<RepositoryUrl>https://github.com/GeneralLibrary/Bowl</RepositoryUrl>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\GeneralUpdate.Bowl\GeneralUpdate.Bowl.csproj" />
<InternalsVisibleTo Include="Bowl.Host.Tests" />
<None Include="..\..\LICENSE" Link="LICENSE" CopyToPublishDirectory="PreserveNewest" />
<None Include="..\..\THIRD-PARTY-NOTICES.md" Link="THIRD-PARTY-NOTICES.md" CopyToPublishDirectory="PreserveNewest" />
Expand Down
31 changes: 31 additions & 0 deletions src/Bowl.Host/CaptureConsole.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using System.ComponentModel;
using System.Runtime.InteropServices;

namespace Bowl.Host;

internal static class CaptureConsole
{
public static void Stop(int pid)
{
if (!FreeConsole() || !AttachConsole((uint)pid))
throw new Win32Exception(Marshal.GetLastWin32Error());
if (!SetConsoleCtrlHandler(IntPtr.Zero, true) || !GenerateConsoleCtrlEvent(0, 0))
throw new Win32Exception(Marshal.GetLastWin32Error());
}

[DllImport("kernel32.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool FreeConsole();

[DllImport("kernel32.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool AttachConsole(uint processId);

[DllImport("kernel32.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool SetConsoleCtrlHandler(IntPtr handler, bool add);

[DllImport("kernel32.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool GenerateConsoleCtrlEvent(uint controlEvent, uint processGroupId);
}
80 changes: 80 additions & 0 deletions src/Bowl.Host/CaptureJob.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
using System.ComponentModel;
using System.Diagnostics;
using System.Runtime.InteropServices;
using Microsoft.Win32.SafeHandles;

namespace Bowl.Host;

internal sealed class CaptureJob(SafeFileHandle handle) : IDisposable
{
public static CaptureJob Create()
{
var handle = CreateJobObject(IntPtr.Zero, null);
if (handle.IsInvalid)
{
var error = Marshal.GetLastWin32Error();
handle.Dispose();
throw new Win32Exception(error);
}
var limits = new ExtendedLimitInformation
{
BasicLimitInformation = new BasicLimitInformation { LimitFlags = 0x2000 }
};
if (!SetInformationJobObject(handle, 9, ref limits, (uint)Marshal.SizeOf<ExtendedLimitInformation>()))
{
var error = Marshal.GetLastWin32Error();
handle.Dispose();
throw new Win32Exception(error);
}
return new CaptureJob(handle);
}

public void Assign(Process process)
{
if (!AssignProcessToJobObject(handle, process.Handle))
throw new Win32Exception(Marshal.GetLastWin32Error());
}

public void Dispose() => handle.Dispose();

[StructLayout(LayoutKind.Sequential)]
private struct BasicLimitInformation
{
public long PerProcessUserTimeLimit;
public long PerJobUserTimeLimit;
public uint LimitFlags;
public UIntPtr MinimumWorkingSetSize;
public UIntPtr MaximumWorkingSetSize;
public uint ActiveProcessLimit;
public UIntPtr Affinity;
public uint PriorityClass;
public uint SchedulingClass;
}

[StructLayout(LayoutKind.Sequential)]
private struct IoCounters
{
public ulong ReadOperationCount, WriteOperationCount, OtherOperationCount;
public ulong ReadTransferCount, WriteTransferCount, OtherTransferCount;
}

[StructLayout(LayoutKind.Sequential)]
private struct ExtendedLimitInformation
{
public BasicLimitInformation BasicLimitInformation;
public IoCounters IoInfo;
public UIntPtr ProcessMemoryLimit, JobMemoryLimit, PeakProcessMemoryUsed, PeakJobMemoryUsed;
}

[DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
private static extern SafeFileHandle CreateJobObject(IntPtr attributes, string? name);

[DllImport("kernel32.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool SetInformationJobObject(SafeFileHandle job, int informationClass,
ref ExtendedLimitInformation information, uint length);

[DllImport("kernel32.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool AssignProcessToJobObject(SafeFileHandle job, IntPtr process);
}
Loading
Loading