:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(review-hog): create review tasks from a task profile (#130625)
Charles Vien98bc46045e61
diff --git a/products/review_hog/backend/apps.py b/products/review_hog/backend/apps.pyindex 8f7b238a30d1..8b23e8bfcfe3 100644--- a/products/review_hog/backend/apps.py+++ b/products/review_hog/backend/apps.py@@ -14,4 +14,6 @@ class ReviewHogConfig(AppConfig):# The settings receivers must connect in every process, so that a write from a shell or a# management command is logged too, not only a write from the API. The same applies to the# receivers that clear the cached ownership summary the webhook handler reads.- from products.review_hog.backend import activity_logging, ownership # noqa: F401, PLC0415+ from products.review_hog.backend import activity_logging, ownership, task_profiles # noqa: F401, PLC0415++ task_profiles.register()diff --git a/products/review_hog/backend/reviewer/constants.py b/products/review_hog/backend/reviewer/constants.pyindex f99618121804..5c051448aeae 100644--- a/products/review_hog/backend/reviewer/constants.py+++ b/products/review_hog/backend/reviewer/constants.py@@ -38,18 +38,6 @@ REVIEW_REASONING_EFFORT = ReasoningEffort.XHIGH# and take None here.)REVIEW_INITIAL_PERMISSION_MODE = "full-access"-# Least-privilege PostHog MCP scopes for every ReviewHog sandbox session. The sessions process-# untrusted PR-comment text, and their only legitimate MCP use is reading their criteria skill-# (skill-get / skill-file-get) — without this the context defaults to "full", handing an injectable-# agent execute-sql and every write tool. Internal sandbox-plumbing scopes are re-added by the-# resolver, so this cannot break session mechanics. `user:read` is the MCP handshake: the MCP-# server resolves the calling user (`/api/users/@me/`) when a session opens and refuses the whole-# connection without it, so the agent never gets `skill-get` and silently reviews without its skill.-# `project:read` is deliberately NOT granted: the handshake's project fetch is best-effort, so the-# scope buys only analytics attribution, but `GET /api/projects/<id>/` returns the team's unmasked-# `secret_api_token`, which an injected agent reading untrusted PR text must never be able to read.-REVIEW_MCP_SCOPES: list[str] = ["llm_skill:read", "user:read"]-@dataclass(frozen=True)class ReviewArm:diff --git a/products/review_hog/backend/reviewer/sandbox/executor.py b/products/review_hog/backend/reviewer/sandbox/executor.pyindex d2b4c04b6982..a7a9934ca6c2 100644--- a/products/review_hog/backend/reviewer/sandbox/executor.py+++ b/products/review_hog/backend/reviewer/sandbox/executor.py@@ -7,9 +7,8 @@ from typing import TypeVarfrom pydantic import BaseModel-from products.review_hog.backend.reviewer.constants import REVIEW_MCP_SCOPES+from products.review_hog.backend.task_profiles import REVIEW, REVIEW_MCP_SCOPESfrom products.tasks.backend.facade.agents import CustomPromptSandboxContext, MultiTurnSession-from products.tasks.backend.facade.api import TaskOriginProductfrom products.tasks.backend.facade.contracts import SessionFile_ModelT = TypeVar("_ModelT", bound=BaseModel)@@ -79,8 +78,7 @@ async def _run_prompt(origin_key=_origin_key(workflow_id_prefix),# ReviewHog-attributed and internal (pipeline plumbing, not a user-facing task); the step# lands on $ai_generation as ai_stage for per-stage cost attribution.- origin_product=TaskOriginProduct.REVIEW_HOG,- internal=True,+ profile=REVIEW,ai_stage=step_name or None,json_retry_prompt=JSON_RETRY_PROMPT,files=files,@@ -208,9 +206,8 @@ async def start_sandbox_session(step_name=step_name,workflow_id_prefix=workflow_id_prefix,origin_key=_origin_key(workflow_id_prefix),- # Same attribution trio as _run_prompt: ReviewHog-origin, internal, step as ai_stage.- origin_product=TaskOriginProduct.REVIEW_HOG,- internal=True,+ # Same attribution as _run_prompt: the ReviewHog profile, step as ai_stage.+ profile=REVIEW,ai_stage=step_name or None,json_retry_prompt=JSON_RETRY_PROMPT,)diff --git a/products/review_hog/backend/reviewer/tests/test_constants.py b/products/review_hog/backend/reviewer/tests/test_constants.pyindex 30d772677787..376531a510e1 100644--- a/products/review_hog/backend/reviewer/tests/test_constants.py+++ b/products/review_hog/backend/reviewer/tests/test_constants.py@@ -20,7 +20,6 @@ from products.review_hog.backend.reviewer.constants import (RESOLUTION_REASONING_EFFORT,RESOLUTION_RUNTIME_ADAPTER,REVIEW_ARMS_BY_TIER,- REVIEW_MCP_SCOPES,REVIEW_MODE_FLASH,REVIEW_MODE_FULL,REVIEW_MODEL,@@ -37,6 +36,7 @@ from products.review_hog.backend.reviewer.constants import (select_review_tier,validation_arm_for_mode,)+from products.review_hog.backend.task_profiles import REVIEW_MCP_SCOPESfrom products.review_hog.backend.temporal.types import TRIGGER_AUTOMATIC, TRIGGER_INBOXfrom products.signals.backend.facade.taxonomy import ReportPriorityfrom products.tasks.backend.facade.run_config import (diff --git a/products/review_hog/backend/reviewer/tests/test_executor.py b/products/review_hog/backend/reviewer/tests/test_executor.pyindex 323467876e8f..df82eeceb18a 100644--- a/products/review_hog/backend/reviewer/tests/test_executor.py+++ b/products/review_hog/backend/reviewer/tests/test_executor.py@@ -12,7 +12,7 @@ from products.review_hog.backend.reviewer.sandbox.executor import (run_sandbox_review,start_sandbox_session,)-from products.tasks.backend.facade.api import TaskOriginProduct+from products.review_hog.backend.task_profiles import REVIEW_EXECUTOR_PREFIX = "products.review_hog.backend.reviewer.sandbox.executor"@@ -51,10 +51,9 @@ class TestRunSandboxReview:assert "user prompt" in call_kwargs["prompt"]assert call_kwargs["branch"] == "test-branch"assert call_kwargs["step_name"] == "split"- # Spawn attribution: dropping any of these silently reverts ReviewHog's sandbox tasks to+ # Spawn attribution: dropping the profile silently reverts ReviewHog's sandbox tasks to# user-visible "user_created" ones with no per-stage $ai_generation attribution.- assert call_kwargs["origin_product"] == TaskOriginProduct.REVIEW_HOG- assert call_kwargs["internal"] is True+ assert call_kwargs["profile"] == REVIEWassert call_kwargs["ai_stage"] == "split"# Without the retry prompt a prose first turn fails the whole activity and reruns the review.assert call_kwargs["json_retry_prompt"] == JSON_RETRY_PROMPT@@ -142,8 +141,7 @@ class TestRunSandboxReview:)call_kwargs = mock_start.call_args.kwargs- assert call_kwargs["origin_product"] == TaskOriginProduct.REVIEW_HOG- assert call_kwargs["internal"] is True+ assert call_kwargs["profile"] == REVIEWassert call_kwargs["ai_stage"] == "validation-c3"assert call_kwargs["workflow_id_prefix"] == "review-pr:1:o/r:7/validate:validation-c3"# The session path builds its own context, so the least-privilege pin must hold here too.diff --git a/products/review_hog/backend/task_profiles.py b/products/review_hog/backend/task_profiles.pynew file mode 100644index 000000000000..21a7c229a1fd--- /dev/null+++ b/products/review_hog/backend/task_profiles.py@@ -0,0 +1,70 @@+from products.tasks.backend.facade.profiles import (+ DrivePolicy,+ GithubAccess,+ GithubResolution,+ NetworkAccess,+ NetworkPolicy,+ OAuthApp,+ PrAuthorship,+ Read,+ TaskProfile,+ register_task_profiles,+)++# Least-privilege PostHog MCP scopes for every ReviewHog sandbox session. The sessions process+# untrusted PR-comment text, and their only legitimate MCP use is reading their criteria skill+# (skill-get / skill-file-get) — without this the context defaults to "full", handing an injectable+# agent execute-sql and every write tool. Internal sandbox-plumbing scopes are re-added by the+# resolver, so this cannot break session mechanics. `user:read` is the MCP handshake: the MCP+# server resolves the calling user (`/api/users/@me/`) when a session opens and refuses the whole+# connection without it, so the agent never gets `skill-get` and silently reviews without its skill.+# `project:read` is deliberately NOT granted: the handshake's project fetch is best-effort, so the+# scope buys only analytics attribution, but `GET /api/projects/<id>/` returns the team's unmasked+# `secret_api_token`, which an injected agent reading untrusted PR text must never be able to read.+REVIEW_MCP_SCOPES: list[str] = ["llm_skill:read", "user:read"]++REVIEW = TaskProfile(+ key="review_hog",+ origin_product="review_hog",+ public=False,+ public_options=frozenset(),+ source_kind=None,+ listed=False,+ read_without_channel=Read.CREATOR,+ api_visible=True,+ drive=DrivePolicy.OWNER,+ max_live_per_user=None,+ warm=None,+ runtimes=("acp",),+ sandbox_templates=("default_base",),+ network=NetworkPolicy(levels=(NetworkAccess.FULL,)),+ inherit_user_defaults=False,+ personal_mcp=False,+ mcp_agent=None,+ mcp_scopes=REVIEW_MCP_SCOPES,+ mcp_store_servers=True,+ mcp_exclude_tools=(),+ oauth_app=OAuthApp.ARRAY,+ github_resolution=GithubResolution.WITH_REPOSITORY,+ github_access=GithubAccess.WRITE,+ user_authorable_prs=False,+ default_pr_authorship=PrAuthorship.BOT,+ create_pr=True,+ finish_tool=False,+ done_on_turn_close=False,+ idle_minutes=30,+ inactivity_minutes=10,+ tool_call_minutes=None,+ max_wake_minutes=180,+ billing_product="review_hog",+ bills_compute=False,+ max_cost_usd=None,+ task_budget_usd=None,+ finish_in_flight=True,+)++PROFILES = (REVIEW,)+++def register() -> None:+ register_task_profiles(PROFILES)diff --git a/products/review_hog/eval/experiments/2026-08-model-glm53-flash/scripts/glm_mts_smoke.py b/products/review_hog/eval/experiments/2026-08-model-glm53-flash/scripts/glm_mts_smoke.pyindex c130adfac073..b1f33ba79916 100644--- a/products/review_hog/eval/experiments/2026-08-model-glm53-flash/scripts/glm_mts_smoke.py+++ b/products/review_hog/eval/experiments/2026-08-model-glm53-flash/scripts/glm_mts_smoke.py@@ -22,9 +22,8 @@ django.setup()from pydantic import BaseModel # noqa: E402-from products.review_hog.backend.reviewer.constants import REVIEW_MCP_SCOPES # noqa: E402+from products.review_hog.backend.task_profiles import REVIEW, REVIEW_MCP_SCOPES # noqa: E402from products.tasks.backend.facade.agents import CustomPromptSandboxContext, MultiTurnSession # noqa: E402-from products.tasks.backend.facade.api import TaskOriginProduct # noqa: E402logging.basicConfig(level=logging.INFO, format="%(asctime)s %(levelname)s %(name)s: %(message)s")@@ -123,8 +122,7 @@ async def main() -> int:model=Turn1,step_name="glm-mts-smoke",output_fn=out,- origin_product=TaskOriginProduct.REVIEW_HOG,- internal=True,+ profile=REVIEW,ai_stage="glm-mts-smoke",)print(f"task={session.task.id} run={session.task_run.id} log_url={session.task_run.log_url}", flush=True)diff --git a/products/review_hog/eval/experiments/2026-08-validator-model-sol/scripts/codex_mts_smoke.py b/products/review_hog/eval/experiments/2026-08-validator-model-sol/scripts/codex_mts_smoke.pyindex c2c825e2d1bf..e5520e798d15 100644--- a/products/review_hog/eval/experiments/2026-08-validator-model-sol/scripts/codex_mts_smoke.py+++ b/products/review_hog/eval/experiments/2026-08-validator-model-sol/scripts/codex_mts_smoke.py@@ -22,9 +22,8 @@ django.setup()from pydantic import BaseModel # noqa: E402-from products.review_hog.backend.reviewer.constants import REVIEW_MCP_SCOPES # noqa: E402+from products.review_hog.backend.task_profiles import REVIEW, REVIEW_MCP_SCOPES # noqa: E402from products.tasks.backend.facade.agents import CustomPromptSandboxContext, MultiTurnSession # noqa: E402-from products.tasks.backend.facade.api import TaskOriginProduct # noqa: E402logging.basicConfig(level=logging.INFO, format="%(asctime)s %(levelname)s %(name)s: %(message)s")@@ -116,8 +115,7 @@ async def main() -> int:model=Turn1,step_name="codex-mts-smoke",output_fn=out,- origin_product=TaskOriginProduct.REVIEW_HOG,- internal=True,+ profile=REVIEW,ai_stage="codex-mts-smoke",)print(f"task={session.task.id} run={session.task_run.id} log_url={session.task_run.log_url}", flush=True)diff --git a/products/review_hog/eval/experiments/2026-09-model-kimi-k3/scripts/kimi_mts_smoke.py b/products/review_hog/eval/experiments/2026-09-model-kimi-k3/scripts/kimi_mts_smoke.pyindex 9556691a3438..6cde40904230 100644--- a/products/review_hog/eval/experiments/2026-09-model-kimi-k3/scripts/kimi_mts_smoke.py+++ b/products/review_hog/eval/experiments/2026-09-model-kimi-k3/scripts/kimi_mts_smoke.py@@ -27,9 +27,8 @@ django.setup()from pydantic import BaseModel # noqa: E402-from products.review_hog.backend.reviewer.constants import REVIEW_MCP_SCOPES # noqa: E402+from products.review_hog.backend.task_profiles import REVIEW, REVIEW_MCP_SCOPES # noqa: E402from products.tasks.backend.facade.agents import CustomPromptSandboxContext, MultiTurnSession # noqa: E402-from products.tasks.backend.facade.api import TaskOriginProduct # noqa: E402logging.basicConfig(level=logging.INFO, format="%(asctime)s %(levelname)s %(name)s: %(message)s")@@ -128,8 +127,7 @@ async def main() -> int:model=Turn1,step_name="kimi-mts-smoke",output_fn=out,- origin_product=TaskOriginProduct.REVIEW_HOG,- internal=True,+ profile=REVIEW,ai_stage="kimi-mts-smoke",)print(f"task={session.task.id} run={session.task_run.id} log_url={session.task_run.log_url}", flush=True)