From 60e5d176188e5f28ff7cf34fe9fe5750fb817557 Mon Sep 17 00:00:00 2001 From: Waleed Latif Date: Tue, 1 Dec 2026 01:52:08 -0800 Subject: [PATCH 1/2] feat(workflows-as-code): turn workflows as code on for everyone Remove the workflow-code feature flag and every gate behind it: the source operations' feature declarations and the operation-feature mechanism (its only user), FEATURE_NOT_ENABLED, the flag registry entry and WORKFLOW_CODE fallback, the Code tab gates and Preview badge, the CLI inventory entitlement fields, the flag-off tests and CI app, and the preview and 403 copy across OpenAPI, CLI, docs and rules. The Mothership workflow-code entitlement stays granted as constant true until the worker stops gating on it. computeEntitlements now settles each evaluator on its own, so one failing rollout check withholds only its entitlement. The Code tab mounts on first open, so sessions that never open it pay for none of its draft subscriptions. Also documents RESOURCE_ERRORS on the blob operations, names Stage Workspace Source Blobs instead of its path, and corrects the missing-blobs TSDoc. --- .claude/rules/sim-workflow-code.md | 16 +- .cursor/rules/sim-workflow-code.mdc | 16 +- .github/scripts/http-e2e.sh | 38 +-- apps/desktop/e2e/local-files.spec.ts | 2 +- .../api-reference/build-and-run-workflows.mdx | 2 +- apps/docs/content/docs/cli/index.mdx | 2 +- apps/docs/content/docs/mcp/tools.mdx | 2 +- .../self-hosting/environment-variables.mdx | 6 - .../docs/content/docs/workflows/code/edit.mdx | 2 +- .../docs/workflows/code/get-started.mdx | 1 - .../content/docs/workflows/code/index.mdx | 6 +- .../docs/workflows/code/troubleshooting.mdx | 2 - .../content/docs/workflows/code/workspace.mdx | 6 +- apps/docs/openapi-v2-billing.json | 3 +- apps/docs/openapi-v2-files-audit.json | 3 +- apps/docs/openapi-v2-knowledge.json | 3 +- apps/docs/openapi-v2-logs.json | 3 +- apps/docs/openapi-v2-resources.json | 5 +- apps/docs/openapi-v2-tables.json | 3 +- apps/docs/openapi-v2-workflows.json | 39 +-- .../scripts/fixtures/content-baseline.json | 5 - apps/sim/app/account/settings/layout.tsx | 1 - .../[workflowId]/source/feature-flag.test.ts | 89 ------- .../[workflowId]/source/plan/route.ts | 2 +- .../v2/workflows/[workflowId]/source/route.ts | 7 +- .../source/blobs/missing/route.ts | 3 +- .../[workspaceId]/source/plan/route.ts | 1 - .../workspaces/[workspaceId]/source/route.ts | 3 +- .../workflows/source/resources/route.ts | 3 +- .../[workspaceId]/workflows/source/route.ts | 6 +- apps/sim/app/extension/providers.tsx | 1 - .../components/composer/composer.test.tsx | 2 - apps/sim/app/o/[organizationId]/layout.tsx | 1 - .../mothership-chat/rollout-controls.test.tsx | 1 - .../app/workspace/[workspaceId]/layout.tsx | 8 - .../providers/feature-flags-provider.tsx | 1 - .../components/desktop/desktop.test.tsx | 1 - .../components/panel/components/code/code.tsx | 11 +- .../w/[workflowId]/components/panel/panel.tsx | 52 ++-- .../project-issue-restrictions.test.tsx | 1 - .../contracts/v2/openapi/source-catalog.ts | 2 +- .../contracts/v2/openapi/source-resources.ts | 2 +- .../contracts/v2/openapi/workflow-source.ts | 8 +- .../contracts/v2/openapi/workspace-source.ts | 14 +- .../lib/api/contracts/v2/workspace-source.ts | 2 +- .../lib/api/mcp/generated/v2-operations.ts | 20 +- .../authorized-workspace-use-case.ts | 9 +- .../core/application/feature-availability.ts | 47 ---- apps/sim/lib/core/application/forbidden.ts | 2 - apps/sim/lib/core/application/index.ts | 1 - .../core/application/workspace-operation.ts | 6 - apps/sim/lib/core/config/env.ts | 1 - apps/sim/lib/core/config/feature-flags.ts | 5 - apps/sim/lib/mothership/chat/payload.test.ts | 11 +- apps/sim/lib/mothership/entitlements.ts | 53 ++-- .../tools/sandbox-session.integration.ts | 14 +- .../mothership/tools/sandbox-session.test.ts | 8 +- ...ply-workflow-source.catalog.integration.ts | 5 +- ...workflow-source.credentials.integration.ts | 5 +- ...ly-workflow-source.fidelity.integration.ts | 5 +- ...-workflow-source.governance.integration.ts | 5 +- .../apply-workflow-source.integration.ts | 22 +- ...pply-workflow-source.parity.integration.ts | 7 +- ...ply-workflow-source.runtime.integration.ts | 5 +- ...pply-workflow-source.skills.integration.ts | 5 +- .../block-visibility-writes.integration.ts | 5 +- .../application/code-availability.ts | 39 --- .../lib/workflows/application/operations.ts | 7 - .../read-source-catalog.integration.ts | 10 +- .../read-source-resources.integration.ts | 5 +- .../source-feature-gate.integration.ts | 239 ------------------ .../source-pipeline/workspace-writes.ts | 13 +- .../code/feature-flag.integration.ts | 187 -------------- apps/sim/lib/workflows/code/feature-flag.ts | 33 --- .../application/apply.integration.ts | 58 +---- .../application/cross-kind.integration.ts | 5 +- .../application/deployments.integration.ts | 5 +- .../application/files.integration.ts | 5 +- .../application/knowledge.integration.ts | 5 +- .../application/lease.integration.ts | 5 +- .../application/mcp.integration.ts | 5 +- .../application/operations.ts | 2 - .../application/promote.integration.ts | 5 +- .../application/references.integration.ts | 5 +- .../application/rows.integration.ts | 5 +- .../application/staging.integration.ts | 5 +- .../application/status.integration.ts | 5 +- .../application/tools-skills.integration.ts | 5 +- apps/sim/scripts/test-workflow-code-ui-e2e.ts | 132 ++++------ .../scripts/test-workflow-source-apply-e2e.ts | 9 +- apps/sim/scripts/test-workflow-source-e2e.ts | 11 +- apps/sim/scripts/test-workspace-source-e2e.ts | 4 +- packages/sim-cli/README.md | 3 +- .../scripts/print-command-inventory.ts | 50 +--- .../sim-cli/src/commands/protocol/index.ts | 4 +- .../sim-cli/src/contract/reference.test.ts | 27 -- packages/sim-cli/src/generated/v2-api.ts | 4 +- packages/workflow-code/DESIGN.md | 28 +- vitest.integration-durations.json | 2 - 99 files changed, 243 insertions(+), 1312 deletions(-) delete mode 100644 apps/sim/app/api/v2/workflows/[workflowId]/source/feature-flag.test.ts delete mode 100644 apps/sim/lib/core/application/feature-availability.ts delete mode 100644 apps/sim/lib/workflows/application/code-availability.ts delete mode 100644 apps/sim/lib/workflows/application/source-feature-gate.integration.ts delete mode 100644 apps/sim/lib/workflows/code/feature-flag.integration.ts delete mode 100644 apps/sim/lib/workflows/code/feature-flag.ts diff --git a/.claude/rules/sim-workflow-code.md b/.claude/rules/sim-workflow-code.md index 24d4b87b2d8..8cb0c1c3056 100644 --- a/.claude/rules/sim-workflow-code.md +++ b/.claude/rules/sim-workflow-code.md @@ -42,7 +42,7 @@ workspace directory). | `packages/table-cells` | Pure table cell rules (coerce, validate, currency/date/ttl parsing) shared by the table codec's offline row check and the server's writes | | `packages/workflow-sdk` | Authoring declarations (`src/core.d.ts`, `src/workspace/*.d.ts`), type codegen from the catalog (`src/codegen/`), the cookbook | | `packages/sim-cli/src/commands/protocol/` | `workflow-source-*` and `workspace-source-*` commands, which never import each other's command modules; `source-dir/`, `workflow-dir.ts`, `source-check.ts`, `source-write.ts`, `source-tree.ts`, `source-ui.ts` and `workspace-source-dir.ts` (the workspace directory reader a workflow check also reads declarations through) are shared | -| `apps/sim/lib/workflows/code/` | Server glue: catalog projection from the registry (`catalog/`), source-apply gates (`apply/`), stored canonical form, the feature flag, the proof corpus (`corpus/`) | +| `apps/sim/lib/workflows/code/` | Server glue: catalog projection from the registry (`catalog/`), source-apply gates (`apply/`), stored canonical form, the proof corpus (`corpus/`) | | `apps/sim/lib/workflows/application/*source*` | Workflow source use cases: read, apply, create, catalog, resources; `source-pipeline/` holds the one plan → preview/commit flow an apply and a create share | | `apps/sim/lib/workspace-source/` | Workspace source use cases (`application/`), one adapter per kind (`application/kinds//`), route policies (`api/`) | | `apps/sim/blocks/sdk-names/.json` | Frozen SDK builder names, one file per block type | @@ -69,7 +69,7 @@ server unchanged. Both words name the same feature, split by role; follow the split rather than rename: - **code** names the feature and its engines: the packages (`workflow-code`, `workspace-code`), the - server glue folder `lib/workflows/code/`, the `workflow-code` flag, the Code tab. + server glue folder `lib/workflows/code/`, the Code tab. - **source** names the artifact and the operations on it: the files themselves, the use cases (`readWorkflowSource`, `applyWorkspaceSource`), the routes (`/source`), the CLI (`sim workflows source get`), `lib/workspace-source/`. @@ -91,18 +91,6 @@ lock. The catalog (built from the block registry, `lib/workflows/code/catalog/`) engine learns about blocks; engines never import the registry. See DESIGN.md "The canonical model" and "The catalog". -## Feature flag - -One global flag, `workflow-code` (`lib/core/config/feature-flags.ts`, env fallback -`WORKFLOW_CODE`), gates workflow source, workspace source, the source catalog and resources, and -the Code tab. Every source operation (the workflow source ones in -`lib/workflows/application/operations.ts` and the workspace source ones in -`lib/workspace-source/application/operations.ts`) declares `feature: WORKFLOW_CODE_FEATURE`, which -the shared use-case wrapper checks after authorization (`FEATURE_NOT_ENABLED`); a new source -operation declares the same feature, never its own check. A surface outside an operation (the Code -tab, Copilot entitlements) calls `isWorkflowCodeEnabled()` (`lib/workflows/code/feature-flag.ts`); -the UI reads it from the workspace layout's flags. - ## Adding things ### A block type diff --git a/.cursor/rules/sim-workflow-code.mdc b/.cursor/rules/sim-workflow-code.mdc index 100c3bdefe5..095f515465a 100644 --- a/.cursor/rules/sim-workflow-code.mdc +++ b/.cursor/rules/sim-workflow-code.mdc @@ -22,7 +22,7 @@ workspace directory). | `packages/table-cells` | Pure table cell rules (coerce, validate, currency/date/ttl parsing) shared by the table codec's offline row check and the server's writes | | `packages/workflow-sdk` | Authoring declarations (`src/core.d.ts`, `src/workspace/*.d.ts`), type codegen from the catalog (`src/codegen/`), the cookbook | | `packages/sim-cli/src/commands/protocol/` | `workflow-source-*` and `workspace-source-*` commands, which never import each other's command modules; `source-dir/`, `workflow-dir.ts`, `source-check.ts`, `source-write.ts`, `source-tree.ts`, `source-ui.ts` and `workspace-source-dir.ts` (the workspace directory reader a workflow check also reads declarations through) are shared | -| `apps/sim/lib/workflows/code/` | Server glue: catalog projection from the registry (`catalog/`), source-apply gates (`apply/`), stored canonical form, the feature flag, the proof corpus (`corpus/`) | +| `apps/sim/lib/workflows/code/` | Server glue: catalog projection from the registry (`catalog/`), source-apply gates (`apply/`), stored canonical form, the proof corpus (`corpus/`) | | `apps/sim/lib/workflows/application/*source*` | Workflow source use cases: read, apply, create, catalog, resources; `source-pipeline/` holds the one plan → preview/commit flow an apply and a create share | | `apps/sim/lib/workspace-source/` | Workspace source use cases (`application/`), one adapter per kind (`application/kinds//`), route policies (`api/`) | | `apps/sim/blocks/sdk-names/.json` | Frozen SDK builder names, one file per block type | @@ -49,7 +49,7 @@ server unchanged. Both words name the same feature, split by role; follow the split rather than rename: - **code** names the feature and its engines: the packages (`workflow-code`, `workspace-code`), the - server glue folder `lib/workflows/code/`, the `workflow-code` flag, the Code tab. + server glue folder `lib/workflows/code/`, the Code tab. - **source** names the artifact and the operations on it: the files themselves, the use cases (`readWorkflowSource`, `applyWorkspaceSource`), the routes (`/source`), the CLI (`sim workflows source get`), `lib/workspace-source/`. @@ -71,18 +71,6 @@ lock. The catalog (built from the block registry, `lib/workflows/code/catalog/`) engine learns about blocks; engines never import the registry. See DESIGN.md "The canonical model" and "The catalog". -## Feature flag - -One global flag, `workflow-code` (`lib/core/config/feature-flags.ts`, env fallback -`WORKFLOW_CODE`), gates workflow source, workspace source, the source catalog and resources, and -the Code tab. Every source operation (the workflow source ones in -`lib/workflows/application/operations.ts` and the workspace source ones in -`lib/workspace-source/application/operations.ts`) declares `feature: WORKFLOW_CODE_FEATURE`, which -the shared use-case wrapper checks after authorization (`FEATURE_NOT_ENABLED`); a new source -operation declares the same feature, never its own check. A surface outside an operation (the Code -tab, Copilot entitlements) calls `isWorkflowCodeEnabled()` (`lib/workflows/code/feature-flag.ts`); -the UI reads it from the workspace layout's flags. - ## Adding things ### A block type diff --git a/.github/scripts/http-e2e.sh b/.github/scripts/http-e2e.sh index f67b72a5dbf..13da60428e8 100755 --- a/.github/scripts/http-e2e.sh +++ b/.github/scripts/http-e2e.sh @@ -36,9 +36,6 @@ realtime_tag='' realtime_log='' browsers_pid='' local_app_url='' -extra_pids=() -extra_tags=() -extra_logs=() # `dev` or `start`; a group sets it before start_app. app_server=${E2E_APP_SERVER:-dev} @@ -61,13 +58,6 @@ finish() { tail -n 200 "$server_log" fi fi - for i in "${!extra_pids[@]}"; do - bash "$GITHUB_WORKSPACE/.github/scripts/stop-session.sh" "${extra_pids[$i]}" "${extra_tags[$i]}" || status=1 - wait "${extra_pids[$i]}" 2>/dev/null || true - if [ "$status" -ne 0 ]; then - tail -n 100 "${extra_logs[$i]}" - fi - done if [ -n "$realtime_pid" ]; then bash "$GITHUB_WORKSPACE/.github/scripts/stop-session.sh" "$realtime_pid" "$realtime_tag" || status=1 wait "$realtime_pid" 2>/dev/null || true @@ -132,27 +122,6 @@ start_app() { wait_ready "$server_pid" "$local_app_url/api/health" "$label app" } -# start_extra_app