Repository navigation
fix(workflow-code): staging QA fixes and a cheaper agent path - #10220
Merged
Merged
Conversation
A workflow holding a type the workspace catalog withholds (table_v2 behind a preview gate on staging) is printed and dry-run against its own per-workflow source catalog, but the get never cached that catalog, so the offline check compiled against the workspace catalog: table.insertRow became E_UNKNOWN_BUILDER and the branch wired to it W_BRANCH_UNWIRED, while the dry run was clean. The get now caches the per-workflow catalog beside the workspace one, and check and the tsconfig refresh use it when its hash is the one .sim/base.json records, else the workspace catalog.
…en bound blocks Offline (storedUnread), compile took any edge between two blocks the lock binds as one the stored workflow may hold, so a cycle or container error edge an edit added between known blocks was only W_EDGE_CYCLE / W_ERROR_PORT_STORED and check exited 0 even with --strict, while the dry run refused it with E_EDGE_CYCLE. A get, apply or create now compiles the printed source and records its edges by lock key with the base fingerprint in .sim/stored-edges.json (a CLI-only record). Check passes them as storedUnreadEdges, and compile counts an edge between bound blocks as possibly stored only when it is one of them, mapping a block renamed in source to its vacated lock key, so a printed cycle stays a warning and a new one is the server's error. Without a record for the current base (an older directory, a workspace directory) the old rule holds. CompileResult gains edges, the accepted edges even when the compile fails elsewhere (a printed stored() secret).
Each catalog is cached once at source-catalog/<hash>.json (verified against its hash on read), and each workspace records its current catalog's hash in source-catalog/workspaces/<id>.json for ETag revalidation. Check and apply resolve the catalog by the hash .sim/base.json records, and a get reuses a cached workflow catalog of that hash instead of fetching it again, so the cache grows with distinct catalogs rather than with workflows. The per-workspace and per-workflow copies an older CLI wrote are removed on the next catalog read.
…ase names A workspace get or apply now fetches, once per distinct hash, the catalog of each workflow folder whose base names one other than the workspace catalog (a workflow holding a type the workspace withholds) and caches it by hash; the offline workspace check compiles each folder against the catalog its base names. Each workflow folder also gets its .sim/stored-edges.json, so an edit's new cycle between bound blocks is E_EDGE_CYCLE in a workspace directory too. The record is a CLI file: never sent, not listed as ignored, and removed with its workflow.
… does not declare
A result past the 64 KiB a pipe buffers was cut short with exit 0: Bun drops console writes once process.stdout exists, and process.exit (every error path) ended the process before Node or Bun drained the pipe. Lines go through the stream under Bun, refused writes are tracked until they drain, and the terminal entrypoint is the only place that exits, after flushing; exitCli now throws CliExit for it.
…names
A custom tool's canonical id is custom_<title>, and the title is free text, so an agent
using a tool titled with a space failed on Anthropic (tools.0.custom.name must match
^[a-zA-Z0-9_-]{1,128}$). The wire id now replaces every character outside that alphabet
with _, aliasing on collision; the canonical id keeps the title, which execution resolves
by, and the existing wire-to-canonical map projects calls back.
The source catalog hides an unrevealed preview block or one the block-visibility kill switch names, but the write paths only checked the allowlist and deployment availability, so source apply (generic block() form) and editing operations placed a kill-switched table_v2 for a non-admin. A VISIBLE_TYPE placement gate in BLOCK_GATES now refuses a new placement or type change to a type isHiddenUnder hides, for both writers; state replace refuses a hidden type the stored graph does not already hold on that block. Placed blocks of a hidden type stay editable.
An interrupt while workflows/workspaces source apply (or create) was committing exited 130 at once: the server still stored the write, and the directory, never saved, was stranded as a conflict on both sides. The send and the write-back now run with interrupts deferred: the first Ctrl-C waits (up to 60s) for the answer, saves it, then ends by the signal; a second one, or the bound, stops at once and prints that it may have been written and how to recover. Staging and lock cleanup handlers wait for the deferral.
…yped for The starter wrote no record of its workspace and printed a create command without --workspace, so the create silently went to the profile's default workspace. The starter now writes .sim/starter.json, prints the create with --workspace, and a create into another workspace is refused (SOURCE_OTHER_WORKSPACE) unless --workspace names it; the record goes once the workflow is created.
…s and hints - workflows/workspaces source status without a login exited 0 (or 11): statusExitCode now returns 13 when the server was not checked for that. - Ctrl-D at a confirmation or login prompt hung (Node) or printed Bun's AbortError stack: askLine resolves null when input ends, so the prompt cancels cleanly (exit 1). - A refusal in a display format no longer points at details.diagnostics, a JSON field: it says each finding is printed above. - status, diff and apply on a starter no workflow was created from name the create to run (with its workspace), not a get. - A key the server refuses from SIM_API_KEY (or --api-key) says to fix or unset it, since sim login cannot override it.
… tsc as a step The directory guides and the workflow SDK README listed only some exit codes (no 8, 10-12 or 130, and the README no 13). Both guides now print one table built from exit-codes.ts, the README carries the same rows, and the apply/create help and the scripting page add 13 and 130 and that a locked block exits 1. The guides and README make tsc a firm step after every edit and pass --workspace to create. CLI reference pages regenerated.
Next.js truncates a proxied /api body past 10 MiB, so a 24 MB staging batch reached the route as a broken multipart prefix (400, never converging). Batches now carry at most 8 MB framing included, a file up to the 10 MB blob limit goes alone, the route caps the body below the proxy ceiling and answers 413 PAYLOAD_TOO_LARGE naming the limit, and the CLI maps that 413 to the upload it refused and the fix. Server hashing keeps its own 24 MB budget.
…t in the target apply --to read the target's live base at promote time and used it as the three-way base, so a target edit since the last promotion could never look changed and was overwritten. Each promotion now records the target's base entries and promoted workflow folders in .sim/targets/<workspaceId>.json; the next promotion uses a recorded entry in place of the live one for the same id, sends a workflow folder unchanged since as its base alone, and an edited one with the recorded fingerprint. A target edit is kept when the directory left the resource alone and refused as stale (exit 5) when it changed it too. A resource without a record (the first promotion) takes the target as it stands; docs say so.
… them
A column key lived only in the directory's base, so a fresh get (or a promotion's read of
the target) keyed each column by its name: `note: column.string({ name: 'note_text' })`
came back as `note_text: column.string()`, against the documented promise that the key
stays bound to the column. Every table write now records each declared column whose key is
not its name in metadata.sourceColumnKeys (column id -> key), reads print base binding, then
that record, then the name, and an apply that finds a column a read would key otherwise
records the keys alone.
Managed rows promoted to another workspace planned an update on every run: the target's read keyed a column whose key is not its name by that name, so the stored rows never fingerprinted like the directory's. Persisting column keys (previous commit) fixes it; this pins the promotion round trip.
… keep seed rows
- Each file under a kind folder the CLI does not send (a hidden name, or a character no
workspace path holds) is a W_PATH_NOT_SENT warning, printed and in the JSON result and
its warnings count, instead of one unstructured "Not sent" line.
- The per-file findings cap ends a list with I_FINDINGS_TRUNCATED (info) instead of
E_LIMIT_EXCEEDED, so plain source errors exit 1, not 7 (too large); the offline check
keeps each rows finding's own severity.
- A table seeded by source records { mode: 'seed' } in metadata.sourceRows, so a get prints
rows: { mode: 'seed' }, and the CLI keeps the seed rows file beside it; a declaration that
starts or stops seeding records or clears the mark.
- I_KB_CHUNKING counts the stored documents that keep their chunks, not those the apply
replaces or deletes.
- A replaced knowledge document keeps its tag values: the SDK docs said they were lost.
…uiet $refs a rename resolves Three or more blocks renamed at once bind by params; renames nothing ties are refused naming the look-alike blocks instead of offering --allow-delete. A dangling $ref in a function file is one warning at the file line in check and dry run alike.
…he stale workflow, and list changed variables E_NAME_TAKEN, E_WORKFLOW_META_INVALID and E_APPLY_BLOCK_DELETE point at the workflow name (or description) instead of the SDK header; an unknown MCP tool points at the agent's tools line; the stale finding names the workflow; the offline check stays quiet on a legacy block the lock binds, as the server does; the CLI apply result and preview name each changed variable.
…ad from check, status, diff and apply (workflow and workspace) now take the workspace recorded in .sim/base.json whatever the profile default, as get already did; only a --workspace naming another one is refused (SOURCE_OTHER_WORKSPACE). check refuses a directory without workflow.ts before any catalog lookup, and every --dir is made absolute before the command runs, so messages name the directory read wherever the CLI was started.
…eated
With --output json (or yaml) a source check, apply or create prints its
findings only in the document on stdout, no longer also as frames on stderr,
and leaves info findings out unless --verbose. A display format prints the
first warning of each code whole and the rest of that code on one line.
Workflow create and apply, and workspace apply, list what they created as
created: [{ kind, key, id }] (named on one line in a display format), and a
workflow write lists its notes in a machine result.
…and not on typed Function returns The warning fired on every bare Function-output reference in a JSON field, untouched blocks included, so one apply of a large workflow printed thousands of tokens of it. Against a stored workflow (the server's dry run and apply) it is now raised only for a JSON field the source changed, and an offline check reports it only on blocks the lock does not bind (--strict: on every block). A Function result field the JavaScript returns as a number, boolean, array or object literal (directly, or through a local never reassigned to another kind) no longer warns; a text field and anything uncertain keep the warning.
--deploy deploys the workflow once the write is saved, through the same deployWorkflow operation (and so the same server-side permission check) as `sim workflows deploy`; a failed deploy says the write itself was saved and names the command to retry. Without it, a write to a deployed workflow whose draft now differs names that command as next. --deploy with --dry-run is refused.
…refusing Where no terminal can ask, workflows source apply/create and workspaces source apply without --yes now run the dry run, print the plan and its findings, write nothing, and exit 14 naming the same command with --yes (or exit with the refusal when the plan has errors), instead of refusing with CONFIRMATION_REQUIRED and nothing to act on. apply --yes prints the summary of what it applied, so an agent's loop is edit, then apply --yes.
…nd on any with --strict A rename's apply already rewrites $ref.<old key> in function files to the new key and writes the files back; the integration proof now asserts the written-back function file too.
…yped for Without --workspace, a create now binds to the workspace .sim/starter.json records, as check, status, diff and apply bind to the one .sim/base.json records, instead of refusing with SOURCE_OTHER_WORKSPACE when the profile default differs; --workspace still chooses another.
…nd warn on a probable rename The diff lists each added and removed block's type; an apply passed --allow-delete that deletes a block and adds one of the same type and parent warns W_APPLY_PROBABLE_RENAME, since that block gets a new id. The CLI result and preview name the added and removed blocks.
…low writing the old name A plan that renames a column scans the stored workflows that use the table and warns W_TABLE_COLUMN_RENAMED_IN_USE on each Table block that still writes, filters or sorts by the old name, naming the workflow and block, at the line of the declared workflow's file.
… supersedes Editing operations store a loop's iterations/loopType inputs beside data.count; the serializer reads only data, so source no longer prints them under extra. They are preserved state: apply restores them from the stored block, so a no-op apply stays byte-identical.
Collaborator
Author
Contributor
[High impact] The PR reaches shared workflow and workspace write paths as well as the source CLI. Fix the apply save-back gap and preservation of target deletions before merging. Findings
SummaryThis PR improves workflow and workspace source commands, reduces generated SDK files, and fixes several staging failures.
|
Contributor
There was a problem hiding this comment.
All reported issues were addressed across 151 files
Reply with feedback, questions, or to request a fix.
Turn on auto-fix | Re-trigger cubic
…last promotion deleted
…hen an unchanged reference's Function changed kind
…fill Value<string> params in snippets
…bflows, read case-insensitively
…bose in a refusal
…r the limit, and word a chunked body's 413
… truncated warnings
…ts keeping their chunks
…deployed workflow still uses
…ext strips the Content-Encoding of Next's sendResponse drops a route handler's Content-Encoding header (FORBIDDEN_HEADERS in send-response.js), so a production server sent brotli bytes as plain JSON and every client failed to parse them (the workflow source e2e: JSON Parse error). The routes answer plain JSON again; the CLI still offers br and gzip for a server or proxy that compresses.
This branch was successfully deployed
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.
Fixes from end-to-end testing of workflows/workspace as code (#10129) on staging, plus the changes that make the code path cheaper for agents than the operations path.
Summary
Bugs found on staging
source checkfailed on uneditedgetoutput when a workflow's catalog differs from the workspace's (hidden/preview types): catalogs are cached by content hash and check uses the one the get printed with; workspace check too.checklet a new cycle through as a warning: the get records the stored edges, so only stored cycles stay warnings.$refwarnings on renames, precise locations, a warning when a renamed column is still used by a workflow, dead loop config no longer printed.Agent experience
getprints a short primer with snippets for the builders in use;sim workflows source params <builder>replaces grepping the SDK.apply --deploy;applywithout--yesprints the plan (exit 14); each finding prints once andW_JSON_REF_UNTYPEDonly fires where the edit wrote it.Changes outside the workflow-code flag
Type of Change
Testing
Every fix has a regression test that fails before it. Local gate: package suites, apps/sim units, real-Postgres integration (migrated and push DBs), goldens, check:audits, check:test-types, docs compatibility, lint, block registry. Several fixes were verified live on staging with the CLI from this branch.
Checklist