Skip to content

Commit aa75afc

Browse files
GitHub Copilot Agentgithub-actions[bot]
authored andcommitted
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
1 parent 06ff18a commit aa75afc

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

internal/difc/agent.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,12 @@ package difc
33
import (
44
"log"
55
"sync"
6+
7+
"github.com/github/gh-aw-mcpg/internal/logger"
68
)
79

10+
var logAgent = logger.New("difc:agent")
11+
812
// AgentLabels associates each agent with their DIFC labels
913
// Tracks what secrecy and integrity tags an agent has accumulated
1014
type AgentLabels struct {
@@ -16,6 +20,7 @@ type AgentLabels struct {
1620

1721
// NewAgentLabels creates a new agent with empty labels
1822
func NewAgentLabels(agentID string) *AgentLabels {
23+
logAgent.Printf("Creating new agent labels: agentID=%s", agentID)
1924
return &AgentLabels{
2025
AgentID: agentID,
2126
Secrecy: NewSecrecyLabel(),
@@ -25,6 +30,8 @@ func NewAgentLabels(agentID string) *AgentLabels {
2530

2631
// NewAgentLabelsWithTags creates a new agent with initial tags
2732
func NewAgentLabelsWithTags(agentID string, secrecyTags []Tag, integrityTags []Tag) *AgentLabels {
33+
logAgent.Printf("Creating agent labels with tags: agentID=%s, secrecyTags=%v, integrityTags=%v",
34+
agentID, secrecyTags, integrityTags)
2835
return &AgentLabels{
2936
AgentID: agentID,
3037
Secrecy: NewSecrecyLabelWithTags(secrecyTags),
@@ -34,6 +41,7 @@ func NewAgentLabelsWithTags(agentID string, secrecyTags []Tag, integrityTags []T
3441

3542
// AddSecrecyTag adds a secrecy tag to the agent
3643
func (a *AgentLabels) AddSecrecyTag(tag Tag) {
44+
logAgent.Printf("Agent %s adding secrecy tag: %s", a.AgentID, tag)
3745
a.mu.Lock()
3846
defer a.mu.Unlock()
3947
a.Secrecy.Label.Add(tag)
@@ -42,6 +50,7 @@ func (a *AgentLabels) AddSecrecyTag(tag Tag) {
4250

4351
// AddIntegrityTag adds an integrity tag to the agent
4452
func (a *AgentLabels) AddIntegrityTag(tag Tag) {
53+
logAgent.Printf("Agent %s adding integrity tag: %s", a.AgentID, tag)
4554
a.mu.Lock()
4655
defer a.mu.Unlock()
4756
a.Integrity.Label.Add(tag)
@@ -132,10 +141,13 @@ func NewAgentRegistryWithDefaults(defaultSecrecy []Tag, defaultIntegrity []Tag)
132141

133142
// GetOrCreate gets an existing agent or creates a new one with default labels
134143
func (r *AgentRegistry) GetOrCreate(agentID string) *AgentLabels {
144+
logAgent.Printf("GetOrCreate called for agentID=%s", agentID)
145+
135146
// Try to get existing agent first (read lock)
136147
r.mu.RLock()
137148
if labels, ok := r.agents[agentID]; ok {
138149
r.mu.RUnlock()
150+
logAgent.Printf("Found existing agent: %s", agentID)
139151
return labels
140152
}
141153
r.mu.RUnlock()
@@ -146,6 +158,7 @@ func (r *AgentRegistry) GetOrCreate(agentID string) *AgentLabels {
146158

147159
// Double-check after acquiring write lock
148160
if labels, ok := r.agents[agentID]; ok {
161+
logAgent.Printf("Agent %s created by another goroutine", agentID)
149162
return labels
150163
}
151164

0 commit comments

Comments
 (0)