feat(app): Velopack, the updater with FR-12 as its shape, release.yml, and one VERSION source (P4 PR-5) (#174)
* feat(app): Velopack, the updater with FR-12 as its shape, release.yml, and one VERSION source (P4 PR-5)
The updater of 11_UPDATER behind an IUpdateClient port (VelopackUpdateClient over Velopack 1.2.0's
GitHub source; stable = releases GitHub does not mark pre-release, beta adds them): the startup silent
check 5 s after start for an installed copy with update.auto_check on, Help > Check for updates with
the dialogs and the six error rows, the background download (a checksum failure retried once), and the
apply -- refused while any session runs, Deferred until the last SessionCompleted, then Shutdown to the
Agent, the connection's relaunch held, the pipe watched until it drops, WaitExitThenApplyUpdates, the
host ended. Program.Main runs VelopackApp first; the uninstall hook stops the Agent, unregisters the
layer, removes the logon task and asks about the data folder.
The package id is FrameLedger.App, not FrameLedger: Velopack installs into and deletes
%LOCALAPPDATA%\<packId>, which with the documented id is the data folder holding ledger.db.
VERSION at the root feeds Directory.Build.props and the native CMake project; versioninfo-check
compares every binary against it. release.yml gates the tag against VERSION and CHANGELOG
(tools/release-notes.ps1), substitutes {{RELEASE_DATE}}, runs the identical gate, publishes, asserts
the published tree, packs, checksums and releases.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* fix(app): the private constant's name, Velopack's copyright as its package states it, and the measured pack
- UpdateService: _idleState (IDE1006, the repository's private-field rule; dotnet format caught it).
- legal/licenses/velopack-MIT.txt and THIRD_PARTY_NOTICES: the copyright line is the package's own
<copyright> field ("Velopack Ltd."), not a name written from memory.
- 12_BUILD / 13_CI_CD / CHANGELOG: vpk pack 1.2.0 run by hand over the published tree -- Setup 104 MB,
VelopackApp.Run() verified in Program.Main.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
603795f49d
commit
1776a22907
64 files changed
+2930
-62
No files matched your search
@@ -0,0 +1,203 @@
|
||||
# FrameLedger release (docs/13_CI_CD.md §release.yml, docs/12_BUILD.md §Publish & package).
|
||||
#
|
||||
# On a tag `v*`: the same gate ci.yml runs, then publish → pack → checksums →
|
||||
# a GitHub Release whose body is CHANGELOG.md's section for the version. Three
|
||||
# things are refused loudly rather than papered over, because a release is the
|
||||
# one artefact nobody can re-run:
|
||||
# - the tag's numeric core must equal the VERSION file (the one version source;
|
||||
# the native VERSIONINFO blocks are built from it and versioninfo-check
|
||||
# compares them);
|
||||
# - CHANGELOG.md must carry a non-empty `## [x.y.z]` section for the tag
|
||||
# (tools/release-notes.ps1) — an empty release body is a defect, not a default;
|
||||
# - the published tree must hold both entry points and every shipped native
|
||||
# binary, checked by name, because `dotnet publish` warns rather than fails
|
||||
# when a .targets-staged DLL is missing.
|
||||
#
|
||||
# Unsigned by policy (11_UPDATER §Unsigned releases): SHA256SUMS.txt is published
|
||||
# beside the assets and printed into the release body.
|
||||
#
|
||||
# A pre-release tag (`v0.1.0-beta.1`, 13_CI_CD §Branch & release policy) marks the
|
||||
# GitHub release as pre-release; the App's stable channel ignores it and the beta
|
||||
# channel sees it. The managed assemblies take the tag's full version through
|
||||
# -p:Version; the native blocks keep the numeric core (CMake's project() accepts
|
||||
# nothing else).
|
||||
|
||||
name: Release
|
||||
|
||||
on:
|
||||
push:
|
||||
tags: ['v*']
|
||||
|
||||
# The Release API is contents: write; nothing else is needed and nothing else is granted.
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
concurrency:
|
||||
group: release-${{ github.ref }}
|
||||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
release:
|
||||
runs-on: windows-latest
|
||||
timeout-minutes: 60
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
|
||||
- name: Set up .NET
|
||||
uses: actions/setup-dotnet@v6
|
||||
with:
|
||||
global-json-file: global.json
|
||||
|
||||
- name: Set up MSVC (x64)
|
||||
uses: ilammy/msvc-dev-cmd@v1
|
||||
with:
|
||||
arch: x64
|
||||
|
||||
# Same pin as ci.yml, for the same reason (the gate's clang-format step).
|
||||
- name: Pin clang-format
|
||||
shell: pwsh
|
||||
run: |
|
||||
pip install --disable-pip-version-check "clang-format==22.1.3"
|
||||
clang-format --version
|
||||
|
||||
- name: Cache NuGet
|
||||
uses: actions/cache@v6
|
||||
with:
|
||||
path: ~/.nuget/packages
|
||||
key: nuget-${{ runner.os }}-${{ hashFiles('**/Directory.Packages.props', 'global.json') }}
|
||||
restore-keys: nuget-${{ runner.os }}-
|
||||
|
||||
- name: Version gate (tag vs VERSION, CHANGELOG section)
|
||||
id: version
|
||||
shell: pwsh
|
||||
run: |
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$tag = $env:GITHUB_REF_NAME
|
||||
$m = [regex]::Match($tag, '^v(\d+\.\d+\.\d+)(-[0-9A-Za-z.]+)?$')
|
||||
if (-not $m.Success) { throw "tag '$tag' is not vMAJOR.MINOR.PATCH[-prerelease]" }
|
||||
$full = $tag.Substring(1)
|
||||
$core = $m.Groups[1].Value
|
||||
$pre = if ($m.Groups[2].Success) { 'true' } else { 'false' }
|
||||
$file = (Get-Content VERSION -Raw).Trim()
|
||||
if ($core -ne $file) { throw "tag $tag has numeric core $core but VERSION says $file — bump VERSION in the same commit as the changelog section, then tag" }
|
||||
New-Item -ItemType Directory -Force out | Out-Null
|
||||
./tools/release-notes.ps1 -Version $full -OutFile out/notes.md
|
||||
if ($LASTEXITCODE -ne 0) { throw 'release notes' }
|
||||
"version=$full" >> $env:GITHUB_OUTPUT
|
||||
"prerelease=$pre" >> $env:GITHUB_OUTPUT
|
||||
Write-Host "releasing $full (pre-release: $pre)"
|
||||
|
||||
# 12_BUILD §Release-time token substitution: the effective date of a legal
|
||||
# document is the date it ships. The only placeholder that survives into the
|
||||
# repository, substituted here and nowhere else; the App embeds legal/*.md at
|
||||
# build time, so this runs BEFORE the build.
|
||||
- name: Substitute {{RELEASE_DATE}}
|
||||
shell: pwsh
|
||||
run: |
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$date = (Get-Date).ToUniversalTime().ToString('yyyy-MM-dd')
|
||||
$n = 0
|
||||
foreach ($f in Get-ChildItem legal -Filter *.md) {
|
||||
$t = Get-Content $f.FullName -Raw
|
||||
if ($t.Contains('{{RELEASE_DATE}}')) {
|
||||
[System.IO.File]::WriteAllText($f.FullName, $t.Replace('{{RELEASE_DATE}}', $date), [System.Text.UTF8Encoding]::new($false))
|
||||
$n++
|
||||
}
|
||||
}
|
||||
Write-Host "RELEASE_DATE = $date in $n file(s)"
|
||||
if (Select-String -Path legal/*.md, README.md -Pattern '\{\{' -Quiet) { throw 'a {{ token survived substitution' }
|
||||
|
||||
# The identical gate ci.yml runs — native build, tests, every check including
|
||||
# versioninfo-check against VERSION. A release never skips it.
|
||||
- name: Quality gate
|
||||
shell: pwsh
|
||||
run: ./build.ps1 check
|
||||
env:
|
||||
CI: 'true'
|
||||
|
||||
- name: Publish App + Agent (self-contained, ReadyToRun)
|
||||
shell: pwsh
|
||||
run: |
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$v = '${{ steps.version.outputs.version }}'
|
||||
dotnet publish src/FrameLedger.App -c Release -r win-x64 --self-contained -p:PublishReadyToRun=true -p:Version=$v -o out/app
|
||||
if ($LASTEXITCODE -ne 0) { throw 'App publish failed' }
|
||||
dotnet publish src/FrameLedger.Agent -c Release -r win-x64 --self-contained -p:PublishReadyToRun=true -p:Version=$v -o out/app
|
||||
if ($LASTEXITCODE -ne 0) { throw 'Agent publish failed' }
|
||||
|
||||
# What ships is what matters: the two entry points and the four shipped native
|
||||
# binaries (versioninfo-check's list) must be in the tree, and the unshipped
|
||||
# capture host must not be (package-closure-check proves it statically; this
|
||||
# reads the directory).
|
||||
- name: Assert the published tree
|
||||
shell: pwsh
|
||||
run: |
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$required = 'FrameLedger.exe', 'FrameLedger.Agent.exe', 'FrameLedger.Overlay.dll', 'FrameLedger.VkLayer.dll', 'FrameLedger.Guard.dll', 'FrameLedger.NvapiBridge.dll', 'rules/detection-rules.json'
|
||||
$missing = @($required | Where-Object { -not (Test-Path (Join-Path out/app $_)) })
|
||||
if ($missing.Count -gt 0) { throw "out/app is missing: $($missing -join ', ')" }
|
||||
if (Test-Path out/app/FrameLedger.CaptureHost.exe) { throw 'out/app contains the unshipped capture host (12_BUILD: exactly two roots)' }
|
||||
./tools/versioninfo-check.ps1 -BuildDir out/app
|
||||
if ($LASTEXITCODE -ne 0) { throw 'versioninfo-check over the published tree' }
|
||||
$size = (Get-ChildItem out/app -Recurse -File | Measure-Object Length -Sum).Sum / 1MB
|
||||
Write-Host ("published tree: {0:N0} MB" -f $size)
|
||||
|
||||
# Velopack's packer, pinned to the library version the App references
|
||||
# (Directory.Packages.props). No --icon: assets/icon.ico does not exist yet
|
||||
# (12_BUILD §Publish & package says so rather than pointing at a file that is not there).
|
||||
#
|
||||
# --packId is FrameLedger.App, NOT FrameLedger, and that is a data-loss rule:
|
||||
# Velopack installs into %LOCALAPPDATA%\<packId> and deletes that directory on
|
||||
# uninstall, and %LOCALAPPDATA%\FrameLedger is the DATA folder (LedgerPaths:
|
||||
# ledger.db, logs, the layer manifest). The same id would put the install inside
|
||||
# the ledger's folder and have the uninstaller remove every session without the
|
||||
# question 12_BUILD promises. The title the user sees is still "FrameLedger".
|
||||
- name: Pack (Velopack)
|
||||
shell: pwsh
|
||||
run: |
|
||||
$ErrorActionPreference = 'Stop'
|
||||
dotnet tool install -g vpk --version 1.2.0
|
||||
if ($LASTEXITCODE -ne 0) { throw 'vpk install failed' }
|
||||
$v = '${{ steps.version.outputs.version }}'
|
||||
vpk pack --packId FrameLedger.App --packVersion $v --packDir out/app --mainExe FrameLedger.exe --packTitle FrameLedger --packAuthors FrameLedger --releaseNotes out/notes.md --outputDir out/release
|
||||
if ($LASTEXITCODE -ne 0) { throw 'vpk pack failed' }
|
||||
Get-ChildItem out/release | ForEach-Object { Write-Host (" {0,-48} {1,12:N0}" -f $_.Name, $_.Length) }
|
||||
if (-not (Test-Path out/release/FrameLedger.App-win-Setup.exe)) { throw 'vpk did not produce FrameLedger.App-win-Setup.exe (README §Install names it)' }
|
||||
|
||||
- name: Checksums
|
||||
shell: pwsh
|
||||
run: |
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$lines = Get-ChildItem out/release -File | Sort-Object Name | ForEach-Object {
|
||||
'{0} {1}' -f (Get-FileHash $_.FullName -Algorithm SHA256).Hash.ToLowerInvariant(), $_.Name
|
||||
}
|
||||
[System.IO.File]::WriteAllLines('out/release/SHA256SUMS.txt', $lines, [System.Text.UTF8Encoding]::new($false))
|
||||
$notes = Get-Content out/notes.md -Raw
|
||||
$notes += "`n`n## SHA-256`n`nReleases are not code-signed (11_UPDATER). Verify before running:`n`n``````text`n" + ($lines -join "`n") + "`n``````"
|
||||
[System.IO.File]::WriteAllText('out/notes.md', $notes, [System.Text.UTF8Encoding]::new($false))
|
||||
Get-Content out/release/SHA256SUMS.txt
|
||||
|
||||
- name: Create the GitHub Release
|
||||
shell: pwsh
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
run: |
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$v = '${{ steps.version.outputs.version }}'
|
||||
$ghArgs = @('release', 'create', $env:GITHUB_REF_NAME, '--title', "FrameLedger $v", '--notes-file', 'out/notes.md', '--verify-tag')
|
||||
if ('${{ steps.version.outputs.prerelease }}' -eq 'true') { $ghArgs += '--prerelease' }
|
||||
$ghArgs += Get-ChildItem out/release -File | ForEach-Object { $_.FullName }
|
||||
gh @ghArgs
|
||||
if ($LASTEXITCODE -ne 0) { throw 'gh release create failed' }
|
||||
|
||||
- name: Upload the published tree (for the smoke checklist)
|
||||
if: always()
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: release-${{ github.ref_name }}
|
||||
path: |
|
||||
out/release/**
|
||||
out/notes.md
|
||||
if-no-files-found: warn
|
||||
retention-days: 30
|
||||
+47
-7
@@ -6,19 +6,59 @@ Format: [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
||||
Versioning: [Semantic Versioning](https://semver.org/spec/v2.0.0.html) — `MAJOR`
|
||||
bumps for a database schema or IPC protocol break (`docs/11_UPDATER.md`).
|
||||
|
||||
`release.yml` **will** read the section for the tag being released and use it as the
|
||||
GitHub release body, so a missing section will mean an empty release note.
|
||||
`release.yml` reads the section for the tag being released (`tools/release-notes.ps1`) and
|
||||
uses it as the GitHub release body. A missing or empty `## [x.y.z]` section is a **red
|
||||
release**, not an empty note — so cutting a release means moving the `[Unreleased]` entries
|
||||
under a `## [x.y.z] - date` heading in the same commit that bumps `VERSION`, then tagging
|
||||
(`docs/13_CI_CD.md` §Branch & release policy).
|
||||
|
||||
> **It does not exist yet** — `.github/workflows/` holds `ci.yml`, `codeql.yml` and
|
||||
> `rules-publish.yml` only, and `docs/13_CI_CD.md` records that. Written in the future
|
||||
> tense here from 2026-08-06 rather than describing a workflow nobody has. Note also
|
||||
> that this file has no `## [x.y.z]` heading yet, so the first release needs one
|
||||
> created before a tag has anything to find.
|
||||
> **Built 2026-09-14 (P4 PR-5).** From 2026-08-06 until then this paragraph said the workflow
|
||||
> "will" exist and that a missing section "will mean an empty release note"; the second half
|
||||
> was the wrong design and is replaced rather than implemented. This file still has no
|
||||
> `## [x.y.z]` heading: the first one is the owner's, in the commit that cuts the first tag.
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
### Added
|
||||
|
||||
- **P4 PR-5 — Velopack, the updater, `release.yml`, and one version source (`11_UPDATER`, 2026-09-14).**
|
||||
`FrameLedger.App/Update/`: `VelopackUpdateClient` behind the `IUpdateClient` port (Velopack's `UpdateManager` over
|
||||
its GitHub source for this repository; the `stable` channel is the releases GitHub does not mark pre-release, `beta`
|
||||
adds the ones it does), `UpdateFailureMapper` (the §Error mapping rows from the exception: 404 / 403+429 / 5xx /
|
||||
transport / checksum / unknown; an HttpClient timeout is Offline, not a cancel), `FrameLedgerFileDownloader` (Velopack's
|
||||
downloader with `User-Agent: FrameLedger/<version>`), `UpdateService` — the startup silent check 5 s after start when the copy is
|
||||
installed and the new `update.auto_check` setting (default on) says so, every failure a log line; Help ▸ Check for
|
||||
updates with the dialogs (`UpdatePrompts` over WPF-UI's `MessageBox`: the offer with the release notes and the
|
||||
unsigned-release footer, up to date, not an installed copy, the six error rows — a 404 offers the releases page, an
|
||||
unknown failure offers the bug report); the background download, retried once on a checksum failure; and **FR-12 as the shape of the whole thing**: a
|
||||
downloaded package is `Ready` only while the Agent reports no session, otherwise `Deferred` until the last
|
||||
`SessionCompleted`, and the apply itself is refused with a session running. The apply (`Restart to update`, the
|
||||
shell's new persistent InfoBar) sends `Shutdown` to the Agent, holds the connection's relaunch (`IAgentLink.SetLaunchHold`),
|
||||
waits for the pipe to drop (an Agent that does not stop in 10 s leaves everything as it was), hands Velopack the
|
||||
package (`WaitExitThenApplyUpdates`) and ends the host; the restarted App starts the Agent beside itself as always,
|
||||
and — when Velopack reports the restart — re-validates the logon task's action path (`--install-task` on `Stale`).
|
||||
`Program.Main` is now hand-written so `VelopackApp.Run()` precedes any window: the uninstall hook (`UninstallHook`,
|
||||
delegates for the test) asks a running Agent to stop, unregisters the Vulkan layer, removes the logon task and
|
||||
**asks** about the data folder (deleted on Yes only; unanswered inside Velopack's 30 s budget keeps it); install
|
||||
registers nothing. The tray raises "update available" as a balloon only while the window is off screen. Settings ▸
|
||||
Updates gained the startup-check toggle and the channel row's real text. **One version source:** `VERSION` at the
|
||||
repository root, read by `Directory.Build.props` (`<Version>`, SourceLink's `+sha` suffix off) and by
|
||||
`src/native/CMakeLists.txt`, with `versioninfo-check` comparing every built binary's `FileVersion` against it.
|
||||
**`release.yml`** on a `v*` tag: the tag's numeric core must equal `VERSION` and `CHANGELOG.md` must carry a
|
||||
non-empty `## [x.y.z]` section (`tools/release-notes.ps1`, self-tested in `build.ps1`), `{{RELEASE_DATE}}`
|
||||
substituted before the build, the identical gate, publish App + Agent self-contained + ReadyToRun with
|
||||
`-p:Version=<tag>`, the published tree asserted by name (both entry points, the four shipped natives, the rules
|
||||
seed, no capture host), `vpk pack`, `SHA256SUMS.txt` printed into the release body, `gh release create`
|
||||
(`--prerelease` for a `-beta.N` tag). **The package id is `FrameLedger.App`**: Velopack installs into and, on
|
||||
uninstall, deletes `%LOCALAPPDATA%\<packId>`, and `%LOCALAPPDATA%\FrameLedger` is the data folder — the id the docs
|
||||
named would have removed every user's ledger without asking (`UninstallHook.AreSeparate` now refuses the data delete
|
||||
if the two ever overlap). Published locally before the PR: 250 MB in 362 files, every assertion of the workflow's
|
||||
tree step green; `vpk pack` 1.2.0 over it produced `FrameLedger.App-win-Setup.exe` (104 MB) and verified `VelopackApp.Run()` in `Program.Main`. The GitHub release itself is unexercised until a tag. `legal/PRIVACY_POLICY.md` is now **2.1-draft**: the update check and download
|
||||
rows describe requests the software makes, which is a material change the policy's own rule says re-shows the Legal
|
||||
Gate. `legal/licenses/velopack-MIT.txt`. Tests: `UpdateServiceTests` (the skips, the channels, Deferred ↔ Ready,
|
||||
the dialogs and rows, the apply's three endings), `UpdateFailureMapperTests`, `UninstallHookTests`, the
|
||||
connection's hold, the tray's balloon, the settings toggle. Docs: `11_UPDATER` built note, `12_BUILD` §Version and
|
||||
§Publish & package, `13_CI_CD` §release.yml, `08_UI`, `06_DATA_MODEL`, HANDOFF §P4, `15_ROADMAP`, README §Privacy.
|
||||
- **P4 PR-4 — the library import: Steam, GOG Galaxy, Epic and itch.io through a review checklist, hooking off for
|
||||
every row (FR-1.2, 2026-09-14).** `Application.Import.LibraryImporter` over four `IStoreLibrarySource` adapters in
|
||||
`Infrastructure.Import`: `SteamLibrarySource` (`libraryfolders.vdf` + `appmanifest_*.acf` through a new
|
||||
|
||||
@@ -54,6 +54,19 @@
|
||||
<SatelliteResourceLanguages>en;vi;ja</SatelliteResourceLanguages>
|
||||
|
||||
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
|
||||
|
||||
<!-- ONE version source (P4 PR-5, docs/12_BUILD.md §Version): the VERSION file
|
||||
at the repository root. src/native/CMakeLists.txt reads the same file for
|
||||
the VERSIONINFO blocks, and tools/versioninfo-check.ps1 compares the built
|
||||
binaries against it, so the managed and native halves cannot drift. The
|
||||
condition lets release.yml pass -p:Version=<tag> for a pre-release
|
||||
(0.1.0-beta.1 is not a number CMake's project() accepts, so the native
|
||||
FileVersion stays the numeric core). SourceLink's "+sha" suffix is off so
|
||||
About, Hello and the bug bundle print the version a user can find on the
|
||||
releases page. -->
|
||||
<FrameLedgerVersionFile>$(MSBuildThisFileDirectory)VERSION</FrameLedgerVersionFile>
|
||||
<Version Condition="'$(Version)' == '' And Exists('$(FrameLedgerVersionFile)')">$([System.IO.File]::ReadAllText('$(FrameLedgerVersionFile)').Trim())</Version>
|
||||
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- Test projects: documentation comments are noise, and xUnit's own
|
||||
|
||||
@@ -105,7 +105,7 @@ Elevation is **optional — for everything.** Hooked capture is the normal path
|
||||
|
||||
## Install
|
||||
|
||||
1. Download the latest `FrameLedger-win-Setup.exe` from [Releases](https://github.com/poli0981/frameledger/releases).
|
||||
1. Download the latest `FrameLedger.App-win-Setup.exe` from [Releases](https://github.com/poli0981/frameledger/releases). It installs into `%LOCALAPPDATA%\FrameLedger.App`; your data stays in `%LOCALAPPDATA%\FrameLedger`, and uninstalling asks before touching it.
|
||||
2. SmartScreen may warn — releases are not code-signed (free, open-source project). Verify the SHA-256 checksum published with each release, then **More info → Run anyway**.
|
||||
3. Follow the first-run Legal Gate and Agent setup. Nothing is injected until you enable it for a specific game.
|
||||
|
||||
@@ -113,7 +113,7 @@ Elevation is **optional — for everything.** Hooked capture is the normal path
|
||||
|
||||
Everything lives locally in `%LOCALAPPDATA%\FrameLedger`. The only network calls FrameLedger will ever make: update checks against GitHub Releases, detection-rules updates from this repository, and *optional, opt-in* store metadata lookups. Bug reports are always built locally, shown to you, and submitted by you. Full policy: [`legal/PRIVACY_POLICY.md`](legal/PRIVACY_POLICY.md).
|
||||
|
||||
**Today it makes none of them.** The rules feed in particular does not exist — the blocklist ships with the build and updates only when you install a new one (`docs/20_OPEN_QUESTIONS.md` §S20). Listing a fetch that has no code is over-disclosure, and this document was already corrected once for describing a weekly outbound request the software never made.
|
||||
**Today it makes one of them: the update check** — at startup, a few seconds after launch, unless you turn it off in Settings ▸ Updates, and when you choose Help ▸ Check for updates — plus the download of an update you accepted; both go to GitHub Releases, from an installed copy only, and nothing is applied until you restart (never while a game is hooked). The rules feed does not exist — the blocklist ships with the build and updates only when you install a new one (`docs/20_OPEN_QUESTIONS.md` §S20). Listing a fetch that has no code is over-disclosure, and this document was already corrected once for describing a weekly outbound request the software never made.
|
||||
|
||||
## License
|
||||
|
||||
|
||||
@@ -426,6 +426,12 @@ function Invoke-ProjectGates {
|
||||
Skip-Gate 'changelog-check' 'tools/changelog-check.ps1 not implemented yet'
|
||||
}
|
||||
|
||||
# The release body's extractor (P4 PR-5, 13_CI_CD §release.yml): self-test only
|
||||
# here — the live pass needs a tag's version and runs in release.yml, where a
|
||||
# missing or empty `## [x.y.z]` section is a red release rather than an empty note.
|
||||
Write-Step 'release-notes'
|
||||
Invoke-Checked 'release-notes (self-test)' { & (Join-Path $repo 'tools/release-notes.ps1') -SelfTest }
|
||||
|
||||
# 09_I18N's gate, built with the first .resx family (P3 PR-2, 2026-09-13): every key in en/vi/ja, ja
|
||||
# Safety_* marked for human review, the generated accessor current. Self-test first (at least four
|
||||
# cases must go red), then the live pass; a tree with no family is red, not skipped.
|
||||
|
||||
@@ -330,7 +330,8 @@ switch's rule); integers are invariant-culture within an inclusive range; choice
|
||||
| `capture.min_session_s` | int | `30` | 5–600 | Agent, per session (FR-3.6) |
|
||||
| `telemetry.interval_ms` | int | `1000` | 500–2000 | Agent, per session (FR-3.5) |
|
||||
| `retention.raw_sessions_per_game` | int | `20` | 0–10000; **0 = unlimited** | Agent, per session (§Retention) |
|
||||
| `update.channel` | choice | `stable` | `stable` · `beta` | UI (P4) |
|
||||
| `update.channel` | choice | `stable` | `stable` · `beta` | UI (P4 PR-5 reads it: `beta` = GitHub pre-releases too) |
|
||||
| `update.auto_check` | bool | `1` | | UI (P4 PR-5: the startup silent check, `11_UPDATER` §Flow "if enabled") |
|
||||
| `privacy.online_metadata` | bool | `0` | | UI (P4; CLAUDE.md rule 8) |
|
||||
| `log.debug` | bool | `0` | | UI |
|
||||
|
||||
|
||||
+5
-3
@@ -37,8 +37,10 @@ The Menu sits in its own row **below** the TitleBar (never inside the drag regio
|
||||
> Import library… is PR-4's** (`ImportLibraryFlow` → the review checklist `ImportReviewPrompt` / `Dialogs/ImportReviewContent`,
|
||||
> a `DataGrid` with a tick column like Compare's picker — store, game, the executable to add, a note for
|
||||
> "already in the library" / "no executable found" / "guessed — check it"; Add selected lands every row hooking
|
||||
> off and shows the Games page; `05_DETECTION` §Platform signatures built note). Still "later build": Tools ▸
|
||||
> Database maintenance, Help ▸ Check for updates.
|
||||
> off and shows the Games page; `05_DETECTION` §Platform signatures built note). **Help ▸ Check for updates is PR-5's** (`Update/UpdateService.CheckInteractivelyAsync`, the
|
||||
> dialogs of `11_UPDATER` §Flow; a downloaded update is the shell's persistent InfoBar with the one button,
|
||||
> disabled while a session runs — FR-12 — and "update available" is a tray balloon only while the window is off
|
||||
> screen). Still "later build": Tools ▸ Database maintenance.
|
||||
>
|
||||
> **Built 2026-09-13 (P3 PR-2): the shell, and only the shell.** `FluentWindow`, the TitleBar with the
|
||||
> Agent pill as trailing content, the Menu row (every item that a later slice builds says so in a 4 s
|
||||
@@ -263,7 +265,7 @@ Agent section: elevation state with a plain explanation of what elevation *optio
|
||||
> `Infrastructure.Startup.RunAtLogon` — this user's `HKCU\…\Run` value, quoted executable path, never HKLM —
|
||||
> and the Run entry is the truth the toggle loads from; "Minimize to tray on close" is stored now and honoured
|
||||
> when the tray exists. **Privacy:** `privacy.online_metadata`, off by default, with the network sentence.
|
||||
> **Updates:** `update.channel` stored now. **Logging:** `log.debug` moves this app's `LoggingLevelSwitch` at
|
||||
> **Updates:** `update.channel` is read by PR-5's updater (beta = GitHub pre-releases), and `update.auto_check` — the startup check, on by default — sits beside it. **Logging:** `log.debug` moves this app's `LoggingLevelSwitch` at
|
||||
> once; the Agent has no reader for the key yet, and the row says so. **Legal:** reopen is a "not yet" line
|
||||
> until PR-9's gate exists. ~~Register/Unregister the layer, Register/Repair/Remove the task~~ — PR-8b, with the
|
||||
> Agent flags they need. Tests: `SettingsViewModelTests` (seven cases), `RunAtLogonTests` (Infrastructure, under
|
||||
|
||||
@@ -35,3 +35,65 @@ Binaries are not code-signed (project policy). Consequences and mitigations, doc
|
||||
## Versioning
|
||||
|
||||
SemVer `MAJOR.MINOR.PATCH`. Tag `vX.Y.Z` triggers the release workflow (13_CI_CD). `MAJOR` bumps for DB schema or IPC protocol breaks; migrations must cover every released `MAJOR-1` version.
|
||||
|
||||
## Built 2026-09-14 (P4 PR-5) — what exists, and where it deviates from the above
|
||||
|
||||
`src/FrameLedger.App/Update/`. Velopack 1.2.0 (`Directory.Packages.props`, pinned since P0, referenced since
|
||||
this PR) behind the `IUpdateClient` port — `VelopackUpdateClient` is the one implementation, `UpdateService` the
|
||||
flow, and the tests run the flow over a fake client because nothing here may touch the network in a test.
|
||||
|
||||
- **Startup silent check:** `UpdateHostedService`, 5 s after the host starts (the "5 s after UI idle" above —
|
||||
measured from start, because the shell shows synchronously inside it), only for a copy the installer laid down
|
||||
(`UpdateManager.IsInstalled`; a `bin/` build logs one line and does nothing) and only while `update.auto_check`
|
||||
is on (Settings ▸ Updates, default on — the "if enabled" above). Every failure is `Information` in the log,
|
||||
never a dialog. A release found is downloaded in the background; the tray raises a balloon only while the
|
||||
window is off screen (`08_UI` §Notifications policy), and the shell's persistent InfoBar carries the download
|
||||
and the **Restart to update** button.
|
||||
- **Manual check:** Help ▸ Check for updates → `UpdateService.CheckInteractivelyAsync` and the dialogs in
|
||||
`UpdatePrompts` (WPF-UI `MessageBox`): the offer with the release notes (the GitHub release body, shown as text —
|
||||
no Markdown renderer is shipped), the unsigned-release footer, Download / Later; "up to date"; "not an
|
||||
installed copy"; and the error table below. There is no progress *dialog*: progress is the banner's percent. A
|
||||
package that fails its checksum is downloaded once more before the Corrupt row is shown (the table's "auto-retry
|
||||
once").
|
||||
- **FR-12 is the shape of the flow, not a check at the end.** A downloaded package is `Ready` only while the Agent
|
||||
reports no session (its `StatusAck` at connect, then `SessionStarted` / `SessionCompleted` on the pipe);
|
||||
otherwise it is `Deferred`, the button is disabled and the body says why, and it becomes `Ready` when the last
|
||||
session ends. The apply is refused again inside if a session started meanwhile. A recording-only (Tier 2)
|
||||
session that began before the App connected is covered by the status; one that begins afterwards raises no
|
||||
`SessionStarted` (that event is the ring's) and is not — a known gap, recorded rather than hidden: the Overlay
|
||||
is not on disk under such a session, so the rule's reason does not apply to it.
|
||||
- **Apply:** `Shutdown` to the Agent over the pipe, the connection's relaunch held (`IAgentLink.SetLaunchHold`),
|
||||
the pipe watched until it drops (10 s; an Agent that does not stop leaves everything as it was and says so),
|
||||
then `WaitExitThenApplyUpdates(asset, silent: false, restart: true)` and the host ends. The restarted App
|
||||
starts the Agent beside itself as always, and when Velopack reports the restart (`OnRestarted`) the host reads
|
||||
the logon task: `Stale` (the action path moved) runs `--install-task`, this user's own task, and says so in the
|
||||
log — the "re-validated after update" above. Velopack keeps `current` stable, so `Installed` is the expectation.
|
||||
- **Channels:** `stable` = releases GitHub does not mark pre-release; `beta` = those too (`GithubSource(prerelease)`).
|
||||
Not Velopack's own `--channel` mechanism — one package set per tag, the GitHub flag decides. `13_CI_CD` §Branch &
|
||||
release policy.
|
||||
- **Hooks** (`VelopackHooks`, in the hand-written `Program.Main` so `VelopackApp.Run()` precedes any window):
|
||||
install registers nothing; uninstall = `UninstallHook` (`12_BUILD` §Publish & package). `Run()` in a copy the
|
||||
installer did not lay down returns at once and runs no hook (probed on 1.2.0); it does append a line to Velopack's
|
||||
own `%LOCALAPPDATA%\velopack\velopack.log` on every start — local, the library's, and stated here because it is a
|
||||
file outside `%LOCALAPPDATA%\FrameLedger`.
|
||||
- **Where it installs:** `%LOCALAPPDATA%\FrameLedger.App` (the package id), never `%LOCALAPPDATA%\FrameLedger`, which is
|
||||
the data folder Velopack would otherwise delete on uninstall (`12_BUILD` §Publish & package).
|
||||
|
||||
**Deviations from the table and the paragraph above, stated rather than left to be discovered:**
|
||||
|
||||
- `Update_Err_RateLimited` says "try again in about an hour", not "in {n} minutes": Velopack's downloader
|
||||
surfaces the status code (`HttpRequestException.StatusCode`) and not `Retry-After` / `X-RateLimit-Reset`.
|
||||
Likewise **no `If-None-Match` ETag** on the check — the request is Velopack's, not ours. The quota is 60/h
|
||||
anonymous; the App makes one request per start plus manual checks, so the header would change nothing in
|
||||
practice, but the sentence above promised it and this one withdraws it.
|
||||
- **No `GitHubHttpClient`**, no 10 s timeout of ours, no jittered retry: the HTTP is Velopack's
|
||||
`HttpClientFileDownloader`, subclassed as `FrameLedgerFileDownloader` only to put `User-Agent: FrameLedger/{version}`
|
||||
in place of `Velopack/1.2.0` (a read-only static there). The GitHub source adds no `Authorization` header for an
|
||||
empty token — measured on 1.2.0 by reflection, so the request identifies the product and nothing else. When the rules fetch is built
|
||||
(`05_DETECTION` FR-7.3, `20_OPEN_QUESTIONS` §S20 feed half) it needs a client of its own; this paragraph no
|
||||
longer claims the updater provides one.
|
||||
- Release notes are rendered as plain text, not Markdown.
|
||||
|
||||
`UpdateServiceTests` (App.Tests/Update) cover the two skips, the channels, Deferred ↔ Ready, each error row, and
|
||||
the apply's three endings; `UpdateFailureMapperTests` the table; `UninstallHookTests` the hook; a real feed has
|
||||
not been exercised — the first tag is the measurement (`13_CI_CD` §release.yml).
|
||||
+43
-7
@@ -107,7 +107,7 @@ Agent flags: `--serve`, `--console`, ~~`--diag`~~ (the App's — `FrameLedger.ex
|
||||
The struck text is kept because the *reason* it was written is still live. What it said next, and what remains true:
|
||||
|
||||
> **planned, not present.** `assets/` does not exist, nothing fetches or verifies the binary, and `EtwFrameSource` is unwritten. `20_OPEN_QUESTIONS` §M2 (does the pinned console binary still exist, run unelevated, and emit the 2.x column set?) is unanswered, so this is not merely unpinned — there is nothing to pin yet.
|
||||
- Vulkan layer manifest, **written** with the installed layer path at install time (Velopack hook) — but **not registered there**. Registration is a separate, later act.
|
||||
- ~~Vulkan layer manifest, **written** with the installed layer path at install time (Velopack hook) — but **not registered there**.~~ **The install hook writes nothing (P4 PR-5):** the manifest is written by the registrar the first time the ledger asks for the layer (`VkLayerRegistrar.Register`, P4 PR-2), so an install that never enables a Vulkan game has no manifest either. Registration is a separate, later act.
|
||||
|
||||
### The Vulkan layer is not registered at install time
|
||||
|
||||
@@ -135,15 +135,50 @@ repairs state, it does not grant machine-wide reach on its own).
|
||||
> after every sweep; the flag and the button run the same rule. The uninstall hook is still the updater's
|
||||
> (P4, Velopack).
|
||||
|
||||
## Version
|
||||
|
||||
**One source: the `VERSION` file at the repository root** (`MAJOR.MINOR.PATCH`, nothing else — P4 PR-5,
|
||||
2026-09-14). Before it, the managed assemblies carried the SDK's default `1.0.0` while CMake said `0.1.0`,
|
||||
two products claiming to be one.
|
||||
|
||||
- `Directory.Build.props` reads it into `<Version>` (assembly, file and informational versions; SourceLink's
|
||||
`+sha` suffix is off so About, `Hello` and the bug bundle print the version a user can find on the releases
|
||||
page). The read is conditional on `$(Version)` being empty, so `release.yml` passes `-p:Version=0.1.0-beta.1`
|
||||
for a pre-release and the assemblies carry the tag's full version.
|
||||
- `src/native/CMakeLists.txt` reads the same file into `project(VERSION …)`, which the `.rc` template turns
|
||||
into every VERSIONINFO block. CMake's `project()` accepts numbers only, so the native `FileVersion` is the
|
||||
numeric core even for a pre-release.
|
||||
- `tools/versioninfo-check.ps1` compares every built binary's `FileVersion` against the file (`x.y.z.0`), so a
|
||||
read that silently produced `0.0.0` on either side is red in the gate.
|
||||
- `release.yml` refuses a tag whose numeric core is not the file's. Bumping the version is one edit to
|
||||
`VERSION`, in the same commit as the changelog section, before the tag.
|
||||
|
||||
The Velopack package version is the tag's (`vpk pack --packVersion`), and `UpdateManager.CurrentVersion` reads
|
||||
the installed package's manifest — not the assembly — which is why the two are made to agree here rather than
|
||||
assumed to.
|
||||
|
||||
## Publish & package
|
||||
|
||||
```
|
||||
cmake --build --preset x64-release
|
||||
dotnet publish src/FrameLedger.App -c Release -r win-x64 --self-contained -p:PublishReadyToRun=true -o out/app
|
||||
dotnet publish src/FrameLedger.Agent -c Release -r win-x64 --self-contained -p:PublishReadyToRun=true -o out/app
|
||||
vpk pack --packId FrameLedger --packVersion {ver} --packDir out/app --mainExe FrameLedger.exe --icon assets/icon.ico
|
||||
vpk pack --packId FrameLedger.App --packVersion {ver} --packDir out/app --mainExe FrameLedger.exe --packTitle FrameLedger --releaseNotes out/notes.md --outputDir out/release
|
||||
```
|
||||
|
||||
> **Run by `release.yml` since 2026-09-14 (P4 PR-5)** — `13_CI_CD` §release.yml carries the steps around it
|
||||
> (the version gate, `{{RELEASE_DATE}}`, the published-tree assertion, checksums, the release). Both publishes
|
||||
> take `-p:Version=<tag>` (§Version). No `--icon`: `assets/icon.ico` does not exist, and this line named it
|
||||
> for six weeks.
|
||||
>
|
||||
> **The package id is `FrameLedger.App`, and this line said `FrameLedger` until 2026-09-14 — which would have
|
||||
> deleted every user's ledger on uninstall.** Velopack installs into `%LOCALAPPDATA%\<packId>` and removes that
|
||||
> directory when the app is uninstalled; `%LOCALAPPDATA%\FrameLedger` is the data folder (`LedgerPaths`, `07_IPC`,
|
||||
> `legal/PRIVACY_POLICY.md` §1). With the same id the install would live inside the ledger's folder and the
|
||||
> uninstaller would take `ledger.db` with it, without the question below. The title users see stays "FrameLedger"
|
||||
> (`--packTitle`); the installer is `FrameLedger.App-win-Setup.exe`. `UninstallHook.AreSeparate` refuses the data
|
||||
> delete if the two ever overlap again, so a future id change fails safe rather than silently.
|
||||
>
|
||||
> **Exactly two roots, and a gate now says so.** `src/FrameLedger.CaptureHost` — the unshipped
|
||||
> capture host — is outside the package because neither root references it, and
|
||||
> `tools/package-closure-check.ps1` is what keeps that true rather than remembered. It matters
|
||||
@@ -168,15 +203,15 @@ vpk pack --packId FrameLedger --packVersion {ver} --packDir out/app --mainExe Fr
|
||||
> prevent.
|
||||
|
||||
- No trimming (WPF + reflection), no NativeAOT (WPF unsupported), **no obfuscation** (GPLv3 policy, and `19_SAFETY` forbids making our binaries harder to identify).
|
||||
- `SatelliteResourceLanguages=en;vi;ja`. Expected package ≈ 95–130 MB self-contained.
|
||||
- Velopack hooks: installed → offer Agent setup + Vulkan layer registration; uninstalled → unregister the layer, remove the scheduled task, ask about the data folder.
|
||||
- `SatelliteResourceLanguages=en;vi;ja`. ~~Expected package ≈ 95–130 MB self-contained.~~ **Measured 2026-09-14 (P4 PR-5): the published tree is 250 MB in 362 files** (App + Agent, self-contained, ReadyToRun roughly doubles the IL). `vpk pack` 1.2.0 over that tree, run by hand the same day with the workflow's arguments: `FrameLedger.App-win-Setup.exe` **104 MB**, the full `.nupkg` and the portable zip 100 MB each, plus `releases.win.json` / `RELEASES` / `assets.win.json`; vpk's own pre-process step verified `VelopackApp.Run()` in `FrameLedger.App.Program::Main()`.
|
||||
- Velopack hooks (**built 2026-09-14, P4 PR-5**: `App/Update/VelopackHooks`, wired in the hand-written `Program.Main` before any window). **Install registers nothing** — the first-run flow is the offer (Agent setup), and the layer follows the ledger (§The Vulkan layer is not registered at install time); this line used to say "offer Agent setup + Vulkan layer registration", and the second half was the thing the section below forbids. Uninstall runs `UninstallHook`: `Shutdown` to a running Agent over the pipe (best effort, it holds the install directory), unregister the layer (HKCU), remove the logon task, then **ask** about the data folder — deleted on Yes only, never when it and the install overlap (`AreSeparate`), and a question unanswered inside Velopack's 30 s callback budget keeps it.
|
||||
|
||||
## Release-time token substitution
|
||||
|
||||
`{{RELEASE_DATE}}` in `legal/*.md` is the **only** placeholder that survives into
|
||||
the repository, and it is deliberate: the effective date of a legal document is
|
||||
the date it ships, which is not knowable at authoring time. `release.yml` — **which
|
||||
does not exist yet; `13_CI_CD` §release.yml records that** —
|
||||
the date it ships, which is not knowable at authoring time. `release.yml` (**built 2026-09-14**, P4 PR-5 — the step runs before the
|
||||
build, because the App embeds `legal/*.md`)
|
||||
substitutes it with the tag date when packaging, and `ci.yml` fails the build if
|
||||
**any other** `{{` token appears in `README.md` or `legal/*.md` (`13_CI_CD.md`
|
||||
§ci.yml). Everything else — repository URL, slug, developer identity, contact
|
||||
@@ -196,13 +231,14 @@ document the app displays for acceptance (FR-11) is a defect, not a template.
|
||||
7. `tools/coverage-gate.ps1` — reads this run's cobertura reports; self-arming, and armed today for
|
||||
`FrameLedger.Domain` and `FrameLedger.Application`
|
||||
8. `tools/rules-validate.ps1` (schema + `anticheat` block sanity — a malformed or empty blocklist is a safety bug)
|
||||
9. `tools/versioninfo-check.ps1` — reads the built binary, because what ships is what an anti-cheat vendor sees
|
||||
9. `tools/versioninfo-check.ps1` — reads the built binary, because what ships is what an anti-cheat vendor sees; since P4 PR-5 it also compares every `FileVersion` against the `VERSION` file (§Version)
|
||||
10. `tools/chokepoint-check.ps1` — injection and evasion primitives confined to one file, native **and** managed, plus the `FL_GUARD_TESTABLE` symbol check against the shipped artifacts
|
||||
11. **`tools/hookinventory-check.ps1`** — three passes: A resolves every vendor symbol the Overlay names against `docs/vendor-exports.json`, B sweeps for stray literals, C reads the BUILT Overlay's import table and asserts it imports no vendor module. C skips loudly under `-SkipNative`. **Missing from this list until 2026-08-28**, which is §R10 happening again
|
||||
12. **`tools/package-closure-check.ps1`** — both halves: the self-test (5 cases, 4 of which must go RED) **and** a live pass over this repository. It walks the transitive `ProjectReference` closure of the two publish roots below and fails on anything outside the allowlist, naming the reference edge. `FrameLedger.CaptureHost` is an injecting entry point kept out of the package by construction, and `20_OPEN_QUESTIONS` §S27 is closed on exactly that basis
|
||||
13. `tools/license-check.ps1` — asserts every vendored third-party has a licence copy in `legal/licenses/`, and that no Intel IGCL / AMD ADLX material has appeared in the tree
|
||||
13b. `tools/accuracy-check.ps1 -SelfTest`, then live — the accuracy block is ONE text (`legal/ACCURACY.md`) embedded verbatim in `README.md` and `legal/DISCLAIMER.md` §4; a copy that drifted, a copy with no markers, or an empty source is red. Four self-test cases, both directions (§S23-6, 2026-09-06)
|
||||
14. `tools/changelog-check.ps1 -SelfTest` — nine cases, five expected RED. The live half needs a pull request's changed-file list and is supplied by `ci.yml`
|
||||
14b. `tools/release-notes.ps1 -SelfTest` — five cases over a fixture changelog (a dated and an undated section, a missing one, a prefix that must not match, an empty one). The live half needs a tag's version and runs in `release.yml`, where a missing or empty section is a red release (P4 PR-5)
|
||||
15. `tools/resx-audit.ps1` — ~~**skipped loudly; it does not exist, and no `.resx` file does either**~~ **built 2026-09-13 (P3 PR-2)**: `-SelfTest` first (11 fixture cases, both directions), then the live pass over every `Strings.resx` family under `src/` — key sets equal across en/vi/ja, `Safety_*` in `ja` marked for review or signed, `Strings.Designer.cs` current with `tools/resx-gen.ps1`. A tree with no family is red (`09_I18N` §Translation workflow)
|
||||
16. **struct-mirror** — reads this run's `.trx` and fails when `ShmLayoutMirrorTests` did not execute, so deleting the mirror test is red as well as breaking it
|
||||
17. Placeholder guard — fails if any `{{` token other than `{{RELEASE_DATE}}` survives in `README.md` or `legal/*.md`
|
||||
|
||||
+36
-13
@@ -1,6 +1,6 @@
|
||||
# 13 — CI/CD
|
||||
|
||||
FrameLedger uses the **`poli0981/.github` ops repo** where its templates fit, and repo-local workflows where they do not. `ci.yml` is repo-local **by necessity, not preference**: the ops repo's `reusable-desktop-csharp.yml` runs `dotnet restore` / `build` / `test` directly and exposes no input for a native pre-step, MSVC setup, or the Vulkan SDK. FrameLedger's build is mixed-toolchain and native-first, and `12_BUILD.md` §Local quality gate commits to CI running *the identical script* as local — a promise a pure-managed template cannot keep. CodeQL and release still call the ops repo.
|
||||
FrameLedger uses the **`poli0981/.github` ops repo** where its templates fit, and repo-local workflows where they do not. `ci.yml` is repo-local **by necessity, not preference**: the ops repo's `reusable-desktop-csharp.yml` runs `dotnet restore` / `build` / `test` directly and exposes no input for a native pre-step, MSVC setup, or the Vulkan SDK. FrameLedger's build is mixed-toolchain and native-first, and `12_BUILD.md` §Local quality gate commits to CI running *the identical script* as local — a promise a pure-managed template cannot keep. CodeQL is repo-local too (its own heading below says why), and so is `release.yml` since 2026-09-14 — the same native pre-step and the identical gate make a caller stub impossible for it as well; this sentence said both "still call the ops repo" until then.
|
||||
|
||||
> ⚠ Known gotcha (learned on earlier migrations): caller stubs **must declare explicit `permissions:` blocks** — permissions do not inherit into reusable workflows. Every stub below lists its own.
|
||||
|
||||
@@ -67,17 +67,40 @@ FrameLedger uses the **`poli0981/.github` ops repo** where its templates fit, an
|
||||
- Languages: `csharp` **and `cpp`** (manual build mode for C++, driven by the CMake preset). The native layer is where memory-safety bugs would live; excluding it would defeat the purpose. Verify the mixed template exposes a C++ build-command input; if it does not, this one goes repo-local too.
|
||||
- `permissions: security-events: write, contents: read`.
|
||||
|
||||
### `release.yml` — on tag `v*` · **PLANNED, NOT PRESENT**
|
||||
### `release.yml` — on tag `v*` · **repo-local, built 2026-09-14 (P4 PR-5)**
|
||||
|
||||
> `.github/workflows/` contains `ci.yml`, `codeql.yml` and `rules-publish.yml`. There is no release
|
||||
> automation at all: the publish commands exist only as a fenced block in `12_BUILD` §Publish &
|
||||
> package, and **nothing in this repository has ever run `dotnet publish`** — which is why
|
||||
> `out/app`'s real contents had never been asserted by anything until
|
||||
> `tools/package-closure-check.ps1` started walking the reference closure statically. Recorded
|
||||
> 2026-08-06 rather than left describing a workflow that does not exist.
|
||||
- Build + test (same script, native first) → publish App+Agent self-contained → ~~verify PresentMon SHA-256~~ *(retired 2026-08-27 — the console binary is not bundled; owner decision, `20_OPEN_QUESTIONS` §G)* → **verify VERSIONINFO present on `FrameLedger.Overlay.dll` and `FrameLedger.VkLayer.dll`** (identifiability is a safety requirement, `19_SAFETY`) → `vpk pack` → generate `SHA256SUMS.txt` → create GitHub Release with Velopack assets + checksums, release notes from `CHANGELOG.md` section.
|
||||
- Optional final step: submit installer hash to VirusTotal and append the report link to release notes (helps unsigned-binary trust).
|
||||
- `permissions: contents: write`.
|
||||
> This heading said **PLANNED, NOT PRESENT** from 2026-08-06 until the workflow existed, with the note that
|
||||
> "nothing in this repository has ever run `dotnet publish`". Still true of the *repository's history*: the
|
||||
> workflow has not been exercised by a tag yet — its publish, tree assertion and `vpk pack` steps were run by hand on
|
||||
> 2026-09-14 (`12_BUILD` §Publish & package has the sizes), the release upload was not. The first tag is the rest of the measurement; until then every other claim below is
|
||||
> what the file says, not what a run showed.
|
||||
|
||||
- `runs-on: windows-latest`, the same .NET / MSVC / clang-format pins as `ci.yml`, `permissions: contents: write`
|
||||
(the Release API) and nothing else.
|
||||
- **Version gate first.** The tag must be `vMAJOR.MINOR.PATCH[-prerelease]`; its numeric core must equal the
|
||||
`VERSION` file (`12_BUILD` §Version); and `CHANGELOG.md` must carry a **non-empty** `## [x.y.z]` section for the
|
||||
full version, extracted by `tools/release-notes.ps1` (self-tested on every `build.ps1 check`). A missing
|
||||
section is a red release, not an empty note — the ledger's header said the opposite for five weeks.
|
||||
- `{{RELEASE_DATE}}` substituted in `legal/*.md` with the run's UTC date **before the build**, because the App
|
||||
embeds those documents (FR-11); any `{{` token left anywhere after that fails the job.
|
||||
- **The identical gate** — `./build.ps1 check`, native first, every tool including `versioninfo-check` against
|
||||
`VERSION`. A release never skips it.
|
||||
- `dotnet publish` App + Agent, self-contained + ReadyToRun, `-p:Version=<tag>`, into one `out/app`.
|
||||
- **The published tree asserted by name**: `FrameLedger.exe`, `FrameLedger.Agent.exe`, the four shipped natives
|
||||
`versioninfo-check` lists, `rules/detection-rules.json`; `FrameLedger.CaptureHost.exe` absent (`12_BUILD`:
|
||||
exactly two roots — `package-closure-check` proves it statically, this reads the directory); `versioninfo-check`
|
||||
run again over `out/app`, because a `.targets`-staged DLL that failed to copy is a warning to `dotnet publish`.
|
||||
- `vpk pack --packId FrameLedger.App` (the `vpk` tool pinned to the library's 1.2.0) with the release notes;
|
||||
`FrameLedger.App-win-Setup.exe` must come out, because README §Install names it. **Not `--packId FrameLedger`**:
|
||||
Velopack installs into and uninstalls `%LOCALAPPDATA%\<packId>`, which with that id is the data folder
|
||||
(`12_BUILD` §Publish & package). No `--icon` until `assets/icon.ico` exists.
|
||||
- `SHA256SUMS.txt` over every asset, published beside them and printed into the release body (`11_UPDATER`
|
||||
§Unsigned releases).
|
||||
- `gh release create` with the assets, `--verify-tag`, and `--prerelease` for a `-beta.N` tag.
|
||||
- The assets and the notes are also uploaded as a workflow artifact for the smoke checklist (`14_TESTING`
|
||||
§Release smoke).
|
||||
- ~~Optional final step: submit installer hash to VirusTotal~~ — not built; an upload of the installer to a third
|
||||
party is a decision the owner makes, not a step a workflow adds quietly.
|
||||
|
||||
### `rules-publish.yml` — on change to `rules/detection-rules.json` in `main`
|
||||
- Runs `tools/rules-validate` and fails on anti-cheat removals. The raw file on `main` **is** the distribution endpoint (05_DETECTION), so this workflow only gates correctness.
|
||||
@@ -126,8 +149,8 @@ Central package management makes Dependabot PRs single-file diffs.
|
||||
## Branch & release policy
|
||||
|
||||
- `main` protected: CI + CodeQL required, linear history, no direct pushes.
|
||||
- Release: update `CHANGELOG.md` (Keep a Changelog format) → tag `vX.Y.Z` → `release.yml` does the rest → smoke-test the produced installer on a clean Win 10 VM + Win 11 (manual checklist in 14_TESTING §Release smoke).
|
||||
- Pre-releases: `vX.Y.Z-beta.N` tags mark the GitHub release as pre-release; Velopack stable channel ignores them (explicit beta channel is v2 backlog).
|
||||
- Release: in ONE commit, bump `VERSION` and move the `[Unreleased]` entries of `CHANGELOG.md` under `## [X.Y.Z] - date` (Keep a Changelog format) → tag `vX.Y.Z` → `release.yml` does the rest (and refuses a tag that disagrees with either file) → smoke-test the produced installer on a clean Win 10 VM + Win 11 (manual checklist in 14_TESTING §Release smoke).
|
||||
- Pre-releases: `vX.Y.Z-beta.N` tags mark the GitHub release as pre-release; the App's `stable` channel ignores them and its `beta` channel (Settings ▸ Updates, `update.channel`) includes them — built with P4 PR-5, so ~~explicit beta channel is v2 backlog~~ is struck. The managed assemblies carry the full tag version; the native VERSIONINFO blocks carry the numeric core (`12_BUILD` §Version).
|
||||
|
||||
## Repo hygiene checklist (one-time setup)
|
||||
|
||||
|
||||
+2
-2
@@ -317,10 +317,10 @@ Agent: watcher, tier selection, injection orchestration, shm drain, telemetry po
|
||||
WPF UI shell (`16_WPFUI_SYNTAX`), library, per-game hooking consent flow, Dashboard live card showing *measured* settings, session summary, ScottPlot charts, game detail tabs, Compare with tier guarding, segment ribbon, tri-state chips with override, refusal/degradation/unhook notices as first-class UI. **Plus, moved here from P4 on 2026-09-13 (owner):** the command pipe (`07_IPC` §C — P2's decision D10 put it here), i18n en/vi/ja with `tools/resx-audit` (the consent dialog is the first thing that needs a reviewed `.resx`, so it cannot wait), the Legal Gate (FR-11), Settings (FR-10, the kill switch first), the Logs page, tray + toasts. The owner chose the whole of `08_UI` over a shell-first cut; HANDOFF §P3 carries the slice order and the decisions (D11–D17). *Not started as of 2026-09-13: `FrameLedger.App` is the scaffold, `FrameLedger.Shared` has no IPC type, and no `.resx` exists in the tree.*
|
||||
|
||||
## P4 — Detection & product polish (1 week)
|
||||
~~Static rules engine + `detection-rules.json` (engines, platforms, capabilities, **anticheat blocklist**) + validator + fixtures~~ **landed 2026-09-14 (P4 PR-1: the engine existed since P0; the Agent's `DetectionSweep` is its first caller, `ApplyDetectionAsync` its first writer — HANDOFF §P4)**; ~~store auto-import~~ **landed 2026-09-14 (P4 PR-4)**; ~~capability-vs-measured UI separation~~ **(PR-1: the Supports row reads the sweep's flags)**; ~~i18n en/vi/ja; Legal Gate;~~ Velopack + updater (with the hooked-session deferral); bug bundle incl. overlay logs; ~~tray + toasts; Settings;~~ DB maintenance; accessibility pass; the scheduled task (`--install-task`) and the Velopack install hooks. *(The struck items moved to P3 on 2026-09-13 — see §P3.)*
|
||||
~~Static rules engine + `detection-rules.json` (engines, platforms, capabilities, **anticheat blocklist**) + validator + fixtures~~ **landed 2026-09-14 (P4 PR-1: the engine existed since P0; the Agent's `DetectionSweep` is its first caller, `ApplyDetectionAsync` its first writer — HANDOFF §P4)**; ~~store auto-import~~ **landed 2026-09-14 (P4 PR-4)**; ~~capability-vs-measured UI separation~~ **(PR-1: the Supports row reads the sweep's flags)**; ~~i18n en/vi/ja; Legal Gate;~~ ~~Velopack + updater (with the hooked-session deferral)~~ **landed 2026-09-14 (P4 PR-5 — the deferral is `UpdateService`'s shape, not a flag)**; bug bundle incl. overlay logs; ~~tray + toasts; Settings;~~ DB maintenance; accessibility pass; ~~the scheduled task (`--install-task`)~~ (P3 PR-8b) and ~~the Velopack install hooks~~ **(PR-5: the uninstall hook; install registers nothing, by design — `12_BUILD` §The Vulkan layer is not registered at install time)**. *(The struck items moved to P3 on 2026-09-13 — see §P3.)*
|
||||
|
||||
## P5 — Ship (3–4 days)
|
||||
CI/CD with the native build; CodeQL (C# + C++); Dependabot; CHANGELOG; README with the P0 accuracy comparison — **which is not a percentage, and this line used to send its author looking for one**. The decision is recorded under item 3 and in `spike-notes.md` §8: the baseline can answer **none** of item 4's four runtime questions, so the defensible claim is *"the baseline cannot answer four of these five questions at all"*, not *"N% more accurate"*. Overhead + tier cross-validation measurements; release smoke on clean VMs; `v0.1.0-beta.1`.
|
||||
CI/CD with the native build (`release.yml` exists since P4 PR-5, 2026-09-14 — untested by a tag yet); CodeQL (C# + C++); Dependabot; CHANGELOG; README with the P0 accuracy comparison — **which is not a percentage, and this line used to send its author looking for one**. The decision is recorded under item 3 and in `spike-notes.md` §8: the baseline can answer **none** of item 4's four runtime questions, so the defensible claim is *"the baseline cannot answer four of these five questions at all"*, not *"N% more accurate"*. Overhead + tier cross-validation measurements; release smoke on clean VMs; `v0.1.0-beta.1`.
|
||||
|
||||
**Total ≈ 5.5–6.5 weeks full-time** — roughly 1.5–2 weeks more than the ETW design, which is the honest price of the accuracy.
|
||||
|
||||
|
||||
+4
-4
@@ -1229,8 +1229,8 @@ filled — status in `CHANGELOG.md`, the decisions in `05_DETECTION` §Caching's
|
||||
itch.io — the first-run flow's step 4 and File ▸ Import library both say "later build")~~ **LANDED 2026-09-14 (P4 PR-4:
|
||||
`LibraryImporter` over four `IStoreLibrarySource` adapters, the review checklist, `ApplyStoreMetadataAsync` under
|
||||
the provenance rule, hooking off for every row — `05_DETECTION` §Platform signatures built note)**, ~~the
|
||||
capability-vs-measured separation in the UI (the game page's Supports row is empty until this)~~ **(PR-1)**, Velopack +
|
||||
the updater (`11_UPDATER`; the Settings channel row is stored and unused), ~~the bug-report flow's steps 3–5
|
||||
capability-vs-measured separation in the UI (the game page's Supports row is empty until this)~~ **(PR-1)**, ~~Velopack +
|
||||
the updater (`11_UPDATER`; the Settings channel row is stored and unused)~~ **LANDED 2026-09-14 (P4 PR-5: `App/Update/` — `VelopackUpdateClient` behind `IUpdateClient`, `UpdateService` with FR-12 as its shape, the banner, the install/uninstall hooks in `Program.Main`, `release.yml`, one `VERSION` source — `11_UPDATER` built note)**, ~~the bug-report flow's steps 3–5
|
||||
(`10_LOGGING`: the preview dialog, the GitHub issue link — step 2's bundle exists)~~ **LANDED 2026-09-14 (P4 PR-3:
|
||||
`BugReportFlow`, the preview dialog, the issue link with the form's real field ids, the Markdown clipboard fallback;
|
||||
the crash dialog + minidump stay open — `10_LOGGING` built note)**, ~~the "is Vulkan" fact the
|
||||
@@ -1238,8 +1238,8 @@ layer's register/unregister-on-consent automation needs (`17_HOOK_ENGINE` §Vulk
|
||||
2026-09-14 (P4 PR-2): a static PE fact (`PeImports` + the bounded scan) stored as `vulkan` in `capability_flags`,
|
||||
and `VkLayerReconciler` moving the HKCU registration after every consent change and sweep — the built note
|
||||
carries it**, the Help menu's
|
||||
~~Documentation~~ / Check for updates / ~~Report a bug~~ items **(Documentation and Report a bug landed with PR-3;
|
||||
Check for updates waits for the updater; File ▸ Export became the three-leaf submenu `08_UI` specifies)**, and
|
||||
~~Documentation~~ / ~~Check for updates~~ / ~~Report a bug~~ items **(Documentation and Report a bug landed with PR-3;
|
||||
~~Check for updates waits for the updater~~ — PR-5; File ▸ Export became the three-leaf submenu `08_UI` specifies)**, and
|
||||
`legal/licenses/` populated by the license-gathering
|
||||
script. Decisions that live only here: D11–D17 below still hold; nothing in P4 may add a third writer to
|
||||
`ledger.db` or a message that carries a safety fact over the pipe.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# FrameLedger — Privacy Policy
|
||||
|
||||
**Version:** 2.0-draft · **Effective:** {{RELEASE_DATE}}
|
||||
**Version:** 2.1-draft · **Effective:** {{RELEASE_DATE}}
|
||||
|
||||
**Short version: everything stays on your PC. FrameLedger has no accounts, no telemetry, no analytics, and never uploads your data anywhere.**
|
||||
|
||||
@@ -28,7 +28,7 @@ FrameLedger makes **no network connections except the following**, each visible
|
||||
| Detection-rules update | Raw file on the project repository | Weekly check (can be disabled) and manual | Same as above |
|
||||
| Store metadata lookup | Steam public store API | **Off by default — opt-in** | The Steam AppID of a game you added |
|
||||
|
||||
> ⚠ **Accuracy audit, 2026-08-04: the "Safety list update" and "Detection-rules update" rows describe outbound requests the software does not make.** There is no HTTP client anywhere in the product; the anti-cheat blocklist currently ships with the build and is installed locally on first run (`docs/20_OPEN_QUESTIONS.md` §S20 — the seed half is done, the feed half is not). **Over-disclosure is a defect in this document too**: a privacy policy that lists a transmission which never happens is as wrong as one that omits a transmission which does. Either the fetch exists at first release or these rows change.
|
||||
> ⚠ **Accuracy audit, 2026-08-04, amended 2026-09-14: the "Safety list update" and "Detection-rules update" rows describe outbound requests the software does not make.** The "Update check" and "Update download" rows are real since 2026-09-14 (version 2.1 of this document — a new outbound request is a material change): Velopack, against GitHub's release API and release assets, from an installed copy only, the startup check off with one switch in Settings ▸ Updates, and the request carries `User-Agent: FrameLedger/<version>` and nothing else of ours. The rules rows are not real: there is no rules HTTP client anywhere in the product; the anti-cheat blocklist currently ships with the build and is installed locally on first run (`docs/20_OPEN_QUESTIONS.md` §S20 — the seed half is done, the feed half is not). **Over-disclosure is a defect in this document too**: a privacy policy that lists a transmission which never happens is as wrong as one that omits a transmission which does. Either the fetch exists at first release or these rows change.
|
||||
|
||||
GitHub's own privacy practices apply to requests it receives: <https://docs.github.com/privacy>. The Steam lookup, if enabled, is governed by Valve's policies.
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ FrameLedger is licensed under **GPL-3.0-only**. It includes or depends on the th
|
||||
| CommunityToolkit.Mvvm | MVVM framework | MIT | |
|
||||
| ScottPlot 5 | Charts | MIT | |
|
||||
| Serilog (+ file sink) | Logging | Apache-2.0 | |
|
||||
| Velopack | Installer/updater | MIT | |
|
||||
| Velopack | Installer/updater | MIT | © Velopack Ltd. (the package's copyright field). Referenced by the App since 2026-09-14 (P4 PR-5); the package ships no licence file, so the copy is `legal/licenses/velopack-MIT.txt` |
|
||||
| Microsoft.Data.Sqlite / SQLitePCLraw | Database | MIT / Apache-2.0 | SQLite itself: public domain |
|
||||
| Dapper | Data access | Apache-2.0 | |
|
||||
| CsWin32 (build-time) | Win32 interop source generator | MIT | Build-time only |
|
||||
|
||||
@@ -12,6 +12,7 @@ Required before the first release
|
||||
| `minhook-BSD-2-Clause.txt` | MinHook — vendored and built from source |
|
||||
| `nvapi-MIT.txt` | NVIDIA NVAPI SDK — headers + import library vendored |
|
||||
| `wpfui-MIT.txt` | WPF UI (lepoco) — MIT requires the notice to ship |
|
||||
| `velopack-MIT.txt` | Velopack — the installer and updater (P4 PR-5); the package declares MIT and ships no licence file |
|
||||
| `librehardwaremonitor-MPL-2.0.txt` | LibreHardwareMonitorLib, consumed unmodified |
|
||||
| `apache-2.0.txt` | Serilog, Dapper, the analyzers, Vulkan headers |
|
||||
| `mit.txt` | Shared text for the MIT-licensed NuGet packages |
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
Velopack — https://github.com/velopack/velopack
|
||||
NuGet package Velopack 1.2.0. The package declares the licence expression MIT and ships no licence file, so
|
||||
this copy is ours to distribute. The copyright line below is the package's own <copyright> field, verbatim
|
||||
(its <authors> field: Velopack Ltd, Caelan Sayler, Kevin Bost); the licence text is the standard MIT text.
|
||||
|
||||
MIT License
|
||||
|
||||
Copyright © Velopack Ltd. All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
@@ -4,6 +4,7 @@ using System.Windows;
|
||||
using System.Windows.Threading;
|
||||
using FrameLedger.App.Pages;
|
||||
using FrameLedger.App.Services;
|
||||
using FrameLedger.App.Update;
|
||||
using FrameLedger.App.ViewModels;
|
||||
using FrameLedger.Application.Import;
|
||||
using FrameLedger.Application.Persistence;
|
||||
@@ -281,12 +282,26 @@ public partial class App : System.Windows.Application
|
||||
services.AddSingleton<IMaintenanceState, MaintenanceState>();
|
||||
services.AddSingleton<IAgentTool, AgentTool>();
|
||||
|
||||
AddUpdates(services);
|
||||
|
||||
// FR-11 (P3 PR-9): the gate over the UI's own table, the documents this build embeds, the window that shows them.
|
||||
services.AddSingleton<ILegalAcceptanceStore, SqliteLegalAcceptanceStore>();
|
||||
services.AddSingleton(static sp => new LegalGate(sp.GetRequiredService<ILegalAcceptanceStore>(), LegalDocuments.Load()));
|
||||
services.AddSingleton<IFirstRunFlow, FirstRunFlow>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The updater (P4 PR-5, <c>11_UPDATER</c>): Velopack behind the <see cref="IUpdateClient"/> port, the dialogs behind
|
||||
/// <see cref="IUpdatePrompts"/>, the flow that holds FR-12, and the startup check as a hosted service.
|
||||
/// </summary>
|
||||
private static void AddUpdates(IServiceCollection services)
|
||||
{
|
||||
services.AddSingleton<IUpdateClient, VelopackUpdateClient>();
|
||||
services.AddSingleton<IUpdatePrompts, UpdatePrompts>();
|
||||
services.AddSingleton<UpdateService>();
|
||||
services.AddHostedService<UpdateHostedService>();
|
||||
}
|
||||
|
||||
/// <summary>FR-1.2's library import (P4 PR-4): the stores, the executable guess, the importer over the games port, the review checklist behind a port.</summary>
|
||||
private static void AddImport(IServiceCollection services)
|
||||
{
|
||||
|
||||
@@ -21,6 +21,9 @@
|
||||
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||
<!-- NFR-9: Per-Monitor V2. Declared in app.manifest; kept here as the
|
||||
reminder that it is a requirement, not a default. -->
|
||||
<!-- 11_UPDATER (P4 PR-5): Velopack must run before any window exists, so the
|
||||
entry point is Program.Main rather than the generated App.Main. -->
|
||||
<StartupObject>FrameLedger.App.Program</StartupObject>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@@ -51,6 +54,7 @@
|
||||
<PackageReference Include="CommunityToolkit.Mvvm" />
|
||||
<PackageReference Include="ScottPlot.WPF" />
|
||||
<PackageReference Include="H.NotifyIcon.Wpf" />
|
||||
<PackageReference Include="Velopack" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" />
|
||||
<PackageReference Include="Serilog" />
|
||||
<PackageReference Include="Serilog.Extensions.Hosting" />
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
<MenuItem Header="{x:Static res:Strings.Menu_Tools_DbMaintenance}" Command="{Binding ViewModel.NotYetCommand}" />
|
||||
</MenuItem>
|
||||
<MenuItem Header="{x:Static res:Strings.Menu_Help}">
|
||||
<MenuItem Header="{x:Static res:Strings.Menu_Help_CheckUpdates}" Command="{Binding ViewModel.NotYetCommand}" />
|
||||
<MenuItem Header="{x:Static res:Strings.Menu_Help_CheckUpdates}" Command="{Binding ViewModel.CheckForUpdatesCommand}" />
|
||||
<MenuItem Header="{x:Static res:Strings.Menu_Help_ReportBug}" Command="{Binding ViewModel.ReportBugCommand}" />
|
||||
<MenuItem Header="{x:Static res:Strings.Menu_Help_Documentation}" Command="{Binding ViewModel.DocumentationCommand}" />
|
||||
<Separator />
|
||||
@@ -75,6 +75,22 @@
|
||||
Content="{x:Static res:Strings.Agent_Banner_Retry}" />
|
||||
</ui:InfoBar>
|
||||
|
||||
<!--
|
||||
11_UPDATER (P4 PR-5): "update downloaded" is in-app and PERSISTENT, with the one action. The button is
|
||||
disabled, not hidden, while a session runs (FR-12) — the body says the update waits for the session's end.
|
||||
-->
|
||||
<ui:InfoBar Margin="12,4,12,0"
|
||||
IsClosable="False"
|
||||
IsOpen="{Binding ViewModel.IsUpdateBannerVisible}"
|
||||
Message="{Binding ViewModel.UpdateBannerBody}"
|
||||
Severity="Informational"
|
||||
Title="{x:Static res:Strings.Update_Banner_Title}">
|
||||
<ui:Button Appearance="Primary"
|
||||
Command="{Binding ViewModel.RestartToUpdateCommand}"
|
||||
Content="{x:Static res:Strings.Update_Banner_Restart}"
|
||||
IsEnabled="{Binding ViewModel.CanRestartToUpdate}" />
|
||||
</ui:InfoBar>
|
||||
|
||||
<!--
|
||||
The safety events (CaptureRefused, SafetyUnhook, CaptureDegraded): persistent, the signal named, never
|
||||
dismissed by a timeout — the one button is the user's acknowledgement (08_UI §Notifications policy, FR-14).
|
||||
|
||||
@@ -235,6 +235,16 @@
|
||||
SelectedValue="{Binding ViewModel.UpdateChannel, Mode=TwoWay}"
|
||||
SelectedValuePath="Value" />
|
||||
</ui:CardControl>
|
||||
<!-- 11_UPDATER §Flow (P4 PR-5): the startup silent check, "if enabled" — the one request rule 8 permits, and the user's to turn off. -->
|
||||
<ui:CardControl Margin="0,4,0,0" Icon="{ui:SymbolIcon CloudArrowDown24}">
|
||||
<ui:CardControl.Header>
|
||||
<StackPanel>
|
||||
<ui:TextBlock FontTypography="BodyStrong" Text="{x:Static res:Strings.Settings_AutoCheck_Label}" />
|
||||
<ui:TextBlock MaxWidth="560" HorizontalAlignment="Left" Appearance="Secondary" Text="{x:Static res:Strings.Settings_AutoCheck_Body}" TextWrapping="Wrap" />
|
||||
</StackPanel>
|
||||
</ui:CardControl.Header>
|
||||
<ui:ToggleSwitch IsChecked="{Binding ViewModel.AutoCheckUpdates, Mode=TwoWay}" />
|
||||
</ui:CardControl>
|
||||
|
||||
<ui:TextBlock FontTypography="Subtitle" Margin="0,20,0,8" Text="{x:Static res:Strings.Settings_Logging_Header}" />
|
||||
<ui:CardControl Margin="0,4,0,0" Icon="{ui:SymbolIcon Bug24}">
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
using FrameLedger.App.Update;
|
||||
using Velopack;
|
||||
|
||||
namespace FrameLedger.App;
|
||||
|
||||
/// <summary>
|
||||
/// The entry point, hand-written so Velopack runs first (<c>11_UPDATER</c>): its install, update and uninstall
|
||||
/// launches re-enter this executable with their own arguments and must be answered before any window, host or
|
||||
/// ledger exists — <see cref="VelopackApp.Run"/> handles them and exits the process; on an ordinary launch it
|
||||
/// returns and the WPF application starts as it always did. <c>StartupObject</c> in the project file names this
|
||||
/// class over the generated <c>App.Main</c>.
|
||||
/// </summary>
|
||||
internal static class Program
|
||||
{
|
||||
[STAThread]
|
||||
private static int Main()
|
||||
{
|
||||
VelopackHooks.Configure(VelopackApp.Build()).Run();
|
||||
var app = new App();
|
||||
app.InitializeComponent();
|
||||
return app.Run();
|
||||
}
|
||||
}
|
||||
@@ -27,6 +27,7 @@ public sealed class AgentConnection : IAgentLink, IAsyncDisposable
|
||||
private PipeClient? _client;
|
||||
private long _rounds;
|
||||
private long _launches;
|
||||
private volatile bool _holdLaunches;
|
||||
|
||||
public AgentConnection(IAgentLauncher launcher, Func<PipeClient> pipes, AgentConnectionOptions options, string appVersion)
|
||||
{
|
||||
@@ -56,6 +57,12 @@ public sealed class AgentConnection : IAgentLink, IAsyncDisposable
|
||||
/// <summary>Skip the wait before the next round (the banner's Retry).</summary>
|
||||
public void RetryNow() => _retryNow.Release();
|
||||
|
||||
/// <summary>True while the update's apply has asked that no Agent be started from beside this executable.</summary>
|
||||
public bool LaunchesHeld => _holdLaunches;
|
||||
|
||||
/// <inheritdoc />
|
||||
public void SetLaunchHold(bool hold) => _holdLaunches = hold;
|
||||
|
||||
/// <summary>Loop until cancelled.</summary>
|
||||
public async Task RunAsync(CancellationToken ct)
|
||||
{
|
||||
@@ -129,7 +136,7 @@ public sealed class AgentConnection : IAgentLink, IAsyncDisposable
|
||||
{
|
||||
Set(AgentConnectionState.Connecting, null, null);
|
||||
PipeClient? client = await TryConnectAsync(ct).ConfigureAwait(false);
|
||||
if (client is null && _launcher.CanLaunch)
|
||||
if (client is null && _launcher.CanLaunch && !_holdLaunches)
|
||||
{
|
||||
Set(AgentConnectionState.Starting, null, null);
|
||||
if (_launcher.TryStart())
|
||||
|
||||
@@ -16,4 +16,10 @@ public interface IAgentLink : IAgentRequests
|
||||
event EventHandler? Changed;
|
||||
|
||||
event EventHandler<AgentEventArgs>? EventReceived;
|
||||
|
||||
/// <summary>
|
||||
/// While held, a round that finds no Agent does not start one beside this executable (P4 PR-5: the update's
|
||||
/// apply asks the Agent to stop and must not have it restarted under the updater). Released on a failed apply.
|
||||
/// </summary>
|
||||
void SetLaunchHold(bool hold);
|
||||
}
|
||||
Generated
+90
@@ -380,6 +380,8 @@ public static class Strings
|
||||
nameof(Settings_Agent_Task_Unknown),
|
||||
nameof(Settings_Appearance_Header),
|
||||
nameof(Settings_Applied),
|
||||
nameof(Settings_AutoCheck_Body),
|
||||
nameof(Settings_AutoCheck_Label),
|
||||
nameof(Settings_Background_Body),
|
||||
nameof(Settings_Background_Label),
|
||||
nameof(Settings_Capture_Header),
|
||||
@@ -507,6 +509,34 @@ public static class Strings
|
||||
nameof(Trend_Metric_MaxGpuTemp),
|
||||
nameof(Trend_Metric_P01Low),
|
||||
nameof(Trend_Metric_P1Low),
|
||||
nameof(Uninstall_DataFolder_Body),
|
||||
nameof(Uninstall_DataFolder_Title),
|
||||
nameof(Update_AgentStillRunning),
|
||||
nameof(Update_Available_Body_Format),
|
||||
nameof(Update_Available_Title_Format),
|
||||
nameof(Update_Banner_Applying_Format),
|
||||
nameof(Update_Banner_Deferred_Format),
|
||||
nameof(Update_Banner_Downloading_Format),
|
||||
nameof(Update_Banner_Ready_Format),
|
||||
nameof(Update_Banner_Restart),
|
||||
nameof(Update_Banner_Title),
|
||||
nameof(Update_Download),
|
||||
nameof(Update_Err_Corrupt),
|
||||
nameof(Update_Err_Offline),
|
||||
nameof(Update_Err_RateLimited),
|
||||
nameof(Update_Err_Server),
|
||||
nameof(Update_Err_Title),
|
||||
nameof(Update_Err_Unknown),
|
||||
nameof(Update_Err404),
|
||||
nameof(Update_HookedRefused),
|
||||
nameof(Update_Later),
|
||||
nameof(Update_Notes_Header),
|
||||
nameof(Update_NotInstalled),
|
||||
nameof(Update_OpenReleases),
|
||||
nameof(Update_Toast_Body_Format),
|
||||
nameof(Update_Toast_Title),
|
||||
nameof(Update_Unsigned_Footer),
|
||||
nameof(Update_UpToDate_Format),
|
||||
nameof(Upscaler_None),
|
||||
nameof(Upscaler_Unknown),
|
||||
];
|
||||
@@ -1219,6 +1249,10 @@ public static class Strings
|
||||
|
||||
public static string Settings_Applied => ResourceManager.GetString(nameof(Settings_Applied), Culture) ?? nameof(Settings_Applied);
|
||||
|
||||
public static string Settings_AutoCheck_Body => ResourceManager.GetString(nameof(Settings_AutoCheck_Body), Culture) ?? nameof(Settings_AutoCheck_Body);
|
||||
|
||||
public static string Settings_AutoCheck_Label => ResourceManager.GetString(nameof(Settings_AutoCheck_Label), Culture) ?? nameof(Settings_AutoCheck_Label);
|
||||
|
||||
public static string Settings_Background_Body => ResourceManager.GetString(nameof(Settings_Background_Body), Culture) ?? nameof(Settings_Background_Body);
|
||||
|
||||
public static string Settings_Background_Label => ResourceManager.GetString(nameof(Settings_Background_Label), Culture) ?? nameof(Settings_Background_Label);
|
||||
@@ -1473,6 +1507,62 @@ public static class Strings
|
||||
|
||||
public static string Trend_Metric_P1Low => ResourceManager.GetString(nameof(Trend_Metric_P1Low), Culture) ?? nameof(Trend_Metric_P1Low);
|
||||
|
||||
public static string Uninstall_DataFolder_Body => ResourceManager.GetString(nameof(Uninstall_DataFolder_Body), Culture) ?? nameof(Uninstall_DataFolder_Body);
|
||||
|
||||
public static string Uninstall_DataFolder_Title => ResourceManager.GetString(nameof(Uninstall_DataFolder_Title), Culture) ?? nameof(Uninstall_DataFolder_Title);
|
||||
|
||||
public static string Update_AgentStillRunning => ResourceManager.GetString(nameof(Update_AgentStillRunning), Culture) ?? nameof(Update_AgentStillRunning);
|
||||
|
||||
public static string Update_Available_Body_Format => ResourceManager.GetString(nameof(Update_Available_Body_Format), Culture) ?? nameof(Update_Available_Body_Format);
|
||||
|
||||
public static string Update_Available_Title_Format => ResourceManager.GetString(nameof(Update_Available_Title_Format), Culture) ?? nameof(Update_Available_Title_Format);
|
||||
|
||||
public static string Update_Banner_Applying_Format => ResourceManager.GetString(nameof(Update_Banner_Applying_Format), Culture) ?? nameof(Update_Banner_Applying_Format);
|
||||
|
||||
public static string Update_Banner_Deferred_Format => ResourceManager.GetString(nameof(Update_Banner_Deferred_Format), Culture) ?? nameof(Update_Banner_Deferred_Format);
|
||||
|
||||
public static string Update_Banner_Downloading_Format => ResourceManager.GetString(nameof(Update_Banner_Downloading_Format), Culture) ?? nameof(Update_Banner_Downloading_Format);
|
||||
|
||||
public static string Update_Banner_Ready_Format => ResourceManager.GetString(nameof(Update_Banner_Ready_Format), Culture) ?? nameof(Update_Banner_Ready_Format);
|
||||
|
||||
public static string Update_Banner_Restart => ResourceManager.GetString(nameof(Update_Banner_Restart), Culture) ?? nameof(Update_Banner_Restart);
|
||||
|
||||
public static string Update_Banner_Title => ResourceManager.GetString(nameof(Update_Banner_Title), Culture) ?? nameof(Update_Banner_Title);
|
||||
|
||||
public static string Update_Download => ResourceManager.GetString(nameof(Update_Download), Culture) ?? nameof(Update_Download);
|
||||
|
||||
public static string Update_Err_Corrupt => ResourceManager.GetString(nameof(Update_Err_Corrupt), Culture) ?? nameof(Update_Err_Corrupt);
|
||||
|
||||
public static string Update_Err_Offline => ResourceManager.GetString(nameof(Update_Err_Offline), Culture) ?? nameof(Update_Err_Offline);
|
||||
|
||||
public static string Update_Err_RateLimited => ResourceManager.GetString(nameof(Update_Err_RateLimited), Culture) ?? nameof(Update_Err_RateLimited);
|
||||
|
||||
public static string Update_Err_Server => ResourceManager.GetString(nameof(Update_Err_Server), Culture) ?? nameof(Update_Err_Server);
|
||||
|
||||
public static string Update_Err_Title => ResourceManager.GetString(nameof(Update_Err_Title), Culture) ?? nameof(Update_Err_Title);
|
||||
|
||||
public static string Update_Err_Unknown => ResourceManager.GetString(nameof(Update_Err_Unknown), Culture) ?? nameof(Update_Err_Unknown);
|
||||
|
||||
public static string Update_Err404 => ResourceManager.GetString(nameof(Update_Err404), Culture) ?? nameof(Update_Err404);
|
||||
|
||||
public static string Update_HookedRefused => ResourceManager.GetString(nameof(Update_HookedRefused), Culture) ?? nameof(Update_HookedRefused);
|
||||
|
||||
public static string Update_Later => ResourceManager.GetString(nameof(Update_Later), Culture) ?? nameof(Update_Later);
|
||||
|
||||
public static string Update_Notes_Header => ResourceManager.GetString(nameof(Update_Notes_Header), Culture) ?? nameof(Update_Notes_Header);
|
||||
|
||||
public static string Update_NotInstalled => ResourceManager.GetString(nameof(Update_NotInstalled), Culture) ?? nameof(Update_NotInstalled);
|
||||
|
||||
public static string Update_OpenReleases => ResourceManager.GetString(nameof(Update_OpenReleases), Culture) ?? nameof(Update_OpenReleases);
|
||||
|
||||
public static string Update_Toast_Body_Format => ResourceManager.GetString(nameof(Update_Toast_Body_Format), Culture) ?? nameof(Update_Toast_Body_Format);
|
||||
|
||||
public static string Update_Toast_Title => ResourceManager.GetString(nameof(Update_Toast_Title), Culture) ?? nameof(Update_Toast_Title);
|
||||
|
||||
public static string Update_Unsigned_Footer => ResourceManager.GetString(nameof(Update_Unsigned_Footer), Culture) ?? nameof(Update_Unsigned_Footer);
|
||||
|
||||
public static string Update_UpToDate_Format => ResourceManager.GetString(nameof(Update_UpToDate_Format), Culture) ?? nameof(Update_UpToDate_Format);
|
||||
|
||||
public static string Upscaler_None => ResourceManager.GetString(nameof(Upscaler_None), Culture) ?? nameof(Upscaler_None);
|
||||
|
||||
public static string Upscaler_Unknown => ResourceManager.GetString(nameof(Upscaler_Unknown), Culture) ?? nameof(Upscaler_Unknown);
|
||||
|
||||
@@ -1714,7 +1714,7 @@
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Settings_UpdateChannel_Body" xml:space="preserve">
|
||||
<value>今すぐ保存されます。アップデーターは後のビルドで追加されます。ゲームがフックされている間は更新されません。</value>
|
||||
<value>安定版のみ、または安定版とプレリリース。見つかった更新はバックグラウンドでダウンロードされ、再起動時にのみ適用されます。ゲームがフックされている間は適用されません。</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Settings_UpdateChannel_Label" xml:space="preserve">
|
||||
@@ -1949,4 +1949,124 @@
|
||||
<value>FrameLedger へようこそ</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Update_UpToDate_Format" xml:space="preserve">
|
||||
<value>FrameLedger {0} は最新バージョンです。</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Update_NotInstalled" xml:space="preserve">
|
||||
<value>このコピーは FrameLedger のインストーラーで導入されていないため、自動更新できません。GitHub からリリースをダウンロードしてください。</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Update_Available_Title_Format" xml:space="preserve">
|
||||
<value>アップデート {0} が利用可能です</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Update_Available_Body_Format" xml:space="preserve">
|
||||
<value>バージョン {0}({1} MB)を今すぐダウンロードできます。適用は FrameLedger の再起動時のみで、ゲームがフックされている間は行われません。</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Update_Notes_Header" xml:space="preserve">
|
||||
<value>変更内容</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Update_Download" xml:space="preserve">
|
||||
<value>ダウンロード</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Update_Later" xml:space="preserve">
|
||||
<value>後で</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Update_Unsigned_Footer" xml:space="preserve">
|
||||
<value>リリースはコード署名されていないため、SmartScreen が警告する場合があります。各リリースの SHA-256 チェックサムはリリースと一緒に公開されています。</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Update_Err_Title" xml:space="preserve">
|
||||
<value>更新の確認に失敗しました</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Update_Err404" xml:space="preserve">
|
||||
<value>リリースフィードが見つかりません。リポジトリが移動した可能性があります。</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Update_Err_RateLimited" xml:space="preserve">
|
||||
<value>GitHub のレート制限に達しました。匿名の確認は 1 時間に 60 回までです。約 1 時間後にもう一度お試しください。</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Update_Err_Server" xml:space="preserve">
|
||||
<value>GitHub に問題が発生しています。後でもう一度お試しください。</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Update_Err_Offline" xml:space="preserve">
|
||||
<value>GitHub に接続できませんでした。ネットワークがない、DNS の失敗、またはタイムアウトです。</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Update_Err_Corrupt" xml:space="preserve">
|
||||
<value>ダウンロードしたパッケージのチェックサムが一致せず、破棄されました。もう一度お試しください。2 回続く場合はバグを報告してください。</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Update_Err_Unknown" xml:space="preserve">
|
||||
<value>FrameLedger が認識できない理由で更新の確認に失敗しました。詳細はログにあります。</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Update_OpenReleases" xml:space="preserve">
|
||||
<value>リリースページを開く</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Update_Banner_Title" xml:space="preserve">
|
||||
<value>アップデート</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Update_Banner_Downloading_Format" xml:space="preserve">
|
||||
<value>バージョン {0} をダウンロード中… {1}%</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Update_Banner_Ready_Format" xml:space="preserve">
|
||||
<value>バージョン {0} のダウンロードと検証が完了しました。FrameLedger を再起動して適用してください。Agent は先に停止し、その後再び起動します。</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Update_Banner_Deferred_Format" xml:space="preserve">
|
||||
<value>バージョン {0} のダウンロードが完了しました。セッションが実行中のため、適用はセッション終了後になります。そのときに再起動してください。</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Update_Banner_Applying_Format" xml:space="preserve">
|
||||
<value>バージョン {0} を適用しています。Agent を停止してから FrameLedger を再起動します…</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Update_Banner_Restart" xml:space="preserve">
|
||||
<value>再起動して更新</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Update_HookedRefused" xml:space="preserve">
|
||||
<value>セッションが実行中です。ゲームがフックまたは記録されている間、FrameLedger は更新しません。更新はセッション終了後に適用されます。</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Update_AgentStillRunning" xml:space="preserve">
|
||||
<value>Agent が時間内に停止しなかったため、何も適用されませんでした。しばらくしてからもう一度お試しください。</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Update_Toast_Title" xml:space="preserve">
|
||||
<value>アップデートがあります</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Update_Toast_Body_Format" xml:space="preserve">
|
||||
<value>FrameLedger {0} をバックグラウンドでダウンロードしています。適用は再起動時のみです。</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Settings_AutoCheck_Label" xml:space="preserve">
|
||||
<value>起動時に更新を確認する</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Settings_AutoCheck_Body" xml:space="preserve">
|
||||
<value>起動の数秒後に GitHub Releases へ 1 回だけ要求します(インストール済みのコピーのみ)。見つかった更新はバックグラウンドでダウンロードされ、再起動しない限り適用されません。</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Uninstall_DataFolder_Title" xml:space="preserve">
|
||||
<value>FrameLedger のデータを削除しますか?</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Uninstall_DataFolder_Body" xml:space="preserve">
|
||||
<value>データフォルダー(%LOCALAPPDATA%\FrameLedger:ライブラリ、すべてのセッション、ログ、設定)も削除しますか?後でインストールするために残す場合は「いいえ」を選んでください。</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
</root>
|
||||
@@ -1291,7 +1291,7 @@
|
||||
<value>Start FrameLedger with Windows</value>
|
||||
</data>
|
||||
<data name="Settings_UpdateChannel_Body" xml:space="preserve">
|
||||
<value>Stored now; the updater arrives in a later build. Updates never apply while a game is hooked.</value>
|
||||
<value>Stable, or stable plus pre-releases. A found update downloads in the background and is applied only when you restart — never while a game is hooked.</value>
|
||||
</data>
|
||||
<data name="Settings_UpdateChannel_Label" xml:space="preserve">
|
||||
<value>Channel</value>
|
||||
@@ -1467,4 +1467,94 @@
|
||||
<data name="FirstRun_Title" xml:space="preserve">
|
||||
<value>Welcome to FrameLedger</value>
|
||||
</data>
|
||||
<data name="Update_UpToDate_Format" xml:space="preserve">
|
||||
<value>FrameLedger {0} is the latest version.</value>
|
||||
</data>
|
||||
<data name="Update_NotInstalled" xml:space="preserve">
|
||||
<value>This copy was not set up by the FrameLedger installer, so it cannot update itself. Download releases from GitHub.</value>
|
||||
</data>
|
||||
<data name="Update_Available_Title_Format" xml:space="preserve">
|
||||
<value>Update {0} is available</value>
|
||||
</data>
|
||||
<data name="Update_Available_Body_Format" xml:space="preserve">
|
||||
<value>Version {0} ({1} MB) can be downloaded now. It is applied only when you restart FrameLedger, and never while a game is hooked.</value>
|
||||
</data>
|
||||
<data name="Update_Notes_Header" xml:space="preserve">
|
||||
<value>What changed</value>
|
||||
</data>
|
||||
<data name="Update_Download" xml:space="preserve">
|
||||
<value>Download</value>
|
||||
</data>
|
||||
<data name="Update_Later" xml:space="preserve">
|
||||
<value>Later</value>
|
||||
</data>
|
||||
<data name="Update_Unsigned_Footer" xml:space="preserve">
|
||||
<value>Releases are not code-signed, so SmartScreen may warn. The SHA-256 checksums of every release are published beside it.</value>
|
||||
</data>
|
||||
<data name="Update_Err_Title" xml:space="preserve">
|
||||
<value>Update check failed</value>
|
||||
</data>
|
||||
<data name="Update_Err404" xml:space="preserve">
|
||||
<value>No release feed found. The repository may have moved.</value>
|
||||
</data>
|
||||
<data name="Update_Err_RateLimited" xml:space="preserve">
|
||||
<value>GitHub rate limit reached. Anonymous checks allow 60 requests an hour; try again in about an hour.</value>
|
||||
</data>
|
||||
<data name="Update_Err_Server" xml:space="preserve">
|
||||
<value>GitHub is having trouble. Try again later.</value>
|
||||
</data>
|
||||
<data name="Update_Err_Offline" xml:space="preserve">
|
||||
<value>GitHub could not be reached: no network, a DNS failure, or a timeout.</value>
|
||||
</data>
|
||||
<data name="Update_Err_Corrupt" xml:space="preserve">
|
||||
<value>The downloaded package failed its checksum and was discarded. Try again; if it happens twice, report a bug.</value>
|
||||
</data>
|
||||
<data name="Update_Err_Unknown" xml:space="preserve">
|
||||
<value>The update check failed for a reason FrameLedger does not recognise. The details are in the log.</value>
|
||||
</data>
|
||||
<data name="Update_OpenReleases" xml:space="preserve">
|
||||
<value>Open releases page</value>
|
||||
</data>
|
||||
<data name="Update_Banner_Title" xml:space="preserve">
|
||||
<value>Update</value>
|
||||
</data>
|
||||
<data name="Update_Banner_Downloading_Format" xml:space="preserve">
|
||||
<value>Downloading version {0}… {1}%</value>
|
||||
</data>
|
||||
<data name="Update_Banner_Ready_Format" xml:space="preserve">
|
||||
<value>Version {0} is downloaded and verified. Restart FrameLedger to apply it — the Agent is stopped first and started again afterwards.</value>
|
||||
</data>
|
||||
<data name="Update_Banner_Deferred_Format" xml:space="preserve">
|
||||
<value>Version {0} is downloaded. A session is running, so it is applied only after the session ends — restart then.</value>
|
||||
</data>
|
||||
<data name="Update_Banner_Applying_Format" xml:space="preserve">
|
||||
<value>Applying version {0}: stopping the Agent, then restarting FrameLedger…</value>
|
||||
</data>
|
||||
<data name="Update_Banner_Restart" xml:space="preserve">
|
||||
<value>Restart to update</value>
|
||||
</data>
|
||||
<data name="Update_HookedRefused" xml:space="preserve">
|
||||
<value>A session is running. FrameLedger does not update while a game is hooked or recorded; the update is applied after the session ends.</value>
|
||||
</data>
|
||||
<data name="Update_AgentStillRunning" xml:space="preserve">
|
||||
<value>The Agent did not stop in time, so nothing was applied. Try again in a moment.</value>
|
||||
</data>
|
||||
<data name="Update_Toast_Title" xml:space="preserve">
|
||||
<value>Update available</value>
|
||||
</data>
|
||||
<data name="Update_Toast_Body_Format" xml:space="preserve">
|
||||
<value>FrameLedger {0} is downloading in the background. It is applied only when you restart.</value>
|
||||
</data>
|
||||
<data name="Settings_AutoCheck_Label" xml:space="preserve">
|
||||
<value>Check for updates at startup</value>
|
||||
</data>
|
||||
<data name="Settings_AutoCheck_Body" xml:space="preserve">
|
||||
<value>One request to GitHub Releases a few seconds after start, only for an installed copy. A found update downloads in the background; nothing is applied without your restart.</value>
|
||||
</data>
|
||||
<data name="Uninstall_DataFolder_Title" xml:space="preserve">
|
||||
<value>Remove FrameLedger data?</value>
|
||||
</data>
|
||||
<data name="Uninstall_DataFolder_Body" xml:space="preserve">
|
||||
<value>Also delete the data folder (%LOCALAPPDATA%\FrameLedger: your library, every session, logs and settings)? Choose No to keep it for a later install.</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -1286,7 +1286,7 @@
|
||||
<value>Khởi động FrameLedger cùng Windows</value>
|
||||
</data>
|
||||
<data name="Settings_UpdateChannel_Body" xml:space="preserve">
|
||||
<value>Lưu ngay; trình cập nhật sẽ có ở bản sau. Không bao giờ cập nhật khi game đang được hook.</value>
|
||||
<value>Ổn định, hoặc ổn định kèm bản tiền phát hành. Bản cập nhật tìm thấy sẽ tải ở nền và chỉ được áp dụng khi bạn khởi động lại — không bao giờ khi game đang được hook.</value>
|
||||
</data>
|
||||
<data name="Settings_UpdateChannel_Label" xml:space="preserve">
|
||||
<value>Kênh</value>
|
||||
@@ -1462,4 +1462,94 @@
|
||||
<data name="FirstRun_Title" xml:space="preserve">
|
||||
<value>Chào mừng đến với FrameLedger</value>
|
||||
</data>
|
||||
<data name="Update_UpToDate_Format" xml:space="preserve">
|
||||
<value>FrameLedger {0} đã là phiên bản mới nhất.</value>
|
||||
</data>
|
||||
<data name="Update_NotInstalled" xml:space="preserve">
|
||||
<value>Bản này không được cài bằng trình cài đặt FrameLedger nên không tự cập nhật được. Hãy tải bản phát hành từ GitHub.</value>
|
||||
</data>
|
||||
<data name="Update_Available_Title_Format" xml:space="preserve">
|
||||
<value>Có bản cập nhật {0}</value>
|
||||
</data>
|
||||
<data name="Update_Available_Body_Format" xml:space="preserve">
|
||||
<value>Có thể tải phiên bản {0} ({1} MB) ngay bây giờ. Bản cập nhật chỉ được áp dụng khi bạn khởi động lại FrameLedger, và không bao giờ khi game đang được hook.</value>
|
||||
</data>
|
||||
<data name="Update_Notes_Header" xml:space="preserve">
|
||||
<value>Thay đổi</value>
|
||||
</data>
|
||||
<data name="Update_Download" xml:space="preserve">
|
||||
<value>Tải về</value>
|
||||
</data>
|
||||
<data name="Update_Later" xml:space="preserve">
|
||||
<value>Để sau</value>
|
||||
</data>
|
||||
<data name="Update_Unsigned_Footer" xml:space="preserve">
|
||||
<value>Bản phát hành không được ký mã nên SmartScreen có thể cảnh báo. Checksum SHA-256 của mỗi bản phát hành được công bố kèm theo.</value>
|
||||
</data>
|
||||
<data name="Update_Err_Title" xml:space="preserve">
|
||||
<value>Kiểm tra cập nhật thất bại</value>
|
||||
</data>
|
||||
<data name="Update_Err404" xml:space="preserve">
|
||||
<value>Không tìm thấy nguồn phát hành. Kho mã có thể đã chuyển đi.</value>
|
||||
</data>
|
||||
<data name="Update_Err_RateLimited" xml:space="preserve">
|
||||
<value>Đã chạm giới hạn tần suất của GitHub. Kiểm tra ẩn danh cho phép 60 yêu cầu mỗi giờ; hãy thử lại sau khoảng một giờ.</value>
|
||||
</data>
|
||||
<data name="Update_Err_Server" xml:space="preserve">
|
||||
<value>GitHub đang gặp sự cố. Hãy thử lại sau.</value>
|
||||
</data>
|
||||
<data name="Update_Err_Offline" xml:space="preserve">
|
||||
<value>Không kết nối được GitHub: không có mạng, lỗi DNS, hoặc hết thời gian chờ.</value>
|
||||
</data>
|
||||
<data name="Update_Err_Corrupt" xml:space="preserve">
|
||||
<value>Gói tải về không khớp checksum và đã bị loại bỏ. Hãy thử lại; nếu lặp lại lần nữa, hãy báo lỗi.</value>
|
||||
</data>
|
||||
<data name="Update_Err_Unknown" xml:space="preserve">
|
||||
<value>Kiểm tra cập nhật thất bại vì lý do FrameLedger không nhận ra. Chi tiết nằm trong log.</value>
|
||||
</data>
|
||||
<data name="Update_OpenReleases" xml:space="preserve">
|
||||
<value>Mở trang phát hành</value>
|
||||
</data>
|
||||
<data name="Update_Banner_Title" xml:space="preserve">
|
||||
<value>Cập nhật</value>
|
||||
</data>
|
||||
<data name="Update_Banner_Downloading_Format" xml:space="preserve">
|
||||
<value>Đang tải phiên bản {0}… {1}%</value>
|
||||
</data>
|
||||
<data name="Update_Banner_Ready_Format" xml:space="preserve">
|
||||
<value>Phiên bản {0} đã tải xong và được xác minh. Khởi động lại FrameLedger để áp dụng — Agent sẽ được dừng trước và khởi động lại sau đó.</value>
|
||||
</data>
|
||||
<data name="Update_Banner_Deferred_Format" xml:space="preserve">
|
||||
<value>Phiên bản {0} đã tải xong. Đang có phiên chạy nên bản cập nhật chỉ được áp dụng sau khi phiên kết thúc — hãy khởi động lại khi đó.</value>
|
||||
</data>
|
||||
<data name="Update_Banner_Applying_Format" xml:space="preserve">
|
||||
<value>Đang áp dụng phiên bản {0}: dừng Agent, rồi khởi động lại FrameLedger…</value>
|
||||
</data>
|
||||
<data name="Update_Banner_Restart" xml:space="preserve">
|
||||
<value>Khởi động lại để cập nhật</value>
|
||||
</data>
|
||||
<data name="Update_HookedRefused" xml:space="preserve">
|
||||
<value>Đang có phiên chạy. FrameLedger không cập nhật khi game đang được hook hoặc ghi; bản cập nhật sẽ được áp dụng sau khi phiên kết thúc.</value>
|
||||
</data>
|
||||
<data name="Update_AgentStillRunning" xml:space="preserve">
|
||||
<value>Agent không dừng kịp thời nên chưa áp dụng gì. Hãy thử lại sau giây lát.</value>
|
||||
</data>
|
||||
<data name="Update_Toast_Title" xml:space="preserve">
|
||||
<value>Có bản cập nhật</value>
|
||||
</data>
|
||||
<data name="Update_Toast_Body_Format" xml:space="preserve">
|
||||
<value>FrameLedger {0} đang được tải ở nền. Chỉ áp dụng khi bạn khởi động lại.</value>
|
||||
</data>
|
||||
<data name="Settings_AutoCheck_Label" xml:space="preserve">
|
||||
<value>Kiểm tra cập nhật khi khởi động</value>
|
||||
</data>
|
||||
<data name="Settings_AutoCheck_Body" xml:space="preserve">
|
||||
<value>Một yêu cầu tới GitHub Releases vài giây sau khi khởi động, chỉ với bản đã cài đặt. Bản cập nhật tìm thấy sẽ tải ở nền; không có gì được áp dụng nếu bạn không khởi động lại.</value>
|
||||
</data>
|
||||
<data name="Uninstall_DataFolder_Title" xml:space="preserve">
|
||||
<value>Xoá dữ liệu FrameLedger?</value>
|
||||
</data>
|
||||
<data name="Uninstall_DataFolder_Body" xml:space="preserve">
|
||||
<value>Xoá luôn thư mục dữ liệu (%LOCALAPPDATA%\FrameLedger: thư viện, mọi phiên, log và cài đặt)? Chọn Không để giữ lại cho lần cài sau.</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -0,0 +1,24 @@
|
||||
using System.Net.Http;
|
||||
using FrameLedger.App.Services;
|
||||
using Velopack.Sources;
|
||||
|
||||
namespace FrameLedger.App.Update;
|
||||
|
||||
/// <summary>
|
||||
/// Velopack's downloader with this product's <c>User-Agent</c> (<c>11_UPDATER</c>: <c>FrameLedger/{version}</c>) in
|
||||
/// place of its own <c>Velopack/x.y.z</c>, which is a read-only static there. Nothing else changes: the GitHub source
|
||||
/// adds no <c>Authorization</c> header for an empty token (measured on 1.2.0), so the request carries the UA and
|
||||
/// GitHub's own <c>Accept</c>, and nothing that identifies the user.
|
||||
/// </summary>
|
||||
public sealed class FrameLedgerFileDownloader : HttpClientFileDownloader
|
||||
{
|
||||
public static string UserAgentValue => "FrameLedger/" + UiIdentity.Version;
|
||||
|
||||
protected override HttpClient CreateHttpClient(IDictionary<string, string>? headers, double timeout)
|
||||
{
|
||||
HttpClient client = base.CreateHttpClient(headers, timeout);
|
||||
client.DefaultRequestHeaders.UserAgent.Clear();
|
||||
_ = client.DefaultRequestHeaders.UserAgent.TryParseAdd(UserAgentValue);
|
||||
return client;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
namespace FrameLedger.App.Update;
|
||||
|
||||
/// <summary>
|
||||
/// The updater's port (<c>11_UPDATER</c>): what the flow needs from Velopack and nothing it does not, so the flow is
|
||||
/// tested without a feed. <see cref="VelopackUpdateClient"/> is the one implementation; every failure it reports
|
||||
/// is an <see cref="UpdateException"/> carrying the dialog's row.
|
||||
/// </summary>
|
||||
public interface IUpdateClient
|
||||
{
|
||||
/// <summary>True for a copy the installer laid down; a build run from <c>bin/</c> cannot update itself and says so.</summary>
|
||||
bool IsInstalled { get; }
|
||||
|
||||
/// <summary>The installed version as the package manifest states it, or null when not installed.</summary>
|
||||
string? CurrentVersion { get; }
|
||||
|
||||
/// <summary>One feed request; null when the installed version is current.</summary>
|
||||
/// <exception cref="UpdateException">The feed could not be read.</exception>
|
||||
Task<UpdateCandidate?> CheckAsync(bool includePrereleases, CancellationToken ct = default);
|
||||
|
||||
/// <summary>The package into Velopack's staging directory, verified; <paramref name="progress"/> in percent.</summary>
|
||||
/// <exception cref="UpdateException">The download failed or the checksum did not match.</exception>
|
||||
Task DownloadAsync(UpdateCandidate candidate, IProgress<int>? progress, CancellationToken ct = default);
|
||||
|
||||
/// <summary>Hand the downloaded package to the updater, which waits for this process to exit, applies, and restarts the App.</summary>
|
||||
void ApplyOnExit(UpdateCandidate candidate);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
namespace FrameLedger.App.Update;
|
||||
|
||||
/// <summary>The manual check's dialogs (<c>11_UPDATER</c> §Flow, "Manual check"), behind an interface so the flow is tested without a window.</summary>
|
||||
public interface IUpdatePrompts
|
||||
{
|
||||
/// <summary>The release found, its notes, the unsigned-release footer; true when the user chose to download it.</summary>
|
||||
Task<bool> OfferAsync(UpdateCandidate candidate, CancellationToken ct = default);
|
||||
|
||||
Task UpToDateAsync(string version, CancellationToken ct = default);
|
||||
|
||||
/// <summary>A copy the installer did not lay down cannot update itself.</summary>
|
||||
Task NotInstalledAsync(CancellationToken ct = default);
|
||||
|
||||
/// <summary>The mapped dialog for the row, with its extra action where the table names one.</summary>
|
||||
Task FailedAsync(UpdateFailure failure, CancellationToken ct = default);
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
namespace FrameLedger.App.Update;
|
||||
|
||||
/// <summary>
|
||||
/// The uninstall hook's decisions (<c>12_BUILD</c> §Publish & package: "uninstalled → unregister the layer, remove
|
||||
/// the scheduled task, ask about the data folder"), over delegates so a test runs it without a pipe, a registry, a
|
||||
/// Task Scheduler or a data folder. Every step is independent: a failure in one is logged and the next still
|
||||
/// runs, and the data folder is deleted only on an explicit yes — a question that goes unanswered inside
|
||||
/// Velopack's 30 s budget leaves the folder where it is.
|
||||
/// </summary>
|
||||
public sealed class UninstallHook(
|
||||
Func<bool> stopAgent,
|
||||
Func<bool> unregisterLayer,
|
||||
Func<bool> removeTask,
|
||||
Func<bool> askDeleteData,
|
||||
Action deleteData,
|
||||
Action<string> log)
|
||||
{
|
||||
public UninstallOutcome Run()
|
||||
{
|
||||
bool agent = Step("agent shutdown", stopAgent);
|
||||
bool layer = Step("vulkan layer unregister", unregisterLayer);
|
||||
bool task = Step("logon task remove", removeTask);
|
||||
bool asked = false;
|
||||
bool deleted = false;
|
||||
if (Step("data folder question", () =>
|
||||
{
|
||||
asked = true;
|
||||
return askDeleteData();
|
||||
}))
|
||||
{
|
||||
deleted = Step("data folder delete", () =>
|
||||
{
|
||||
deleteData();
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
var outcome = new UninstallOutcome(agent, layer, task, asked, deleted);
|
||||
log("uninstall: " + outcome);
|
||||
return outcome;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// True when neither directory contains the other. The data folder is deleted only then: an install living inside
|
||||
/// it (a package id equal to the data folder's name — Velopack installs to <c>%LOCALAPPDATA%\<packId></c>) would
|
||||
/// have the delete remove the running install, and the question could not honestly be asked.
|
||||
/// </summary>
|
||||
public static bool AreSeparate(string dataDirectory, string installDirectory)
|
||||
{
|
||||
ArgumentException.ThrowIfNullOrWhiteSpace(dataDirectory);
|
||||
ArgumentException.ThrowIfNullOrWhiteSpace(installDirectory);
|
||||
string data = Normalise(dataDirectory);
|
||||
string install = Normalise(installDirectory);
|
||||
return !data.StartsWith(install, StringComparison.OrdinalIgnoreCase) && !install.StartsWith(data, StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
private static string Normalise(string directory) =>
|
||||
System.IO.Path.TrimEndingDirectorySeparator(System.IO.Path.GetFullPath(directory)) + System.IO.Path.DirectorySeparatorChar;
|
||||
|
||||
private bool Step(string name, Func<bool> action)
|
||||
{
|
||||
try
|
||||
{
|
||||
bool done = action();
|
||||
log($"uninstall: {name}: {(done ? "done" : "nothing to do")}");
|
||||
return done;
|
||||
}
|
||||
catch (Exception ex) when (ex is not OutOfMemoryException)
|
||||
{
|
||||
log($"uninstall: {name} failed: {ex.GetType().Name}: {ex.Message}");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
namespace FrameLedger.App.Update;
|
||||
|
||||
/// <summary>What the uninstall hook did, for its log line and its test.</summary>
|
||||
public sealed record UninstallOutcome(bool AgentAsked, bool LayerUnregistered, bool TaskRemoved, bool DataAsked, bool DataDeleted);
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace FrameLedger.App.Update;
|
||||
|
||||
/// <summary>A newer release was found (<c>08_UI</c> §Notifications policy: "update available" is a tray toast when the window is off screen).</summary>
|
||||
public sealed class UpdateAvailableEventArgs(string version) : EventArgs
|
||||
{
|
||||
public string Version { get; } = version ?? throw new ArgumentNullException(nameof(version));
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
namespace FrameLedger.App.Update;
|
||||
|
||||
/// <summary>A release newer than the installed one, as the feed describes it: the version, its notes (the GitHub release body, Markdown), the full package's size.</summary>
|
||||
public sealed record UpdateCandidate(string Version, string? NotesMarkdown, long SizeBytes);
|
||||
@@ -0,0 +1,24 @@
|
||||
namespace FrameLedger.App.Update;
|
||||
|
||||
/// <summary>An update step that did not complete, classified for the dialog (<see cref="UpdateFailure"/>); the cause is the inner exception.</summary>
|
||||
public sealed class UpdateException : Exception
|
||||
{
|
||||
public UpdateException()
|
||||
{
|
||||
}
|
||||
|
||||
public UpdateException(string message)
|
||||
: base(message)
|
||||
{
|
||||
}
|
||||
|
||||
public UpdateException(string message, Exception? innerException)
|
||||
: base(message, innerException)
|
||||
{
|
||||
}
|
||||
|
||||
public UpdateException(UpdateFailure failure, string message, Exception? innerException)
|
||||
: base(message, innerException) => Failure = failure;
|
||||
|
||||
public UpdateFailure Failure { get; } = UpdateFailure.Unknown;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
namespace FrameLedger.App.Update;
|
||||
|
||||
/// <summary><c>11_UPDATER</c> §Error mapping, one member per row; the dialog text is the matching <c>Update_Err_*</c> string.</summary>
|
||||
public enum UpdateFailure
|
||||
{
|
||||
/// <summary>HTTP 404: no release feed where the client looked.</summary>
|
||||
NotFound = 0,
|
||||
|
||||
/// <summary>HTTP 403 / 429: GitHub's anonymous quota.</summary>
|
||||
RateLimited,
|
||||
|
||||
/// <summary>HTTP 5xx.</summary>
|
||||
Server,
|
||||
|
||||
/// <summary>Timeout, DNS, no network — silent on the startup check.</summary>
|
||||
Offline,
|
||||
|
||||
/// <summary>The downloaded package failed its checksum.</summary>
|
||||
Corrupt,
|
||||
|
||||
/// <summary>Anything else; the exception is logged.</summary>
|
||||
Unknown,
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Net.Sockets;
|
||||
using Velopack.Exceptions;
|
||||
|
||||
namespace FrameLedger.App.Update;
|
||||
|
||||
/// <summary>
|
||||
/// <c>11_UPDATER</c> §Error mapping as a function of the exception Velopack's client threw: the HTTP status when
|
||||
/// there is one (404 → <see cref="UpdateFailure.NotFound"/>, 403/429 → <see cref="UpdateFailure.RateLimited"/>,
|
||||
/// 5xx → <see cref="UpdateFailure.Server"/>), the transport failures → <see cref="UpdateFailure.Offline"/>, a
|
||||
/// checksum → <see cref="UpdateFailure.Corrupt"/>, the rest → <see cref="UpdateFailure.Unknown"/>. Walks the inner
|
||||
/// chain, because the source wraps what its downloader threw.
|
||||
/// </summary>
|
||||
public static class UpdateFailureMapper
|
||||
{
|
||||
public static UpdateFailure Map(Exception exception)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(exception);
|
||||
for (Exception? e = exception; e is not null; e = e.InnerException)
|
||||
{
|
||||
if (Classify(e) is { } failure)
|
||||
{
|
||||
return failure;
|
||||
}
|
||||
}
|
||||
|
||||
return UpdateFailure.Unknown;
|
||||
}
|
||||
|
||||
private static UpdateFailure? Classify(Exception e) => e switch
|
||||
{
|
||||
ChecksumFailedException => UpdateFailure.Corrupt,
|
||||
HttpRequestException { StatusCode: HttpStatusCode.NotFound } => UpdateFailure.NotFound,
|
||||
HttpRequestException { StatusCode: HttpStatusCode.Forbidden or HttpStatusCode.TooManyRequests } => UpdateFailure.RateLimited,
|
||||
HttpRequestException { StatusCode: { } status } when (int)status >= 500 => UpdateFailure.Server,
|
||||
HttpRequestException { StatusCode: null } => UpdateFailure.Offline,
|
||||
HttpRequestException => UpdateFailure.Unknown,
|
||||
TaskCanceledException or TimeoutException or SocketException or IOException => UpdateFailure.Offline,
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
using FrameLedger.App.Services;
|
||||
using FrameLedger.Infrastructure.Startup;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Serilog;
|
||||
|
||||
namespace FrameLedger.App.Update;
|
||||
|
||||
/// <summary>
|
||||
/// The startup leg of <c>11_UPDATER</c> §Flow: the silent check 5 s after the host is up (the spec's "5 s after UI
|
||||
/// idle", measured from start because the shell shows synchronously inside it), and — on the first run after an
|
||||
/// update — the logon task's action path re-validated, because the updater rewrote the install directory
|
||||
/// (<c>LogonTaskState.Stale</c> is the signal; <c>--install-task</c> the repair, this user's own task).
|
||||
/// </summary>
|
||||
internal sealed class UpdateHostedService(UpdateService updates, IMaintenanceState maintenance, IAgentTool tool) : BackgroundService
|
||||
{
|
||||
private static readonly TimeSpan _startupDelay = TimeSpan.FromSeconds(5);
|
||||
|
||||
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (UpdateRestart.Detected)
|
||||
{
|
||||
await RepairTaskAsync(stoppingToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
await Task.Delay(_startupDelay, stoppingToken).ConfigureAwait(false);
|
||||
await updates.CheckSilentlyAsync(stoppingToken).ConfigureAwait(false);
|
||||
}
|
||||
catch (OperationCanceledException) when (stoppingToken.IsCancellationRequested)
|
||||
{
|
||||
}
|
||||
catch (Exception ex) when (ex is not OutOfMemoryException)
|
||||
{
|
||||
Log.Warning(ex, "update: the startup check faulted");
|
||||
}
|
||||
}
|
||||
|
||||
private async Task RepairTaskAsync(CancellationToken ct)
|
||||
{
|
||||
MaintenanceSnapshot snapshot = await maintenance.ReadAsync(ct).ConfigureAwait(false);
|
||||
if (snapshot.Task != LogonTaskState.Stale)
|
||||
{
|
||||
Log.Information("update: restarted after an update; the logon task is {State}", snapshot.Task);
|
||||
return;
|
||||
}
|
||||
|
||||
AgentToolResult result = await tool.RunAsync("--install-task", ct).ConfigureAwait(false);
|
||||
Log.Information("update: restarted after an update; the logon task was stale and --install-task exited {Exit}", result.ExitCode);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Globalization;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using FrameLedger.App.Services;
|
||||
using MessageBox = Wpf.Ui.Controls.MessageBox;
|
||||
using MessageBoxResult = Wpf.Ui.Controls.MessageBoxResult;
|
||||
|
||||
namespace FrameLedger.App.Update;
|
||||
|
||||
/// <summary><see cref="IUpdatePrompts"/> over WPF-UI's <see cref="MessageBox"/>, the way About and the removal confirmation are.</summary>
|
||||
[SuppressMessage("Performance", "CA1863:Use 'CompositeFormat'", Justification = "the format strings are resources that follow the UI culture, which changes at runtime; a cached CompositeFormat would pin the first culture")]
|
||||
public sealed class UpdatePrompts(IUrlOpener urls, BugReportFlow bugReports) : IUpdatePrompts
|
||||
{
|
||||
/// <summary>Where a 404 sends the user: the releases page itself, which is what a moved feed would have changed.</summary>
|
||||
public static Uri ReleasesPage { get; } = new(VelopackUpdateClient.RepositoryUrl + "/releases");
|
||||
|
||||
public async Task<bool> OfferAsync(UpdateCandidate candidate, CancellationToken ct = default)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(candidate);
|
||||
var body = new StackPanel();
|
||||
body.Children.Add(new System.Windows.Controls.TextBlock
|
||||
{
|
||||
Text = string.Format(CultureInfo.CurrentCulture, Strings.Update_Available_Body_Format, candidate.Version, candidate.SizeBytes / (1024 * 1024)),
|
||||
TextWrapping = TextWrapping.Wrap,
|
||||
});
|
||||
if (!string.IsNullOrWhiteSpace(candidate.NotesMarkdown))
|
||||
{
|
||||
body.Children.Add(new System.Windows.Controls.TextBlock { Text = Strings.Update_Notes_Header, FontWeight = FontWeights.SemiBold, Margin = new Thickness(0, 12, 0, 4) });
|
||||
body.Children.Add(new ScrollViewer
|
||||
{
|
||||
MaxHeight = 260,
|
||||
VerticalScrollBarVisibility = ScrollBarVisibility.Auto,
|
||||
Content = new System.Windows.Controls.TextBlock { Text = candidate.NotesMarkdown, TextWrapping = TextWrapping.Wrap },
|
||||
});
|
||||
}
|
||||
|
||||
body.Children.Add(new System.Windows.Controls.TextBlock { Text = Strings.Update_Unsigned_Footer, TextWrapping = TextWrapping.Wrap, Margin = new Thickness(0, 12, 0, 0), Opacity = 0.7 });
|
||||
var box = new MessageBox
|
||||
{
|
||||
Title = string.Format(CultureInfo.CurrentCulture, Strings.Update_Available_Title_Format, candidate.Version),
|
||||
Content = body,
|
||||
PrimaryButtonText = Strings.Update_Download,
|
||||
CloseButtonText = Strings.Update_Later,
|
||||
MaxWidth = 640,
|
||||
};
|
||||
MessageBoxResult result = await box.ShowDialogAsync(cancellationToken: ct).ConfigureAwait(true);
|
||||
return result == MessageBoxResult.Primary;
|
||||
}
|
||||
|
||||
public Task UpToDateAsync(string version, CancellationToken ct = default) =>
|
||||
ShowAsync(Strings.Menu_Help_CheckUpdates, string.Format(CultureInfo.CurrentCulture, Strings.Update_UpToDate_Format, version), ct);
|
||||
|
||||
public Task NotInstalledAsync(CancellationToken ct = default) => ShowAsync(Strings.Menu_Help_CheckUpdates, Strings.Update_NotInstalled, ct);
|
||||
|
||||
/// <summary>The table's extra behaviour: a 404 offers the releases page, an unknown failure offers the bug report.</summary>
|
||||
public async Task FailedAsync(UpdateFailure failure, CancellationToken ct = default)
|
||||
{
|
||||
var box = new MessageBox
|
||||
{
|
||||
Title = Strings.Update_Err_Title,
|
||||
Content = new System.Windows.Controls.TextBlock { Text = Text(failure), TextWrapping = TextWrapping.Wrap },
|
||||
CloseButtonText = Strings.Common_Ok,
|
||||
MaxWidth = 560,
|
||||
};
|
||||
switch (failure)
|
||||
{
|
||||
case UpdateFailure.NotFound:
|
||||
box.PrimaryButtonText = Strings.Update_OpenReleases;
|
||||
break;
|
||||
case UpdateFailure.Unknown:
|
||||
box.PrimaryButtonText = Strings.Menu_Help_ReportBug;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
MessageBoxResult result = await box.ShowDialogAsync(cancellationToken: ct).ConfigureAwait(true);
|
||||
if (result != MessageBoxResult.Primary)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (failure == UpdateFailure.NotFound)
|
||||
{
|
||||
_ = urls.Open(ReleasesPage);
|
||||
}
|
||||
else if (failure == UpdateFailure.Unknown)
|
||||
{
|
||||
_ = await bugReports.RunAsync(ct).ConfigureAwait(true);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>The row's string (<c>11_UPDATER</c> §Error mapping).</summary>
|
||||
public static string Text(UpdateFailure failure) => failure switch
|
||||
{
|
||||
UpdateFailure.NotFound => Strings.Update_Err404,
|
||||
UpdateFailure.RateLimited => Strings.Update_Err_RateLimited,
|
||||
UpdateFailure.Server => Strings.Update_Err_Server,
|
||||
UpdateFailure.Offline => Strings.Update_Err_Offline,
|
||||
UpdateFailure.Corrupt => Strings.Update_Err_Corrupt,
|
||||
_ => Strings.Update_Err_Unknown,
|
||||
};
|
||||
|
||||
private static async Task ShowAsync(string title, string body, CancellationToken ct)
|
||||
{
|
||||
var box = new MessageBox
|
||||
{
|
||||
Title = title,
|
||||
Content = new System.Windows.Controls.TextBlock { Text = body, TextWrapping = TextWrapping.Wrap },
|
||||
CloseButtonText = Strings.Common_Ok,
|
||||
MaxWidth = 560,
|
||||
};
|
||||
await box.ShowDialogAsync(cancellationToken: ct).ConfigureAwait(true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace FrameLedger.App.Update;
|
||||
|
||||
/// <summary>Set by Velopack's restarted hook in <c>Program.Main</c>, read once by <see cref="UpdateHostedService"/>: this process is the first run after an update.</summary>
|
||||
internal static class UpdateRestart
|
||||
{
|
||||
public static bool Detected { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,341 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using FrameLedger.App.Services;
|
||||
using FrameLedger.Application.Settings;
|
||||
using FrameLedger.Infrastructure.Ipc;
|
||||
using FrameLedger.Shared.Ipc;
|
||||
using Serilog;
|
||||
|
||||
namespace FrameLedger.App.Update;
|
||||
|
||||
/// <summary>
|
||||
/// <c>11_UPDATER</c> §Flow over the <see cref="IUpdateClient"/> port: the startup silent check (when the copy is
|
||||
/// installed and <c>update.auto_check</c> is on), the manual check with its dialogs, the background download, and
|
||||
/// the one rule that shapes every step — <b>FR-12: nothing is applied while a session runs.</b> A downloaded
|
||||
/// package is <see cref="UpdateStage.Ready"/> only while the Agent reports no session; otherwise it is
|
||||
/// <see cref="UpdateStage.Deferred"/> and becomes Ready when the last session ends. The apply itself asks the Agent
|
||||
/// to stop first (it outlives the App and holds the Overlay on disk), holds the connection's relaunch, and ends
|
||||
/// the host once the pipe has dropped; Velopack waits for the exit, applies, and restarts the App, which starts
|
||||
/// the Agent beside itself as it always does.
|
||||
/// </summary>
|
||||
public sealed partial class UpdateService : ObservableObject, IDisposable
|
||||
{
|
||||
/// <summary><c>StatusAck.State</c> when no session runs.</summary>
|
||||
private const string _idleState = "idle";
|
||||
|
||||
private static readonly TimeSpan _defaultAgentStopTimeout = TimeSpan.FromSeconds(10);
|
||||
|
||||
private readonly TimeSpan _agentStopTimeout;
|
||||
private readonly IUpdateClient _client;
|
||||
private readonly IAgentLink _agent;
|
||||
private readonly RegisteredSettings _settings;
|
||||
private readonly IUpdatePrompts _prompts;
|
||||
private readonly IShellPresence _shell;
|
||||
private readonly IMessageStrip _strip;
|
||||
private readonly UiThread _ui = new();
|
||||
private readonly HashSet<Guid> _running = [];
|
||||
private UpdateCandidate? _pending;
|
||||
|
||||
[ObservableProperty]
|
||||
private UpdateStage _stage;
|
||||
|
||||
[ObservableProperty]
|
||||
private string? _version;
|
||||
|
||||
[ObservableProperty]
|
||||
private int _percent;
|
||||
|
||||
/// <summary>
|
||||
/// The flow over its ports; subscribes to the Agent link for the session facts FR-12 needs. The last parameter is
|
||||
/// how long the apply waits for the pipe to drop after <c>Shutdown</c> (10 s), overridable as a test's clock.
|
||||
/// </summary>
|
||||
public UpdateService(IUpdateClient client, IAgentLink agent, RegisteredSettings settings, IUpdatePrompts prompts, IShellPresence shell, IMessageStrip strip, TimeSpan? agentStopTimeout = null)
|
||||
{
|
||||
_agentStopTimeout = agentStopTimeout ?? _defaultAgentStopTimeout;
|
||||
_client = client ?? throw new ArgumentNullException(nameof(client));
|
||||
_agent = agent ?? throw new ArgumentNullException(nameof(agent));
|
||||
_settings = settings ?? throw new ArgumentNullException(nameof(settings));
|
||||
_prompts = prompts ?? throw new ArgumentNullException(nameof(prompts));
|
||||
_shell = shell ?? throw new ArgumentNullException(nameof(shell));
|
||||
_strip = strip ?? throw new ArgumentNullException(nameof(strip));
|
||||
_agent.Changed += OnAgentChanged;
|
||||
_agent.EventReceived += OnAgentEvent;
|
||||
}
|
||||
|
||||
/// <summary>Raised once per release found, for the tray's toast; the banner follows <see cref="Stage"/>.</summary>
|
||||
public event EventHandler<UpdateAvailableEventArgs>? Available;
|
||||
|
||||
/// <summary>A session runs (hooked or recording): the Agent said so at connect, or a <c>SessionStarted</c> arrived without its <c>SessionCompleted</c>.</summary>
|
||||
public bool IsSessionActive
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_running.Count > 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
StatusAck? status = _agent.Status;
|
||||
return status is not null && (!string.Equals(status.State, _idleState, StringComparison.Ordinal) || status.ActiveSessions.Count > 0);
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_agent.Changed -= OnAgentChanged;
|
||||
_agent.EventReceived -= OnAgentEvent;
|
||||
}
|
||||
|
||||
/// <summary>The startup check: skipped for an uninstalled copy and when the setting is off; every failure is a log line, never a dialog (NFR-10).</summary>
|
||||
public async Task CheckSilentlyAsync(CancellationToken ct = default)
|
||||
{
|
||||
if (!_client.IsInstalled)
|
||||
{
|
||||
Log.Information("update: not an installed copy; the startup check is skipped");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!await _settings.GetBooleanAsync(SettingsRegistry.UpdateAutoCheck, ct).ConfigureAwait(false))
|
||||
{
|
||||
Log.Information("update: the startup check is off (update.auto_check)");
|
||||
return;
|
||||
}
|
||||
|
||||
if (Stage != UpdateStage.Idle)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
UpdateCandidate? candidate = await CheckCoreAsync(ct).ConfigureAwait(false);
|
||||
if (candidate is null)
|
||||
{
|
||||
Log.Information("update: {Version} is current", _client.CurrentVersion);
|
||||
return;
|
||||
}
|
||||
|
||||
await DownloadAsync(candidate, ct).ConfigureAwait(false);
|
||||
}
|
||||
catch (UpdateException ex)
|
||||
{
|
||||
Log.Information("update: the startup check did not complete ({Failure}: {Message})", ex.Failure, ex.Message);
|
||||
Post(() => Stage = UpdateStage.Idle);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Help ▸ Check for updates: the dialogs of <c>11_UPDATER</c> §Flow, "Manual check".</summary>
|
||||
public async Task CheckInteractivelyAsync(CancellationToken ct = default)
|
||||
{
|
||||
if (!_client.IsInstalled)
|
||||
{
|
||||
await _prompts.NotInstalledAsync(ct).ConfigureAwait(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (Stage is not UpdateStage.Idle and not UpdateStage.Available)
|
||||
{
|
||||
// Downloading, Ready or Deferred: the banner already says what is pending.
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
UpdateCandidate? candidate = await CheckCoreAsync(ct).ConfigureAwait(true);
|
||||
if (candidate is null)
|
||||
{
|
||||
await _prompts.UpToDateAsync(_client.CurrentVersion ?? UiIdentity.Version, ct).ConfigureAwait(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (await _prompts.OfferAsync(candidate, ct).ConfigureAwait(true))
|
||||
{
|
||||
await DownloadAsync(candidate, ct).ConfigureAwait(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
Stage = UpdateStage.Idle;
|
||||
}
|
||||
}
|
||||
catch (UpdateException ex)
|
||||
{
|
||||
Log.Warning(ex, "update: the manual check did not complete ({Failure})", ex.Failure);
|
||||
Stage = UpdateStage.Idle;
|
||||
await _prompts.FailedAsync(ex.Failure, ct).ConfigureAwait(true);
|
||||
}
|
||||
catch (Exception ex) when (ex is not OutOfMemoryException && !(ex is OperationCanceledException && ct.IsCancellationRequested))
|
||||
{
|
||||
Log.Error(ex, "update: the manual check faulted");
|
||||
Stage = UpdateStage.Idle;
|
||||
await _prompts.FailedAsync(UpdateFailure.Unknown, ct).ConfigureAwait(true);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The banner's button. FR-12 first: with a session running nothing is applied and the package stays deferred.
|
||||
/// Then <c>Shutdown</c> to the Agent, the relaunch held, the pipe watched until it drops, the updater told to
|
||||
/// wait for this process, and the host ended. An Agent that does not stop in time leaves everything as it was.
|
||||
/// </summary>
|
||||
public async Task RestartToUpdateAsync(CancellationToken ct = default)
|
||||
{
|
||||
UpdateCandidate? pending = _pending;
|
||||
if (pending is null || Stage is not UpdateStage.Ready and not UpdateStage.Deferred)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (IsSessionActive)
|
||||
{
|
||||
Stage = UpdateStage.Deferred;
|
||||
_strip.Warn(Strings.Update_Banner_Title, Strings.Update_HookedRefused);
|
||||
return;
|
||||
}
|
||||
|
||||
Stage = UpdateStage.Applying;
|
||||
_agent.SetLaunchHold(true);
|
||||
if (!await StopAgentAsync(ct).ConfigureAwait(true))
|
||||
{
|
||||
_agent.SetLaunchHold(false);
|
||||
Stage = UpdateStage.Ready;
|
||||
_strip.Warn(Strings.Update_Banner_Title, Strings.Update_AgentStillRunning);
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Log.Information("update: applying {Version} on exit", pending.Version);
|
||||
_client.ApplyOnExit(pending);
|
||||
}
|
||||
catch (Exception ex) when (ex is not OutOfMemoryException)
|
||||
{
|
||||
Log.Error(ex, "update: the updater could not be started; nothing was applied");
|
||||
_agent.SetLaunchHold(false);
|
||||
Stage = UpdateStage.Ready;
|
||||
_strip.Warn(Strings.Update_Banner_Title, Strings.Update_Err_Unknown);
|
||||
return;
|
||||
}
|
||||
|
||||
_shell.Quit();
|
||||
}
|
||||
|
||||
private async Task<UpdateCandidate?> CheckCoreAsync(CancellationToken ct)
|
||||
{
|
||||
Post(() => Stage = UpdateStage.Checking);
|
||||
bool prereleases = string.Equals(await _settings.GetAsync(SettingsRegistry.UpdateChannel, ct).ConfigureAwait(false), "beta", StringComparison.Ordinal);
|
||||
UpdateCandidate? candidate = await _client.CheckAsync(prereleases, ct).ConfigureAwait(false);
|
||||
if (candidate is null)
|
||||
{
|
||||
Post(() => Stage = UpdateStage.Idle);
|
||||
return null;
|
||||
}
|
||||
|
||||
Log.Information("update: {Version} is available ({Size} bytes)", candidate.Version, candidate.SizeBytes);
|
||||
Post(() =>
|
||||
{
|
||||
Version = candidate.Version;
|
||||
Stage = UpdateStage.Available;
|
||||
Available?.Invoke(this, new UpdateAvailableEventArgs(candidate.Version));
|
||||
});
|
||||
return candidate;
|
||||
}
|
||||
|
||||
private async Task DownloadAsync(UpdateCandidate candidate, CancellationToken ct)
|
||||
{
|
||||
Post(() =>
|
||||
{
|
||||
Percent = 0;
|
||||
Stage = UpdateStage.Downloading;
|
||||
});
|
||||
var progress = new PostingProgress(this);
|
||||
try
|
||||
{
|
||||
await _client.DownloadAsync(candidate, progress, ct).ConfigureAwait(false);
|
||||
}
|
||||
catch (UpdateException ex) when (ex.Failure == UpdateFailure.Corrupt)
|
||||
{
|
||||
// 11_UPDATER §Error mapping: a package hash mismatch retries once, then it is the dialog's.
|
||||
Log.Warning("update: {Version} failed its checksum ({Message}); downloading once more", candidate.Version, ex.Message);
|
||||
await _client.DownloadAsync(candidate, progress, ct).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
_pending = candidate;
|
||||
Log.Information("update: {Version} downloaded and verified", candidate.Version);
|
||||
Post(Settle);
|
||||
}
|
||||
|
||||
/// <summary>Ready or Deferred, from whether a session runs right now.</summary>
|
||||
private void Settle()
|
||||
{
|
||||
if (_pending is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (Stage is UpdateStage.Applying)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Stage = IsSessionActive ? UpdateStage.Deferred : UpdateStage.Ready;
|
||||
}
|
||||
|
||||
private async Task<bool> StopAgentAsync(CancellationToken ct)
|
||||
{
|
||||
if (!_agent.IsConnected)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
await _agent.RequestAsync(IpcMessageType.Shutdown, new ShutdownRequest(), ct).ConfigureAwait(true);
|
||||
}
|
||||
catch (Exception ex) when (ex is IpcRequestException or TimeoutException or System.IO.IOException or InvalidOperationException)
|
||||
{
|
||||
Log.Warning(ex, "update: the Agent did not acknowledge Shutdown");
|
||||
}
|
||||
|
||||
DateTimeOffset deadline = DateTimeOffset.UtcNow + _agentStopTimeout;
|
||||
while (_agent.IsConnected)
|
||||
{
|
||||
if (DateTimeOffset.UtcNow >= deadline)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
await Task.Delay(100, ct).ConfigureAwait(true);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void OnAgentChanged(object? sender, EventArgs e) => Post(() =>
|
||||
{
|
||||
_running.Clear();
|
||||
Settle();
|
||||
});
|
||||
|
||||
private void OnAgentEvent(object? sender, AgentEventArgs e) => Post(() =>
|
||||
{
|
||||
switch (e.Envelope.Type)
|
||||
{
|
||||
case IpcMessageType.SessionStarted when IpcCodec.Payload<SessionStartedEvent>(e.Envelope) is { } started:
|
||||
_running.Add(started.SessionGuid);
|
||||
break;
|
||||
case IpcMessageType.SessionCompleted when IpcCodec.Payload<SessionCompletedEvent>(e.Envelope) is { } completed:
|
||||
_running.Remove(completed.SessionGuid);
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
Settle();
|
||||
});
|
||||
|
||||
private void Post(Action action) => _ui.Post(action);
|
||||
|
||||
/// <summary>The download's percent onto the UI thread, in order; <see cref="Progress{T}"/> would queue each report to the thread pool when there is no context.</summary>
|
||||
private sealed class PostingProgress(UpdateService owner) : IProgress<int>
|
||||
{
|
||||
public void Report(int value) => owner.Post(() => owner.Percent = value);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
namespace FrameLedger.App.Update;
|
||||
|
||||
/// <summary>Where the updater is, as the shell's banner shows it (<c>08_UI</c> §Notifications policy: "update downloaded" is a persistent InfoBar).</summary>
|
||||
public enum UpdateStage
|
||||
{
|
||||
/// <summary>Nothing pending: no check yet, the installed version is current, or a check failed.</summary>
|
||||
Idle = 0,
|
||||
|
||||
Checking,
|
||||
|
||||
/// <summary>A newer release was found; the download has not started (the manual check's offer is open).</summary>
|
||||
Available,
|
||||
|
||||
Downloading,
|
||||
|
||||
/// <summary>Downloaded and verified; "Restart to update" is live.</summary>
|
||||
Ready,
|
||||
|
||||
/// <summary>Downloaded, but a session is running (FR-12): offered again when it ends.</summary>
|
||||
Deferred,
|
||||
|
||||
/// <summary>The Agent has been asked to stop and the updater to wait for this process; the host is ending.</summary>
|
||||
Applying,
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.IO;
|
||||
using System.Windows;
|
||||
using FrameLedger.App.Services;
|
||||
using FrameLedger.Infrastructure.Ipc;
|
||||
using FrameLedger.Infrastructure.Startup;
|
||||
using FrameLedger.Infrastructure.Vulkan;
|
||||
using FrameLedger.Shared.Ipc;
|
||||
using Velopack;
|
||||
|
||||
namespace FrameLedger.App.Update;
|
||||
|
||||
/// <summary>
|
||||
/// What runs inside Velopack's own process launches, before <see cref="App"/> exists (<c>Program.Main</c>, first
|
||||
/// line). Install registers nothing machine-wide — the first-run flow offers the Agent's task and the layer's
|
||||
/// registration follows the ledger (<c>12_BUILD</c> §The Vulkan layer is not registered at install time). Uninstall
|
||||
/// is <see cref="UninstallHook"/> over the real pieces. A restart after an update sets <see cref="UpdateRestart"/>
|
||||
/// so the host re-validates the logon task's action path.
|
||||
/// </summary>
|
||||
internal static class VelopackHooks
|
||||
{
|
||||
/// <summary>
|
||||
/// Velopack gives the callback 30 s in all, and the question at the end needs most of them: 1 s to find a pipe
|
||||
/// (none is the common case), 3 s for the ack, 5 s for the Agent's process to leave.
|
||||
/// </summary>
|
||||
private static readonly TimeSpan _connectTimeout = TimeSpan.FromSeconds(1);
|
||||
|
||||
private static readonly TimeSpan _requestTimeout = TimeSpan.FromSeconds(3);
|
||||
|
||||
private static readonly TimeSpan _exitTimeout = TimeSpan.FromSeconds(5);
|
||||
|
||||
public static VelopackApp Configure(VelopackApp app) => app
|
||||
.OnRestarted(static _ => UpdateRestart.Detected = true)
|
||||
.OnBeforeUninstallFastCallback(static _ => BeforeUninstall());
|
||||
|
||||
private static void BeforeUninstall()
|
||||
{
|
||||
string manifest = Path.Combine(VkLayerLaunchEnvironment.DefaultDirectory, VkLayerLaunchEnvironment.ManifestFileName);
|
||||
var hook = new UninstallHook(
|
||||
stopAgent: StopAgent,
|
||||
unregisterLayer: () => new VkLayerRegistration().Unregister(manifest),
|
||||
removeTask: static () => new LogonTask().Remove() is null,
|
||||
askDeleteData: static () => UninstallHook.AreSeparate(UiPaths.DataDirectory, AppContext.BaseDirectory)
|
||||
? System.Windows.MessageBox.Show(Strings.Uninstall_DataFolder_Body, Strings.Uninstall_DataFolder_Title, MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.Yes
|
||||
: throw new InvalidOperationException($"the install ({AppContext.BaseDirectory}) and the data folder ({UiPaths.DataDirectory}) overlap; nothing is deleted"),
|
||||
deleteData: static () => Directory.Delete(UiPaths.DataDirectory, recursive: true),
|
||||
log: Log);
|
||||
hook.Run();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The Agent outlives the App and holds the install directory and the ledger; a <c>Shutdown</c> over the pipe,
|
||||
/// best effort, then a bounded wait for its process to leave — so the uninstaller's file removal and a Yes to the
|
||||
/// data question do not meet an open <c>ledger.db</c>. Nothing is killed.
|
||||
/// </summary>
|
||||
[SuppressMessage("Usage", "VSTHRD002:Avoid problematic synchronous waits", Justification = "Velopack's fast callback is synchronous, runs with no dispatcher, and the process exits when it returns; a bounded wait on a pooled task is the only shape available")]
|
||||
private static bool StopAgent()
|
||||
{
|
||||
Task<bool> ask = Task.Run(static async () =>
|
||||
{
|
||||
var client = new PipeClient();
|
||||
await using (client.ConfigureAwait(false))
|
||||
{
|
||||
await client.ConnectAsync(_connectTimeout).ConfigureAwait(false);
|
||||
await client.RequestEnvelopeAsync(IpcMessageType.Shutdown, new ShutdownRequest(), _requestTimeout).ConfigureAwait(false);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
bool asked;
|
||||
try
|
||||
{
|
||||
asked = ask.Wait(_connectTimeout + _requestTimeout + _connectTimeout) && ask.Result;
|
||||
}
|
||||
catch (AggregateException)
|
||||
{
|
||||
// No Agent listening (the common case: nothing was running), or it dropped the pipe on Shutdown.
|
||||
asked = false;
|
||||
}
|
||||
|
||||
WaitForAgentExit();
|
||||
return asked;
|
||||
}
|
||||
|
||||
private static void WaitForAgentExit()
|
||||
{
|
||||
DateTimeOffset deadline = DateTimeOffset.UtcNow + _exitTimeout;
|
||||
foreach (Process agent in Process.GetProcessesByName("FrameLedger.Agent"))
|
||||
{
|
||||
using (agent)
|
||||
{
|
||||
TimeSpan left = deadline - DateTimeOffset.UtcNow;
|
||||
if (left > TimeSpan.Zero)
|
||||
{
|
||||
try
|
||||
{
|
||||
_ = agent.WaitForExit(left);
|
||||
}
|
||||
catch (Exception ex) when (ex is InvalidOperationException or System.ComponentModel.Win32Exception)
|
||||
{
|
||||
// Gone between the listing and the wait, or not ours to wait on.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Serilog is not configured this early; the hook's own file under <c>logs/</c>, appended, never thrown from.</summary>
|
||||
private static void Log(string line)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!Directory.Exists(UiPaths.DataDirectory))
|
||||
{
|
||||
// Deleted on the user's yes a moment ago; recreating it for a log line would undo their answer.
|
||||
return;
|
||||
}
|
||||
|
||||
Directory.CreateDirectory(UiPaths.Logs);
|
||||
File.AppendAllText(Path.Combine(UiPaths.Logs, "uninstall.log"), $"[{DateTimeOffset.UtcNow:O}] {line}{Environment.NewLine}");
|
||||
}
|
||||
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException)
|
||||
{
|
||||
// The folder may already be gone (the user said yes) — nothing to write to, nothing to do.
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
using FrameLedger.App.Services;
|
||||
using Velopack;
|
||||
using Velopack.Sources;
|
||||
|
||||
namespace FrameLedger.App.Update;
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="IUpdateClient"/> over Velopack's <see cref="UpdateManager"/> and its GitHub source for this repository
|
||||
/// (<c>11_UPDATER</c>): the stable channel is the releases GitHub does not mark pre-release, the beta channel adds the
|
||||
/// ones it does (<c>13_CI_CD</c> §Branch & release policy — <c>vX.Y.Z-beta.N</c>). One manager per check, because
|
||||
/// the channel is a constructor argument there; the <see cref="UpdateInfo"/> a check returned is held for the
|
||||
/// download and the apply that follow it.
|
||||
/// </summary>
|
||||
public sealed class VelopackUpdateClient : IUpdateClient
|
||||
{
|
||||
/// <summary>The one feed (CLAUDE.md rule 8: the GitHub release check is a permitted call).</summary>
|
||||
public const string RepositoryUrl = "https://github.com/poli0981/frameledger";
|
||||
|
||||
private readonly Lock _lock = new();
|
||||
private (UpdateManager Manager, UpdateInfo Info, string Version)? _held;
|
||||
|
||||
public bool IsInstalled => Probe(static m => m.IsInstalled, false);
|
||||
|
||||
public string? CurrentVersion => Probe(static m => m.CurrentVersion?.ToString(), null);
|
||||
|
||||
public async Task<UpdateCandidate?> CheckAsync(bool includePrereleases, CancellationToken ct = default)
|
||||
{
|
||||
ct.ThrowIfCancellationRequested();
|
||||
UpdateManager manager = Create(includePrereleases);
|
||||
try
|
||||
{
|
||||
UpdateInfo? info = await manager.CheckForUpdatesAsync().ConfigureAwait(false);
|
||||
if (info is null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
VelopackAsset target = info.TargetFullRelease;
|
||||
string version = target.Version.ToString();
|
||||
lock (_lock)
|
||||
{
|
||||
_held = (manager, info, version);
|
||||
}
|
||||
|
||||
return new UpdateCandidate(version, target.NotesMarkdown, target.Size);
|
||||
}
|
||||
catch (Exception ex) when (IsFailure(ex, ct))
|
||||
{
|
||||
throw new UpdateException(UpdateFailureMapper.Map(ex), ex.Message, ex);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task DownloadAsync(UpdateCandidate candidate, IProgress<int>? progress, CancellationToken ct = default)
|
||||
{
|
||||
(UpdateManager manager, UpdateInfo info) = Held(candidate);
|
||||
try
|
||||
{
|
||||
await manager.DownloadUpdatesAsync(info, p => progress?.Report(p), ct).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex) when (IsFailure(ex, ct))
|
||||
{
|
||||
throw new UpdateException(UpdateFailureMapper.Map(ex), ex.Message, ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Velopack's updater waits up to 60 s for this process to exit; the caller ends the host right after.</summary>
|
||||
public void ApplyOnExit(UpdateCandidate candidate)
|
||||
{
|
||||
(UpdateManager manager, UpdateInfo info) = Held(candidate);
|
||||
manager.WaitExitThenApplyUpdates(info.TargetFullRelease, silent: false, restart: true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Everything but the caller's own cancellation is a failure to classify — including the
|
||||
/// <see cref="TaskCanceledException"/> an HttpClient timeout throws, which is the Offline row, not a cancel.
|
||||
/// </summary>
|
||||
private static bool IsFailure(Exception ex, CancellationToken ct) =>
|
||||
ex is not OutOfMemoryException && !(ex is OperationCanceledException && ct.IsCancellationRequested);
|
||||
|
||||
private static UpdateManager Create(bool includePrereleases)
|
||||
{
|
||||
return new UpdateManager(new GithubSource(RepositoryUrl, string.Empty, includePrereleases, new FrameLedgerFileDownloader()));
|
||||
}
|
||||
|
||||
/// <summary>A manager is cheap to build and never touches the network until asked; the two properties read its locator only.</summary>
|
||||
private static T Probe<T>(Func<UpdateManager, T> read, T fallback)
|
||||
{
|
||||
try
|
||||
{
|
||||
return read(Create(false));
|
||||
}
|
||||
catch (Exception ex) when (ex is not OutOfMemoryException)
|
||||
{
|
||||
Serilog.Log.Debug(ex, "update: the locator could not be read");
|
||||
return fallback;
|
||||
}
|
||||
}
|
||||
|
||||
private (UpdateManager Manager, UpdateInfo Info) Held(UpdateCandidate candidate)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(candidate);
|
||||
lock (_lock)
|
||||
{
|
||||
if (_held is { } held && string.Equals(held.Version, candidate.Version, StringComparison.Ordinal))
|
||||
{
|
||||
return (held.Manager, held.Info);
|
||||
}
|
||||
}
|
||||
|
||||
throw new InvalidOperationException("no check returned this candidate");
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using FrameLedger.App.Pages;
|
||||
using FrameLedger.App.Services;
|
||||
using FrameLedger.App.Update;
|
||||
using FrameLedger.Infrastructure.Ipc;
|
||||
using FrameLedger.Shared.Ipc;
|
||||
using Wpf.Ui;
|
||||
@@ -34,7 +35,19 @@ public sealed partial class MainWindowViewModel : ObservableObject, IDisposable
|
||||
[ObservableProperty]
|
||||
private string _agentBannerBody = string.Empty;
|
||||
|
||||
/// <summary>08_UI §Notifications policy: "update downloaded" is in-app and persistent — the banner follows <see cref="UpdateService.Stage"/>.</summary>
|
||||
[ObservableProperty]
|
||||
private bool _isUpdateBannerVisible;
|
||||
|
||||
[ObservableProperty]
|
||||
private string _updateBannerBody = string.Empty;
|
||||
|
||||
/// <summary>FR-12: the button is live only while no session runs; deferred, it stays visible and disabled with the body saying why.</summary>
|
||||
[ObservableProperty]
|
||||
private bool _canRestartToUpdate;
|
||||
|
||||
private readonly AddGameFlow _addGame;
|
||||
private readonly UpdateService _updates;
|
||||
private readonly BugReportFlow _bugReports;
|
||||
private readonly IUrlOpener _urls;
|
||||
private readonly SessionSelection _selection;
|
||||
@@ -43,9 +56,11 @@ public sealed partial class MainWindowViewModel : ObservableObject, IDisposable
|
||||
private readonly ImportLibraryFlow _import;
|
||||
|
||||
public MainWindowViewModel(AgentConnection agent, ISnackbarService snackbar, IShellPresence shell, IPageNavigator navigator, AddGameFlow addGame, SafetyNotices notices,
|
||||
BugReportFlow bugReports, IUrlOpener urls, SessionSelection selection, SessionExportService exports, ISessionSummaryOpener summaries, ImportLibraryFlow import)
|
||||
BugReportFlow bugReports, IUrlOpener urls, SessionSelection selection, SessionExportService exports, ISessionSummaryOpener summaries, ImportLibraryFlow import,
|
||||
UpdateService updates)
|
||||
{
|
||||
Notices = notices ?? throw new ArgumentNullException(nameof(notices));
|
||||
_updates = updates ?? throw new ArgumentNullException(nameof(updates));
|
||||
_import = import ?? throw new ArgumentNullException(nameof(import));
|
||||
_bugReports = bugReports ?? throw new ArgumentNullException(nameof(bugReports));
|
||||
_urls = urls ?? throw new ArgumentNullException(nameof(urls));
|
||||
@@ -58,7 +73,9 @@ public sealed partial class MainWindowViewModel : ObservableObject, IDisposable
|
||||
_navigator = navigator ?? throw new ArgumentNullException(nameof(navigator));
|
||||
_addGame = addGame ?? throw new ArgumentNullException(nameof(addGame));
|
||||
_agent.Changed += OnAgentChanged;
|
||||
_updates.PropertyChanged += OnUpdatesChanged;
|
||||
Refresh();
|
||||
RefreshUpdate();
|
||||
}
|
||||
|
||||
public static string Title => Strings.App_Title;
|
||||
@@ -66,10 +83,39 @@ public sealed partial class MainWindowViewModel : ObservableObject, IDisposable
|
||||
/// <summary>08_UI §Notifications policy: the safety events, as persistent InfoBars above every page — never toasts.</summary>
|
||||
public SafetyNotices Notices { get; }
|
||||
|
||||
public void Dispose() => _agent.Changed -= OnAgentChanged;
|
||||
public void Dispose()
|
||||
{
|
||||
_agent.Changed -= OnAgentChanged;
|
||||
_updates.PropertyChanged -= OnUpdatesChanged;
|
||||
}
|
||||
|
||||
private void OnAgentChanged(object? sender, EventArgs e) => _ui.Post(Refresh);
|
||||
|
||||
private void OnUpdatesChanged(object? sender, PropertyChangedEventArgs e) => RefreshUpdate();
|
||||
|
||||
/// <summary>The banner's three faces: downloading (with the percent), ready (the button live), deferred (FR-12, the button waits).</summary>
|
||||
[SuppressMessage("Performance", "CA1863:Use 'CompositeFormat'", Justification = "the format strings are resources that follow the UI culture, which changes at runtime; a cached CompositeFormat would pin the first culture")]
|
||||
private void RefreshUpdate()
|
||||
{
|
||||
string version = _updates.Version ?? string.Empty;
|
||||
(IsUpdateBannerVisible, UpdateBannerBody, CanRestartToUpdate) = _updates.Stage switch
|
||||
{
|
||||
UpdateStage.Downloading => (true, string.Format(CultureInfo.CurrentCulture, Strings.Update_Banner_Downloading_Format, version, _updates.Percent), false),
|
||||
UpdateStage.Ready => (true, string.Format(CultureInfo.CurrentCulture, Strings.Update_Banner_Ready_Format, version), true),
|
||||
UpdateStage.Deferred => (true, string.Format(CultureInfo.CurrentCulture, Strings.Update_Banner_Deferred_Format, version), false),
|
||||
UpdateStage.Applying => (true, string.Format(CultureInfo.CurrentCulture, Strings.Update_Banner_Applying_Format, version), false),
|
||||
_ => (false, string.Empty, false),
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>Help ▸ Check for updates (P4 PR-5): <c>11_UPDATER</c> §Flow, "Manual check".</summary>
|
||||
[RelayCommand]
|
||||
private Task CheckForUpdatesAsync() => _updates.CheckInteractivelyAsync();
|
||||
|
||||
/// <summary>The banner's button: the Agent stopped, the updater told to wait for this process, the host ended (FR-12 is checked again inside).</summary>
|
||||
[RelayCommand]
|
||||
private Task RestartToUpdateAsync() => _updates.RestartToUpdateAsync();
|
||||
|
||||
private void Refresh()
|
||||
{
|
||||
(string text, ControlAppearance appearance) = AgentStatusPresentation.Pill(_agent.State);
|
||||
|
||||
@@ -75,6 +75,10 @@ public sealed partial class SettingsViewModel : ObservableObject
|
||||
[ObservableProperty]
|
||||
private string _updateChannel = "stable";
|
||||
|
||||
/// <summary><c>11_UPDATER</c> §Flow: the startup silent check, on by default (P4 PR-5).</summary>
|
||||
[ObservableProperty]
|
||||
private bool _autoCheckUpdates = true;
|
||||
|
||||
[ObservableProperty]
|
||||
private bool _logDebug;
|
||||
|
||||
@@ -268,6 +272,8 @@ public sealed partial class SettingsViewModel : ObservableObject
|
||||
|
||||
partial void OnUpdateChannelChanged(string value) => Persist(SettingsRegistry.UpdateChannel, value);
|
||||
|
||||
partial void OnAutoCheckUpdatesChanged(bool value) => Persist(SettingsRegistry.UpdateAutoCheck, value);
|
||||
|
||||
partial void OnStartWithWindowsChanged(bool value)
|
||||
{
|
||||
if (_loading)
|
||||
@@ -329,6 +335,7 @@ public sealed partial class SettingsViewModel : ObservableObject
|
||||
MinimizeToTray = await _settings.GetBooleanAsync(SettingsRegistry.UiMinimizeToTray).ConfigureAwait(true);
|
||||
OnlineMetadata = await _settings.GetBooleanAsync(SettingsRegistry.PrivacyOnlineMetadata).ConfigureAwait(true);
|
||||
UpdateChannel = await _settings.GetAsync(SettingsRegistry.UpdateChannel).ConfigureAwait(true);
|
||||
AutoCheckUpdates = await _settings.GetBooleanAsync(SettingsRegistry.UpdateAutoCheck).ConfigureAwait(true);
|
||||
LogDebug = await _settings.GetBooleanAsync(SettingsRegistry.LogDebug).ConfigureAwait(true);
|
||||
|
||||
// The Run entry is the truth for "start with Windows"; the settings row follows it.
|
||||
|
||||
@@ -4,6 +4,7 @@ using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using FrameLedger.App.Pages;
|
||||
using FrameLedger.App.Services;
|
||||
using FrameLedger.App.Update;
|
||||
using FrameLedger.Infrastructure.Ipc;
|
||||
using FrameLedger.Shared.Ipc;
|
||||
|
||||
@@ -23,6 +24,7 @@ public sealed partial class TrayViewModel : ObservableObject, IDisposable
|
||||
private readonly IShellPresence _shell;
|
||||
private readonly ISessionSummaryOpener _summaries;
|
||||
private readonly IPageNavigator _navigator;
|
||||
private readonly UpdateService _updates;
|
||||
private readonly UiThread _ui = new();
|
||||
private readonly Dictionary<Guid, (int Tier, string Name)> _running = [];
|
||||
|
||||
@@ -35,17 +37,28 @@ public sealed partial class TrayViewModel : ObservableObject, IDisposable
|
||||
[NotifyPropertyChangedFor(nameof(Tooltip))]
|
||||
private bool _isPaused;
|
||||
|
||||
public TrayViewModel(IAgentLink agent, IShellPresence shell, ISessionSummaryOpener summaries, IPageNavigator navigator)
|
||||
public TrayViewModel(IAgentLink agent, IShellPresence shell, ISessionSummaryOpener summaries, IPageNavigator navigator, UpdateService updates)
|
||||
{
|
||||
_agent = agent ?? throw new ArgumentNullException(nameof(agent));
|
||||
_shell = shell ?? throw new ArgumentNullException(nameof(shell));
|
||||
_summaries = summaries ?? throw new ArgumentNullException(nameof(summaries));
|
||||
_navigator = navigator ?? throw new ArgumentNullException(nameof(navigator));
|
||||
_updates = updates ?? throw new ArgumentNullException(nameof(updates));
|
||||
_agent.Changed += OnAgentChanged;
|
||||
_agent.EventReceived += OnAgentEvent;
|
||||
_updates.Available += OnUpdateAvailable;
|
||||
IsPaused = _agent.Status?.Paused ?? false;
|
||||
}
|
||||
|
||||
/// <summary><c>08_UI</c> §Notifications policy: "update available" reaches a minimized app as a balloon; on screen, the shell's banner is the one channel.</summary>
|
||||
private void OnUpdateAvailable(object? sender, UpdateAvailableEventArgs e)
|
||||
{
|
||||
if (!_shell.IsShown)
|
||||
{
|
||||
ToastRequested?.Invoke(this, new TrayToastEventArgs(Strings.Update_Toast_Title, string.Format(CultureInfo.CurrentCulture, Strings.Update_Toast_Body_Format, e.Version), null));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>A balloon to show (the host decides how); never raised while the window is on screen.</summary>
|
||||
public event EventHandler<TrayToastEventArgs>? ToastRequested;
|
||||
|
||||
@@ -69,6 +82,7 @@ public sealed partial class TrayViewModel : ObservableObject, IDisposable
|
||||
{
|
||||
_agent.Changed -= OnAgentChanged;
|
||||
_agent.EventReceived -= OnAgentEvent;
|
||||
_updates.Available -= OnUpdateAvailable;
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
|
||||
@@ -91,7 +91,7 @@ public static class SettingsRegistry
|
||||
AgentReads = true,
|
||||
};
|
||||
|
||||
/// <summary><c>11_UPDATER</c>: the Velopack channel (P4 reads it).</summary>
|
||||
/// <summary><c>11_UPDATER</c>: the release feed's channel — <c>stable</c> is the releases GitHub does not mark pre-release, <c>beta</c> adds the ones it does (P4 PR-5 reads it).</summary>
|
||||
public static readonly SettingDefinition UpdateChannel = new()
|
||||
{
|
||||
Key = "update.channel",
|
||||
@@ -100,6 +100,14 @@ public static class SettingsRegistry
|
||||
Choices = ["stable", "beta"],
|
||||
};
|
||||
|
||||
/// <summary><c>11_UPDATER</c> §Flow: the startup silent check, "if enabled" — on by default, one request to GitHub Releases after start (P4 PR-5).</summary>
|
||||
public static readonly SettingDefinition UpdateAutoCheck = new()
|
||||
{
|
||||
Key = "update.auto_check",
|
||||
Kind = SettingKind.Boolean,
|
||||
Default = "1",
|
||||
};
|
||||
|
||||
/// <summary>CLAUDE.md rule 8: the opt-in store-metadata fetch, off by default.</summary>
|
||||
public static readonly SettingDefinition PrivacyOnlineMetadata = new()
|
||||
{
|
||||
@@ -121,7 +129,7 @@ public static class SettingsRegistry
|
||||
[
|
||||
UiLanguage, UiTheme, UiStartWithWindows, UiMinimizeToTray,
|
||||
CaptureBackground, HookingKillSwitch, CaptureMinSessionSeconds, TelemetryIntervalMs, RetentionRawSessionsPerGame,
|
||||
UpdateChannel, PrivacyOnlineMetadata, LogDebug,
|
||||
UpdateChannel, UpdateAutoCheck, PrivacyOnlineMetadata, LogDebug,
|
||||
];
|
||||
|
||||
private static readonly Dictionary<string, SettingDefinition> _byKey = All.ToDictionary(static d => d.Key, StringComparer.Ordinal);
|
||||
|
||||
@@ -5,7 +5,20 @@
|
||||
# hard to retrofit, and two of them are open questions (see below).
|
||||
|
||||
cmake_minimum_required(VERSION 3.28)
|
||||
project(FrameLedgerNative VERSION 0.1.0 LANGUAGES CXX RC)
|
||||
|
||||
# ONE version source (P4 PR-5, docs/12_BUILD.md §Version): the VERSION file at the
|
||||
# repository root, which Directory.Build.props reads for the managed assemblies.
|
||||
# tools/versioninfo-check.ps1 compares every built binary's FileVersion against
|
||||
# the same file, so a read that silently produced 0.0.0 here would be red there.
|
||||
set(FL_VERSION_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../VERSION")
|
||||
# Re-configure when the file changes, or a bumped VERSION would ship yesterday's version blocks.
|
||||
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${FL_VERSION_PATH}")
|
||||
file(READ "${FL_VERSION_PATH}" FL_VERSION_FILE)
|
||||
string(STRIP "${FL_VERSION_FILE}" FL_VERSION_FILE)
|
||||
if(NOT FL_VERSION_FILE MATCHES "^[0-9]+\\.[0-9]+\\.[0-9]+$")
|
||||
message(FATAL_ERROR "VERSION must be MAJOR.MINOR.PATCH (read '${FL_VERSION_FILE}')")
|
||||
endif()
|
||||
project(FrameLedgerNative VERSION ${FL_VERSION_FILE} LANGUAGES CXX RC)
|
||||
|
||||
if(NOT WIN32)
|
||||
message(FATAL_ERROR "FrameLedger's native layer is Windows-only.")
|
||||
|
||||
@@ -109,9 +109,10 @@ public sealed class AgentConnectionTests : IAsyncDisposable
|
||||
_serving = null;
|
||||
}
|
||||
|
||||
private AgentConnection Start(FakeLauncher launcher)
|
||||
private AgentConnection Start(FakeLauncher launcher, bool holdLaunches = false)
|
||||
{
|
||||
_connection = new AgentConnection(launcher, () => new PipeClient(_pipeName), _fast, "app-test");
|
||||
_connection.SetLaunchHold(holdLaunches);
|
||||
_connection.Changed += (s, _) =>
|
||||
{
|
||||
lock (_seen)
|
||||
@@ -134,6 +135,34 @@ public sealed class AgentConnectionTests : IAsyncDisposable
|
||||
condition().Should().BeTrue(because);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task WhileLaunchesAreHeldAnAbsentAgentIsNotStartedAndIsStartedOnceReleased()
|
||||
{
|
||||
// P4 PR-5: the update's apply asks the Agent to stop and must not have this loop start it again under the updater.
|
||||
FakeLauncher? launcher = null;
|
||||
launcher = new FakeLauncher(() =>
|
||||
{
|
||||
StartServer();
|
||||
return true;
|
||||
})
|
||||
{ CanLaunch = true };
|
||||
AgentConnection c = Start(launcher, holdLaunches: true);
|
||||
|
||||
await WaitForAsync(() => c.Rounds >= 2, "two rounds found nothing").ConfigureAwait(true);
|
||||
launcher.Starts.Should().Be(0, "held");
|
||||
c.LaunchesHeld.Should().BeTrue();
|
||||
lock (_seen)
|
||||
{
|
||||
_seen.Should().NotContain(AgentConnectionState.Starting, "a held round never says it is starting one");
|
||||
_seen.Should().NotContain(AgentConnectionState.Missing, "an Agent could be started, so the pill says Offline, not Missing");
|
||||
}
|
||||
|
||||
c.SetLaunchHold(false);
|
||||
c.RetryNow();
|
||||
await WaitForAsync(() => c.State == AgentConnectionState.Connected, "released: started, then connected").ConfigureAwait(true);
|
||||
launcher.Starts.Should().Be(1);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task WithNoAgentBesideTheAppTheStateIsMissingAndNothingIsStarted()
|
||||
{
|
||||
|
||||
@@ -30,6 +30,10 @@ public sealed class DashboardViewModelTests
|
||||
where T : class => EventReceived?.Invoke(this, new AgentEventArgs(IpcCodec.Decode(IpcCodec.Encode(type, null, payload))));
|
||||
|
||||
public void Change() => Changed?.Invoke(this, EventArgs.Empty);
|
||||
|
||||
public void SetLaunchHold(bool hold)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
private sealed class NoSummaries : ISessionSummaryOpener
|
||||
|
||||
@@ -16,6 +16,11 @@ internal sealed class FakeAgentLink : IAgentLink
|
||||
|
||||
public List<(string Type, object Payload)> Sent { get; } = [];
|
||||
|
||||
/// <summary>Every <see cref="SetLaunchHold"/> call, in order (P4 PR-5: the apply holds, a failed apply releases).</summary>
|
||||
public List<bool> Holds { get; } = [];
|
||||
|
||||
public void SetLaunchHold(bool hold) => Holds.Add(hold);
|
||||
|
||||
public Func<string, object, IpcEnvelope> Answer { get; set; } = static (_, _) => throw new InvalidOperationException("no answer scripted");
|
||||
|
||||
public event EventHandler? Changed;
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
using FrameLedger.Application.Persistence;
|
||||
|
||||
namespace FrameLedger.App.Tests;
|
||||
|
||||
/// <summary>An <see cref="ISettingsStore"/> in a dictionary, for a flow that reads a setting or two and has no ledger of its own.</summary>
|
||||
internal sealed class MemorySettings : ISettingsStore
|
||||
{
|
||||
public Dictionary<string, string> Rows { get; } = new(StringComparer.Ordinal);
|
||||
|
||||
public ValueTask<string?> GetAsync(string key, CancellationToken ct = default) => ValueTask.FromResult(Rows.GetValueOrDefault(key));
|
||||
|
||||
public ValueTask SetAsync(string key, string value, CancellationToken ct = default)
|
||||
{
|
||||
Rows[key] = value;
|
||||
return ValueTask.CompletedTask;
|
||||
}
|
||||
}
|
||||
@@ -47,6 +47,10 @@ public sealed class PagesLoadTests
|
||||
|
||||
public Task<IpcEnvelope> RequestAsync<TRequest>(string type, TRequest payload, CancellationToken ct = default)
|
||||
where TRequest : class => throw new NotSupportedException();
|
||||
|
||||
public void SetLaunchHold(bool hold)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
private sealed class NoNavigation : IPageNavigator
|
||||
|
||||
@@ -217,6 +217,23 @@ public sealed class SettingsViewModelTests
|
||||
(await s.Games.FindByIdAsync(on.Id, Ct))!.HookEnabled.Should().BeTrue("a fake Agent wrote nothing — the App itself never touches hook_enabled (D15)");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task TheStartupUpdateCheckIsOnByDefaultAndItsToggleIsPersisted()
|
||||
{
|
||||
// 11_UPDATER §Flow, "if enabled" (P4 PR-5): update.auto_check, default 1, the row the updater reads.
|
||||
await using ScratchLedger s = await ScratchLedger.OpenAsync();
|
||||
Harness h = await OpenAsync(s);
|
||||
|
||||
h.Vm.AutoCheckUpdates.Should().BeTrue();
|
||||
(await new SqliteSettingsStore(s.Db).GetAsync(SettingsRegistry.UpdateAutoCheck.Key, Ct)).Should().BeNull("nothing was written by the load");
|
||||
|
||||
h.Vm.AutoCheckUpdates = false;
|
||||
Task pending = h.Vm.Pending;
|
||||
await pending;
|
||||
|
||||
(await h.Settings.GetBooleanAsync(SettingsRegistry.UpdateAutoCheck, Ct)).Should().BeFalse();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ARevokeTheAgentCannotTakeStaysInTheListAndSaysWhy()
|
||||
{
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
using FluentAssertions;
|
||||
using FrameLedger.App.Services;
|
||||
using FrameLedger.App.Tests.Update;
|
||||
using FrameLedger.App.Update;
|
||||
using FrameLedger.App.ViewModels;
|
||||
using FrameLedger.Application.Settings;
|
||||
using FrameLedger.Shared.Ipc;
|
||||
|
||||
namespace FrameLedger.App.Tests;
|
||||
@@ -47,11 +50,40 @@ public sealed class TrayViewModelTests
|
||||
|
||||
private static SessionCompletedEvent Completed(Guid guid, long? sessionId) => new(guid, sessionId, "normal", 1, "ok", "exit");
|
||||
|
||||
/// <summary>An updater over a client that finds <paramref name="next"/>, wired to the same link as the tray (P4 PR-5).</summary>
|
||||
private static UpdateService Updates(IAgentLink link, UpdateCandidate? next = null) =>
|
||||
new(new FakeUpdateClient { Next = next }, link, new RegisteredSettings(new MemorySettings()), new FakeUpdatePrompts(), new FakeShell(), new RecordingStrip());
|
||||
|
||||
[Fact]
|
||||
public async Task AnUpdateFoundWhileTheWindowIsOffScreenIsABalloonAndOnScreenIsNot()
|
||||
{
|
||||
// 08_UI §Notifications policy: "update available" reaches a minimized app as a balloon; on screen the shell's banner is the one channel.
|
||||
var link = new FakeAgentLink();
|
||||
var candidate = new UpdateCandidate("0.2.0", null, 1);
|
||||
using UpdateService hidden = Updates(link, candidate);
|
||||
using var vm = new TrayViewModel(link, new FakeShell { IsShown = false }, new FakeSummaries(), new NoNavigation(), hidden);
|
||||
var toasts = new List<TrayToastEventArgs>();
|
||||
vm.ToastRequested += (_, t) => toasts.Add(t);
|
||||
|
||||
await hidden.CheckSilentlyAsync(TestContext.Current.CancellationToken);
|
||||
|
||||
toasts.Should().ContainSingle().Which.Title.Should().Be(Strings.Update_Toast_Title);
|
||||
toasts[0].SessionId.Should().BeNull("a click reveals the window; there is no session to open");
|
||||
|
||||
using UpdateService shown = Updates(link, candidate);
|
||||
using var onScreen = new TrayViewModel(link, new FakeShell { IsShown = true }, new FakeSummaries(), new NoNavigation(), shown);
|
||||
var none = new List<TrayToastEventArgs>();
|
||||
onScreen.ToastRequested += (_, t) => none.Add(t);
|
||||
await shown.CheckSilentlyAsync(TestContext.Current.CancellationToken);
|
||||
none.Should().BeEmpty();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TheStateFollowsTheSessionsAndTheirTier()
|
||||
{
|
||||
var link = new FakeAgentLink();
|
||||
using var vm = new TrayViewModel(link, new FakeShell(), new FakeSummaries(), new NoNavigation());
|
||||
using UpdateService updates = Updates(link);
|
||||
using var vm = new TrayViewModel(link, new FakeShell(), new FakeSummaries(), new NoNavigation(), updates);
|
||||
vm.State.Should().Be(TrayState.Idle);
|
||||
vm.Tooltip.Should().Be(Strings.Tray_State_Idle);
|
||||
|
||||
@@ -74,7 +106,8 @@ public sealed class TrayViewModelTests
|
||||
public async Task PauseIsOneRequestAndTheStateIsTheAgentsAnswer()
|
||||
{
|
||||
var link = new FakeAgentLink { Answer = static (type, _) => FakeAgentLink.Envelope(IpcMessageType.PauseAck, new PauseAck(string.Equals(type, IpcMessageType.PauseCapture, StringComparison.Ordinal))) };
|
||||
using var vm = new TrayViewModel(link, new FakeShell(), new FakeSummaries(), new NoNavigation());
|
||||
using UpdateService updates = Updates(link);
|
||||
using var vm = new TrayViewModel(link, new FakeShell(), new FakeSummaries(), new NoNavigation(), updates);
|
||||
link.Raise(IpcMessageType.SessionStarted, Started(Guid.NewGuid(), 1));
|
||||
|
||||
await vm.TogglePauseCommand.ExecuteAsync(null);
|
||||
@@ -95,7 +128,8 @@ public sealed class TrayViewModelTests
|
||||
public async Task WithoutAnAgentPauseSendsNothing()
|
||||
{
|
||||
var link = new FakeAgentLink { IsConnected = false };
|
||||
using var vm = new TrayViewModel(link, new FakeShell(), new FakeSummaries(), new NoNavigation());
|
||||
using UpdateService updates = Updates(link);
|
||||
using var vm = new TrayViewModel(link, new FakeShell(), new FakeSummaries(), new NoNavigation(), updates);
|
||||
|
||||
await vm.TogglePauseCommand.ExecuteAsync(null);
|
||||
|
||||
@@ -109,7 +143,8 @@ public sealed class TrayViewModelTests
|
||||
var link = new FakeAgentLink();
|
||||
var shell = new FakeShell { IsShown = true };
|
||||
var summaries = new FakeSummaries();
|
||||
using var vm = new TrayViewModel(link, shell, summaries, new NoNavigation());
|
||||
using UpdateService updates = Updates(link);
|
||||
using var vm = new TrayViewModel(link, shell, summaries, new NoNavigation(), updates);
|
||||
var toasts = new List<TrayToastEventArgs>();
|
||||
vm.ToastRequested += (_, t) => toasts.Add(t);
|
||||
var first = Guid.NewGuid();
|
||||
@@ -136,7 +171,8 @@ public sealed class TrayViewModelTests
|
||||
public void ADiscardedSessionAndASafetyEventRaiseNoBalloon()
|
||||
{
|
||||
var link = new FakeAgentLink();
|
||||
using var vm = new TrayViewModel(link, new FakeShell { IsShown = false }, new FakeSummaries(), new NoNavigation());
|
||||
using UpdateService updates = Updates(link);
|
||||
using var vm = new TrayViewModel(link, new FakeShell { IsShown = false }, new FakeSummaries(), new NoNavigation(), updates);
|
||||
var toasts = new List<TrayToastEventArgs>();
|
||||
vm.ToastRequested += (_, t) => toasts.Add(t);
|
||||
var guid = Guid.NewGuid();
|
||||
@@ -155,7 +191,8 @@ public sealed class TrayViewModelTests
|
||||
{
|
||||
var shell = new FakeShell();
|
||||
var nav = new NoNavigation();
|
||||
using var vm = new TrayViewModel(new FakeAgentLink(), shell, new FakeSummaries(), nav);
|
||||
using UpdateService updates = Updates(new FakeAgentLink());
|
||||
using var vm = new TrayViewModel(new FakeAgentLink(), shell, new FakeSummaries(), nav, updates);
|
||||
|
||||
vm.OpenCommand.Execute(null);
|
||||
vm.AgentStatusCommand.Execute(null);
|
||||
@@ -170,7 +207,8 @@ public sealed class TrayViewModelTests
|
||||
public void ADisconnectClearsTheRunningSessions()
|
||||
{
|
||||
var link = new FakeAgentLink();
|
||||
using var vm = new TrayViewModel(link, new FakeShell(), new FakeSummaries(), new NoNavigation());
|
||||
using UpdateService updates = Updates(link);
|
||||
using var vm = new TrayViewModel(link, new FakeShell(), new FakeSummaries(), new NoNavigation(), updates);
|
||||
link.Raise(IpcMessageType.SessionStarted, Started(Guid.NewGuid(), 1));
|
||||
vm.State.Should().Be(TrayState.Capturing);
|
||||
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
using FrameLedger.App.Update;
|
||||
|
||||
namespace FrameLedger.App.Tests.Update;
|
||||
|
||||
/// <summary>An <see cref="IUpdateClient"/> a test scripts: what the next check finds, what each step throws, and what was asked of it.</summary>
|
||||
internal sealed class FakeUpdateClient : IUpdateClient
|
||||
{
|
||||
public bool IsInstalled { get; set; } = true;
|
||||
|
||||
public string? CurrentVersion { get; set; } = "0.1.0";
|
||||
|
||||
/// <summary>What the next check returns; null is "current".</summary>
|
||||
public UpdateCandidate? Next { get; set; }
|
||||
|
||||
public UpdateException? CheckThrows { get; set; }
|
||||
|
||||
/// <summary>One failure per download attempt, in order; an empty queue downloads.</summary>
|
||||
public Queue<UpdateException> DownloadThrows { get; } = new();
|
||||
|
||||
public int DownloadAttempts { get; private set; }
|
||||
|
||||
/// <summary>The <c>includePrereleases</c> flag of every check, in order.</summary>
|
||||
public List<bool> Checks { get; } = [];
|
||||
|
||||
public List<string> Downloaded { get; } = [];
|
||||
|
||||
public List<string> Applied { get; } = [];
|
||||
|
||||
public Task<UpdateCandidate?> CheckAsync(bool includePrereleases, CancellationToken ct = default)
|
||||
{
|
||||
Checks.Add(includePrereleases);
|
||||
return CheckThrows is { } ex ? Task.FromException<UpdateCandidate?>(ex) : Task.FromResult(Next);
|
||||
}
|
||||
|
||||
public Task DownloadAsync(UpdateCandidate candidate, IProgress<int>? progress, CancellationToken ct = default)
|
||||
{
|
||||
DownloadAttempts++;
|
||||
if (DownloadThrows.TryDequeue(out UpdateException? ex))
|
||||
{
|
||||
return Task.FromException(ex);
|
||||
}
|
||||
|
||||
progress?.Report(50);
|
||||
progress?.Report(100);
|
||||
Downloaded.Add(candidate.Version);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public void ApplyOnExit(UpdateCandidate candidate) => Applied.Add(candidate.Version);
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
using FrameLedger.App.Update;
|
||||
|
||||
namespace FrameLedger.App.Tests.Update;
|
||||
|
||||
/// <summary>An <see cref="IUpdatePrompts"/> that answers the offer as scripted and remembers every dialog it would have shown.</summary>
|
||||
internal sealed class FakeUpdatePrompts : IUpdatePrompts
|
||||
{
|
||||
public bool Accept { get; set; } = true;
|
||||
|
||||
public List<string> Offered { get; } = [];
|
||||
|
||||
public List<string> UpToDate { get; } = [];
|
||||
|
||||
public int NotInstalled { get; private set; }
|
||||
|
||||
public List<UpdateFailure> Failed { get; } = [];
|
||||
|
||||
public Task<bool> OfferAsync(UpdateCandidate candidate, CancellationToken ct = default)
|
||||
{
|
||||
Offered.Add(candidate.Version);
|
||||
return Task.FromResult(Accept);
|
||||
}
|
||||
|
||||
public Task UpToDateAsync(string version, CancellationToken ct = default)
|
||||
{
|
||||
UpToDate.Add(version);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task NotInstalledAsync(CancellationToken ct = default)
|
||||
{
|
||||
NotInstalled++;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task FailedAsync(UpdateFailure failure, CancellationToken ct = default)
|
||||
{
|
||||
Failed.Add(failure);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
using FluentAssertions;
|
||||
using FrameLedger.App.Update;
|
||||
|
||||
namespace FrameLedger.App.Tests.Update;
|
||||
|
||||
/// <summary><c>12_BUILD</c> §Publish & package, the uninstall hook: every step runs, a failing one does not stop the next, and the data folder goes only on an explicit yes.</summary>
|
||||
public sealed class UninstallHookTests
|
||||
{
|
||||
private sealed class Probe
|
||||
{
|
||||
public int Agent { get; set; }
|
||||
|
||||
public int Layer { get; set; }
|
||||
|
||||
public int Task { get; set; }
|
||||
|
||||
public int Asked { get; set; }
|
||||
|
||||
public int Deleted { get; set; }
|
||||
|
||||
public List<string> Log { get; } = [];
|
||||
|
||||
public bool Answer { get; set; }
|
||||
|
||||
public Func<bool>? LayerBehaviour { get; set; }
|
||||
|
||||
public UninstallHook Hook() => new(
|
||||
stopAgent: () =>
|
||||
{
|
||||
Agent++;
|
||||
return true;
|
||||
},
|
||||
unregisterLayer: () =>
|
||||
{
|
||||
Layer++;
|
||||
return LayerBehaviour is { } b ? b() : true;
|
||||
},
|
||||
removeTask: () =>
|
||||
{
|
||||
Task++;
|
||||
return true;
|
||||
},
|
||||
askDeleteData: () =>
|
||||
{
|
||||
Asked++;
|
||||
return Answer;
|
||||
},
|
||||
deleteData: () => Deleted++,
|
||||
log: Log.Add);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(@"C:\Users\u\AppData\Local\FrameLedger", @"C:\Users\u\AppData\Local\FrameLedger.App\current\", true)]
|
||||
[InlineData(@"C:\Users\u\AppData\Local\FrameLedger", @"C:\Users\u\AppData\Local\FrameLedger\current\", false)]
|
||||
[InlineData(@"C:\Users\u\AppData\Local\FrameLedger\current", @"C:\Users\u\AppData\Local\FrameLedger", false)]
|
||||
[InlineData(@"C:\Users\u\AppData\Local\FrameLedger", @"c:\users\u\appdata\local\frameledger", false)]
|
||||
[InlineData(@"C:\Users\u\AppData\Local\FrameLedger", @"C:\Users\u\AppData\Local\FrameLedgerX", true)]
|
||||
public void TheDataFolderIsDeletableOnlyWhenItAndTheInstallAreSeparate(string data, string install, bool separate) =>
|
||||
UninstallHook.AreSeparate(data, install).Should().Be(separate, "a package id equal to the data folder's name puts the install inside the ledger's folder");
|
||||
|
||||
[Fact]
|
||||
public void YesRemovesEverythingIncludingTheDataFolder()
|
||||
{
|
||||
var p = new Probe { Answer = true };
|
||||
|
||||
UninstallOutcome outcome = p.Hook().Run();
|
||||
|
||||
outcome.Should().Be(new UninstallOutcome(true, true, true, true, true));
|
||||
(p.Agent, p.Layer, p.Task, p.Asked, p.Deleted).Should().Be((1, 1, 1, 1, 1));
|
||||
p.Log.Should().Contain(static l => l.Contains("data folder delete: done", StringComparison.Ordinal));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void NoKeepsTheDataFolderAndStillRemovesTheRegistrationAndTheTask()
|
||||
{
|
||||
var p = new Probe { Answer = false };
|
||||
|
||||
UninstallOutcome outcome = p.Hook().Run();
|
||||
|
||||
outcome.Should().Be(new UninstallOutcome(true, true, true, true, false));
|
||||
p.Deleted.Should().Be(0, "the folder is the user's; only a yes removes it");
|
||||
(p.Layer, p.Task).Should().Be((1, 1));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AStepThatThrowsIsLoggedAndTheNextStillRuns()
|
||||
{
|
||||
var p = new Probe { Answer = false, LayerBehaviour = static () => throw new UnauthorizedAccessException("HKCU") };
|
||||
|
||||
UninstallOutcome outcome = p.Hook().Run();
|
||||
|
||||
outcome.LayerUnregistered.Should().BeFalse();
|
||||
outcome.TaskRemoved.Should().BeTrue("the task removal does not depend on the layer step");
|
||||
outcome.DataAsked.Should().BeTrue();
|
||||
p.Log.Should().Contain(static l => l.Contains("vulkan layer unregister failed: UnauthorizedAccessException", StringComparison.Ordinal));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Net.Sockets;
|
||||
using FluentAssertions;
|
||||
using FrameLedger.App.Update;
|
||||
using Velopack.Exceptions;
|
||||
|
||||
namespace FrameLedger.App.Tests.Update;
|
||||
|
||||
/// <summary><c>11_UPDATER</c> §Error mapping, row by row, from the exception the client threw — including one wrapped by a source.</summary>
|
||||
public sealed class UpdateFailureMapperTests
|
||||
{
|
||||
public static TheoryData<Exception, UpdateFailure> Rows => new()
|
||||
{
|
||||
{ new HttpRequestException("gone", null, HttpStatusCode.NotFound), UpdateFailure.NotFound },
|
||||
{ new HttpRequestException("quota", null, HttpStatusCode.Forbidden), UpdateFailure.RateLimited },
|
||||
{ new HttpRequestException("quota", null, HttpStatusCode.TooManyRequests), UpdateFailure.RateLimited },
|
||||
{ new HttpRequestException("down", null, HttpStatusCode.ServiceUnavailable), UpdateFailure.Server },
|
||||
{ new HttpRequestException("down", null, HttpStatusCode.BadGateway), UpdateFailure.Server },
|
||||
{ new HttpRequestException("no such host"), UpdateFailure.Offline },
|
||||
{ new TaskCanceledException("timeout"), UpdateFailure.Offline },
|
||||
{ new SocketException(10060), UpdateFailure.Offline },
|
||||
{ new TimeoutException(), UpdateFailure.Offline },
|
||||
{ new InvalidOperationException("wrapped by the source", new HttpRequestException("gone", null, HttpStatusCode.NotFound)), UpdateFailure.NotFound },
|
||||
{ new HttpRequestException("odd", null, HttpStatusCode.Unauthorized), UpdateFailure.Unknown },
|
||||
{ new InvalidOperationException("no idea"), UpdateFailure.Unknown },
|
||||
{ new ChecksumFailedException("FrameLedger-0.2.0-full.nupkg", "hash mismatch"), UpdateFailure.Corrupt },
|
||||
};
|
||||
|
||||
[Theory]
|
||||
[MemberData(nameof(Rows))]
|
||||
public void TheExceptionMapsToItsRow(Exception exception, UpdateFailure expected) => UpdateFailureMapper.Map(exception).Should().Be(expected);
|
||||
|
||||
[Fact]
|
||||
public void TheClientsExceptionCarriesTheRowAndTheCause()
|
||||
{
|
||||
var cause = new HttpRequestException("gone", null, HttpStatusCode.NotFound);
|
||||
var ex = new UpdateException(UpdateFailureMapper.Map(cause), cause.Message, cause);
|
||||
ex.Failure.Should().Be(UpdateFailure.NotFound);
|
||||
ex.InnerException.Should().BeSameAs(cause);
|
||||
new UpdateException("bare").Failure.Should().Be(UpdateFailure.Unknown, "the standard constructors classify nothing");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,382 @@
|
||||
using FluentAssertions;
|
||||
using FrameLedger.App.Services;
|
||||
using FrameLedger.App.Update;
|
||||
using FrameLedger.Application.Settings;
|
||||
using FrameLedger.Shared.Ipc;
|
||||
|
||||
namespace FrameLedger.App.Tests.Update;
|
||||
|
||||
/// <summary>
|
||||
/// <c>11_UPDATER</c> §Flow over the port: the startup check's two skips and its silence on failure, the manual
|
||||
/// check's dialogs and the error rows, the download landing Ready or Deferred by whether a session runs (FR-12),
|
||||
/// and the apply — <c>Shutdown</c> to the Agent, the relaunch held, the updater told, the host ended — or refused
|
||||
/// with everything left as it was.
|
||||
/// </summary>
|
||||
public sealed class UpdateServiceTests
|
||||
{
|
||||
private static CancellationToken Ct => TestContext.Current.CancellationToken;
|
||||
|
||||
private sealed class FakeShell : IShellPresence
|
||||
{
|
||||
public bool IsShown { get; set; } = true;
|
||||
|
||||
public int Quits { get; private set; }
|
||||
|
||||
public void Reveal()
|
||||
{
|
||||
}
|
||||
|
||||
public void Quit() => Quits++;
|
||||
}
|
||||
|
||||
private sealed class Harness
|
||||
{
|
||||
public FakeUpdateClient Client { get; } = new();
|
||||
|
||||
public FakeAgentLink Agent { get; } = new();
|
||||
|
||||
public MemorySettings Store { get; } = new();
|
||||
|
||||
public FakeUpdatePrompts Prompts { get; } = new();
|
||||
|
||||
public FakeShell Shell { get; } = new();
|
||||
|
||||
public RecordingStrip Strip { get; } = new();
|
||||
|
||||
public List<string> Available { get; } = [];
|
||||
|
||||
public UpdateService Service { get; }
|
||||
|
||||
public Harness(TimeSpan? agentStop = null)
|
||||
{
|
||||
Service = new UpdateService(Client, Agent, new RegisteredSettings(Store), Prompts, Shell, Strip, agentStop);
|
||||
Service.Available += (_, e) => Available.Add(e.Version);
|
||||
}
|
||||
}
|
||||
|
||||
private static UpdateCandidate Candidate(string version = "0.2.0") => new(version, "- notes", 42L * 1024 * 1024);
|
||||
|
||||
private static StatusAck Status(string state, int sessions = 0) =>
|
||||
new(state, null, null, [.. Enumerable.Range(0, sessions).Select(static i => new ActiveSession(Guid.NewGuid(), 1, "Title", 100 + i, 1, DateTimeOffset.UtcNow))]);
|
||||
|
||||
[Fact]
|
||||
public async Task TheStartupCheckIsSkippedForACopyTheInstallerDidNotLayDown()
|
||||
{
|
||||
var h = new Harness();
|
||||
h.Client.IsInstalled = false;
|
||||
h.Client.Next = Candidate();
|
||||
|
||||
await h.Service.CheckSilentlyAsync(Ct);
|
||||
|
||||
h.Client.Checks.Should().BeEmpty("a bin/ build cannot update itself and must not ask the feed");
|
||||
h.Service.Stage.Should().Be(UpdateStage.Idle);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task TheStartupCheckIsSkippedWhenTheSettingIsOff()
|
||||
{
|
||||
var h = new Harness();
|
||||
h.Store.Rows[SettingsRegistry.UpdateAutoCheck.Key] = "0";
|
||||
h.Client.Next = Candidate();
|
||||
|
||||
await h.Service.CheckSilentlyAsync(Ct);
|
||||
|
||||
h.Client.Checks.Should().BeEmpty("11_UPDATER: the startup check runs 'if enabled'");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task AStartupCheckThatFindsNothingStaysIdleAndShowsNothing()
|
||||
{
|
||||
var h = new Harness();
|
||||
|
||||
await h.Service.CheckSilentlyAsync(Ct);
|
||||
|
||||
h.Client.Checks.Should().ContainSingle().Which.Should().BeFalse("the stable channel asks for no pre-releases");
|
||||
h.Service.Stage.Should().Be(UpdateStage.Idle);
|
||||
h.Prompts.Offered.Should().BeEmpty();
|
||||
h.Prompts.UpToDate.Should().BeEmpty("silent means silent");
|
||||
h.Available.Should().BeEmpty();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task AStartupCheckDownloadsInTheBackgroundAndLandsReadyWhenNoSessionRuns()
|
||||
{
|
||||
var h = new Harness();
|
||||
h.Client.Next = Candidate();
|
||||
|
||||
await h.Service.CheckSilentlyAsync(Ct);
|
||||
|
||||
h.Available.Should().ContainSingle("the tray's toast is raised once, when found").Which.Should().Be("0.2.0");
|
||||
h.Client.Downloaded.Should().Equal("0.2.0");
|
||||
h.Service.Stage.Should().Be(UpdateStage.Ready);
|
||||
h.Service.Version.Should().Be("0.2.0");
|
||||
h.Service.Percent.Should().Be(100);
|
||||
h.Prompts.Offered.Should().BeEmpty("the startup check never asks; the banner offers the restart");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task TheBetaChannelAsksForPrereleases()
|
||||
{
|
||||
var h = new Harness();
|
||||
h.Store.Rows[SettingsRegistry.UpdateChannel.Key] = "beta";
|
||||
|
||||
await h.Service.CheckSilentlyAsync(Ct);
|
||||
|
||||
h.Client.Checks.Should().ContainSingle().Which.Should().BeTrue("beta includes GitHub pre-releases");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ADownloadWhileASessionRunsIsDeferredAndBecomesReadyWhenTheSessionEnds()
|
||||
{
|
||||
var h = new Harness();
|
||||
h.Agent.Status = Status("capturing", 1);
|
||||
h.Client.Next = Candidate();
|
||||
|
||||
await h.Service.CheckSilentlyAsync(Ct);
|
||||
h.Service.Stage.Should().Be(UpdateStage.Deferred, "FR-12: never apply — or offer the apply — while a game is hooked");
|
||||
|
||||
h.Agent.Status = Status("idle");
|
||||
h.Agent.RaiseChanged();
|
||||
h.Service.Stage.Should().Be(UpdateStage.Ready);
|
||||
|
||||
var guid = Guid.NewGuid();
|
||||
h.Agent.Raise(IpcMessageType.SessionStarted, new SessionStartedEvent(guid, 1, "Title", 100, 1, DateTimeOffset.UtcNow));
|
||||
h.Service.Stage.Should().Be(UpdateStage.Deferred, "a session that started after the download defers it again");
|
||||
h.Agent.Raise(IpcMessageType.SessionCompleted, new SessionCompletedEvent(guid, 5, "normal", 1, "saved", "exit"));
|
||||
h.Service.Stage.Should().Be(UpdateStage.Ready);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task AStartupFailureIsALogLineNotADialog()
|
||||
{
|
||||
var h = new Harness();
|
||||
h.Client.CheckThrows = new UpdateException(UpdateFailure.Offline, "dns", null);
|
||||
|
||||
await h.Service.CheckSilentlyAsync(Ct);
|
||||
|
||||
h.Prompts.Failed.Should().BeEmpty("NFR-10: offline on the startup check is Information, no dialog");
|
||||
h.Service.Stage.Should().Be(UpdateStage.Idle);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task TheManualCheckOnAnUninstalledCopySaysSoAndAsksNothing()
|
||||
{
|
||||
var h = new Harness();
|
||||
h.Client.IsInstalled = false;
|
||||
|
||||
await h.Service.CheckInteractivelyAsync(Ct);
|
||||
|
||||
h.Prompts.NotInstalled.Should().Be(1);
|
||||
h.Client.Checks.Should().BeEmpty();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task TheManualCheckSaysUpToDateWithTheInstalledVersion()
|
||||
{
|
||||
var h = new Harness();
|
||||
|
||||
await h.Service.CheckInteractivelyAsync(Ct);
|
||||
|
||||
h.Prompts.UpToDate.Should().Equal("0.1.0");
|
||||
h.Service.Stage.Should().Be(UpdateStage.Idle);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task TheManualCheckOffersAndADeclineDownloadsNothing()
|
||||
{
|
||||
var h = new Harness();
|
||||
h.Client.Next = Candidate();
|
||||
h.Prompts.Accept = false;
|
||||
|
||||
await h.Service.CheckInteractivelyAsync(Ct);
|
||||
|
||||
h.Prompts.Offered.Should().Equal("0.2.0");
|
||||
h.Client.Downloaded.Should().BeEmpty();
|
||||
h.Service.Stage.Should().Be(UpdateStage.Idle);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task TheManualCheckOffersAndAnAcceptDownloadsToReady()
|
||||
{
|
||||
var h = new Harness();
|
||||
h.Client.Next = Candidate();
|
||||
|
||||
await h.Service.CheckInteractivelyAsync(Ct);
|
||||
|
||||
h.Client.Downloaded.Should().Equal("0.2.0");
|
||||
h.Service.Stage.Should().Be(UpdateStage.Ready);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(UpdateFailure.NotFound)]
|
||||
[InlineData(UpdateFailure.RateLimited)]
|
||||
[InlineData(UpdateFailure.Server)]
|
||||
[InlineData(UpdateFailure.Offline)]
|
||||
[InlineData(UpdateFailure.Unknown)]
|
||||
public async Task TheManualCheckMapsAFailureToItsRow(UpdateFailure failure)
|
||||
{
|
||||
var h = new Harness();
|
||||
h.Client.CheckThrows = new UpdateException(failure, "x", null);
|
||||
|
||||
await h.Service.CheckInteractivelyAsync(Ct);
|
||||
|
||||
h.Prompts.Failed.Should().Equal(failure);
|
||||
h.Service.Stage.Should().Be(UpdateStage.Idle);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ACorruptDownloadOnTheManualCheckIsItsRow()
|
||||
{
|
||||
var h = new Harness();
|
||||
h.Client.Next = Candidate();
|
||||
h.Client.DownloadThrows.Enqueue(new UpdateException(UpdateFailure.Corrupt, "hash", null));
|
||||
h.Client.DownloadThrows.Enqueue(new UpdateException(UpdateFailure.Corrupt, "hash again", null));
|
||||
|
||||
await h.Service.CheckInteractivelyAsync(Ct);
|
||||
|
||||
h.Client.DownloadAttempts.Should().Be(2, "11_UPDATER: a hash mismatch retries once, then it is the dialog's");
|
||||
h.Prompts.Failed.Should().Equal(UpdateFailure.Corrupt);
|
||||
h.Service.Stage.Should().Be(UpdateStage.Idle);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task OneCorruptDownloadIsRetriedAndTheSecondLandsReady()
|
||||
{
|
||||
var h = new Harness();
|
||||
h.Client.Next = Candidate();
|
||||
h.Client.DownloadThrows.Enqueue(new UpdateException(UpdateFailure.Corrupt, "hash", null));
|
||||
|
||||
await h.Service.CheckSilentlyAsync(Ct);
|
||||
|
||||
h.Client.DownloadAttempts.Should().Be(2);
|
||||
h.Client.Downloaded.Should().Equal("0.2.0");
|
||||
h.Service.Stage.Should().Be(UpdateStage.Ready);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ADownloadThatFailsForAnotherReasonIsNotRetried()
|
||||
{
|
||||
var h = new Harness();
|
||||
h.Client.Next = Candidate();
|
||||
h.Client.DownloadThrows.Enqueue(new UpdateException(UpdateFailure.Offline, "dropped", null));
|
||||
|
||||
await h.Service.CheckSilentlyAsync(Ct);
|
||||
|
||||
h.Client.DownloadAttempts.Should().Be(1);
|
||||
h.Service.Stage.Should().Be(UpdateStage.Idle);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task AFaultTheClientDidNotClassifyIsTheUnknownRowNotAnUnhandledCommand()
|
||||
{
|
||||
var h = new Harness();
|
||||
h.Store.Rows[SettingsRegistry.UpdateChannel.Key] = "stable";
|
||||
using var faulting = new UpdateService(new ThrowingClient(), h.Agent, new RegisteredSettings(h.Store), h.Prompts, h.Shell, h.Strip);
|
||||
|
||||
await faulting.CheckInteractivelyAsync(Ct);
|
||||
|
||||
h.Prompts.Failed.Should().Equal(UpdateFailure.Unknown);
|
||||
faulting.Stage.Should().Be(UpdateStage.Idle);
|
||||
}
|
||||
|
||||
/// <summary>A client whose check throws something it did not wrap — the shape a future bug in the adapter would have.</summary>
|
||||
private sealed class ThrowingClient : IUpdateClient
|
||||
{
|
||||
public bool IsInstalled => true;
|
||||
|
||||
public string? CurrentVersion => "0.1.0";
|
||||
|
||||
public Task<UpdateCandidate?> CheckAsync(bool includePrereleases, CancellationToken ct = default) =>
|
||||
Task.FromException<UpdateCandidate?>(new InvalidOperationException("not wrapped"));
|
||||
|
||||
public Task DownloadAsync(UpdateCandidate candidate, IProgress<int>? progress, CancellationToken ct = default) => Task.CompletedTask;
|
||||
|
||||
public void ApplyOnExit(UpdateCandidate candidate)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task RestartToUpdateRefusesWhileASessionRunsAndLeavesThePackageDeferred()
|
||||
{
|
||||
var h = new Harness();
|
||||
h.Client.Next = Candidate();
|
||||
await h.Service.CheckSilentlyAsync(Ct);
|
||||
h.Service.Stage.Should().Be(UpdateStage.Ready);
|
||||
h.Agent.Status = Status("capturing", 1);
|
||||
|
||||
await h.Service.RestartToUpdateAsync(Ct);
|
||||
|
||||
h.Service.Stage.Should().Be(UpdateStage.Deferred);
|
||||
h.Client.Applied.Should().BeEmpty("FR-12");
|
||||
h.Agent.Sent.Should().BeEmpty("the Agent is not even asked");
|
||||
h.Shell.Quits.Should().Be(0);
|
||||
h.Strip.Shown.Should().ContainSingle().Which.Kind.Should().Be("warn");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task RestartToUpdateStopsTheAgentHoldsItsRelaunchAppliesAndEndsTheHost()
|
||||
{
|
||||
var h = new Harness();
|
||||
h.Client.Next = Candidate();
|
||||
await h.Service.CheckSilentlyAsync(Ct);
|
||||
h.Agent.Answer = (type, _) =>
|
||||
{
|
||||
type.Should().Be(IpcMessageType.Shutdown);
|
||||
h.Agent.IsConnected = false;
|
||||
return FakeAgentLink.Envelope(IpcMessageType.ShutdownAck, new ShutdownAck());
|
||||
};
|
||||
|
||||
await h.Service.RestartToUpdateAsync(Ct);
|
||||
|
||||
h.Agent.Sent.Should().ContainSingle().Which.Type.Should().Be(IpcMessageType.Shutdown);
|
||||
h.Agent.Holds.Should().ContainSingle("the connection must not start the Agent under the updater").Which.Should().BeTrue();
|
||||
h.Client.Applied.Should().Equal("0.2.0");
|
||||
h.Shell.Quits.Should().Be(1);
|
||||
h.Service.Stage.Should().Be(UpdateStage.Applying);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task RestartToUpdateWithNoAgentConnectedAppliesWithoutAsking()
|
||||
{
|
||||
var h = new Harness();
|
||||
h.Agent.IsConnected = false;
|
||||
h.Client.Next = Candidate();
|
||||
await h.Service.CheckSilentlyAsync(Ct);
|
||||
|
||||
await h.Service.RestartToUpdateAsync(Ct);
|
||||
|
||||
h.Agent.Sent.Should().BeEmpty();
|
||||
h.Client.Applied.Should().Equal("0.2.0");
|
||||
h.Shell.Quits.Should().Be(1);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task AnAgentThatDoesNotStopInTimeLeavesEverythingAsItWas()
|
||||
{
|
||||
var h = new Harness(TimeSpan.FromMilliseconds(300));
|
||||
h.Client.Next = Candidate();
|
||||
await h.Service.CheckSilentlyAsync(Ct);
|
||||
h.Agent.Answer = static (_, _) => FakeAgentLink.Envelope(IpcMessageType.ShutdownAck, new ShutdownAck());
|
||||
|
||||
await h.Service.RestartToUpdateAsync(Ct);
|
||||
|
||||
h.Agent.Holds.Should().Equal([true, false], "held for the attempt, released when it was abandoned");
|
||||
h.Client.Applied.Should().BeEmpty("an Agent still holding the install directory would make the apply fail half way");
|
||||
h.Shell.Quits.Should().Be(0);
|
||||
h.Service.Stage.Should().Be(UpdateStage.Ready, "the package is still there for the next try");
|
||||
h.Strip.Shown.Should().ContainSingle().Which.Body.Should().Be(Strings.Update_AgentStillRunning);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task RestartToUpdateWithNothingDownloadedDoesNothing()
|
||||
{
|
||||
var h = new Harness();
|
||||
|
||||
await h.Service.RestartToUpdateAsync(Ct);
|
||||
|
||||
h.Client.Applied.Should().BeEmpty();
|
||||
h.Shell.Quits.Should().Be(0);
|
||||
h.Agent.Holds.Should().BeEmpty();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
#Requires -Version 7.0
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Extracts one version's section from CHANGELOG.md as the GitHub release body.
|
||||
|
||||
.DESCRIPTION
|
||||
docs/13_CI_CD.md §release.yml: the release body is the CHANGELOG section for the
|
||||
tag being released. CHANGELOG.md's own header said for five weeks that a missing
|
||||
section "will mean an empty release note"; this script makes a missing section a
|
||||
RED release instead, because a release published with no notes is the thing the
|
||||
ledger exists to prevent and nobody reads an empty body as a defect.
|
||||
|
||||
The section is everything from the `## [x.y.z]` heading to the next `## ` heading
|
||||
(or the end of the file), heading excluded, trimmed. The heading may carry a date
|
||||
(`## [0.1.0] - 2026-09-20`, Keep a Changelog's form) or not. An EMPTY section is
|
||||
red too — a heading that was moved without its entries is the same defect.
|
||||
|
||||
tools/changelog-check.ps1 asserts a pull request touched the ledger; it does not
|
||||
look at sections and this script does not look at diffs. Two questions, two tools.
|
||||
|
||||
.PARAMETER Version
|
||||
The version whose section to extract, without the leading `v` (the workflow strips it).
|
||||
|
||||
.PARAMETER Changelog
|
||||
Path to CHANGELOG.md. Default: the repository's.
|
||||
|
||||
.PARAMETER OutFile
|
||||
Where to write the body. Written to stdout when omitted.
|
||||
|
||||
.PARAMETER SelfTest
|
||||
Runs the fixture cases below and exits 0 only if every one behaves; build.ps1
|
||||
runs this on every gate so the script is exercised before a tag depends on it.
|
||||
#>
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[string]$Version,
|
||||
[string]$Changelog = (Join-Path (Split-Path $PSScriptRoot -Parent) 'CHANGELOG.md'),
|
||||
[string]$OutFile,
|
||||
[switch]$SelfTest
|
||||
)
|
||||
|
||||
Set-StrictMode -Version Latest
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
function Get-ReleaseSection {
|
||||
param([string]$Text, [string]$Ver)
|
||||
|
||||
$lines = $Text -split "`r?`n"
|
||||
$escaped = [regex]::Escape($Ver)
|
||||
$start = -1
|
||||
for ($i = 0; $i -lt $lines.Count; $i++) {
|
||||
if ($lines[$i] -match "^## \[$escaped\](\s|$)") { $start = $i; break }
|
||||
}
|
||||
if ($start -lt 0) { return $null }
|
||||
|
||||
$body = [System.Collections.Generic.List[string]]::new()
|
||||
for ($i = $start + 1; $i -lt $lines.Count; $i++) {
|
||||
if ($lines[$i] -match '^## ') { break }
|
||||
$body.Add($lines[$i])
|
||||
}
|
||||
return (($body -join "`n").Trim())
|
||||
}
|
||||
|
||||
if ($SelfTest) {
|
||||
$fixture = @"
|
||||
# Changelog
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
### Added
|
||||
|
||||
- something pending
|
||||
|
||||
## [0.2.0] - 2026-10-01
|
||||
|
||||
### Added
|
||||
|
||||
- the second thing
|
||||
|
||||
### Fixed
|
||||
|
||||
- a fix
|
||||
|
||||
## [0.1.0]
|
||||
|
||||
### Added
|
||||
|
||||
- the first thing
|
||||
"@
|
||||
$cases = @(
|
||||
@{ Name = 'a dated heading yields its body only'; Ver = '0.2.0'; Expect = "### Added`n`n- the second thing`n`n### Fixed`n`n- a fix" },
|
||||
@{ Name = 'an undated last section runs to the end of file'; Ver = '0.1.0'; Expect = "### Added`n`n- the first thing" },
|
||||
@{ Name = 'a missing section is null'; Ver = '0.3.0'; Expect = $null },
|
||||
@{ Name = 'a prefix does not match (0.1.0 is not 0.1.0-beta.1)'; Ver = '0.1.0-beta.1'; Expect = $null },
|
||||
@{ Name = 'an empty section is empty, not the next one'; Ver = 'x'; Text = "## [x]`n`n## [y]`n- y"; Expect = '' }
|
||||
)
|
||||
$failed = 0
|
||||
foreach ($c in $cases) {
|
||||
$text = if ($c.ContainsKey('Text')) { $c.Text } else { $fixture }
|
||||
$got = Get-ReleaseSection -Text $text -Ver $c.Ver
|
||||
$ok = if ($null -eq $c.Expect) { $null -eq $got } else { $got -eq $c.Expect }
|
||||
Write-Host (" {0,-4} {1}" -f ($(if ($ok) { 'ok' } else { 'FAIL' })), $c.Name) -ForegroundColor ($(if ($ok) { 'DarkGray' } else { 'Red' }))
|
||||
if (-not $ok) { $failed++ }
|
||||
}
|
||||
if ($failed -gt 0) { Write-Host "release-notes self-test FAILED ($failed)" -ForegroundColor Red; exit 1 }
|
||||
Write-Host 'release-notes self-test OK' -ForegroundColor Green
|
||||
exit 0
|
||||
}
|
||||
|
||||
if (-not $Version) { throw '-Version is required (or -SelfTest)' }
|
||||
if (-not (Test-Path $Changelog)) { throw "no changelog at $Changelog" }
|
||||
|
||||
$section = Get-ReleaseSection -Text (Get-Content $Changelog -Raw) -Ver $Version
|
||||
if ($null -eq $section) {
|
||||
Write-Host "RELEASE NOTES FAILED: CHANGELOG.md has no '## [$Version]' section — add one (move the [Unreleased] entries under it) before tagging" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
if ($section.Length -eq 0) {
|
||||
Write-Host "RELEASE NOTES FAILED: the '## [$Version]' section is empty" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
|
||||
if ($OutFile) {
|
||||
[System.IO.File]::WriteAllText($OutFile, $section + "`n", [System.Text.UTF8Encoding]::new($false))
|
||||
Write-Host "release notes for $Version written to $OutFile ($($section.Length) chars)" -ForegroundColor Green
|
||||
}
|
||||
else {
|
||||
Write-Output $section
|
||||
}
|
||||
exit 0
|
||||
@@ -22,7 +22,15 @@
|
||||
#>
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[string]$BuildDir = (Join-Path (Split-Path $PSScriptRoot -Parent) 'build/native/x64-release')
|
||||
[string]$BuildDir = (Join-Path (Split-Path $PSScriptRoot -Parent) 'build/native/x64-release'),
|
||||
|
||||
# P4 PR-5: the one version source (docs/12_BUILD.md §Version). Every binary's
|
||||
# FileVersion must be this, with the fourth component the .rc template adds.
|
||||
# Default: the repository's VERSION file; an empty string skips the comparison.
|
||||
[string]$ExpectedVersion = $(
|
||||
$f = Join-Path (Split-Path $PSScriptRoot -Parent) 'VERSION'
|
||||
if (Test-Path $f) { (Get-Content $f -Raw).Trim() } else { '' }
|
||||
)
|
||||
)
|
||||
|
||||
Set-StrictMode -Version Latest
|
||||
@@ -82,6 +90,13 @@ foreach ($name in $required) {
|
||||
$errors.Add("$name OriginalFilename is '$($vi.OriginalFilename)' — a renamed binary is harder to identify, which is the wrong direction")
|
||||
}
|
||||
|
||||
# The version the binary says is the version the repository says (P4 PR-5). A
|
||||
# native block reading 0.0.0 beside a managed assembly reading 0.1.0 is two
|
||||
# products claiming to be one, and the release workflow would ship it.
|
||||
if ($ExpectedVersion -and $vi.FileVersion.Trim() -ne "$ExpectedVersion.0") {
|
||||
$errors.Add("$name FileVersion is '$($vi.FileVersion)', expected '$ExpectedVersion.0' — the VERSION file is the one source (12_BUILD §Version)")
|
||||
}
|
||||
|
||||
++$checked
|
||||
Write-Host (" {0,-28} {1} / {2} / v{3}" -f $name, $vi.CompanyName, $vi.ProductName, $vi.FileVersion) -ForegroundColor DarkGray
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user