refactor(programs): B2a move-only — shared helpers, bindings, program run data - #1342
Merged
Merged
Conversation
… into shared Four stateless leaves move into src/shared with no behavior change: the cleanup registry out of wizard-abort, the scan-consent helpers and DiscoveredFeature out of the session, buildRunTags out of the agent interface, and the ask policy and longer ask timeout out of the runner bootstrap and the ask bridge. Each old module re-exports what it gave up, so shouldDisableAsk and every other existing import keeps working. The run-tags test moves with its function. Generated-By: PostHog Desktop Task-Id: d14e92bb-6ee1-49b5-8502-39cb80079589
OAuthTokenResponseSchema, getOAuthClientId and refreshAccessToken need no UI, so they move from utils/oauth.ts into utils/oauth-token.ts with no behavior change. oauth.ts imports what its login flow uses and re-exports the schema, its type and refreshAccessToken for existing callers. Generated-By: PostHog Desktop Task-Id: d14e92bb-6ee1-49b5-8502-39cb80079589
…y-auth GatewayAuth, isPastRefresh, isTrustedGatewayUrl and buildWizardPropertiesBlob hold no mint state, so they move verbatim from agent/gateway-session.ts into shared/gateway-auth.ts. The mint, its cache and the CI credential loading stay where they are. gateway-session.ts imports what the mint uses and re-exports all four, so no caller changes. Generated-By: PostHog Desktop Task-Id: d14e92bb-6ee1-49b5-8502-39cb80079589
src/lib/file-watcher.ts moves unchanged to src/shared/file-watcher.ts. The audit ledger watcher, the event-plan watcher and the TUI hook import it from @shared, which drops two programs-to-legacy rows from the architecture allowlist. Generated-By: PostHog Desktop Task-Id: d14e92bb-6ee1-49b5-8502-39cb80079589
The pricing constants move unchanged from the self-driving deck into shared/self-driving-pricing.ts. The deck's pricing.ts re-exports them, so its importers keep their paths. Generated-By: PostHog Desktop Task-Id: d14e92bb-6ee1-49b5-8502-39cb80079589
SERVER_NAME and WIZARD_TOOL_NAMES move unchanged from tools/tools.ts into tools/tool-names.ts, a data-only module. tools.ts re-exports both, so every importer keeps its path. Generated-By: PostHog Desktop Task-Id: d14e92bb-6ee1-49b5-8502-39cb80079589
…ules Eight programs keep their run definitions, skill options and abort cases in their index or detect files. That data now lives in run.ts, abort-cases.ts and agent-skill/run-definition.ts, and each index imports it. The data is unchanged: every exported config, prompt and abort case resolves to the same values as before. The old modules re-export SkillProgramOptions and each abort-case list, so importers keep their paths. Generated-By: PostHog Desktop Task-Id: d14e92bb-6ee1-49b5-8502-39cb80079589
Generated-By: PostHog Desktop Task-Id: d14e92bb-6ee1-49b5-8502-39cb80079589
🧙 Wizard CIRun 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:
Test all apps in a directory:
Test an individual app:
Show more apps
Test against a Context Mill branch:
Add Results will be posted here when complete. |
Move program routing out of the agent: - PROGRAM_BINDINGS and resolveProgramBinding go to src/programs/binding.ts. - The flag experiments move from src/agent/runner/switchboard/flags to src/programs/experiments, with their tests. - The program-axis commandments go to src/programs/commandments.ts, and the switchboard telemetry to src/programs/binding-telemetry.ts. - The switchboard and variant-gating tests move to src/programs. - DEFAULT_AGENT_BINDING, in src/agent/default-binding.ts, is the route standalone callers pass. RunConfig drops switchboard. The caller passes what it already resolved: programCommandments, stageOverrides, seededTasksEnabled and binding.roleBindings. The orchestrator reads the role routes and the stage and seeded-task policy from them. Pi assembles the supplied commandments on both sequences, and Anthropic on task runs. Anthropic's linear run looked guidance up by the run label, which names no program, so it still gets none. The agent's resolveBinding and resolveHarness take the base binding and the flag route as data. Behavior is unchanged. For every program, across 22 flag and CLI cases, in dev, production and cloud-surface builds, the resolved binding, trace, role routes, stage overrides, seeded-task gate and commandments match the previous code. Generated-By: PostHog Desktop Task-Id: d14e92bb-6ee1-49b5-8502-39cb80079589
resolveHarness and resolveRoleHarness move from switchboard/harness.ts to switchboard/resolve-harness.ts, so harness.ts holds only the registry. The three-step middleware chain becomes straight-line code with the same precedence: binding, then the flag route, then the dev-build CLI model and harness overrides. The traces and log line are unchanged. HARNESS_RUNS_TASKS records which backends implement runTask, and the sequence capability clamp reads it through harnessRunsTasks instead of asking the live registry. Both backends implement runTask, so the clamp decides the same way. A registry test keeps the table in step with HARNESS_OPTIONS. The DEFAULT_BINDING alias goes, and the sequence resolver reads DEFAULT_AGENT_BINDING. Generated-By: PostHog Desktop Task-Id: d14e92bb-6ee1-49b5-8502-39cb80079589
resolveProgramBinding now resolves the sequence itself, so programs own the whole binding precedence. The agent keeps the harness axis. The middleware chain becomes straight-line code with the same order: the composed clamp, the dev-build CLI override, the runTask capability clamp, the flag route, the sequence experiment, then the base binding. The traces and log lines are unchanged. The agent's switchboard keeps the registries, resolveHarness, resolveRoleHarness and harnessRunsTasks. It drops resolveBinding, resolveSequence, runChain, and the flagSequence and orchestratorFlagOn context fields, which only programs read. @agent exports harnessRunsTasks beside resolveHarness in place of resolveBinding. Generated-By: PostHog Desktop Task-Id: d14e92bb-6ee1-49b5-8502-39cb80079589
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Scope: Moves only. Behavior preserved.
Problem
The callable program host (#1307) mixed pure code moves with behavior changes, which made it too large to review. This PR takes the moves out so #1307 shows only the host changes.
Stack: #1306 → this PR → #1307 → #1308 → #1309.
Changes
These are pure moves and extractions. Each old site re-exports what moved, so no caller changes and no behavior changes.
shared/utils/cleanup-registry.ts(fromwizard-abort.ts)shared/scan-consent.ts(fromwizard-session.ts)shared/run-tags.tsand its test (fromagent-interface.ts)shared/ask-policy.ts(frombootstrap.tsandwizard-ask-bridge.ts)shared/utils/oauth-token.ts(fromoauth.ts)shared/gateway-auth.ts(fromagent/gateway-session.ts)lib/file-watcher.ts→shared/file-watcher.ts, as a rename. This drops two allowlist rows.shared/self-driving-pricing.ts(from the TUI deck)agent/tools/tool-names.ts(fromtools.ts)index.tsintorun.ts,abort-cases.tsandrun-definition.ts.Test plan
pnpm typecheck,pnpm lint(0 errors) andpnpm vitest run(3,361 tests) pass at every commit. The architecture test passes, and the allowlist only loses rows.Created with PostHog Desktop