Skip to content

[log] Add debug logging to difc/reflect.go#7173

Merged
lpcox merged 3 commits into
mainfrom
log/difc-reflect-logging-26675b369ebca44f
Jun 8, 2026
Merged

[log] Add debug logging to difc/reflect.go#7173
lpcox merged 3 commits into
mainfrom
log/difc-reflect-logging-26675b369ebca44f

Conversation

@github-actions

@github-actions github-actions Bot commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

Adds a logReflect debug logger (namespace difc:reflect) to internal/difc/reflect.go.

Changes

File modified: internal/difc/reflect.go

  • Added var logReflect = logger.New("difc:reflect") following the pkg:filename convention used across the difc package
  • Added 5 meaningful log calls inside BuildReflectResponse:
    1. Entry — logs current enforcement mode (e.g. strict, filter, propagate)
    2. Agent count — logs how many agents the registry reports before iterating
    3. Skipped agents — logs when an agent ID cannot be resolved to an *AgentLabels (was silently continued before)
    4. No registry — logs the new else branch when AgentRegistry == nil
    5. Completion — logs mode and total reflected agent count

Why

BuildReflectResponse is called by the /reflect endpoint to snapshot all agent DIFC labels. Without logging it was impossible to tell at debug time whether zero agents were reflected because the registry was empty, nil, or because agents failed lookups. These log calls (controlled by DEBUG=difc:reflect or DEBUG=difc:*) provide that visibility with zero overhead when the debug logger is disabled.

Validation

  • make agent-finished passed: format ✓, build ✓, lint ✓, all Go tests ✓ (unit + integration)
  • Rust guard tests failed due to sandboxed network blocking crates.io — unrelated to this change

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • index.crates.io

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "index.crates.io"

See Network Configuration for more information.

Generated by Go Logger Enhancement · sonnet46 4.2M ·

Add a logReflect logger (difc:reflect namespace) to BuildReflectResponse
to help troubleshoot DIFC label reflection issues. The new log calls trace:
- Entry with current enforcement mode
- Count of registered agents before iterating
- Any agents skipped due to missing/nil registry entries
- Completion summary with reflected agent count and mode

Also adds an explicit else-branch log when no AgentRegistry is configured,
improving visibility into DIFC component initialization state.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions github-actions Bot added automation enhancement New feature or request labels Jun 7, 2026
@lpcox lpcox marked this pull request as ready for review June 8, 2026 13:57
Copilot AI review requested due to automatic review settings June 8, 2026 13:57

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds DIFC debug logging to the /reflect response builder so operators can understand why zero (or fewer-than-expected) agents are reflected at runtime (e.g., nil registry vs empty registry vs missing agents).

Changes:

  • Introduces a new debug logger namespace difc:reflect.
  • Adds debug log lines in BuildReflectResponse for entry, registry size, skipped agents, nil-registry case, and completion.
Show a summary per file
File Description
internal/difc/reflect.go Adds a difc:reflect debug logger and instrumentation in BuildReflectResponse to improve observability of reflect behavior.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 1/1 changed files
  • Comments generated: 2

Comment thread internal/difc/reflect.go Outdated
Comment thread internal/difc/reflect.go Outdated
lpcox and others added 2 commits June 8, 2026 07:34
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@lpcox lpcox merged commit 0a97c72 into main Jun 8, 2026
16 checks passed
@lpcox lpcox deleted the log/difc-reflect-logging-26675b369ebca44f branch June 8, 2026 15:44
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.

2 participants