Repository navigation
Bound the stacktape logs backlog, dedupe by time, cap dev daemon output [skip ci] - #346
Merged
Merged
Conversation
…tput, and fix #343 review leftovers [skip ci] - `stacktape logs` in a terminal shows the newest `--limit` lines of the window first, found one request at a time from the newest window backwards within the 2 req/s budget, then follows; `--filter` applies to both. Every poll is one FilterLogEvents request; further pages come on the next polls. - Shown event IDs are kept only as long as a later read can return them (the 10 s look-back), not the last 5,000. - The dev daemon's output files are opened for appending and kept below 5 MB each (previous part in `<file>.1`) instead of muting process.stdout.write, which Bun's console.* bypassed. - A failed rebuild is not retried when a newer build of the workload waits, and the retry waits 3 s. - MCP: only a session of the same stage clears the remembered DEV_STAGE_TAKEN_OVER answer. - Log levels: numeric pino/bunyan levels; a plain "Error: ..." line without a stack is info. - The stale-holder check compares a machine ID in the relay session, not only the hostname in the label. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ly, and rotate daemon output on Windows [skip ci] - The `stacktape logs` backlog starts with the last minute and widens older windows tenfold, so recent matches of a filter are not stuck behind CloudWatch's empty scanning pages for the oldest part of the window. When its 12 requests run out, it shows only the fully read recent windows and prints which lines it did not read. - Lines the backlog read but cut by `--limit` count as handled, so following does not print one with the time of the oldest line shown. - Daemon output files are emptied through a new handle opened by path: Windows refuses to truncate a handle opened for appending (EPERM), so the files grew without bound there. Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts: # apps/cli/@generated/llm-docs/lexical-index.json
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.
This fixes the seven findings the #343 review left open, and the two P1s from the review of this PR.
stacktape logsin a terminal read the whole--sincewindow (an hour by default), every page, before it followed new lines. Now it shows the newest--limitlines (100 by default), which is what the one-time read and the docs promise, and then follows. The search starts with the last minute and reads each older window up to ten times wider. A window that holds more events than needed is narrowed to its newest part, and a window of one second or less is read whole and its newest events kept. Every poll sends one FilterLogEvents request, and further pages come on later polls within the 2 req/s budget. Following now also applies--filter, which it ignored before. The docs page describes follow mode, and the generated LLM docs corpus is regenerated for that paragraph.The first version of this PR started the search with the whole window. With
--filter, CloudWatch can return empty pages while it scans, so the 12-request budget could run out on the oldest part, and the recent matches were never shown (review P1). Starting from the last minute shows recent matches first. When the budget runs out, the backlog shows only the windows it read to the end and prints which lines it did not read, suggesting--queryto search the whole window. Lines the backlog read but cut by--limitnow count as handled, so following no longer prints one that has the same millisecond as the oldest line shown (review P2).The dedupe set was trimmed to the last 5,000 event IDs, so a group writing more than 500 lines a second printed duplicates. It now keeps an ID only while a later read can still return that event (the 10 s look-back).
The dev daemon used to mute
process.stdout.writeafter it reported ready, but Bun'sconsole.*bypasses that. Now nothing is muted. The output files are opened for appending, and the daemon keeps each below 5 MB, moving the previous part to<file>.1. Append mode lets the daemon and its children (Docker builds) keep writing from the start of an emptied file, without a gap of zero bytes. The file is emptied through a new handle opened by its path: Windows refuses to truncate through a handle opened for appending (review P1). I reproduced that with Windows node.exe 26.3.0 and bun.exe 1.3.14 from WSL: EPERM, and 134 to 138 KB written against a 20 KB cap. Truncating by path kept the file at about the cap (at most 25 KB) with no zero bytes, on Windows with both runtimes and on Linux. The daemon gets the file paths in an environment variable instead of deriving them from its port.Smaller fixes:
Error: ...line without a stack is info. The .NET start-up failure and errors with a stack trace are still errors.kill(pid, 0)for a process on another machine with the same hostname. Holders from older CLIs have no machine ID and are treated as live.Checks on the merged head:
test:src3,094 pass / 0 fail,test:local-dev213 / 0,test:tools85 / 0, CLI typecheck,pnpm lintandgenerate:check. In the first round I also rantest:operations:rules,test:operations:terminal,test:cli-smoke,test:llm-docsandtest:mcp-docs, all passing. Each new test fails against the code it fixes. The three tests added in this round fail on the reviewed head 9682093. The in-memory FilterLogEvents fake now returns a token after the last page, as CloudWatch does, and can return empty scanning pages.Live checks in us-west-2 (stacktape-e2e) with the real printer against throwaway log groups, all deleted and the deletion verified:
ERROR): the same 30,000 non-matching lines, 5 matches 50 minutes ago and 10 in the last minute. The backlog showed all 15 matches in order in 5 requests (2.0 s), starting with the last minute. Following printed the new matching line and skipped the non-matching one.Uncertain:
node_modulesover\\wsl.localhost. The Windows evidence is a standalone probe that makes the same calls asrotateDaemonOutputFile, with an opener, a daemon and a grandchild writing through the inherited descriptor.