fix(tui): stop Home telemetry sqlite3 process churn#659
Open
TZZheng wants to merge 5 commits into
Open
Conversation
TZZheng
marked this pull request as ready for review
July 15, 2026 21:24
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
sqlite3to resolve molt-session boundaries, including when canonical events are missing, non-regular, or unreadablepsyche_moltboundaries from canonicallogs/events.jsonlwith a stateless in-process reverse scan that normally reads only the two-session tailAddresses #643.
Why
On macOS under Rosetta, each
sqlite3child could emit:Home telemetry already ran asynchronously after #540, but active tool traffic changed
log.sqliteoften enough to invalidate the short session-window cache. The one-second Home refresh therefore kept launching child PIDs and could leak unsolicited warnings into the terminal.logs/events.jsonlis the canonical source for molt boundaries;log.sqliteis derived. Reading the small relevant tail directly removes the child-process boundary without introducing an in-process SQLite dependency.Test-first chronology
Initial RED on untouched production code at base
10c2822812add0ae07ed26ffcfff8d6cec202a4f:The fixture puts a recording
sqlite3executable first onPATH, supplies a sidecar that would exercise the old fallback, calls the production Home entry point, and fails on the forbidden process launch itself—not on a mocked helper or environment error.Two additional REDs then pinned unavailable-canonical behavior and ordinary same-inode truncate/regrow recovery. A final adversarial RED defeated the intermediate bounded-anchor cache: it rewrote equal-length earlier molt rows on the same inode, preserved the exact prior 4 KiB tail sample, grew beyond the old horizon, and observed stale
current = 2000, want 5000. That showed that no finite byte sample can prove an unchanged semantic prefix.All of these cases are GREEN in final candidate
3d6f53bc12f5564cfd1584250140fe077d9048f1.Implementation notes
SumMoltSessionTokenLedgerFromEventsis the Home-only, process-free source; an unavailable canonical log returns empty session stats and never reachessqlitelogSumMoltSessionTokenLedgerremains canonical-first with derived-SQLite fallback for the explicit detail-view compatibility pathpsyche_moltrowsReadAtwhen both boundaries are in the tail; histories with fewer than two boundaries necessarily scan to byte zeroValidation
Candidate:
3d6f53bc12f5564cfd1584250140fe077d9048f1(five commits; 9 files, +635/−109)go test -race ./internal/fs ./internal/tuigo test ./... -count=1go vet ./...go build ./...go test -race ./internal/fs ./internal/tui -count=1, except the proven-baseline test described belowCGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build ./...CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build ./...git diff --checkThe unfiltered full suite, vet, and build pass at the exact candidate. The race gate reproduces one unrelated baseline timing flake,
TestPortalURLTimeoutKillsChild(fake portal never wrote its pid). An untouched base checkout reproduces the same failure. A supplemental exact-HEAD run skips only that one proven-baseline test and passes the full suite, fs/tui race, vet, build, both Darwin no-CGO builds, diff-check, and Anatomy checks. No unrelated portal-test change is included.After acceptance, current
mainadvanced by one release/install commit (45482ced); its changed paths are disjoint from this PR andgit merge-treereports no conflicts, so the reviewed candidate SHA was intentionally preserved rather than rebased without cause.Scope / related work
No duplicate or linked PR was found for #643 before publication. #526 is the broader historical SQLite/slow-volume issue; #540 moved Home telemetry off the UI thread but retained this fork; closed #578 was a deliberately partial
/kanbantimeout attempt; #611 and #632 do not remove the Home session-window subprocess.Generic SQLite-backed detail and diagnostic helpers remain in place. This PR changes only the high-frequency Home token/session-boundary path and removes the superseded full-JSONL/SQLite fallback behavior from that path.