: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(workflows): add a "Run scout" workflow action (#90938)
Harley Alexander93d7f2af3f9e
diff --git a/frontend/src/lib/components/CyclotronJob/customInputRenderers.ts b/frontend/src/lib/components/CyclotronJob/customInputRenderers.tsindex 9e85a2cc1e53..cf1a72dcc4c9 100644--- a/frontend/src/lib/components/CyclotronJob/customInputRenderers.ts+++ b/frontend/src/lib/components/CyclotronJob/customInputRenderers.ts@@ -44,4 +44,7 @@ export const CUSTOM_INPUT_RENDERERS: Record<task_mcp_installations: lazyWithRetry(() => import('products/tasks/frontend/components/TaskConnectorsPicker/CyclotronJobInputTaskConnectors')),+ signals_scout: lazyWithRetry(+ () => import('products/signals/frontend/components/ScoutPicker/CyclotronJobInputScoutPicker')+ ),}diff --git a/frontend/src/lib/constants.tsx b/frontend/src/lib/constants.tsxindex 76900846a409..68972859591f 100644--- a/frontend/src/lib/constants.tsx+++ b/frontend/src/lib/constants.tsx@@ -568,6 +568,7 @@ export const FEATURE_FLAGS = {WEB_ANALYTICS_TILE_TOGGLES: 'web-analytics-tile-toggles', // owner: @lricoy #team-web-analyticsWEB_ANALYTICS_TOOLTIP_COMPARISON_LABELS: 'web-analytics-tooltip-comparison-labels', // owner: @lricoy #team-web-analyticsWORKFLOW_AI_TASK_ACTION: 'workflow-ai-task-action', // owner: @mayteio #team-workflows+ WORKFLOW_RUN_SCOUT_ACTION: 'workflow-run-scout-action', // owner: #team-workflowsWORKFLOWS_DELAY_UNTIL_DATE: 'workflows-delay-until-date', // owner: @dmarchuk #team-workflowsWORKFLOWS_EMAIL_REPUTATION: 'workflows-email-reputation', // owner: #team-workflowsWORKFLOWS_EMAIL_SENDER_ROTATION: 'workflows-email-sender-rotation', // owner: @arthurdedeus #team-workflowsdiff --git a/frontend/src/types.ts b/frontend/src/types.tsindex 847719a4989a..b61ab1dc4267 100644--- a/frontend/src/types.ts+++ b/frontend/src/types.ts@@ -7310,6 +7310,7 @@ export type CyclotronJobInputSchemaType = {| 'task_model'| 'task_repository'| 'task_mcp_installations'+ | 'signals_scout'key: stringlabel: stringchoices?: { value: string; label: string }[]diff --git a/nodejs/src/cdp/async-functions/index.ts b/nodejs/src/cdp/async-functions/index.tsindex 64daa70ec02c..6c55f5d6216a 100644--- a/nodejs/src/cdp/async-functions/index.ts+++ b/nodejs/src/cdp/async-functions/index.ts@@ -2,6 +2,7 @@ import './conversations'import './create-task'import './customer_analytics'import './fetch-handler'+import './run-scout'import './send-email'import './send-push-notification'import './warehouse-webhooks'diff --git a/nodejs/src/cdp/async-functions/run-scout.ts b/nodejs/src/cdp/async-functions/run-scout.tsnew file mode 100644index 000000000000..b48f330444db--- /dev/null+++ b/nodejs/src/cdp/async-functions/run-scout.ts@@ -0,0 +1,83 @@+import { DateTime } from 'luxon'++import { CyclotronInvocationQueueParametersFetchSchema } from '~/cdp/schema/cyclotron'+import { HogFlow } from '~/cdp/schema/hogflow'+import { defaultConfig } from '~/common/config/config'++import { registerAsyncFunction } from '../async-function-registry'+import { PosthogJwtAudience } from '../utils/jwt-utils'+import { ScopedServiceJwt } from '../utils/scoped-service-jwt'++// The token rides the staged fetch verbatim through every engine retry (executeFetch re-queues+// the identical request), so its lifetime must cover the whole backoff chain plus queue lag,+// not one attempt. An expired token 401s, which is not retriable, so the step fails permanently.+// The claims scope it to a single team and workflow, which keeps the longer window cheap.+const TOKEN_TTL_SECONDS = 30 * 60++// Its own key, not postHogCreateTask's — see products/workflows/backend/service_jwt.py for why.+let scoutRunJwt: ScopedServiceJwt | undefined+const getScoutRunJwt = (): ScopedServiceJwt =>+ (scoutRunJwt ??= new ScopedServiceJwt(+ PosthogJwtAudience.WORKFLOW_SCOUT_RUN,+ defaultConfig.WORKFLOW_SCOUT_RUN_JWT_SECRET+ ))++registerAsyncFunction('postHogRunScout', {+ execute: (args, context, result) => {+ const [payload] = args as [Record<string, any> | undefined]++ if (!payload?.skill_name || typeof payload.skill_name !== 'string') {+ throw new Error("postHogRunScout call missing 'skill_name' property")+ }++ // Both come from the flow-spawned invocation, never from step inputs: the hog_flow_id+ // claim is what the endpoint trusts to resolve the calling workflow, and the action id+ // makes the idempotency key step-scoped (the run id alone is shared by every step in+ // the run, so two run-scout steps in one workflow would dedupe against each other).+ const hogFlow = (context.invocation as { hogFlow?: HogFlow }).hogFlow+ const actionId = context.invocation.state.actionId+ if (!hogFlow?.id || !actionId) {+ throw new Error('postHogRunScout only runs inside a workflow')+ }++ const jwt = getScoutRunJwt()+ if (!jwt.enabled) {+ throw new Error(+ 'Running scouts from a workflow is not configured in this environment (WORKFLOW_SCOUT_RUN_JWT_SECRET unset)'+ )+ }+ const token = jwt.mint({ team_id: context.invocation.teamId, hog_flow_id: hogFlow.id }, TOKEN_TTL_SECONDS)++ result.invocation.queueParameters = CyclotronInvocationQueueParametersFetchSchema.parse({+ type: 'fetch',+ url: `${context.siteUrl}/api/projects/${context.invocation.teamId}/workflow_scout_runs/`,+ method: 'POST',+ headers: {+ 'Content-Type': 'application/json',+ Authorization: `Bearer ${token}`,+ },+ body: JSON.stringify({+ skill_name: payload.skill_name,+ idempotency_key: `${context.invocation.id}:${actionId}`,+ }),+ })+ },++ mock: (args, logs) => {+ logs.push({+ level: 'info',+ timestamp: DateTime.now(),+ message: `Async function 'postHogRunScout' was mocked with arguments:`,+ })+ logs.push({+ level: 'info',+ timestamp: DateTime.now(),+ message: `postHogRunScout(${JSON.stringify(args[0], null, 2)})`,+ })++ return {+ status: 202,+ body: { scout: (args[0] as Record<string, any> | undefined)?.skill_name, workflow_id: 'mock-workflow-id' },+ }+ },+})diff --git a/nodejs/src/cdp/config.ts b/nodejs/src/cdp/config.tsindex 80c56981dfea..d37f0ef2139e 100644--- a/nodejs/src/cdp/config.ts+++ b/nodejs/src/cdp/config.ts@@ -195,6 +195,10 @@ export type CdpConfig = ClickhouseConfig & {// Scoped JWT keys signing the workflow engine's task-create calls to Django, with the same// comma-separated rotation and fail-closed-when-empty semantics as the secret above.TASKS_CREATE_JWT_SECRET: string+ // Scoped JWT keys signing the workflow engine's run-scout calls to Django. Its own key, not+ // TASKS_CREATE_JWT_SECRET — see products/workflows/backend/service_jwt.py. Same+ // comma-separated rotation and fail-closed-when-empty semantics.+ WORKFLOW_SCOUT_RUN_JWT_SECRET: stringCYCLOTRON_NODE_RESCHEDULE_FLOOR_SECONDS: numberCYCLOTRON_NODE_RESCHEDULE_WAKE_RATE_PER_SECOND: numberCYCLOTRON_NODE_RESCHEDULE_MIN_WINDOW_SECONDS: number@@ -380,6 +384,8 @@ export function getDefaultCdpConfig(): CdpConfig {WORKFLOWS_CANCEL_JWT_SECRET: isTestEnv() || isDevEnv() ? 'local-dev-workflows-cancel-jwt' : '',// Dev/test default must match Django's (posthog/settings/data_stores.py).TASKS_CREATE_JWT_SECRET: isTestEnv() || isDevEnv() ? 'local-dev-tasks-create-jwt' : '',+ // Dev/test default must match Django's (posthog/settings/data_stores.py).+ WORKFLOW_SCOUT_RUN_JWT_SECRET: isTestEnv() || isDevEnv() ? 'local-dev-workflow-scout-run-jwt' : '',CYCLOTRON_NODE_RESCHEDULE_FLOOR_SECONDS: 600,CYCLOTRON_NODE_RESCHEDULE_WAKE_RATE_PER_SECOND: 200,CYCLOTRON_NODE_RESCHEDULE_MIN_WINDOW_SECONDS: 300,diff --git a/nodejs/src/cdp/schema/cyclotron.ts b/nodejs/src/cdp/schema/cyclotron.tsindex 77b57f885744..14e928bfc06d 100644--- a/nodejs/src/cdp/schema/cyclotron.ts+++ b/nodejs/src/cdp/schema/cyclotron.ts@@ -32,6 +32,7 @@ export const CyclotronJobInputSchemaTypeSchema = z.object({'task_model','task_repository','task_mcp_installations',+ 'signals_scout',]),key: z.string(),label: z.string(),diff --git a/nodejs/src/cdp/templates/_destinations/posthog_signals/posthog-run-scout.template.test.ts b/nodejs/src/cdp/templates/_destinations/posthog_signals/posthog-run-scout.template.test.tsnew file mode 100644index 000000000000..2a3c1f585b55--- /dev/null+++ b/nodejs/src/cdp/templates/_destinations/posthog_signals/posthog-run-scout.template.test.ts@@ -0,0 +1,94 @@+import jwt from 'jsonwebtoken'++import { CyclotronInvocationQueueParametersFetchType } from '~/cdp/schema/cyclotron'+import { parseJSON } from '~/common/utils/json-parse'++import { TemplateTester } from '../../test/test-helpers'+import { template } from './posthog-run-scout.template'++describe('posthog run scout template', () => {+ const tester = new TemplateTester(template)++ const workflowOptions = { hogFlow: { id: '0198c9f1-0000-0000-0000-000000000001' }, actionId: 'action_1' }+ const inputs = { skill_name: 'signals-scout-error-tracking' }++ beforeEach(async () => {+ await tester.beforeEach()+ })++ it('stages an authenticated run request with a step-scoped idempotency key', async () => {+ const response = await tester.invoke(inputs, undefined, workflowOptions)+ expect(response.error).toBeUndefined()+ expect(response.finished).toBe(false)++ const params = response.invocation.queueParameters as CyclotronInvocationQueueParametersFetchType+ expect(params.type).toBe('fetch')+ expect(params.method).toBe('POST')+ expect(params.url).toMatch(/\/api\/projects\/1\/workflow_scout_runs\/$/)++ expect(parseJSON(params.body!)).toEqual({+ skill_name: 'signals-scout-error-tracking',+ idempotency_key: `${response.invocation.id}:action_1`,+ })++ const token = (params.headers?.['Authorization'] ?? '').replace('Bearer ', '')+ // The literal pins the cross-language contract: Django's WORKFLOW_SCOUT_RUN_JWT_SECRET+ // dev default (posthog/settings/data_stores.py) must match the nodejs one or local runs 401.+ // nosemgrep: javascript.jsonwebtoken.security.jwt-hardcode.hardcoded-jwt-secret+ const claims = jwt.verify(token, 'local-dev-workflow-scout-run-jwt', {+ audience: 'posthog:workflows:scout_run',+ algorithms: ['HS256'],+ }) as jwt.JwtPayload+ expect(claims.team_id).toBe(1)+ expect(claims.hog_flow_id).toBe(workflowOptions.hogFlow.id)+ })++ it('fails without staging a request when no scout is chosen', async () => {+ const response = await tester.invoke({ skill_name: '' }, undefined, workflowOptions)+ expect(response.error).toMatch(/A scout is required/)+ expect(response.invocation.queueParameters).toBeUndefined()+ })++ it('fails when invoked outside a workflow', async () => {+ const response = await tester.invoke(inputs)+ expect(response.error).toMatch(/inside a workflow/)+ expect(response.invocation.queueParameters).toBeUndefined()+ })++ it('returns the dispatched run on a 202 response', async () => {+ let response = await tester.invoke(inputs, undefined, workflowOptions)+ response = await tester.invokeFetchResponse(response.invocation, {+ status: 202,+ body: { scout: 'signals-scout-error-tracking', workflow_id: 'wf-1' },+ })++ expect(response.error).toBeUndefined()+ expect(response.finished).toBe(true)+ expect(response.execResult).toEqual({ scout: 'signals-scout-error-tracking', workflow_id: 'wf-1' })+ })++ it('skips instead of failing on a 409 response', async () => {+ let response = await tester.invoke(inputs, undefined, workflowOptions)+ response = await tester.invokeFetchResponse(response.invocation, {+ status: 409,+ body: { detail: 'A run for this scout is already in progress.' },+ })++ expect(response.error).toBeUndefined()+ expect(response.finished).toBe(true)+ expect(response.execResult).toEqual({ skipped: true, reason: 'A run for this scout is already in progress.' })+ expect(response.logs.map((log) => log.message)).toContain(+ 'Scout not run: A run for this scout is already in progress.'+ )+ })++ it.each([+ [403, 'Signals scouts are not enabled for this project.'],+ [404, "No scout named 'signals-scout-typo' exists in this project."],+ ])('surfaces the API error on a %i response', async (status, detail) => {+ let response = await tester.invoke(inputs, undefined, workflowOptions)+ response = await tester.invokeFetchResponse(response.invocation, { status, body: { detail } })++ expect(response.error).toEqual(`Failed to run scout (${status}): ${detail}`)+ })+})diff --git a/nodejs/src/cdp/templates/_destinations/posthog_signals/posthog-run-scout.template.ts b/nodejs/src/cdp/templates/_destinations/posthog_signals/posthog-run-scout.template.tsnew file mode 100644index 000000000000..1a6940139705--- /dev/null+++ b/nodejs/src/cdp/templates/_destinations/posthog_signals/posthog-run-scout.template.ts@@ -0,0 +1,65 @@+import { HogFunctionTemplate } from '~/cdp/types'++import { hogApiErrorMessageFn } from '../../hog-helpers'++export const template: HogFunctionTemplate = {+ free: true,+ status: 'hidden',+ type: 'destination',+ id: 'template-posthog-run-scout',+ name: 'Run scout',+ description:+ 'Start a Signals scout run from a workflow. The scout explores as it does on its schedule and files what it finds to your inbox. The triggering event starts the run but is not shown to it.',+ icon_url: '/static/posthog-icon.svg',+ category: ['Custom'],+ code_language: 'hog',+ code: `+${hogApiErrorMessageFn}++if (empty(inputs.skill_name)) {+ throw Error('A scout is required')+}++let response := postHogRunScout({ 'skill_name': inputs.skill_name })++if (response.status == 409) {+ print(f'Scout not run: {apiErrorMessage(response)}')+ return { 'skipped': true, 'reason': apiErrorMessage(response) }+}++if (response.status >= 400) {+ throw Error(f'Failed to run scout ({response.status}): {apiErrorMessage(response)}')+}++return response.body+`,+ inputs_schema: [+ {+ key: 'skill_name',+ type: 'signals_scout',+ label: 'Scout',+ secret: false,+ required: true,+ description:+ 'Name of the scout to run, as shown in your scout fleet, for example signals-scout-error-tracking. The scout must be active. A paused scout is skipped.',+ },+ {+ // The engine treats a 4xx as a step failure before the code above runs, unless the+ // status is listed here. 409 is the endpoint's answer for every kind of backpressure+ // (paused, cooldown, budget, quota), which the code above turns into a graceful skip.+ // A missing or unrunnable scout answers 404, deliberately NOT listed here, so a+ // misconfigured node fails loudly.+ // required (despite being hidden): the backend only fills a schema default for a+ // required input (posthog/cdp/validation.py), and an API- or MCP-built step has no+ // editor to pre-fill this from the template, so it would otherwise publish with the+ // field unset and fail its workflow on ordinary backpressure instead of skipping.+ key: 'non_failure_status_codes',+ type: 'non_failure_status_codes',+ label: 'Non-failure status codes',+ secret: false,+ required: true,+ hidden: true,+ default: [409],+ },+ ],+}diff --git a/nodejs/src/cdp/templates/index.ts b/nodejs/src/cdp/templates/index.tsindex 96277cb0aaee..d4a238144f95 100644--- a/nodejs/src/cdp/templates/index.ts+++ b/nodejs/src/cdp/templates/index.ts@@ -31,6 +31,7 @@ import { template as posthogTagAccountTemplate } from './_destinations/posthog_cimport { template as posthogUpdateAccountPropertyTemplate } from './_destinations/posthog_customer_analytics/posthog-update-account-property.template'import { template as posthogUpdateAccountRelationshipsTemplate } from './_destinations/posthog_customer_analytics/posthog-update-account-relationships.template'import { template as posthogUpdateAccountTemplate } from './_destinations/posthog_customer_analytics/posthog-update-account.template'+import { template as posthogRunScoutTemplate } from './_destinations/posthog_signals/posthog-run-scout.template'import { template as posthogCreateTaskTemplate } from './_destinations/posthog_tasks/posthog-create-task.template'import { template as posthogSetHogflowVariableTemplate } from './_destinations/posthog_workflows/posthog-set-variable.template'import { template as pushTemplate } from './_destinations/push/push.template'@@ -93,6 +94,7 @@ export const HOG_FUNCTION_TEMPLATES_DESTINATIONS: HogFunctionTemplate[] = [posthogGetTicketTemplate,posthogUpdateTicketTemplate,posthogCreateTaskTemplate,+ posthogRunScoutTemplate,posthogCreateAccountTemplate,posthogGetAccountTemplate,posthogTagAccountTemplate,diff --git a/nodejs/src/cdp/types.ts b/nodejs/src/cdp/types.tsindex 6306b33c1d69..090c6dd97315 100644--- a/nodejs/src/cdp/types.ts+++ b/nodejs/src/cdp/types.ts@@ -519,6 +519,7 @@ export type HogFunctionInputSchemaType = {| 'task_model'| 'task_repository'| 'task_mcp_installations'+ | 'signals_scout'key: stringlabel?: stringchoices?: { value: string; label: string }[]diff --git a/nodejs/src/cdp/utils/jwt-utils.ts b/nodejs/src/cdp/utils/jwt-utils.tsindex f0bf43db5313..3eea15d6d617 100644--- a/nodejs/src/cdp/utils/jwt-utils.ts+++ b/nodejs/src/cdp/utils/jwt-utils.ts@@ -7,6 +7,7 @@ export enum PosthogJwtAudience {WORKFLOWS_CANCEL_INVOCATIONS = 'posthog:workflows:cancel_invocations',WORKFLOWS_CANCEL_BATCH = 'posthog:workflows:cancel_batch',TASKS_CREATE = 'posthog:tasks:create',+ WORKFLOW_SCOUT_RUN = 'posthog:workflows:scout_run',// Must match PosthogJwtAudience.CONVERSATIONS_TICKETS in posthog/jwt.py exactly.CONVERSATIONS_TICKETS = 'posthog:conversations:tickets',// Must match PosthogJwtAudience.CUSTOMER_ANALYTICS_ACCOUNTS in posthog/jwt.py exactly.diff --git a/nodejs/tests/fixtures/hog-bytecode/13ed9ea15853edfabe2184efb3ab276947889ae19df8eebabbffcd1df78d836e.json b/nodejs/tests/fixtures/hog-bytecode/13ed9ea15853edfabe2184efb3ab276947889ae19df8eebabbffcd1df78d836e.jsonnew file mode 100644index 000000000000..c22fb268df06--- /dev/null+++ b/nodejs/tests/fixtures/hog-bytecode/13ed9ea15853edfabe2184efb3ab276947889ae19df8eebabbffcd1df78d836e.json@@ -0,0 +1 @@+["_H",1,32,"signals-scout-error-tracking",38]diff --git a/nodejs/tests/fixtures/hog-bytecode/ddda9822bde8e91c3dfb043ffdc396b620c289384773798e615b242ca497dbfd.json b/nodejs/tests/fixtures/hog-bytecode/ddda9822bde8e91c3dfb043ffdc396b620c289384773798e615b242ca497dbfd.jsonnew file mode 100644index 000000000000..dbdf93d44b47--- /dev/null+++ b/nodejs/tests/fixtures/hog-bytecode/ddda9822bde8e91c3dfb043ffdc396b620c289384773798e615b242ca497dbfd.json@@ -0,0 +1 @@+["_H",1,52,"apiErrorMessage",1,0,28,36,0,32,"body",45,32,"error",45,47,9,35,36,0,32,"body",45,32,"detail",45,47,6,35,36,0,32,"body",45,38,53,0,32,"skill_name",32,"inputs",1,2,2,"empty",1,40,6,32,"A scout is required",2,"Error",1,49,32,"skill_name",32,"skill_name",32,"inputs",1,2,42,1,2,"postHogRunScout",1,33,409,36,1,32,"status",45,11,40,29,32,"Scout not run: ",36,1,36,0,54,1,2,"concat",2,2,"print",1,35,32,"skipped",29,32,"reason",36,1,36,0,54,1,42,2,38,33,400,36,1,32,"status",45,14,40,22,32,"Failed to run scout (",36,1,32,"status",45,32,"): ",36,1,36,0,54,1,2,"concat",4,2,"Error",1,49,36,1,32,"body",45,38,35,35]diff --git a/posthog/cdp/flag_gated_templates.py b/posthog/cdp/flag_gated_templates.pyindex f21825235671..b8390cabd28a 100644--- a/posthog/cdp/flag_gated_templates.py+++ b/posthog/cdp/flag_gated_templates.py@@ -14,6 +14,7 @@ logger = structlog.get_logger(__name__)# frontend/src/lib/constants.tsx. Remove an entry when its feature goes GA.FLAG_GATED_TEMPLATE_IDS = {"template-posthog-create-task": "workflow-ai-task-action",+ "template-posthog-run-scout": "workflow-run-scout-action",}diff --git a/posthog/cdp/test/test_validation.py b/posthog/cdp/test/test_validation.pyindex 65804edb6425..aba0a47dd150 100644--- a/posthog/cdp/test/test_validation.py+++ b/posthog/cdp/test/test_validation.py@@ -1247,6 +1247,8 @@ class TestTaskInputTypeValidation(SimpleTestCase):("installations_string_list", "task_mcp_installations", ["id-1", "id-2"], True),("installations_not_list", "task_mcp_installations", "id-1", False),("installations_not_strings", "task_mcp_installations", [1, 2], False),+ ("signals_scout_string", "signals_scout", "signals-scout-error-tracking", True),+ ("signals_scout_not_string", "signals_scout", 123, False),])def test_task_input_value_shapes(self, _name, schema_type, value, expect_valid):diff --git a/posthog/cdp/validation.py b/posthog/cdp/validation.pyindex 55b0b5d3f90c..cf84fdc1e644 100644--- a/posthog/cdp/validation.py+++ b/posthog/cdp/validation.py@@ -540,6 +540,7 @@ class InputsSchemaItemSerializer(serializers.Serializer):"task_model","task_repository","task_mcp_installations",+ "signals_scout",])key = serializers.CharField()@@ -654,6 +655,9 @@ class InputsItemSerializer(serializers.Serializer):elif item_type == "task_mcp_installations":if not isinstance(value, list) or not all(isinstance(v, str) for v in value):raise serializers.ValidationError({"input": "Value must be a list of MCP connector IDs."})+ elif item_type == "signals_scout":+ if not isinstance(value, str):+ raise serializers.ValidationError({"input": "Value must be a scout skill name."})elif item_type == "email" or item_type == "native_email":if not isinstance(value, dict):raise serializers.ValidationError({"input": f"Value must be an email object."})diff --git a/posthog/jwt.py b/posthog/jwt.pyindex b96932c727b5..57c04bb57031 100644--- a/posthog/jwt.py+++ b/posthog/jwt.py@@ -25,6 +25,7 @@ class PosthogJwtAudience(Enum):WORKFLOWS_CANCEL_BATCH = "posthog:workflows:cancel_batch"INTEGRATION_SERVICE = "posthog:integration_service"TASKS_CREATE = "posthog:tasks:create"+ WORKFLOW_SCOUT_RUN = "posthog:workflows:scout_run"CONVERSATIONS_TICKETS = "posthog:conversations:tickets"CUSTOMER_ANALYTICS_ACCOUNTS = "posthog:customer_analytics:accounts"diff --git a/posthog/settings/data_stores.py b/posthog/settings/data_stores.pyindex 358419d7742b..84ce3ed0a66e 100644--- a/posthog/settings/data_stores.py+++ b/posthog/settings/data_stores.py@@ -584,6 +584,13 @@ TASKS_CREATE_JWT_SECRETS = get_list(get_from_env("TASKS_CREATE_JWT_SECRET", "local-dev-tasks-create-jwt" if DEBUG or TEST else ""))+# Signs the tokens a workflow's "Run scout" action calls back with. Its own key rather than+# TASKS_CREATE_JWT_SECRETS — see products/workflows/backend/service_jwt.py for why. The dev/test+# value must match the plugin server's minting default.+WORKFLOW_SCOUT_RUN_JWT_SECRETS = get_list(+ get_from_env("WORKFLOW_SCOUT_RUN_JWT_SECRET", "local-dev-workflow-scout-run-jwt" if DEBUG or TEST else "")+)+# Verifies the scoped JWTs the CDP worker's conversations ticket actions send to the internal# ticket route (the worker mints, Django verifies; products/conversations/backend/api/internal.py).# Comma-separated, newest first. Empty outside dev/test, so the internal route rejects everydiff --git a/products/cdp/frontend/generated/api.schemas.ts b/products/cdp/frontend/generated/api.schemas.tsindex 2f6ad86c3341..542fd810bc20 100644--- a/products/cdp/frontend/generated/api.schemas.ts+++ b/products/cdp/frontend/generated/api.schemas.ts@@ -284,6 +284,7 @@ export const HogFunctionTypeEnumApi = {* * `task_model` - task_model* * `task_repository` - task_repository* * `task_mcp_installations` - task_mcp_installations+ * * `signals_scout` - signals_scout*/export type InputsSchemaItemTypeEnumApi = (typeof InputsSchemaItemTypeEnumApi)[keyof typeof InputsSchemaItemTypeEnumApi]@@ -308,6 +309,7 @@ export const InputsSchemaItemTypeEnumApi = {TaskModel: 'task_model',TaskRepository: 'task_repository',TaskMcpInstallations: 'task_mcp_installations',+ SignalsScout: 'signals_scout',} as constexport type InputsSchemaItemApiChoicesItem = { [key: string]: unknown }diff --git a/products/cdp/frontend/generated/api.zod.ts b/products/cdp/frontend/generated/api.zod.tsindex e147300d99a2..1c45679f2481 100644--- a/products/cdp/frontend/generated/api.zod.ts+++ b/products/cdp/frontend/generated/api.zod.ts@@ -83,9 +83,10 @@ export const HogFunctionsCreateBody = /* @__PURE__ */ zod.object({'task_model','task_repository','task_mcp_installations',+ 'signals_scout',]).describe(- '\* `string` - string\n\* `number` - number\n\* `boolean` - boolean\n\* `dictionary` - dictionary\n\* `choice` - choice\n\* `json` - json\n\* `integration` - integration\n\* `integration_multi` - integration_multi\n\* `integration_field` - integration_field\n\* `email` - email\n\* `native_email` - native_email\n\* `posthog_assignee` - posthog_assignee\n\* `posthog_ticket_tags` - posthog_ticket_tags\n\* `posthog_business_hours` - posthog_business_hours\n\* `non_failure_status_codes` - non_failure_status_codes\n\* `customer_analytics_account_properties` - customer_analytics_account_properties\n\* `customer_analytics_account_relationships` - customer_analytics_account_relationships\n\* `task_model` - task_model\n\* `task_repository` - task_repository\n\* `task_mcp_installations` - task_mcp_installations'+ '\* `string` - string\n\* `number` - number\n\* `boolean` - boolean\n\* `dictionary` - dictionary\n\* `choice` - choice\n\* `json` - json\n\* `integration` - integration\n\* `integration_multi` - integration_multi\n\* `integration_field` - integration_field\n\* `email` - email\n\* `native_email` - native_email\n\* `posthog_assignee` - posthog_assignee\n\* `posthog_ticket_tags` - posthog_ticket_tags\n\* `posthog_business_hours` - posthog_business_hours\n\* `non_failure_status_codes` - non_failure_status_codes\n\* `customer_analytics_account_properties` - customer_analytics_account_properties\n\* `customer_analytics_account_relationships` - customer_analytics_account_relationships\n\* `task_model` - task_model\n\* `task_repository` - task_repository\n\* `task_mcp_installations` - task_mcp_installations\n\* `signals_scout` - signals_scout'),key: zod.string(),label: zod.string().optional(),@@ -186,9 +187,10 @@ export const HogFunctionsCreateBody = /* @__PURE__ */ zod.object({'task_model','task_repository','task_mcp_installations',+ 'signals_scout',]).describe(- '\* `string` - string\n\* `number` - number\n\* `boolean` - boolean\n\* `dictionary` - dictionary\n\* `choice` - choice\n\* `json` - json\n\* `integration` - integration\n\* `integration_multi` - integration_multi\n\* `integration_field` - integration_field\n\* `email` - email\n\* `native_email` - native_email\n\* `posthog_assignee` - posthog_assignee\n\* `posthog_ticket_tags` - posthog_ticket_tags\n\* `posthog_business_hours` - posthog_business_hours\n\* `non_failure_status_codes` - non_failure_status_codes\n\* `customer_analytics_account_properties` - customer_analytics_account_properties\n\* `customer_analytics_account_relationships` - customer_analytics_account_relationships\n\* `task_model` - task_model\n\* `task_repository` - task_repository\n\* `task_mcp_installations` - task_mcp_installations'+ '\* `string` - string\n\* `number` - number\n\* `boolean` - boolean\n\* `dictionary` - dictionary\n\* `choice` - choice\n\* `json` - json\n\* `integration` - integration\n\* `integration_multi` - integration_multi\n\* `integration_field` - integration_field\n\* `email` - email\n\* `native_email` - native_email\n\* `posthog_assignee` - posthog_assignee\n\* `posthog_ticket_tags` - posthog_ticket_tags\n\* `posthog_business_hours` - posthog_business_hours\n\* `non_failure_status_codes` - non_failure_status_codes\n\* `customer_analytics_account_properties` - customer_analytics_account_properties\n\* `customer_analytics_account_relationships` - customer_analytics_account_relationships\n\* `task_model` - task_model\n\* `task_repository` - task_repository\n\* `task_mcp_installations` - task_mcp_installations\n\* `signals_scout` - signals_scout'),key: zod.string(),label: zod.string().optional(),@@ -352,9 +354,10 @@ export const HogFunctionsUpdateBody = /* @__PURE__ */ zod.object({'task_model','task_repository','task_mcp_installations',+ 'signals_scout',]).describe(- '\* `string` - string\n\* `number` - number\n\* `boolean` - boolean\n\* `dictionary` - dictionary\n\* `choice` - choice\n\* `json` - json\n\* `integration` - integration\n\* `integration_multi` - integration_multi\n\* `integration_field` - integration_field\n\* `email` - email\n\* `native_email` - native_email\n\* `posthog_assignee` - posthog_assignee\n\* `posthog_ticket_tags` - posthog_ticket_tags\n\* `posthog_business_hours` - posthog_business_hours\n\* `non_failure_status_codes` - non_failure_status_codes\n\* `customer_analytics_account_properties` - customer_analytics_account_properties\n\* `customer_analytics_account_relationships` - customer_analytics_account_relationships\n\* `task_model` - task_model\n\* `task_repository` - task_repository\n\* `task_mcp_installations` - task_mcp_installations'+ '\* `string` - string\n\* `number` - number\n\* `boolean` - boolean\n\* `dictionary` - dictionary\n\* `choice` - choice\n\* `json` - json\n\* `integration` - integration\n\* `integration_multi` - integration_multi\n\* `integration_field` - integration_field\n\* `email` - email\n\* `native_email` - native_email\n\* `posthog_assignee` - posthog_assignee\n\* `posthog_ticket_tags` - posthog_ticket_tags\n\* `posthog_business_hours` - posthog_business_hours\n\* `non_failure_status_codes` - non_failure_status_codes\n\* `customer_analytics_account_properties` - customer_analytics_account_properties\n\* `customer_analytics_account_relationships` - customer_analytics_account_relationships\n\* `task_model` - task_model\n\* `task_repository` - task_repository\n\* `task_mcp_installations` - task_mcp_installations\n\* `signals_scout` - signals_scout'),key: zod.string(),label: zod.string().optional(),@@ -455,9 +458,10 @@ export const HogFunctionsUpdateBody = /* @__PURE__ */ zod.object({'task_model','task_repository','task_mcp_installations',+ 'signals_scout',]).describe(- '\* `string` - string\n\* `number` - number\n\* `boolean` - boolean\n\* `dictionary` - dictionary\n\* `choice` - choice\n\* `json` - json\n\* `integration` - integration\n\* `integration_multi` - integration_multi\n\* `integration_field` - integration_field\n\* `email` - email\n\* `native_email` - native_email\n\* `posthog_assignee` - posthog_assignee\n\* `posthog_ticket_tags` - posthog_ticket_tags\n\* `posthog_business_hours` - posthog_business_hours\n\* `non_failure_status_codes` - non_failure_status_codes\n\* `customer_analytics_account_properties` - customer_analytics_account_properties\n\* `customer_analytics_account_relationships` - customer_analytics_account_relationships\n\* `task_model` - task_model\n\* `task_repository` - task_repository\n\* `task_mcp_installations` - task_mcp_installations'+ '\* `string` - string\n\* `number` - number\n\* `boolean` - boolean\n\* `dictionary` - dictionary\n\* `choice` - choice\n\* `json` - json\n\* `integration` - integration\n\* `integration_multi` - integration_multi\n\* `integration_field` - integration_field\n\* `email` - email\n\* `native_email` - native_email\n\* `posthog_assignee` - posthog_assignee\n\* `posthog_ticket_tags` - posthog_ticket_tags\n\* `posthog_business_hours` - posthog_business_hours\n\* `non_failure_status_codes` - non_failure_status_codes\n\* `customer_analytics_account_properties` - customer_analytics_account_properties\n\* `customer_analytics_account_relationships` - customer_analytics_account_relationships\n\* `task_model` - task_model\n\* `task_repository` - task_repository\n\* `task_mcp_installations` - task_mcp_installations\n\* `signals_scout` - signals_scout'),key: zod.string(),label: zod.string().optional(),@@ -621,9 +625,10 @@ export const HogFunctionsPartialUpdateBody = /* @__PURE__ */ zod.object({'task_model','task_repository','task_mcp_installations',+ 'signals_scout',]).describe(- '\* `string` - string\n\* `number` - number\n\* `boolean` - boolean\n\* `dictionary` - dictionary\n\* `choice` - choice\n\* `json` - json\n\* `integration` - integration\n\* `integration_multi` - integration_multi\n\* `integration_field` - integration_field\n\* `email` - email\n\* `native_email` - native_email\n\* `posthog_assignee` - posthog_assignee\n\* `posthog_ticket_tags` - posthog_ticket_tags\n\* `posthog_business_hours` - posthog_business_hours\n\* `non_failure_status_codes` - non_failure_status_codes\n\* `customer_analytics_account_properties` - customer_analytics_account_properties\n\* `customer_analytics_account_relationships` - customer_analytics_account_relationships\n\* `task_model` - task_model\n\* `task_repository` - task_repository\n\* `task_mcp_installations` - task_mcp_installations'+ '\* `string` - string\n\* `number` - number\n\* `boolean` - boolean\n\* `dictionary` - dictionary\n\* `choice` - choice\n\* `json` - json\n\* `integration` - integration\n\* `integration_multi` - integration_multi\n\* `integration_field` - integration_field\n\* `email` - email\n\* `native_email` - native_email\n\* `posthog_assignee` - posthog_assignee\n\* `posthog_ticket_tags` - posthog_ticket_tags\n\* `posthog_business_hours` - posthog_business_hours\n\* `non_failure_status_codes` - non_failure_status_codes\n\* `customer_analytics_account_properties` - customer_analytics_account_properties\n\* `customer_analytics_account_relationships` - customer_analytics_account_relationships\n\* `task_model` - task_model\n\* `task_repository` - task_repository\n\* `task_mcp_installations` - task_mcp_installations\n\* `signals_scout` - signals_scout'),key: zod.string(),label: zod.string().optional(),@@ -724,9 +729,10 @@ export const HogFunctionsPartialUpdateBody = /* @__PURE__ */ zod.object({'task_model','task_repository','task_mcp_installations',+ 'signals_scout',]).describe(- '\* `string` - string\n\* `number` - number\n\* `boolean` - boolean\n\* `dictionary` - dictionary\n\* `choice` - choice\n\* `json` - json\n\* `integration` - integration\n\* `integration_multi` - integration_multi\n\* `integration_field` - integration_field\n\* `email` - email\n\* `native_email` - native_email\n\* `posthog_assignee` - posthog_assignee\n\* `posthog_ticket_tags` - posthog_ticket_tags\n\* `posthog_business_hours` - posthog_business_hours\n\* `non_failure_status_codes` - non_failure_status_codes\n\* `customer_analytics_account_properties` - customer_analytics_account_properties\n\* `customer_analytics_account_relationships` - customer_analytics_account_relationships\n\* `task_model` - task_model\n\* `task_repository` - task_repository\n\* `task_mcp_installations` - task_mcp_installations'+ '\* `string` - string\n\* `number` - number\n\* `boolean` - boolean\n\* `dictionary` - dictionary\n\* `choice` - choice\n\* `json` - json\n\* `integration` - integration\n\* `integration_multi` - integration_multi\n\* `integration_field` - integration_field\n\* `email` - email\n\* `native_email` - native_email\n\* `posthog_assignee` - posthog_assignee\n\* `posthog_ticket_tags` - posthog_ticket_tags\n\* `posthog_business_hours` - posthog_business_hours\n\* `non_failure_status_codes` - non_failure_status_codes\n\* `customer_analytics_account_properties` - customer_analytics_account_properties\n\* `customer_analytics_account_relationships` - customer_analytics_account_relationships\n\* `task_model` - task_model\n\* `task_repository` - task_repository\n\* `task_mcp_installations` - task_mcp_installations\n\* `signals_scout` - signals_scout'),key: zod.string(),label: zod.string().optional(),@@ -894,9 +900,10 @@ export const HogFunctionsEnableBackfillsCreateBody = /* @__PURE__ */ zod.object('task_model','task_repository','task_mcp_installations',+ 'signals_scout',]).describe(- '\* `string` - string\n\* `number` - number\n\* `boolean` - boolean\n\* `dictionary` - dictionary\n\* `choice` - choice\n\* `json` - json\n\* `integration` - integration\n\* `integration_multi` - integration_multi\n\* `integration_field` - integration_field\n\* `email` - email\n\* `native_email` - native_email\n\* `posthog_assignee` - posthog_assignee\n\* `posthog_ticket_tags` - posthog_ticket_tags\n\* `posthog_business_hours` - posthog_business_hours\n\* `non_failure_status_codes` - non_failure_status_codes\n\* `customer_analytics_account_properties` - customer_analytics_account_properties\n\* `customer_analytics_account_relationships` - customer_analytics_account_relationships\n\* `task_model` - task_model\n\* `task_repository` - task_repository\n\* `task_mcp_installations` - task_mcp_installations'+ '\* `string` - string\n\* `number` - number\n\* `boolean` - boolean\n\* `dictionary` - dictionary\n\* `choice` - choice\n\* `json` - json\n\* `integration` - integration\n\* `integration_multi` - integration_multi\n\* `integration_field` - integration_field\n\* `email` - email\n\* `native_email` - native_email\n\* `posthog_assignee` - posthog_assignee\n\* `posthog_ticket_tags` - posthog_ticket_tags\n\* `posthog_business_hours` - posthog_business_hours\n\* `non_failure_status_codes` - non_failure_status_codes\n\* `customer_analytics_account_properties` - customer_analytics_account_properties\n\* `customer_analytics_account_relationships` - customer_analytics_account_relationships\n\* `task_model` - task_model\n\* `task_repository` - task_repository\n\* `task_mcp_installations` - task_mcp_installations\n\* `signals_scout` - signals_scout'),key: zod.string(),label: zod.string().optional(),@@ -997,9 +1004,10 @@ export const HogFunctionsEnableBackfillsCreateBody = /* @__PURE__ */ zod.object('task_model','task_repository','task_mcp_installations',+ 'signals_scout',]).describe(- '\* `string` - string\n\* `number` - number\n\* `boolean` - boolean\n\* `dictionary` - dictionary\n\* `choice` - choice\n\* `json` - json\n\* `integration` - integration\n\* `integration_multi` - integration_multi\n\* `integration_field` - integration_field\n\* `email` - email\n\* `native_email` - native_email\n\* `posthog_assignee` - posthog_assignee\n\* `posthog_ticket_tags` - posthog_ticket_tags\n\* `posthog_business_hours` - posthog_business_hours\n\* `non_failure_status_codes` - non_failure_status_codes\n\* `customer_analytics_account_properties` - customer_analytics_account_properties\n\* `customer_analytics_account_relationships` - customer_analytics_account_relationships\n\* `task_model` - task_model\n\* `task_repository` - task_repository\n\* `task_mcp_installations` - task_mcp_installations'+ '\* `string` - string\n\* `number` - number\n\* `boolean` - boolean\n\* `dictionary` - dictionary\n\* `choice` - choice\n\* `json` - json\n\* `integration` - integration\n\* `integration_multi` - integration_multi\n\* `integration_field` - integration_field\n\* `email` - email\n\* `native_email` - native_email\n\* `posthog_assignee` - posthog_assignee\n\* `posthog_ticket_tags` - posthog_ticket_tags\n\* `posthog_business_hours` - posthog_business_hours\n\* `non_failure_status_codes` - non_failure_status_codes\n\* `customer_analytics_account_properties` - customer_analytics_account_properties\n\* `customer_analytics_account_relationships` - customer_analytics_account_relationships\n\* `task_model` - task_model\n\* `task_repository` - task_repository\n\* `task_mcp_installations` - task_mcp_installations\n\* `signals_scout` - signals_scout'),key: zod.string(),label: zod.string().optional(),@@ -1239,9 +1247,10 @@ export const HogFunctionsInvocationsCreateBody = /* @__PURE__ */ zod.object({'task_model','task_repository','task_mcp_installations',+ 'signals_scout',]).describe(- '\* `string` - string\n\* `number` - number\n\* `boolean` - boolean\n\* `dictionary` - dictionary\n\* `choice` - choice\n\* `json` - json\n\* `integration` - integration\n\* `integration_multi` - integration_multi\n\* `integration_field` - integration_field\n\* `email` - email\n\* `native_email` - native_email\n\* `posthog_assignee` - posthog_assignee\n\* `posthog_ticket_tags` - posthog_ticket_tags\n\* `posthog_business_hours` - posthog_business_hours\n\* `non_failure_status_codes` - non_failure_status_codes\n\* `customer_analytics_account_properties` - customer_analytics_account_properties\n\* `customer_analytics_account_relationships` - customer_analytics_account_relationships\n\* `task_model` - task_model\n\* `task_repository` - task_repository\n\* `task_mcp_installations` - task_mcp_installations'+ '\* `string` - string\n\* `number` - number\n\* `boolean` - boolean\n\* `dictionary` - dictionary\n\* `choice` - choice\n\* `json` - json\n\* `integration` - integration\n\* `integration_multi` - integration_multi\n\* `integration_field` - integration_field\n\* `email` - email\n\* `native_email` - native_email\n\* `posthog_assignee` - posthog_assignee\n\* `posthog_ticket_tags` - posthog_ticket_tags\n\* `posthog_business_hours` - posthog_business_hours\n\* `non_failure_status_codes` - non_failure_status_codes\n\* `customer_analytics_account_properties` - customer_analytics_account_properties\n\* `customer_analytics_account_relationships` - customer_analytics_account_relationships\n\* `task_model` - task_model\n\* `task_repository` - task_repository\n\* `task_mcp_installations` - task_mcp_installations\n\* `signals_scout` - signals_scout'),key: zod.string(),label: zod.string().optional(),@@ -1357,9 +1366,10 @@ export const HogFunctionsInvocationsCreateBody = /* @__PURE__ */ zod.object({'task_model','task_repository','task_mcp_installations',+ 'signals_scout',]).describe(- '\* `string` - string\n\* `number` - number\n\* `boolean` - boolean\n\* `dictionary` - dictionary\n\* `choice` - choice\n\* `json` - json\n\* `integration` - integration\n\* `integration_multi` - integration_multi\n\* `integration_field` - integration_field\n\* `email` - email\n\* `native_email` - native_email\n\* `posthog_assignee` - posthog_assignee\n\* `posthog_ticket_tags` - posthog_ticket_tags\n\* `posthog_business_hours` - posthog_business_hours\n\* `non_failure_status_codes` - non_failure_status_codes\n\* `customer_analytics_account_properties` - customer_analytics_account_properties\n\* `customer_analytics_account_relationships` - customer_analytics_account_relationships\n\* `task_model` - task_model\n\* `task_repository` - task_repository\n\* `task_mcp_installations` - task_mcp_installations'+ '\* `string` - string\n\* `number` - number\n\* `boolean` - boolean\n\* `dictionary` - dictionary\n\* `choice` - choice\n\* `json` - json\n\* `integration` - integration\n\* `integration_multi` - integration_multi\n\* `integration_field` - integration_field\n\* `email` - email\n\* `native_email` - native_email\n\* `posthog_assignee` - posthog_assignee\n\* `posthog_ticket_tags` - posthog_ticket_tags\n\* `posthog_business_hours` - posthog_business_hours\n\* `non_failure_status_codes` - non_failure_status_codes\n\* `customer_analytics_account_properties` - customer_analytics_account_properties\n\* `customer_analytics_account_relationships` - customer_analytics_account_relationships\n\* `task_model` - task_model\n\* `task_repository` - task_repository\n\* `task_mcp_installations` - task_mcp_installations\n\* `signals_scout` - signals_scout'),key: zod.string(),label: zod.string().optional(),diff --git a/products/signals/ARCHITECTURE.md b/products/signals/ARCHITECTURE.mdindex 9860e3d5daca..11fd164512c1 100644--- a/products/signals/ARCHITECTURE.md+++ b/products/signals/ARCHITECTURE.md@@ -333,6 +333,16 @@ dispatch when a prior run for the same `(team, skill_name)` hasmodel's own status column; active recovery of stranded `IN_PROGRESS` task runs(`_self_heal_stale_runs` is a no-op today) is a tracked follow-up.+**Three dispatch paths, one workflow.** The coordinator's per-tick children are the schedule+(`triggered_by="schedule"`). Two off-schedule paths reuse the same workflow under their own stable id+namespaces, so they single-flight independently at the Temporal server: the `run` endpoint+(`"manual"`) and a workflow's "Run scout" step (`"workflow"`, `backend/scout_harness/workflow_runs.py`,+called from the workflows product's `workflow_scout_runs` endpoint). Neither stamps `last_run_at`,+and neither feeds the failure-streak breaker whose threshold is sized on the schedule. The gates they+share (enrolment kill switch, daily run budget, Signals quota, daily report limit, in-flight+single-flight) live in `backend/scout_harness/run_gates.py`; the workflow path adds a 30-minute+per-`(team, skill)` cooldown, a backstop that does not have to trust the workflow's masking config.+Findings emitted during the run go through the harness's `emit_signal_*` tools,which call `emit_signal()` with `source_product="signals_scout"` and`source_type="cross_source_issue"` — from there the signal flows through the same@@ -572,20 +582,20 @@ Per-scout binding for the headless **Signals agent**: one row per `(team, skill_Thin bridge from a Tasks `TaskRun` to the scout skill that ran inside it: one scout-domain row per scheduled agent run that links its `TaskRun` to the skill it executed. Status, timing, error context, and the full chat log live on the `TaskRun`; emitted findings are `Signal` / `SignalReport` rows written by `emit_signal()`. This row carries only the scout-specific fields that need to be queryable as real columns.-| Field | Type | Description |-| --------------- | --------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |-| `team` | FK → Team | Owning team (`related_name="signal_scout_runs"`). Denormalised tenant boundary; canonical value is `task_run.task.team`. |-| `task_run` | OneToOne → tasks.TaskRun | The `TaskRun` the scout span ran inside (`related_name="signal_scout_run"`, CASCADE — bridge row goes when the `TaskRun` is purged). |-| `scout_config` | FK → SignalScoutConfig (SET_NULL) | Audit pointer; `SET_NULL` so deleting and recreating a config doesn't destroy run history. |-| `skill_name` | CharField(200) | The `signals-scout-*` skill the run executed. |-| `skill_version` | Int | The `LLMSkill.version` snapshot at run start. |-| `summary` | TextField | One-paragraph close-out the agent writes at end-of-run. Searchable via ILIKE on the list endpoint so future runs can dedupe even when no `Signal` row was emitted. |-| `metadata` | JSONField | Server-written run context in two regions: runner-stamped top-level keys (always `harness_prompt_version` / `report_channel` / `skill_origin`; plus `model` / `runtime_adapter` / `reasoning_effort` when routing overrode the default) and the nested `derived` map of harness-computed booleans written at finalize. See below. |-| `created_at` | DateTime | Auto-set on creation. |+| Field | Type | Description |+| --------------- | --------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |+| `team` | FK → Team | Owning team (`related_name="signal_scout_runs"`). Denormalised tenant boundary; canonical value is `task_run.task.team`. |+| `task_run` | OneToOne → tasks.TaskRun | The `TaskRun` the scout span ran inside (`related_name="signal_scout_run"`, CASCADE — bridge row goes when the `TaskRun` is purged). |+| `scout_config` | FK → SignalScoutConfig (SET_NULL) | Audit pointer; `SET_NULL` so deleting and recreating a config doesn't destroy run history. |+| `skill_name` | CharField(200) | The `signals-scout-*` skill the run executed. |+| `skill_version` | Int | The `LLMSkill.version` snapshot at run start. |+| `summary` | TextField | One-paragraph close-out the agent writes at end-of-run. Searchable via ILIKE on the list endpoint so future runs can dedupe even when no `Signal` row was emitted. |+| `metadata` | JSONField | Server-written run context in two regions: runner-stamped top-level keys (always `harness_prompt_version` / `report_channel` / `skill_origin`; plus `model` / `runtime_adapter` / `reasoning_effort` when routing overrode the default, plus `triggered_by` when the run was not dispatched by the schedule) and the nested `derived` map of harness-computed booleans written at finalize. See below. |+| `created_at` | DateTime | Auto-set on creation. |**Status, timing, and chat log live on the linked `TaskRun`.** The bridge row carries no `status` / `started_at` / `completed_at` / `findings` / `run_metrics` of its own — those moved to `tasks.TaskRun` so the LLM-analytics token / cost roll-up, the Tasks UI, and the harness all see one canonical record.-**Run provenance is stamped, not re-derived.** `harness_prompt_version` (a hash of `scout_harness/prompt.py` plus the imported constants its templates render, identifying the prompt build), `report_channel` (`none`/`emit`/`edit`/`both`, since the prompt branches on the two report capabilities separately), `skill_origin`, and `github_guidance` are written at run creation because none can be reconstructed later: the harness prompt carries no version history, `allowed_tools` is editable, and a seeded canonical skill row becomes `custom` as soon as a team edits it. Together they let a model or prompt A/B compare only runs that were given the same prompt shape. All four ride the `signals_scout_run_started` / `_finished` events too, which is where that readout happens.+**Run provenance is stamped, not re-derived.** `harness_prompt_version` (a hash of `scout_harness/prompt.py` plus the imported constants its templates render, identifying the prompt build), `report_channel` (`none`/`emit`/`edit`/`both`, since the prompt branches on the two report capabilities separately), `skill_origin`, and `github_guidance` are written at run creation because none can be reconstructed later: the harness prompt carries no version history, `allowed_tools` is editable, and a seeded canonical skill row becomes `custom` as soon as a team edits it. Together they let a model or prompt A/B compare only runs that were given the same prompt shape. All four ride the `signals_scout_run_started` / `_finished` events too, which is where that readout happens. `triggered_by` is stamped the same way but only when it is not `schedule`, so absence reads as the default path; the workflow trigger's cooldown reads it back to tell its own prior fires apart from scheduled patrols and human "Run now" presses.**Run metadata is derived, never self-reported.** `metadata.derived` answers "what kind of run was this?" (`has_emit_report`, `has_edit_report`, `has_self_improvement`, `has_chart`, `has_self_validation`) and is computed server-side at finalize by `scout_harness/derived_metadata.py` from the run's own settled output. Asking the scout to declare these instead would make each flag only as reliable as the model remembering to write it, so the column stays queryable precisely because nothing in it is agent-authored. An absent `derived` region is unknown rather than all-false: the run predates the field, never reached finalize, or its stamp failed (best-effort, logged). `MultiTurnSession` owns the `TaskRun` lifecycle; the `on_task_run_created` hook attaches the `TaskRun` to the bridge row before the agent's first turn.@@ -1410,7 +1420,9 @@ products/signals/│ │ ├── prompt.py # System prompt assembly (skill + scratchpad + profile + run history)│ │ ├── skill_loader.py # Resolves signals-scout-* LLMSkill rows for a run│ │ ├── lazy_seed.py # Canonical SKILL.md → LLMSkill sync (sync_canonical_skills)-│ │ ├── limits.py # DEFAULT_MAX_RUNTIME_S + ACTIVITY_SLACK_S + WORKFLOW_HARD_CEILING_S+│ │ ├── limits.py # DEFAULT_MAX_RUNTIME_S + ACTIVITY_SLACK_S + WORKFLOW_HARD_CEILING_S + trigger-source vocabulary+│ │ ├── run_gates.py # Pre-dispatch gates shared by the off-schedule run paths+│ │ ├── workflow_runs.py # Dispatch for a workflow step that runs a scout│ │ ├── serializers.py # DRF serializers for runs / scratchpad / project profile│ │ ├── views.py # SignalScoutRunViewSet, SignalScratchpadViewSet, SignalProjectProfileViewSet│ │ ├── profile/diff --git a/products/signals/backend/facade/api.py b/products/signals/backend/facade/api.pyindex 88c7d4b3c447..47a2a61240c4 100644--- a/products/signals/backend/facade/api.py+++ b/products/signals/backend/facade/api.py@@ -23,6 +23,19 @@ from posthog.temporal.common.client import async_connectfrom products.signals.backend.contracts import DIRECT_STEERABLE_SOURCES, SIGNAL_VARIANT_LOOKUP, SignalRemediationfrom products.signals.backend.enums import SIGNAL_SOURCE_PRODUCT_LABELS, SignalSourceProductfrom products.signals.backend.models import SignalReport, SignalScoutConfig, SignalScoutRun, SignalSourceConfig+from products.signals.backend.scout_harness.run_gates import (+ # Re-exported so the workflows endpoint can branch on why a fire was refused without reaching+ # into the scout harness. Every decision behind them stays Signals-side.+ ScoutRunRejectionKind as ScoutRunRejectionKind,+)+from products.signals.backend.scout_harness.workflow_runs import (+ WorkflowScoutRunRejected as WorkflowScoutRunRejected,+ WorkflowScoutRunStarted as WorkflowScoutRunStarted,+ # Facade entrypoint for a workflow's "Run scout" step: the workflows endpoint proves which+ # workflow is firing, and everything after that (enrolment, budget, quota, the paused-scout+ # rule, the workflow cooldown, single-flight, dispatch) happens here.+ start_workflow_scout_run as start_workflow_scout_run,+)from products.signals.backend.signal_metadata import fetch_signal_stats_for_source_slice# Re-exported for external products (tasks presentation catches it around facade create_task).diff --git a/products/signals/backend/management/commands/run_signals_scout.py b/products/signals/backend/management/commands/run_signals_scout.pyindex 04969a0c71e0..57db4ed3fade 100644--- a/products/signals/backend/management/commands/run_signals_scout.py+++ b/products/signals/backend/management/commands/run_signals_scout.py@@ -9,6 +9,7 @@ from __future__ import annotationsfrom django.core.management.base import BaseCommand, CommandError+from products.signals.backend.scout_harness.limits import TRIGGERED_BY_MANUALfrom products.signals.backend.scout_harness.runner import run_signals_scoutfrom products.signals.backend.scout_harness.skill_loader import SkillNotFoundError@@ -35,7 +36,7 @@ class Command(BaseCommand):skill_version=options["skill_version"],repository=options["repository"],verbose=options["verbose"],- triggered_by="manual",+ triggered_by=TRIGGERED_BY_MANUAL,)except SkillNotFoundError as exc:raise CommandError(str(exc))diff --git a/products/signals/backend/scout_harness/limits.py b/products/signals/backend/scout_harness/limits.pyindex b4811d3418d5..203ec934fd3d 100644--- a/products/signals/backend/scout_harness/limits.py+++ b/products/signals/backend/scout_harness/limits.py@@ -137,6 +137,23 @@ def interval_runs_in_tolerance_window(interval_minutes: int) -> int:# rather than up to a full (possibly 30-day) interval after the underlying cause is fixed.AUTO_PAUSE_PROBE_INTERVAL_S = 24 * 60 * 60+# How a run was dispatched, carried on `RunSignalsScoutInput.triggered_by` and stamped onto+# `SignalScoutRun.metadata` for anything but the schedule (absence means "schedule", matching how+# the rest of that blob omits default-path keys). Only `schedule` failures feed the failure-streak+# breaker — the threshold is sized on the schedule's cadence, so off-schedule runs must not count.+TRIGGERED_BY_SCHEDULE = "schedule"+TRIGGERED_BY_MANUAL = "manual"+TRIGGERED_BY_WORKFLOW = "workflow"++# Minimum gap between two workflow-triggered runs of the same (team, skill), enforced scout-side.+# The workflow layer has its own first line of defence (trigger masking), but that lives in+# customer-editable config, so this backstop deliberately does not trust it: an event trigger on a+# high-volume event would otherwise fire hundreds of times an hour. 30 minutes is the floor the+# system already applies to `run_interval_minutes` for the same worker-pool reason, and it bounds+# the workflow path at 48 runs/day/skill regardless of how the workflow is configured. Suppressed+# fires are dropped, not queued — there is deliberately no trailing-edge coalescing.+WORKFLOW_RUN_COOLDOWN_S = 30 * 60+# Per-team ceiling on ENABLED scout configs — the per-team cost cap. Each enabled scout# is a recurring LLM sandbox run, so this bounds what one team can switch on. Set high so# teams can freely author scouts with minimal friction; it's a backstop against runawaydiff --git a/products/signals/backend/scout_harness/run_gates.py b/products/signals/backend/scout_harness/run_gates.pynew file mode 100644index 000000000000..ea4ac2406fa2--- /dev/null+++ b/products/signals/backend/scout_harness/run_gates.py@@ -0,0 +1,183 @@+"""Pre-dispatch gates shared by every off-schedule scout run.++Two entry points start a scout outside its schedule: the `run` endpoint (`views.py`, a human+pressing "Run now") and a workflow's "Run scout" step (`workflow_runs.py`). Both must honour the+controls the scheduled coordinator already applies, or a trigger routes around a rollout+kill-switch and repeated triggers blow past the daily cap. They live here rather than in either+caller so the next entry point can't ship without them.++Each gate returns a `ScoutRunRejection` (or `None` to proceed) rather than raising, because the+callers speak different transports: DRF exceptions for the endpoint, HTTP status codes the workflow+step reads as a graceful skip for the service-to-service path.+"""++from __future__ import annotations++from datetime import timedelta+from enum import Enum++from django.utils import timezone++from posthog.dataclasses import frozen+from posthog.models import Team++from products.signals.backend.daily_limit import daily_report_limit_gate+from products.signals.backend.models import SignalScoutRun+from products.signals.backend.quota import is_team_signals_quota_limited+from products.signals.backend.scout_harness.limits import (+ STALE_RUN_CUTOFF_S,+ TRIGGERED_BY_WORKFLOW,+ WORKFLOW_RUN_COOLDOWN_S,+)+from products.signals.backend.scout_harness.team_limits import (+ DAILY_BUDGET_WINDOW,+ _canonicalize_team_config_keys,+ _default_team_config,+ _parse_enrollment,+ _read_flag_payload,+ _resolve_enrolled,+ _resolve_max_runs_per_day,+ _runs_today_by_team,+ _team_configs,+)+from products.tasks.backend.facade import api as tasks_facade++# Metadata key the runner stamps the trigger source under, read here for the workflow cooldown.+TRIGGERED_BY_METADATA_KEY = "triggered_by"+++class ScoutRunRejectionKind(Enum):+ """How a caller should surface the rejection. Mirrors the HTTP semantics both callers use."""++ NOT_FOUND = "not_found"+ FORBIDDEN = "forbidden"+ THROTTLED = "throttled"+ CONFLICT = "conflict"+++@frozen+class ScoutRunRejection:+ """Why a dispatch was refused. `reason` is the stable machine-readable slug (logs, metrics);+ `detail` is the message a caller surfaces."""++ kind: ScoutRunRejectionKind+ reason: str+ detail: str+++def check_fleet_gates(team_id: int) -> ScoutRunRejection | None:+ """The fleet-level controls the scheduled coordinator enforces, applied to an off-schedule run.++ Reads the `signals-scout` flag payload once, the same snapshot the coordinator plans off, for+ the enrollment kill switch (a project in `skip_team_ids`, or one not enrolled at all, never runs+ scheduled scouts, so a trigger must not either) and the rolling-24h `max_runs_per_day` budget,+ whose tally off-schedule runs share because they land the same `SignalScoutRun` rows.++ `team_id` is the canonical (parent) project id, matching how the coordinator plans; team config+ keys are canonicalized the same way so a child-env override still lines up.+ """+ payload = _read_flag_payload()+ if not _resolve_enrolled(team_id, _parse_enrollment(payload)):+ return ScoutRunRejection(+ kind=ScoutRunRejectionKind.FORBIDDEN,+ reason="not_enrolled",+ detail="Signals scouts are not enabled for this project.",+ )++ team_configs = _canonicalize_team_config_keys(_team_configs(payload))+ per_day = _resolve_max_runs_per_day(team_id, team_configs, _default_team_config(payload))+ if per_day is not None:+ runs_today = _runs_today_by_team({team_id}, timezone.now() - DAILY_BUDGET_WINDOW).get(team_id, 0)+ if runs_today >= per_day:+ return ScoutRunRejection(+ kind=ScoutRunRejectionKind.THROTTLED,+ reason="daily_run_budget",+ detail="This project has reached its daily scout run budget. Try again later.",+ )+ return None+++def check_spend_gates(team: Team) -> ScoutRunRejection | None:+ """Fail fast on the two spend gates `run_signals_scout_activity` re-checks authoritatively, so+ a caller gets a clean throttle instead of a 202 whose run only skips."""+ if is_team_signals_quota_limited(team.api_token):+ return ScoutRunRejection(+ kind=ScoutRunRejectionKind.THROTTLED,+ reason="quota_limited",+ detail="This project is over its Signals credits quota. Try again later.",+ )+ if daily_report_limit_gate(team).limited:+ return ScoutRunRejection(+ kind=ScoutRunRejectionKind.THROTTLED,+ reason="daily_report_limit",+ detail="This project reached its daily report limit. Try again tomorrow.",+ )+ return None+++def check_run_in_flight(team_id: int, skill_name: str) -> ScoutRunRejection | None:+ """Reject when a *live* run for this `(canonical team, skill)` is already QUEUED or IN_PROGRESS.++ Mirrors the runner's authoritative single-flight (`runner._has_running_run`) so a trigger fails+ fast instead of dispatching a workflow the runner would only skip. Status flows from the linked+ `TaskRun`; covers a run started by any path — coordinator, manual, or workflow.++ A run older than `STALE_RUN_CUTOFF_S` is an orphan left by a crashed worker and deliberately+ does NOT count as in-flight. Otherwise this gate short-circuits before the dispatched run's+ `_self_heal_stale_runs` reap can clear it, wedging the lane until a scheduled tick happens to+ reap it — which never comes for a disabled scout, whose only run path is a trigger.+ """+ live_cutoff = timezone.now() - timedelta(seconds=STALE_RUN_CUTOFF_S)+ in_flight = (+ SignalScoutRun.objects.for_team(team_id)+ .filter(+ skill_name=skill_name,+ # Floors the range scan on signal_scout_run_recent_idx (team, skill_name, -created_at)+ # instead of the scout's whole unpruned history. Same result set as the task_run floor+ # below, since the scout row is written only after its TaskRun exists.+ created_at__gte=live_cutoff,+ task_run__status__in=(tasks_facade.TaskRunStatus.QUEUED, tasks_facade.TaskRunStatus.IN_PROGRESS),+ task_run__created_at__gte=live_cutoff,+ )+ .exists()+ )+ if not in_flight:+ return None+ return ScoutRunRejection(+ kind=ScoutRunRejectionKind.CONFLICT,+ reason="run_in_flight",+ detail="A run for this scout is already in progress.",+ )+++def check_workflow_cooldown(team_id: int, skill_name: str) -> ScoutRunRejection | None:+ """Reject a workflow-triggered fire inside `WORKFLOW_RUN_COOLDOWN_S` of the previous one.++ Counts only prior *workflow* fires: letting a scheduled patrol or a human's "Run now" extend+ the cooldown would make this path's behaviour depend on unrelated activity. Measured from run+ start, since that is what `created_at` records.++ The `created_at` floor is what keeps this cheap — `signal_scout_run_recent_idx` range-scans just+ the cooldown window, so the un-indexed `metadata` predicate only sees the rows inside it.++ A dispatch that has not yet written its run row is invisible to both this and the in-flight+ gate. Within this path Temporal's id-conflict policy closes that gap; across paths it stays+ open, the same pre-existing race the scheduled and manual paths already have with each other.+ """+ cutoff = timezone.now() - timedelta(seconds=WORKFLOW_RUN_COOLDOWN_S)+ recent = (+ SignalScoutRun.objects.for_team(team_id)+ .filter(+ skill_name=skill_name,+ created_at__gte=cutoff,+ **{f"metadata__{TRIGGERED_BY_METADATA_KEY}": TRIGGERED_BY_WORKFLOW},+ )+ .exists()+ )+ if not recent:+ return None+ return ScoutRunRejection(+ kind=ScoutRunRejectionKind.THROTTLED,+ reason="workflow_cooldown",+ detail=(f"This scout was already run from a workflow in the last {WORKFLOW_RUN_COOLDOWN_S // 60} minutes."),+ )diff --git a/products/signals/backend/scout_harness/runner.py b/products/signals/backend/scout_harness/runner.pyindex b886f8968998..aba70a61ca4f 100644--- a/products/signals/backend/scout_harness/runner.py+++ b/products/signals/backend/scout_harness/runner.py@@ -34,6 +34,7 @@ from products.signals.backend.scout_harness.limits import (FAILURE_STREAK_MAX_RUNS,FAILURE_STREAK_MIN_SPAN_MINUTES,STALE_RUN_CUTOFF_S,+ TRIGGERED_BY_SCHEDULE,failure_streak_pause_threshold,interval_runs_in_tolerance_window,)@@ -137,7 +138,7 @@ def run_signals_scout(skill_version: int | None = None,repository: str | None = None,verbose: bool = False,- triggered_by: str = "schedule",+ triggered_by: str = TRIGGERED_BY_SCHEDULE,) -> RunResult:"""Synchronous entrypoint: resolves config, spawns sandbox, persists the run row.@@ -163,13 +164,15 @@ async def arun_signals_scout(skill_version: int | None = None,repository: str | None = None,verbose: bool = False,- triggered_by: str = "schedule",+ triggered_by: str = TRIGGERED_BY_SCHEDULE,) -> RunResult:"""Async core. Safe to call from inside a running event loop (Temporal activity).- `triggered_by` is `"schedule"` for coordinator-dispatched runs (including breaker probes)- and `"manual"` for on-demand triggers (the `run` endpoint, the management command). Only- scheduled failures feed the failure-streak breaker; see the failure path below.+ `triggered_by` is `"schedule"` for coordinator-dispatched runs (including breaker probes),+ `"manual"` for on-demand triggers (the `run` endpoint, the management command) and+ `"workflow"` for a workflow step that runs a scout. Only scheduled failures feed the+ failure-streak breaker; see the failure path below. Anything but `"schedule"` is also stamped+ onto the run row's `metadata`, which is what the workflow path's cooldown reads."""team = await database_sync_to_async(_get_team, thread_sensitive=False)(team_id)@@ -361,6 +364,7 @@ async def arun_signals_scout(model=model,runtime_adapter=runtime_adapter,reasoning_effort=reasoning_effort,+ triggered_by=triggered_by,)runtime_s = time.monotonic() - startedemitted_count, _ = await database_sync_to_async(_read_run_metrics, thread_sensitive=False)(@@ -383,6 +387,7 @@ async def arun_signals_scout(status=tasks_facade.TaskRunStatus.COMPLETED.value,runtime_s=runtime_s,emitted_count=emitted_count,+ triggered_by=triggered_by,model=model,runtime_adapter=runtime_adapter,)@@ -431,7 +436,7 @@ async def arun_signals_scout(# on a lane whose schedule never failed.streak = (await database_sync_to_async(_record_failure_streak, thread_sensitive=False)(config.pk)- if triggered_by == "schedule"+ if triggered_by == TRIGGERED_BY_SCHEDULEelse None)_capture_run_finished(@@ -445,6 +450,7 @@ async def arun_signals_scout(status=tasks_facade.TaskRunStatus.FAILED.value,runtime_s=runtime_s,emitted_count=emitted_count,+ triggered_by=triggered_by,model=model,runtime_adapter=runtime_adapter,error_type=type(exc).__name__,@@ -505,6 +511,7 @@ async def arun_signals_scout(status=tasks_facade.TaskRunStatus.CANCELLED.value,runtime_s=runtime_s,emitted_count=None,+ triggered_by=triggered_by,model=model,runtime_adapter=runtime_adapter,)@@ -584,6 +591,7 @@ async def _spawn_and_run(model: str | None,runtime_adapter: str | None = None,reasoning_effort: str | None = None,+ triggered_by: str = TRIGGERED_BY_SCHEDULE,) -> tuple[str, str]:"""Spawn the sandbox, create the bridge row before the first turn, run the agent.@@ -705,6 +713,7 @@ async def _spawn_and_run(reasoning_effort=reasoning_effort,github_guidance=github_guidance,business_knowledge_maintained=business_knowledge_maintained,+ triggered_by=triggered_by,)# Lifecycle start marker. The row + TaskRun now exist and the run has cleared the# reap + single-flight guards, so this counts exactly the runs that actually start —@@ -719,6 +728,7 @@ async def _spawn_and_run(business_knowledge_maintained=business_knowledge_maintained,run_id=run_id,task_run_id=str(task_run.id),+ triggered_by=triggered_by,model=model,runtime_adapter=runtime_adapter,)@@ -902,6 +912,7 @@ def _create_run_row(reasoning_effort: str | None = None,github_guidance: bool = False,business_knowledge_maintained: bool = False,+ triggered_by: str = TRIGGERED_BY_SCHEDULE,) -> SignalScoutRun:# Stamp the routed model triple onto the row's `metadata` so "which model ran this?" is a# column read on the run API, not an analytics-event join. Keys are omitted (not null-valued)@@ -949,6 +960,12 @@ def _create_run_row(# section: records land solely as project events, so a dry-run scout has no channel.if config.structured_output_schema and config.emit:metadata["structured_output_schema"] = config.structured_output_schema+ # Omitted on the default path like the model triple, so absence reads as "the schedule".+ # Load-bearing for the workflow path specifically: its 30-minute cooldown counts prior+ # *workflow*-triggered runs of this (team, skill), and this is the only record of which those+ # were — a scheduled patrol or a human's "Run now" must not extend it.+ if triggered_by != TRIGGERED_BY_SCHEDULE:+ metadata["triggered_by"] = triggered_byreturn SignalScoutRun.objects.unscoped().create(id=run_id,task_run=task_run,@@ -1143,6 +1160,7 @@ def _capture_run_started(business_knowledge_maintained: bool,run_id: Any,task_run_id: str,+ triggered_by: str,model: str | None = None,runtime_adapter: str | None = None,) -> None:@@ -1170,6 +1188,7 @@ def _capture_run_started(business_knowledge_maintained=business_knowledge_maintained,model=model,runtime_adapter=runtime_adapter,+ triggered_by=triggered_by,)try:posthoganalytics.capture(@@ -1277,6 +1296,7 @@ def _attach_run_shape_props(business_knowledge_maintained: bool,model: str | None,runtime_adapter: str | None,+ triggered_by: str,) -> None:"""Attach the dimensions that describe what this run was configured with, to both lifecycleevents from one place so the started and finished streams can never drift apart.@@ -1287,8 +1307,11 @@ def _attach_run_shape_props(`scouts-model-selection` gate (or a runtime pin) routed the run, so their absence means theagent-server default served it. `network_access` follows the same absent-means-defaultconvention (attached only for `full`), so an event-based readout never pools runs with- different egress capabilities under one model or prompt. All of these make run outcomes- (timeout rate, runtime, emit volume) sliceable without joining through $ai_generation.+ different egress capabilities under one model or prompt. `triggered_by` follows the run row's+ own absent-means-schedule convention (`_create_run_row`), so the started/finished streams can+ separate workflow-triggered volume, failure, and latency from scheduled and manual traffic+ without a database join. All of these make run outcomes (timeout rate, runtime, emit volume)+ sliceable without joining through $ai_generation."""properties["harness_prompt_version"] = HARNESS_PROMPT_VERSIONproperties["report_channel"] = resolve_report_channel_variant(skill.allowed_tools)@@ -1301,6 +1324,8 @@ def _attach_run_shape_props(properties["model"] = modelif runtime_adapter is not None:properties["runtime_adapter"] = runtime_adapter+ if triggered_by != TRIGGERED_BY_SCHEDULE:+ properties["triggered_by"] = triggered_bydef _capture_run_finished(@@ -1315,6 +1340,7 @@ def _capture_run_finished(status: str,runtime_s: float,emitted_count: int | None,+ triggered_by: str,model: str | None = None,runtime_adapter: str | None = None,error_type: str | None = None,@@ -1356,6 +1382,7 @@ def _capture_run_finished(business_knowledge_maintained=business_knowledge_maintained,model=model,runtime_adapter=runtime_adapter,+ triggered_by=triggered_by,)# Only attach failure context on failed runs — keeps successful / cancelled events clean# rather than carrying explicit-null error fields on every event.diff --git a/products/signals/backend/scout_harness/serializers.py b/products/signals/backend/scout_harness/serializers.pyindex c4c8fa544f2e..b3d39b449683 100644--- a/products/signals/backend/scout_harness/serializers.py+++ b/products/signals/backend/scout_harness/serializers.py@@ -93,6 +93,7 @@ logger = structlog.get_logger(__name__)"runtime_adapter": {"type": "string"},"reasoning_effort": {"type": "string"},"network_access": {"type": "string"},+ "triggered_by": {"type": "string"},# Closed and fully required, unlike the parent: the region is written whole or not at# all, so every flag is present whenever the object is. Leaving it open would generate# a `[key: string]: boolean` index signature that the optional named flags cannot@@ -244,9 +245,10 @@ class SignalScoutRunSummarySerializer(serializers.Serializer):"looks maintained) — the provenance set that says which instructions the run ""actually got, so runs are only compared against runs of the same shape. Present only ""when the run departed from a default: `model`, `runtime_adapter`, and "- "`reasoning_effort` (routing overrode the agent-server default), and `network_access` "+ "`reasoning_effort` (routing overrode the agent-server default), `network_access` ""(`full` when the scout's config lifted the trusted-domain network restriction for "- "this run). The nested `derived` object is the harness's "+ "this run), and `triggered_by` (`manual` or `workflow` when the run was fired off-schedule; "+ "absent means the run came from the coordinator's schedule). The nested `derived` object is the harness's ""own map of boolean run dimensions, computed server-side at finalize: `has_emit_report`, ""`has_edit_report`, `has_self_improvement`, `has_chart`, and `has_self_validation`. Use ""`derived` to answer 'what kind of run was this?' instead of parsing the `summary` prose. "diff --git a/products/signals/backend/scout_harness/views.py b/products/signals/backend/scout_harness/views.pyindex 82dff448d6f9..6bb2927264df 100644--- a/products/signals/backend/scout_harness/views.py+++ b/products/signals/backend/scout_harness/views.py@@ -22,11 +22,9 @@ from __future__ import annotationsimport uuidimport dataclassesfrom dataclasses import dataclass-from datetime import timedeltafrom typing import Any, castfrom django.db import transaction-from django.utils import timezoneimport structlogfrom drf_spectacular.types import OpenApiTypes@@ -54,7 +52,6 @@ from posthog.permissions import AccessControlPermission, APIScopePermission, getfrom posthog.temporal.common.client import sync_connectfrom products.access_control.backend.facade.user_access_control import UserAccessControl-from products.signals.backend.daily_limit import daily_report_limit_gatefrom products.signals.backend.models import (SignalProjectProfile,SignalReport,@@ -64,13 +61,19 @@ from products.signals.backend.models import (SignalScoutRun,)from products.signals.backend.pipeline_identity import pipeline_writer_identity-from products.signals.backend.quota import is_team_signals_quota_limitedfrom products.signals.backend.report_charts import ChartSizefrom products.signals.backend.report_generation.resolve_reviewers import MAX_PROJECT_MEMBERS, list_project_membersfrom products.signals.backend.scout_harness.config_registry import enabled_scout_count, ensure_scout_categoryfrom products.signals.backend.scout_harness.fleet_sync import materialize_scout_fleetfrom products.signals.backend.scout_harness.lazy_seed import scout_skill_origin-from products.signals.backend.scout_harness.limits import MAX_ENABLED_SCOUTS_PER_TEAM, STALE_RUN_CUTOFF_S+from products.signals.backend.scout_harness.limits import MAX_ENABLED_SCOUTS_PER_TEAM+from products.signals.backend.scout_harness.run_gates import (+ ScoutRunRejection,+ ScoutRunRejectionKind,+ check_fleet_gates,+ check_run_in_flight,+ check_spend_gates,+)from products.signals.backend.scout_harness.serializers import (EditReportRequestSerializer,EditReportResponseSerializer,@@ -118,19 +121,7 @@ from products.signals.backend.scout_harness.skill_loader import (SkillNotFoundError,load_skill_for_run,)-from products.signals.backend.scout_harness.team_limits import (- DAILY_BUDGET_WINDOW,- _canonicalize_team_config_keys,- _default_team_config,- _parse_enrollment,- _read_flag_payload,- _resolve_enrolled,- _resolve_max_runs_per_day,- _runs_today_by_team,- _team_configs,- resolve_team_metadata,- withheld_skills_for_team,-)+from products.signals.backend.scout_harness.team_limits import resolve_team_metadata, withheld_skills_for_teamfrom products.signals.backend.scout_harness.tools.emit import EvidenceEntry, InvalidEmitError, emit_finding_syncfrom products.signals.backend.scout_harness.tools.notes import (DEFAULT_NOTES_LIST_LIMIT,@@ -281,63 +272,25 @@ class Conflict(exceptions.APIException):default_code = "conflict"-def _scout_run_in_flight(team_id: int, skill_name: str) -> bool:- """Whether a *live* run for this `(canonical team, skill)` is already QUEUED or IN_PROGRESS.-- Mirrors the runner's authoritative single-flight (`scout_harness/runner._has_running_run`)- so the manual-trigger endpoint can fail fast with a 409 instead of dispatching a workflow- that the runner would only skip. Status flows from the linked `TaskRun`; covers a run- started by either the coordinator or a prior manual trigger.-- A run older than `STALE_RUN_CUTOFF_S` is an orphan left by a crashed worker (Temporal kills- the activity at the hard ceiling, so it cannot still be executing) — it is deliberately NOT- counted as in-flight here. Otherwise this fail-fast 409 would short-circuit before the- workflow's runner reaches its `_self_heal_stale_runs` reap, wedging the lane until a- scheduled tick happens to reap it — which never comes for a disabled scout, whose only run- path is this endpoint. Treating the orphan as free lets the dispatched run reap it and proceed.- """- live_cutoff = timezone.now() - timedelta(seconds=STALE_RUN_CUTOFF_S)- return (- SignalScoutRun.objects.unscoped()- .filter(- team_id=team_id,- skill_name=skill_name,- task_run__status__in=(tasks_facade.TaskRunStatus.QUEUED, tasks_facade.TaskRunStatus.IN_PROGRESS),- task_run__created_at__gte=live_cutoff,- )- .exists()- )+def _raise_rejection(rejection: ScoutRunRejection) -> None:+ """Surface a shared pre-dispatch gate rejection as this endpoint's DRF exception."""+ if rejection.kind is ScoutRunRejectionKind.FORBIDDEN:+ raise exceptions.PermissionDenied(detail=rejection.detail)+ if rejection.kind is ScoutRunRejectionKind.CONFLICT:+ raise Conflict(detail=rejection.detail)+ raise exceptions.Throttled(detail=rejection.detail)def _reject_if_manual_run_suppressed(team_id: int) -> None:"""Apply the fleet-level gates the scheduled coordinator enforces, so a manual trigger can't- run a scout the scheduled path would deliberately suppress.-- Reads the `signals-scout` flag payload once (the same snapshot the coordinator plans off):-- - **Enrollment kill switch.** A project in `skip_team_ids`, or one not enrolled at all, never- runs scheduled scouts — so its manual trigger is forbidden too (403). Without this, any- caller with `signal_scout:write` could run a scout on a project an operator has explicitly- drained or held back via the flag.- - **Daily run budget.** `max_runs_per_day` (per-team override → fleet default → code constant)- bounds dispatches per rolling 24h. Manual runs land the same `SignalScoutRun` rows the- coordinator counts, so they share the tally: once the budget is spent the trigger is- throttled (429) until the window rolls, instead of letting repeated manual runs blow past- the per-team daily cap the scheduled path enforces.-- `team_id` is the canonical (parent) project id, matching how the coordinator plans; team- config keys are canonicalized the same way so a child-env override still lines up.+ run a scout the scheduled path would deliberately suppress: the enrollment kill switch (403)+ and the per-team daily run budget (429). The checks themselves live in `run_gates` because the+ workflow-triggered path has to apply exactly the same ones; this only maps the outcome onto+ DRF. `team_id` is the canonical (parent) project id, matching how the coordinator plans."""- payload = _read_flag_payload()- if not _resolve_enrolled(team_id, _parse_enrollment(payload)):- raise exceptions.PermissionDenied(detail="Signals scouts are not enabled for this project.")-- team_configs = _canonicalize_team_config_keys(_team_configs(payload))- per_day = _resolve_max_runs_per_day(team_id, team_configs, _default_team_config(payload))- if per_day is not None:- runs_today = _runs_today_by_team({team_id}, timezone.now() - DAILY_BUDGET_WINDOW).get(team_id, 0)- if runs_today >= per_day:- raise exceptions.Throttled(detail="This project has reached its daily scout run budget. Try again later.")+ rejection = check_fleet_gates(team_id)+ if rejection is not None:+ _raise_rejection(rejection)def _parse_run_id_or_404(kwargs: dict) -> uuid.UUID:@@ -861,7 +814,6 @@ class SignalScoutRunViewSet(TeamAndOrgViewSetMixin, viewsets.GenericViewSet):)def emit_signal(self, request: Request, **kwargs) -> Response:run_id = _parse_run_id_or_404(kwargs)- from products.tasks.backend.facade import api as tasks_facaderun = (SignalScoutRun.objects.select_related("scout_config", "task_run")@@ -933,7 +885,6 @@ class SignalScoutRunViewSet(TeamAndOrgViewSetMixin, viewsets.GenericViewSet):check is the matching fail-closed gate on the write itself: reject unless the run's skill lists`required_tool` in its `allowed_tools`, so the two enforcement layers can't drift."""run_id = _parse_run_id_or_404(kwargs)- from products.tasks.backend.facade import api as tasks_facaderun = (SignalScoutRun.objects.select_related("scout_config", "task_run", "team")@@ -1144,7 +1095,6 @@ class SignalScoutRunViewSet(TeamAndOrgViewSetMixin, viewsets.GenericViewSet):)def record_output(self, request: Request, **kwargs) -> Response:run_id = _parse_run_id_or_404(kwargs)- from products.tasks.backend.facade import api as tasks_facaderun = (SignalScoutRun.objects.select_related("scout_config", "task_run", "team")@@ -2316,14 +2266,11 @@ class SignalScoutConfigViewSet(TeamAndOrgViewSetMixin, viewsets.GenericViewSet):# re-checked authoritatively downstream (quota and daily report limit in the run activity,# single-flight in the runner and at the Temporal server), but rejecting here avoids# dispatching a workflow that would only be skipped, and turns the common cases into clean- # 429/409 responses.+ # 429/409 responses. Shared with the workflow-triggered path (see `run_gates`).team = Team.objects.get(pk=team_id)- if is_team_signals_quota_limited(team.api_token):- raise exceptions.Throttled(detail="This project is over its Signals credits quota. Try again later.")- if daily_report_limit_gate(team).limited:- raise exceptions.Throttled(detail="This project reached its daily report limit. Try again tomorrow.")- if _scout_run_in_flight(team_id, skill_name):- raise Conflict()+ for rejection in (check_spend_gates(team), check_run_in_flight(team_id, skill_name)):+ if rejection is not None:+ _raise_rejection(rejection)# Deferred: keeps the heavy Signals Temporal workflow/activity graph (dragged in by the# `products.signals.backend.temporal` package aggregator) off the route-load path — this viewsetdiff --git a/products/signals/backend/scout_harness/workflow_runs.py b/products/signals/backend/scout_harness/workflow_runs.pynew file mode 100644index 000000000000..aa5f3c6e58e3--- /dev/null+++ b/products/signals/backend/scout_harness/workflow_runs.py@@ -0,0 +1,144 @@+"""Dispatch a scout run from a workflow's "Run scout" step.++The third way a scout run starts, after the coordinator's schedule and the manual `run` endpoint.+`products/workflows/backend/api/workflow_scout_runs.py` has already proved *which* workflow is+firing; this module decides whether that fire may spend a run, and dispatches it if so.++Two deliberate properties. A trigger is additive to the schedule: it never stamps `last_run_at`, so+fires can't mark a cron slot fulfilled or starve an interval scout's patrol. And it is not a health+signal: its failures don't feed the failure-streak breaker, whose threshold is sized on the+schedule's cadence. The run is a pure kick — no content from the triggering event reaches it, so+the prompt is identical to a scheduled run's.+"""++from __future__ import annotations++import structlog+from temporalio.exceptions import WorkflowAlreadyStartedError++from posthog.dataclasses import frozen+from posthog.models import Team+from posthog.temporal.common.client import sync_connect++from products.signals.backend.models import SignalScoutConfig+from products.signals.backend.scout_harness.run_gates import (+ ScoutRunRejection,+ ScoutRunRejectionKind,+ check_fleet_gates,+ check_run_in_flight,+ check_spend_gates,+ check_workflow_cooldown,+)+from products.signals.backend.scout_harness.team_limits import withheld_skills_for_team+from products.skills.backend.models.skills import LLMSkill++logger = structlog.get_logger(__name__)+++class WorkflowScoutRunRejected(Exception):+ """A fire that will not become a run. Carries the shared `ScoutRunRejection` so the HTTP layer+ maps it to a status code without re-deriving why."""++ def __init__(self, rejection: ScoutRunRejection) -> None:+ super().__init__(rejection.detail)+ self.rejection = rejection+++@frozen+class WorkflowScoutRunStarted:+ skill_name: str+ workflow_id: str+++def _rejected(kind: ScoutRunRejectionKind, reason: str, detail: str) -> WorkflowScoutRunRejected:+ return WorkflowScoutRunRejected(ScoutRunRejection(kind=kind, reason=reason, detail=detail))+++def start_workflow_scout_run(*, team_id: int, skill_name: str) -> WorkflowScoutRunStarted:+ """Start one workflow-triggered run of `skill_name`, or raise `WorkflowScoutRunRejected`.++ `team_id` has to be the project's main environment: scout rows live under it, and there is no+ human credential here to re-authorize a child environment against it.++ Rejection kinds are chosen so the step reads them correctly. `NOT_FOUND` means the node names a+ scout that cannot run (a typo, a deleted skill) and surfaces as a step failure the author+ notices; `CONFLICT` / `THROTTLED` are ordinary backpressure the step skips on.+ """+ team = Team.objects.get(pk=team_id)+ if team.parent_team_id:+ raise _rejected(+ ScoutRunRejectionKind.FORBIDDEN,+ "child_environment",+ "Running a scout from a workflow is only available in the project's main environment.",+ )++ config = SignalScoutConfig.objects.for_team(team_id).filter(skill_name=skill_name).first()+ if config is None:+ raise _rejected(+ ScoutRunRejectionKind.NOT_FOUND,+ "scout_not_found",+ f"No scout named '{skill_name}' exists in this project.",+ )++ # A withheld scout is invisible across the whole config API, so the node names something this+ # project cannot run — "not found" rather than a skip.+ if skill_name in withheld_skills_for_team(team_id):+ raise _rejected(+ ScoutRunRejectionKind.NOT_FOUND,+ "scout_withheld",+ f"No scout named '{skill_name}' exists in this project.",+ )++ # A config can outlive its skill. Dispatching for one hands back a workflow id whose run dies+ # in `load_skill_for_run` before any run row exists, so the step would look successful while+ # nothing ever happens.+ if not LLMSkill.objects.filter(team_id=team_id, name=skill_name, is_latest=True, deleted=False).exists():+ raise _rejected(+ ScoutRunRejectionKind.NOT_FOUND,+ "skill_missing",+ f"Scout '{skill_name}' no longer has a skill to run.",+ )++ # Stricter than the manual endpoint, which lets a human run a disabled scout as a test act:+ # pausing has to stop automation, or a pause keeps spending while a workflow points at it.+ if config.status not in SignalScoutConfig.RUNNABLE_STATUSES:+ raise _rejected(+ ScoutRunRejectionKind.CONFLICT,+ "scout_not_runnable",+ f"Scout '{skill_name}' is {config.status} and does not accept workflow triggers.",+ )++ # Deferred: keeps the Signals Temporal workflow/activity graph off this module's import path,+ # which the workflows API imports just to reach this function.+ from products.signals.backend.temporal.agentic.scout_scheduler import ( # noqa: PLC0415+ start_workflow_signals_scout_run,+ workflow_triggered_run_workflow_id,+ )++ for rejection in (+ check_fleet_gates(team_id),+ check_spend_gates(team),+ # Ordered before the in-flight check so a burst of fires reports the cooldown (the thing the+ # author can actually act on) rather than whichever run happens to still be running.+ check_workflow_cooldown(team_id, skill_name),+ check_run_in_flight(team_id, skill_name),+ ):+ if rejection is not None:+ raise WorkflowScoutRunRejected(rejection)++ workflow_id = workflow_triggered_run_workflow_id(team_id, skill_name)+ try:+ start_workflow_signals_scout_run(sync_connect(), team_id=team_id, skill_name=skill_name)+ except WorkflowAlreadyStartedError:+ # A run was dispatched between the in-flight check and the start call. The endpoint's+ # idempotency cache is what replays a retry whose response was lost, so a collision+ # reaching here is a genuine one and skips.+ raise _rejected(ScoutRunRejectionKind.CONFLICT, "run_in_flight", "A run for this scout is already in progress.")++ logger.info(+ "signals_scout: workflow-triggered run dispatched",+ team_id=team_id,+ skill_name=skill_name,+ workflow_id=workflow_id,+ )+ return WorkflowScoutRunStarted(skill_name=skill_name, workflow_id=workflow_id)diff --git a/products/signals/backend/temporal/agentic/scout_scheduler.py b/products/signals/backend/temporal/agentic/scout_scheduler.pyindex f6ea0fbadb6a..aa656ba4da5c 100644--- a/products/signals/backend/temporal/agentic/scout_scheduler.py+++ b/products/signals/backend/temporal/agentic/scout_scheduler.py@@ -14,6 +14,7 @@ from asgiref.sync import async_to_syncfrom temporalio.client import Clientfrom temporalio.common import RetryPolicy, WorkflowIDConflictPolicy, WorkflowIDReusePolicy+from posthog.dataclasses import frozenfrom posthog.models import Teamfrom posthog.sync import database_sync_to_asyncfrom posthog.temporal.common.heartbeat import Heartbeater@@ -21,7 +22,12 @@ from posthog.temporal.common.utils import close_db_connectionsfrom products.signals.backend.daily_limit import capture_signal_report_daily_limit_paused, daily_report_limit_gatefrom products.signals.backend.quota import is_team_signals_quota_limited-from products.signals.backend.scout_harness.limits import WORKFLOW_HARD_CEILING_S+from products.signals.backend.scout_harness.limits import (+ TRIGGERED_BY_MANUAL,+ TRIGGERED_BY_SCHEDULE,+ TRIGGERED_BY_WORKFLOW,+ WORKFLOW_HARD_CEILING_S,+)from products.signals.backend.temporal import metricsif TYPE_CHECKING:@@ -32,16 +38,17 @@ if TYPE_CHECKING:logger = structlog.get_logger(__name__)-@dataclass+@frozenclass RunSignalsScoutInput:team_id: intskill_name: strskill_version: int | None = Nonerepository: str | None = None- # "schedule" (coordinator dispatch, including breaker probes) or "manual" (the `run`- # endpoint). Only scheduled failures feed the failure-streak breaker; the default keeps- # in-flight workflow histories decoding to today's behavior.- triggered_by: str = "schedule"+ # "schedule" (coordinator dispatch, including breaker probes), "manual" (the `run` endpoint)+ # or "workflow" (a workflow step that runs a scout). Only scheduled failures feed the+ # failure-streak breaker; the default keeps in-flight workflow histories decoding to today's+ # behavior. See `scout_harness/limits.py` for the vocabulary.+ triggered_by: str = TRIGGERED_BY_SCHEDULE@dataclass@@ -197,48 +204,82 @@ class RunSignalsScoutWorkflow:)-def manual_run_workflow_id(team_id: int, skill_name: str) -> str:- """Deterministic workflow id for an on-demand (`run now`) scout run.+def _off_schedule_run_workflow_id(namespace: str, team_id: int, skill_name: str) -> str:+ """Deterministic workflow id for an off-schedule scout run.- Distinct namespace from the coordinator's per-tick child ids (`signals-scout-run-…`)- so a manual run can't collide with a scheduled one. Stable per `(team, skill)` so the- id-conflict policy in `start_manual_signals_scout_run` can single-flight against it.+ One namespace per trigger source, all distinct from the coordinator's per-tick child ids+ (`signals-scout-run-…`), so each path single-flights independently at the Temporal server.+ Stable per `(team, skill)` so the id-conflict policy has something to single-flight against.- The readable skill fragment is truncated for legibility, but a digest of the *full*- skill name is appended so two custom scouts sharing the first 60 chars still map to- distinct ids — otherwise `WorkflowIDConflictPolicy.FAIL` would 409 one scout while the- other (truncation-twin) is running, even though it has no in-flight run of its own.+ The readable skill fragment is truncated, but a digest of the *full* skill name is appended so+ two custom scouts sharing the first 60 chars still map to distinct ids — otherwise+ `WorkflowIDConflictPolicy.FAIL` would 409 one scout while its truncation-twin is running."""safe_skill = skill_name.replace(" ", "_")[:60]digest = hashlib.sha256(skill_name.encode("utf-8"), usedforsecurity=False).hexdigest()[:12]- return f"signals-scout-manual-run-{team_id}-{safe_skill}-{digest}"+ return f"{namespace}-{team_id}-{safe_skill}-{digest}"+++def manual_run_workflow_id(team_id: int, skill_name: str) -> str:+ """Deterministic workflow id for an on-demand (`run now`) scout run."""+ return _off_schedule_run_workflow_id("signals-scout-manual-run", team_id, skill_name)+++def workflow_triggered_run_workflow_id(team_id: int, skill_name: str) -> str:+ """Deterministic workflow id for a run fired by a workflow step that runs a scout."""+ return _off_schedule_run_workflow_id("signals-scout-workflow-run", team_id, skill_name)@async_to_sync-async def start_manual_signals_scout_run(client: Client, *, team_id: int, skill_name: str) -> str:- """Dispatch one on-demand scout run on the signals task queue; return its workflow id.-- Reuses `RunSignalsScoutWorkflow`, so a manual run inherits every guard the scheduled- path has — the activity's Signals-credits quota check, and the runner's withheld-skill- denylist, stale-run self-heal, and single-flight. It does NOT honor the per-scout- schedule or `last_run_at`: a manual run is off-schedule and deliberately leaves the- cadence untouched — which is also why its failures don't feed the failure-streak- breaker (the threshold is sized on the schedule), while a manual success still clears- the streak and can resume a breaker-paused lane.-- Single-flight is enforced at the Temporal server, so the trigger can't be gamed into- stacking concurrent runs of the same scout: `ALLOW_DUPLICATE` lets the stable id be- reused once the prior manual run has closed, while `FAIL` rejects a second trigger- while one is still running — raising `WorkflowAlreadyStartedError` for the caller to- map to a 409.+async def _start_off_schedule_run(+ client: Client, *, workflow_id: str, team_id: int, skill_name: str, source: str+) -> str:+ """Start one `RunSignalsScoutWorkflow` off-schedule under `workflow_id`; return the id.++ Reusing the scheduled path's workflow means an off-schedule run inherits every guard it has —+ the activity's quota check, and the runner's withheld-skill denylist, stale-run self-heal, and+ single-flight — but not the per-scout schedule or `last_run_at`, which it deliberately leaves+ untouched. That is also why its failures don't feed the failure-streak breaker, whose threshold+ is sized on the schedule, while a success still clears the streak and can resume a paused lane.++ `ALLOW_DUPLICATE` lets the stable id be reused once the prior run under it has closed; `FAIL`+ rejects a second start while one is running, raising `WorkflowAlreadyStartedError` for the+ caller to map to a 409."""- workflow_id = manual_run_workflow_id(team_id, skill_name)await client.start_workflow(RunSignalsScoutWorkflow.run,- RunSignalsScoutInput(team_id=team_id, skill_name=skill_name, triggered_by="manual"),+ RunSignalsScoutInput(team_id=team_id, skill_name=skill_name, triggered_by=source),id=workflow_id,task_queue=settings.VIDEO_EXPORT_TASK_QUEUE,id_reuse_policy=WorkflowIDReusePolicy.ALLOW_DUPLICATE,id_conflict_policy=WorkflowIDConflictPolicy.FAIL,)return workflow_id+++def start_manual_signals_scout_run(client: Client, *, team_id: int, skill_name: str) -> str:+ """Dispatch one on-demand scout run on the signals task queue; return its workflow id."""+ return _start_off_schedule_run(+ client,+ workflow_id=manual_run_workflow_id(team_id, skill_name),+ team_id=team_id,+ skill_name=skill_name,+ source=TRIGGERED_BY_MANUAL,+ )+++def start_workflow_signals_scout_run(client: Client, *, team_id: int, skill_name: str) -> str:+ """Dispatch one workflow-triggered scout run on the signals task queue; return its workflow id.++ Its own id namespace, so a workflow fire and a human's "Run now" single-flight separately — a+ human testing a scout shouldn't 409 the automation, or vice versa. The overlap that matters+ (one live run per `(team, skill)`) is still caught by the runner's single-flight and the+ callers' in-flight pre-check, both source-agnostic.+ """+ return _start_off_schedule_run(+ client,+ workflow_id=workflow_triggered_run_workflow_id(team_id, skill_name),+ team_id=team_id,+ skill_name=skill_name,+ source=TRIGGERED_BY_WORKFLOW,+ )diff --git a/products/signals/backend/test/test_scout_harness_api.py b/products/signals/backend/test/test_scout_harness_api.pyindex 0febc4fe57d3..0e270bf4b728 100644--- a/products/signals/backend/test/test_scout_harness_api.py+++ b/products/signals/backend/test/test_scout_harness_api.py@@ -3147,12 +3147,14 @@ class TestScoutHarnessMetadataAPI(APIBaseTest):assert body["limits"]["runs_today"] == 1-_QUOTA = "products.signals.backend.scout_harness.views.is_team_signals_quota_limited"-_DAILY_GATE = "products.signals.backend.scout_harness.views.daily_report_limit_gate"+# The gates themselves live in `run_gates`, shared with the workflow-triggered run path, so+# that's where they're patched; the view only maps their outcome onto DRF exceptions.+_QUOTA = "products.signals.backend.scout_harness.run_gates.is_team_signals_quota_limited"+_DAILY_GATE = "products.signals.backend.scout_harness.run_gates.daily_report_limit_gate"+_FLAG = "products.signals.backend.scout_harness.run_gates._read_flag_payload"_START = "products.signals.backend.temporal.agentic.scout_scheduler.start_manual_signals_scout_run"_CONNECT = "products.signals.backend.scout_harness.views.sync_connect"_WITHHELD = "products.signals.backend.scout_harness.views.withheld_skills_for_team"-_FLAG = "products.signals.backend.scout_harness.views._read_flag_payload"class TestScoutHarnessConfigRunAPI(APIBaseTest):diff --git a/products/signals/backend/test/test_workflow_scout_runs.py b/products/signals/backend/test/test_workflow_scout_runs.pynew file mode 100644index 000000000000..bfc6e732f1ba--- /dev/null+++ b/products/signals/backend/test/test_workflow_scout_runs.py@@ -0,0 +1,173 @@+"""Dispatch semantics for workflow-triggered scout runs.++Covers the three things that make this path different from the manual `run` endpoint: the+30-minute workflow cooldown, the refusal to run a paused scout, and the `triggered_by="workflow"`+stamp that both of those read off. The endpoint that fires it is the workflows product's+`workflow_tasks`, tested next to it.+"""++from datetime import timedelta+from typing import Any++from posthog.test.base import APIBaseTest+from unittest.mock import patch++from django.utils import timezone++from temporalio.exceptions import WorkflowAlreadyStartedError++from posthog.models import Team++from products.signals.backend.models import SignalScoutConfig, SignalScoutRun+from products.signals.backend.scout_harness.limits import TRIGGERED_BY_WORKFLOW, WORKFLOW_RUN_COOLDOWN_S+from products.signals.backend.scout_harness.run_gates import ScoutRunRejectionKind+from products.signals.backend.scout_harness.workflow_runs import WorkflowScoutRunRejected, start_workflow_scout_run+from products.signals.backend.temporal.agentic.scout_scheduler import workflow_triggered_run_workflow_id+from products.skills.backend.models.skills import LLMSkill+from products.tasks.backend.models import Task, TaskRun++SKILL = "signals-scout-error-tracking"++_DISPATCH = "products.signals.backend.temporal.agentic.scout_scheduler.start_workflow_signals_scout_run"+_CONNECT = "products.signals.backend.scout_harness.workflow_runs.sync_connect"+_FLAG = "products.signals.backend.scout_harness.run_gates._read_flag_payload"+++class TestWorkflowScoutRunDispatch(APIBaseTest):+ """The Signals-side decision: may this fire spend a run, and what does it record?"""++ def setUp(self) -> None:+ super().setUp()+ # A workflow fire honours the same enrolment kill switch and daily budget the coordinator+ # does, so enrol this team by default and let the cases below exercise the gates they are+ # actually about. `test_rejects_an_unenrolled_project` overrides it.+ self._enrol({"guaranteed_team_ids": [self.team.id]})+ LLMSkill.objects.create(team=self.team, name=SKILL, is_latest=True, deleted=False)+ self.config = SignalScoutConfig.objects.create(+ team=self.team, skill_name=SKILL, status=SignalScoutConfig.Status.ACTIVE, enabled=True+ )+ # Stable per (team, skill): what the endpoint hands back, and what a retry collides with.+ self.workflow_id = workflow_triggered_run_workflow_id(self.team.id, SKILL)++ def _enrol(self, payload: dict) -> None:+ flag = patch(_FLAG, return_value=payload)+ flag.start()+ self.addCleanup(flag.stop)++ def _run(self) -> Any:+ with patch(_CONNECT), patch(_DISPATCH, return_value="wf-1") as dispatch:+ started = start_workflow_scout_run(team_id=self.team.id, skill_name=SKILL)+ self.last_dispatch = dispatch+ return started++ def _seed_run(self, *, triggered_by: str | None, age: timedelta = timedelta(minutes=1)) -> SignalScoutRun:+ """A finished scout run of the given trigger source, `age` in the past."""+ task = Task.objects.create(team=self.team, title="t", description="d")+ task_run = TaskRun.objects.create(task=task, team=self.team, status=TaskRun.Status.COMPLETED)+ run = SignalScoutRun.objects.create(+ task_run=task_run,+ team=self.team,+ scout_config=self.config,+ skill_name=SKILL,+ skill_version=1,+ metadata={"triggered_by": triggered_by} if triggered_by else {},+ )+ # `created_at` is auto_now_add, so the age has to be written back.+ SignalScoutRun.objects.filter(pk=run.pk).update(created_at=timezone.now() - age)+ return run++ def _assert_rejected(self, reason: str, kind: ScoutRunRejectionKind) -> None:+ with self.assertRaises(WorkflowScoutRunRejected) as caught:+ self._run()+ assert caught.exception.rejection.reason == reason+ assert caught.exception.rejection.kind is kind++ def test_dispatches_the_run_as_workflow_triggered(self) -> None:+ started = self._run()++ assert started.skill_name == SKILL+ assert started.workflow_id == self.workflow_id+ self.last_dispatch.assert_called_once()+ assert self.last_dispatch.call_args.kwargs["skill_name"] == SKILL++ def test_never_stamps_last_run_at(self) -> None:+ self._run()++ self.config.refresh_from_db()+ # A trigger is additive to the schedule: stamping would let fires starve the patrol.+ assert self.config.last_run_at is None++ def test_rejects_a_second_fire_inside_the_cooldown(self) -> None:+ self._seed_run(triggered_by=TRIGGERED_BY_WORKFLOW, age=timedelta(minutes=5))++ self._assert_rejected("workflow_cooldown", ScoutRunRejectionKind.THROTTLED)++ def test_allows_a_fire_once_the_cooldown_has_rolled(self) -> None:+ self._seed_run(triggered_by=TRIGGERED_BY_WORKFLOW, age=timedelta(seconds=WORKFLOW_RUN_COOLDOWN_S + 60))++ assert self._run().workflow_id == self.workflow_id++ def test_a_scheduled_or_manual_run_does_not_extend_the_workflow_cooldown(self) -> None:+ # The cooldown bounds the workflow path specifically, so unrelated activity must not+ # silently suppress it — otherwise a busy scout would never accept a trigger.+ self._seed_run(triggered_by=None, age=timedelta(minutes=5))+ self._seed_run(triggered_by="manual", age=timedelta(minutes=5))++ assert self._run().workflow_id == self.workflow_id++ def test_rejects_an_unenrolled_project(self) -> None:+ # `skip_team_ids` is the operator kill switch: the coordinator never schedules a skipped+ # team, so automation pointed at it must be refused too — otherwise a workflow would route+ # around a rollout an operator deliberately drained.+ self._enrol({"guaranteed_team_ids": [self.team.id], "skip_team_ids": [self.team.id]})++ self._assert_rejected("not_enrolled", ScoutRunRejectionKind.FORBIDDEN)++ def test_rejects_a_paused_scout(self) -> None:+ self.config.status = SignalScoutConfig.Status.PAUSED_BY_USER+ self.config.enabled = False+ self.config.save()++ self._assert_rejected("scout_not_runnable", ScoutRunRejectionKind.CONFLICT)++ def test_rejects_an_unknown_scout(self) -> None:+ with self.assertRaises(WorkflowScoutRunRejected) as caught:+ with patch(_CONNECT), patch(_DISPATCH):+ start_workflow_scout_run(team_id=self.team.id, skill_name="signals-scout-nope")+ assert caught.exception.rejection.kind is ScoutRunRejectionKind.NOT_FOUND++ def test_rejects_a_config_whose_skill_is_gone(self) -> None:+ LLMSkill.objects.filter(team=self.team, name=SKILL).update(deleted=True)++ self._assert_rejected("skill_missing", ScoutRunRejectionKind.NOT_FOUND)++ def test_rejects_while_a_run_is_in_flight(self) -> None:+ task = Task.objects.create(team=self.team, title="t", description="d")+ task_run = TaskRun.objects.create(task=task, team=self.team, status=TaskRun.Status.IN_PROGRESS)+ SignalScoutRun.objects.create(+ task_run=task_run, team=self.team, scout_config=self.config, skill_name=SKILL, skill_version=1+ )++ self._assert_rejected("run_in_flight", ScoutRunRejectionKind.CONFLICT)++ def test_skips_when_temporal_single_flights_the_start(self) -> None:+ # The pre-dispatch check can't see a run whose row isn't written yet, so the Temporal+ # id-conflict policy is the backstop and its collision reads as ordinary backpressure.+ with self.assertRaises(WorkflowScoutRunRejected) as caught:+ with patch(_CONNECT), patch(_DISPATCH, side_effect=WorkflowAlreadyStartedError("wf", "RunSignalsScout")):+ start_workflow_scout_run(team_id=self.team.id, skill_name=SKILL)++ assert caught.exception.rejection.reason == "run_in_flight"+ assert caught.exception.rejection.kind is ScoutRunRejectionKind.CONFLICT++ def test_refuses_a_child_environment(self) -> None:+ # No human credential is left at run time to authorize against the environment that owns+ # the scouts, so a child environment's workflow is refused rather than resolved upwards.+ env = Team.objects.create(organization=self.organization, parent_team=self.team, name="env")++ with self.assertRaises(WorkflowScoutRunRejected) as caught:+ with patch(_CONNECT), patch(_DISPATCH) as dispatch:+ start_workflow_scout_run(team_id=env.id, skill_name=SKILL)++ assert caught.exception.rejection.kind is ScoutRunRejectionKind.FORBIDDEN+ dispatch.assert_not_called()diff --git a/products/signals/frontend/components/ScoutPicker/CyclotronJobInputScoutPicker.tsx b/products/signals/frontend/components/ScoutPicker/CyclotronJobInputScoutPicker.tsxnew file mode 100644index 000000000000..b008ee1fd99f--- /dev/null+++ b/products/signals/frontend/components/ScoutPicker/CyclotronJobInputScoutPicker.tsx@@ -0,0 +1,38 @@+import { useValues } from 'kea'++import { LemonInputSelect, LemonInputSelectOption } from '@posthog/lemon-ui'++import type { CustomInputRendererProps } from 'lib/components/CyclotronJob/customInputRenderers'++import { prettifyScoutSkillName } from 'products/signals/frontend/inbox/utils/scoutRunsWindow'++import { scoutPickerLogic } from './scoutPickerLogic'++export default function CyclotronJobInputScoutPicker({ value, onChange }: CustomInputRendererProps): JSX.Element {+ const { scoutConfigs, scoutConfigsLoading } = useValues(scoutPickerLogic)++ const selected = typeof value === 'string' ? value : ''+ const options: LemonInputSelectOption[] = scoutConfigs.map((config) => ({+ key: config.skill_name,+ label: config.enabled+ ? prettifyScoutSkillName(config.skill_name)+ : `${prettifyScoutSkillName(config.skill_name)} (paused)`,+ }))+ // A stored skill name that isn't in this team's fleet (deleted since, or authored+ // elsewhere) still needs to render as itself, not as blank.+ if (selected && !options.some((option) => option.key === selected)) {+ options.push({ key: selected, label: selected })+ }++ return (+ <LemonInputSelect+ mode="single"+ data-attr="select-signals-scout"+ placeholder={scoutConfigsLoading ? 'Loading scouts...' : 'Select a scout...'}+ value={selected ? [selected] : []}+ onChange={(val) => onChange(val[0] ?? null)}+ options={options}+ loading={scoutConfigsLoading}+ />+ )+}diff --git a/products/signals/frontend/components/ScoutPicker/scoutPickerLogic.ts b/products/signals/frontend/components/ScoutPicker/scoutPickerLogic.tsnew file mode 100644index 000000000000..8c311e703778--- /dev/null+++ b/products/signals/frontend/components/ScoutPicker/scoutPickerLogic.ts@@ -0,0 +1,58 @@+import { MakeLogicType, afterMount, connect, kea, path } from 'kea'+import { loaders } from 'kea-loaders'++import { teamLogic } from 'scenes/teamLogic'++import { signalsScoutConfigList } from 'products/signals/frontend/generated/api'+import type { SignalScoutConfigApi } from 'products/signals/frontend/generated/api.schemas'++// Generated by kea-typegen. Update if you're an agent, ignore if you're human.+export interface scoutPickerLogicValues {+ currentTeamId: number | null // teamLogic+ scoutConfigs: SignalScoutConfigApi[]+ scoutConfigsLoading: boolean+}++// Generated by kea-typegen. Update if you're an agent, ignore if you're human.+export interface scoutPickerLogicActions {+ loadScoutConfigs: () => any+ loadScoutConfigsFailure: (+ error: string,+ errorObject?: any+ ) => {+ error: string+ errorObject?: any+ }+ loadScoutConfigsSuccess: (+ scoutConfigs: SignalScoutConfigApi[],+ payload?: any+ ) => {+ scoutConfigs: SignalScoutConfigApi[]+ payload?: any+ }+}++export type scoutPickerLogicType = MakeLogicType<scoutPickerLogicValues, scoutPickerLogicActions>++export const scoutPickerLogic = kea<scoutPickerLogicType>([+ path(['products', 'signals', 'frontend', 'components', 'ScoutPicker', 'scoutPickerLogic']),+ connect(() => ({+ values: [teamLogic, ['currentTeamId']],+ })),+ loaders(({ values }) => ({+ scoutConfigs: [+ [] as SignalScoutConfigApi[],+ {+ loadScoutConfigs: async (): Promise<SignalScoutConfigApi[]> => {+ if (!values.currentTeamId) {+ return []+ }+ return await signalsScoutConfigList(String(values.currentTeamId))+ },+ },+ ],+ })),+ afterMount(({ actions }) => {+ actions.loadScoutConfigs()+ }),+])diff --git a/products/signals/frontend/generated/api.schemas.ts b/products/signals/frontend/generated/api.schemas.tsindex e24b22fe7767..22c9d1febadf 100644--- a/products/signals/frontend/generated/api.schemas.ts+++ b/products/signals/frontend/generated/api.schemas.ts@@ -3132,7 +3132,7 @@ export type SignalScoutRunSummaryApiMetadataDerived = {}/**- * Scout-owned per-run context, in two regions. Top-level keys are stamped by the runner at run start. Always present: `harness_prompt_version` (id of the harness prompt build the run was given), `report_channel` (which report tools the run held: `none`, `emit`, `edit`, or `both`), `skill_origin` (`canonical` or `custom`), `github_guidance` (whether the run got the GitHub evidence section), and `business_knowledge_maintained` (whether the run got the business-knowledge section: the product flag is on and the team's knowledge base looks maintained) — the provenance set that says which instructions the run actually got, so runs are only compared against runs of the same shape. Present only when the run departed from a default: `model`, `runtime_adapter`, and `reasoning_effort` (routing overrode the agent-server default), and `network_access` (`full` when the scout's config lifted the trusted-domain network restriction for this run). The nested `derived` object is the harness's own map of boolean run dimensions, computed server-side at finalize: `has_emit_report`, `has_edit_report`, `has_self_improvement`, `has_chart`, and `has_self_validation`. Use `derived` to answer 'what kind of run was this?' instead of parsing the `summary` prose. Note the flags describe the reports the run authored as they stand now, so charts attached to someone else's report via an edit are not counted. A missing `derived` object is unknown, not all-false: the run predates the field, never finalized, or its stamp failed.+ * Scout-owned per-run context, in two regions. Top-level keys are stamped by the runner at run start. Always present: `harness_prompt_version` (id of the harness prompt build the run was given), `report_channel` (which report tools the run held: `none`, `emit`, `edit`, or `both`), `skill_origin` (`canonical` or `custom`), `github_guidance` (whether the run got the GitHub evidence section), and `business_knowledge_maintained` (whether the run got the business-knowledge section: the product flag is on and the team's knowledge base looks maintained) — the provenance set that says which instructions the run actually got, so runs are only compared against runs of the same shape. Present only when the run departed from a default: `model`, `runtime_adapter`, and `reasoning_effort` (routing overrode the agent-server default), `network_access` (`full` when the scout's config lifted the trusted-domain network restriction for this run), and `triggered_by` (`manual` or `workflow` when the run was fired off-schedule; absent means the run came from the coordinator's schedule). The nested `derived` object is the harness's own map of boolean run dimensions, computed server-side at finalize: `has_emit_report`, `has_edit_report`, `has_self_improvement`, `has_chart`, and `has_self_validation`. Use `derived` to answer 'what kind of run was this?' instead of parsing the `summary` prose. Note the flags describe the reports the run authored as they stand now, so charts attached to someone else's report via an edit are not counted. A missing `derived` object is unknown, not all-false: the run predates the field, never finalized, or its stamp failed.*/export type SignalScoutRunSummaryApiMetadata = {harness_prompt_version?: string@@ -3144,6 +3144,7 @@ export type SignalScoutRunSummaryApiMetadata = {runtime_adapter?: stringreasoning_effort?: stringnetwork_access?: string+ triggered_by?: stringderived?: SignalScoutRunSummaryApiMetadataDerived[key: string]: unknown}@@ -3232,7 +3233,7 @@ export interface SignalScoutRunSummaryApi {emitted_report_ids: string[]/** The `SignalReport` ids this run mutated via the `edit_report` channel (rewrote title/summary and/or appended a note), deduped. Distinct from `emitted_report_ids`: edit can target any inbox report, so these are generally not reports the run authored. Empty for runs that edited no report. */edited_report_ids: string[]- /** Scout-owned per-run context, in two regions. Top-level keys are stamped by the runner at run start. Always present: `harness_prompt_version` (id of the harness prompt build the run was given), `report_channel` (which report tools the run held: `none`, `emit`, `edit`, or `both`), `skill_origin` (`canonical` or `custom`), `github_guidance` (whether the run got the GitHub evidence section), and `business_knowledge_maintained` (whether the run got the business-knowledge section: the product flag is on and the team's knowledge base looks maintained) — the provenance set that says which instructions the run actually got, so runs are only compared against runs of the same shape. Present only when the run departed from a default: `model`, `runtime_adapter`, and `reasoning_effort` (routing overrode the agent-server default), and `network_access` (`full` when the scout's config lifted the trusted-domain network restriction for this run). The nested `derived` object is the harness's own map of boolean run dimensions, computed server-side at finalize: `has_emit_report`, `has_edit_report`, `has_self_improvement`, `has_chart`, and `has_self_validation`. Use `derived` to answer 'what kind of run was this?' instead of parsing the `summary` prose. Note the flags describe the reports the run authored as they stand now, so charts attached to someone else's report via an edit are not counted. A missing `derived` object is unknown, not all-false: the run predates the field, never finalized, or its stamp failed. */+ /** Scout-owned per-run context, in two regions. Top-level keys are stamped by the runner at run start. Always present: `harness_prompt_version` (id of the harness prompt build the run was given), `report_channel` (which report tools the run held: `none`, `emit`, `edit`, or `both`), `skill_origin` (`canonical` or `custom`), `github_guidance` (whether the run got the GitHub evidence section), and `business_knowledge_maintained` (whether the run got the business-knowledge section: the product flag is on and the team's knowledge base looks maintained) — the provenance set that says which instructions the run actually got, so runs are only compared against runs of the same shape. Present only when the run departed from a default: `model`, `runtime_adapter`, and `reasoning_effort` (routing overrode the agent-server default), `network_access` (`full` when the scout's config lifted the trusted-domain network restriction for this run), and `triggered_by` (`manual` or `workflow` when the run was fired off-schedule; absent means the run came from the coordinator's schedule). The nested `derived` object is the harness's own map of boolean run dimensions, computed server-side at finalize: `has_emit_report`, `has_edit_report`, `has_self_improvement`, `has_chart`, and `has_self_validation`. Use `derived` to answer 'what kind of run was this?' instead of parsing the `summary` prose. Note the flags describe the reports the run authored as they stand now, so charts attached to someone else's report via an edit are not counted. A missing `derived` object is unknown, not all-false: the run predates the field, never finalized, or its stamp failed. */metadata: SignalScoutRunSummaryApiMetadata}@@ -3246,7 +3247,7 @@ export type SignalScoutRunDetailApiMetadataDerived = {}/**- * Scout-owned per-run context, in two regions. Top-level keys are stamped by the runner at run start. Always present: `harness_prompt_version` (id of the harness prompt build the run was given), `report_channel` (which report tools the run held: `none`, `emit`, `edit`, or `both`), `skill_origin` (`canonical` or `custom`), `github_guidance` (whether the run got the GitHub evidence section), and `business_knowledge_maintained` (whether the run got the business-knowledge section: the product flag is on and the team's knowledge base looks maintained) — the provenance set that says which instructions the run actually got, so runs are only compared against runs of the same shape. Present only when the run departed from a default: `model`, `runtime_adapter`, and `reasoning_effort` (routing overrode the agent-server default), and `network_access` (`full` when the scout's config lifted the trusted-domain network restriction for this run). The nested `derived` object is the harness's own map of boolean run dimensions, computed server-side at finalize: `has_emit_report`, `has_edit_report`, `has_self_improvement`, `has_chart`, and `has_self_validation`. Use `derived` to answer 'what kind of run was this?' instead of parsing the `summary` prose. Note the flags describe the reports the run authored as they stand now, so charts attached to someone else's report via an edit are not counted. A missing `derived` object is unknown, not all-false: the run predates the field, never finalized, or its stamp failed.+ * Scout-owned per-run context, in two regions. Top-level keys are stamped by the runner at run start. Always present: `harness_prompt_version` (id of the harness prompt build the run was given), `report_channel` (which report tools the run held: `none`, `emit`, `edit`, or `both`), `skill_origin` (`canonical` or `custom`), `github_guidance` (whether the run got the GitHub evidence section), and `business_knowledge_maintained` (whether the run got the business-knowledge section: the product flag is on and the team's knowledge base looks maintained) — the provenance set that says which instructions the run actually got, so runs are only compared against runs of the same shape. Present only when the run departed from a default: `model`, `runtime_adapter`, and `reasoning_effort` (routing overrode the agent-server default), `network_access` (`full` when the scout's config lifted the trusted-domain network restriction for this run), and `triggered_by` (`manual` or `workflow` when the run was fired off-schedule; absent means the run came from the coordinator's schedule). The nested `derived` object is the harness's own map of boolean run dimensions, computed server-side at finalize: `has_emit_report`, `has_edit_report`, `has_self_improvement`, `has_chart`, and `has_self_validation`. Use `derived` to answer 'what kind of run was this?' instead of parsing the `summary` prose. Note the flags describe the reports the run authored as they stand now, so charts attached to someone else's report via an edit are not counted. A missing `derived` object is unknown, not all-false: the run predates the field, never finalized, or its stamp failed.*/export type SignalScoutRunDetailApiMetadata = {harness_prompt_version?: string@@ -3258,6 +3259,7 @@ export type SignalScoutRunDetailApiMetadata = {runtime_adapter?: stringreasoning_effort?: stringnetwork_access?: string+ triggered_by?: stringderived?: SignalScoutRunDetailApiMetadataDerived[key: string]: unknown}@@ -3327,7 +3329,7 @@ export interface SignalScoutRunDetailApi {emitted_report_ids: string[]/** The `SignalReport` ids this run mutated via the `edit_report` channel (rewrote title/summary and/or appended a note), deduped. Distinct from `emitted_report_ids`: edit can target any inbox report, so these are generally not reports the run authored. Empty for runs that edited no report. */edited_report_ids: string[]- /** Scout-owned per-run context, in two regions. Top-level keys are stamped by the runner at run start. Always present: `harness_prompt_version` (id of the harness prompt build the run was given), `report_channel` (which report tools the run held: `none`, `emit`, `edit`, or `both`), `skill_origin` (`canonical` or `custom`), `github_guidance` (whether the run got the GitHub evidence section), and `business_knowledge_maintained` (whether the run got the business-knowledge section: the product flag is on and the team's knowledge base looks maintained) — the provenance set that says which instructions the run actually got, so runs are only compared against runs of the same shape. Present only when the run departed from a default: `model`, `runtime_adapter`, and `reasoning_effort` (routing overrode the agent-server default), and `network_access` (`full` when the scout's config lifted the trusted-domain network restriction for this run). The nested `derived` object is the harness's own map of boolean run dimensions, computed server-side at finalize: `has_emit_report`, `has_edit_report`, `has_self_improvement`, `has_chart`, and `has_self_validation`. Use `derived` to answer 'what kind of run was this?' instead of parsing the `summary` prose. Note the flags describe the reports the run authored as they stand now, so charts attached to someone else's report via an edit are not counted. A missing `derived` object is unknown, not all-false: the run predates the field, never finalized, or its stamp failed. */+ /** Scout-owned per-run context, in two regions. Top-level keys are stamped by the runner at run start. Always present: `harness_prompt_version` (id of the harness prompt build the run was given), `report_channel` (which report tools the run held: `none`, `emit`, `edit`, or `both`), `skill_origin` (`canonical` or `custom`), `github_guidance` (whether the run got the GitHub evidence section), and `business_knowledge_maintained` (whether the run got the business-knowledge section: the product flag is on and the team's knowledge base looks maintained) — the provenance set that says which instructions the run actually got, so runs are only compared against runs of the same shape. Present only when the run departed from a default: `model`, `runtime_adapter`, and `reasoning_effort` (routing overrode the agent-server default), `network_access` (`full` when the scout's config lifted the trusted-domain network restriction for this run), and `triggered_by` (`manual` or `workflow` when the run was fired off-schedule; absent means the run came from the coordinator's schedule). The nested `derived` object is the harness's own map of boolean run dimensions, computed server-side at finalize: `has_emit_report`, `has_edit_report`, `has_self_improvement`, `has_chart`, and `has_self_validation`. Use `derived` to answer 'what kind of run was this?' instead of parsing the `summary` prose. Note the flags describe the reports the run authored as they stand now, so charts attached to someone else's report via an edit are not counted. A missing `derived` object is unknown, not all-false: the run predates the field, never finalized, or its stamp failed. */metadata: SignalScoutRunDetailApiMetadata}diff --git a/products/tasks/backend/tests/test_workflow_tasks_api.py b/products/tasks/backend/tests/test_workflow_tasks_api.pyindex 36e4118b245e..56f972a8f5bf 100644--- a/products/tasks/backend/tests/test_workflow_tasks_api.py+++ b/products/tasks/backend/tests/test_workflow_tasks_api.py@@ -225,6 +225,9 @@ class TestWorkflowTasksAPI(APIBaseTest):("no_header", "none"),("wrong_signing_key", "wrong_key"),("wrong_audience", "wrong_audience"),+ # Same signing key as the scout-run step, distinct audience: that token must not+ # spend a task creation, even though both mint from TASKS_CREATE_JWT_SECRETS.+ ("scout_run_audience", "scout_run_audience"),("expired", "expired"),("missing_workflow_claim", "no_flow_claim"),]@@ -235,6 +238,7 @@ class TestWorkflowTasksAPI(APIBaseTest):"none": None,"wrong_key": _token(self.team.id, flow_id, signing_key="not-the-secret"),"wrong_audience": _token(self.team.id, flow_id, audience=PosthogJwtAudience.RECORDING_API),+ "scout_run_audience": _token(self.team.id, flow_id, audience=PosthogJwtAudience.WORKFLOW_SCOUT_RUN),"expired": _token(self.team.id, flow_id, expiry=timedelta(minutes=-1)),"no_flow_claim": _token(self.team.id, None),}[kind]diff --git a/products/workflows/backend/api/hog_flow.py b/products/workflows/backend/api/hog_flow.pyindex f92af0a10881..f34064c3d35c 100644--- a/products/workflows/backend/api/hog_flow.py+++ b/products/workflows/backend/api/hog_flow.py@@ -557,6 +557,13 @@ _FIXED_TEMPLATE_IDS = {# generic input-shape validation every function step goes through._CREATE_TASK_TEMPLATE_ID = "template-posthog-create-task"+# The "Run scout" step. Scouts belong to the project's main environment, and the runtime dispatch+# in start_workflow_scout_run refuses a child environment's workflow with no human credential to+# re-authorize against it. That refusal is otherwise invisible until the step first runs: the+# build panel only hides the node, and the catalog still advertises it to a child-environment+# workflow built through the API or MCP.+_RUN_SCOUT_TEMPLATE_ID = "template-posthog-run-scout"+_REPOSITORY_SHAPE = re.compile(r"[A-Za-z0-9_.-]+/[A-Za-z0-9_.-]+")MIN_WORKFLOW_TASK_MAX_PARALLEL_TASKS = 1@@ -1360,6 +1367,20 @@ class HogFlowActionSerializer(serializers.Serializer):})+ def _validate_run_scout_action(self) -> None:+ """Save-time check for the "Run scout" step: reject it in a child environment, matching+ the runtime refusal in start_workflow_scout_run, so a broken step fails at save instead of+ on every run."""+ get_team = self.context.get("get_team")+ # No team to check against outside a request (internal re-saves) - nothing new is being+ # authored there, so there is nothing to validate.+ if get_team is None:+ return+ if get_team().parent_team_id:+ raise serializers.ValidationError(+ {"template_id": "Run scout is only available in the project's main environment."}+ )+def validate(self, data):is_draft = self.context.get("is_draft")# Drafts from the web builder stay lenient (incomplete graphs save fine); programmatic callers@@ -1612,6 +1633,8 @@ class HogFlowActionSerializer(serializers.Serializer):if strict and template_id == _CREATE_TASK_TEMPLATE_ID:self._validate_create_task_action(data["config"]["inputs"])+ if strict and template_id == _RUN_SCOUT_TEMPLATE_ID:+ self._validate_run_scout_action()# Branch types fan out via 'branch' edges indexed into these arrays; a node stored without# its array crashes the editor panel and assigns nothing at runtime. Presence is onlydiff --git a/products/workflows/backend/api/test/test_hog_flow.py b/products/workflows/backend/api/test/test_hog_flow.pyindex c1e3ebddd4a7..189cff19c67f 100644--- a/products/workflows/backend/api/test/test_hog_flow.py+++ b/products/workflows/backend/api/test/test_hog_flow.py@@ -5580,3 +5580,61 @@ class TestCreateTaskActionValidation(APIBaseTest):response = self._post_flow({"max_parallel_tasks": {"value": value}})assert response.status_code == status.HTTP_201_CREATED, response.json()+++class TestRunScoutActionValidation(APIBaseTest):+ """Save-time check specific to the "Run scout" step: it used to fail only on the first run,+ once per fire, in a child environment. This locks in that the same misconfiguration is now+ rejected when the workflow is saved."""++ def setUp(self):+ super().setUp()+ template = deepcopy(webhook_template)+ template["id"] = "template-posthog-run-scout"+ template["name"] = "Run scout"+ template["inputs_schema"] = [+ {"key": "skill_name", "type": "string", "label": "Scout", "secret": False, "required": True}+ ]+ sync_template_to_db(template)++ def _post_flow(self, team: Team):+ trigger_action = {+ "id": "trigger_node",+ "name": "trigger_1",+ "type": "trigger",+ "config": {+ "type": "event",+ "filters": {"events": [{"id": "$pageview", "name": "$pageview", "type": "events", "order": 0}]},+ },+ }+ action = {+ "id": "action_1",+ "name": "action_1",+ "type": "function",+ "config": {+ "template_id": "template-posthog-run-scout",+ "inputs": {"skill_name": {"value": "signals-scout-general"}},+ },+ }+ # Strict validation, same as any programmatic caller - the path a misconfigured+ # workflow is actually authored through.+ with patch("products.workflows.backend.api.hog_flow.gated_template_enabled", return_value=True):+ return self.client.post(+ f"/api/projects/{team.id}/hog_flows",+ {"name": "Test Flow", "actions": [trigger_action, action], "edges": []},+ HTTP_X_POSTHOG_CLIENT="mcp",+ )++ def test_rejects_the_action_in_a_child_environment(self):+ child = Team.objects.create(organization=self.organization, name="child env", parent_team=self.team)++ response = self._post_flow(child)++ assert response.status_code == status.HTTP_400_BAD_REQUEST, response.json()+ assert response.json()["attr"] == "actions__1__template_id"+ assert not HogFlow.objects.filter(team=child).exists()++ def test_accepts_the_action_in_the_main_environment(self):+ response = self._post_flow(self.team)++ assert response.status_code == status.HTTP_201_CREATED, response.json()diff --git a/products/workflows/backend/api/test/test_workflow_scout_runs_api.py b/products/workflows/backend/api/test/test_workflow_scout_runs_api.pynew file mode 100644index 000000000000..7014f0577ebb--- /dev/null+++ b/products/workflows/backend/api/test/test_workflow_scout_runs_api.py@@ -0,0 +1,163 @@+from datetime import timedelta+from typing import Any+from uuid import uuid4++from posthog.test.base import APIBaseTest+from unittest.mock import patch++from django.test import override_settings++from parameterized import parameterized+from rest_framework import status++from posthog.jwt import PosthogJwtAudience, encode_jwt++from products.signals.backend.facade.api import ScoutRunRejectionKind, WorkflowScoutRunRejected, WorkflowScoutRunStarted+from products.signals.backend.scout_harness.run_gates import ScoutRunRejection+from products.workflows.backend.models import HogFlow++SECRET = "test-workflow-scout-run-jwt"+SCOUT = "signals-scout-error-tracking"+_START_SCOUT = "products.workflows.backend.api.workflow_scout_runs.start_workflow_scout_run"+++def _token(+ team_id: int,+ hog_flow_id: str | None,+ *,+ audience: PosthogJwtAudience = PosthogJwtAudience.WORKFLOW_SCOUT_RUN,+ expiry: timedelta = timedelta(minutes=5),+) -> str:+ claims: dict = {"team_id": team_id}+ if hog_flow_id is not None:+ claims["hog_flow_id"] = hog_flow_id+ return encode_jwt(claims, expiry, audience, signing_key=SECRET)+++# Both settings provisioned with the same value here so audience is the only thing under test+# in test_rejects_a_task_creation_token below; test_rejects_a_token_signed_with_the_wrong_secret+# overrides them to differing values to prove the endpoint verifies its own dedicated secret.+@override_settings(WORKFLOW_SCOUT_RUN_JWT_SECRETS=[SECRET], TASKS_CREATE_JWT_SECRETS=[SECRET])+class TestWorkflowScoutRunsAPI(APIBaseTest):+ def setUp(self) -> None:+ super().setUp()+ self.client.logout()+ self.hog_flow = HogFlow.objects.create(+ team=self.team, name="Alert triage", created_by=self.user, trigger={"type": "manual"}+ )+ self.url = f"/api/projects/{self.team.id}/workflow_scout_runs/"++ def _post(self, body: dict | None = None, token: str | None = None) -> Any:+ return self.client.post(+ self.url,+ {"skill_name": SCOUT, **(body or {})},+ format="json",+ HTTP_AUTHORIZATION=f"Bearer {token or _token(self.team.id, str(self.hog_flow.id))}",+ )++ def test_dispatches_a_scout_run(self) -> None:+ started = WorkflowScoutRunStarted(skill_name=SCOUT, workflow_id="signals-scout-workflow-run-1")+ with patch(_START_SCOUT, return_value=started) as start:+ response = self._post()++ assert response.status_code == status.HTTP_202_ACCEPTED, response.json()+ assert response.json() == {"scout": SCOUT, "workflow_id": "signals-scout-workflow-run-1"}+ start.assert_called_once_with(team_id=self.team.id, skill_name=SCOUT)++ @parameterized.expand(+ [+ ("paused", ScoutRunRejectionKind.CONFLICT, status.HTTP_409_CONFLICT),+ ("cooldown", ScoutRunRejectionKind.THROTTLED, status.HTTP_409_CONFLICT),+ ("unknown_scout", ScoutRunRejectionKind.NOT_FOUND, status.HTTP_404_NOT_FOUND),+ ("child_environment", ScoutRunRejectionKind.FORBIDDEN, status.HTTP_403_FORBIDDEN),+ ]+ )+ def test_a_refused_run_maps_onto_the_status_the_step_expects(+ self, reason: str, kind: ScoutRunRejectionKind, expected: int+ ) -> None:+ # The step skips on 409 and fails on anything else, so backpressure has to be a 409 and a+ # scout that cannot run has to be something else.+ rejection = WorkflowScoutRunRejected(ScoutRunRejection(kind=kind, reason=reason, detail=f"detail: {reason}"))+ with patch(_START_SCOUT, side_effect=rejection):+ response = self._post()++ assert response.status_code == expected+ assert response.json()["detail"] == f"detail: {reason}"++ def test_a_retry_with_the_same_idempotency_key_does_not_dispatch_twice(self) -> None:+ # A retry landing after the original Temporal workflow has already closed would otherwise+ # start a second billable run: ALLOW_DUPLICATE lets a closed workflow's id be reused for a+ # fresh execution, so Temporal's own id-conflict policy can't catch this the way it catches+ # an in-flight collision.+ started = WorkflowScoutRunStarted(skill_name=SCOUT, workflow_id="signals-scout-workflow-run-1")+ with patch(_START_SCOUT, return_value=started) as start:+ first = self._post({"idempotency_key": "invocation-1:action-1"})+ second = self._post({"idempotency_key": "invocation-1:action-1"})++ assert first.status_code == status.HTTP_202_ACCEPTED, first.json()+ assert second.status_code == status.HTTP_202_ACCEPTED, second.json()+ assert first.json() == second.json() == {"scout": SCOUT, "workflow_id": "signals-scout-workflow-run-1"}+ start.assert_called_once_with(team_id=self.team.id, skill_name=SCOUT)++ def test_a_different_idempotency_key_still_dispatches_its_own_run(self) -> None:+ started = WorkflowScoutRunStarted(skill_name=SCOUT, workflow_id="signals-scout-workflow-run-1")+ with patch(_START_SCOUT, return_value=started) as start:+ self._post({"idempotency_key": "invocation-1:action-1"})+ self._post({"idempotency_key": "invocation-2:action-1"})++ assert start.call_count == 2++ def test_refuses_a_request_for_a_deleted_workflow(self) -> None:+ token = _token(self.team.id, str(self.hog_flow.id))+ self.hog_flow.delete()+ with patch(_START_SCOUT) as start:+ response = self._post(token=token)++ assert response.status_code == status.HTTP_422_UNPROCESSABLE_ENTITY+ start.assert_not_called()++ def test_a_request_without_a_scout_name_is_rejected(self) -> None:+ response = self.client.post(+ self.url,+ {},+ format="json",+ HTTP_AUTHORIZATION=f"Bearer {_token(self.team.id, str(self.hog_flow.id))}",+ )++ assert response.status_code == status.HTTP_400_BAD_REQUEST++ def test_rejects_a_task_creation_token(self) -> None:+ # A token minted for the "Create AI task" step must not spend a scout run, even signed+ # with a secret this endpoint would otherwise accept (both settings share SECRET above) —+ # the audience claim alone has to be what's rejecting it here.+ token = _token(self.team.id, str(self.hog_flow.id), audience=PosthogJwtAudience.TASKS_CREATE)+ with patch(_START_SCOUT) as start:+ response = self._post(token=token)++ assert response.status_code in (status.HTTP_401_UNAUTHORIZED, status.HTTP_403_FORBIDDEN)+ start.assert_not_called()++ @override_settings(WORKFLOW_SCOUT_RUN_JWT_SECRETS=["other-workflow-scout-run-jwt"])+ def test_rejects_a_token_signed_with_the_wrong_secret(self) -> None:+ # A leak of the task-creation secret must not forge scout runs, so a token signed with it+ # must not verify here even with the correct audience.+ with patch(_START_SCOUT) as start:+ response = self._post()++ assert response.status_code in (status.HTTP_401_UNAUTHORIZED, status.HTTP_403_FORBIDDEN)+ start.assert_not_called()++ @parameterized.expand([("unknown_workflow",), ("another_teams_workflow",)])+ def test_refuses_a_workflow_it_cannot_find_in_the_tokens_team(self, case: str) -> None:+ if case == "unknown_workflow":+ flow_id = str(uuid4())+ else:+ other_team = self.create_team_with_organization(self.organization)+ flow = HogFlow.objects.create(team=other_team, name="Other team's", created_by=self.user)+ flow_id = str(flow.id)++ with patch(_START_SCOUT) as start:+ response = self._post(token=_token(self.team.id, flow_id))++ assert response.status_code == status.HTTP_422_UNPROCESSABLE_ENTITY+ start.assert_not_called()diff --git a/products/workflows/backend/api/workflow_scout_runs.py b/products/workflows/backend/api/workflow_scout_runs.pynew file mode 100644index 000000000000..45a023bc51bc--- /dev/null+++ b/products/workflows/backend/api/workflow_scout_runs.py@@ -0,0 +1,182 @@+import uuid+from typing import Any, cast++import structlog+from drf_spectacular.utils import OpenApiResponse, extend_schema+from rest_framework import serializers, status, viewsets+from rest_framework.exceptions import AuthenticationFailed+from rest_framework.permissions import IsAuthenticated+from rest_framework.request import Request+from rest_framework.response import Response++from posthog.auth import InternalAPIUser, ScopedServiceJWTAuthentication+from posthog.redis import get_client++from products.signals.backend.facade.api import (+ ScoutRunRejectionKind,+ WorkflowScoutRunRejected,+ start_workflow_scout_run,+)+from products.workflows.backend.models import HogFlow+from products.workflows.backend.service_jwt import WORKFLOW_SCOUT_RUN_PURPOSE++logger = structlog.get_logger(__name__)++# Covers the whole retry window a staged fetch can span: the JWT that carries idempotency_key+# lives 30 minutes (nodejs/src/cdp/async-functions/run-scout.ts), and this outlives that with+# margin for engine backoff and queue lag. Temporal's own id-conflict policy only dedupes a+# retry that lands while the original run is still open (ALLOW_DUPLICATE lets a closed run's id+# be reused for a fresh, billable execution) — this cache is what catches a retry landing after+# the original run has already finished.+IDEMPOTENCY_KEY_TTL_SECONDS = 60 * 60+++def _idempotency_cache_key(hog_flow_id: uuid.UUID, idempotency_key: str) -> str:+ # Scoped by workflow so one workflow's key can never replay another's dispatch.+ return f"workflow_scout_run_idempotency:{hog_flow_id}:{idempotency_key}"+++# The step only treats 409 as a graceful skip, so every backpressure kind (paused, cooldown,+# budget, quota, run in flight) maps onto it; a scout that cannot run at all fails the step so the+# author notices.+_REJECTION_STATUS: dict[ScoutRunRejectionKind, int] = {+ ScoutRunRejectionKind.NOT_FOUND: status.HTTP_404_NOT_FOUND,+ ScoutRunRejectionKind.FORBIDDEN: status.HTTP_403_FORBIDDEN,+ ScoutRunRejectionKind.CONFLICT: status.HTTP_409_CONFLICT,+ ScoutRunRejectionKind.THROTTLED: status.HTTP_409_CONFLICT,+}+++class WorkflowScoutRunsJWTAuthentication(ScopedServiceJWTAuthentication):+ purpose = WORKFLOW_SCOUT_RUN_PURPOSE++ # nosemgrep: tuple-return-prefer-dataclass -- DRF's (user, auth) authentication contract+ def _authenticate_claims(self, request: Request, claims: dict[str, Any]) -> tuple[Any, Any]:+ user, _ = super()._authenticate_claims(request, claims)+ # The workflow is identified by the verified token, never by the request body, so a+ # token minted for one workflow can't spend another workflow's scout runs.+ try:+ hog_flow_id = uuid.UUID(str(claims.get("hog_flow_id")))+ except ValueError:+ raise AuthenticationFailed("Service token is missing its workflow claim.")+ return user, hog_flow_id+++class WorkflowScoutRunCreateSerializer(serializers.Serializer):+ skill_name = serializers.CharField(+ max_length=200, help_text="Name of the scout to run, for example signals-scout-error-tracking."+ )+ idempotency_key = serializers.CharField(+ max_length=128,+ required=False,+ help_text="Stable key for this invocation. A retried request with the same key returns the run it dispatched, without spending another.",+ )+++class WorkflowScoutRunResponseSerializer(serializers.Serializer):+ scout = serializers.CharField(help_text="The scout that was run.")+ workflow_id = serializers.CharField(help_text="Temporal workflow ID of the dispatched scout run.")+++class WorkflowScoutRunRejectedSerializer(serializers.Serializer):+ detail = serializers.CharField(help_text="Why the scout was not run.")+++class WorkflowScoutRunViewSet(viewsets.GenericViewSet):+ """Start a Signals scout run from a workflow's "Run scout" action. Authenticated by a scoped+ service JWT minted by the plugin server, never by a user credential, with its own signing key+ and audience.++ A run is a pure kick: nothing from the triggering event reaches the scout, so it explores+ exactly as it does on its schedule. It never stamps the scout's last_run_at and never feeds+ its failure-streak breaker — a workflow trigger is additive to the schedule, not a+ substitute for it."""++ authentication_classes = [WorkflowScoutRunsJWTAuthentication]+ permission_classes = [IsAuthenticated]+ serializer_class = WorkflowScoutRunCreateSerializer++ @extend_schema(+ request=WorkflowScoutRunCreateSerializer,+ responses={+ 202: OpenApiResponse(+ response=WorkflowScoutRunResponseSerializer,+ description="The scout run was dispatched. It runs asynchronously; poll the scout's runs for the result",+ ),+ 403: OpenApiResponse(+ response=WorkflowScoutRunRejectedSerializer,+ description="The workflow lives in a child environment, which cannot run scouts",+ ),+ 404: OpenApiResponse(+ response=WorkflowScoutRunRejectedSerializer,+ description="No runnable scout of that name exists in this project",+ ),+ 409: OpenApiResponse(+ response=WorkflowScoutRunRejectedSerializer,+ description="The scout is paused or over its cooldown, daily budget, or quota",+ ),+ 422: OpenApiResponse(+ response=WorkflowScoutRunRejectedSerializer,+ description="The workflow no longer exists",+ ),+ },+ summary="Run a Signals scout from a workflow",+ )+ def create(self, request: Request, **kwargs: Any) -> Response:+ # Both from the verified token, not the URL or body.+ user = cast(InternalAPIUser, request.user)+ team_id = cast(int, user.current_team_id)+ hog_flow_id = cast(uuid.UUID, request.auth)++ serializer = WorkflowScoutRunCreateSerializer(data=request.data)+ serializer.is_valid(raise_exception=True)+ skill_name = serializer.validated_data["skill_name"].strip()+ idempotency_key = serializer.validated_data.get("idempotency_key")+ cache_key = _idempotency_cache_key(hog_flow_id, idempotency_key) if idempotency_key else None++ # A replay of an already-dispatched key returns that run before any other check, same as+ # the task-creation endpoint's origin_key — no need to re-resolve the workflow or re-run+ # the scout's gates for a request this key has already spent.+ if cache_key is not None:+ cached = get_client().get(cache_key)+ if cached is not None:+ return _dispatched(skill_name, cached.decode() if isinstance(cached, bytes) else cached)++ # A token outlives the workflow it was minted for (its TTL covers the whole fetch retry+ # chain), so a deleted workflow must not still be able to spend scout runs.+ if not HogFlow.objects.filter(team_id=team_id, id=hog_flow_id).exists():+ return _rejected("Workflow no longer exists.", status.HTTP_422_UNPROCESSABLE_ENTITY)++ try:+ started = start_workflow_scout_run(team_id=team_id, skill_name=skill_name)+ except WorkflowScoutRunRejected as error:+ logger.info(+ "workflow_scout_run_rejected",+ team_id=team_id,+ hog_flow_id=str(hog_flow_id),+ skill_name=skill_name,+ reason=error.rejection.reason,+ )+ return _rejected(error.rejection.detail, _REJECTION_STATUS[error.rejection.kind])++ logger.info(+ "workflow_scout_run_started",+ team_id=team_id,+ hog_flow_id=str(hog_flow_id),+ skill_name=started.skill_name,+ workflow_id=started.workflow_id,+ )+ if cache_key is not None:+ get_client().set(cache_key, started.workflow_id, ex=IDEMPOTENCY_KEY_TTL_SECONDS)+ return _dispatched(started.skill_name, started.workflow_id)+++def _dispatched(skill_name: str, workflow_id: str) -> Response:+ return Response(+ WorkflowScoutRunResponseSerializer({"scout": skill_name, "workflow_id": workflow_id}).data,+ status=status.HTTP_202_ACCEPTED,+ )+++def _rejected(detail: str, http_status: int) -> Response:+ return Response(WorkflowScoutRunRejectedSerializer({"detail": detail}).data, status=http_status)diff --git a/products/workflows/backend/routes.py b/products/workflows/backend/routes.pyindex 7c589603b43c..98678f0e3527 100644--- a/products/workflows/backend/routes.py+++ b/products/workflows/backend/routes.py@@ -1,6 +1,6 @@from posthog.api.routing import RouterRegistry-from products.workflows.backend.api import hog_flow, hog_flow_template, workflow_tasks+from products.workflows.backend.api import hog_flow, hog_flow_template, workflow_scout_runs, workflow_tasksdef register_routes(routers: RouterRegistry) -> None:@@ -8,6 +8,12 @@ def register_routes(routers: RouterRegistry) -> None:routers.projects.register(r"workflow_tasks", workflow_tasks.WorkflowTaskViewSet, "project_workflow_tasks", ["team_id"])+ routers.projects.register(+ r"workflow_scout_runs",+ workflow_scout_runs.WorkflowScoutRunViewSet,+ "project_workflow_scout_runs",+ ["team_id"],+ )routers.projects.register(r"hog_flow_templates",hog_flow_template.HogFlowTemplateViewSet,diff --git a/products/workflows/backend/service_jwt.py b/products/workflows/backend/service_jwt.pyindex 024711d5edcf..5c3cced4a267 100644--- a/products/workflows/backend/service_jwt.py+++ b/products/workflows/backend/service_jwt.py@@ -7,3 +7,12 @@ TASKS_CREATE_PURPOSE = ScopedServiceJwtPurpose(audience=PosthogJwtAudience.TASKS_CREATE,settings_name="TASKS_CREATE_JWT_SECRETS",)++# A dedicated key, not TASKS_CREATE_PURPOSE's: both mint from the plugin server for a workflow+# step, but the scoped-JWT rule is narrowest scope, mint a new key for a new use case rather than+# widen an existing one's — a leak of one can't forge the other's calls, on top of the audience+# claim already blocking a legitimate token from replaying at the wrong endpoint.+WORKFLOW_SCOUT_RUN_PURPOSE = ScopedServiceJwtPurpose(+ audience=PosthogJwtAudience.WORKFLOW_SCOUT_RUN,+ settings_name="WORKFLOW_SCOUT_RUN_JWT_SECRETS",+)diff --git a/products/workflows/frontend/Workflows/hogflows/hogFlowEditorLogic.tsx b/products/workflows/frontend/Workflows/hogflows/hogFlowEditorLogic.tsxindex 13e3056cf3b5..5583cdba9bba 100644--- a/products/workflows/frontend/Workflows/hogflows/hogFlowEditorLogic.tsx+++ b/products/workflows/frontend/Workflows/hogflows/hogFlowEditorLogic.tsx@@ -486,6 +486,7 @@ export interface hogFlowEditorLogicActions {| 'posthog_assignee'| 'posthog_business_hours'| 'posthog_ticket_tags'+ | 'signals_scout'| 'string'| 'task_mcp_installations'| 'task_model'@@ -1032,6 +1033,7 @@ export interface hogFlowEditorLogicActions {| 'posthog_assignee'| 'posthog_business_hours'| 'posthog_ticket_tags'+ | 'signals_scout'| 'string'| 'task_mcp_installations'| 'task_model'@@ -1337,6 +1339,7 @@ export interface hogFlowEditorLogicActions {| 'posthog_assignee'| 'posthog_business_hours'| 'posthog_ticket_tags'+ | 'signals_scout'| 'string'| 'task_mcp_installations'| 'task_model'@@ -1883,6 +1886,7 @@ export interface hogFlowEditorLogicActions {| 'posthog_assignee'| 'posthog_business_hours'| 'posthog_ticket_tags'+ | 'signals_scout'| 'string'| 'task_mcp_installations'| 'task_model'diff --git a/products/workflows/frontend/Workflows/hogflows/panel/HogFlowEditorPanelBuild.tsx b/products/workflows/frontend/Workflows/hogflows/panel/HogFlowEditorPanelBuild.tsxindex 523d1e354246..71f8d7103a7a 100644--- a/products/workflows/frontend/Workflows/hogflows/panel/HogFlowEditorPanelBuild.tsx+++ b/products/workflows/frontend/Workflows/hogflows/panel/HogFlowEditorPanelBuild.tsx@@ -7,6 +7,7 @@ import { LemonButton, LemonDivider, LemonDropdown, LemonInput, LemonTag, Spinnerimport { featureFlagLogic } from 'lib/logic/featureFlagLogic'import { hogFunctionTemplateListLogic } from 'scenes/hog-functions/list/hogFunctionTemplateListLogic'import { HogFunctionStatusTag } from 'scenes/hog-functions/misc/HogFunctionStatusTag'+import { teamLogic } from 'scenes/teamLogic'import { HogFunctionTemplateType } from '~/types'@@ -76,6 +77,19 @@ const AI_TASK_ACTION_NODE: CreateActionType = {output_variable: { key: 'task', result_path: null, label: 'Task' },}+const RUN_SCOUT_ACTION_NODE: CreateActionType = {+ type: 'function',+ name: 'Run scout',+ description: 'Start a Signals scout run. The scout explores as it does on its schedule.',+ config: {+ template_id: 'template-posthog-run-scout',+ // Same reason as the AI-task node above: 409 (run in flight, scout paused, cooldown,+ // budget, or quota) is backpressure the step should skip on, not fail.+ inputs: { non_failure_status_codes: { value: [409] } },+ },+ output_variable: { key: 'scout_run', result_path: null, label: 'Scout run' },+}+export const DELAY_NODES_TO_SHOW: CreateActionType[] = [{type: 'delay',@@ -298,6 +312,7 @@ function HogFunctionTemplatesChooser(): JSX.Element {export function HogFlowEditorPanelBuild(): JSX.Element {const { featureFlags } = useValues(featureFlagLogic)+ const { currentTeam } = useValues(teamLogic)const { isRowScopedTrigger } = useValues(workflowLogic)const registeredCategories = getRegisteredActionNodeCategories().filter(@@ -335,6 +350,19 @@ export function HogFlowEditorPanelBuild(): JSX.Element {</span></HogFlowEditorToolbarNode>)}+ {/* Scouts belong to the project's main environment, and the server refuses the step elsewhere.+ Require currentTeam explicitly: while it's still loading, both sides of the id comparison are+ undefined, which would otherwise pass. */}+ {featureFlags[FEATURE_FLAGS.WORKFLOW_RUN_SCOUT_ACTION] &&+ !!currentTeam &&+ currentTeam.id === currentTeam.project_id && (+ <HogFlowEditorToolbarNode key="run-scout" action={RUN_SCOUT_ACTION_NODE}>+ <span className="inline-flex items-center gap-1.5">+ {RUN_SCOUT_ACTION_NODE.name}+ <LemonTag type="completion">Beta</LemonTag>+ </span>+ </HogFlowEditorToolbarNode>+ )}<HogFunctionTemplatesChooser /><span className="flex gap-2 text-sm font-semibold mt-2 items-center">diff --git a/products/workflows/frontend/Workflows/hogflows/steps/stepDelayLogic.ts b/products/workflows/frontend/Workflows/hogflows/steps/stepDelayLogic.tsindex 0977ea5bcce8..ce711571bb47 100644--- a/products/workflows/frontend/Workflows/hogflows/steps/stepDelayLogic.ts+++ b/products/workflows/frontend/Workflows/hogflows/steps/stepDelayLogic.ts@@ -332,6 +332,7 @@ export interface stepDelayLogicActions {| 'posthog_assignee'| 'posthog_business_hours'| 'posthog_ticket_tags'+ | 'signals_scout'| 'string'| 'task_mcp_installations'| 'task_model'@@ -642,6 +643,7 @@ export interface stepDelayLogicActions {| 'posthog_assignee'| 'posthog_business_hours'| 'posthog_ticket_tags'+ | 'signals_scout'| 'string'| 'task_mcp_installations'| 'task_model'diff --git a/products/workflows/frontend/Workflows/hogflows/steps/stepWaitUntilTimeWindowLogic.ts b/products/workflows/frontend/Workflows/hogflows/steps/stepWaitUntilTimeWindowLogic.tsindex b337d24f3ffe..9a89c232e9d3 100644--- a/products/workflows/frontend/Workflows/hogflows/steps/stepWaitUntilTimeWindowLogic.ts+++ b/products/workflows/frontend/Workflows/hogflows/steps/stepWaitUntilTimeWindowLogic.ts@@ -257,6 +257,7 @@ export interface stepWaitUntilTimeWindowLogicActions {| 'posthog_assignee'| 'posthog_business_hours'| 'posthog_ticket_tags'+ | 'signals_scout'| 'string'| 'task_mcp_installations'| 'task_model'@@ -568,6 +569,7 @@ export interface stepWaitUntilTimeWindowLogicActions {| 'posthog_assignee'| 'posthog_business_hours'| 'posthog_ticket_tags'+ | 'signals_scout'| 'string'| 'task_mcp_installations'| 'task_model'diff --git a/products/workflows/frontend/Workflows/hogflows/steps/types.ts b/products/workflows/frontend/Workflows/hogflows/steps/types.tsindex fb2209bd8990..8b8f97ec32e7 100644--- a/products/workflows/frontend/Workflows/hogflows/steps/types.ts+++ b/products/workflows/frontend/Workflows/hogflows/steps/types.ts@@ -103,6 +103,7 @@ export const CyclotronJobInputSchemaTypeSchema = z.object({'task_model','task_repository','task_mcp_installations',+ 'signals_scout',]),key: z.string(),label: z.string(),diff --git a/products/workflows/frontend/Workflows/workflowLogic.ts b/products/workflows/frontend/Workflows/workflowLogic.tsindex 3bc3cc54b4f0..a376e5240ed8 100644--- a/products/workflows/frontend/Workflows/workflowLogic.ts+++ b/products/workflows/frontend/Workflows/workflowLogic.ts@@ -520,6 +520,7 @@ export interface workflowLogicActions {| 'posthog_assignee'| 'posthog_business_hours'| 'posthog_ticket_tags'+ | 'signals_scout'| 'string'| 'task_mcp_installations'| 'task_model'@@ -1163,6 +1164,7 @@ export interface workflowLogicActions {| 'posthog_assignee'| 'posthog_business_hours'| 'posthog_ticket_tags'+ | 'signals_scout'| 'string'| 'task_mcp_installations'| 'task_model'@@ -1371,6 +1373,7 @@ export interface workflowLogicActions {| 'posthog_assignee'| 'posthog_business_hours'| 'posthog_ticket_tags'+ | 'signals_scout'| 'string'| 'task_mcp_installations'| 'task_model'@@ -2014,6 +2017,7 @@ export interface workflowLogicActions {| 'posthog_assignee'| 'posthog_business_hours'| 'posthog_ticket_tags'+ | 'signals_scout'| 'string'| 'task_mcp_installations'| 'task_model'@@ -2195,6 +2199,7 @@ export interface workflowLogicActions {| 'posthog_assignee'| 'posthog_business_hours'| 'posthog_ticket_tags'+ | 'signals_scout'| 'string'| 'task_mcp_installations'| 'task_model'@@ -2572,6 +2577,7 @@ export interface workflowLogicActions {| 'posthog_assignee'| 'posthog_business_hours'| 'posthog_ticket_tags'+ | 'signals_scout'| 'string'| 'task_mcp_installations'| 'task_model'diff --git a/pyproject.toml b/pyproject.tomlindex 4a77cf6fe110..69ada6dc8c75 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -771,6 +771,7 @@ ignore_imports = ["products.web_analytics.backend.routes -> products.web_analytics.backend.api.web_analytics_path_cleaning_suggestions","products.workflows.backend.routes -> products.workflows.backend.api.hog_flow","products.workflows.backend.routes -> products.workflows.backend.api.hog_flow_template",+ "products.workflows.backend.routes -> products.workflows.backend.api.workflow_scout_runs","products.workflows.backend.routes -> products.workflows.backend.api.workflow_tasks",]diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex 1f1fac3931f9..752c4514973d 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -42419,6 +42419,7 @@ export namespace Schemas {* * `task_model` - task_model* * `task_repository` - task_repository* * `task_mcp_installations` - task_mcp_installations+ * * `signals_scout` - signals_scout*/export type InputsSchemaItemTypeEnum = typeof InputsSchemaItemTypeEnum[keyof typeof InputsSchemaItemTypeEnum];@@ -42444,6 +42445,7 @@ export namespace Schemas {TaskModel: 'task_model',TaskRepository: 'task_repository',TaskMcpInstallations: 'task_mcp_installations',+ SignalsScout: 'signals_scout',} as const;export type InputsSchemaItemChoicesItem = { [key: string]: unknown };@@ -77018,7 +77020,7 @@ export namespace Schemas {};/**- * Scout-owned per-run context, in two regions. Top-level keys are stamped by the runner at run start. Always present: `harness_prompt_version` (id of the harness prompt build the run was given), `report_channel` (which report tools the run held: `none`, `emit`, `edit`, or `both`), `skill_origin` (`canonical` or `custom`), `github_guidance` (whether the run got the GitHub evidence section), and `business_knowledge_maintained` (whether the run got the business-knowledge section: the product flag is on and the team's knowledge base looks maintained) — the provenance set that says which instructions the run actually got, so runs are only compared against runs of the same shape. Present only when the run departed from a default: `model`, `runtime_adapter`, and `reasoning_effort` (routing overrode the agent-server default), and `network_access` (`full` when the scout's config lifted the trusted-domain network restriction for this run). The nested `derived` object is the harness's own map of boolean run dimensions, computed server-side at finalize: `has_emit_report`, `has_edit_report`, `has_self_improvement`, `has_chart`, and `has_self_validation`. Use `derived` to answer 'what kind of run was this?' instead of parsing the `summary` prose. Note the flags describe the reports the run authored as they stand now, so charts attached to someone else's report via an edit are not counted. A missing `derived` object is unknown, not all-false: the run predates the field, never finalized, or its stamp failed.+ * Scout-owned per-run context, in two regions. Top-level keys are stamped by the runner at run start. Always present: `harness_prompt_version` (id of the harness prompt build the run was given), `report_channel` (which report tools the run held: `none`, `emit`, `edit`, or `both`), `skill_origin` (`canonical` or `custom`), `github_guidance` (whether the run got the GitHub evidence section), and `business_knowledge_maintained` (whether the run got the business-knowledge section: the product flag is on and the team's knowledge base looks maintained) — the provenance set that says which instructions the run actually got, so runs are only compared against runs of the same shape. Present only when the run departed from a default: `model`, `runtime_adapter`, and `reasoning_effort` (routing overrode the agent-server default), `network_access` (`full` when the scout's config lifted the trusted-domain network restriction for this run), and `triggered_by` (`manual` or `workflow` when the run was fired off-schedule; absent means the run came from the coordinator's schedule). The nested `derived` object is the harness's own map of boolean run dimensions, computed server-side at finalize: `has_emit_report`, `has_edit_report`, `has_self_improvement`, `has_chart`, and `has_self_validation`. Use `derived` to answer 'what kind of run was this?' instead of parsing the `summary` prose. Note the flags describe the reports the run authored as they stand now, so charts attached to someone else's report via an edit are not counted. A missing `derived` object is unknown, not all-false: the run predates the field, never finalized, or its stamp failed.*/export type SignalScoutRunDetailMetadata = {harness_prompt_version?: string;@@ -77030,6 +77032,7 @@ export namespace Schemas {runtime_adapter?: string;reasoning_effort?: string;network_access?: string;+ triggered_by?: string;derived?: SignalScoutRunDetailMetadataDerived;[key: string]: unknown;};@@ -77099,7 +77102,7 @@ export namespace Schemas {emitted_report_ids: string[];/** The `SignalReport` ids this run mutated via the `edit_report` channel (rewrote title/summary and/or appended a note), deduped. Distinct from `emitted_report_ids`: edit can target any inbox report, so these are generally not reports the run authored. Empty for runs that edited no report. */edited_report_ids: string[];- /** Scout-owned per-run context, in two regions. Top-level keys are stamped by the runner at run start. Always present: `harness_prompt_version` (id of the harness prompt build the run was given), `report_channel` (which report tools the run held: `none`, `emit`, `edit`, or `both`), `skill_origin` (`canonical` or `custom`), `github_guidance` (whether the run got the GitHub evidence section), and `business_knowledge_maintained` (whether the run got the business-knowledge section: the product flag is on and the team's knowledge base looks maintained) — the provenance set that says which instructions the run actually got, so runs are only compared against runs of the same shape. Present only when the run departed from a default: `model`, `runtime_adapter`, and `reasoning_effort` (routing overrode the agent-server default), and `network_access` (`full` when the scout's config lifted the trusted-domain network restriction for this run). The nested `derived` object is the harness's own map of boolean run dimensions, computed server-side at finalize: `has_emit_report`, `has_edit_report`, `has_self_improvement`, `has_chart`, and `has_self_validation`. Use `derived` to answer 'what kind of run was this?' instead of parsing the `summary` prose. Note the flags describe the reports the run authored as they stand now, so charts attached to someone else's report via an edit are not counted. A missing `derived` object is unknown, not all-false: the run predates the field, never finalized, or its stamp failed. */+ /** Scout-owned per-run context, in two regions. Top-level keys are stamped by the runner at run start. Always present: `harness_prompt_version` (id of the harness prompt build the run was given), `report_channel` (which report tools the run held: `none`, `emit`, `edit`, or `both`), `skill_origin` (`canonical` or `custom`), `github_guidance` (whether the run got the GitHub evidence section), and `business_knowledge_maintained` (whether the run got the business-knowledge section: the product flag is on and the team's knowledge base looks maintained) — the provenance set that says which instructions the run actually got, so runs are only compared against runs of the same shape. Present only when the run departed from a default: `model`, `runtime_adapter`, and `reasoning_effort` (routing overrode the agent-server default), `network_access` (`full` when the scout's config lifted the trusted-domain network restriction for this run), and `triggered_by` (`manual` or `workflow` when the run was fired off-schedule; absent means the run came from the coordinator's schedule). The nested `derived` object is the harness's own map of boolean run dimensions, computed server-side at finalize: `has_emit_report`, `has_edit_report`, `has_self_improvement`, `has_chart`, and `has_self_validation`. Use `derived` to answer 'what kind of run was this?' instead of parsing the `summary` prose. Note the flags describe the reports the run authored as they stand now, so charts attached to someone else's report via an edit are not counted. A missing `derived` object is unknown, not all-false: the run predates the field, never finalized, or its stamp failed. */metadata: SignalScoutRunDetailMetadata;}@@ -77113,7 +77116,7 @@ export namespace Schemas {};/**- * Scout-owned per-run context, in two regions. Top-level keys are stamped by the runner at run start. Always present: `harness_prompt_version` (id of the harness prompt build the run was given), `report_channel` (which report tools the run held: `none`, `emit`, `edit`, or `both`), `skill_origin` (`canonical` or `custom`), `github_guidance` (whether the run got the GitHub evidence section), and `business_knowledge_maintained` (whether the run got the business-knowledge section: the product flag is on and the team's knowledge base looks maintained) — the provenance set that says which instructions the run actually got, so runs are only compared against runs of the same shape. Present only when the run departed from a default: `model`, `runtime_adapter`, and `reasoning_effort` (routing overrode the agent-server default), and `network_access` (`full` when the scout's config lifted the trusted-domain network restriction for this run). The nested `derived` object is the harness's own map of boolean run dimensions, computed server-side at finalize: `has_emit_report`, `has_edit_report`, `has_self_improvement`, `has_chart`, and `has_self_validation`. Use `derived` to answer 'what kind of run was this?' instead of parsing the `summary` prose. Note the flags describe the reports the run authored as they stand now, so charts attached to someone else's report via an edit are not counted. A missing `derived` object is unknown, not all-false: the run predates the field, never finalized, or its stamp failed.+ * Scout-owned per-run context, in two regions. Top-level keys are stamped by the runner at run start. Always present: `harness_prompt_version` (id of the harness prompt build the run was given), `report_channel` (which report tools the run held: `none`, `emit`, `edit`, or `both`), `skill_origin` (`canonical` or `custom`), `github_guidance` (whether the run got the GitHub evidence section), and `business_knowledge_maintained` (whether the run got the business-knowledge section: the product flag is on and the team's knowledge base looks maintained) — the provenance set that says which instructions the run actually got, so runs are only compared against runs of the same shape. Present only when the run departed from a default: `model`, `runtime_adapter`, and `reasoning_effort` (routing overrode the agent-server default), `network_access` (`full` when the scout's config lifted the trusted-domain network restriction for this run), and `triggered_by` (`manual` or `workflow` when the run was fired off-schedule; absent means the run came from the coordinator's schedule). The nested `derived` object is the harness's own map of boolean run dimensions, computed server-side at finalize: `has_emit_report`, `has_edit_report`, `has_self_improvement`, `has_chart`, and `has_self_validation`. Use `derived` to answer 'what kind of run was this?' instead of parsing the `summary` prose. Note the flags describe the reports the run authored as they stand now, so charts attached to someone else's report via an edit are not counted. A missing `derived` object is unknown, not all-false: the run predates the field, never finalized, or its stamp failed.*/export type SignalScoutRunSummaryMetadata = {harness_prompt_version?: string;@@ -77125,6 +77128,7 @@ export namespace Schemas {runtime_adapter?: string;reasoning_effort?: string;network_access?: string;+ triggered_by?: string;derived?: SignalScoutRunSummaryMetadataDerived;[key: string]: unknown;};@@ -77194,7 +77198,7 @@ export namespace Schemas {emitted_report_ids: string[];/** The `SignalReport` ids this run mutated via the `edit_report` channel (rewrote title/summary and/or appended a note), deduped. Distinct from `emitted_report_ids`: edit can target any inbox report, so these are generally not reports the run authored. Empty for runs that edited no report. */edited_report_ids: string[];- /** Scout-owned per-run context, in two regions. Top-level keys are stamped by the runner at run start. Always present: `harness_prompt_version` (id of the harness prompt build the run was given), `report_channel` (which report tools the run held: `none`, `emit`, `edit`, or `both`), `skill_origin` (`canonical` or `custom`), `github_guidance` (whether the run got the GitHub evidence section), and `business_knowledge_maintained` (whether the run got the business-knowledge section: the product flag is on and the team's knowledge base looks maintained) — the provenance set that says which instructions the run actually got, so runs are only compared against runs of the same shape. Present only when the run departed from a default: `model`, `runtime_adapter`, and `reasoning_effort` (routing overrode the agent-server default), and `network_access` (`full` when the scout's config lifted the trusted-domain network restriction for this run). The nested `derived` object is the harness's own map of boolean run dimensions, computed server-side at finalize: `has_emit_report`, `has_edit_report`, `has_self_improvement`, `has_chart`, and `has_self_validation`. Use `derived` to answer 'what kind of run was this?' instead of parsing the `summary` prose. Note the flags describe the reports the run authored as they stand now, so charts attached to someone else's report via an edit are not counted. A missing `derived` object is unknown, not all-false: the run predates the field, never finalized, or its stamp failed. */+ /** Scout-owned per-run context, in two regions. Top-level keys are stamped by the runner at run start. Always present: `harness_prompt_version` (id of the harness prompt build the run was given), `report_channel` (which report tools the run held: `none`, `emit`, `edit`, or `both`), `skill_origin` (`canonical` or `custom`), `github_guidance` (whether the run got the GitHub evidence section), and `business_knowledge_maintained` (whether the run got the business-knowledge section: the product flag is on and the team's knowledge base looks maintained) — the provenance set that says which instructions the run actually got, so runs are only compared against runs of the same shape. Present only when the run departed from a default: `model`, `runtime_adapter`, and `reasoning_effort` (routing overrode the agent-server default), `network_access` (`full` when the scout's config lifted the trusted-domain network restriction for this run), and `triggered_by` (`manual` or `workflow` when the run was fired off-schedule; absent means the run came from the coordinator's schedule). The nested `derived` object is the harness's own map of boolean run dimensions, computed server-side at finalize: `has_emit_report`, `has_edit_report`, `has_self_improvement`, `has_chart`, and `has_self_validation`. Use `derived` to answer 'what kind of run was this?' instead of parsing the `summary` prose. Note the flags describe the reports the run authored as they stand now, so charts attached to someone else's report via an edit are not counted. A missing `derived` object is unknown, not all-false: the run predates the field, never finalized, or its stamp failed. */metadata: SignalScoutRunSummaryMetadata;}diff --git a/services/mcp/src/generated/cdp_functions/api.ts b/services/mcp/src/generated/cdp_functions/api.tsindex 5e14927ad0f9..f68506dd6d6c 100644--- a/services/mcp/src/generated/cdp_functions/api.ts+++ b/services/mcp/src/generated/cdp_functions/api.ts@@ -108,9 +108,10 @@ export const HogFunctionsCreateBody = /* @__PURE__ */ zod.object({'task_model','task_repository','task_mcp_installations',+ 'signals_scout',]).describe(- '\* `string` - string\n\* `number` - number\n\* `boolean` - boolean\n\* `dictionary` - dictionary\n\* `choice` - choice\n\* `json` - json\n\* `integration` - integration\n\* `integration_multi` - integration_multi\n\* `integration_field` - integration_field\n\* `email` - email\n\* `native_email` - native_email\n\* `posthog_assignee` - posthog_assignee\n\* `posthog_ticket_tags` - posthog_ticket_tags\n\* `posthog_business_hours` - posthog_business_hours\n\* `non_failure_status_codes` - non_failure_status_codes\n\* `customer_analytics_account_properties` - customer_analytics_account_properties\n\* `customer_analytics_account_relationships` - customer_analytics_account_relationships\n\* `task_model` - task_model\n\* `task_repository` - task_repository\n\* `task_mcp_installations` - task_mcp_installations'+ '\* `string` - string\n\* `number` - number\n\* `boolean` - boolean\n\* `dictionary` - dictionary\n\* `choice` - choice\n\* `json` - json\n\* `integration` - integration\n\* `integration_multi` - integration_multi\n\* `integration_field` - integration_field\n\* `email` - email\n\* `native_email` - native_email\n\* `posthog_assignee` - posthog_assignee\n\* `posthog_ticket_tags` - posthog_ticket_tags\n\* `posthog_business_hours` - posthog_business_hours\n\* `non_failure_status_codes` - non_failure_status_codes\n\* `customer_analytics_account_properties` - customer_analytics_account_properties\n\* `customer_analytics_account_relationships` - customer_analytics_account_relationships\n\* `task_model` - task_model\n\* `task_repository` - task_repository\n\* `task_mcp_installations` - task_mcp_installations\n\* `signals_scout` - signals_scout'),key: zod.string(),label: zod.string().optional(),@@ -199,9 +200,10 @@ export const HogFunctionsCreateBody = /* @__PURE__ */ zod.object({'task_model','task_repository','task_mcp_installations',+ 'signals_scout',]).describe(- '\* `string` - string\n\* `number` - number\n\* `boolean` - boolean\n\* `dictionary` - dictionary\n\* `choice` - choice\n\* `json` - json\n\* `integration` - integration\n\* `integration_multi` - integration_multi\n\* `integration_field` - integration_field\n\* `email` - email\n\* `native_email` - native_email\n\* `posthog_assignee` - posthog_assignee\n\* `posthog_ticket_tags` - posthog_ticket_tags\n\* `posthog_business_hours` - posthog_business_hours\n\* `non_failure_status_codes` - non_failure_status_codes\n\* `customer_analytics_account_properties` - customer_analytics_account_properties\n\* `customer_analytics_account_relationships` - customer_analytics_account_relationships\n\* `task_model` - task_model\n\* `task_repository` - task_repository\n\* `task_mcp_installations` - task_mcp_installations'+ '\* `string` - string\n\* `number` - number\n\* `boolean` - boolean\n\* `dictionary` - dictionary\n\* `choice` - choice\n\* `json` - json\n\* `integration` - integration\n\* `integration_multi` - integration_multi\n\* `integration_field` - integration_field\n\* `email` - email\n\* `native_email` - native_email\n\* `posthog_assignee` - posthog_assignee\n\* `posthog_ticket_tags` - posthog_ticket_tags\n\* `posthog_business_hours` - posthog_business_hours\n\* `non_failure_status_codes` - non_failure_status_codes\n\* `customer_analytics_account_properties` - customer_analytics_account_properties\n\* `customer_analytics_account_relationships` - customer_analytics_account_relationships\n\* `task_model` - task_model\n\* `task_repository` - task_repository\n\* `task_mcp_installations` - task_mcp_installations\n\* `signals_scout` - signals_scout'),key: zod.string(),label: zod.string().optional(),@@ -367,9 +369,10 @@ export const HogFunctionsPartialUpdateBody = /* @__PURE__ */ zod.object({'task_model','task_repository','task_mcp_installations',+ 'signals_scout',]).describe(- '\* `string` - string\n\* `number` - number\n\* `boolean` - boolean\n\* `dictionary` - dictionary\n\* `choice` - choice\n\* `json` - json\n\* `integration` - integration\n\* `integration_multi` - integration_multi\n\* `integration_field` - integration_field\n\* `email` - email\n\* `native_email` - native_email\n\* `posthog_assignee` - posthog_assignee\n\* `posthog_ticket_tags` - posthog_ticket_tags\n\* `posthog_business_hours` - posthog_business_hours\n\* `non_failure_status_codes` - non_failure_status_codes\n\* `customer_analytics_account_properties` - customer_analytics_account_properties\n\* `customer_analytics_account_relationships` - customer_analytics_account_relationships\n\* `task_model` - task_model\n\* `task_repository` - task_repository\n\* `task_mcp_installations` - task_mcp_installations'+ '\* `string` - string\n\* `number` - number\n\* `boolean` - boolean\n\* `dictionary` - dictionary\n\* `choice` - choice\n\* `json` - json\n\* `integration` - integration\n\* `integration_multi` - integration_multi\n\* `integration_field` - integration_field\n\* `email` - email\n\* `native_email` - native_email\n\* `posthog_assignee` - posthog_assignee\n\* `posthog_ticket_tags` - posthog_ticket_tags\n\* `posthog_business_hours` - posthog_business_hours\n\* `non_failure_status_codes` - non_failure_status_codes\n\* `customer_analytics_account_properties` - customer_analytics_account_properties\n\* `customer_analytics_account_relationships` - customer_analytics_account_relationships\n\* `task_model` - task_model\n\* `task_repository` - task_repository\n\* `task_mcp_installations` - task_mcp_installations\n\* `signals_scout` - signals_scout'),key: zod.string(),label: zod.string().optional(),@@ -458,9 +461,10 @@ export const HogFunctionsPartialUpdateBody = /* @__PURE__ */ zod.object({'task_model','task_repository','task_mcp_installations',+ 'signals_scout',]).describe(- '\* `string` - string\n\* `number` - number\n\* `boolean` - boolean\n\* `dictionary` - dictionary\n\* `choice` - choice\n\* `json` - json\n\* `integration` - integration\n\* `integration_multi` - integration_multi\n\* `integration_field` - integration_field\n\* `email` - email\n\* `native_email` - native_email\n\* `posthog_assignee` - posthog_assignee\n\* `posthog_ticket_tags` - posthog_ticket_tags\n\* `posthog_business_hours` - posthog_business_hours\n\* `non_failure_status_codes` - non_failure_status_codes\n\* `customer_analytics_account_properties` - customer_analytics_account_properties\n\* `customer_analytics_account_relationships` - customer_analytics_account_relationships\n\* `task_model` - task_model\n\* `task_repository` - task_repository\n\* `task_mcp_installations` - task_mcp_installations'+ '\* `string` - string\n\* `number` - number\n\* `boolean` - boolean\n\* `dictionary` - dictionary\n\* `choice` - choice\n\* `json` - json\n\* `integration` - integration\n\* `integration_multi` - integration_multi\n\* `integration_field` - integration_field\n\* `email` - email\n\* `native_email` - native_email\n\* `posthog_assignee` - posthog_assignee\n\* `posthog_ticket_tags` - posthog_ticket_tags\n\* `posthog_business_hours` - posthog_business_hours\n\* `non_failure_status_codes` - non_failure_status_codes\n\* `customer_analytics_account_properties` - customer_analytics_account_properties\n\* `customer_analytics_account_relationships` - customer_analytics_account_relationships\n\* `task_model` - task_model\n\* `task_repository` - task_repository\n\* `task_mcp_installations` - task_mcp_installations\n\* `signals_scout` - signals_scout'),key: zod.string(),label: zod.string().optional(),@@ -717,9 +721,10 @@ export const HogFunctionsInvocationsCreateBody = /* @__PURE__ */ zod.object({'task_model','task_repository','task_mcp_installations',+ 'signals_scout',]).describe(- '\* `string` - string\n\* `number` - number\n\* `boolean` - boolean\n\* `dictionary` - dictionary\n\* `choice` - choice\n\* `json` - json\n\* `integration` - integration\n\* `integration_multi` - integration_multi\n\* `integration_field` - integration_field\n\* `email` - email\n\* `native_email` - native_email\n\* `posthog_assignee` - posthog_assignee\n\* `posthog_ticket_tags` - posthog_ticket_tags\n\* `posthog_business_hours` - posthog_business_hours\n\* `non_failure_status_codes` - non_failure_status_codes\n\* `customer_analytics_account_properties` - customer_analytics_account_properties\n\* `customer_analytics_account_relationships` - customer_analytics_account_relationships\n\* `task_model` - task_model\n\* `task_repository` - task_repository\n\* `task_mcp_installations` - task_mcp_installations'+ '\* `string` - string\n\* `number` - number\n\* `boolean` - boolean\n\* `dictionary` - dictionary\n\* `choice` - choice\n\* `json` - json\n\* `integration` - integration\n\* `integration_multi` - integration_multi\n\* `integration_field` - integration_field\n\* `email` - email\n\* `native_email` - native_email\n\* `posthog_assignee` - posthog_assignee\n\* `posthog_ticket_tags` - posthog_ticket_tags\n\* `posthog_business_hours` - posthog_business_hours\n\* `non_failure_status_codes` - non_failure_status_codes\n\* `customer_analytics_account_properties` - customer_analytics_account_properties\n\* `customer_analytics_account_relationships` - customer_analytics_account_relationships\n\* `task_model` - task_model\n\* `task_repository` - task_repository\n\* `task_mcp_installations` - task_mcp_installations\n\* `signals_scout` - signals_scout'),key: zod.string(),label: zod.string().optional(),@@ -835,9 +840,10 @@ export const HogFunctionsInvocationsCreateBody = /* @__PURE__ */ zod.object({'task_model','task_repository','task_mcp_installations',+ 'signals_scout',]).describe(- '\* `string` - string\n\* `number` - number\n\* `boolean` - boolean\n\* `dictionary` - dictionary\n\* `choice` - choice\n\* `json` - json\n\* `integration` - integration\n\* `integration_multi` - integration_multi\n\* `integration_field` - integration_field\n\* `email` - email\n\* `native_email` - native_email\n\* `posthog_assignee` - posthog_assignee\n\* `posthog_ticket_tags` - posthog_ticket_tags\n\* `posthog_business_hours` - posthog_business_hours\n\* `non_failure_status_codes` - non_failure_status_codes\n\* `customer_analytics_account_properties` - customer_analytics_account_properties\n\* `customer_analytics_account_relationships` - customer_analytics_account_relationships\n\* `task_model` - task_model\n\* `task_repository` - task_repository\n\* `task_mcp_installations` - task_mcp_installations'+ '\* `string` - string\n\* `number` - number\n\* `boolean` - boolean\n\* `dictionary` - dictionary\n\* `choice` - choice\n\* `json` - json\n\* `integration` - integration\n\* `integration_multi` - integration_multi\n\* `integration_field` - integration_field\n\* `email` - email\n\* `native_email` - native_email\n\* `posthog_assignee` - posthog_assignee\n\* `posthog_ticket_tags` - posthog_ticket_tags\n\* `posthog_business_hours` - posthog_business_hours\n\* `non_failure_status_codes` - non_failure_status_codes\n\* `customer_analytics_account_properties` - customer_analytics_account_properties\n\* `customer_analytics_account_relationships` - customer_analytics_account_relationships\n\* `task_model` - task_model\n\* `task_repository` - task_repository\n\* `task_mcp_installations` - task_mcp_installations\n\* `signals_scout` - signals_scout'),key: zod.string(),label: zod.string().optional(),diff --git a/services/mcp/src/generated/error_tracking_alerts/api.ts b/services/mcp/src/generated/error_tracking_alerts/api.tsindex 91dfe46a228a..466cfd29a04f 100644--- a/services/mcp/src/generated/error_tracking_alerts/api.ts+++ b/services/mcp/src/generated/error_tracking_alerts/api.ts@@ -108,9 +108,10 @@ export const HogFunctionsCreateBody = /* @__PURE__ */ zod.object({'task_model','task_repository','task_mcp_installations',+ 'signals_scout',]).describe(- '\* `string` - string\n\* `number` - number\n\* `boolean` - boolean\n\* `dictionary` - dictionary\n\* `choice` - choice\n\* `json` - json\n\* `integration` - integration\n\* `integration_multi` - integration_multi\n\* `integration_field` - integration_field\n\* `email` - email\n\* `native_email` - native_email\n\* `posthog_assignee` - posthog_assignee\n\* `posthog_ticket_tags` - posthog_ticket_tags\n\* `posthog_business_hours` - posthog_business_hours\n\* `non_failure_status_codes` - non_failure_status_codes\n\* `customer_analytics_account_properties` - customer_analytics_account_properties\n\* `customer_analytics_account_relationships` - customer_analytics_account_relationships\n\* `task_model` - task_model\n\* `task_repository` - task_repository\n\* `task_mcp_installations` - task_mcp_installations'+ '\* `string` - string\n\* `number` - number\n\* `boolean` - boolean\n\* `dictionary` - dictionary\n\* `choice` - choice\n\* `json` - json\n\* `integration` - integration\n\* `integration_multi` - integration_multi\n\* `integration_field` - integration_field\n\* `email` - email\n\* `native_email` - native_email\n\* `posthog_assignee` - posthog_assignee\n\* `posthog_ticket_tags` - posthog_ticket_tags\n\* `posthog_business_hours` - posthog_business_hours\n\* `non_failure_status_codes` - non_failure_status_codes\n\* `customer_analytics_account_properties` - customer_analytics_account_properties\n\* `customer_analytics_account_relationships` - customer_analytics_account_relationships\n\* `task_model` - task_model\n\* `task_repository` - task_repository\n\* `task_mcp_installations` - task_mcp_installations\n\* `signals_scout` - signals_scout'),key: zod.string(),label: zod.string().optional(),@@ -199,9 +200,10 @@ export const HogFunctionsCreateBody = /* @__PURE__ */ zod.object({'task_model','task_repository','task_mcp_installations',+ 'signals_scout',]).describe(- '\* `string` - string\n\* `number` - number\n\* `boolean` - boolean\n\* `dictionary` - dictionary\n\* `choice` - choice\n\* `json` - json\n\* `integration` - integration\n\* `integration_multi` - integration_multi\n\* `integration_field` - integration_field\n\* `email` - email\n\* `native_email` - native_email\n\* `posthog_assignee` - posthog_assignee\n\* `posthog_ticket_tags` - posthog_ticket_tags\n\* `posthog_business_hours` - posthog_business_hours\n\* `non_failure_status_codes` - non_failure_status_codes\n\* `customer_analytics_account_properties` - customer_analytics_account_properties\n\* `customer_analytics_account_relationships` - customer_analytics_account_relationships\n\* `task_model` - task_model\n\* `task_repository` - task_repository\n\* `task_mcp_installations` - task_mcp_installations'+ '\* `string` - string\n\* `number` - number\n\* `boolean` - boolean\n\* `dictionary` - dictionary\n\* `choice` - choice\n\* `json` - json\n\* `integration` - integration\n\* `integration_multi` - integration_multi\n\* `integration_field` - integration_field\n\* `email` - email\n\* `native_email` - native_email\n\* `posthog_assignee` - posthog_assignee\n\* `posthog_ticket_tags` - posthog_ticket_tags\n\* `posthog_business_hours` - posthog_business_hours\n\* `non_failure_status_codes` - non_failure_status_codes\n\* `customer_analytics_account_properties` - customer_analytics_account_properties\n\* `customer_analytics_account_relationships` - customer_analytics_account_relationships\n\* `task_model` - task_model\n\* `task_repository` - task_repository\n\* `task_mcp_installations` - task_mcp_installations\n\* `signals_scout` - signals_scout'),key: zod.string(),label: zod.string().optional(),@@ -358,9 +360,10 @@ export const HogFunctionsPartialUpdateBody = /* @__PURE__ */ zod.object({'task_model','task_repository','task_mcp_installations',+ 'signals_scout',]).describe(- '\* `string` - string\n\* `number` - number\n\* `boolean` - boolean\n\* `dictionary` - dictionary\n\* `choice` - choice\n\* `json` - json\n\* `integration` - integration\n\* `integration_multi` - integration_multi\n\* `integration_field` - integration_field\n\* `email` - email\n\* `native_email` - native_email\n\* `posthog_assignee` - posthog_assignee\n\* `posthog_ticket_tags` - posthog_ticket_tags\n\* `posthog_business_hours` - posthog_business_hours\n\* `non_failure_status_codes` - non_failure_status_codes\n\* `customer_analytics_account_properties` - customer_analytics_account_properties\n\* `customer_analytics_account_relationships` - customer_analytics_account_relationships\n\* `task_model` - task_model\n\* `task_repository` - task_repository\n\* `task_mcp_installations` - task_mcp_installations'+ '\* `string` - string\n\* `number` - number\n\* `boolean` - boolean\n\* `dictionary` - dictionary\n\* `choice` - choice\n\* `json` - json\n\* `integration` - integration\n\* `integration_multi` - integration_multi\n\* `integration_field` - integration_field\n\* `email` - email\n\* `native_email` - native_email\n\* `posthog_assignee` - posthog_assignee\n\* `posthog_ticket_tags` - posthog_ticket_tags\n\* `posthog_business_hours` - posthog_business_hours\n\* `non_failure_status_codes` - non_failure_status_codes\n\* `customer_analytics_account_properties` - customer_analytics_account_properties\n\* `customer_analytics_account_relationships` - customer_analytics_account_relationships\n\* `task_model` - task_model\n\* `task_repository` - task_repository\n\* `task_mcp_installations` - task_mcp_installations\n\* `signals_scout` - signals_scout'),key: zod.string(),label: zod.string().optional(),@@ -449,9 +452,10 @@ export const HogFunctionsPartialUpdateBody = /* @__PURE__ */ zod.object({'task_model','task_repository','task_mcp_installations',+ 'signals_scout',]).describe(- '\* `string` - string\n\* `number` - number\n\* `boolean` - boolean\n\* `dictionary` - dictionary\n\* `choice` - choice\n\* `json` - json\n\* `integration` - integration\n\* `integration_multi` - integration_multi\n\* `integration_field` - integration_field\n\* `email` - email\n\* `native_email` - native_email\n\* `posthog_assignee` - posthog_assignee\n\* `posthog_ticket_tags` - posthog_ticket_tags\n\* `posthog_business_hours` - posthog_business_hours\n\* `non_failure_status_codes` - non_failure_status_codes\n\* `customer_analytics_account_properties` - customer_analytics_account_properties\n\* `customer_analytics_account_relationships` - customer_analytics_account_relationships\n\* `task_model` - task_model\n\* `task_repository` - task_repository\n\* `task_mcp_installations` - task_mcp_installations'+ '\* `string` - string\n\* `number` - number\n\* `boolean` - boolean\n\* `dictionary` - dictionary\n\* `choice` - choice\n\* `json` - json\n\* `integration` - integration\n\* `integration_multi` - integration_multi\n\* `integration_field` - integration_field\n\* `email` - email\n\* `native_email` - native_email\n\* `posthog_assignee` - posthog_assignee\n\* `posthog_ticket_tags` - posthog_ticket_tags\n\* `posthog_business_hours` - posthog_business_hours\n\* `non_failure_status_codes` - non_failure_status_codes\n\* `customer_analytics_account_properties` - customer_analytics_account_properties\n\* `customer_analytics_account_relationships` - customer_analytics_account_relationships\n\* `task_model` - task_model\n\* `task_repository` - task_repository\n\* `task_mcp_installations` - task_mcp_installations\n\* `signals_scout` - signals_scout'),key: zod.string(),label: zod.string().optional(),diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/cdp-functions-create.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/cdp-functions-create.jsonindex 2345a1272f79..2a37e079c7ff 100644--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/cdp-functions-create.json+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/cdp-functions-create.json@@ -175,7 +175,7 @@]},"type": {- "description": "* `string` - string\n* `number` - number\n* `boolean` - boolean\n* `dictionary` - dictionary\n* `choice` - choice\n* `json` - json\n* `integration` - integration\n* `integration_multi` - integration_multi\n* `integration_field` - integration_field\n* `email` - email\n* `native_email` - native_email\n* `posthog_assignee` - posthog_assignee\n* `posthog_ticket_tags` - posthog_ticket_tags\n* `posthog_business_hours` - posthog_business_hours\n* `non_failure_status_codes` - non_failure_status_codes\n* `customer_analytics_account_properties` - customer_analytics_account_properties\n* `customer_analytics_account_relationships` - customer_analytics_account_relationships\n* `task_model` - task_model\n* `task_repository` - task_repository\n* `task_mcp_installations` - task_mcp_installations",+ "description": "* `string` - string\n* `number` - number\n* `boolean` - boolean\n* `dictionary` - dictionary\n* `choice` - choice\n* `json` - json\n* `integration` - integration\n* `integration_multi` - integration_multi\n* `integration_field` - integration_field\n* `email` - email\n* `native_email` - native_email\n* `posthog_assignee` - posthog_assignee\n* `posthog_ticket_tags` - posthog_ticket_tags\n* `posthog_business_hours` - posthog_business_hours\n* `non_failure_status_codes` - non_failure_status_codes\n* `customer_analytics_account_properties` - customer_analytics_account_properties\n* `customer_analytics_account_relationships` - customer_analytics_account_relationships\n* `task_model` - task_model\n* `task_repository` - task_repository\n* `task_mcp_installations` - task_mcp_installations\n* `signals_scout` - signals_scout","enum": ["string","number",@@ -196,7 +196,8 @@"customer_analytics_account_relationships","task_model","task_repository",- "task_mcp_installations"+ "task_mcp_installations",+ "signals_scout"],"type": "string"}@@ -346,7 +347,7 @@]},"type": {- "description": "* `string` - string\n* `number` - number\n* `boolean` - boolean\n* `dictionary` - dictionary\n* `choice` - choice\n* `json` - json\n* `integration` - integration\n* `integration_multi` - integration_multi\n* `integration_field` - integration_field\n* `email` - email\n* `native_email` - native_email\n* `posthog_assignee` - posthog_assignee\n* `posthog_ticket_tags` - posthog_ticket_tags\n* `posthog_business_hours` - posthog_business_hours\n* `non_failure_status_codes` - non_failure_status_codes\n* `customer_analytics_account_properties` - customer_analytics_account_properties\n* `customer_analytics_account_relationships` - customer_analytics_account_relationships\n* `task_model` - task_model\n* `task_repository` - task_repository\n* `task_mcp_installations` - task_mcp_installations",+ "description": "* `string` - string\n* `number` - number\n* `boolean` - boolean\n* `dictionary` - dictionary\n* `choice` - choice\n* `json` - json\n* `integration` - integration\n* `integration_multi` - integration_multi\n* `integration_field` - integration_field\n* `email` - email\n* `native_email` - native_email\n* `posthog_assignee` - posthog_assignee\n* `posthog_ticket_tags` - posthog_ticket_tags\n* `posthog_business_hours` - posthog_business_hours\n* `non_failure_status_codes` - non_failure_status_codes\n* `customer_analytics_account_properties` - customer_analytics_account_properties\n* `customer_analytics_account_relationships` - customer_analytics_account_relationships\n* `task_model` - task_model\n* `task_repository` - task_repository\n* `task_mcp_installations` - task_mcp_installations\n* `signals_scout` - signals_scout","enum": ["string","number",@@ -367,7 +368,8 @@"customer_analytics_account_relationships","task_model","task_repository",- "task_mcp_installations"+ "task_mcp_installations",+ "signals_scout"],"type": "string"}diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/cdp-functions-invocations-create.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/cdp-functions-invocations-create.jsonindex 7b5df04afa73..60b48f72695b 100644--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/cdp-functions-invocations-create.json+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/cdp-functions-invocations-create.json@@ -341,7 +341,7 @@]},"type": {- "description": "* `string` - string\n* `number` - number\n* `boolean` - boolean\n* `dictionary` - dictionary\n* `choice` - choice\n* `json` - json\n* `integration` - integration\n* `integration_multi` - integration_multi\n* `integration_field` - integration_field\n* `email` - email\n* `native_email` - native_email\n* `posthog_assignee` - posthog_assignee\n* `posthog_ticket_tags` - posthog_ticket_tags\n* `posthog_business_hours` - posthog_business_hours\n* `non_failure_status_codes` - non_failure_status_codes\n* `customer_analytics_account_properties` - customer_analytics_account_properties\n* `customer_analytics_account_relationships` - customer_analytics_account_relationships\n* `task_model` - task_model\n* `task_repository` - task_repository\n* `task_mcp_installations` - task_mcp_installations",+ "description": "* `string` - string\n* `number` - number\n* `boolean` - boolean\n* `dictionary` - dictionary\n* `choice` - choice\n* `json` - json\n* `integration` - integration\n* `integration_multi` - integration_multi\n* `integration_field` - integration_field\n* `email` - email\n* `native_email` - native_email\n* `posthog_assignee` - posthog_assignee\n* `posthog_ticket_tags` - posthog_ticket_tags\n* `posthog_business_hours` - posthog_business_hours\n* `non_failure_status_codes` - non_failure_status_codes\n* `customer_analytics_account_properties` - customer_analytics_account_properties\n* `customer_analytics_account_relationships` - customer_analytics_account_relationships\n* `task_model` - task_model\n* `task_repository` - task_repository\n* `task_mcp_installations` - task_mcp_installations\n* `signals_scout` - signals_scout","enum": ["string","number",@@ -362,7 +362,8 @@"customer_analytics_account_relationships","task_model","task_repository",- "task_mcp_installations"+ "task_mcp_installations",+ "signals_scout"],"type": "string"}@@ -532,7 +533,7 @@]},"type": {- "description": "* `string` - string\n* `number` - number\n* `boolean` - boolean\n* `dictionary` - dictionary\n* `choice` - choice\n* `json` - json\n* `integration` - integration\n* `integration_multi` - integration_multi\n* `integration_field` - integration_field\n* `email` - email\n* `native_email` - native_email\n* `posthog_assignee` - posthog_assignee\n* `posthog_ticket_tags` - posthog_ticket_tags\n* `posthog_business_hours` - posthog_business_hours\n* `non_failure_status_codes` - non_failure_status_codes\n* `customer_analytics_account_properties` - customer_analytics_account_properties\n* `customer_analytics_account_relationships` - customer_analytics_account_relationships\n* `task_model` - task_model\n* `task_repository` - task_repository\n* `task_mcp_installations` - task_mcp_installations",+ "description": "* `string` - string\n* `number` - number\n* `boolean` - boolean\n* `dictionary` - dictionary\n* `choice` - choice\n* `json` - json\n* `integration` - integration\n* `integration_multi` - integration_multi\n* `integration_field` - integration_field\n* `email` - email\n* `native_email` - native_email\n* `posthog_assignee` - posthog_assignee\n* `posthog_ticket_tags` - posthog_ticket_tags\n* `posthog_business_hours` - posthog_business_hours\n* `non_failure_status_codes` - non_failure_status_codes\n* `customer_analytics_account_properties` - customer_analytics_account_properties\n* `customer_analytics_account_relationships` - customer_analytics_account_relationships\n* `task_model` - task_model\n* `task_repository` - task_repository\n* `task_mcp_installations` - task_mcp_installations\n* `signals_scout` - signals_scout","enum": ["string","number",@@ -553,7 +554,8 @@"customer_analytics_account_relationships","task_model","task_repository",- "task_mcp_installations"+ "task_mcp_installations",+ "signals_scout"],"type": "string"}diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/cdp-functions-partial-update.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/cdp-functions-partial-update.jsonindex 57dbefd398b8..94bed77b8d38 100644--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/cdp-functions-partial-update.json+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/cdp-functions-partial-update.json@@ -185,7 +185,7 @@]},"type": {- "description": "* `string` - string\n* `number` - number\n* `boolean` - boolean\n* `dictionary` - dictionary\n* `choice` - choice\n* `json` - json\n* `integration` - integration\n* `integration_multi` - integration_multi\n* `integration_field` - integration_field\n* `email` - email\n* `native_email` - native_email\n* `posthog_assignee` - posthog_assignee\n* `posthog_ticket_tags` - posthog_ticket_tags\n* `posthog_business_hours` - posthog_business_hours\n* `non_failure_status_codes` - non_failure_status_codes\n* `customer_analytics_account_properties` - customer_analytics_account_properties\n* `customer_analytics_account_relationships` - customer_analytics_account_relationships\n* `task_model` - task_model\n* `task_repository` - task_repository\n* `task_mcp_installations` - task_mcp_installations",+ "description": "* `string` - string\n* `number` - number\n* `boolean` - boolean\n* `dictionary` - dictionary\n* `choice` - choice\n* `json` - json\n* `integration` - integration\n* `integration_multi` - integration_multi\n* `integration_field` - integration_field\n* `email` - email\n* `native_email` - native_email\n* `posthog_assignee` - posthog_assignee\n* `posthog_ticket_tags` - posthog_ticket_tags\n* `posthog_business_hours` - posthog_business_hours\n* `non_failure_status_codes` - non_failure_status_codes\n* `customer_analytics_account_properties` - customer_analytics_account_properties\n* `customer_analytics_account_relationships` - customer_analytics_account_relationships\n* `task_model` - task_model\n* `task_repository` - task_repository\n* `task_mcp_installations` - task_mcp_installations\n* `signals_scout` - signals_scout","enum": ["string","number",@@ -206,7 +206,8 @@"customer_analytics_account_relationships","task_model","task_repository",- "task_mcp_installations"+ "task_mcp_installations",+ "signals_scout"],"type": "string"}@@ -356,7 +357,7 @@]},"type": {- "description": "* `string` - string\n* `number` - number\n* `boolean` - boolean\n* `dictionary` - dictionary\n* `choice` - choice\n* `json` - json\n* `integration` - integration\n* `integration_multi` - integration_multi\n* `integration_field` - integration_field\n* `email` - email\n* `native_email` - native_email\n* `posthog_assignee` - posthog_assignee\n* `posthog_ticket_tags` - posthog_ticket_tags\n* `posthog_business_hours` - posthog_business_hours\n* `non_failure_status_codes` - non_failure_status_codes\n* `customer_analytics_account_properties` - customer_analytics_account_properties\n* `customer_analytics_account_relationships` - customer_analytics_account_relationships\n* `task_model` - task_model\n* `task_repository` - task_repository\n* `task_mcp_installations` - task_mcp_installations",+ "description": "* `string` - string\n* `number` - number\n* `boolean` - boolean\n* `dictionary` - dictionary\n* `choice` - choice\n* `json` - json\n* `integration` - integration\n* `integration_multi` - integration_multi\n* `integration_field` - integration_field\n* `email` - email\n* `native_email` - native_email\n* `posthog_assignee` - posthog_assignee\n* `posthog_ticket_tags` - posthog_ticket_tags\n* `posthog_business_hours` - posthog_business_hours\n* `non_failure_status_codes` - non_failure_status_codes\n* `customer_analytics_account_properties` - customer_analytics_account_properties\n* `customer_analytics_account_relationships` - customer_analytics_account_relationships\n* `task_model` - task_model\n* `task_repository` - task_repository\n* `task_mcp_installations` - task_mcp_installations\n* `signals_scout` - signals_scout","enum": ["string","number",@@ -377,7 +378,8 @@"customer_analytics_account_relationships","task_model","task_repository",- "task_mcp_installations"+ "task_mcp_installations",+ "signals_scout"],"type": "string"}diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/error-tracking-alerts-create.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/error-tracking-alerts-create.jsonindex 98eb05fd1052..935a292c0437 100644--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/error-tracking-alerts-create.json+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/error-tracking-alerts-create.json@@ -175,7 +175,7 @@]},"type": {- "description": "* `string` - string\n* `number` - number\n* `boolean` - boolean\n* `dictionary` - dictionary\n* `choice` - choice\n* `json` - json\n* `integration` - integration\n* `integration_multi` - integration_multi\n* `integration_field` - integration_field\n* `email` - email\n* `native_email` - native_email\n* `posthog_assignee` - posthog_assignee\n* `posthog_ticket_tags` - posthog_ticket_tags\n* `posthog_business_hours` - posthog_business_hours\n* `non_failure_status_codes` - non_failure_status_codes\n* `customer_analytics_account_properties` - customer_analytics_account_properties\n* `customer_analytics_account_relationships` - customer_analytics_account_relationships\n* `task_model` - task_model\n* `task_repository` - task_repository\n* `task_mcp_installations` - task_mcp_installations",+ "description": "* `string` - string\n* `number` - number\n* `boolean` - boolean\n* `dictionary` - dictionary\n* `choice` - choice\n* `json` - json\n* `integration` - integration\n* `integration_multi` - integration_multi\n* `integration_field` - integration_field\n* `email` - email\n* `native_email` - native_email\n* `posthog_assignee` - posthog_assignee\n* `posthog_ticket_tags` - posthog_ticket_tags\n* `posthog_business_hours` - posthog_business_hours\n* `non_failure_status_codes` - non_failure_status_codes\n* `customer_analytics_account_properties` - customer_analytics_account_properties\n* `customer_analytics_account_relationships` - customer_analytics_account_relationships\n* `task_model` - task_model\n* `task_repository` - task_repository\n* `task_mcp_installations` - task_mcp_installations\n* `signals_scout` - signals_scout","enum": ["string","number",@@ -196,7 +196,8 @@"customer_analytics_account_relationships","task_model","task_repository",- "task_mcp_installations"+ "task_mcp_installations",+ "signals_scout"],"type": "string"}@@ -346,7 +347,7 @@]},"type": {- "description": "* `string` - string\n* `number` - number\n* `boolean` - boolean\n* `dictionary` - dictionary\n* `choice` - choice\n* `json` - json\n* `integration` - integration\n* `integration_multi` - integration_multi\n* `integration_field` - integration_field\n* `email` - email\n* `native_email` - native_email\n* `posthog_assignee` - posthog_assignee\n* `posthog_ticket_tags` - posthog_ticket_tags\n* `posthog_business_hours` - posthog_business_hours\n* `non_failure_status_codes` - non_failure_status_codes\n* `customer_analytics_account_properties` - customer_analytics_account_properties\n* `customer_analytics_account_relationships` - customer_analytics_account_relationships\n* `task_model` - task_model\n* `task_repository` - task_repository\n* `task_mcp_installations` - task_mcp_installations",+ "description": "* `string` - string\n* `number` - number\n* `boolean` - boolean\n* `dictionary` - dictionary\n* `choice` - choice\n* `json` - json\n* `integration` - integration\n* `integration_multi` - integration_multi\n* `integration_field` - integration_field\n* `email` - email\n* `native_email` - native_email\n* `posthog_assignee` - posthog_assignee\n* `posthog_ticket_tags` - posthog_ticket_tags\n* `posthog_business_hours` - posthog_business_hours\n* `non_failure_status_codes` - non_failure_status_codes\n* `customer_analytics_account_properties` - customer_analytics_account_properties\n* `customer_analytics_account_relationships` - customer_analytics_account_relationships\n* `task_model` - task_model\n* `task_repository` - task_repository\n* `task_mcp_installations` - task_mcp_installations\n* `signals_scout` - signals_scout","enum": ["string","number",@@ -367,7 +368,8 @@"customer_analytics_account_relationships","task_model","task_repository",- "task_mcp_installations"+ "task_mcp_installations",+ "signals_scout"],"type": "string"}diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/error-tracking-alerts-partial-update.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/error-tracking-alerts-partial-update.jsonindex 7bc3ec18ac19..6571e41a5296 100644--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/error-tracking-alerts-partial-update.json+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/error-tracking-alerts-partial-update.json@@ -185,7 +185,7 @@]},"type": {- "description": "* `string` - string\n* `number` - number\n* `boolean` - boolean\n* `dictionary` - dictionary\n* `choice` - choice\n* `json` - json\n* `integration` - integration\n* `integration_multi` - integration_multi\n* `integration_field` - integration_field\n* `email` - email\n* `native_email` - native_email\n* `posthog_assignee` - posthog_assignee\n* `posthog_ticket_tags` - posthog_ticket_tags\n* `posthog_business_hours` - posthog_business_hours\n* `non_failure_status_codes` - non_failure_status_codes\n* `customer_analytics_account_properties` - customer_analytics_account_properties\n* `customer_analytics_account_relationships` - customer_analytics_account_relationships\n* `task_model` - task_model\n* `task_repository` - task_repository\n* `task_mcp_installations` - task_mcp_installations",+ "description": "* `string` - string\n* `number` - number\n* `boolean` - boolean\n* `dictionary` - dictionary\n* `choice` - choice\n* `json` - json\n* `integration` - integration\n* `integration_multi` - integration_multi\n* `integration_field` - integration_field\n* `email` - email\n* `native_email` - native_email\n* `posthog_assignee` - posthog_assignee\n* `posthog_ticket_tags` - posthog_ticket_tags\n* `posthog_business_hours` - posthog_business_hours\n* `non_failure_status_codes` - non_failure_status_codes\n* `customer_analytics_account_properties` - customer_analytics_account_properties\n* `customer_analytics_account_relationships` - customer_analytics_account_relationships\n* `task_model` - task_model\n* `task_repository` - task_repository\n* `task_mcp_installations` - task_mcp_installations\n* `signals_scout` - signals_scout","enum": ["string","number",@@ -206,7 +206,8 @@"customer_analytics_account_relationships","task_model","task_repository",- "task_mcp_installations"+ "task_mcp_installations",+ "signals_scout"],"type": "string"}@@ -356,7 +357,7 @@]},"type": {- "description": "* `string` - string\n* `number` - number\n* `boolean` - boolean\n* `dictionary` - dictionary\n* `choice` - choice\n* `json` - json\n* `integration` - integration\n* `integration_multi` - integration_multi\n* `integration_field` - integration_field\n* `email` - email\n* `native_email` - native_email\n* `posthog_assignee` - posthog_assignee\n* `posthog_ticket_tags` - posthog_ticket_tags\n* `posthog_business_hours` - posthog_business_hours\n* `non_failure_status_codes` - non_failure_status_codes\n* `customer_analytics_account_properties` - customer_analytics_account_properties\n* `customer_analytics_account_relationships` - customer_analytics_account_relationships\n* `task_model` - task_model\n* `task_repository` - task_repository\n* `task_mcp_installations` - task_mcp_installations",+ "description": "* `string` - string\n* `number` - number\n* `boolean` - boolean\n* `dictionary` - dictionary\n* `choice` - choice\n* `json` - json\n* `integration` - integration\n* `integration_multi` - integration_multi\n* `integration_field` - integration_field\n* `email` - email\n* `native_email` - native_email\n* `posthog_assignee` - posthog_assignee\n* `posthog_ticket_tags` - posthog_ticket_tags\n* `posthog_business_hours` - posthog_business_hours\n* `non_failure_status_codes` - non_failure_status_codes\n* `customer_analytics_account_properties` - customer_analytics_account_properties\n* `customer_analytics_account_relationships` - customer_analytics_account_relationships\n* `task_model` - task_model\n* `task_repository` - task_repository\n* `task_mcp_installations` - task_mcp_installations\n* `signals_scout` - signals_scout","enum": ["string","number",@@ -377,7 +378,8 @@"customer_analytics_account_relationships","task_model","task_repository",- "task_mcp_installations"+ "task_mcp_installations",+ "signals_scout"],"type": "string"}diff --git a/tach.toml b/tach.tomlindex 1026f39f9272..2dae2961c5d4 100644--- a/tach.toml+++ b/tach.toml@@ -983,6 +983,9 @@ depends_on = ["products.feature_flags","products.messaging","products.notifications",+ # Facade-only: the Run scout action's endpoint starts a scout run through+ # products.signals.backend.facade.api.+ "products.signals",# Facade-only: the AI task action's endpoint creates tasks through# products.tasks.backend.facade.workflow_tasks."products.tasks", "products.access_control",