X Tutup
Skip to content

[log] Add debug logging to difc/resource.go#1664

Draft
github-actions[bot] wants to merge 1 commit intomainfrom
log/difc-resource-logging-6080d3550e935d6c
Draft

[log] Add debug logging to difc/resource.go#1664
github-actions[bot] wants to merge 1 commit intomainfrom
log/difc-resource-logging-6080d3550e935d6c

Conversation

@github-actions
Copy link
Contributor

@github-actions github-actions bot commented Mar 8, 2026

Adds logResource debug logger to internal/difc/resource.go and introduces 3 meaningful logging calls in key DIFC label aggregation and filtering methods.

Changes

File modified: internal/difc/resource.go

  1. Added import "github.com/github/gh-aw-mcpg/internal/logger"
  2. Added package-level logger: var logResource = logger.New("difc:resource")
  3. Added 3 debug logging calls:
Method Log Message
CollectionLabeledData.Overall() "Aggregating labels for collection: items=%d"
FilteredCollectionLabeledData.Overall() "Aggregating labels for filtered collection: accessible=%d, filtered=%d"
FilteredCollectionLabeledData.ToResult() "Producing filtered collection result: accessible=%d, filtered=%d, reason=%s"

Why these locations?

The difc/resource.go file contains the core DIFC data structures for label aggregation and filtering. These methods are called during every tool invocation to determine what data an agent can access. Adding logging here:

  • Helps debug DIFC policy issues: When an agent reports "missing data", you can see exactly how many items were filtered vs accessible
  • Provides visibility into label aggregation: Shows when collection labels are being computed for access decisions
  • Zero performance overhead when debug is off: Uses logResource.Printf() which is a no-op unless DEBUG=difc:* is set

Testing

Enable debug logging to see the new output:

DEBUG=difc:* ./awmg --config config.toml

Quality Checklist

  • Exactly 1 file modified
  • No test files modified
  • Logger naming follows pkg:filename convention (difc:resource)
  • Logger arguments use only len() (built-in, no side effects)
  • Messages are meaningful for debugging DIFC behavior
  • No duplicate logging with existing logs
  • Import statements properly formatted

Generated by Go Logger Enhancement

Add logResource logger to internal/difc/resource.go with meaningful debug
logging calls in key DIFC data aggregation and filtering methods:

- CollectionLabeledData.Overall(): log item count when aggregating labels
- FilteredCollectionLabeledData.Overall(): log accessible/filtered counts
- FilteredCollectionLabeledData.ToResult(): log result statistics with filter reason

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

0 participants

X Tutup