Bound mutation log capture and streamline error summaries - #10
Merged
Merged
Conversation
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
Long mutation-command logs previously accumulated in unbounded stdout/stderr buffers, even while streamed. Commands whose output is only diagnostic now opt into a 64 KiB tail per stream. Verbose writers still receive all output; retained results carry truncation flags and failure summaries explicitly mark omitted output.
Failure formatting now scans backward for the final ten nonempty lines and limits line prefixes without allocating a rune slice for an entire long line.
Closes #7.
Capture policy
Bounded capture is selected at individual calls for Homebrew install/upgrade/tap, Git clone, shell execution, defaults writes, system/security/login-shell mutations, SSH key generation, and ASDF plugin add/update.
Complete capture remains the default. All inventory/status reads, SSH public-key extraction, and ASDF installs remain complete because callers parse their output. In particular, ASDF installation still searches the full log for version-not-found guidance; bounding those logs would require a separate streaming parser. Custom runner implementations are unchanged.
Evidence
Local real-subprocess benchmarks, three iterations per case (not production guarantees):
The cap applies independently to stdout and stderr, including a single very long line. Unicode cut boundaries are handled without corrupting otherwise valid UTF-8. Multiline failure formatting allocated about 1.3 KB for both 1 MiB and 64 MiB inputs.
Reproduce with
go test ./internal/platform -run '^$' -bench 'BenchmarkExecRunnerOutputCapture|BenchmarkCommandErrorOutputFormatting' -benchmem.Verification
make release-check: formatting, full tests, vet, build, distribution smokegit diff --checkLogin-shell smoke coverage was skipped because the host could not report
UserShell. Go commands used a writable temporary cache due to sandbox restrictions.Safety and documentation