[log] Add debug logging to guard/guard.go - #4639
Merged
Merged
Conversation
Add logGuard debug logger to internal/guard/guard.go to provide visibility into DIFC label agent result processing. Logging added: - emptyAgentLabelsResult: logs mode when creating empty result - ApplyLabelAgentResult: logs input parameters, mode override decisions, validation errors, and the effective mode on success Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds package-level debug logging to internal/guard/guard.go to improve observability when applying DIFC label-agent results (mode parsing + tag application).
Changes:
- Introduces a new
logGuarddebug logger (logger.New("guard:guard")) for the guard package’s core helpers. - Adds debug logs in
emptyAgentLabelsResultandApplyLabelAgentResultfor mode construction/parsing, override behavior, and the final effective mode.
Show a summary per file
| File | Description |
|---|---|
| internal/guard/guard.go | Adds debug logger and emits logs around DIFC label-agent result application to aid troubleshooting enforcement-mode decisions. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 1/1 changed files
- Comments generated: 2
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This was referenced Apr 27, 2026
4 tasks
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.
Adds a
logGuarddebug logger tointernal/guard/guard.goto improve observability of DIFC label agent result processing.Changes
File modified:
internal/guard/guard.goLogger added:
Logging calls added (5 total):
emptyAgentLabelsResult— logs the DIFC mode when constructing an empty result (used by NoopGuard and WriteSinkGuard)ApplyLabelAgentResultentry — logs the incomingdifc_mode, secrecy/integrity tag counts, and default modeApplyLabelAgentResulterror path — logs the invalid mode value and error whenParseEnforcementModefailsApplyLabelAgentResultoverride path — logs when the enforcement mode is overridden from defaultApplyLabelAgentResultsuccess — logs the effective mode after tags are appliedWhy this file
ApplyLabelAgentResultis a central DIFC helper called during agent initialization to apply guard-provided labels. When debugging DIFC enforcement issues it can be difficult to trace why a session ends up with a particular enforcement mode or label set — these log lines surface that decision chain underDEBUG=guard:*.Validation
go build ./...✅go vet ./internal/guard/...✅go test ./internal/guard/...✅