Skip to content

Allow loading external content during review#6086

Draft
padenot wants to merge 7 commits into
mozilla:masterfrom
padenot:load-skills-reorganized
Draft

Allow loading external content during review#6086
padenot wants to merge 7 commits into
mozilla:masterfrom
padenot:load-skills-reorganized

Conversation

@padenot
Copy link
Copy Markdown
Collaborator

@padenot padenot commented May 27, 2026

No description provided.

@padenot padenot marked this pull request as draft May 27, 2026 17:30
@padenot padenot force-pushed the load-skills-reorganized branch from 8d9321b to 8a640ef Compare May 28, 2026 16:04
padenot added 6 commits May 28, 2026 16:21
Improves editability by loading them at import time from
prompts/system.md and prompts/first_message.md instead of keeping them
as inline Python strings.
Step 1 now says to read the commit message. Step 3 tool guidance is
updated with a {context_tools} placeholder and Mozilla-specific tools
(Phabricator, Bugzilla, fx-docs). Step 5 drops several "What NOT to
Include" items that were overly restrictive.
Adds the moz.tools MCP server to the Anthropic client so the agent can
call mozilla__ tools during review. URL is overridable via
BUGBUG_MOZ_MCP_URL.
LocalPatch wraps a raw unified diff string as a first-class Patch so it
can flow through the review pipeline without a Phabricator backing.
It accepts an optional commit_message and parses from it: the patch
title (first line), description (remaining lines), bug ID (Bug NNN),
and Differential Revision URL, and date if present in the format-patch
header.

On the MCP server side, patch_review now accepts optional diff= and
commit_message= parameters alongside patch_url=, and a new
patch_review_tool exposes the same logic as an @mcp.tool(). A shared
_patch_review_impl handles both cases, using a lighter CodeReviewTool
instance (no DB, no suggestion filtering) for local diffs.
LOCAL_SYSTEM_PROMPT_TEMPLATE uses searchfox-cli and local agent tools
instead of the agent-specific expand_context and searchfox tools.
ExternalContent (in data_types.py) fetches any URL and injects its
content as context for the review. Frontmatter is stripped before
injection. Fetches are retried on transient errors via tenacity and
cached per-instance.

skill_rules.py implements the rule engine: it fetches skill-rules.toml
from the reviewed repository (with retry and a 5-minute in-process TTL
cache), matches changed files against rules (by extension, path glob, or
Bugzilla component), deduplicates actions across rules, and returns
(name, content) pairs ready for injection.

Changed files are extracted using unidiff (consistent with the rest of
the codebase). Supports load_file (from the same repo or another GitHub
repo) and fetch_revision (Phabricator or GitHub commit diff) action
types. Extra rules can be merged at call time for testing before landing.
Logging added throughout for auditability.
Wires load_external_content_for_diff into CodeReviewTool.run(): fetches
skill-rules.toml when BUGBUG_REVIEW_RULES_URL is set (opt-in for now,
until we're ready to generalize), matches rules against the diff, and
injects matched content as <external_context> blocks in the review prompt.

generate_initial_prompt and generate_review_comments gain an
external_context parameter. patch_review and patch_review_tool on the
MCP server accept extra_rules_toml and content_overrides so callers can
test rule and content changes before landing.
@padenot padenot force-pushed the load-skills-reorganized branch from 8a640ef to 0048d1b Compare May 28, 2026 17:10
Documents skill-rules.toml format, rule matching semantics, action
types (load_file, fetch_revision), and the testing workflow using
extra_rules_toml and content_overrides. Includes a reference table of
key files and a gotchas section.
@padenot padenot force-pushed the load-skills-reorganized branch from 0048d1b to fac1b71 Compare May 28, 2026 17:23
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.

1 participant