Skip to content

Introduce a way to load external content when an agent review code#6128

Merged
suhaibmujahid merged 7 commits into
mozilla:masterfrom
padenot:external-context-rules
Jun 12, 2026
Merged

Introduce a way to load external content when an agent review code#6128
suhaibmujahid merged 7 commits into
mozilla:masterfrom
padenot:external-context-rules

Conversation

@padenot

@padenot padenot commented Jun 4, 2026

Copy link
Copy Markdown
Collaborator

See the doc and example in the last commit first.

@padenot padenot requested review from marco-c and suhaibmujahid and removed request for suhaibmujahid June 8, 2026 09:53
Comment thread bugbug/tools/code_review/agent.py Outdated
Comment thread bugbug/tools/code_review/review_context.py Outdated
suhaibmujahid
suhaibmujahid previously approved these changes Jun 10, 2026

@suhaibmujahid suhaibmujahid left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you! Just minor comments to address and then we should land it ASAP.

Comment thread bugbug/tools/code_review/prompts.py
Comment thread bugbug/tools/code_review/agent.py Outdated
Comment thread bugbug/tools/code_review/agent.py Outdated
padenot added 7 commits June 11, 2026 15:11
Introduce ExternalContent as the common loader for review-time files fetched
over HTTP. It strips frontmatter, caches the fetched body, and reports load
failures with context.

The loader uses a shared retrying fetch helper so skills and future
review-context content use the same network behavior.
Add a stdlib-only schema parser for review-context.toml, including reusable
predicate definitions, boolean composition, file predicates, metadata
predicates, and file or revision load actions.

The validator rejects unknown fields and malformed rules before the runtime
loader sees them, and exposes bugbug-validate-review-context for
repository-side checks.
Add the initial review-context runtime: fetch review-context.toml from GitHub,
match rules against changed files, deduplicate load actions, and inject fetched
files with an audit manifest.

Cross-repository file loads are restricted to the rule repository unless
explicitly allow-listed, and the parsed rules file is cached briefly to avoid
repeated fetches during adjacent reviews.
Extend review-context matching with Bugzilla component lookup for patches that
have an associated bug, failing closed when metadata is unavailable.

Also implement fetch_revision actions for Phabricator revisions and GitHub
commits so rules can include trusted related diffs as review context.
Thread review_context_repo, review_context_branch, extra_context_toml, and
content overrides through the CodeReviewTool.

When matching rules load content, the prompt receives the formatted external
context and the tool response records the content manifest for auditing.
Add developer and rule-author documentation for review-context.toml, including
validation, matching semantics, trust policy, metadata predicates,
fetch_revision, testing overrides, and prompt injection.

The example TOML demonstrates the intended full rule language separately from
the subset currently active in the loader, and the docs examples are covered by
tests to keep them valid.

@suhaibmujahid suhaibmujahid left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM! Thank you!

@suhaibmujahid suhaibmujahid merged commit b2c767e into mozilla:master Jun 12, 2026
6 checks passed
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