Skip to content

[log] Add debug logging to guard/guard.go - #4639

Merged
lpcox merged 3 commits into
mainfrom
log/guard-debug-logging-a892e2bc0db1a3e3
Apr 27, 2026
Merged

[log] Add debug logging to guard/guard.go#4639
lpcox merged 3 commits into
mainfrom
log/guard-debug-logging-a892e2bc0db1a3e3

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

Adds a logGuard debug logger to internal/guard/guard.go to improve observability of DIFC label agent result processing.

Changes

File modified: internal/guard/guard.go

Logger added:

var logGuard = logger.New("guard:guard")

Logging calls added (5 total):

  1. emptyAgentLabelsResult — logs the DIFC mode when constructing an empty result (used by NoopGuard and WriteSinkGuard)
  2. ApplyLabelAgentResult entry — logs the incoming difc_mode, secrecy/integrity tag counts, and default mode
  3. ApplyLabelAgentResult error path — logs the invalid mode value and error when ParseEnforcementMode fails
  4. ApplyLabelAgentResult override path — logs when the enforcement mode is overridden from default
  5. ApplyLabelAgentResult success — logs the effective mode after tags are applied

Why this file

ApplyLabelAgentResult is 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 under DEBUG=guard:*.

Validation

  • go build ./...
  • go vet ./internal/guard/...
  • go test ./internal/guard/...

Generated by Go Logger Enhancement · ● 2.7M ·

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>
@github-actions github-actions Bot added automation enhancement New feature or request labels Apr 27, 2026
@lpcox
lpcox marked this pull request as ready for review April 27, 2026 14:52
Copilot AI review requested due to automatic review settings April 27, 2026 14:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 logGuard debug logger (logger.New("guard:guard")) for the guard package’s core helpers.
  • Adds debug logs in emptyAgentLabelsResult and ApplyLabelAgentResult for 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

Comment thread internal/guard/guard.go Outdated
Comment thread internal/guard/guard.go Outdated
lpcox and others added 2 commits April 27, 2026 07:57
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@lpcox
lpcox merged commit 2931910 into main Apr 27, 2026
16 checks passed
@lpcox
lpcox deleted the log/guard-debug-logging-a892e2bc0db1a3e3 branch April 27, 2026 15:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants