Commit Graph
4 Commits
Author SHA1 Message Date
yetone f368f709c3 test(usage): TestLogChangeTrustedAppendReuse counts the prefix it re-hashes, not an empty fingerprint (CI red on Windows since 439cfc4a)
What changed. TestLogChangeTrustedAppendReuse (Windows-only) took
`after.hash != ""` to mean "the read after a trusted append re-read the
historical prefix". Since #1357 (439cfc4a) the trusted, settled path keeps
a fingerprint without re-reading: the old snapshot's SHA-256 state is
continued over the appended lines. So the Windows "usage cache" CI step
failed with "trusted append scanned the historical prefix" while the
guarantee still held. The test now wraps logRecordHash, as
TestUsageAppendReadHashesNoPreReadScan does, and fails if the read after
the append hashes any bytes through it; it still checks the sealed blocks
are reused, and now also that the continued fingerprint equals a fresh
SHA-256 of the parsed bytes.

Verified rather than assumed: in log_index.go the trusted path skips the
prefix check (`trusted ||` short-circuits it) and the after-read check
(`!trusted || !settled`), and the parse seeks to old.off. Siblings: the
only build-tagged test in internal/usage is log_change_windows_test.go.
TestLogChangeSnapshotReuseWithoutFingerprint clears hash only to simulate
a cache hit with no fingerprint, which a change-time stamp alone still
serves; it doesn't use hash as a proxy for a re-read and passes.
incremental_log_test.go:147 asserts hash != "" on the unsettled path,
where the fingerprint is still required. Neither needed a change.

What was run. Windows 11 box (xiaomi-gpu; no Go there, so test binaries
were cross-compiled with go1.26.8 GOOS=windows and run in a scratch dir
with USERPROFILE/APPDATA/LOCALAPPDATA/TEMP redirected):
- origin/main's test, -count=5: FAIL x5 at :164 "trusted append scanned
  the historical prefix" (CI's failure reproduced).
- fixed test, -count=5: PASS x5.
- break A (continuation always re-verifies the prefix: `trusted ||`
  removed): FAIL x5 "re-hashed 143726 bytes of the 143726-byte
  historical prefix".
- break B (after-read check runs on the trusted path too): FAIL x5
  "re-hashed 143849 bytes of the 143726-byte historical prefix".
- CI's "Windows usage cache" -run set (no tags): all 11 PASS.
- whole package (-tags nogui): everything passes but
  TestDesktopSessionAccountMetadata, which fails identically with
  origin/main's binary; that is #1356, already filed, not touched here.
macOS: go test -tags nogui ./internal/usage/... ok (temp HOME, pinned
caches). gofmt -l clean; go vet, GOOS=linux and GOOS=windows go vet
-tags nogui ./internal/usage/ clean.
2026-10-09 07:20:48 +08:00
Ethereal49 3c629133c2 usage: refresh caches after same-tick log rewrites (#1328)
* usage: same-tick rewrites refresh cached totals and request pages

Trust change stamps only when they were settled at the snapshot read's
start. Fingerprint recent snapshots and append prefixes, and discard
fingerprint trust when the content changes during a read.

Fixes https://github.com/yetone/magpie/issues/1305

Verified: deterministic old-predicate FAIL/new PASS; usage tests with race;
nogui vet; Linux nogui and Windows builds; usage test cross-compilation for
Windows, Darwin and the unsupported-stamp fallback on FreeBSD.
Full nogui suite exposed the independent sessions TestList empty-session
limit failure. Native Linux GUI vet/build lack pkg-config and GTK/WebKit;
native Windows/NTFS execution was not run.

* usage: keep FILETIME stamp ages valid beyond UnixNano range

Convert whole seconds and the 100ns fraction separately. Checked the epoch, current dates with fractional ticks and year 2500; Windows build and usage test cross-compilation pass. Native Windows execution was not run.

* usage: keep history cached after an append settles

An unchanged log now validates a recent snapshot's nonempty fingerprint
before publishing a settled clone. Preserve its version and sealed blocks
so the summary and page caches stay warm without mutating readers' snapshots.

Follow-up to the review on https://github.com/yetone/magpie/pull/1328,
for https://github.com/yetone/magpie/issues/1305.

On e28e686, the real-clock append/read/settle/read tests fail with a
version bump and 32,428 additional allocations over 4,000 versus 10 rows.
With this change the targeted race run passes, with 165 extra allocations.
The existing performance test now measures this path on the real clock.

Verification uses Go 1.26.8, a temporary HOME and pinned Go caches.
Native Linux GUI checks require missing pkg-config/GTK/WebKit libraries;
native Windows/NTFS execution is not available. No GUI assets change.
Implementation and verification used AI assistance.

Final checks: usage race PASS (421 test results); nogui suite PASS (7,273
test results, 44 packages; 21 skipped tests, 3 packages without tests).
Nogui vet, Linux nogui build, Windows build, and usage test cross-compilation
for Windows amd64, Darwin arm64 and FreeBSD amd64 PASS. Native Linux GUI
vet/build were attempted and failed at the missing pkg-config executable.
2026-10-09 02:48:29 +08:00
Snowyy 5422306fac usage: guard cache transitions and Windows long-path reads (#598) 2026-10-03 02:19:11 +08:00
Snowyy 3d8c6f24c5 usage: capture Windows change time for cached logs (#594)
* usage: capture Windows change time for cached logs

* ci: show native Windows usage test outcomes
2026-10-03 01:15:29 +08:00