Skip to content

Commit 369576f

Browse files
log: add debug logging to 5 pkg/ files (#26500)
1 parent d48c8b1 commit 369576f

File tree

5 files changed

+41
-0
lines changed

5 files changed

+41
-0
lines changed

pkg/agentdrain/defaults.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,12 @@ package agentdrain
33
import (
44
"bytes"
55
_ "embed"
6+
7+
"github.com/github/gh-aw/pkg/logger"
68
)
79

10+
var defaultsLog = logger.New("agentdrain:defaults")
11+
812
//go:embed data/default_weights.json
913
var defaultWeightsJSON []byte
1014

@@ -20,11 +24,14 @@ var defaultWeightsJSON []byte
2024
// then rebuilding the binary.
2125
func (c *Coordinator) LoadDefaultWeights() error {
2226
if len(defaultWeightsJSON) == 0 {
27+
defaultsLog.Print("No default weights embedded; skipping load")
2328
return nil
2429
}
2530
// A bare "{}" file means no weights have been trained yet.
2631
if string(bytes.TrimSpace(defaultWeightsJSON)) == "{}" {
32+
defaultsLog.Print("Default weights file is empty ({}); skipping load")
2733
return nil
2834
}
35+
defaultsLog.Printf("Loading embedded default weights: bytes=%d", len(defaultWeightsJSON))
2936
return c.LoadWeightsJSON(defaultWeightsJSON)
3037
}

pkg/cli/gateway_logs_aggregation.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,13 @@
22

33
package cli
44

5+
import "github.com/github/gh-aw/pkg/logger"
6+
7+
var gatewayLogsAggregationLog = logger.New("cli:gateway_logs_aggregation")
8+
59
// calculateGatewayAggregates calculates aggregate statistics
610
func calculateGatewayAggregates(metrics *GatewayMetrics) {
11+
gatewayLogsAggregationLog.Printf("Calculating gateway aggregates: servers=%d", len(metrics.Servers))
712
for _, server := range metrics.Servers {
813
for _, tool := range server.Tools {
914
if tool.CallCount > 0 {
@@ -15,6 +20,7 @@ func calculateGatewayAggregates(metrics *GatewayMetrics) {
1520

1621
// buildGuardPolicySummary creates a GuardPolicySummary from GatewayMetrics.
1722
func buildGuardPolicySummary(metrics *GatewayMetrics) *GuardPolicySummary {
23+
gatewayLogsAggregationLog.Printf("Building guard policy summary: totalBlocked=%d events=%d", metrics.TotalGuardBlocked, len(metrics.GuardPolicyEvents))
1824
summary := &GuardPolicySummary{
1925
TotalBlocked: metrics.TotalGuardBlocked,
2026
Events: metrics.GuardPolicyEvents,

pkg/workflow/action_pins.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@ import (
44
"strings"
55

66
actionpins "github.com/github/gh-aw/pkg/actionpins"
7+
"github.com/github/gh-aw/pkg/logger"
78
)
89

10+
var actionPinsLog = logger.New("workflow:action_pins")
11+
912
// Type aliases — callers within pkg/workflow use these names directly.
1013

1114
// ActionYAMLInput is defined in pkg/actionpins; aliased here so all files in
@@ -48,6 +51,7 @@ func extractActionVersion(uses string) string {
4851
func getActionPin(repo string) string {
4952
pins := actionpins.GetActionPinsByRepo(repo)
5053
if len(pins) == 0 {
54+
actionPinsLog.Printf("No embedded pins found for repo: %s", repo)
5155
return ""
5256
}
5357
return actionpins.FormatReference(repo, pins[0].SHA, pins[0].Version)
@@ -124,9 +128,11 @@ func applyActionPinToTypedStep(step *WorkflowStep, data *WorkflowData) *Workflow
124128

125129
pinnedRef, err := getActionPinWithData(actionRepo, rawVersion, data)
126130
if err != nil || pinnedRef == "" {
131+
actionPinsLog.Printf("Skipping pin for %s@%s: no pin available", actionRepo, rawVersion)
127132
return step
128133
}
129134

135+
actionPinsLog.Printf("Pinned action: %s@%s -> %s", actionRepo, rawVersion, pinnedRef)
130136
result := step.Clone()
131137
result.Uses = pinnedRef
132138
return result

pkg/workflow/maintenance_cron.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,12 @@ package workflow
33
import (
44
"fmt"
55
"hash/fnv"
6+
7+
"github.com/github/gh-aw/pkg/logger"
68
)
79

10+
var maintenanceCronLog = logger.New("workflow:maintenance_cron")
11+
812
// generateMaintenanceCron generates a cron schedule based on the minimum expires value in days
913
// Schedule runs at minimum required frequency to check expirations at appropriate intervals
1014
// Returns cron expression and description.
@@ -16,16 +20,20 @@ func generateMaintenanceCron(minExpiresDays int) (string, string) {
1620
// Run at least as often as the shortest expiration would need
1721
if minExpiresDays <= 1 {
1822
// For 1 day or less, run every 2 hours
23+
maintenanceCronLog.Printf("Selected cron frequency: every 2 hours (minExpiresDays=%d)", minExpiresDays)
1924
return fmt.Sprintf("%d */2 * * *", minute), "Every 2 hours"
2025
} else if minExpiresDays == 2 {
2126
// For 2 days, run every 6 hours
27+
maintenanceCronLog.Printf("Selected cron frequency: every 6 hours (minExpiresDays=%d)", minExpiresDays)
2228
return fmt.Sprintf("%d */6 * * *", minute), "Every 6 hours"
2329
} else if minExpiresDays <= 4 {
2430
// For 3-4 days, run every 12 hours
31+
maintenanceCronLog.Printf("Selected cron frequency: every 12 hours (minExpiresDays=%d)", minExpiresDays)
2532
return fmt.Sprintf("%d */12 * * *", minute), "Every 12 hours"
2633
}
2734

2835
// For more than 4 days, run daily
36+
maintenanceCronLog.Printf("Selected cron frequency: daily (minExpiresDays=%d)", minExpiresDays)
2937
return fmt.Sprintf("%d %d * * *", minute, 0), "Daily"
3038
}
3139

@@ -48,20 +56,26 @@ func generateSideRepoMaintenanceCron(repoSlug string, minExpiresDays int) (strin
4856
// Derive a deterministic minute in 0-59 from the seed.
4957
minute := int(seed % 60)
5058

59+
maintenanceCronLog.Printf("Generating side-repo cron: repoSlug=%q minExpiresDays=%d minute=%d", repoSlug, minExpiresDays, minute)
60+
5161
if minExpiresDays <= 1 {
5262
// Every 2 hours — vary the starting minute only.
63+
maintenanceCronLog.Printf("Selected side-repo cron frequency: every 2 hours")
5364
return fmt.Sprintf("%d */2 * * *", minute), "Every 2 hours"
5465
} else if minExpiresDays == 2 {
5566
// Every 6 hours — vary the starting hour within the 6-hour window.
5667
startHour := int((seed >> 8) % 6)
68+
maintenanceCronLog.Printf("Selected side-repo cron frequency: every 6 hours (startHour=%d)", startHour)
5769
return fmt.Sprintf("%d %d,%d,%d,%d * * *", minute, startHour, startHour+6, startHour+12, startHour+18), "Every 6 hours"
5870
} else if minExpiresDays <= 4 {
5971
// Every 12 hours — vary the starting hour within the 12-hour window.
6072
startHour := int((seed >> 8) % 12)
73+
maintenanceCronLog.Printf("Selected side-repo cron frequency: every 12 hours (startHour=%d)", startHour)
6174
return fmt.Sprintf("%d %d,%d * * *", minute, startHour, startHour+12), "Every 12 hours"
6275
}
6376

6477
// Daily — vary the hour of day (0-23) to spread load.
6578
hour := int((seed >> 8) % 24)
79+
maintenanceCronLog.Printf("Selected side-repo cron frequency: daily (hour=%d)", hour)
6680
return fmt.Sprintf("%d %d * * *", minute, hour), "Daily"
6781
}

pkg/workflow/maintenance_workflow_yaml.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,12 @@ package workflow
33
import (
44
"strconv"
55
"strings"
6+
7+
"github.com/github/gh-aw/pkg/logger"
68
)
79

10+
var maintenanceWorkflowYAMLLog = logger.New("workflow:maintenance_workflow_yaml")
11+
812
// buildMaintenanceWorkflowYAML generates the complete YAML content for the
913
// agentics-maintenance.yml workflow. It is called by GenerateMaintenanceWorkflow
1014
// after the cron schedule and setup parameters have been resolved.
@@ -17,6 +21,8 @@ func buildMaintenanceWorkflowYAML(
1721
resolver ActionSHAResolver,
1822
configuredRunsOn RunsOnValue,
1923
) string {
24+
maintenanceWorkflowYAMLLog.Printf("Building maintenance workflow YAML: actionMode=%s minExpiresDays=%d cronSchedule=%q", actionMode, minExpiresDays, cronSchedule)
25+
2026
var yaml strings.Builder
2127

2228
// Add workflow header with logo and instructions
@@ -97,6 +103,7 @@ jobs:
97103

98104
// Add checkout step only in dev/script mode (for local action paths)
99105
if actionMode == ActionModeDev || actionMode == ActionModeScript {
106+
maintenanceWorkflowYAMLLog.Printf("Adding checkout step for close-expired-entities (actionMode=%s)", actionMode)
100107
yaml.WriteString(" - name: Checkout actions folder\n")
101108
yaml.WriteString(" uses: " + getActionPin("actions/checkout") + "\n")
102109
yaml.WriteString(" with:\n")
@@ -392,6 +399,7 @@ jobs:
392399
// These jobs are specific to the gh-aw repository and require go.mod, make build, etc.
393400
// User repositories won't have these dependencies, so we skip them in release mode
394401
if actionMode == ActionModeDev {
402+
maintenanceWorkflowYAMLLog.Printf("Adding dev-only jobs: compile-workflows and secret-validation")
395403
// Add compile-workflows job
396404
yaml.WriteString(`
397405
compile-workflows:

0 commit comments

Comments
 (0)