Skip to content

[refactor] Group RunPlan by concern instead of one flat bag - #5702

Merged
mmabrouk merged 2 commits into
feat/daytona-secrets-v2from
refactor/run-plan-groups
Aug 3, 2026
Merged

[refactor] Group RunPlan by concern instead of one flat bag#5702
mmabrouk merged 2 commits into
feat/daytona-secrets-v2from
refactor/run-plan-groups

Conversation

@mmabrouk

@mmabrouk mmabrouk commented Aug 3, 2026

Copy link
Copy Markdown
Member

Context

RunPlan had grown to thirty fields on one flat interface, and every consumer took the whole thing regardless of how little of it they read. Raised in review of #5670: #5670 (comment)

This PR is stacked on feat/daytona-secrets-v2 (#5670) and its base is that branch, so the diff here is only the refactor.

Changes

The fields are grouped by concern into credentials, workspace, tools, and prompt, each exported as its own interface. Five identity fields stay at the top level because almost every consumer branches on them, and sandboxPermission stays there too since the declared security boundary is its own concern.

RunPlan {
  harness, acpAgent, sandboxId, isPi, isDaytona
  credentials: { modelEnvironment, daytonaSecretPlan?, harnessApiKeyVar, hasApiKey, credentialMode? }
  workspace:   { cwd, relayDir, toolMcpDir, usageOutPath?, skillDirs, skillsCleanup,
                 sourcePiAgentDir, harnessFiles? }
  tools:       { toolSpecs, executableToolSpecs, builtinGatingActive, useToolRelay,
                 clientToolPauseDisposition }
  prompt:      { text, turnText, agentsMd?, systemPrompt?, appendSystemPrompt?, hasSystemPrompt }
  sandboxPermission?
}

The real payoff is that consumers can now say what they touch. prepareWorkspace used to declare a nine-key Pick of the flat plan:

Before:

plan: Pick<RunPlan, "isDaytona" | "isPi" | "cwd" | "relayDir" | "useToolRelay"
                  | "agentsMd" | "acpAgent" | "harnessFiles" | "skillDirs">

After:

plan: Pick<RunPlan, "isDaytona" | "isPi" | "acpAgent"> & {
  workspace: Pick<RunPlanWorkspace, "cwd" | "relayDir" | "harnessFiles" | "skillDirs">
  tools: Pick<RunPlanTools, "useToolRelay">
  prompt: Pick<RunPlanPrompt, "agentsMd">
}

The parameter type now reads as a description of the function rather than an alphabet soup of field names. pi-assets.ts, codex-assets.ts, attachments.ts, and daytona.ts narrowed the same way. That means a future change to credential delivery has a compiler-checked list of what depends on it, which is the thing the flat bag made impossible.

The one rename is plan.prompt to plan.prompt.text, forced by the group taking the name.

Tests / notes

  • Runner tsc --noEmit is clean and the unit suite reports 99 files / 1535 tests, the same counts as before the change.
  • No logic, ordering, condition, or default changed. No any cast, @ts-ignore, or @ts-expect-error was added; verified by grepping the diff.
  • Test updates are purely the same field moves. No test was weakened or deleted.
  • Review suggestion: read run-plan.ts first for the new shape, then skim the rest as mechanical. The interesting files are the ones where a signature narrowed, since that is where the change earns its keep.

This is a pure refactor, so there is nothing to QA manually. If the runner suite is green and the type checker is clean, behavior is unchanged.

@dosubot dosubot Bot added size:XL This PR changes 500-999 lines, ignoring generated files. refactor A code change that neither fixes a bug nor adds a feature labels Aug 3, 2026
@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 20ffeb78-309e-4a06-b30f-fa2e2a154ec0

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@vercel

vercel Bot commented Aug 3, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
agenta-documentation Ready Ready Preview Aug 3, 2026 6:36pm

Request Review

@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Railway Preview Environment

Status Destroyed (PR closed)

Updated at 2026-08-03T19:07:42.858Z

`RunPlan` had grown to thirty fields on one flat interface, and every
consumer took the whole thing regardless of how little it read. Raised in
review of #5670.

The fields are grouped into `credentials`, `workspace`, `tools`, and `prompt`.
The five identity fields (`harness`, `acpAgent`, `sandboxId`, `isPi`,
`isDaytona`) stay at the top level because almost every consumer branches on
them, and `sandboxPermission` stays there too since the declared security
boundary is its own concern.

The payoff is not the tidier interface. It is that a consumer can now say what
it actually touches. `prepareWorkspace` used to take a nine-key `Pick` of the
flat plan; it now takes three named slices and the parameter type reads as a
description of the function. Several other consumers narrowed the same way,
which means a future change to, say, credential delivery has a compiler-checked
list of what depends on it.

The one rename is `plan.prompt` to `plan.prompt.text`, forced by the group
taking the name. Nothing else was renamed, no logic changed, and no `any` cast
or `@ts-expect-error` was added.

Runner tsc clean, 99 files / 1535 tests, the same counts as before the change.
@mmabrouk
mmabrouk force-pushed the refactor/run-plan-groups branch from 469f8e5 to a6879d8 Compare August 3, 2026 18:35
@mmabrouk
mmabrouk merged commit 929a46e into feat/daytona-secrets-v2 Aug 3, 2026
54 of 59 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor A code change that neither fixes a bug nor adds a feature size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant