feat(integrity): human-readable colored audit output on a terminal#125
Merged
Conversation
The integrity audit log was one JSON line to stderr — fine for server log ingestion, noisy for interactive use. Now, when stderr is a terminal, print a human-readable block using the term package: a green '✓ integrity verified' with ref/commit/signer each on its own line, or a red '✗ integrity check failed' with the reason. When stderr is redirected (pipe/file) the structured JSON line is kept, so machine consumers are unaffected. Honors NO_COLOR / CLICOLOR_FORCE. - lib/term: exported StderrStyle (Go-facing colorizer, stderr TTY + NO_COLOR/CLICOLOR_FORCE aware) and StderrIsTerminal; colorDecision refactored to take an fd. - command: reportIntegrity/integrityBlock; a terminal failure prints the red block and returns ErrIntegrityReported so main exits non-zero without a second 'Error:' line. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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
The integrity audit was a single JSON line to stderr — fine for servers, noisy for interactive use. Now the output adapts to where stderr goes:
termpackage, one field per line, green when integrity is satisfied, red when not:Honors
NO_COLOR/CLICOLOR_FORCE. A terminal failure prints the red block and exits non-zero without the old secondError:line.Implementation
lib/term: exportedStderrStyle(Go-facing colorizer — stderr TTY +NO_COLOR/CLICOLOR_FORCEaware) andStderrIsTerminal;colorDecisionrefactored to take an fd (separate stdout/stderr caches).command:reportIntegrity/integrityBlock;ErrIntegrityReportedsentinel somainsuppresses the duplicate error line.Test plan
TestStderrStyle/TestStderrStylePlain(term): SGR codes underCLICOLOR_FORCE, plain underNO_COLOR.TestIntegrityBlockFormat(command): green success block (header + 3 field lines), no signer line when absent, red failure block with theintegrity:prefix stripped.-tags debugger; verified end to end under a pty (colored block) and a pipe (JSON).🤖 Generated with Claude Code