Repository navigation
perf(cli): load a manual run's draft once and keep embedded CLI results lean - #8625
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
@cubic-dev-ai review this PR |
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
|
|
@cubic-dev-ai review this PR |
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
|
@cubic-dev-ai review this PR |
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
|
@cubic-dev-ai review this PR |
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
Comments Outside DiffThese findings could not be posted inline.
|
|
On the 4/5: the stop-after finding is about |
…ts lean - Manual runs reuse the draft state the use case loaded to pick and validate the trigger, instead of reading the draft tables twice more in the execute service and the execution core. The trigger is now chosen from the same snapshot that runs. - Embedded (in-app agent) synchronous runs ask for file references without inline base64 unless --include-file-base64 is passed; --async never sends it. - Embedded logs get leaves the workflow snapshot out unless --include-workflow-state is passed, via a new embeddedRequestDefault contract field. The installed CLI and public API defaults are unchanged. - Add test-cli-run-latency-e2e.ts, which times both commands per segment against a running app and writes a JSON report; CI runs a short pass.
…he CLI E2E - Embedded --follow runs also ask for file references only. - The E2E asserts this checkout's embedded results carry no inline file bytes or workflow snapshot; a compared CLI build is measured, not asserted. - Run the CLI E2E against its own self-hosted app: hosted billing admits runs through Redis, which the HTTP E2E job does not provision.
572982d to
114cf00
Compare
|
@cubic-dev-ai review this PR |
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
Summary
Cuts fixed overhead from the two CLI commands the in-app agent issues most,
workflows run --manualandlogs get. The public API and the installed CLI behave exactly as before.executeManualWorkflowOperationalready loads the saved draft to choose and validate the trigger. The execute service and the execution core then each read it again. They now reuse the snapshot the use case loaded, for both the sync and the stream paths and for run-from-block.sim_cli), a synchronous or--followworkflows runsendsincludeFileBase64: falseunless the caller passes--include-file-base64. The agent reads produced files by id. The inline bytes only grew its result and cost the server a storage read and an encode per file.--asyncruns never send the field, because the route rejects it there.logs getleaves out the workflow snapshot. A newembeddedRequestDefaultfield on the CLI contract makes embedded invocations sendincludeWorkflowState=falseunless--include-workflow-stateis passed. The agent diagnoses runs fromtraceSpans, andworkflows getserves the block configuration.apps/sim/scripts/test-cli-run-latency-e2e.ts(bun run test:cli-run-latency:e2e). It seeds a five-block workflow (Start, two Functions, a file write, a file read) into a disposable database and drives both commands through the embedded CLI over real HTTP. It writes each command's stdout to a file, as theoutputFilesink does, and records per-segment timings in a JSON report atCLI_LATENCY_E2E_REPORT_PATH. CI runs a short pass (1 warm-up and 3 measured iterations) in the HTTP E2E job's workflow step, after the--stop-aftersuite and against the same self-hosted app (hosted billing admits runs through Redis, which that job does not provision). With this checkout's CLI, the run asserts that the results stay lean.Before / after
Setup:
next buildandnext start) oforigin/stagingagainst this branch, and each variant's own CLI source.With about 2 ms of database RTT (all values in ms):
workflows run: before execution (request → logstarted_at)workflows run: executionworkflows run: after execution (ended_at→ last byte)workflows run: CLI renderworkflows run: sink writeworkflows run: totalworkflows run: stdoutlogs get: HTTPlogs get: CLI renderlogs get: totallogs get: stdoutworkflows run+logs get)Direct loopback database (all values in ms; noisier, because the database costs almost nothing and machine load dominates):
workflows run: before executionworkflows run: executionworkflows run: after executionworkflows run: totallogs get: totalWhat the numbers say:
logs getreturns 6.9 KB less, the size of this workflow's snapshot. Its time change is within noise.logs getcost after the request comes from the remote workbench write of stdout, which this harness cannot reproduce.Reproduce:
To compare CLI builds, set
CLI_LATENCY_E2E_CLI_MODULEto another checkout'spackages/sim-cli/src/embed.ts.Design
ExecuteWorkflowServiceParams.draftState→ExecuteWorkflowCoreOptions.draftState, andExecuteWorkflowOptions.draftStateon the stream path.useDraftState.logs getgoes through a generic, contract-declaredembeddedRequestDefault, which wins overrequestDefaultonly inside an embedded invocation.workflows runapplies its default in the synchronous request builder (workflow-run-follow.ts), because the same field is a 400 on--async.Compatibility
includeFileBase64still defaults to true andincludeWorkflowStatestill defaults to true.runEmbeddedCli. A test covers the explicit flags.file.base64, andlogs getreturnsworkflowState: nullunless asked.base64orworkflowState.files read) and logs bytraceSpans.--include-file-base64or--include-workflow-state.--stop-after(feat(workflows): stop a manual v2 run after a block, andworkflows run --stop-after#8622):run.stopAfterBlockIdis validated against the snapshot the run then executes, and it threads through the service and core alongsidedraftState.mergeSubblockStateWithValues, and the service reads the blocks only to resolve--select-output.Test plan
test-cli-run-latency-e2e.ts, 8 interleaved rounds per variant and condition. Every check passed: the run completes,blockOutputsmatches, the file reference is present, and the log has trace spans.packages/sim-cli/src/embed.test.ts, covering sync,--follow,--async,logs getand explicit opt-in. The sync andlogs gettests fail on the pre-change CLI.execute-manual-workflow,execute-service,execution-core,execute-workflow, v2 execute route andcsv-workflow-executiontestsbun run lint,bun run type-check,bun run check:audits,bun run docs-manifest:check, block-registry check againstorigin/stagingbun run testvia CI (Lint and Test, PostgreSQL integration), plus the new E2E in the HTTP E2E job: all green. Locally, the suite only timed out under unrelated machine load.