Skip to content

test(windows): run history-recovery rows 1-3 against the real aw-server.exe in disposable profiles - #864

Open
TimeToBuildBob wants to merge 8 commits into
ActivityWatch:masterfrom
TimeToBuildBob:test/windows-recovery-matrix-rows-1-3
Open

TimeToBuildBob wants to merge 8 commits into
ActivityWatch:masterfrom
TimeToBuildBob:test/windows-recovery-matrix-rows-1-3

Conversation

@TimeToBuildBob

Copy link
Copy Markdown
Contributor

Follow-up to #859 and #860, which proved that CI can start the real aw-server.exe as a disposable Windows user whose Known Folder roots (%LOCALAPPDATA%, %APPDATA%) are isolated from the runner profile. This uses that seam to execute the history-recovery rows from #813 through actual Windows root discovery, not explicit helper paths.

Each row gets its own disposable user (awrow1..3), so rows cannot see one another's databases, and a failed row does not hide the others (!cancelled()):

  1. Local older, Roaming newer. A default start migrates Roaming to Local, unions the older Local history in, and keeps both original trees (*.migrated-*, *.pre-migration-*). Sentinels LOCAL-1..3 and ROAM-1..3 each appear exactly once. A fresh-process restart inserts 0 events.
  2. Stale Local testing history, newer Roaming. The default profile selects Roaming and unions Local. Two fresh --profile testing processes serve exactly TEST-1..3, recovered from the preserved pre-migration tree, and the second inserts and skips 0.
  3. Roaming history plus missed Python history. The first default start runs the one-shot post-migration Python import and serves ROAM-1..3 and PY-1..3. A restart repeats neither the import nor any event, and the originals are kept.

Fixtures are created by the real server, never hand-written SQL, so they track the datastore schema. Sources use colliding event IDs. Rust fixtures are killed with taskkill /F after a committing request, so the asserted events exist only in a non-empty sqlite.db-wal. --dbpath is used only for fixture creation; every assertion run is a default-profile (or --profile testing) start that resolves its roots natively. Per-row evidence JSON is uploaded as the windows-disposable-profile-evidence artifact.

Not tested: power-loss or pre-import interruption (no production crash knob was added), WAL-only Python events (the Python fixture is a rollback-journal file written with the runner's sqlite3), and packaged standalone/Tauri artifacts. A CI debug executable is not release acceptance.

Pre-flight: the same five commits passed windows-latest on the fork (run 43282549608, on master 1bde448). They are now rebased cleanly onto current master 63ed6b3, whose PE-version-resource change also touches build.yml. Test scripts and the workflow only; no production code changes.

…ide the disposable profile

Git-Session-Id: cb91a81d-4907-4dcd-b714-b06dc5ba433b
…row 1

Git-Session-Id: cb91a81d-4907-4dcd-b714-b06dc5ba433b
…t idle time

Git-Session-Id: cb91a81d-4907-4dcd-b714-b06dc5ba433b
Row 2: stale Local history plus a saved testing-profile database, newer
Roaming. Row 3: Roaming history plus a Python aw-server database that
v0.14.0 never imported. Each row runs in its own disposable user.

Git-Session-Id: 2872730e-4cc6-4483-9baf-13e1eb338835
…out testing root exists

Git-Session-Id: 2872730e-4cc6-4483-9baf-13e1eb338835
@TimeToBuildBob

Copy link
Copy Markdown
Contributor Author

Review guide (auto-posted)

Structured warm-up for reviewers — what changed, what to run, where to look.

Key files

  • scripts/windows-recovery-scenarios/row3-roaming-with-missed-python-history.ps1 (+122/-0, Δ122)
  • scripts/windows-recovery-scenarios/row2-stale-local-testing-newer-roaming.ps1 (+99/-0, Δ99)
  • scripts/windows-recovery-scenarios/common.ps1 (+96/-0, Δ96)
  • scripts/windows-recovery-scenarios/row1-local-older-roaming-newer.ps1 (+76/-0, Δ76)
  • .github/workflows/build.yml (+26/-4, Δ30)
  • scripts/test-windows-disposable-profile.ps1 (+13/-1, Δ14)

Suggested verification

  • Run the repo's usual CI-equivalent checks locally

Known risks / watch points

  • No automatic high-risk tags; use file list + diff for judgment.

Suggested review focus

  • Confirm behavior matches the PR description acceptance criteria.
  • Skim the largest diffs first (listed above).
  • If CI is green, spot-check the highest-risk paths called out here.

Generated by scripts/github/pr-warmup-review-guide.py for #864.

@greptile-apps

greptile-apps Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] The PR appears safe to merge; no new actionable issues were found.

Summary

This PR tests three Windows history-recovery cases with the real server in separate disposable user profiles.

  • Windows CI runs recovery checks in isolated profiles.
  • The first recovery case joins older Local history with newer Roaming history.
  • Default and testing profiles recover their own saved histories.
  • The first default start imports missed Python history alongside Roaming events.

Reviews (3) · Last reviewed commit: "fix(test): retry transient sentinel read..." · Reviewed by Greptile

@codecov

codecov Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.00%. Comparing base (656f3c9) to head (4a45b32).
⚠️ Report is 244 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff             @@
##           master     #864       +/-   ##
===========================================
+ Coverage   70.81%   86.00%   +15.18%     
===========================================
  Files          51       90       +39     
  Lines        2916    13089    +10173     
===========================================
+ Hits         2065    11257     +9192     
- Misses        851     1832      +981     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Git-Session-Id: 02610e12-7f80-5e66-9bc0-b0f7a5f57b79
@TimeToBuildBob

Copy link
Copy Markdown
Contributor Author

Addressed all four findings in 01d631e:

  • Wait for /api/0/info before invoking the scenario; a readable SQLite header alone no longer permits fixture writes.
  • On scenario startup timeout, stop the owned process tree, preserve its log in the evidence, and remove its wrapper/log before throwing.
  • Require recovery log summaries with zero inserts on row 1's restart, and zero inserts/skipped duplicates on row 2's second testing start. Missing summaries fail rather than pass silently.
  • Require the original Local aw-server-rust.pre-migration-* and Roaming aw-server-rust.migrated-* trees to contain their databases; an active unioned database cannot satisfy the preservation check.

Added a hermetic PowerShell regression script to the existing Windows guard step. Both guard scripts pass locally under PowerShell, all PowerShell scripts parse, and pre-commit passes. The new regressions exercise delayed/never-ready HTTP, leaked timeout processes, nonzero/missing recovery summaries, and removal of either original backup. Native Windows execution of this new head still needs CI; the previous head's Windows run was green.

@TimeToBuildBob

This comment has been minimized.

@TimeToBuildBob

TimeToBuildBob commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 AI code review

Safe to merge — no P0/P1 findings on latest review

Updated after inline dispositions on finding threads — this is the current state; the verdict below is frozen at review time and is kept as the historical record of that pass.

Finding disposition
Finding Severity State
.github/workflows/build.yml:102 P2 rejected
scripts/test-windows-recovery-guards.ps1:88 P2 rejected
scripts/test-windows-recovery-guards.ps1:117 P2 rejected
scripts/test-windows-recovery-guards.ps1:75 P2 wontfix
scripts/test-windows-recovery-guards.ps1:60 P2 resolved (no disposition on record)
scripts/windows-recovery-scenarios/common.ps1:107 P2 superseded by latest review (not reproduced)
scripts/windows-recovery-scenarios/common.ps1:16 P2 superseded by latest review (not reproduced)
scripts/windows-recovery-scenarios/common.ps1:46 P2 rejected
scripts/windows-recovery-scenarios/common.ps1:20 P2 rejected
scripts/windows-recovery-scenarios/common.ps1:108 P2 rejected
scripts/windows-recovery-scenarios/common.ps1:25 P2 resolved (no disposition on record)
scripts/windows-recovery-scenarios/common.ps1:17 P2 rejected
scripts/windows-recovery-scenarios/row1-local-older-roaming-newer.ps1:63 P2 rejected
scripts/windows-recovery-scenarios/row2-stale-local-testing-newer-roaming.ps1:74 P2 rejected
scripts/windows-recovery-scenarios/row3-roaming-with-missed-python-history.ps1:71 P2 rejected

Adds Windows recovery-matrix scenarios that run the real aw-server.exe under disposable user profiles, with new guard tests for HTTP readiness, process cleanup, sentinel polling, and no-recovery-work assertions. Introduces a common helper library, three row-specific scenario scripts, and updates the CI workflow to run them and upload per-row evidence.

Needs a look — P2 only

Confidence 4/5

1 finding · ⚠️ 1 P2

⚠️ P2 medium — scripts/windows-recovery-scenarios/common.ps1:17

In Wait-ScenarioSentinels (common.ps1), the value of $lastError is reset to $null at the top of every do-loop iteration, and the function throws it only after the loop exits. If each read fails until the deadline passes, the last read's error is thrown, which is correct. But if a mid-loop read fails and a later read succeeds with content that never matches the expected sentinels, the final returned $got is silently non-matching and the stale error is discarded. That is the documented contract (the caller's Assert-True reports the mismatch), so the behavior is intentional. A genuine defect, however, is the opposite corner: when the last read fails the function throws $lastError even if an earlier iteration had already produced the correct sentinels (e.g. the bucket briefly read fine, then disappeared); the caller receives a hard failure instead of the matched sentinels. In row1/row2/row3, Wait-ScenarioSentinels is only called once per server, and this race requires the bucket to vanish after a successful match, which the fixtures do not create. The impact is a possible spurious failure if a fixture server is killed between the effective read and the loop exit; the tests as written never trigger it.

How this was verified: Inspected the do/while in Wait-ScenarioSentinels: $lastError is reset each iteration and only the last iteration's error is thrown. A successful-read-then-vanish sequence produces a thrown error despite a prior match, but the covered scenario scripts never kill a server mid-poll, so this path is not reached in practice.

Consensus: 2/3 passes agreed — pass 1 looked and disagreed
Distinct keys: 1 (general)

Files changed (7) — the diff as I read it
  • .github/workflows/build.yml — Adds guard tests and three recovery-row steps using disposable users, and changes evidence artifact path to a wildcard.
  • scripts/test-windows-disposable-profile.ps1 — Adds Wait-ServerHttpReady function and an optional scenario hook that runs after isolation proof.
  • scripts/test-windows-recovery-guards.ps1 — Adds hermetic tests for HTTP readiness gating, startup timeout cleanup, sentinel retry, and recovery-work assertions.
  • scripts/windows-recovery-scenarios/common.ps1 — Adds shared helpers for scenario servers, sentinel polling, fixture commits, and recovery-work assertions.
  • scripts/windows-recovery-scenarios/row1-local-older-roaming-newer.ps1 — Adds scenario for Local older and Roaming newer history, asserting migration union and restart stability.
  • scripts/windows-recovery-scenarios/row2-stale-local-testing-newer-roaming.ps1 — Adds scenario for stale Local testing profile and Roaming newer history, verifying recovery of testing DB.
  • scripts/windows-recovery-scenarios/row3-roaming-with-missed-python-history.ps1 — Adds scenario for Roaming history plus missed Python DB, checking one-shot import and restart idempotence.
Previous review passes
commit score findings engine when
01d631e254e7 4/5 7 llm 2026-11-17 14:46 UTC
15c917ad8d2e 4/5 5 llm 2026-11-17 15:49 UTC
15c917ad8d2e 4/5 2 llm 2026-11-17 16:35 UTC

Reviewed 4a45b323a632 · openrouter/deepseek/deepseek-v4-flash-0731 · llm engine · 156s · about this reviewer

Maintainer commands

@TimeToBuildBob review (own line) — fresh review · @TimeToBuildBob fix — a worker acts on the findings. Once per comment; 👀 = received.

Comment thread .github/workflows/build.yml Resolved
…bucket

Wait-ScenarioSentinels aborted on the first failed read (e.g. a 404 before
recovery or import creates the bucket). Retry until the deadline and rethrow
only if the final read still failed. Row 1's first start now uses the shared
waiter instead of its own unguarded loop. Adds a hermetic guard regression.

Git-Session-Id: d06b680b-a659-52fd-828b-6c9cda29909f
@TimeToBuildBob

Copy link
Copy Markdown
Contributor Author

CI-green and mergeable (Greptile 5/5) — waiting only on a maintainer click.

This PR is ready to merge, but the bot has pull-only access to this repo and can't self-merge — surfacing it here so it isn't lost. The monitoring loop will stop re-flagging it now that this note is posted.

@TimeToBuildBob

Copy link
Copy Markdown
Contributor Author

@greptileai review

Git-Session-Id: 9dc14d5c-2227-487a-aae7-971ed70df4d5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant