Skip to content

Commit 293ec1b

Browse files
authored
improvement(workflow-code): server hardening, flaky test root causes, and agent DX across the source loop (#10287)
Server: dry runs charged to the plan budget and slot, create-from-source answers 429 when slots are full, the Code tab has its own slot lane, staged blobs count against the payer's storage quota (consumed on apply, never renewed by reads), file deletes carry a revision precondition, row limits refuse only growth, joined table transactions keep their timeouts, and blocks/edges/subflows load in a stable created_at,ctid order. DX: group help for the source loop, a primer covering renames, failures and test runs, JSON-only output, run errors mapped back to source file and line, --stop-after/--from-block by name, webhook URLs after deploy, GitHub Actions annotations and step summary, exit 15 for a partial write, table names on every table route, status that agrees with the dry run, and quieter output. Flaky tests fixed at the root (keep-alive races, sleep-based waits). Migration 0469 adds a nullable staged_blob.consumed_at.
1 parent 93555ff commit 293ec1b

145 files changed

Lines changed: 37923 additions & 894 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎apps/docs/content/docs/api-reference/getting-started.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ Some endpoints return an unpaginated bounded inventory or a provider-specific pa
239239

240240
## Rate limits
241241

242-
V2 request limits apply to the credential and its user or workspace. Workflow execution also applies separate synchronous/asynchronous execution buckets, quota, and concurrency policy. Writing workflow source (applying it, a dry run, or creating a workflow from it) draws on one tighter budget of its own, 20 requests a minute with bursts of up to 40, on every plan. Plan and deployment configuration determine the other limits.
242+
V2 request limits apply to the credential and its user or workspace. Workflow execution also applies separate synchronous/asynchronous execution buckets, quota, and concurrency policy. Writing workflow source (applying it, or creating a workflow from it) draws on one tighter budget of its own, 20 requests a minute with bursts of up to 40, on every plan. A dry run, which writes nothing, draws on the source plan budget the plan routes use instead, 30 requests a minute with bursts of up to 60. Plan and deployment configuration determine the other limits.
243243

244244
A rate-limited request returns `429`; `Retry-After` gives seconds to wait. Inspect [Billing status](/api-reference/billing/getBillingStatus) for a workspace's current credits and storage. Async mode does not bypass admission or usage limits.
245245

‎apps/docs/content/docs/cli/blocks.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ sim blocks get <blockId>
4949

5050
| Argument | Required | Description |
5151
| --- | --- | --- |
52-
| `blockId` | Yes | Block type identifier. An unversioned base type resolves to the newest visible version. The response echoes the resolved ID. |
52+
| `blockId` | Yes | Block type identifier. An unversioned base type resolves to the newest visible version. The response echoes the resolved ID. A legacy or deprecated block (such as `starter`) is readable by its exact ID, and its description opens with the block that replaces it. |
5353

5454
</CommandTable>
5555

‎apps/docs/content/docs/cli/reference.mdx‎

Lines changed: 78 additions & 56 deletions
Large diffs are not rendered by default.

‎apps/docs/content/docs/cli/scripting.mdx‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -207,16 +207,20 @@ The CLI resends a request the API answers `429` only when sending it twice is sa
207207
| Code | `sim workspaces source apply` |
208208
| --- | --- |
209209
| `0` | Applied, or a dry run with no errors |
210-
| `1` | The source has errors, changes were held back for a secret or credential the workspace cannot satisfy, or command/request failure |
210+
| `1` | The source has errors, every change it would write was held back for a secret or credential the workspace cannot satisfy (nothing was written), or command/request failure |
211211
| `5` | A resource changed since the directory was read (`409 SOURCE_STALE`): get it again into a fresh directory, reapply the edit, and retry |
212212
| `6` | A resource (a workflow or its folder, a table) is locked (`423`); a locked block exits `1` (`E_APPLY_LOCKED_BLOCK`) |
213213
| `7` | The directory is over the size limits (`413`) |
214214
| `8` | The apply stopped part-way: what was written is saved into the directory; apply again |
215215
| `9` | Still rate limited (`429`) after the CLI's retries; nothing was written |
216216
| `10` | Busy, retry: another apply is writing the workspace (`409 SOURCE_BUSY`), or another `sim workspaces source` command is using the same directory (`SOURCE_DIR_BUSY`); nothing was written: run the command again once the other finished |
217217
| `13` | `AUTH_REQUIRED`: not logged in, or the server refused the credential; nothing was sent |
218+
| `14` | Run without `--yes` and with no terminal to ask: the plan was printed with no errors and nothing was written; run the same command with `--yes` |
219+
| `15` | Written in part: changes that use a declared secret with no value, or a credential key nothing binds to, were held back and the rest was applied and saved; set the secret or connect the credential, then apply again (a promotion with `--to` too) |
218220
| `130` | Interrupted (Ctrl-C). A write already sent is finished and saved into the directory first, waiting up to 60s for its answer; a second Ctrl-C, or no answer by then, stops at once and prints that it may have been written and how to check |
219221

222+
Earlier CLI releases exited `1` when an apply held changes back, whether or not it wrote the rest. A script that reads `1` as "held back" should test for `15` too.
223+
220224
Both waits default to 3600 seconds; `--wait-timeout 0` waits indefinitely. `SIM_TIMEOUT_SECONDS` independently bounds one API request. A timeout does not cancel the underlying run or operation.
221225

222226
A synchronous or followed workflow run prints its result before exiting 1 for failure/cancellation. A paused run is not failed and can return 0; use `runs wait` or inspect status if your script requires completion. Fetching a failed run or listing runs only reports their state.
@@ -377,7 +381,7 @@ exit "$status"
377381

378382
## Workspace source in CI
379383

380-
Keep a [workspace source directory](/workflows/workspace-code) in a repository, `.sim/` included, and let CI plan each pull request and apply each merge. The dry run exits `1` on errors and `5` when the workspace changed since the committed base; `check` downloads the block catalog once on a fresh runner.
384+
Keep a [workspace source directory](/workflows/workspace-code) in a repository, `.sim/` included, and let CI plan each pull request and apply each merge. The dry run exits `1` on errors and `5` when the workspace changed since the committed base; `check` downloads the block catalog once on a fresh runner. On GitHub Actions (`GITHUB_ACTIONS=true`), every source command also annotates each error and warning at its file and line, so they show inline on the pull request, and `apply` (a dry run too) appends its plan and errors to the job's step summary.
381385

382386
```yaml title=".github/workflows/sim-workspace.yml"
383387
on:
@@ -410,7 +414,7 @@ jobs:
410414
- run: sim workspaces source apply --dir workspace --dry-run
411415
- if: github.event_name == 'push'
412416
run: sim workspaces source apply --dir workspace --yes
413-
- if: github.event_name == 'push'
417+
- if: ${{ !cancelled() && github.event_name == 'push' }}
414418
run: |
415419
git add -A workspace
416420
if ! git diff --cached --quiet; then
@@ -420,7 +424,7 @@ jobs:
420424
fi
421425
```
422426
423-
`check` runs first because it is offline and fast, and it regenerates `.sim/sdk/workspace.d.ts`, so the `tsc` step after it types resources the pull request adds. A workspace API key can apply tables, rows, knowledge bases, files, custom tools, MCP servers and credential bindings. Workflows, skills, secrets and deployments need a member's personal API key, and deployments need an admin. Apply rewrites files under the directory (each `.sim/base.json`, ids it allocated, values the server normalized), and the next apply compares with them, so the last step commits them back to the branch; `[skip ci]` keeps that commit from running the job again. Where the branch is protected, run `sim workspaces source get --dir workspace` on a new branch instead and open a pull request. After merging two branches that each applied, a dry run with no changes means the files match the workspace. Exit `5` means a resource changed since this branch's base: get the workspace into a fresh directory and carry the edit over. Exit `10` means another apply is writing the workspace (or another command is using the directory), so retry; the `concurrency` key keeps two runs of this job from overlapping.
427+
`check` runs first because it is offline and fast, and it regenerates `.sim/sdk/workspace.d.ts`, so the `tsc` step after it types resources the pull request adds. A workspace API key can apply tables, rows, knowledge bases, files, custom tools, MCP servers and credential bindings. Workflows, skills, secrets and deployments need a member's personal API key, and deployments need an admin. Apply rewrites files under the directory (each `.sim/base.json`, ids it allocated, values the server normalized), and the next apply compares with them, so the last step commits them back to the branch; `[skip ci]` keeps that commit from running the job again. That step runs even when the apply failed (`!cancelled()`), because an apply can fail having written part of its plan: exit `15` means it held back changes that use a secret with no value or a credential nothing binds to and applied the rest, and exit `8` means it stopped part-way. Either way the directory records what was written, so committing it keeps the next run from being refused as stale (exit `5`) for resources this run wrote; the job still fails, so set the secret, connect the credential or fix the failure, and push again. Where the branch is protected, run `sim workspaces source get --dir workspace` on a new branch instead and open a pull request. After merging two branches that each applied, a dry run with no changes means the files match the workspace. Exit `5` means a resource changed since this branch's base: get the workspace into a fresh directory and carry the edit over. Exit `10` means another apply is writing the workspace (or another command is using the directory), so retry; the `concurrency` key keeps two runs of this job from overlapping.
424428
425429
To promote the same directory to a second workspace, add a step with `--to` before the step that commits the files back:
426430

0 commit comments

Comments
 (0)