Skip to content

Feat/unified jsonl logs#2371

Merged
lpcox merged 2 commits intomainfrom
feat/unified-jsonl-logs
Mar 23, 2026
Merged

Feat/unified jsonl logs#2371
lpcox merged 2 commits intomainfrom
feat/unified-jsonl-logs

Conversation

@lpcox
Copy link
Copy Markdown
Collaborator

@lpcox lpcox commented Mar 23, 2026

No description provided.

lpcox and others added 2 commits March 22, 2026 22:16
Extend GraphQL field injection to support commit queries. The Commit
type uses author{user{login}} (different from Issue/PR author{login})
and has no authorAssociation field. This enables the guard's trusted-bot
detection for commit objects.

Also adds a GraphQL pattern for commit history queries (list_commits)
and refactors the injection to use tool-specific field sets.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The Copilot SWE Agent (app/copilot-swe-agent) was not recognized as a
trusted first-party bot, causing its PRs to receive none integrity and
be filtered by DIFC. Add all login variants:
- copilot-swe-agent[bot] (REST API bot user)
- copilot-swe-agent (without [bot] suffix)
- app/copilot-swe-agent (gh CLI app/ prefix)

Update tests to use a non-builtin bot name for configured-only
trusted bot scenarios since copilot-swe-agent is now built-in.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 23, 2026 13:53
@lpcox lpcox merged commit 5783649 into main Mar 23, 2026
12 checks passed
@lpcox lpcox deleted the feat/unified-jsonl-logs branch March 23, 2026 13:54
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

Adds support for commit-history GraphQL operations to the proxy/guard pipeline so commit authors can be integrity-labeled without extra enrichment, and extends trusted first-party bot detection for Copilot SWE agent identities.

Changes:

  • Extend GraphQL request rewriting to inject commit-specific guard fields (author{user{login}}) for list_commits.
  • Add GraphQL routing pattern to classify commit history queries as list_commits.
  • Update Rust guard trusted-bot detection + tests for additional Copilot SWE agent login variants.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
internal/proxy/graphql_rewrite_test.go Adds tests for commit-specific field injection behavior.
internal/proxy/graphql_rewrite.go Introduces per-tool field sets and commit-specific injection requirements.
internal/proxy/graphql.go Routes GraphQL commit-history queries to list_commits.
guards/github-guard/rust-guard/src/labels/mod.rs Updates tests for trusted first-party bot detection and configured trusted bots.
guards/github-guard/rust-guard/src/labels/helpers.rs Expands trusted first-party bot login allowlist (Copilot SWE agent variants).

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

// author{user{login}} enables trusted-bot detection. Commits don't have an
// authorAssociation field in the GraphQL schema.
var commitFields = []guardFieldSet{
{"author{user{login}}", regexp.MustCompile(`\bauthor\s*\{[^}]*\buser\s*\{[^}]*\blogin\b`)},
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

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

The present regexp for commit fields will never match a real author{user{login}} selection because it uses [^}]* around nested braces; the first [^}]* will greedily consume through user{login and then stop before the inner }, leaving no user{ token for the remainder of the pattern. This causes InjectGuardFields to think the field is missing and inject it again, potentially producing invalid GraphQL or duplicated selections. Consider using non-greedy quantifiers (e.g. [^}]*?) or a different presence check that can handle nested selections reliably.

Suggested change
{"author{user{login}}", regexp.MustCompile(`\bauthor\s*\{[^}]*\buser\s*\{[^}]*\blogin\b`)},
{"author{user{login}}", regexp.MustCompile(`(?s)\bauthor\b.*\buser\b.*\blogin\b`)},

Copilot uses AI. Check for mistakes.
Comment thread internal/proxy/graphql.go
Comment on lines +50 to +52
// Commit history operations
{queryPattern: regexp.MustCompile(`(?i)\bhistory\s*[\({]`), toolName: "list_commits"},

Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

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

A new list_commits GraphQL routing pattern is introduced here, but there isn’t corresponding unit test coverage in the existing TestMatchGraphQL tables to ensure commit-history queries are classified as list_commits (and that other patterns still win when combined). Adding a focused test case for a typical ... on Commit { history(first:...) { nodes { ... } } } query would prevent regressions.

Copilot uses AI. Check for mistakes.
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.

2 participants