From aa75afc6f14cef01aaa25c567015df5679608d81 Mon Sep 17 00:00:00 2001 From: GitHub Copilot Agent Date: Fri, 6 Feb 2026 15:50:20 +0000 Subject: [PATCH] Add debug logging to internal/difc/agent.go - Added internal logger import and declaration following pkg:filename convention - Added debug logging to NewAgentLabels() to track agent creation - Added debug logging to NewAgentLabelsWithTags() with initial tag info - Added debug logging to AddSecrecyTag() before lock acquisition - Added debug logging to AddIntegrityTag() before lock acquisition - Added debug logging to GetOrCreate() for cache hits and race conditions - All logging follows project conventions with no side effects in arguments - Complements existing operational logs without duplication --- internal/difc/agent.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/internal/difc/agent.go b/internal/difc/agent.go index 7d05ff5d..b1c68bdc 100644 --- a/internal/difc/agent.go +++ b/internal/difc/agent.go @@ -3,8 +3,12 @@ package difc import ( "log" "sync" + + "github.com/github/gh-aw-mcpg/internal/logger" ) +var logAgent = logger.New("difc:agent") + // AgentLabels associates each agent with their DIFC labels // Tracks what secrecy and integrity tags an agent has accumulated type AgentLabels struct { @@ -16,6 +20,7 @@ type AgentLabels struct { // NewAgentLabels creates a new agent with empty labels func NewAgentLabels(agentID string) *AgentLabels { + logAgent.Printf("Creating new agent labels: agentID=%s", agentID) return &AgentLabels{ AgentID: agentID, Secrecy: NewSecrecyLabel(), @@ -25,6 +30,8 @@ func NewAgentLabels(agentID string) *AgentLabels { // NewAgentLabelsWithTags creates a new agent with initial tags func NewAgentLabelsWithTags(agentID string, secrecyTags []Tag, integrityTags []Tag) *AgentLabels { + logAgent.Printf("Creating agent labels with tags: agentID=%s, secrecyTags=%v, integrityTags=%v", + agentID, secrecyTags, integrityTags) return &AgentLabels{ AgentID: agentID, Secrecy: NewSecrecyLabelWithTags(secrecyTags), @@ -34,6 +41,7 @@ func NewAgentLabelsWithTags(agentID string, secrecyTags []Tag, integrityTags []T // AddSecrecyTag adds a secrecy tag to the agent func (a *AgentLabels) AddSecrecyTag(tag Tag) { + logAgent.Printf("Agent %s adding secrecy tag: %s", a.AgentID, tag) a.mu.Lock() defer a.mu.Unlock() a.Secrecy.Label.Add(tag) @@ -42,6 +50,7 @@ func (a *AgentLabels) AddSecrecyTag(tag Tag) { // AddIntegrityTag adds an integrity tag to the agent func (a *AgentLabels) AddIntegrityTag(tag Tag) { + logAgent.Printf("Agent %s adding integrity tag: %s", a.AgentID, tag) a.mu.Lock() defer a.mu.Unlock() a.Integrity.Label.Add(tag) @@ -132,10 +141,13 @@ func NewAgentRegistryWithDefaults(defaultSecrecy []Tag, defaultIntegrity []Tag) // GetOrCreate gets an existing agent or creates a new one with default labels func (r *AgentRegistry) GetOrCreate(agentID string) *AgentLabels { + logAgent.Printf("GetOrCreate called for agentID=%s", agentID) + // Try to get existing agent first (read lock) r.mu.RLock() if labels, ok := r.agents[agentID]; ok { r.mu.RUnlock() + logAgent.Printf("Found existing agent: %s", agentID) return labels } r.mu.RUnlock() @@ -146,6 +158,7 @@ func (r *AgentRegistry) GetOrCreate(agentID string) *AgentLabels { // Double-check after acquiring write lock if labels, ok := r.agents[agentID]; ok { + logAgent.Printf("Agent %s created by another goroutine", agentID) return labels }