Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4543013034 |
No files matched your search
@@ -40,6 +40,11 @@ numeric core and does not move; the heading is the full version — corrected 20
|
||||
§Engine version — Unity, Godot, RPG Maker).
|
||||
- **The Privacy Policy (version 2.8)** names the files those versions are read from, and two that were already read and
|
||||
never named (Unity's player library and an RPG Maker game's title); it is shown once for you to accept.
|
||||
- **A game you uninstalled leaves the library by itself** when it has no sessions: the agent removes an entry whose `.exe`
|
||||
has been gone for ten minutes, if its drive is connected and the folder it was installed in is still there — an
|
||||
unplugged or re-lettered drive never counts — and never one where anti-cheat was found. A game with sessions stays, with
|
||||
them, and reads *Not installed* as before. The Games page says so when it happens; **Settings ▸ Data ▸ Remove uninstalled
|
||||
games** turns it off (`docs/02_SPEC.md` FR-1.8).
|
||||
|
||||
### Changed
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ Requirement IDs (`FR-x`, `NFR-x`) are referenced by other docs, commits, and tes
|
||||
- FR-1.4 Remove game (asks whether to keep or delete its sessions).
|
||||
- FR-1.5 "Supports" row shows shipped-capability hints (DLSS/FSR/XeSS/FG) — visually distinct from measured per-session values (`05_DETECTION` §Capability hints).
|
||||
- FR-1.7 Delete all sessions (beta.11, owner decision D40): of one game from its page, or of every game from Settings ▸ Data, after a confirmation that says how many — with their frame and sensor series and notes; the library, the settings and every consent stay. The Agent deletes them (the rows are its, `06_DATA_MODEL` §Writer ownership) and refuses while a session it would delete under is being recorded.
|
||||
- FR-1.8 Uninstalled games leave the library by themselves (beta.19, owner decision D55, amending D41): an entry whose executable has been gone for ten minutes — its drive connected and the folder it was installed in still there, so an unplugged or re-lettered drive never counts — and that has no session (stored, being recorded or waiting to be recovered) is removed by the Agent, behind Settings ▸ Data ▸ *Remove uninstalled games* (on by default). Never an entry carrying an anti-cheat block, an exception or a failed-trial mark (FR-2.2, rule 2). The App is told (`GameRemoved`).
|
||||
- FR-1.6 Recording switch per entry (2026-09-23, HANDOFF D29): off, the program is not watched at all — no session, no measurement, no injection — and a session of it that is running stops. On by default; entries an old import made for Steam's own tools start with it off. The library card says "Not recorded".
|
||||
|
||||
### FR-2 Hooking consent & control (new, safety-critical — see `19_SAFETY`)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
`%LOCALAPPDATA%\FrameLedger\ledger.db`. Pragmas: `journal_mode=WAL`, `synchronous=NORMAL`, `foreign_keys=ON`, `busy_timeout=5000`. `Microsoft.Data.Sqlite` + Dapper; all writes in explicit transactions.
|
||||
|
||||
**Writer ownership:** Agent writes `sessions`, `session_segments`, `frame_blobs`, `sensor_blobs`, `hardware_snapshots`, the hook-state columns on `games`, **and since P4 PR-1 (2026-09-14) the *detected* columns on `games`** — `engine`, `engine_version`, `platform` under the per-field provenance rule (`05_DETECTION` §Caching: a `user` field is never touched), `capability_flags` whole, and the cache key `detection_rules_version` / `detection_exe_size_bytes` / `detection_exe_mtime_ms`, and since schema 0011 (2026-09-25) the executable's own facts `exe_machine` / `exe_file_version` / `exe_product_version` / `library_versions`, written whole like the flags — through `IGameRepository.ApplyDetectionAsync` only. The UI and the Agent were both already writers of `games`; this adds columns to the Agent's half, not a third writer (HANDOFF §P4). **And since P4 PR-4 the UI's library import writes `platform`, `store_id` and `game_version` through `ApplyStoreMetadataAsync`** — the same per-field provenance rule, badged `detected` (a store's record is not the user's typing), on columns the UI already owned. **And since 2026-09-23 the Agent's relocator merges two entries for one executable under two drive letters** (`IGameMerge`, HANDOFF D26, `19_SAFETY` §A moved drive is the same executable): in one transaction it re-parents the dropped entry's `sessions` to the survivor (before the delete — `sessions.game_id` cascades), carries a block or a crash auto-disable still in force to the survivor (`hook_enabled` only ever to 0; `hook_blocked_reason` is copied, never originated or cleared), adds the crash counts, deletes the dropped `games` row, and then moves the survivor to the file's path (after the delete — `exe_path` is UNIQUE). It is the one Agent write that deletes a `games` row; it never touches a consent column. **And since 2026-09-23 the UI writes `record_sessions`** (schema 0009, FR-1.6): the entry's recording switch, which the Agent only reads — off, the watcher does not watch for the program. The script's one data change switches it off for entries an old import made for Steam's own tools (`SteamLibrarySource.KnownTools`, the ids as of the script); a twin merge keeps it off when either twin had it off. **And since 2026-09-25 the Agent's pre-scan of the library (`19_SAFETY` §What a finding does to the game) writes the hook-state columns of every entry, not only of those the user asked to hook** — `hook_prescan_state`, and on a finding `hook_enabled = 0` and `hook_blocked_reason` — and its own key, `hook_prescan_rules_version` / `hook_prescan_exe_size_bytes` / `hook_prescan_exe_mtime_ms` (schema 0010), through `IGameConsentStore.RecordPreScanAsync` only: columns that were already the Agent's, never over a block, never a new row. **And since 2026-09-26 (schema 0014, D33) the Agent writes the user-mode exception's columns** — `ac_exception_*` on `games` through `IGameConsentStore` only (eligibility from the sweep, a grant from the `SetAntiCheatException` command, every end), and `sessions.ac_exception_family` with the session — the grant only after the user accepted its disclosure in the UI, which asks and never writes. **And since 2026-10-03 (beta.11, D40) the Agent deletes sessions on request** — every session of one game or of every game, `DeleteSessions` over the pipe, through `ISessionRepository.DeleteSessionsAsync` in one transaction (segments, blobs and annotations cascade), never while one is being recorded; the UI asks and never deletes a session row itself *(for Delete all sessions; FR-1.4's removal is the App's own cascade, above — corrected 2026-10-04)*. **Maintenance (P4 PR-7) adds no writer:** the retention sweep on demand is the Agent's, asked over the pipe; the UI's `VACUUM` rewrites pages with the same contents and changes no row (§Retention built note). UI writes `games` (user-editable fields — since P3 PR-3 that is the FR-1.3 metadata, the `*_default` tri-states, and `removed_at`; ~~never a `hook_*` column~~ **and two downgrades** *(corrected 2026-10-04)*: *Change executable* (2026-09-21, `GameLibrary.ChangeExecutableAsync`) turns hooking off, clears the consent and pre-scan columns and ends an exception grant — it never writes a block or a grant — and *Remove game ▸ Delete sessions too* (FR-1.4) deletes the `games` row, cascading to its sessions, segments, blobs and annotations), `session_annotations` (tags, notes, and since schema 0002 the FR-8.3 overrides — which is WHY they are on this table and not on `sessions`), `settings`, `legal_acceptance`. Both read everything. The ports say the same in their names: `IGameRepository.UpdateMetadataAsync` / `SetTriStateDefaultAsync` / `RemoveAsync`, `ISessionAnnotationRepository`, `RegisteredSettings`, `ILegalAcceptanceStore.RecordAsync` (all P3 PR-3).
|
||||
**Writer ownership:** Agent writes `sessions`, `session_segments`, `frame_blobs`, `sensor_blobs`, `hardware_snapshots`, the hook-state columns on `games`, **and since P4 PR-1 (2026-09-14) the *detected* columns on `games`** — `engine`, `engine_version`, `platform` under the per-field provenance rule (`05_DETECTION` §Caching: a `user` field is never touched), `capability_flags` whole, and the cache key `detection_rules_version` / `detection_exe_size_bytes` / `detection_exe_mtime_ms`, and since schema 0011 (2026-09-25) the executable's own facts `exe_machine` / `exe_file_version` / `exe_product_version` / `library_versions`, written whole like the flags — through `IGameRepository.ApplyDetectionAsync` only. The UI and the Agent were both already writers of `games`; this adds columns to the Agent's half, not a third writer (HANDOFF §P4). **And since P4 PR-4 the UI's library import writes `platform`, `store_id` and `game_version` through `ApplyStoreMetadataAsync`** — the same per-field provenance rule, badged `detected` (a store's record is not the user's typing), on columns the UI already owned. **And since 2026-09-23 the Agent's relocator merges two entries for one executable under two drive letters** (`IGameMerge`, HANDOFF D26, `19_SAFETY` §A moved drive is the same executable): in one transaction it re-parents the dropped entry's `sessions` to the survivor (before the delete — `sessions.game_id` cascades), carries a block or a crash auto-disable still in force to the survivor (`hook_enabled` only ever to 0; `hook_blocked_reason` is copied, never originated or cleared), adds the crash counts, deletes the dropped `games` row, and then moves the survivor to the file's path (after the delete — `exe_path` is UNIQUE). It was the one Agent write that deletes a `games` row until beta.19; it never touches a consent column. **And since beta.19 (2026-10-12, D55) the Agent removes an entry whose game is no longer installed** (`IGamePrune`, `SqliteGamePrune`, asked by the detection sweep through `UninstalledEntryPrune`): one `DELETE` that holds every stored condition in the same statement — the same row at the same path, `removed_at` NULL, no session stored (`NOT EXISTS` on `sessions` — nothing cascades), no `hook_blocked_reason`, `hook_prescan_state` not `blocked`, no `ac_exception_at` and no `ac_exception_trial_failed_at` — behind `retention.remove_uninstalled_games`; a block, a grant and D38's mark are never removed with their entry (`19_SAFETY` §What a finding does to the game, *What clears it*). **And since 2026-09-23 the UI writes `record_sessions`** (schema 0009, FR-1.6): the entry's recording switch, which the Agent only reads — off, the watcher does not watch for the program. The script's one data change switches it off for entries an old import made for Steam's own tools (`SteamLibrarySource.KnownTools`, the ids as of the script); a twin merge keeps it off when either twin had it off. **And since 2026-09-25 the Agent's pre-scan of the library (`19_SAFETY` §What a finding does to the game) writes the hook-state columns of every entry, not only of those the user asked to hook** — `hook_prescan_state`, and on a finding `hook_enabled = 0` and `hook_blocked_reason` — and its own key, `hook_prescan_rules_version` / `hook_prescan_exe_size_bytes` / `hook_prescan_exe_mtime_ms` (schema 0010), through `IGameConsentStore.RecordPreScanAsync` only: columns that were already the Agent's, never over a block, never a new row. **And since 2026-09-26 (schema 0014, D33) the Agent writes the user-mode exception's columns** — `ac_exception_*` on `games` through `IGameConsentStore` only (eligibility from the sweep, a grant from the `SetAntiCheatException` command, every end), and `sessions.ac_exception_family` with the session — the grant only after the user accepted its disclosure in the UI, which asks and never writes. **And since 2026-10-03 (beta.11, D40) the Agent deletes sessions on request** — every session of one game or of every game, `DeleteSessions` over the pipe, through `ISessionRepository.DeleteSessionsAsync` in one transaction (segments, blobs and annotations cascade), never while one is being recorded; the UI asks and never deletes a session row itself *(for Delete all sessions; FR-1.4's removal is the App's own cascade, above — corrected 2026-10-04)*. **Maintenance (P4 PR-7) adds no writer:** the retention sweep on demand is the Agent's, asked over the pipe; the UI's `VACUUM` rewrites pages with the same contents and changes no row (§Retention built note). UI writes `games` (user-editable fields — since P3 PR-3 that is the FR-1.3 metadata, the `*_default` tri-states, and `removed_at`; ~~never a `hook_*` column~~ **and two downgrades** *(corrected 2026-10-04)*: *Change executable* (2026-09-21, `GameLibrary.ChangeExecutableAsync`) turns hooking off, clears the consent and pre-scan columns and ends an exception grant — it never writes a block or a grant — and *Remove game ▸ DeLine truncated
|
||||
|
||||
## Schema (v2 — hook architecture)
|
||||
|
||||
@@ -442,6 +442,7 @@ 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) |
|
||||
| `retention.remove_uninstalled_games` | bool | `1` | | Agent, at every detection sweep (beta.19, D55, FR-1.8): on, an entry whose executable has been gone for ten minutes — its drive connected, the folder it was installed in still there — and that has no session and no anti-cheat block or exception is removed; off, it stays and reads *Not installed* (D41's behaviour) |
|
||||
| `update.channel` | choice | ~~`stable`~~ `auto` (beta.14, D47) | `auto` · `stable` · `beta` | UI (P4 PR-5 reads it: `beta` = GitHub pre-releases too; `auto` follows the running copy, a pre-release asking for pre-releases — `11_UPDATER` §The update audit) |
|
||||
| `update.auto_check` | bool | `1` | | UI (P4 PR-5: the startup silent check, `11_UPDATER` §Flow "if enabled") |
|
||||
| `privacy.online_metadata` | bool | `0` | | *reserved* — no consumer and, since 2026-09-16, no toggle on Settings either: the store request it would enable has no code (CLAUDE.md rule 8), and PRIVACY_POLICY 2.2 removed the row that described it |
|
||||
|
||||
@@ -409,6 +409,7 @@ Unchanged in spirit from v1, bumped to `v2` for the new message set.
|
||||
| `CaptureRefused` | A→UI | `{ gameId, gameName, reason, family?, signal?, hookingTurnedOff, guardReason? }` — **`guardReason` (beta.13, optional)** is the guard's own reason ~~when it named a family~~ **whenever it refused (beta.18; beside a family only until then)**: `BlockedService` / `BlockedDriver` is a finding on the PC, not in the game, and the notice says so (§S23-3), and a refusal no family names is said in the guard's words (`Formats.GuardSentence`) — it printed the end's name, "reason RefusedByGuard"; `reason` stays the session's end reason — **guard fired**; `hookingTurnedOff` (2026-09-22) is true when the finding turned the game's hooking off (`19_SAFETY` §What a finding does to the game); UI shows the plain-language explanation — ~~and the Tier-2 offer~~; there is no alternative measurement to offer, only the option to record the session unmeasured (`08_UI` §Safety events). *(Built: for `RefusedByGuard`, `RefusedPreviouslyBlocked`, `RefusedKillSwitch`, `PreScanCouldNotVerify` and, since 2026-09-21 (beta.4), `TargetUnreadable` — a protected process the Agent could not open (added 2026-10-04) — `PreScanCouldNotVerify` with no family, because "could not verify" is neither a hit nor a pass; `family`/`signal` are the verdict's. A game merely not enabled or not consented raises nothing: that is an ordinary Tier-2 row, not a refusal to explain.)* |
|
||||
| `CaptureDegraded` | A→UI | `{ sessionGuid, from: 1, to: 2, reason }` — Tier 1 → Tier 2 mid-flight, or overlay self-disabled. **Under a two-rung ladder this means measurement STOPPED**, not that it continued at lower fidelity, and the notice must say so. *(Since beta.18 it says the end in words, `Formats.EndReasonText`; it printed `reason` raw — "The hook stopped (WriterSelfDisabled); the session continues without measuring" — and a stop ends the session, it does not continue it.)* *(Built: `SupervisionLost`, `WriterSelfDisabled`, `WriterStoppedBlocklisted`, `WriterNeverInstalledHooks`, `SupervisionFaulted`, `KillSwitchEngaged` — `RecordedSessionEvents.Classify` is the table.)* |
|
||||
| `SafetyUnhook` | A→UI | `{ sessionGuid, family?, signal?, hookingTurnedOff, guardReason? }` — `guardReason` as on `CaptureRefused` (beta.13) — anti-cheat appeared mid-session; prominent UI notice; `hookingTurnedOff` as on `CaptureRefused`. *(Built: the verdict that FIRED, not the pass that started the session — `CaptureOutcome.Verdict` carries the supervisor's last verdict on this reason since 2026-09-13.)* |
|
||||
| `GameRemoved` | A→UI | `{ gameId, gameName?, exePath, reason }` — **since beta.19 (D55):** the Agent removed a library entry by itself; `reason` is `uninstalled` (its executable gone for ten minutes from a folder that is still there, no session, no anti-cheat block or exception — `06_DATA_MODEL` §Writer ownership). Not a session event. The Games page on screen reloads and says so; a game page showing that entry reloads into its not-found state. Additive: a client that does not know the type ignores it (§Versioning). |
|
||||
| `HookingTurnedOff` | A→UI | `{ gameId, gameName?, reason, family?, signal? }` — **since 2026-09-25 (beta.8):** the Agent's pre-scan of the library (`19_SAFETY` §What a finding does to the game) found anti-cheat in a game whose hooking the user had turned on, and turned it off. Not a session event — no session is running — so the UI's notice carries no "record without measuring" action, only Dismiss (`SafetyNoticeKind.HookingOff`). A finding on a game whose hooking was already off sends nothing: its page and its library card change, nothing the user switched on did. Additive: a client that does not know the type ignores it (§Versioning). |
|
||||
| `CaptureError` | A→UI | `{ sessionGuid?, code, message }` — `InjectFailed`, `RingVersionMismatch`, `AttachRefused`, ~~`EtwAccessDenied`~~ (struck 2026-09-13 with the tier), ~~`PresentMonMissing`~~ (retired with the tool, 2026-08-27 — a code naming an implementation nobody chose), `TelemetryUnavailable`, `DbWriteFailed`, `SessionFaulted` (the session's task threw before finalize; the `.partial` stays for recovery, and ~~no `SessionCompleted` follows~~ a `SessionCompleted` with `finalize: faulted` follows since 2026-09-23). *(Built: `RingVersionMismatch` for a layout / record-size / build-id refusal — the "restart the game after an update" case — `AttachRefused` for the rest of the ring's refusals, `InjectFailed` for a target that could not be started, pinned, read or singled out.)* |
|
||||
| `Ping`/`Pong` | ~~both~~ UI→A | 15 s keepalive, **client-driven** (built 2026-09-13): the client pings, the Agent answers; the Agent initiates nothing on an idle connection |
|
||||
|
||||
+9
-1
@@ -272,7 +272,11 @@ All screens are `Page`s registered with the navigation page provider and navigat
|
||||
> since (`ImportLibraryFlow.RunAsync(onlyNew: true)`: *No new games* and no checklist when there are none), and every entry
|
||||
> whose executable is not on disk carries a **Not installed** pill — its tooltip is the game page's own sentence for it,
|
||||
> the drive that is not connected or the path the file is gone from (`GameLibrary.ExecutableExists` and
|
||||
> `Formats.ExecutableMissingText`, asked off the UI thread on every listing, never stored; nothing is removed for it). **The page reloads by itself** while it is on screen when a session ends (`SessionCompleted`) or an
|
||||
> `Formats.ExecutableMissingText`, asked off the UI thread on every listing, never stored; ~~nothing is removed for it~~
|
||||
> *since beta.19 (D55) the Agent removes such an entry by itself after ten minutes when it has no session and no
|
||||
> anti-cheat block or exception, and its drive is connected — Settings ▸ Data ▸ Remove uninstalled games, on by default; the
|
||||
> page on screen hears `GameRemoved`, reloads and says so in the snackbar (`Games_Removed_Format`); one with sessions keeps
|
||||
> its pill*). **The page reloads by itself** while it is on screen when a session ends (`SessionCompleted`) or an
|
||||
> import adds games (`LibraryChanges` — navigating to the page already on screen does nothing in WPF UI 4.3.0, so an
|
||||
> import from the menu never showed until the page was left). **Import** (FR-1.2): the games already in the library — at
|
||||
> this path or under another drive letter — are hidden by default (*Show the N games already in the library* brings them
|
||||
@@ -661,6 +665,10 @@ Tail view of `ui-*.log` / `agent-*.log` (toggle), level filter, search (`ui:Auto
|
||||
> sentence under the language row is gone. A **Data** section has one row, **Delete all sessions…** (FR-1.7): the
|
||||
> confirmation names how many, the Agent deletes them (`DeleteSessions`), and the strip says what happened or why nothing
|
||||
> was deleted (a session being recorded, no agent, an older agent). Tests: `SettingsViewModelTests.DeleteAllSessionsAsksWithTheTotalThenGoesThroughTheAgent`.
|
||||
> **Since beta.19 (D55) the Data section's first row is *Remove uninstalled games*** (`retention.remove_uninstalled_games`,
|
||||
> on by default, off in a viewer like every setting the Agent reads): its strip says the Agent reads it within 15 seconds
|
||||
> (`Settings_RemoveUninstalled_Applied`), not at the next session — the detection sweep reads it at every pass. Tests:
|
||||
> `ViewerModeTests.EverySettingTheAgentReadsIsOffInAViewer`, `GuideDocumentsTests.TheSettingsPageOfTheGuideNamesEverySetting`.
|
||||
|
||||
Sections per FR-10 using the WPF UI settings idiom: `ui:CardControl`/`ui:CardExpander` rows with `ToggleSwitch`, `ComboBox`, `ui:NumberBox` (numeric inputs — min session length, sensor interval, retention). Language switch applies immediately (09_I18N). Theme selector (Light/Dark/System) drives `ApplicationThemeManager` (16 §Theming). **Capture section (top, most important):** the global **hooking kill switch** (`ToggleSwitch`, prominent) with a one-line summary of what it does; a list of games currently hook-enabled with a per-game revoke; Vulkan layer registration state + Register/Unregister; a link to the safety documentation. Turning the global switch off must take effect immediately, including for the Vulkan layer.
|
||||
|
||||
|
||||
@@ -499,7 +499,10 @@ card is back with the finding under its disabled switch. The finding itself is o
|
||||
**What clears it.** Nothing, as before: the block outlives *Change executable* and a re-import (§A game already enabled
|
||||
can become blocked later). The owner asked for hooking to be turned off when anti-cheat is detected, not for a second
|
||||
switch. *(Still true under D33: an exception is a separate layer over the block, never a clearing of it — §The user-mode
|
||||
exception.)*
|
||||
exception.)* *(And under D55, beta.19: the Agent removes an entry whose game is no longer installed and that has no session,
|
||||
but never one that carries a block, an exception's grant or a failed trial — the delete's own SQL refuses them
|
||||
(`SqliteGamePrune`), so an uninstall is not how a block, a grant or D38's "never again" disappears. Only the user's
|
||||
*Remove… ▸ Delete sessions too* deletes such a row, as before.)*
|
||||
|
||||
**D21 stands as a fact.** A process an anti-cheat driver protects is `SessionEndReason.TargetUnreadable` (2026-09-21:
|
||||
every candidate of that name exists and none can be opened; ELDEN RING under Easy Anti-Cheat on the owner's machine).
|
||||
|
||||
@@ -26,7 +26,8 @@ a game is being recorded. Backing up is up to you — FrameLedger does not do it
|
||||
## Delete it
|
||||
|
||||
- **A game's sessions:** Games ▸ the game ▸ Sessions ▸ **Delete all sessions…**
|
||||
- **A game:** its page ▸ **Remove…**
|
||||
- **A game:** its page ▸ **Remove…** A game you uninstalled goes by itself when it has no sessions (Settings ▸ Data ▸
|
||||
**Remove uninstalled games**, on unless you turn it off); one with sessions stays, with them, until you remove it.
|
||||
- **Every session of every game:** Settings ▸ Data ▸ **Delete all sessions…**
|
||||
- **Everything:** uninstall FrameLedger and let it delete the data folder, or delete the folder yourself.
|
||||
|
||||
|
||||
+3
-1
@@ -59,7 +59,9 @@ stopped, hooking turned off — each with one button that only says you have rea
|
||||
|
||||
- **Search games**; sort by **Name**, **Last played** or **Playtime**; **Show as a list** or **Show as a grid**.
|
||||
- **Refresh** reads your library again: it offers games newly installed through a store, and marks a game whose `.exe`
|
||||
is gone as *Not installed*.
|
||||
is gone as *Not installed*. The agent removes such a game by itself after ten minutes when it has no sessions and its
|
||||
drive is connected — never one where anti-cheat was found (**Settings ▸ Data ▸ Remove uninstalled games** turns this
|
||||
off).
|
||||
- **Add game…** — or drop `.exe` files onto the page.
|
||||
- Each game shows its name, its store and engine, and one state: **Hooking on**, **Hooking off**, **Anti-cheat** (found,
|
||||
so it is not hooked), **Exception** (a user-mode exception is in force) or **Not recorded**; then its sessions,
|
||||
|
||||
@@ -27,6 +27,7 @@ The link under them, *Read what the hook does and does not do*, opens the safety
|
||||
|
||||
| Setting | What it does | Default |
|
||||
|---|---|---|
|
||||
| **Remove uninstalled games** | A game whose `.exe` has been gone for ten minutes is removed from your library — only when it has no sessions, its drive is connected and the folder it was installed in is still there (an unplugged drive never counts), and never a game where anti-cheat was found. Off, it stays and reads *Not installed*. *Agent*, within 15 seconds. | On |
|
||||
| **Delete all sessions** | Deletes every session of every game, with its data and notes, after asking. Your library, your settings and each game's hooking choice stay. It cannot be undone, and it is refused while a game is being recorded. | — |
|
||||
|
||||
## Capture agent
|
||||
|
||||
@@ -147,6 +147,25 @@ internal static class AgentServices
|
||||
services.AddSingleton<IDriverProfileSource>(static sp => sp.GetRequiredService<NvapiDriverProfileSource>());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// An entry whose game is no longer installed and that had no session goes (beta.19, D55): asked by the detection sweep after
|
||||
/// the relocator, behind the user's switch, never while a session of it is recorded or waits to be recovered — the merge's
|
||||
/// own busy test — and never for an entry carrying an anti-cheat block or exception (the delete's SQL checks again).
|
||||
/// </summary>
|
||||
private static void AddUninstalledEntryPrune(IServiceCollection services)
|
||||
{
|
||||
services.AddSingleton<IGamePrune>(static sp => new SqliteGamePrune(sp.GetRequiredService<LedgerDatabase>()));
|
||||
services.AddSingleton<IExecutablePresence>(static _ => new ExecutablePresenceProbe(VolumeRoots.IsReady));
|
||||
services.AddSingleton(static sp => new UninstalledEntryPrune(
|
||||
sp.GetRequiredService<IGamePrune>(),
|
||||
sp.GetRequiredService<IExecutablePresence>(),
|
||||
ct => sp.GetRequiredService<RegisteredSettings>().GetBooleanAsync(SettingsRegistry.RetentionRemoveUninstalledGames, ct),
|
||||
id => sp.GetRequiredService<CaptureOrchestrator>().IsRecording(id)
|
||||
|| sp.GetRequiredService<IPartialSessionStore>().PendingGameIds().Contains(id),
|
||||
static line => Serilog.Log.Information("{Line}", line),
|
||||
sp.GetRequiredService<IIpcEventPublisher>()));
|
||||
}
|
||||
|
||||
/// <summary>The static detection sweep (P4 PR-1, <c>05_DETECTION</c> §Caching): hosted under <c>--serve</c> only, composed and inert under <c>--console</c>.</summary>
|
||||
private static void AddDetection(IServiceCollection services, AgentPaths paths)
|
||||
{
|
||||
@@ -168,13 +187,15 @@ internal static class AgentServices
|
||||
merge: sp.GetRequiredService<IGameMerge>(),
|
||||
busy: id => sp.GetRequiredService<CaptureOrchestrator>().IsRecording(id)
|
||||
|| sp.GetRequiredService<IPartialSessionStore>().PendingGameIds().Contains(id)));
|
||||
AddUninstalledEntryPrune(services);
|
||||
services.AddSingleton(static sp => new DetectionSweep(
|
||||
sp.GetRequiredService<IGameRepository>(),
|
||||
sp.GetRequiredService<IDetectionRulesSource>(),
|
||||
sp.GetRequiredService<IGameFileProbe>(),
|
||||
sp.GetRequiredService<IExecutableIdentitySource>(),
|
||||
static line => Serilog.Log.Information("{Line}", line),
|
||||
sp.GetRequiredService<ExecutableRelocator>()));
|
||||
sp.GetRequiredService<ExecutableRelocator>(),
|
||||
sp.GetRequiredService<UninstalledEntryPrune>()));
|
||||
|
||||
// The anti-cheat pre-scan of the library (beta.8, 19_SAFETY §What a finding does to the game): every entry through
|
||||
// the guard's advisory checks 3 and 4, again whenever the rules or the executable change. It waits while a session
|
||||
|
||||
@@ -39,10 +39,10 @@ internal sealed class DetectionHostedService(DetectionSweep sweep, VkLayerReconc
|
||||
DetectionSweepReport r = await sweep.SweepOnceAsync(stoppingToken).ConfigureAwait(false);
|
||||
// Said when something happened or changed (2026-09-23): an unreadable entry used to repeat this line every
|
||||
// 15 s — 5,760 a day — with nothing new in it.
|
||||
if (r.Scanned > 0 || r.Relocated > 0 || r.RulesUnusable || (r.Unreadable > 0 && r.Unreadable != previous?.Unreadable))
|
||||
if (r.Scanned > 0 || r.Relocated > 0 || r.Removed > 0 || r.RulesUnusable || (r.Unreadable > 0 && r.Unreadable != previous?.Unreadable))
|
||||
{
|
||||
Log.Information("detect: sweep scanned {Scanned}, current {Current}, unreadable {Unreadable}{Rules}",
|
||||
r.Scanned, r.Current, r.Unreadable, r.RulesUnusable ? ", rules unusable" : string.Empty);
|
||||
Log.Information("detect: sweep scanned {Scanned}, current {Current}, unreadable {Unreadable}, removed {Removed}{Rules}",
|
||||
r.Scanned, r.Current, r.Unreadable, r.Removed, r.RulesUnusable ? ", rules unusable" : string.Empty);
|
||||
}
|
||||
|
||||
previous = r;
|
||||
|
||||
@@ -219,7 +219,19 @@
|
||||
|
||||
<!-- beta.11 (owner request 2026-10-03: no row without a control): Data - Delete all sessions (D40). -->
|
||||
<ui:TextBlock FontTypography="Subtitle" Margin="0,20,0,8" Text="{x:Static res:Strings.Settings_Data_Header}" />
|
||||
<ui:CardControl Margin="0,4,0,0" Icon="{ui:SymbolIcon Delete24}">
|
||||
<!-- beta.19 (owner decision D55): the Agent removes an entry whose game is no longer installed and that has no session. -->
|
||||
<ui:CardControl Margin="0,4,0,0" Icon="{ui:SymbolIcon BoxDismiss24}">
|
||||
<ui:CardControl.Header>
|
||||
<StackPanel>
|
||||
<ui:TextBlock FontTypography="BodyStrong" Text="{x:Static res:Strings.Settings_RemoveUninstalled_Label}" />
|
||||
<ui:TextBlock MaxWidth="560" HorizontalAlignment="Left" Style="{StaticResource SecondaryText}" Text="{x:Static res:Strings.Settings_RemoveUninstalled_Body}" TextWrapping="Wrap" />
|
||||
</StackPanel>
|
||||
</ui:CardControl.Header>
|
||||
<ui:ToggleSwitch AutomationProperties.Name="{x:Static res:Strings.Settings_RemoveUninstalled_Label}"
|
||||
IsChecked="{Binding ViewModel.RemoveUninstalledGames, Mode=TwoWay}"
|
||||
IsEnabled="{Binding ViewModel.ActsOnThisPc}" />
|
||||
</ui:CardControl>
|
||||
<ui:CardControl Margin="0,8,0,0" Icon="{ui:SymbolIcon Delete24}">
|
||||
<ui:CardControl.Header>
|
||||
<StackPanel>
|
||||
<ui:TextBlock FontTypography="BodyStrong" Text="{x:Static res:Strings.Settings_DeleteSessions_Label}" />
|
||||
|
||||
Generated
+15
@@ -519,6 +519,8 @@ public static class Strings
|
||||
nameof(Games_NoMatch),
|
||||
nameof(Games_Refresh),
|
||||
nameof(Games_Refresh_ToolTip),
|
||||
nameof(Games_Removed_Format),
|
||||
nameof(Games_Removed_Title),
|
||||
nameof(Games_Search_Placeholder),
|
||||
nameof(Games_Sort_Label),
|
||||
nameof(Games_Sort_LastPlayed),
|
||||
@@ -839,6 +841,9 @@ public static class Strings
|
||||
nameof(Settings_OnlineMetadata_Label),
|
||||
nameof(Settings_Policy_Header),
|
||||
nameof(Settings_Privacy_Header),
|
||||
nameof(Settings_RemoveUninstalled_Applied),
|
||||
nameof(Settings_RemoveUninstalled_Body),
|
||||
nameof(Settings_RemoveUninstalled_Label),
|
||||
nameof(Settings_Retention_Body),
|
||||
nameof(Settings_Retention_Label),
|
||||
nameof(Settings_SafetyDocs),
|
||||
@@ -2049,6 +2054,10 @@ public static class Strings
|
||||
|
||||
public static string Games_Refresh_ToolTip => ResourceManager.GetString(nameof(Games_Refresh_ToolTip), Culture) ?? nameof(Games_Refresh_ToolTip);
|
||||
|
||||
public static string Games_Removed_Format => ResourceManager.GetString(nameof(Games_Removed_Format), Culture) ?? nameof(Games_Removed_Format);
|
||||
|
||||
public static string Games_Removed_Title => ResourceManager.GetString(nameof(Games_Removed_Title), Culture) ?? nameof(Games_Removed_Title);
|
||||
|
||||
public static string Games_Search_Placeholder => ResourceManager.GetString(nameof(Games_Search_Placeholder), Culture) ?? nameof(Games_Search_Placeholder);
|
||||
|
||||
public static string Games_Sort_Label => ResourceManager.GetString(nameof(Games_Sort_Label), Culture) ?? nameof(Games_Sort_Label);
|
||||
@@ -2689,6 +2698,12 @@ public static class Strings
|
||||
|
||||
public static string Settings_Privacy_Header => ResourceManager.GetString(nameof(Settings_Privacy_Header), Culture) ?? nameof(Settings_Privacy_Header);
|
||||
|
||||
public static string Settings_RemoveUninstalled_Applied => ResourceManager.GetString(nameof(Settings_RemoveUninstalled_Applied), Culture) ?? nameof(Settings_RemoveUninstalled_Applied);
|
||||
|
||||
public static string Settings_RemoveUninstalled_Body => ResourceManager.GetString(nameof(Settings_RemoveUninstalled_Body), Culture) ?? nameof(Settings_RemoveUninstalled_Body);
|
||||
|
||||
public static string Settings_RemoveUninstalled_Label => ResourceManager.GetString(nameof(Settings_RemoveUninstalled_Label), Culture) ?? nameof(Settings_RemoveUninstalled_Label);
|
||||
|
||||
public static string Settings_Retention_Body => ResourceManager.GetString(nameof(Settings_Retention_Body), Culture) ?? nameof(Settings_Retention_Body);
|
||||
|
||||
public static string Settings_Retention_Label => ResourceManager.GetString(nameof(Settings_Retention_Label), Culture) ?? nameof(Settings_Retention_Label);
|
||||
|
||||
@@ -2025,6 +2025,26 @@
|
||||
<value>データ</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Settings_RemoveUninstalled_Label" xml:space="preserve">
|
||||
<value>アンインストールされたゲームを削除</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Settings_RemoveUninstalled_Body" xml:space="preserve">
|
||||
<value>接続されているドライブから実行ファイルが 10 分間なくなっているゲームを、ライブラリから削除します。セッションが 1 つもない場合に限り、アンチチートが見つかったゲームは削除しません。オフにすると、ゲームは「未インストール」のまま残ります。</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Settings_RemoveUninstalled_Applied" xml:space="preserve">
|
||||
<value>適用しました。キャプチャエージェントは 15 秒以内に読み込みます。</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Games_Removed_Title" xml:space="preserve">
|
||||
<value>ライブラリから削除しました</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Games_Removed_Format" xml:space="preserve">
|
||||
<value>{0} はインストールされておらずセッションもないため、キャプチャエージェントが削除しました。「設定 ▸ データ」でオフにできます。</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Settings_DeleteSessions_Label" xml:space="preserve">
|
||||
<value>すべてのセッションを削除</value>
|
||||
<comment>review</comment>
|
||||
|
||||
@@ -1524,6 +1524,21 @@
|
||||
<data name="Settings_Data_Header" xml:space="preserve">
|
||||
<value>Data</value>
|
||||
</data>
|
||||
<data name="Settings_RemoveUninstalled_Label" xml:space="preserve">
|
||||
<value>Remove uninstalled games</value>
|
||||
</data>
|
||||
<data name="Settings_RemoveUninstalled_Body" xml:space="preserve">
|
||||
<value>A game whose executable has been gone for ten minutes, from a drive that is connected, is removed from the library — only when it has no sessions, and never one where anti-cheat was found. Off, it stays and reads Not installed.</value>
|
||||
</data>
|
||||
<data name="Settings_RemoveUninstalled_Applied" xml:space="preserve">
|
||||
<value>Applied. The capture agent reads it within 15 seconds.</value>
|
||||
</data>
|
||||
<data name="Games_Removed_Title" xml:space="preserve">
|
||||
<value>Removed from the library</value>
|
||||
</data>
|
||||
<data name="Games_Removed_Format" xml:space="preserve">
|
||||
<value>{0} is no longer installed and had no sessions, so the capture agent removed it. Settings ▸ Data turns this off.</value>
|
||||
</data>
|
||||
<data name="Settings_DeleteSessions_Label" xml:space="preserve">
|
||||
<value>Delete all sessions</value>
|
||||
</data>
|
||||
|
||||
@@ -1519,6 +1519,21 @@
|
||||
<data name="Settings_Data_Header" xml:space="preserve">
|
||||
<value>Dữ liệu</value>
|
||||
</data>
|
||||
<data name="Settings_RemoveUninstalled_Label" xml:space="preserve">
|
||||
<value>Xoá game đã gỡ cài đặt</value>
|
||||
</data>
|
||||
<data name="Settings_RemoveUninstalled_Body" xml:space="preserve">
|
||||
<value>Game có file thực thi đã biến mất mười phút, trên ổ đĩa vẫn đang cắm, sẽ được xoá khỏi thư viện — chỉ khi game chưa có phiên nào, và không bao giờ xoá game đã phát hiện anti-cheat. Khi tắt, game vẫn ở lại với nhãn Chưa cài.</value>
|
||||
</data>
|
||||
<data name="Settings_RemoveUninstalled_Applied" xml:space="preserve">
|
||||
<value>Đã áp dụng. Capture agent đọc trong vòng 15 giây.</value>
|
||||
</data>
|
||||
<data name="Games_Removed_Title" xml:space="preserve">
|
||||
<value>Đã xoá khỏi thư viện</value>
|
||||
</data>
|
||||
<data name="Games_Removed_Format" xml:space="preserve">
|
||||
<value>{0} không còn được cài đặt và chưa có phiên nào, nên capture agent đã xoá nó. Tắt việc này trong Cài đặt ▸ Dữ liệu.</value>
|
||||
</data>
|
||||
<data name="Settings_DeleteSessions_Label" xml:space="preserve">
|
||||
<value>Xoá mọi phiên</value>
|
||||
</data>
|
||||
|
||||
@@ -521,6 +521,13 @@ public sealed partial class GameDetailViewModel : ObservableObject
|
||||
{
|
||||
Pending = LoadAsync();
|
||||
}
|
||||
else if (string.Equals(e.Envelope.Type, IpcMessageType.GameRemoved, StringComparison.Ordinal)
|
||||
&& IpcCodec.Payload<GameRemovedEvent>(e.Envelope) is { } removed && removed.GameId == _gameId)
|
||||
{
|
||||
// D55 (beta.19): this very entry was removed by the Agent — the page reloads into its not-found state and says why.
|
||||
_strip.Info(Strings.Games_Removed_Title, string.Format(CultureInfo.CurrentCulture, Strings.Games_Removed_Format, removed.GameName ?? removed.ExePath));
|
||||
Pending = LoadAsync();
|
||||
}
|
||||
});
|
||||
|
||||
private async Task LoadSelectedAsync(SessionItemViewModel? session)
|
||||
|
||||
@@ -33,6 +33,7 @@ public sealed partial class GamesViewModel : ObservableObject
|
||||
private readonly RegisteredSettings? _settings;
|
||||
private readonly IAgentLink? _agent;
|
||||
private readonly LibraryChanges? _changes;
|
||||
private readonly IMessageStrip? _strip;
|
||||
private readonly UiThread _ui = new();
|
||||
private IReadOnlyList<GameCardViewModel> _all = [];
|
||||
private bool _viewRead;
|
||||
@@ -58,8 +59,9 @@ public sealed partial class GamesViewModel : ObservableObject
|
||||
private bool _listView;
|
||||
|
||||
public GamesViewModel(GameLibrary library, GameSelection selection, IPageNavigator navigator, AddGameFlow addGame, ImportLibraryFlow? import = null,
|
||||
RegisteredSettings? settings = null, IAgentLink? agent = null, LibraryChanges? changes = null)
|
||||
RegisteredSettings? settings = null, IAgentLink? agent = null, LibraryChanges? changes = null, IMessageStrip? strip = null)
|
||||
{
|
||||
_strip = strip;
|
||||
_library = library ?? throw new ArgumentNullException(nameof(library));
|
||||
_selection = selection ?? throw new ArgumentNullException(nameof(selection));
|
||||
_navigator = navigator ?? throw new ArgumentNullException(nameof(navigator));
|
||||
@@ -245,6 +247,13 @@ public sealed partial class GamesViewModel : ObservableObject
|
||||
{
|
||||
Pending = LoadAsync();
|
||||
}
|
||||
else if (string.Equals(e.Envelope.Type, IpcMessageType.GameRemoved, StringComparison.Ordinal)
|
||||
&& IpcCodec.Payload<GameRemovedEvent>(e.Envelope) is { } removed)
|
||||
{
|
||||
// D55 (beta.19): the Agent removed an entry whose game is no longer installed; the card goes, and the page says why.
|
||||
_strip?.Info(Strings.Games_Removed_Title, string.Format(CultureInfo.CurrentCulture, Strings.Games_Removed_Format, removed.GameName ?? removed.ExePath));
|
||||
Pending = LoadAsync();
|
||||
}
|
||||
});
|
||||
|
||||
private void OnLibraryChanged(object? sender, EventArgs e) => _ui.Post(() => Pending = LoadAsync());
|
||||
|
||||
@@ -71,6 +71,13 @@ public sealed partial class SettingsViewModel : ObservableObject
|
||||
[NotifyPropertyChangedFor(nameof(KillSwitchState))]
|
||||
private bool _killSwitch;
|
||||
|
||||
/// <summary>
|
||||
/// D55 (beta.19): the Agent removes an entry whose game is no longer installed and that has no session
|
||||
/// (<c>retention.remove_uninstalled_games</c>, on by default).
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private bool _removeUninstalledGames;
|
||||
|
||||
[ObservableProperty]
|
||||
private int _minSessionSeconds;
|
||||
|
||||
@@ -384,6 +391,8 @@ public sealed partial class SettingsViewModel : ObservableObject
|
||||
|
||||
partial void OnRetentionRawSessionsChanged(int oldValue, int newValue) => PersistNumber(SettingsRegistry.RetentionRawSessionsPerGame, Strings.Settings_Retention_Label, oldValue, newValue, v => RetentionRawSessions = v);
|
||||
|
||||
partial void OnRemoveUninstalledGamesChanged(bool value) => Persist(SettingsRegistry.RetentionRemoveUninstalledGames, value);
|
||||
|
||||
partial void OnHideAntiCheatHookingChanged(bool value) => Persist(SettingsRegistry.UiHideAntiCheatHooking, value);
|
||||
|
||||
/// <summary>D33: the option is one settings row the Agent reads at every session start and command; the list follows it.</summary>
|
||||
@@ -532,6 +541,7 @@ public sealed partial class SettingsViewModel : ObservableObject
|
||||
MinSessionSeconds = await _settings.GetIntegerAsync(SettingsRegistry.CaptureMinSessionSeconds).ConfigureAwait(true);
|
||||
TelemetryIntervalMs = await _settings.GetIntegerAsync(SettingsRegistry.TelemetryIntervalMs).ConfigureAwait(true);
|
||||
RetentionRawSessions = await _settings.GetIntegerAsync(SettingsRegistry.RetentionRawSessionsPerGame).ConfigureAwait(true);
|
||||
RemoveUninstalledGames = await _settings.GetBooleanAsync(SettingsRegistry.RetentionRemoveUninstalledGames).ConfigureAwait(true);
|
||||
MinimizeToTray = await _settings.GetBooleanAsync(SettingsRegistry.UiMinimizeToTray).ConfigureAwait(true);
|
||||
HideAntiCheatHooking = await _settings.GetBooleanAsync(SettingsRegistry.UiHideAntiCheatHooking).ConfigureAwait(true);
|
||||
UserModeExceptions = await _settings.GetBooleanAsync(SettingsRegistry.HookingUserModeExceptions).ConfigureAwait(true);
|
||||
@@ -767,8 +777,12 @@ public sealed partial class SettingsViewModel : ObservableObject
|
||||
if (definition.AgentReads)
|
||||
{
|
||||
// Disable all hooking does not wait for a session to start (beta.18): a measured one stops at its next safety scan.
|
||||
// Nor does the removal of uninstalled games (beta.19, D55): the Agent reads it at every sweep.
|
||||
bool killSwitchOn = ReferenceEquals(definition, SettingsRegistry.HookingKillSwitch) && string.Equals(value, "1", StringComparison.Ordinal);
|
||||
_strip.Info(Strings.Settings_Header, killSwitchOn ? Strings.Settings_KillSwitch_Applied_On : Strings.Settings_Applied);
|
||||
string applied = killSwitchOn ? Strings.Settings_KillSwitch_Applied_On
|
||||
: ReferenceEquals(definition, SettingsRegistry.RetentionRemoveUninstalledGames) ? Strings.Settings_RemoveUninstalled_Applied
|
||||
: Strings.Settings_Applied;
|
||||
_strip.Info(Strings.Settings_Header, applied);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -40,6 +40,7 @@ public sealed class DetectionSweep : IDisposable
|
||||
private readonly IExecutableIdentitySource _identity;
|
||||
private readonly Action<string> _log;
|
||||
private readonly ExecutableRelocator? _relocator;
|
||||
private readonly UninstalledEntryPrune? _prune;
|
||||
private readonly SemaphoreSlim _wake = new(0, 1);
|
||||
|
||||
// The path each unreadable entry was last reported at (2026-09-23): said once until it changes or reads again. The
|
||||
@@ -53,8 +54,9 @@ public sealed class DetectionSweep : IDisposable
|
||||
/// <param name="identity">Reads each row's executable (its fingerprint), or null when it cannot.</param>
|
||||
/// <param name="log">The Agent's log line.</param>
|
||||
/// <param name="relocator">Follows an executable to a drive that changed its letter (2026-09-22); null sweeps without looking.</param>
|
||||
/// <param name="prune">Removes an entry whose game is no longer installed and had no session (beta.19, D55); null removes nothing.</param>
|
||||
public DetectionSweep(IGameRepository games, IDetectionRulesSource rules, IGameFileProbe probe, IExecutableIdentitySource identity, Action<string> log,
|
||||
ExecutableRelocator? relocator = null)
|
||||
ExecutableRelocator? relocator = null, UninstalledEntryPrune? prune = null)
|
||||
{
|
||||
_games = games ?? throw new ArgumentNullException(nameof(games));
|
||||
_rules = rules ?? throw new ArgumentNullException(nameof(rules));
|
||||
@@ -62,6 +64,7 @@ public sealed class DetectionSweep : IDisposable
|
||||
_identity = identity ?? throw new ArgumentNullException(nameof(identity));
|
||||
_log = log ?? throw new ArgumentNullException(nameof(log));
|
||||
_relocator = relocator;
|
||||
_prune = prune;
|
||||
_detector = new StaticGameDetector(rules, probe);
|
||||
}
|
||||
|
||||
@@ -101,6 +104,7 @@ public sealed class DetectionSweep : IDisposable
|
||||
int current = 0;
|
||||
int unreadable = 0;
|
||||
int relocated = 0;
|
||||
int removed = 0;
|
||||
foreach (GameRow listed in await _games.ListAsync(ct).ConfigureAwait(false))
|
||||
{
|
||||
ct.ThrowIfCancellationRequested();
|
||||
@@ -119,17 +123,14 @@ public sealed class DetectionSweep : IDisposable
|
||||
|
||||
if (read is not { } onDisk)
|
||||
{
|
||||
unreadable++;
|
||||
if (!_unreadableSaid.TryGetValue(game.Id, out string? said) || !string.Equals(said, game.Fingerprint.ExePath, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
_unreadableSaid[game.Id] = game.Fingerprint.ExePath;
|
||||
_log($"detect: {game.Name} — executable unreadable, skipped ({game.Fingerprint.ExePath}); said once until that changes");
|
||||
}
|
||||
|
||||
bool uninstalled = await UnreadableAsync(game, ct).ConfigureAwait(false);
|
||||
removed += uninstalled ? 1 : 0;
|
||||
unreadable += uninstalled ? 0 : 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
_unreadableSaid.Remove(game.Id);
|
||||
_prune?.Present(game.Id);
|
||||
|
||||
if (!IsStale(game, onDisk, rules.RulesVersion))
|
||||
{
|
||||
@@ -143,7 +144,28 @@ public sealed class DetectionSweep : IDisposable
|
||||
}
|
||||
}
|
||||
|
||||
return new DetectionSweepReport { Scanned = scanned, Current = current, Unreadable = unreadable, Relocated = relocated };
|
||||
return new DetectionSweepReport { Scanned = scanned, Current = current, Unreadable = unreadable, Relocated = relocated, Removed = removed };
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// An entry whose executable did not read, after the relocator looked for it on every other drive: removed when its game
|
||||
/// is no longer installed and it had no session (beta.19, D55), else skipped and named once. True when it was removed.
|
||||
/// </summary>
|
||||
private async ValueTask<bool> UnreadableAsync(GameRow game, CancellationToken ct)
|
||||
{
|
||||
if (_prune is not null && await _prune.ConsiderAsync(game, ct).ConfigureAwait(false))
|
||||
{
|
||||
_unreadableSaid.Remove(game.Id);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!_unreadableSaid.TryGetValue(game.Id, out string? said) || !string.Equals(said, game.Fingerprint.ExePath, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
_unreadableSaid[game.Id] = game.Fingerprint.ExePath;
|
||||
_log($"detect: {game.Name} — executable unreadable, skipped ({game.Fingerprint.ExePath}); said once until that changes");
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -18,6 +18,9 @@ public sealed record DetectionSweepReport
|
||||
/// <summary>Rows whose executable was found under another drive letter and moved there this pass (2026-09-22).</summary>
|
||||
public int Relocated { get; init; }
|
||||
|
||||
/// <summary>Entries removed this pass because their game is no longer installed and had no session (beta.19, D55).</summary>
|
||||
public int Removed { get; init; }
|
||||
|
||||
/// <summary>The rules file could not be loaded; nothing was scanned.</summary>
|
||||
public bool RulesUnusable { get; init; }
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
|
||||
|
||||
namespace FrameLedger.Application.Persistence;
|
||||
|
||||
/// <summary>
|
||||
/// Removes a library entry whose game is no longer installed (beta.19, owner decision D55) — the second Agent write that
|
||||
/// deletes a <c>games</c> row, after the twin merge (<see cref="IGameMerge"/>; <c>06_DATA_MODEL</c> §Writer ownership).
|
||||
/// </summary>
|
||||
public interface IGamePrune
|
||||
{
|
||||
/// <summary>
|
||||
/// Deletes the entry when, in the same statement, it is still at <paramref name="exePath"/>, still in the library, has
|
||||
/// no session stored, and carries no anti-cheat block, exception or failed-trial mark (CLAUDE.md rule 2: nothing clears
|
||||
/// a block). True when it was deleted; false when any condition no longer held — nothing is written then.
|
||||
/// </summary>
|
||||
ValueTask<bool> RemoveUninstalledAsync(long gameId, string exePath, CancellationToken ct = default);
|
||||
}
|
||||
@@ -174,6 +174,20 @@ public static class SettingsRegistry
|
||||
AgentReads = true,
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Whether the Agent removes a library entry whose game is no longer installed and that has no session (beta.19, owner
|
||||
/// decision D55, amending D41's "nothing is removed"): its executable gone at sweeps ten minutes apart, on a drive that is
|
||||
/// connected, from a folder whose parents are still there — never an entry carrying an anti-cheat block or exception.
|
||||
/// On by default; off, such an entry stays and reads <i>Not installed</i>. The Agent reads it at every sweep (15 s).
|
||||
/// </summary>
|
||||
public static readonly SettingDefinition RetentionRemoveUninstalledGames = new()
|
||||
{
|
||||
Key = "retention.remove_uninstalled_games",
|
||||
Kind = SettingKind.Boolean,
|
||||
Default = "1",
|
||||
AgentReads = true,
|
||||
};
|
||||
|
||||
/// <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). <c>auto</c>, the default since beta.14 (owner decision D47), follows the
|
||||
@@ -217,7 +231,7 @@ public static class SettingsRegistry
|
||||
[
|
||||
UiLanguage, UiTheme, UiStartWithWindows, UiMinimizeToTray, UiHideAntiCheatHooking, UiFpsDecimals, UiHideScrollBars, UiLibraryView,
|
||||
CaptureBackground, HookingKillSwitch, HookingUserModeExceptions, CaptureRunElevated, CaptureMinSessionSeconds, TelemetryIntervalMs, RetentionRawSessionsPerGame,
|
||||
UpdateChannel, UpdateAutoCheck, PrivacyOnlineMetadata, LogDebug,
|
||||
RetentionRemoveUninstalledGames, UpdateChannel, UpdateAutoCheck, PrivacyOnlineMetadata, LogDebug,
|
||||
];
|
||||
|
||||
private static readonly Dictionary<string, SettingDefinition> _byKey = All.ToDictionary(static d => d.Key, StringComparer.Ordinal);
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
|
||||
|
||||
namespace FrameLedger.Application.Watch;
|
||||
|
||||
/// <summary>
|
||||
/// Why an entry's executable did not read (beta.19, D55) — the distinctions <c>ExecutableIdentity.Read</c>'s null does not
|
||||
/// make, and the only ones that may remove an entry: <see cref="FileGone"/> is the one answer that does.
|
||||
/// </summary>
|
||||
public enum ExecutablePresence
|
||||
{
|
||||
/// <summary>Nothing could be told (a share, a refused listing, an error) — never a reason to remove anything.</summary>
|
||||
Unknown,
|
||||
|
||||
/// <summary>The file is there.</summary>
|
||||
Present,
|
||||
|
||||
/// <summary>Its drive is not connected (or not ready): the relocator follows it when it is back on another letter.</summary>
|
||||
DriveAbsent,
|
||||
|
||||
/// <summary>
|
||||
/// The drive is there, and nothing of the path is but its root: a different disk under the same letter as easily as an
|
||||
/// uninstall, so not one.
|
||||
/// </summary>
|
||||
OnlyTheDriveRemains,
|
||||
|
||||
/// <summary>The file is gone from a folder that is still there, or its folder is gone from one that is: uninstalled.</summary>
|
||||
FileGone,
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
|
||||
|
||||
namespace FrameLedger.Application.Watch;
|
||||
|
||||
/// <summary>Tells why an entry's executable did not read (beta.19, D55; <see cref="ExecutablePresence"/>).</summary>
|
||||
public interface IExecutablePresence
|
||||
{
|
||||
/// <summary>What the file system says about <paramref name="exePath"/> — read only, never a process.</summary>
|
||||
ExecutablePresence Probe(string exePath);
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
|
||||
|
||||
using System.Globalization;
|
||||
using FrameLedger.Application.Ipc;
|
||||
using FrameLedger.Application.Persistence;
|
||||
using FrameLedger.Shared.Ipc;
|
||||
|
||||
namespace FrameLedger.Application.Watch;
|
||||
|
||||
/// <summary>
|
||||
/// Removes a library entry whose game is no longer installed and that has no session (beta.19, owner decision D55, amending
|
||||
/// D41's "nothing is removed"). Asked by <c>DetectionSweep</c> about every entry whose executable stayed unreadable after the
|
||||
/// relocator looked for it on the other drives.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// <b>Every condition, or nothing.</b> The file is <see cref="ExecutablePresence.FileGone"/> — its drive connected, its folder
|
||||
/// or the file gone from a folder that is still there, not a refused listing; it has been so at sweeps at least
|
||||
/// <see cref="Grace"/> apart, at the same path (an update that replaces the executable is not an uninstall); the user's switch
|
||||
/// (<c>retention.remove_uninstalled_games</c>, on by default) is on; no session of it is being recorded or waits in a
|
||||
/// <c>.partial</c> to be recovered; and it carries no anti-cheat block, exception or failed-trial mark — rule 2's block is
|
||||
/// never cleared, and a re-added entry would start without it. The delete itself (<see cref="IGamePrune"/>) checks the stored
|
||||
/// conditions again in one statement, with "no session stored" among them, so a session finalized meanwhile wins.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// <b>Counted in memory.</b> When the file was first seen gone is this object's, not the ledger's: an Agent restart starts
|
||||
/// the ten minutes again, which only delays a removal. An entry the delete refused (it has sessions) is asked again at that
|
||||
/// path only after <see cref="RetryAfter"/> — its sessions may since have been deleted (FR-1.7), and an answer that does not
|
||||
/// change is not worth a statement every 15 seconds.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
public sealed class UninstalledEntryPrune
|
||||
{
|
||||
/// <summary>How long a file must have been gone — across sweeps — before its entry goes: longer than a store takes to replace an executable.</summary>
|
||||
public static readonly TimeSpan Grace = TimeSpan.FromMinutes(10);
|
||||
|
||||
/// <summary>How long an entry the delete refused waits before it is asked again.</summary>
|
||||
public static readonly TimeSpan RetryAfter = TimeSpan.FromHours(1);
|
||||
|
||||
private readonly IGamePrune _prune;
|
||||
private readonly IExecutablePresence _presence;
|
||||
private readonly Func<CancellationToken, ValueTask<bool>> _enabled;
|
||||
private readonly Func<long, bool> _busy;
|
||||
private readonly Action<string> _log;
|
||||
private readonly IIpcEventPublisher? _pipe;
|
||||
private readonly TimeProvider _clock;
|
||||
private readonly Dictionary<long, (string Path, DateTimeOffset Since)> _goneSince = [];
|
||||
private readonly Dictionary<(long Id, string Path), DateTimeOffset> _kept = [];
|
||||
|
||||
/// <summary>The prune over its writer, the file system's answer, the user's switch and the recorder's state.</summary>
|
||||
/// <param name="prune">The one conditional delete.</param>
|
||||
/// <param name="presence">Why an executable did not read.</param>
|
||||
/// <param name="enabled">The user's switch, read at every sweep.</param>
|
||||
/// <param name="busy">True while a session of the entry is recorded or waits to be recovered.</param>
|
||||
/// <param name="log">The Agent's log line.</param>
|
||||
/// <param name="pipe">Where the App hears of a removal; null tells nobody.</param>
|
||||
/// <param name="clock">The time the grace is counted in.</param>
|
||||
public UninstalledEntryPrune(IGamePrune prune, IExecutablePresence presence, Func<CancellationToken, ValueTask<bool>> enabled, Func<long, bool> busy,
|
||||
Action<string> log, IIpcEventPublisher? pipe = null, TimeProvider? clock = null)
|
||||
{
|
||||
_prune = prune ?? throw new ArgumentNullException(nameof(prune));
|
||||
_presence = presence ?? throw new ArgumentNullException(nameof(presence));
|
||||
_enabled = enabled ?? throw new ArgumentNullException(nameof(enabled));
|
||||
_busy = busy ?? throw new ArgumentNullException(nameof(busy));
|
||||
_log = log ?? throw new ArgumentNullException(nameof(log));
|
||||
_pipe = pipe;
|
||||
_clock = clock ?? TimeProvider.System;
|
||||
}
|
||||
|
||||
/// <summary>The entry's executable read: whatever was counted against it is forgotten.</summary>
|
||||
public void Present(long gameId) => _goneSince.Remove(gameId);
|
||||
|
||||
/// <summary>
|
||||
/// The entry's executable did not read and was not relocated: is the game uninstalled, and may its entry go? True when the
|
||||
/// entry was removed.
|
||||
/// </summary>
|
||||
public async ValueTask<bool> ConsiderAsync(GameRow game, CancellationToken ct = default)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(game);
|
||||
string path = game.Fingerprint.ExePath;
|
||||
if (_presence.Probe(path) != ExecutablePresence.FileGone)
|
||||
{
|
||||
_goneSince.Remove(game.Id);
|
||||
return false;
|
||||
}
|
||||
|
||||
DateTimeOffset now = _clock.GetUtcNow();
|
||||
if (!_goneSince.TryGetValue(game.Id, out (string Path, DateTimeOffset Since) seen) || !string.Equals(seen.Path, path, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
_goneSince[game.Id] = (path, now);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (now - seen.Since < Grace || (_kept.TryGetValue((game.Id, path), out DateTimeOffset refused) && now - refused < RetryAfter)
|
||||
|| CarriesAntiCheatState(game) || _busy(game.Id)
|
||||
|| !await _enabled(ct).ConfigureAwait(false))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!await _prune.RemoveUninstalledAsync(game.Id, path, ct).ConfigureAwait(false))
|
||||
{
|
||||
_kept[(game.Id, path)] = now;
|
||||
return false;
|
||||
}
|
||||
|
||||
_goneSince.Remove(game.Id);
|
||||
_log(string.Create(CultureInfo.InvariantCulture,
|
||||
$"library: removed '{game.Name}' — {path} has been gone since {seen.Since:u} and the entry had no session (D55; Settings ▸ Data turns this off)"));
|
||||
_pipe?.Publish(IpcMessageType.GameRemoved, new GameRemovedEvent(game.Id, game.Name, path, GameRemovedEvent.Uninstalled));
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>A block, an exception or a failed trial: what rule 2 and D38 keep for good, and a removal would drop.</summary>
|
||||
private static bool CarriesAntiCheatState(GameRow game) =>
|
||||
game.BlockedByGuard || game.AcException.GrantedAt is not null || game.AcException.TrialFailed;
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
|
||||
|
||||
using Dapper;
|
||||
using FrameLedger.Application.Persistence;
|
||||
|
||||
namespace FrameLedger.Infrastructure.Persistence;
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="IGamePrune"/> over the ledger (beta.19, owner decision D55): one statement that deletes an uninstalled entry
|
||||
/// only while every stored condition still holds — the same row at the same path, in the library, no session stored
|
||||
/// (<c>sessions.game_id</c> is the only reference to <c>games</c> and would cascade), and no anti-cheat block, exception or
|
||||
/// failed-trial mark. Whatever changed between the sweep's read and this write — a session finalized, a block written, the
|
||||
/// entry re-pointed — leaves the row as it is.
|
||||
/// </summary>
|
||||
public sealed class SqliteGamePrune : IGamePrune
|
||||
{
|
||||
private const string _delete =
|
||||
"DELETE FROM games WHERE id = @id AND exe_path = @path AND removed_at IS NULL "
|
||||
+ "AND hook_blocked_reason IS NULL AND hook_prescan_state <> 'blocked' "
|
||||
+ "AND ac_exception_at IS NULL AND ac_exception_trial_failed_at IS NULL "
|
||||
+ "AND NOT EXISTS (SELECT 1 FROM sessions WHERE sessions.game_id = games.id)";
|
||||
|
||||
private readonly LedgerDatabase _db;
|
||||
|
||||
public SqliteGamePrune(LedgerDatabase db) => _db = db ?? throw new ArgumentNullException(nameof(db));
|
||||
|
||||
/// <inheritdoc />
|
||||
public async ValueTask<bool> RemoveUninstalledAsync(long gameId, string exePath, CancellationToken ct = default)
|
||||
{
|
||||
ArgumentException.ThrowIfNullOrWhiteSpace(exePath);
|
||||
int deleted = await _db.WriteAsync((c, tx, token) => c.ExecuteAsync(new CommandDefinition(_delete, new { id = gameId, path = exePath }, tx, cancellationToken: token)), ct)
|
||||
.ConfigureAwait(false);
|
||||
return deleted == 1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
|
||||
|
||||
using System.Security;
|
||||
using FrameLedger.Application.Watch;
|
||||
|
||||
namespace FrameLedger.Infrastructure.Watch;
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="IExecutablePresence"/> over the file system (beta.19, D55): tells a game that is no longer installed from a
|
||||
/// drive that is not connected, a different disk under the same letter, and a folder Windows will not list — the cases
|
||||
/// <c>ExecutableIdentity.Read</c>'s null runs together.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// <b>Asked of listings, not of <c>Exists</c>.</b> <c>File.Exists</c> and <c>Directory.Exists</c> answer false for a path
|
||||
/// they may not look at as for one that is not there, so the file is looked for in its folder's listing, and a folder that
|
||||
/// reads as missing is looked for in its parent's: listed but unreadable is <see cref="ExecutablePresence.Unknown"/>.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// <b>The drive and the path above the game.</b> A drive that <see cref="VolumeRoots"/> does not list as ready (fixed or
|
||||
/// removable — never a share) is <see cref="ExecutablePresence.DriveAbsent"/>. When nothing of the path is left but the
|
||||
/// drive's root, the letter may well be another disk's now (the owner's USB drive has changed letters, 2026-09-22):
|
||||
/// <see cref="ExecutablePresence.OnlyTheDriveRemains"/>, never a removal. An uninstall leaves the folder the game was
|
||||
/// installed in — <c>steamapps\common</c>, the itch location, <c>D:\Games</c>.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
public sealed class ExecutablePresenceProbe : IExecutablePresence
|
||||
{
|
||||
private readonly Func<string, bool> _driveReady;
|
||||
|
||||
/// <summary>
|
||||
/// The probe over <paramref name="driveReady"/>: whether a root is a ready fixed or removable drive — by default
|
||||
/// <see cref="VolumeRoots.IsReady"/>, which asks that one drive rather than listing them all for every entry.
|
||||
/// </summary>
|
||||
public ExecutablePresenceProbe(Func<string, bool>? driveReady = null) => _driveReady = driveReady ?? VolumeRoots.IsReady;
|
||||
|
||||
/// <inheritdoc />
|
||||
public ExecutablePresence Probe(string exePath)
|
||||
{
|
||||
ArgumentException.ThrowIfNullOrWhiteSpace(exePath);
|
||||
try
|
||||
{
|
||||
string full = Path.GetFullPath(exePath);
|
||||
string? root = Path.GetPathRoot(full);
|
||||
string? folder = Path.GetDirectoryName(full);
|
||||
if (string.IsNullOrEmpty(root) || folder is null || full.StartsWith(@"\\", StringComparison.Ordinal))
|
||||
{
|
||||
return ExecutablePresence.Unknown;
|
||||
}
|
||||
|
||||
if (!_driveReady(root))
|
||||
{
|
||||
return ExecutablePresence.DriveAbsent;
|
||||
}
|
||||
|
||||
if (Directory.Exists(folder))
|
||||
{
|
||||
return Directory.EnumerateFiles(folder, Path.GetFileName(full)).Any() ? ExecutablePresence.Present : Gone(folder, root);
|
||||
}
|
||||
|
||||
// The folder reads as missing: up to the nearest folder that is there, which must list the one below it as absent.
|
||||
string missing = folder;
|
||||
string? parent = Path.GetDirectoryName(missing);
|
||||
while (parent is not null && !Directory.Exists(parent))
|
||||
{
|
||||
missing = parent;
|
||||
parent = Path.GetDirectoryName(parent);
|
||||
}
|
||||
|
||||
return parent is null || Directory.EnumerateDirectories(parent, Path.GetFileName(missing)).Any()
|
||||
? ExecutablePresence.Unknown
|
||||
: Gone(parent, root);
|
||||
}
|
||||
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or ArgumentException or NotSupportedException or SecurityException)
|
||||
{
|
||||
return ExecutablePresence.Unknown;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Gone from <paramref name="nearest"/>, the nearest folder still there — unless that is the drive's root.</summary>
|
||||
private static ExecutablePresence Gone(string nearest, string root) =>
|
||||
string.Equals(Path.TrimEndingDirectorySeparator(nearest), Path.TrimEndingDirectorySeparator(root), StringComparison.OrdinalIgnoreCase)
|
||||
? ExecutablePresence.OnlyTheDriveRemains
|
||||
: ExecutablePresence.FileGone;
|
||||
}
|
||||
@@ -30,4 +30,23 @@ public static class VolumeRoots
|
||||
|
||||
return roots;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Whether the one drive <paramref name="root"/> names is a ready fixed or removable drive (beta.19) — the same test as
|
||||
/// <see cref="Ready"/>, asked of one drive. The type is read first: a network or optical drive is never asked whether it
|
||||
/// is ready, which can block for seconds on a share that went away.
|
||||
/// </summary>
|
||||
public static bool IsReady(string root)
|
||||
{
|
||||
ArgumentException.ThrowIfNullOrWhiteSpace(root);
|
||||
try
|
||||
{
|
||||
var drive = new DriveInfo(root);
|
||||
return drive.DriveType is DriveType.Fixed or DriveType.Removable && drive.IsReady;
|
||||
}
|
||||
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or ArgumentException)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -32,6 +32,7 @@ namespace FrameLedger.Shared.Ipc;
|
||||
[JsonSerializable(typeof(CaptureDegradedEvent))]
|
||||
[JsonSerializable(typeof(SafetyUnhookEvent))]
|
||||
[JsonSerializable(typeof(HookingTurnedOffEvent))]
|
||||
[JsonSerializable(typeof(GameRemovedEvent))]
|
||||
[JsonSerializable(typeof(CaptureErrorEvent))]
|
||||
[JsonSerializable(typeof(WatchlistEntry))]
|
||||
[JsonSerializable(typeof(SetWatchlistRequest))]
|
||||
|
||||
@@ -84,6 +84,12 @@ public static class IpcMessageType
|
||||
/// need be running.
|
||||
/// </summary>
|
||||
public const string HookingTurnedOff = "HookingTurnedOff";
|
||||
|
||||
/// <summary>
|
||||
/// The Agent removed a library entry by itself (beta.19, owner decision D55): its game is no longer installed and it had
|
||||
/// no session. Not a session event; the App reloads what shows the library.
|
||||
/// </summary>
|
||||
public const string GameRemoved = "GameRemoved";
|
||||
}
|
||||
|
||||
/// <summary>Codes an <see cref="ErrorAck"/> carries.</summary>
|
||||
@@ -313,6 +319,16 @@ public sealed record CaptureErrorEvent(Guid? SessionGuid, string Code, string Me
|
||||
/// <summary><see cref="IpcMessageType.HookingTurnedOff"/>: which entry, and what the guard found (its reason, family and signal).</summary>
|
||||
public sealed record HookingTurnedOffEvent(long GameId, string? GameName, string Reason, string? Family, string? Signal);
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="IpcMessageType.GameRemoved"/> (beta.19, D55): the entry the Agent removed, its executable's path, and why —
|
||||
/// <see cref="Uninstalled"/>, the one reason there is: gone from its folder for ten minutes, with no session.
|
||||
/// </summary>
|
||||
public sealed record GameRemovedEvent(long GameId, string? GameName, string ExePath, string Reason)
|
||||
{
|
||||
/// <summary>The executable is no longer installed and the entry had no session.</summary>
|
||||
public const string Uninstalled = "uninstalled";
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------------------------------------
|
||||
// The command half (P3 PR-1b). 07_IPC §The pipe is not a trust boundary: none of these carries a verdict, a
|
||||
// clearance, a consent record or a rules source — a client asks, the Agent establishes the fact itself.
|
||||
|
||||
@@ -92,6 +92,55 @@ public sealed class GamesViewModelTests
|
||||
vm.Games.Should().HaveCount(2);
|
||||
}
|
||||
|
||||
private sealed class RecordingStrip : IMessageStrip
|
||||
{
|
||||
public List<string> Lines { get; } = [];
|
||||
|
||||
public void Info(string title, string body) => Lines.Add(title + ": " + body);
|
||||
|
||||
public void Success(string title, string body) => Lines.Add(title + ": " + body);
|
||||
|
||||
public void Warn(string title, string body) => Lines.Add(title + ": " + body);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// beta.19, D55: the Agent removed an entry whose game is no longer installed — the page on screen drops its card at once
|
||||
/// and says why, in words that name the switch that turns it off.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public async Task AnEntryTheAgentRemovedLeavesThePageOnScreenWithAWord()
|
||||
{
|
||||
CultureInfo? previous = Strings.Culture;
|
||||
Strings.Culture = CultureInfo.GetCultureInfo("en");
|
||||
try
|
||||
{
|
||||
await using ScratchLedger s = await ScratchLedger.OpenAsync();
|
||||
GameRow gone = await s.GameAsync("Gone");
|
||||
_ = await s.GameAsync("Kept");
|
||||
var selection = new GameSelection();
|
||||
var nav = new NoNavigation();
|
||||
var link = new FakeAgentLink();
|
||||
var strip = new RecordingStrip();
|
||||
var vm = new GamesViewModel(s.Library, selection, nav, new AddGameFlow(s.Library, new NoPicker(), selection, nav, new NoStrip()), agent: link, strip: strip);
|
||||
Task loaded = vm.Pending;
|
||||
await loaded;
|
||||
vm.Attach();
|
||||
|
||||
// What the Agent did, then said.
|
||||
await s.Db.WriteAsync((c, tx, ct) => Dapper.SqlMapper.ExecuteAsync(c, new Dapper.CommandDefinition("DELETE FROM games WHERE id = @id", new { id = gone.Id }, tx, cancellationToken: ct)), Ct);
|
||||
link.Raise(IpcMessageType.GameRemoved, new GameRemovedEvent(gone.Id, "Gone", gone.Fingerprint.ExePath, GameRemovedEvent.Uninstalled));
|
||||
Task reloaded = vm.Pending;
|
||||
await reloaded;
|
||||
|
||||
vm.Games.Should().ContainSingle().Which.Name.Should().Be("Kept");
|
||||
strip.Lines.Should().ContainSingle().Which.Should().StartWith("Removed from the library: Gone is no longer installed").And.Contain("Settings ▸ Data");
|
||||
}
|
||||
finally
|
||||
{
|
||||
Strings.Culture = previous;
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ACardSaysWhetherItsExecutableIsThereAndWhy()
|
||||
{
|
||||
|
||||
@@ -141,6 +141,7 @@ public sealed class ViewerModeTests
|
||||
[SettingsRegistry.CaptureMinSessionSeconds.Key] = ("Value", "MinSessionSeconds, Mode=TwoWay"),
|
||||
[SettingsRegistry.TelemetryIntervalMs.Key] = ("Value", "TelemetryIntervalMs, Mode=TwoWay"),
|
||||
[SettingsRegistry.RetentionRawSessionsPerGame.Key] = ("Value", "RetentionRawSessions, Mode=TwoWay"),
|
||||
[SettingsRegistry.RetentionRemoveUninstalledGames.Key] = ("IsChecked", "RemoveUninstalledGames, Mode=TwoWay"),
|
||||
};
|
||||
XDocument xaml = AccessibilityTests.AppXaml().Single(static x => string.Equals(x.File, Path.Combine("Pages", "SettingsPage.xaml"), StringComparison.Ordinal)).Xaml;
|
||||
|
||||
|
||||
@@ -270,6 +270,57 @@ public sealed class DetectionSweepTests
|
||||
log.Where(static l => l.Contains("unreadable", StringComparison.Ordinal)).Should().HaveCount(2, "it read in between, so going unreadable again is news");
|
||||
}
|
||||
|
||||
private sealed class PruneClock : TimeProvider
|
||||
{
|
||||
public DateTimeOffset Now { get; set; } = new(2026, 10, 12, 8, 0, 0, TimeSpan.Zero);
|
||||
|
||||
public override DateTimeOffset GetUtcNow() => Now;
|
||||
}
|
||||
|
||||
private sealed class GonePresence : IExecutablePresence
|
||||
{
|
||||
public ExecutablePresence Probe(string exePath) => ExecutablePresence.FileGone;
|
||||
}
|
||||
|
||||
private sealed class DeletingPrune : IGamePrune
|
||||
{
|
||||
public List<long> Deleted { get; } = [];
|
||||
|
||||
public ValueTask<bool> RemoveUninstalledAsync(long gameId, string exePath, CancellationToken ct = default)
|
||||
{
|
||||
Deleted.Add(gameId);
|
||||
return ValueTask.FromResult(true);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// beta.19, D55: an unreadable entry whose game is no longer installed is asked about after the relocator, and once the
|
||||
/// prune removes it the sweep counts it removed — not unreadable — and says nothing else about it.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public async Task AnUninstalledEntryIsRemovedAfterTheGraceAndCountedAsRemoved()
|
||||
{
|
||||
var games = new FakeGameRepository();
|
||||
await games.EnsureAsync(new ExecutableFingerprint { ExePath = _exe, SizeBytes = 1, MtimeUnixMs = 1 }, "Title", Ct);
|
||||
var identity = new FakeIdentity { OnDisk = null };
|
||||
var clock = new PruneClock();
|
||||
var deleting = new DeletingPrune();
|
||||
List<string> log = [];
|
||||
var prune = new UninstalledEntryPrune(deleting, new GonePresence(), static _ => ValueTask.FromResult(true), static _ => false, log.Add, clock: clock);
|
||||
using var sweep = new DetectionSweep(games, new ScriptedRules("2026.10.2"), new ScriptedProbe(), identity, log.Add, prune: prune);
|
||||
|
||||
DetectionSweepReport first = await sweep.SweepOnceAsync(Ct);
|
||||
first.Unreadable.Should().Be(1);
|
||||
first.Removed.Should().Be(0, "the first sweep that sees it gone only starts the count");
|
||||
|
||||
clock.Now += UninstalledEntryPrune.Grace;
|
||||
DetectionSweepReport second = await sweep.SweepOnceAsync(Ct);
|
||||
second.Removed.Should().Be(1);
|
||||
second.Unreadable.Should().Be(0);
|
||||
deleting.Deleted.Should().ContainSingle();
|
||||
log.Should().Contain(static l => l.StartsWith("library: removed 'Title'", StringComparison.Ordinal));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task RequestNowWakesTheWaitBeforeTheIntervalAndIsIdempotent()
|
||||
{
|
||||
|
||||
@@ -78,8 +78,9 @@ public sealed class SettingsRegistryTests
|
||||
// hooking.usermode_ac_exceptions joined on 2026-09-26 (D33): the user-mode exception's option, off by default.
|
||||
// capture.run_elevated joined on 2026-09-27 (D34): the admin mode, read before the Agent exists.
|
||||
// capture.background left in beta.12: it was listed here and no Agent code ever read it; the key is reserved.
|
||||
// retention.remove_uninstalled_games joined in beta.19 (D55): the detection sweep reads it at every pass.
|
||||
agent.Should().BeEquivalentTo(["hooking.kill_switch", "hooking.usermode_ac_exceptions", "capture.run_elevated",
|
||||
"capture.min_session_s", "telemetry.interval_ms", "retention.raw_sessions_per_game"]);
|
||||
"capture.min_session_s", "telemetry.interval_ms", "retention.raw_sessions_per_game", "retention.remove_uninstalled_games"]);
|
||||
agent.Should().OnlyContain(static k => k.StartsWith("hooking.", StringComparison.Ordinal) || k.StartsWith("capture.", StringComparison.Ordinal)
|
||||
|| k.StartsWith("telemetry.", StringComparison.Ordinal) || k.StartsWith("retention.", StringComparison.Ordinal));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,187 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
|
||||
|
||||
using FluentAssertions;
|
||||
using FrameLedger.Application.Persistence;
|
||||
using FrameLedger.Application.Tests.Ipc;
|
||||
using FrameLedger.Application.Watch;
|
||||
using FrameLedger.Domain.Consent;
|
||||
using FrameLedger.Shared.Ipc;
|
||||
|
||||
namespace FrameLedger.Application.Tests.Watch;
|
||||
|
||||
/// <summary>
|
||||
/// beta.19, owner decision D55: an entry whose game is no longer installed and that has no session goes — after ten minutes,
|
||||
/// with the switch on, never while a session of it runs or waits, never one carrying an anti-cheat block or exception, and
|
||||
/// never for a drive that is not there, a different disk under the same letter, or a folder Windows will not list.
|
||||
/// </summary>
|
||||
public sealed class UninstalledEntryPruneTests
|
||||
{
|
||||
private const string _path = @"D:\another\it\uninstalled\Game.exe";
|
||||
|
||||
private static CancellationToken Ct => TestContext.Current.CancellationToken;
|
||||
|
||||
private sealed class ManualClock : TimeProvider
|
||||
{
|
||||
public DateTimeOffset Now { get; set; } = new(2026, 10, 12, 8, 0, 0, TimeSpan.Zero);
|
||||
|
||||
public override DateTimeOffset GetUtcNow() => Now;
|
||||
|
||||
public void Advance(TimeSpan by) => Now += by;
|
||||
}
|
||||
|
||||
private sealed class FakePresence : IExecutablePresence
|
||||
{
|
||||
public ExecutablePresence Answer { get; set; } = ExecutablePresence.FileGone;
|
||||
|
||||
public ExecutablePresence Probe(string exePath) => Answer;
|
||||
}
|
||||
|
||||
private sealed class FakePrune : IGamePrune
|
||||
{
|
||||
/// <summary>What the stored conditions say; true unless the test says the row has sessions.</summary>
|
||||
public bool Deletes { get; set; } = true;
|
||||
|
||||
public List<(long Id, string Path)> Asked { get; } = [];
|
||||
|
||||
public ValueTask<bool> RemoveUninstalledAsync(long gameId, string exePath, CancellationToken ct = default)
|
||||
{
|
||||
Asked.Add((gameId, exePath));
|
||||
return ValueTask.FromResult(Deletes);
|
||||
}
|
||||
}
|
||||
|
||||
private sealed class Rig
|
||||
{
|
||||
public ManualClock Clock { get; } = new();
|
||||
|
||||
public FakePresence Presence { get; } = new();
|
||||
|
||||
public FakePrune Prune { get; } = new();
|
||||
|
||||
public RecordingPublisher Pipe { get; } = new();
|
||||
|
||||
public List<string> Log { get; } = [];
|
||||
|
||||
public bool On { get; set; } = true;
|
||||
|
||||
public bool Busy { get; set; }
|
||||
|
||||
public UninstalledEntryPrune Build() =>
|
||||
new(Prune, Presence, _ => ValueTask.FromResult(On), _ => Busy, Log.Add, Pipe, Clock);
|
||||
}
|
||||
|
||||
private static GameRow Row(string path = _path, long id = 7) => new()
|
||||
{
|
||||
Id = id,
|
||||
Name = "Uninstalled",
|
||||
Fingerprint = new ExecutableFingerprint { ExePath = path, SizeBytes = 1, MtimeUnixMs = 1 },
|
||||
HookEnabled = false,
|
||||
HookCrashCount = 0,
|
||||
AddedAt = DateTimeOffset.UnixEpoch,
|
||||
UpdatedAt = DateTimeOffset.UnixEpoch,
|
||||
};
|
||||
|
||||
[Fact]
|
||||
public async Task AGoneFileIsRemovedOnlyOnceItHasBeenGoneTenMinutesAndTheAppIsTold()
|
||||
{
|
||||
var rig = new Rig();
|
||||
UninstalledEntryPrune prune = rig.Build();
|
||||
|
||||
(await prune.ConsiderAsync(Row(), Ct)).Should().BeFalse("the first sweep that sees it gone starts the count");
|
||||
rig.Clock.Advance(TimeSpan.FromMinutes(9));
|
||||
(await prune.ConsiderAsync(Row(), Ct)).Should().BeFalse("nine minutes is a store replacing the file, perhaps");
|
||||
rig.Prune.Asked.Should().BeEmpty();
|
||||
|
||||
rig.Clock.Advance(TimeSpan.FromMinutes(1));
|
||||
(await prune.ConsiderAsync(Row(), Ct)).Should().BeTrue();
|
||||
|
||||
rig.Prune.Asked.Should().Equal([(7L, _path)]);
|
||||
rig.Log.Should().ContainSingle().Which.Should().Contain("removed 'Uninstalled'").And.Contain(_path).And.Contain("no session");
|
||||
rig.Pipe.Of<GameRemovedEvent>().Should().ContainSingle().Which.Should().Be(new GameRemovedEvent(7, "Uninstalled", _path, GameRemovedEvent.Uninstalled));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(ExecutablePresence.DriveAbsent)]
|
||||
[InlineData(ExecutablePresence.OnlyTheDriveRemains)]
|
||||
[InlineData(ExecutablePresence.Unknown)]
|
||||
[InlineData(ExecutablePresence.Present)]
|
||||
public async Task AnythingButAFileGoneFromAFolderThatIsStillThereRemovesNothingAndStartsTheCountAgain(ExecutablePresence presence)
|
||||
{
|
||||
var rig = new Rig();
|
||||
UninstalledEntryPrune prune = rig.Build();
|
||||
_ = await prune.ConsiderAsync(Row(), Ct);
|
||||
rig.Clock.Advance(TimeSpan.FromMinutes(30));
|
||||
|
||||
rig.Presence.Answer = presence;
|
||||
(await prune.ConsiderAsync(Row(), Ct)).Should().BeFalse();
|
||||
|
||||
rig.Presence.Answer = ExecutablePresence.FileGone;
|
||||
rig.Clock.Advance(TimeSpan.FromMinutes(1));
|
||||
(await prune.ConsiderAsync(Row(), Ct)).Should().BeFalse("the count started again when the answer changed");
|
||||
rig.Prune.Asked.Should().BeEmpty();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task AFileThatReadsAgainOrAnEntryReRepointedStartsTheCountAgain()
|
||||
{
|
||||
var rig = new Rig();
|
||||
UninstalledEntryPrune prune = rig.Build();
|
||||
_ = await prune.ConsiderAsync(Row(), Ct);
|
||||
rig.Clock.Advance(TimeSpan.FromMinutes(20));
|
||||
prune.Present(7);
|
||||
(await prune.ConsiderAsync(Row(), Ct)).Should().BeFalse("it read in between");
|
||||
|
||||
rig.Clock.Advance(TimeSpan.FromMinutes(20));
|
||||
(await prune.ConsiderAsync(Row(@"D:\another\it\uninstalled\Other.exe"), Ct)).Should().BeFalse("Change executable re-pointed it");
|
||||
rig.Prune.Asked.Should().BeEmpty();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task TheSwitchOffABusyEntryAndAnAntiCheatEntryAreKept()
|
||||
{
|
||||
var rig = new Rig { On = false };
|
||||
UninstalledEntryPrune prune = rig.Build();
|
||||
_ = await prune.ConsiderAsync(Row(), Ct);
|
||||
rig.Clock.Advance(TimeSpan.FromMinutes(15));
|
||||
(await prune.ConsiderAsync(Row(), Ct)).Should().BeFalse("Settings ▸ Data turned it off");
|
||||
|
||||
rig.On = true;
|
||||
rig.Busy = true;
|
||||
(await prune.ConsiderAsync(Row(), Ct)).Should().BeFalse("a session of it is recorded, or waits to be recovered");
|
||||
|
||||
rig.Busy = false;
|
||||
(await prune.ConsiderAsync(Row() with { HookBlockedReason = "BlockedModule EasyAntiCheat" }, Ct)).Should().BeFalse("rule 2: nothing clears a block");
|
||||
(await prune.ConsiderAsync(Row() with { HookPrescanState = "blocked" }, Ct)).Should().BeFalse();
|
||||
(await prune.ConsiderAsync(Row() with { AcException = AntiCheatExceptionState.None with { GrantedAt = DateTimeOffset.UnixEpoch, Family = "NetEase Yidun" } }, Ct))
|
||||
.Should().BeFalse("an exception's grant stays with its entry");
|
||||
(await prune.ConsiderAsync(Row() with { AcException = AntiCheatExceptionState.None with { TrialFailedAt = DateTimeOffset.UnixEpoch } }, Ct))
|
||||
.Should().BeFalse("D38: a failed trial ends the exception for good");
|
||||
rig.Prune.Asked.Should().BeEmpty();
|
||||
|
||||
(await prune.ConsiderAsync(Row(), Ct)).Should().BeTrue("the switch on, nothing running, no anti-cheat: it goes");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task AnEntryTheDeleteKeptBecauseItHasSessionsIsNotAskedAgain()
|
||||
{
|
||||
var rig = new Rig();
|
||||
rig.Prune.Deletes = false;
|
||||
UninstalledEntryPrune prune = rig.Build();
|
||||
_ = await prune.ConsiderAsync(Row(), Ct);
|
||||
rig.Clock.Advance(TimeSpan.FromMinutes(10));
|
||||
|
||||
(await prune.ConsiderAsync(Row(), Ct)).Should().BeFalse();
|
||||
(await prune.ConsiderAsync(Row(), Ct)).Should().BeFalse();
|
||||
|
||||
rig.Prune.Asked.Should().ContainSingle("the stored conditions said no once; the answer will not change every 15 seconds");
|
||||
rig.Log.Should().BeEmpty();
|
||||
rig.Pipe.Published.Should().BeEmpty();
|
||||
|
||||
// An hour on, its sessions may have been deleted (FR-1.7): it is asked again.
|
||||
rig.Prune.Deletes = true;
|
||||
rig.Clock.Advance(UninstalledEntryPrune.RetryAfter);
|
||||
(await prune.ConsiderAsync(Row(), Ct)).Should().BeTrue();
|
||||
rig.Prune.Asked.Should().HaveCount(2);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
|
||||
|
||||
using Dapper;
|
||||
using FluentAssertions;
|
||||
using FrameLedger.Application.Persistence;
|
||||
using FrameLedger.Domain.Consent;
|
||||
using FrameLedger.Domain.Sessions;
|
||||
using FrameLedger.Infrastructure.Persistence;
|
||||
|
||||
namespace FrameLedger.Infrastructure.Tests.Persistence;
|
||||
|
||||
/// <summary>
|
||||
/// beta.19, D55: the uninstalled entry's delete on a real ledger — it goes only while, in the same statement, it is the same
|
||||
/// row at the same path, in the library, with no session stored and no anti-cheat block, exception or failed-trial mark.
|
||||
/// </summary>
|
||||
public sealed class SqliteGamePruneTests
|
||||
{
|
||||
private static CancellationToken Ct => TestContext.Current.CancellationToken;
|
||||
|
||||
private static readonly ExecutableFingerprint _exe = new() { ExePath = @"D:\another\it\uninstalled\Game.exe", SizeBytes = 10, MtimeUnixMs = 20 };
|
||||
|
||||
private static Task<int> SetAsync(LedgerFixture f, long id, string assignments) =>
|
||||
f.Db.WriteAsync((c, tx, ct) => c.ExecuteAsync(new CommandDefinition($"UPDATE games SET {assignments} WHERE id = @id", new { id }, tx, cancellationToken: ct)), Ct).AsTask();
|
||||
|
||||
private static async Task AddSessionAsync(LedgerFixture f, long gameId)
|
||||
{
|
||||
long snapshotId = await new SqliteHardwareSnapshotRepository(f.Db).EnsureAsync(new HardwareSnapshot { GpuName = "G" }, DateTimeOffset.UnixEpoch, Ct).ConfigureAwait(false);
|
||||
_ = await new SqliteSessionRepository(f.Db).InsertFinalizedAsync(new FinalizedSession
|
||||
{
|
||||
Row = new SessionRow
|
||||
{
|
||||
SessionGuid = Guid.NewGuid(),
|
||||
GameId = gameId,
|
||||
SnapshotId = snapshotId,
|
||||
StartedAt = DateTimeOffset.UnixEpoch,
|
||||
EndedAt = DateTimeOffset.UnixEpoch.AddSeconds(60),
|
||||
QpcEpoch = 0,
|
||||
QpcFrequency = 1,
|
||||
Tier = CaptureTier.NotHooked,
|
||||
Mode = CaptureMode.Attach,
|
||||
ExitStatus = ExitStatus.Normal,
|
||||
},
|
||||
}, Ct).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task AnUninstalledEntryWithNothingToKeepIsDeleted()
|
||||
{
|
||||
await using LedgerFixture f = await LedgerFixture.OpenAsync();
|
||||
var repo = new SqliteGameRepository(f.Db);
|
||||
GameRow row = await repo.EnsureAsync(_exe, "Uninstalled", Ct);
|
||||
await SetAsync(f, row.Id, "hook_autodisabled_reason = 'executable is x86: the hook runs in x64 processes only', hook_autodisabled_at = 5");
|
||||
|
||||
(await new SqliteGamePrune(f.Db).RemoveUninstalledAsync(row.Id, @"d:\ANOTHER\it\uninstalled\game.EXE", Ct)).Should().BeTrue("the path compares as the column does, without case; an auto-disable is not a block");
|
||||
|
||||
(await repo.FindByIdAsync(row.Id, Ct)).Should().BeNull();
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("hook_blocked_reason = 'BlockedModule: Easy Anti-Cheat'", "a block is never cleared")]
|
||||
[InlineData("hook_prescan_state = 'blocked'", "the pre-scan's block")]
|
||||
[InlineData("ac_exception_at = 5", "an exception's grant")]
|
||||
[InlineData("ac_exception_trial_failed_at = 5", "D38's mark, for good")]
|
||||
[InlineData("removed_at = 5", "an entry already removed keeps its sessions' owner")]
|
||||
public async Task AnEntryCarryingWhatMustOutliveItIsKept(string assignments, string because)
|
||||
{
|
||||
await using LedgerFixture f = await LedgerFixture.OpenAsync();
|
||||
var repo = new SqliteGameRepository(f.Db);
|
||||
GameRow row = await repo.EnsureAsync(_exe, "Uninstalled", Ct);
|
||||
await SetAsync(f, row.Id, assignments);
|
||||
|
||||
(await new SqliteGamePrune(f.Db).RemoveUninstalledAsync(row.Id, _exe.ExePath, Ct)).Should().BeFalse(because);
|
||||
|
||||
(await repo.FindByIdAsync(row.Id, Ct)).Should().NotBeNull(because);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task AnEntryWithASessionOrAtAnotherPathIsKept()
|
||||
{
|
||||
await using LedgerFixture f = await LedgerFixture.OpenAsync();
|
||||
var repo = new SqliteGameRepository(f.Db);
|
||||
GameRow played = await repo.EnsureAsync(_exe, "Played", Ct);
|
||||
await AddSessionAsync(f, played.Id);
|
||||
GameRow moved = await repo.EnsureAsync(_exe with { ExePath = @"D:\another\it\moved\Game.exe" }, "Moved", Ct);
|
||||
var prune = new SqliteGamePrune(f.Db);
|
||||
|
||||
(await prune.RemoveUninstalledAsync(played.Id, _exe.ExePath, Ct)).Should().BeFalse("a session was recorded — the owner's condition");
|
||||
(await prune.RemoveUninstalledAsync(moved.Id, @"D:\another\it\old-place\Game.exe", Ct)).Should().BeFalse("the entry was re-pointed after the sweep read it");
|
||||
|
||||
(await repo.FindByIdAsync(played.Id, Ct)).Should().NotBeNull();
|
||||
(await repo.FindByIdAsync(moved.Id, Ct)).Should().NotBeNull();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
|
||||
|
||||
using FluentAssertions;
|
||||
using FrameLedger.Application.Watch;
|
||||
using FrameLedger.Infrastructure.Watch;
|
||||
|
||||
namespace FrameLedger.Infrastructure.Tests.Watch;
|
||||
|
||||
/// <summary>
|
||||
/// beta.19, D55: what the file system says about an executable that did not read — present, gone from a folder that is
|
||||
/// still there, gone with its folder, nothing left but the drive's root, or a drive that is not connected — on real folders.
|
||||
/// </summary>
|
||||
public sealed class ExecutablePresenceProbeTests : IDisposable
|
||||
{
|
||||
private readonly string _dir = Path.Combine(Path.GetTempPath(), "fl-presence-" + Guid.NewGuid().ToString("N"));
|
||||
|
||||
public ExecutablePresenceProbeTests() => Directory.CreateDirectory(_dir);
|
||||
|
||||
public void Dispose() => Directory.Delete(_dir, recursive: true);
|
||||
|
||||
private static ExecutablePresenceProbe Probe() => new(VolumeRoots.IsReady);
|
||||
|
||||
[Fact]
|
||||
public void AFileThereIsPresentAndAFileGoneFromItsFolderIsGone()
|
||||
{
|
||||
string game = Directory.CreateDirectory(Path.Combine(_dir, "it", "a-game", "Game")).FullName;
|
||||
string exe = Path.Combine(game, "Game.exe");
|
||||
File.WriteAllBytes(exe, [1]);
|
||||
|
||||
Probe().Probe(exe).Should().Be(ExecutablePresence.Present);
|
||||
|
||||
File.Delete(exe);
|
||||
Probe().Probe(exe).Should().Be(ExecutablePresence.FileGone, "the folder is still there and lists no such file");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AGameWhoseFolderWentWithItIsGoneWhileTheFolderItWasInstalledInIsThere()
|
||||
{
|
||||
string library = Directory.CreateDirectory(Path.Combine(_dir, "it")).FullName;
|
||||
|
||||
Probe().Probe(Path.Combine(library, "a-dolls-locket-remake", "Dolls Locket", "css", "Game.exe")).Should().Be(ExecutablePresence.FileGone,
|
||||
"an uninstall takes the game's folder and leaves the library's");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void NothingLeftButTheDrivesRootIsNotAnUninstall()
|
||||
{
|
||||
string root = Path.GetPathRoot(_dir)!;
|
||||
string nowhere = Path.Combine(root, "fl-presence-absent-" + Guid.NewGuid().ToString("N"), "Games", "Title", "Title.exe");
|
||||
|
||||
Probe().Probe(nowhere).Should().Be(ExecutablePresence.OnlyTheDriveRemains, "a different disk under the same letter looks exactly like this");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ADriveThatIsNotConnectedOrAShareIsNeverGone()
|
||||
{
|
||||
string exe = Path.Combine(_dir, "Game.exe");
|
||||
|
||||
new ExecutablePresenceProbe(static _ => false).Probe(exe).Should().Be(ExecutablePresence.DriveAbsent, "the drive is not ready");
|
||||
VolumeRoots.IsReady(Path.GetPathRoot(_dir)!).Should().BeTrue("the drive the temporary folder is on is a ready local drive");
|
||||
Probe().Probe(@"\\server\share\Games\Title.exe").Should().Be(ExecutablePresence.Unknown, "a share is not where a library is uninstalled from");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user