Skip to content

Commit 3a055e0

Browse files
Copilotlpcox
andauthored
refactor: address code review feedback
- Remove SessionIDFromContext != default coupling in getSessionID - Drop now-unused log import from session.go - Add comment explaining normalization-before-lock safety in LabelAgent Agent-Logs-Url: https://github.com/github/gh-aw-mcpg/sessions/25cbb04b-116d-40aa-aea0-f59a319da6d5 Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
1 parent afd4a84 commit 3a055e0

2 files changed

Lines changed: 4 additions & 9 deletions

File tree

internal/guard/wasm.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,9 @@ func (g *WasmGuard) LabelAgent(ctx context.Context, policy interface{}, backend
628628
return nil, fmt.Errorf("WASM guard does not export label_agent")
629629
}
630630

631+
// Normalisation and payload-build operate only on the caller-supplied `policy`
632+
// argument and do not access any g.* fields, so they are safe to run outside
633+
// the lock that callWasmGuardFunction acquires.
631634
normalizedPolicy, err := normalizePolicyPayload(policy)
632635
if err != nil {
633636
logWasm.Printf("LabelAgent normalizePolicyPayload failed: guard=%s, error=%v", g.name, err)

internal/server/session.go

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package server
33
import (
44
"context"
55
"fmt"
6-
"log"
76
"os"
87
"path/filepath"
98
"time"
@@ -39,14 +38,7 @@ func SessionIDFromContext(ctx context.Context) string {
3938
// getSessionID extracts the MCP session ID from the context
4039
func (us *UnifiedServer) getSessionID(ctx context.Context) string {
4140
sessionID := SessionIDFromContext(ctx)
42-
if sessionID != "default" {
43-
logSession.Printf("Extracted session ID from context: %s", auth.TruncateSessionID(sessionID))
44-
} else {
45-
// No session ID in context - this happens before the SDK assigns one
46-
// For now, use "default" as a placeholder for single-client scenarios
47-
// In production multi-agent scenarios, the SDK will provide session IDs after initialize
48-
log.Printf("No session ID in context, using 'default' (this is normal before SDK session is established)")
49-
}
41+
logSession.Printf("Extracted session ID from context: %s", auth.TruncateSessionID(sessionID))
5042
return sessionID
5143
}
5244

0 commit comments

Comments
 (0)