Execute recipes through a typed boundary - #2477
Merged
Merged
Conversation
Internal callers built CLI argument arrays, captured Codebox's own stdout, and reparsed the JSON to recover a result they already produced in process. Add executeRecipeRun() and createRecipeRunOptions() so agent-task and the WordPress workload/fuzz paths consume typed results directly. Accept an in-memory recipe so generated recipes no longer need temporary files, while recipePath remains the provenance and replay identity. runRecipeRunCommand() keeps every CLI-only concern: argument parsing, host heap replay, preview-lease children, heartbeats, stdout capture, rendering, output files, and exit codes.
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.
Part of #2431. This is a bounded first slice, not the full canonical request/result contract.
Problem
Internal callers reached Codebox execution by building CLI argument arrays, capturing Codebox's own stdout, and reparsing that JSON back into a result they had just produced in process.
agent-task-run.tsand three paths inwordpress-runtime.tsdid this, each with its ownparseRecipeRunOutput()and its own temporary recipe file.Change
Add a typed in-process execution seam and make
recipe-runa thin CLI adapter over it.executeRecipeRun(options, interruption?)dispatches dry-run vs. real run and applies interruption metadata.createRecipeRunOptions(input)supplies the same defaults the CLI parser produces, so callers stop synthesizing flags.RecipeRunOptionsaccepts an optional in-memoryrecipeandrecipeDirectory. Generated recipes no longer need temporary files, whilerecipePathremains the provenance and replay identity.agent-task-run.tsdropscaptureOutput(),parseRecipeRunOutput(), and its temporary recipe directory.wordpress-runtime.tsroutes its three round trips through oneexecuteGeneratedRecipe()helper and drops its local parser and temporary files.runRecipeRunCommand()keeps every CLI-only concern: argument parsing, host-heap replay, preview-lease child handling, heartbeats, stdout capture, human/JSON rendering, output files, and exit codes.adversarial.tsstays a thin CLI forwarder because its behavior is argument-level.Two regressions caught in self-review and fixed
recipeRunMetadata()derived site-seed provenance fromdirname(recipePath), which resolves to the wrong directory for in-memory recipes. It now takes the resolved recipe directory.Verification
npm run buildpasses.npm run checkpasses: 310 commands, re-run after both fixes.tests/recipe-execution-boundary.test.tsproves the typed path with no recipe file on disk returns output deep-equal to the CLI's JSON for the same failure, and that typed defaults match CLI defaults.Not run locally: the heavier
integrationandbrowserlanes. CI covers them.Residual risks for reviewers
agent-task-runnow passesprocess.cwd()as the recipe directory instead of the previous empty temp directory.buildAgentTaskRecipeemits absolute paths, so no relative source resolved before; this widens rather than breaks resolution.stdout/stderrfrom execution records and the serialized error instead of captured process output. Contract and canonical-evidence tests pass, but this is the most behavior-visible edge.Follow-ups
Sequence stays #2431 execution boundary, then #2432 artifact kernel, #2433 generated adapters, #2434 optional workload extraction.
AI assistance