fix(graph): resolve status-footer stuck-progress, log clobbering, and rewalk loop#714
Merged
Conversation
… rewalk loop The `tusk graph` status footer had three related defects (see issue): 1. It rendered `index gen N` — the reindex_gen walk counter, bumped on every walk including no-op walks — which reads as N stuck pending items on a quiet, fully-indexed workspace. A new goroutine-safe WalkStatus tracker (shared across runtime swaps and updated by the walk sites) drives a stateful footer: `synced` / `indexing…` / `walk error`, plus a `last walk 1ms (0 changed)` summary. reindex_gen semantics are unchanged (still load-bearing for orphan reap); it is simply no longer surfaced as the prominent number. 2. Under `-v`, background slog lines glued onto the sticky footer on an interactive TTY (footer and logs share the terminal; the `\r`+erase-line footer leaves the cursor mid-line). A new footerWriter multiplexes the footer and the logs onto one stream, erasing and redrawing the footer around each log line under a mutex. 3. `tusk graph -v > graph.log` inside the workspace armed a permanent ~500ms rewalk loop: each walk's own log write was a MODIFY the watcher turned into the next walk. The watcher now schedules a reindex only for paths that can affect the index — node files, the manifest, or (via os.Stat, so a dotted directory name is not mistaken for a file) a directory. This also closes the same footgun in `tusk watch`.
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
Fixes the three defects in the
tusk graphstatus footer reported in the issue:Footer read as stuck progress. The footer showed
index gen N, thereindex_genwalk counter that bumps on every walk — including no-op walks— so a quiet, fully-indexed workspace left it frozen at some N that reads as N
pending items. The footer now names the state (
synced/indexing…/walk error) and, once a walk has completed, summarizes it(
last walk 1ms (0 changed)), sourced from a new goroutine-safeWalkStatustracker updated by the walk sites.
reindex_gensemantics are unchanged (itis load-bearing for generation-based orphan reap); it is simply no longer the
prominent number on screen.
-vlogs glued onto the footer. On an interactive TTY the sticky footer(
\r+erase-line, no trailing newline) and the background slog lines share theterminal, so log lines concatenated onto the footer text (
…[q] quittime=…).A new
footerWritermultiplexes the footer and the logs onto one stream,erasing and redrawing the footer around each log line, mutex-serialized.
Redirect-into-tree rewalk loop.
tusk graph -v > graph.loginside theworkspace armed a permanent ~500ms walk loop: each walk's own log write was a
MODIFY the watcher turned into the next walk. The watcher now drops events
whose path can never be a node — anything that is not a node file
(
.md/.html/.htm), the manifest (tusk.toml), or a directory. This alsofixes the same footgun in
tusk watch.Verification
go test ./...(37 packages, 0 fail),make vet,make lint(0 issues).at 4; only 2 walks total (was climbing ~2/sec indefinitely).
indexing…→synced · 2 nodes · 2 edges · 0 clients · last walk 1ms (0 changed); noindex gen.-v): every log line is preceded by an erase-line; no[q] quittime=glue.Notes
Makefile) still trigger a walk — conservative, sodirectory renames/deletes (whose events name the extensionless dir) still
reindex; no loop risk since the walk never writes those.
footer coordinator (still stderr); non-interactive runs leave it a transparent
passthrough.