Skip to content

refactor: add shared run state, control types and run routing - #1377

Closed
gewenyu99 wants to merge 4 commits into
posthog/functional-r9-03-add-the-session-store-and-run-contract-tfrom
posthog/functional-r9-04-add-shared-run-state-control-types-and-r
Closed

gewenyu99 wants to merge 4 commits into
posthog/functional-r9-03-add-the-session-store-and-run-contract-tfrom
posthog/functional-r9-04-add-shared-run-state-control-types-and-r

Conversation

@gewenyu99

@gewenyu99 gewenyu99 commented Sep 29, 2026 •

Copy link
Copy Markdown
Collaborator

Phase 2 of Release C (#1320), PR 2 of 17, after #1376. Review PR. PRs 1 to 15 of this phase split one change into reviewable pieces and compile only as a stack: review them one by one, then land the whole phase together.

Problem

On main, types and helpers that several layers need live in the wrong place: RunOutcome and OutroData in the agent layer, the ask policy in its bootstrap, the MCP client installs in src/steps. A layer that must not import those cannot reach them.

Changes

New files, plus the test config.

  • Run state in src/shared: RunOutcome, RunPhase, ScanConsent and McpOutcome in run-state.ts, OutroData and OutroKind in outro.ts, TaskStatus in task-status.ts. The agent layer re-exports them in refactor: move the agent, programs, tui, hosts, tools and cli onto the session store #1378.
  • The control API's wire types in src/shared/control/types.ts (ControlTarget, ControlAction, ControlSetter, ControlHooks), with param checks in params.ts and state redaction in redact.ts.
  • Shared helpers: shouldDisableAsk (ask-policy.ts), consoleLog and printAbortOutro (console-log.ts), registerCleanup (utils/cleanup.ts), flushAnalytics, withScopeAdditions (oauth-scopes.ts), and the MCP client installs in mcp-clients/install.ts (addMCPServer, removeMCPServer, installPlugins).
  • resolveRunConfig (src/agent/runner/switchboard/resolve-run.ts) turns a run's routing into the ResolvedRunConfig the runner reads, and records the switchboard's pick.
  • vitest.config.ts: tools, headless and shared projects replace legacy, the @lib, @ui and @steps aliases go, tests write their own log file, and ink-actual maps the real Ink for tests that render.
  • Focus on resolveRunConfig, which decides the harness, sequence and model, and on redact.ts, which decides what a control parent may read.

Test plan

Created with PostHog Desktop

Generated-By: PostHog Desktop
Task-Id: d14e92bb-6ee1-49b5-8502-39cb80079589
Generated-By: PostHog Desktop
Task-Id: d14e92bb-6ee1-49b5-8502-39cb80079589
Generated-By: PostHog Desktop
Task-Id: d14e92bb-6ee1-49b5-8502-39cb80079589
Generated-By: PostHog Desktop
Task-Id: d14e92bb-6ee1-49b5-8502-39cb80079589
@github-actions

Copy link
Copy Markdown

🧙 Wizard CI

Run the Wizard CI and test your changes against wizard-workbench example apps by replying with a GitHub comment using one of the following commands:

Test all apps:

  • /wizard-ci all

Test all apps in a directory:

  • /wizard-ci ai-observability
  • /wizard-ci basic-integration
  • /wizard-ci feature-flags
  • /wizard-ci mcp-analytics
  • /wizard-ci replay-vision
  • /wizard-ci revenue
  • /wizard-ci self-driving
  • /wizard-ci warehouse
  • /wizard-ci warehouse-seeded

Test an individual app:

  • /wizard-ci ai-observability/anthropic
  • /wizard-ci ai-observability/google-adk
  • /wizard-ci ai-observability/groq
Show more apps
  • /wizard-ci ai-observability/manual-capture
  • /wizard-ci ai-observability/openai
  • /wizard-ci ai-observability/openai-agents
  • /wizard-ci ai-observability/opentelemetry
  • /wizard-ci ai-observability/vercel-ai
  • /wizard-ci basic-integration/android
  • /wizard-ci basic-integration/angular
  • /wizard-ci basic-integration/astro
  • /wizard-ci basic-integration/django
  • /wizard-ci basic-integration/fastapi
  • /wizard-ci basic-integration/flask
  • /wizard-ci basic-integration/flutter
  • /wizard-ci basic-integration/javascript-node
  • /wizard-ci basic-integration/javascript-web
  • /wizard-ci basic-integration/laravel
  • /wizard-ci basic-integration/next-js
  • /wizard-ci basic-integration/nuxt
  • /wizard-ci basic-integration/python
  • /wizard-ci basic-integration/rails
  • /wizard-ci basic-integration/react-native
  • /wizard-ci basic-integration/react-router
  • /wizard-ci basic-integration/sveltekit
  • /wizard-ci basic-integration/swift
  • /wizard-ci basic-integration/tanstack-router
  • /wizard-ci basic-integration/tanstack-start
  • /wizard-ci basic-integration/vue
  • /wizard-ci feature-flags/django
  • /wizard-ci feature-flags/next-js
  • /wizard-ci mcp-analytics/custom-dispatcher
  • /wizard-ci mcp-analytics/typescript-sdk
  • /wizard-ci replay-vision/javascript-node
  • /wizard-ci replay-vision/next-js
  • /wizard-ci replay-vision/react-vite
  • /wizard-ci revenue/stripe
  • /wizard-ci self-driving/astro
  • /wizard-ci self-driving/fastapi
  • /wizard-ci self-driving/nuxt
  • /wizard-ci self-driving/react-router
  • /wizard-ci self-driving/sveltekit
  • /wizard-ci warehouse/monorepo-env
  • /wizard-ci warehouse/multi-source-next
  • /wizard-ci warehouse/stripe-node
  • /wizard-ci warehouse/zero-source
  • /wizard-ci warehouse-seeded/next-stripe
  • /wizard-ci warehouse-seeded/next-stripe-declined

Test against a Context Mill branch:

  • /wizard-ci all context-mill:my-branch

Add context-mill:<branch> to any command above to pin the Context Mill branch. It defaults to main.

Results will be posted here when complete.

@gewenyu99
gewenyu99 added this pull request to stack #1394 September 29, 2026 09:41
@gewenyu99
gewenyu99 force-pushed the posthog/functional-r9-03-add-the-session-store-and-run-contract-t branch from 98e08dc to 176d272 Compare September 30, 2026 08:06
@gewenyu99
gewenyu99 removed this pull request from stack #1394 September 30, 2026 08:07
@gewenyu99
gewenyu99 force-pushed the posthog/functional-r9-03-add-the-session-store-and-run-contract-t branch from 176d272 to 4153102 Compare September 30, 2026 08:44
@gewenyu99

Copy link
Copy Markdown
Collaborator Author

Superseded: its files now move in #1375 and change in #1376 and #1378; the shared control types left with the control API. Branch kept.

@gewenyu99 gewenyu99 closed this Sep 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant