: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
chore(tasks): remove pointers to the missing Loops spec (#115072)
Paul D'Ambrad9dad30388e2
diff --git a/posthog/api/advanced_activity_logs/viewset.py b/posthog/api/advanced_activity_logs/viewset.pyindex 55fccb19381c..9aaeb93cfdb2 100644--- a/posthog/api/advanced_activity_logs/viewset.py+++ b/posthog/api/advanced_activity_logs/viewset.py@@ -62,8 +62,7 @@ def activity_log_ordering(request: Request) -> tuple[str, str]:def restrict_loop_activity(queryset: QuerySet[ActivityLog], team_id: int, user) -> QuerySet[ActivityLog]:"""Keep personal loops' config out of the team-wide activity feed.- Loop activity is team-scoped in the log, but a personal loop is owner-only (see- products/tasks/docs/LOOPS.md "Access control"). The static visibility manager can't express+ Loop activity is team-scoped in the log, but a personal loop is owner-only. The static visibility manager can't expressper-user ownership, so restrict `Loop`-scoped rows to the loops this user may actually see.Lazy import keeps the tasks product off this module's import path."""diff --git a/posthog/api/github_callback/installation_events.py b/posthog/api/github_callback/installation_events.pyindex 5f3ca6b01e3e..16671456fa70 100644--- a/posthog/api/github_callback/installation_events.py+++ b/posthog/api/github_callback/installation_events.py@@ -98,7 +98,7 @@ def handle_installation_event(payload: dict) -> HttpResponse:def _pause_loops_referencing_integrations(integrations: list[Integration], installation_id: str) -> None:"""Auto-pause every loop referencing a GitHub integration that's about to be hard-deleted.- See products/tasks/docs/LOOPS.md "Lifecycle and reconciliation": the App uninstall hard-deletes+ The App uninstall hard-deletesthe Integration row with no downstream hooks, and loop references to it are JSON, so no FKmachinery helps. Runs before the delete below and is fully isolated: a loops-side failure mustnever break the pre-existing Integration/UserIntegration deletion path.diff --git a/posthog/models/user.py b/posthog/models/user.pyindex 8f5294191100..933b67043173 100644--- a/posthog/models/user.py+++ b/posthog/models/user.py@@ -743,8 +743,7 @@ def _revoke_sessions_on_user_deactivation(sender: type[User], instance: User, **def _pause_loops_on_user_deactivation(sender: type[User], instance: User, **kwargs: object) -> None:"""Pause every loop owned by a user when they are deactivated (is_active True->False).- Loops execute as their owner for GitHub authorship and MCP identity (see- products/tasks/docs/LOOPS.md "Lifecycle and reconciliation"); deactivation is often the+ Loops execute as their owner for GitHub authorship and MCP identity; deactivation is often thesecurity response and must not leave a loop still scheduled, or a sandbox still running,under that owner's identity. Deferred to `transaction.on_commit` since pausing a loop'sTemporal schedule is an irreversible external side effect.diff --git a/posthog/scopes.py b/posthog/scopes.pyindex ae4d851c9d05..c710b509d4f0 100644--- a/posthog/scopes.py+++ b/posthog/scopes.py@@ -263,7 +263,7 @@ PROJECT_SECRET_API_KEY_ALLOWED_API_SCOPE_ACTION: list[tuple[APIScopeObject, APIS("support_ticket", "read"),# First write-capable PSAK scope: lets a service credential fire a loop via# `loops/:id/trigger/`. PSAKs are project-wide, so a leaked key can fire any loop- # in the project (accepted and documented in products/tasks/docs/LOOPS.md).+ # in the project (accepted).("loop", "write"),# Read-only export of experiment definitions (list/retrieve), so services syncing# experiments into a warehouse don't need a credential tied to one person's account.diff --git a/products/tasks/backend/facade/loops.py b/products/tasks/backend/facade/loops.pyindex b5f1644a53fa..f8fff30d2705 100644--- a/products/tasks/backend/facade/loops.py+++ b/products/tasks/backend/facade/loops.py@@ -1,6 +1,6 @@"""Facade API for Loops — the data surface DRF views for `products/tasks/backend/presentation/views/loops.py`-call into. See `products/tasks/docs/LOOPS.md` for the full spec.+call into.Responsibilities:- Accept ids / primitives as input, enforce visibility and permission rules.@@ -8,7 +8,7 @@ Responsibilities:`loop_runs` (fire + trigger-context rendering).- Convert Django models to DTOs before returning — never return ORM instances.-Permission model (see LOOPS.md "Access control"):+Permission model:- Personal loops are owner-only for everything (view, edit, fire, run history).- Team loops are viewable/fireable by any team member. Identity-bearing config(visibility, instructions, runtime_adapter, model, reasoning_effort, repositories,@@ -197,7 +197,7 @@ class LoopNotificationsDTO:@dataclass(frozen=True)class LoopContextOutputsDTO:- """What a context-attached loop maintains each run (see LOOPS.md "Contexts")."""+ """What a context-attached loop maintains each run."""post_to_feed: bool = Falseupdate_context: bool = False@@ -228,7 +228,7 @@ class LoopSkillBundleDTO:@dataclass(frozen=True)class LoopTriggerDTO:- """A single loop trigger. `config` shape depends on `type` — see LOOPS.md `LoopTrigger`."""+ """A single loop trigger. `config` shape depends on `type`."""id: UUIDloop_id: UUID@@ -707,7 +707,7 @@ def visible_loop_ids(team_id: int, user: User | None) -> set[str]:def hidden_personal_loop_ids_for_org(organization_id: str | UUID, user: User | None) -> set[str]:"""Ids of personal loops across an org NOT owned by `user`, as strings. The org-wide activity-logfeed (org admins/owners) must still keep other people's personal-loop config out, since personal- loops are owner-only (see LOOPS.md "Access control"). Cross-team by design, hence `unscoped()`."""+ loops are owner-only. Cross-team by design, hence `unscoped()`."""user_id = getattr(user, "id", None)hidden = Loop.objects.unscoped().filter(team__organization_id=organization_id, visibility=Loop.Visibility.PERSONAL)if user_id is not None:@@ -1287,8 +1287,7 @@ def soft_delete_loop(loop_id: str | UUID, team_id: int, user: User | None) -> bodef _sync_triggers(loop: Loop, trigger_payloads: list[dict]) -> None:- """Id-stable nested trigger sync for an existing loop (see LOOPS.md "Lifecycle and- reconciliation"). Loop creation handles its (necessarily all-new) triggers inline in+ """Id-stable nested trigger sync for an existing loop. Loop creation handles its (necessarily all-new) triggers inline in`create_loop` instead of through here.Matches incoming trigger payloads by `id`: updates matched rows in place, creates rows with@@ -1396,8 +1395,8 @@ def fire_loop_api(loop_id: str | UUID, team_id: int, payload: dict | None, idempotency_key: str | None = None) -> LoopFireResult | None:"""External fire (`loops/:id/trigger/`, PSAK auth). A PSAK is a project-scoped service- credential, so this is project-wide by design and bypasses the personal/team visibility split- (see LOOPS.md "API trigger auth"). Non-PSAK (session/PAT/OAuth) callers of the same endpoint+ credential, so this is project-wide by design and bypasses the personal/team visibility split.+ Non-PSAK (session/PAT/OAuth) callers of the same endpointgo through `fire_loop_api_for_user` instead, which re-imposes that split."""# `internal=False`: internal loops are driven by their backend flow, never externally# firable, even though a PSAK is project-wide (mirrors the read/write API surface).diff --git a/products/tasks/backend/logic/services/loop_runs.py b/products/tasks/backend/logic/services/loop_runs.pyindex bc95dbbbe87e..8238b04a3e66 100644--- a/products/tasks/backend/logic/services/loop_runs.py+++ b/products/tasks/backend/logic/services/loop_runs.py@@ -1,7 +1,6 @@"""Firing, dedup, guardrails and terminal-status bookkeeping for Loops.-See products/tasks/docs/LOOPS.md (Run, Lifecycle and reconciliation, Security and-guardrails). ``fire_loop`` is the single entry point every trigger path (schedule,+``fire_loop`` is the single entry point every trigger path (schedule,GitHub, API, manual) goes through, so dedup, the usage gate, the per-loop rate capand the overlap policy are enforced once, in one order, regardless of caller."""diff --git a/products/tasks/backend/loop_github_events.py b/products/tasks/backend/loop_github_events.pyindex 18490d2dd190..0bcfa78b1ca2 100644--- a/products/tasks/backend/loop_github_events.py+++ b/products/tasks/backend/loop_github_events.py@@ -283,8 +283,7 @@ def _is_self_triggered_branch(event_type: str, payload: dict[str, Any]) -> bool:def _trigger_filters_match(trigger: LoopTrigger, action: str | None, payload: dict[str, Any]) -> bool:"""JSON `filters` evaluated last, after the DB query already matched the promoted- `(github_integration_id, repository, event_types)` columns (see LOOPS.md "GitHub event- triggers: infrastructure changes")."""+ `(github_integration_id, repository, event_types)` columns."""config = trigger.config if isinstance(trigger.config, dict) else {}filters = config.get("filters")return _filters_match(filters if isinstance(filters, dict) else {}, action, payload)diff --git a/products/tasks/backend/loop_lifecycle.py b/products/tasks/backend/loop_lifecycle.pyindex a718e84ef6f5..405329d89dac 100644--- a/products/tasks/backend/loop_lifecycle.py+++ b/products/tasks/backend/loop_lifecycle.py@@ -1,6 +1,6 @@"""Lifecycle pausing for Loops: owner deactivation and integration disconnects.-See products/tasks/docs/LOOPS.md "Lifecycle and reconciliation": deactivating a user is often+Deactivating a user is oftenthe security response, so every loop they own must pause immediately (not lazily at next fire)and their in-flight runs must be cancelled. A live sandbox must never keep running with thatowner's freshly minted credentials after the account has been deactivated. Likewise, a GitHubdiff --git a/products/tasks/backend/loop_reconciliation.py b/products/tasks/backend/loop_reconciliation.pyindex 5230615f5ad1..f27e1c0d371b 100644--- a/products/tasks/backend/loop_reconciliation.py+++ b/products/tasks/backend/loop_reconciliation.py@@ -1,5 +1,4 @@-"""Reconciliation sweep for loop trigger schedules. See products/tasks/docs/LOOPS.md-(Lifecycle and reconciliation).+"""Reconciliation sweep for loop trigger schedules.Schedule sync to Temporal is best-effort: `sync_loop_trigger_schedule` records `pending` or`failed` on the trigger instead of raising, so a transient Temporal outage during a create ordiff --git a/products/tasks/backend/loop_retention.py b/products/tasks/backend/loop_retention.pyindex 9d7399879ed9..6da784e1b816 100644--- a/products/tasks/backend/loop_retention.py+++ b/products/tasks/backend/loop_retention.py@@ -1,4 +1,4 @@-"""Retention sweeps for loop bookkeeping. See products/tasks/docs/LOOPS.md (Run: Cleanup).+"""Retention sweeps for loop bookkeeping.Keeps the newest 200 tasks per loop and soft-deletes the rest (skipping any task with anon-terminal TaskRun), and prunes old LoopFire dedup rows so that table doesn't grow unbounded.diff --git a/products/tasks/backend/loop_service.py b/products/tasks/backend/loop_service.pyindex 5e396806ac61..c3fef89d7504 100644--- a/products/tasks/backend/loop_service.py+++ b/products/tasks/backend/loop_service.py@@ -110,8 +110,7 @@ def sync_loop_trigger_schedule(trigger: LoopTrigger) -> None:"""Create or update the Temporal Schedule backing a schedule-type loop trigger.Never lets a Temporal error propagate to the caller: failures are logged and- recorded on `trigger.schedule_sync_status` instead, per the Lifecycle section of- products/tasks/docs/LOOPS.md.+ recorded on `trigger.schedule_sync_status` instead."""if trigger.type != LoopTrigger.TriggerType.SCHEDULE:returndiff --git a/products/tasks/backend/metrics.py b/products/tasks/backend/metrics.pyindex ae9371975317..be63479deb2a 100644--- a/products/tasks/backend/metrics.py+++ b/products/tasks/backend/metrics.py@@ -435,8 +435,7 @@ DesktopAccessOutcome = Literal[]# outcome: checked_allowed/checked_blocked when the LLM gateway answered the usage check,-# fail_open when a gateway/token error let the run proceed unchecked (see LOOPS.md Security:-# a degraded gateway must not silently remove the only cost backstop), org_deactivated when+# fail_open when a gateway/token error let the run proceed unchecked (a degraded gateway must not silently remove the only cost backstop), org_deactivated when# the local deactivated-organization check blocked the run before any gateway call.CODE_USAGE_GATE_CHECK_TOTAL = Counter("posthog_tasks_code_usage_gate_check_total",diff --git a/products/tasks/backend/models.py b/products/tasks/backend/models.pyindex db2d6d67dc80..05c86cf51ee9 100644--- a/products/tasks/backend/models.py+++ b/products/tasks/backend/models.py@@ -386,7 +386,7 @@ class Task(Taggable, DeletedMetaFields, models.Model):REVIEW_HOG = "review_hog", "ReviewHog"IMAGE_BUILDER = "image_builder", "Image Builder"# Loop firings: named, cloud-executed agent automations triggered by schedule,- # GitHub event or API. See products/tasks/docs/LOOPS.md.+ # GitHub event or API.LOOP = "loop", "Loop"# "Create fix task" on the MCP analytics tool-quality failure drill-down.MCP_ANALYTICS = "mcp_analytics", "MCP Analytics"@@ -2136,8 +2136,7 @@ class ChannelStar(TeamScopedRootMixin):class Loop(ModelActivityMixin, TeamScopedRootMixin):"""A named, cloud-executed agent automation: instructions plus model config,fired by schedule/GitHub/API triggers. Each firing spawns an internal Task- that runs on the standard tasks pipeline as the loop's owner (created_by).- See products/tasks/docs/LOOPS.md."""+ that runs on the standard tasks pipeline as the loop's owner (created_by)."""class Visibility(models.TextChoices):PERSONAL = "personal", "Personal"@@ -2184,7 +2183,7 @@ class Loop(ModelActivityMixin, TeamScopedRootMixin):# Binding to a context (a "#channel" / desktop folder) this loop is attached to, or {} when# unattached. Shape: {folder_id, name, outputs: {post_to_feed, update_context, canvas_id}}.# Drives feed placement (each run's Task.channel) and the context.md / canvas publish contract- # injected into every run's prompt. See products/tasks/docs/LOOPS.md.+ # injected into every run's prompt.context_target = models.JSONField(default=dict, blank=True)# Skill bundles attached at save time: zipped local skills whose manifest entries (same shape# as TaskRun.artifacts entries, type "skill_bundle", bytes in object storage underdiff --git a/products/tasks/backend/presentation/serializers_loops.py b/products/tasks/backend/presentation/serializers_loops.pyindex e8740ee58e61..3dedaec97e9b 100644--- a/products/tasks/backend/presentation/serializers_loops.py+++ b/products/tasks/backend/presentation/serializers_loops.py@@ -1,5 +1,5 @@"""-DRF serializers for Loops. See `products/tasks/docs/LOOPS.md` for the spec.+DRF serializers for Loops.Presentation never imports `products.tasks.backend.models` directly (see`products/architecture.md`): read serializers wrap the frozen DTOs fromdiff --git a/products/tasks/backend/presentation/views/loops.py b/products/tasks/backend/presentation/views/loops.pyindex 32c6c64cc3fe..a28e9f41b387 100644--- a/products/tasks/backend/presentation/views/loops.py+++ b/products/tasks/backend/presentation/views/loops.py@@ -140,7 +140,7 @@ def _content_length(request) -> int:@extend_schema(tags=["loops"])class LoopViewSet(TeamAndOrgViewSetMixin, viewsets.GenericViewSet):"""API for managing loops — named, cloud-executed agent automations triggered by- schedule, GitHub events or authenticated API calls. See `products/tasks/docs/LOOPS.md`."""+ schedule, GitHub events or authenticated API calls."""authentication_classes = [ProjectSecretAPIKeyAuthentication,diff --git a/products/tasks/backend/temporal/process_task/activities/get_task_processing_context.py b/products/tasks/backend/temporal/process_task/activities/get_task_processing_context.pyindex 9cb3db4cb30f..7f2846434f8c 100644--- a/products/tasks/backend/temporal/process_task/activities/get_task_processing_context.py+++ b/products/tasks/backend/temporal/process_task/activities/get_task_processing_context.py@@ -1109,8 +1109,7 @@ def _compile_effective_network_policy(allowed_domains: list[str]) -> EffectiveNedef _loop_pr_follow_up_enabled(task: Task, state: dict) -> bool:"""Loop runs opt into the CI/review-comment follow-up loop when the loop's- snapshotted behaviors ask for it (see products/tasks/docs/LOOPS.md "Behaviors":- `watch_ci` / `fix_review_comments`). Read from the run-state config snapshot, not+ snapshotted behaviors ask for it (`watch_ci` / `fix_review_comments`). Read from the run-state config snapshot, notthe live `Loop` row, so editing a loop's behaviors never changes an in-flight oralready-queued run."""diff --git a/products/tasks/backend/tests/test_loops_api.py b/products/tasks/backend/tests/test_loops_api.pyindex 456cd442cc5e..2aced1e7dad0 100644--- a/products/tasks/backend/tests/test_loops_api.py+++ b/products/tasks/backend/tests/test_loops_api.py@@ -1128,7 +1128,7 @@ class LoopScopeAPITest(LoopsAPITestCase):[(None, "GET", status.HTTP_403_FORBIDDEN),# Loops deliberately use their own scope object rather than reusing `task`, so a- # task-scoped key must never grant loop access (see products/tasks/docs/LOOPS.md).+ # task-scoped key must never grant loop access.("task:write", "GET", status.HTTP_403_FORBIDDEN),("loop:read", "GET", status.HTTP_200_OK),("loop:read", "POST", status.HTTP_403_FORBIDDEN),diff --git a/products/tasks/frontend/generated/api.ts b/products/tasks/frontend/generated/api.tsindex 7d932c55f8b6..f513fe5e1538 100644--- a/products/tasks/frontend/generated/api.ts+++ b/products/tasks/frontend/generated/api.ts@@ -309,7 +309,7 @@ export const getLoopsCreateUrl = (projectId: string) => {/*** API for managing loops — named, cloud-executed agent automations triggered by- * schedule, GitHub events or authenticated API calls. See `products/tasks/docs/LOOPS.md`.+ * schedule, GitHub events or authenticated API calls.* @summary Create a loop*/export const loopsCreate = async (@@ -331,7 +331,7 @@ export const getLoopsRetrieveUrl = (projectId: string, id: string) => {/*** API for managing loops — named, cloud-executed agent automations triggered by- * schedule, GitHub events or authenticated API calls. See `products/tasks/docs/LOOPS.md`.+ * schedule, GitHub events or authenticated API calls.* @summary Get a loop*/export const loopsRetrieve = async (projectId: string, id: string, options?: RequestInit): Promise<LoopDTOApi> => {diff --git a/products/tasks/frontend/generated/api.zod.ts b/products/tasks/frontend/generated/api.zod.tsindex 772caeb19b4d..59c9b668a35b 100644--- a/products/tasks/frontend/generated/api.zod.ts+++ b/products/tasks/frontend/generated/api.zod.ts@@ -11,7 +11,7 @@ import * as zod from 'zod'/*** API for managing loops — named, cloud-executed agent automations triggered by- * schedule, GitHub events or authenticated API calls. See `products/tasks/docs/LOOPS.md`.+ * schedule, GitHub events or authenticated API calls.* @summary Create a loop*/export const loopsCreateBodyNameMax = 400diff --git a/services/mcp/src/generated/tasks/api.ts b/services/mcp/src/generated/tasks/api.tsindex 0839cc20a66a..7891b72b28fd 100644--- a/services/mcp/src/generated/tasks/api.ts+++ b/services/mcp/src/generated/tasks/api.ts@@ -27,7 +27,7 @@ export const LoopsListQueryParams = () => zod.object({/*** API for managing loops — named, cloud-executed agent automations triggered by- * schedule, GitHub events or authenticated API calls. See `products/tasks/docs/LOOPS.md`.+ * schedule, GitHub events or authenticated API calls.* @summary Create a loop*/export const LoopsCreateParams = () => zod.object({@@ -357,7 +357,7 @@ export const LoopsCreateBody = () => zod/*** API for managing loops — named, cloud-executed agent automations triggered by- * schedule, GitHub events or authenticated API calls. See `products/tasks/docs/LOOPS.md`.+ * schedule, GitHub events or authenticated API calls.* @summary Get a loop*/export const LoopsRetrieveParams = () => zod.object({