Skip to content

Add hackbot-api service#5970

Open
suhaibmujahid wants to merge 24 commits into
mozilla:masterfrom
suhaibmujahid:hackbot-api
Open

Add hackbot-api service#5970
suhaibmujahid wants to merge 24 commits into
mozilla:masterfrom
suhaibmujahid:hackbot-api

Conversation

@suhaibmujahid
Copy link
Copy Markdown
Member

No description provided.

@suhaibmujahid suhaibmujahid force-pushed the hackbot-api branch 2 times, most recently from 68a5381 to 5b883c8 Compare May 19, 2026 20:00
Copy link
Copy Markdown

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 introduces a new “hackbot” stack to the repo: a FastAPI-based orchestration service (hackbot-api) that triggers Cloud Run Jobs for agents, plus a small shared runtime library (hackbot-runtime) used by agent containers to upload artifacts/summary data back to GCS. It also refactors the existing bug-fix agent execution model so Bugzilla credentials live in a broker sidecar instead of the agent container.

Changes:

  • Add services/hackbot-api (FastAPI + Cloud Run Jobs trigger, Cloud SQL persistence, GCS signed-policy generation, Alembic migrations).
  • Add libs/hackbot-runtime for agent-side summary + artifact uploads via signed POST policy.
  • Add agents/bug-fix (agent + broker multi-container build) and update bug-fix tool wiring to use an HTTP MCP broker for Bugzilla.

Reviewed changes

Copilot reviewed 38 out of 42 changed files in this pull request and generated 18 comments.

Show a summary per file
File Description
uv.lock Updates workspace membership and locks additional dependencies for new hackbot components.
pyproject.toml Adds new uv workspace members for hackbot service/agent/runtime.
docker-compose.yml Adds Compose include for the bug-fix agent/broker setup.
services/hackbot-api/pyproject.toml Declares hackbot-api package dependencies and pytest config.
services/hackbot-api/Dockerfile Builds the hackbot-api container using uv workspace sync.
services/hackbot-api/app/init.py Defines hackbot-api version constant.
services/hackbot-api/app/main.py FastAPI app setup, Sentry init, lifespan DB init/close, health endpoint.
services/hackbot-api/app/config.py Pydantic settings for GCP/DB/auth/runtime configuration.
services/hackbot-api/app/auth.py API key header auth dependency for routes.
services/hackbot-api/app/schemas.py Pydantic API schemas for runs, artifacts, agents, and inputs.
services/hackbot-api/app/agents.py Agent registry + per-agent env var mapping (bug-fix).
services/hackbot-api/app/jobs.py Cloud Run Jobs trigger + execution status polling (async wrappers).
services/hackbot-api/app/gcs.py GCS signed POST policy generation and run artifact/summary reading.
services/hackbot-api/app/routers/init.py Exposes runs router.
services/hackbot-api/app/routers/runs.py Endpoints for listing agents, creating runs, fetching run status + reconciliation.
services/hackbot-api/app/database/init.py Marks DB package.
services/hackbot-api/app/database/models.py SQLAlchemy model for runs table.
services/hackbot-api/app/database/connection.py Cloud SQL Connector + async SQLAlchemy engine/session setup.
services/hackbot-api/alembic.ini Alembic configuration for the new service.
services/hackbot-api/alembic/env.py Alembic environment running migrations via Cloud SQL Connector.
services/hackbot-api/alembic/script.py.mako Alembic revision template.
services/hackbot-api/alembic/versions/b5b896e1ce12_initial_schema.py Initial migration creating runs table and indexes.
libs/hackbot-runtime/pyproject.toml Declares the hackbot-runtime library package and dependencies.
libs/hackbot-runtime/hackbot_runtime/init.py Exposes runtime public API surface.
libs/hackbot-runtime/hackbot_runtime/context.py Loads agent runtime context from env and constructs uploader.
libs/hackbot-runtime/hackbot_runtime/result.py Defines AgentResult summary contract.
libs/hackbot-runtime/hackbot_runtime/runtime.py Provides run/run_async wrappers to write summary.json and handle failures.
libs/hackbot-runtime/hackbot_runtime/uploader.py Implements signed-policy POST uploads to GCS for artifacts/summary.
agents/bug-fix/pyproject.toml Declares the bug-fix agent package and its workspace sources.
agents/bug-fix/Dockerfile Multi-target build producing agent and broker images.
agents/bug-fix/compose.yml Local compose wiring for agent + broker containers.
agents/bug-fix/broker/init.py Marks broker package.
agents/bug-fix/broker/main.py Bugzilla MCP broker (HTTP) holding Bugzilla credentials.
agents/bug-fix/agent_runner/init.py Marks agent_runner package.
agents/bug-fix/agent_runner/main.py Agent entrypoint: ensure Firefox checkout, run tool, upload logs, emit summary.
scripts/run_bug_fix.py Updates local runner to use in-process Bugzilla MCP server wiring.
bugbug/tools/bug_fix/agent.py Refactors bug-fix tool to accept an MCP server config instead of raw Bugzilla token/url and removes selector logic.
bugbug/tools/bug_fix/bugzilla_mcp.py Removes dry-run “simulated writes” tracking from Bugzilla MCP context.
bugbug/tools/bug_fix/config.py Expands allowed Firefox MCP tools list (js shell + bootstrap).
bugbug/tools/bug_fix/firefox_mcp.py Exposes new bootstrap_firefox MCP tool and includes it in the server tool list.
bugbug/tools/bug_fix/firefox_tools/init.py Exports new bootstrap helper.
bugbug/tools/bug_fix/firefox_tools/bootstrap_firefox.py Adds async helper for ./mach bootstrap toolchain setup.

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

Comment thread libs/hackbot-runtime/hackbot_runtime/runtime.py Outdated
Comment thread libs/hackbot-runtime/hackbot_runtime/runtime.py Outdated
Comment thread libs/hackbot-runtime/hackbot_runtime/uploader.py Outdated
Comment thread services/hackbot-api/app/gcs.py
Comment thread services/hackbot-api/app/routers/runs.py
Comment thread services/hackbot-api/app/routers/runs.py
Comment thread services/hackbot-api/app/database/connection.py
Comment thread services/hackbot-api/alembic/env.py
Comment thread bugbug/tools/bug_fix/firefox_tools/bootstrap_firefox.py
Comment thread bugbug/tools/bug_fix/firefox_tools/bootstrap_firefox.py
`_validate_result` returned an unraised `RuntimeError` that then flowed
into `_finish` → `_summary_payload_from_exception`. With no active
exception, `traceback.format_exc()` returns "NoneType: None", which
produced a useless summary and obscured the real reason for failure.
Build an AgentResult(status="error", exit_code=1) directly so the
summary path is deterministic, and drop the now-dead RuntimeError
branch in `run()` / `run_async()`.
`upload_file` previously called `path.read_bytes()`, pulling the entire
artifact into memory. The signed POST policy permits uploads up to
several GB; agents that write large build logs or patches would burn
unnecessary RSS. Factor the POST out of `upload_bytes`/`upload_file`
into a shared `_post` that accepts either bytes or a file handle so the
file path streams via the multipart encoder.
The docstring promises every return dict carries `stdout` and `stderr`.
The early-return when the directory is missing and the exception
handler both omitted them, forcing callers to special-case those
shapes. Include empty strings on both paths.
Copy link
Copy Markdown

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

Copilot reviewed 38 out of 42 changed files in this pull request and generated 6 comments.

Comment thread services/hackbot-api/app/gcs.py
Comment thread services/hackbot-api/app/routers/runs.py
Comment thread agents/bug-fix/agent_runner/__main__.py
Comment thread services/hackbot-api/Dockerfile
Comment thread agents/bug-fix/Dockerfile
Comment thread services/hackbot-api/app/gcs.py
@suhaibmujahid suhaibmujahid marked this pull request as ready for review May 31, 2026 01:25
@suhaibmujahid suhaibmujahid requested a review from marco-c May 31, 2026 01:25
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