Skip to content

Add unauthenticated /reflect endpoint for live DIFC label snapshots in gateway and proxy modes#7168

Merged
lpcox merged 5 commits into
mainfrom
copilot/add-reflect-endpoint
Jun 7, 2026
Merged

Add unauthenticated /reflect endpoint for live DIFC label snapshots in gateway and proxy modes#7168
lpcox merged 5 commits into
mainfrom
copilot/add-reflect-endpoint

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jun 7, 2026

This change adds a runtime reflection endpoint to inspect current DIFC agent label state, which was previously not exposed. GET /reflect now returns all known agent IDs with their secrecy/integrity labels, plus current enforcement mode and a timestamp.

  • Shared reflect payload builder

    • Added difc.BuildReflectResponse(...) to produce a consistent snapshot shape:
      • agents map (agentID -> {secrecy, integrity})
      • mode (strict/filter/propagate)
      • timestamp (RFC3339 UTC)
    • Output normalizes tag arrays to sorted string slices.
  • Gateway support (routed + unified)

    • Added server.HandleReflect(...).
    • Registered /reflect in common endpoint wiring, so it is available in both gateway HTTP modes.
    • Endpoint is intentionally unauthenticated per current requirement.
  • Proxy support

    • Added GET /reflect handling in proxy HTTP handler.
    • Works with normal paths and GH-host-prefixed paths (/api/v3/reflect).
  • Focused coverage for reflect behavior

    • Added tests for:
      • gateway routed + unified availability
      • unauthenticated access with API key configured
      • populated and empty registry snapshots
      • proxy /reflect and /api/v3/reflect
      • defensive handling of nil registry entries
{
  "agents": {
    "proxy": {
      "secrecy": ["repo:github/private-repo"],
      "integrity": ["approved"]
    },
    "abc123def456": {
      "secrecy": [],
      "integrity": ["unapproved"]
    }
  },
  "mode": "propagate",
  "timestamp": "2026-06-07T13:40:00Z"
}

Copilot AI changed the title [WIP] Add /reflect endpoint to expose agent-id to label mappings Add unauthenticated /reflect endpoint for live DIFC label snapshots in gateway and proxy modes Jun 7, 2026
Copilot finished work on behalf of lpcox June 7, 2026 21:19
Copilot AI requested a review from lpcox June 7, 2026 21:19
@lpcox
Copy link
Copy Markdown
Collaborator

lpcox commented Jun 7, 2026

@copilot make sure that the endpoint and its schema is clearly documented

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jun 7, 2026

@copilot make sure that the endpoint and its schema is clearly documented

Addressed in ede6b7b. I added clear /reflect endpoint documentation and response schema details in README.md and docs/PROXY_MODE.md, including proxy path variants and a security note about unauthenticated exposure.

Copilot finished work on behalf of lpcox June 7, 2026 21:29
@lpcox lpcox marked this pull request as ready for review June 7, 2026 22:26
Copilot AI review requested due to automatic review settings June 7, 2026 22:26
@lpcox lpcox merged commit 6739e26 into main Jun 7, 2026
17 checks passed
@lpcox lpcox deleted the copilot/add-reflect-endpoint branch June 7, 2026 22:29
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 a new runtime introspection endpoint (GET /reflect) that returns a snapshot of current DIFC agent label state (secrecy/integrity), enforcement mode, and a timestamp, and wires it up in both gateway and proxy modes.

Changes:

  • Added a shared difc.BuildReflectResponse(...) builder and response types to produce a consistent /reflect payload with sorted tag arrays.
  • Registered /reflect in gateway common endpoint wiring and implemented proxy handling (including /api/v3/reflect via GH_HOST prefix stripping).
  • Added focused tests for gateway/proxy /reflect behavior and defensive handling of nil registry entries.
Show a summary per file
File Description
README.md Documents the new /reflect endpoint and its JSON schema, including a security note.
internal/server/reflect.go Implements the gateway /reflect handler.
internal/server/reflect_test.go Tests gateway /reflect availability in routed + unified modes and unauthenticated access.
internal/server/handlers.go Registers /reflect as a common gateway endpoint.
internal/proxy/handler.go Adds proxy-mode handling for /reflect after GH_HOST prefix normalization.
internal/proxy/handler_test.go Tests proxy-mode /reflect for both /reflect and /api/v3/reflect.
internal/difc/reflect.go Adds shared response types and snapshot builder (BuildReflectResponse).
internal/difc/reflect_test.go Adds unit tests for the reflect response builder, including nil-entry handling.
docs/PROXY_MODE.md Documents proxy-mode /reflect behavior and schema.

Copilot's findings

Tip

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

  • Files reviewed: 9/9 changed files
  • Comments generated: 3

Comment on lines +11 to +14
func HandleReflect(unifiedServer *UnifiedServer) http.HandlerFunc {
return func(w http.ResponseWriter, _ *http.Request) {
httputil.WriteJSONResponse(w, http.StatusOK, difc.BuildReflectResponse(unifiedServer.DIFCComponents))
}
Comment on lines +115 to +117
// Reflect endpoint exposes a live DIFC label snapshot.
reflectHandler := HandleReflect(unifiedServer)
mux.Handle("/reflect", withResponseLogging(reflectHandler))
Comment thread internal/proxy/handler.go
Comment on lines +56 to +60
// Reflect endpoint exposes a live DIFC label snapshot.
if r.Method == http.MethodGet && rawPath == "/reflect" {
httputil.WriteJSONResponse(w, http.StatusOK, difc.BuildReflectResponse(h.server.DIFCComponents))
return
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add /reflect endpoint to expose agent-id to label mappings

3 participants