Repository navigation
refactor(workflow): one file boundary, one batcher, shared readers, engine types in the designer - #536
Open
huyplb wants to merge 1 commit into
Open
refactor(workflow): one file boundary, one batcher, shared readers, engine types in the designer#536huyplb wants to merge 1 commit into
huyplb wants to merge 1 commit into
Conversation
…rmat, and the engine's own types The workflow review's remaining structural items. File boundary. Every file pipe resolved its configured path inside the files root and then called node:fs itself, so the rule that keeps an editor from reading /etc/passwd held only while each pipe remembered one call. openWorkflowFile resolves once and hands back the only handle that can read or write; CSV, text, JSON, the CSV sink and the preview route use it, and pipes-fs-boundary.test.ts fails the build when anything else under pipes/ imports node:fs. One batcher. CSV, text and JSON each kept their own onInvalid/reject batching and had drifted on where they cut, what the last cursor named and how errors read. BatchEmitter in delimited.ts does it once: `record` cuts for CSV/JSON, `boundary` cuts for text (a line never straddles batches), and the final cursor names the last position read, so trailing refused rows are not read again on resume (JSON now gets that too). One reader per format. The preview re-implemented each source's loop and had diverged: CSV numbered rows as preamble + header + index, wrong after any quoted field spanning lines. csvRows and TextRowReader are shared by run and preview; CSV rows carry the physical line they start on. Engine types. The HTTP request model, column rules, credential kinds and the designer's saved pipes now come from @foxschema/workflow-engine (type-only; z.input where the designer writes what the engine parses). The swap surfaced two more drops on save: a pipe's retry policy beyond `attempts`, and a column type typed as any string. Both fixed; the e2e round trip now covers retry, and the trigger dialog keeping its section while typing. Verified: full vitest (timing tests pass alone), apps/web tsc, eslint + security lint, build, bundle 146.2 KB; e2e workflow suite in a real browser; every new test fails on the code before it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: b4c56e57-ad40-4ecc-b78a-e3fc7f45eef1) |
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.
The structural items left over from the workflow review (#530): one way to touch the filesystem, one batcher, one reader per format shared by run and preview, and designer types that come from the engine.
File boundary
node:fsdirectly. The rule that keeps a workflow editor from reading/etc/passwdonly held while each new pipe remembered to make that one call, and forgetting it failed open.openWorkflowFile(pipes/utility/workflow-files.ts) now resolves the path once and returns the only handle that can read or write it. CSV, text, JSON, the CSV sink and the preview route all use it.pipes-fs-boundary.test.tsfails when anything else underpipes/importsnode:fs.One batcher
onInvalidbatching, and they had drifted on:BatchEmitterindelimited.tsnow does it once:recordcuts for CSV and JSON.boundarycuts for text, so a line never straddles two batches.Preview and run read the same way
csvRowsandTextRowReaderare now shared by the run and the preview. CSV rows carry the physical line they start on.preview-run-agreement.test.tschecks that the two agree.Designer types from the engine
@foxschema/workflow-engine/definitionsas type-only imports, usingz.inputwhere the designer writes something the engine parses:attempts(backoff,maxDelayMs,jitter,on) were dropped.Tests
batch-emitter.test.ts,workflow-files.test.ts(outside-root, symlink, write/append/read, head),pipes-fs-boundary.test.ts, CSV line numbers with multi-line quoted fields, preview CSV lines.Verification
npx vitest run: three timing tests in files this PR doesn't touch fail under parallel load and pass when run alone.apps/webtsc: clean.npm run build:app: passes.🤖 Generated with Claude Code
Note
Medium Risk
Touches core file-source parsing, batching/checkpoint cursors, and workflow save serialization; filesystem boundary changes are security-sensitive but centralized and tested.
Overview
Unifies workflow file I/O, source parsing, and designer save behavior so preview, runs, and the canvas agree and stop stripping config.
Engine: File pipes must use
openWorkflowFile(root-confined reads/writes); a boundary test blocks otherpipes/code from importingnode:fs. CSV/text/JSON sources shareBatchEmitter(record vs line-boundary batching, shared reject/cursor semantics) and shared readerscsvRows/TextRowReader—CSVlinesare now physical start lines (fixes multi-line quoted fields); preview uses the same paths as runs.Designer: Saved pipes use engine
pipeSchema/pipelineSchemaso full retry policies (not onlyattempts) round-trip; HTTP models are engine types with token-refresh headers/body defaulted and carried through; delimited editors use engine column types.Tests: New unit/integration coverage (batch emitter, workflow files, preview↔run agreement, CSV line numbers) and e2e extends designer round-trip for retry plus trigger-dialog section stability while typing.
Reviewed by Cursor Bugbot for commit 7746bb2. Bugbot is set up for automated code reviews on this repo. Configure here.