* feat: restore bun as default runtime for dedicated workers Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * chore: add context comment for bun dedicated worker nodejs migration Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: dedicated worker dispatch for flows + add E2E tests - Add workspace_id prefix to dedicated worker map lookup keys - Update ee-repo-ref for dedicated worker path handling fix - Add spawn_test_worker_dedicated/in_test_worker_dedicated test helpers - Add 6 E2E tests for dedicated workers: - test_dedicated_flow_rawscript (regression for "Script not found" bug) - test_dedicated_flow_workspace_script - test_dedicated_flow_multiple_steps - test_dedicated_standalone_script - test_dedicated_runner_group - test_dedicated_flow_runners - Add dedicated_flows.sql fixture with scripts, flows, and worker config Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: always run dependency job for dedicated worker scripts When a script with dedicated_worker=true is deployed with a pre-computed lock (e.g. via wmill sync push), no dependency job was created, so the dedicated worker never detected the update and kept running the old version. Now dedicated worker scripts always generate a dependency job regardless of whether a lock is provided. The dependency job runs on the dedicated worker and triggers a restart so it picks up the new script version. Fixes #8638 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: use serial_test for dedicated worker tests to avoid WORKER_CONFIG races Dedicated worker tests need non-default worker tags in the global WORKER_CONFIG. When run in parallel (CI uses --test-threads=10), multiple tests clobber each other's config. Use #[serial] to ensure dedicated worker tests run sequentially. Also load worker config from DB via load_worker_config() instead of manually setting WORKER_CONFIG fields, ensuring consistency with the monitor's reload path. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: nodejs dedicated worker script_path shadowing + add multi-language E2E tests Fix script_path shadowing in bun_executor nodejs branch where the wrapper file path was passed to handle_dedicated_process instead of the logical path, causing "Script not found" for all //nodejs dedicated workers. Add E2E tests for dedicated flows in all supported languages: - test_dedicated_flow_deno - test_dedicated_flow_python - test_dedicated_flow_bunnative (V8 PrewarmedIsolate path) - test_dedicated_flow_bun_nodejs (//nodejs annotation) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: simplify dedicated worker dispatch + add serialization and E2E tests - Unified lookup: always use {workspace}:{runnable_path} for dedicated worker dispatch, replacing the flow_step_id iteration approach - Added serialization_semaphore parameter to executor start_worker fns - Added E2E tests: cross-workspace isolation, conflicting flow step IDs, preprocessor on dedicated worker - Added workspace field to RunJob for cross-workspace test support Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * feat: cross-workspace workspace dependencies on workers page Add two new instance-level endpoints to the configs router: - GET /configs/list_all_workspace_dependencies - GET /configs/list_all_dedicated_with_deps Both require devops role and return data across all workspaces, enabling the workers page to show a consistent view of which workspace dependencies exist regardless of which workspace the user is browsing. Update DedicatedWorkersSelector to use the new cross-workspace endpoints with fallback to per-workspace calls for non-devops users. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * chore: update ee-repo-ref to include dedicated worker lookup simplification Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * chore: use branch name for ee-repo-ref (CI can't fetch by SHA from non-default branch) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Update ee-repo-ref.txt with new reference * sqlx * fix: revert serialization semaphore, multi-workspace picker, dep conflict warnings - Remove serialization_semaphore from executor start_worker signatures - Remove serialization test and fixtures - Fix DedicatedWorkersSelector to preserve tags from other workspaces when toggling in the picker - Track workspace deps per-workspace for conflict detection - Show warning when dep exists in another workspace but not the script's - Group runner groups per-workspace to prevent cross-workspace merging - Add workspace to dep badge link URL Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * chore: update ee-repo-ref Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: simplify exec protocol — execd: for single-script, exec: for runner groups Add execd:/execd_preprocess: commands to bun/deno/python wrappers for single-script dedicated workers (no path needed). Runner groups keep exec:/exec_preprocess: with path for multi-script disambiguation. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * test: add unit tests for execd:/exec: wrapper protocol Verify generate_multi_script_wrapper produces both execd: (single-script) and exec: (runner group) protocol handlers, including preprocessor variants. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Update commit reference in ee-repo-ref.txt * fix: remove beta badge from squash loop, keep tooltip Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: update protocol tests to use execd: for single-script wrappers Deno and bun single-script protocol tests now send execd:{args} instead of exec:{path}:{args}, matching the updated wrapper protocol. Multi-script (runner group) tests continue to use exec:{path}:{args}. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: remove unused TEST_SCRIPT_PATH in deno protocol tests Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: review feedback — down migration, push_as workspace, UI improvements - Use regexp_replace in down migration for positional accuracy - Fix push_as() to use self.workspace_id instead of hardcoded value - Remove per-workspace API fallbacks, use cross-workspace endpoints only - Skip devops-only API calls when user is not devops (disabled prop) - Fix duplicate key error for cross-workspace runner groups - Add workspace to RunnerGroup for unique keying - Reuse tagRow snippet for standalone items with expand/collapse - Fix picker alignment: remove empty column for non-expandable items Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * test: comprehensive dedicated worker test coverage, fix Python execd_preprocess - Add Python execd_preprocess: handler (was missing for single-script dedicated workers) - Add 10 E2E tests: flow+standalone conflict, mixed lang fallback, unsupported lang flow runners, python runner group, bun/python/deno/bunnative preprocessors, runner group preprocessors, branchone flow - Add 4 Python unit tests for execd:/execd_preprocess: protocol - Update EE ref Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * chore: update ee-repo-ref Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: review feedback — migration escaping, deno try/catch, loadRunnables guard - Down migration: use E'...' so \n matches actual newlines - Up migration: anchor regex with ^ to avoid mid-content matches - Deno execd_preprocess: move JSON.parse inside try/catch - DedicatedWorkersSelector: skip devops-only API calls when disabled Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * chore: update ee-repo-ref Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * test: add dedicated worker relative import tests for bun and python Verifies that build_loader's CURRENT_PATH correctly resolves workspace- relative imports when running on a dedicated worker subprocess. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: dedicated worker dispatch for nested flow structures (branches/loops) - Add extract_flow_root() to strip nesting segments from runnable_path - Dispatch uses flow_root/flow_step_id for nested paths, runnable_path for flat paths — deterministic, O(1) - Fix assert_ran_on_dedicated_worker to BFS all descendants - Fix python mode labels (python vs python3 for runner groups) - Add tests: simple forloop, multi-step forloop, whileloop, branchall, nested branch-in-loop, mixed lang fallback, unsupported lang runners Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * chore: fix ee-repo-ref SHA Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: hide picker and skip API calls for read-only users, hide empty runner badge - Hide "Add more scripts/flows" section when disabled (read-only) - Skip per-runnable API calls (getScriptByPath, getFlowByPath) for disabled users — just show path info - Hide "0 runners" badge on flows with no eligible steps Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * chore: update ee-repo-ref to 9422b189762ae27edfc346541ae668a4ad728325 This commit updates the EE repository reference after PR #503 was merged in windmill-ee-private. Previous ee-repo-ref: 4c6ba214bfc23fff05d1dc3200ac59e650af3f4f New ee-repo-ref: 9422b189762ae27edfc346541ae668a4ad728325 Automated by sync-ee-ref workflow. --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Co-authored-by: windmill-internal-app[bot] <windmill-internal-app[bot]@users.noreply.github.com>
600 lines
42 KiB
SQL
600 lines
42 KiB
SQL
-- Fixtures for dedicated worker E2E tests
|
|
|
|
-- A simple Bun script for testing dedicated Script steps in flows
|
|
INSERT INTO public.script(workspace_id, created_by, content, schema, summary, description, path, hash, language, lock, dedicated_worker) VALUES (
|
|
'test-workspace',
|
|
'system',
|
|
E'export function main(x: number) { return x * 2; }',
|
|
'{"$schema":"https://json-schema.org/draft/2020-12/schema","properties":{"x":{"type":"number","description":""}},"required":["x"],"type":"object"}',
|
|
'', '',
|
|
'f/system/dedicated_double', 300001, 'bun', E'{}\n//bun.lock\n<empty>', true);
|
|
|
|
-- Flow with a single RawScript inline bun step (the "Script not found" bug case)
|
|
INSERT INTO public.flow(workspace_id, summary, description, path, versions, schema, value, edited_by) VALUES (
|
|
'test-workspace', '', '',
|
|
'f/system/dedicated_rawscript_flow',
|
|
'{3000000000000001}',
|
|
'{"$schema":"https://json-schema.org/draft/2020-12/schema","properties":{"x":{"type":"number","description":""}},"required":["x"],"type":"object"}',
|
|
E'{"modules":[{"id":"a","value":{"type":"rawscript","content":"export function main(x: number) { return x + 10; }","language":"bun","input_transforms":{"x":{"expr":"flow_input.x","type":"javascript"}},"lock":"{}\\n//bun.lock\\n<empty>"}}]}',
|
|
'system'
|
|
);
|
|
|
|
INSERT INTO public.flow_version(id, workspace_id, path, schema, value, created_by) VALUES (
|
|
3000000000000001,
|
|
'test-workspace',
|
|
'f/system/dedicated_rawscript_flow',
|
|
'{"$schema":"https://json-schema.org/draft/2020-12/schema","properties":{"x":{"type":"number","description":""}},"required":["x"],"type":"object"}',
|
|
E'{"modules":[{"id":"a","value":{"type":"rawscript","content":"export function main(x: number) { return x + 10; }","language":"bun","input_transforms":{"x":{"expr":"flow_input.x","type":"javascript"}},"lock":"{}\\n//bun.lock\\n<empty>"}}]}',
|
|
'system'
|
|
);
|
|
|
|
-- Flow with a Script step referencing the external dedicated_double script
|
|
INSERT INTO public.flow(workspace_id, summary, description, path, versions, schema, value, edited_by) VALUES (
|
|
'test-workspace', '', '',
|
|
'f/system/dedicated_script_flow',
|
|
'{3000000000000002}',
|
|
'{"$schema":"https://json-schema.org/draft/2020-12/schema","properties":{"x":{"type":"number","description":""}},"required":["x"],"type":"object"}',
|
|
'{"modules":[{"id":"a","value":{"type":"script","path":"f/system/dedicated_double","input_transforms":{"x":{"expr":"flow_input.x","type":"javascript"}}}}]}',
|
|
'system'
|
|
);
|
|
|
|
INSERT INTO public.flow_version(id, workspace_id, path, schema, value, created_by) VALUES (
|
|
3000000000000002,
|
|
'test-workspace',
|
|
'f/system/dedicated_script_flow',
|
|
'{"$schema":"https://json-schema.org/draft/2020-12/schema","properties":{"x":{"type":"number","description":""}},"required":["x"],"type":"object"}',
|
|
'{"modules":[{"id":"a","value":{"type":"script","path":"f/system/dedicated_double","input_transforms":{"x":{"expr":"flow_input.x","type":"javascript"}}}}]}',
|
|
'system'
|
|
);
|
|
|
|
-- Flow with two inline RawScript steps (tests multi-step key uniqueness)
|
|
INSERT INTO public.flow(workspace_id, summary, description, path, versions, schema, value, edited_by) VALUES (
|
|
'test-workspace', '', '',
|
|
'f/system/dedicated_multi_step_flow',
|
|
'{3000000000000003}',
|
|
'{"$schema":"https://json-schema.org/draft/2020-12/schema","properties":{"x":{"type":"number","description":""}},"required":["x"],"type":"object"}',
|
|
E'{"modules":[{"id":"a","value":{"type":"rawscript","content":"export function main(x: number) { return x + 1; }","language":"bun","input_transforms":{"x":{"expr":"flow_input.x","type":"javascript"}},"lock":"{}\\n//bun.lock\\n<empty>"}},{"id":"b","value":{"type":"rawscript","content":"export function main(x: number) { return x * 3; }","language":"bun","input_transforms":{"x":{"expr":"results.a","type":"javascript"}},"lock":"{}\\n//bun.lock\\n<empty>"}}]}',
|
|
'system'
|
|
);
|
|
|
|
INSERT INTO public.flow_version(id, workspace_id, path, schema, value, created_by) VALUES (
|
|
3000000000000003,
|
|
'test-workspace',
|
|
'f/system/dedicated_multi_step_flow',
|
|
'{"$schema":"https://json-schema.org/draft/2020-12/schema","properties":{"x":{"type":"number","description":""}},"required":["x"],"type":"object"}',
|
|
E'{"modules":[{"id":"a","value":{"type":"rawscript","content":"export function main(x: number) { return x + 1; }","language":"bun","input_transforms":{"x":{"expr":"flow_input.x","type":"javascript"}},"lock":"{}\\n//bun.lock\\n<empty>"}},{"id":"b","value":{"type":"rawscript","content":"export function main(x: number) { return x * 3; }","language":"bun","input_transforms":{"x":{"expr":"results.a","type":"javascript"}},"lock":"{}\\n//bun.lock\\n<empty>"}}]}',
|
|
'system'
|
|
);
|
|
|
|
-- Two scripts sharing a workspace dependency for runner group testing.
|
|
-- Both reference the same external dep "f/system/dedicated_double" via extra_package_json annotation.
|
|
INSERT INTO public.script(workspace_id, created_by, content, schema, summary, description, path, hash, language, lock, dedicated_worker) VALUES (
|
|
'test-workspace',
|
|
'system',
|
|
E'// extra_package_json: f/system/dedicated_double\nexport function main(x: number) { return x + 100; }',
|
|
'{"$schema":"https://json-schema.org/draft/2020-12/schema","properties":{"x":{"type":"number","description":""}},"required":["x"],"type":"object"}',
|
|
'', '',
|
|
'f/system/rg_script_a', 300010, 'bun', E'{}\n//bun.lock\n<empty>', true);
|
|
|
|
INSERT INTO public.script(workspace_id, created_by, content, schema, summary, description, path, hash, language, lock, dedicated_worker) VALUES (
|
|
'test-workspace',
|
|
'system',
|
|
E'// extra_package_json: f/system/dedicated_double\nexport function main(x: number) { return x + 200; }',
|
|
'{"$schema":"https://json-schema.org/draft/2020-12/schema","properties":{"x":{"type":"number","description":""}},"required":["x"],"type":"object"}',
|
|
'', '',
|
|
'f/system/rg_script_b', 300011, 'bun', E'{}\n//bun.lock\n<empty>', true);
|
|
|
|
-- Flow with a Deno inline RawScript step
|
|
INSERT INTO public.flow(workspace_id, summary, description, path, versions, schema, value, edited_by) VALUES (
|
|
'test-workspace', '', '',
|
|
'f/system/dedicated_deno_flow',
|
|
'{3000000000000005}',
|
|
'{"$schema":"https://json-schema.org/draft/2020-12/schema","properties":{"x":{"type":"number","description":""}},"required":["x"],"type":"object"}',
|
|
E'{"modules":[{"id":"a","value":{"type":"rawscript","content":"export function main(x: number) { return x + 100; }","language":"deno","input_transforms":{"x":{"expr":"flow_input.x","type":"javascript"}}}}]}',
|
|
'system'
|
|
);
|
|
|
|
INSERT INTO public.flow_version(id, workspace_id, path, schema, value, created_by) VALUES (
|
|
3000000000000005,
|
|
'test-workspace',
|
|
'f/system/dedicated_deno_flow',
|
|
'{"$schema":"https://json-schema.org/draft/2020-12/schema","properties":{"x":{"type":"number","description":""}},"required":["x"],"type":"object"}',
|
|
E'{"modules":[{"id":"a","value":{"type":"rawscript","content":"export function main(x: number) { return x + 100; }","language":"deno","input_transforms":{"x":{"expr":"flow_input.x","type":"javascript"}}}}]}',
|
|
'system'
|
|
);
|
|
|
|
-- Flow with a Python inline RawScript step
|
|
INSERT INTO public.flow(workspace_id, summary, description, path, versions, schema, value, edited_by) VALUES (
|
|
'test-workspace', '', '',
|
|
'f/system/dedicated_python_flow',
|
|
'{3000000000000006}',
|
|
'{"$schema":"https://json-schema.org/draft/2020-12/schema","properties":{"x":{"type":"number","description":""}},"required":["x"],"type":"object"}',
|
|
E'{"modules":[{"id":"a","value":{"type":"rawscript","content":"def main(x: int):\\n return x + 100","language":"python3","input_transforms":{"x":{"expr":"flow_input.x","type":"javascript"}}}}]}',
|
|
'system'
|
|
);
|
|
|
|
INSERT INTO public.flow_version(id, workspace_id, path, schema, value, created_by) VALUES (
|
|
3000000000000006,
|
|
'test-workspace',
|
|
'f/system/dedicated_python_flow',
|
|
'{"$schema":"https://json-schema.org/draft/2020-12/schema","properties":{"x":{"type":"number","description":""}},"required":["x"],"type":"object"}',
|
|
E'{"modules":[{"id":"a","value":{"type":"rawscript","content":"def main(x: int):\\n return x + 100","language":"python3","input_transforms":{"x":{"expr":"flow_input.x","type":"javascript"}}}}]}',
|
|
'system'
|
|
);
|
|
|
|
-- Flow with a Bunnative (//native) inline RawScript step
|
|
INSERT INTO public.flow(workspace_id, summary, description, path, versions, schema, value, edited_by) VALUES (
|
|
'test-workspace', '', '',
|
|
'f/system/dedicated_bunnative_flow',
|
|
'{3000000000000007}',
|
|
'{"$schema":"https://json-schema.org/draft/2020-12/schema","properties":{"x":{"type":"number","description":""}},"required":["x"],"type":"object"}',
|
|
E'{"modules":[{"id":"a","value":{"type":"rawscript","content":"//native\\nexport function main(x: number) { return x + 100; }","language":"bunnative","input_transforms":{"x":{"expr":"flow_input.x","type":"javascript"}},"lock":"{}\\n//bun.lock\\n<empty>"}}]}',
|
|
'system'
|
|
);
|
|
|
|
INSERT INTO public.flow_version(id, workspace_id, path, schema, value, created_by) VALUES (
|
|
3000000000000007,
|
|
'test-workspace',
|
|
'f/system/dedicated_bunnative_flow',
|
|
'{"$schema":"https://json-schema.org/draft/2020-12/schema","properties":{"x":{"type":"number","description":""}},"required":["x"],"type":"object"}',
|
|
E'{"modules":[{"id":"a","value":{"type":"rawscript","content":"//native\\nexport function main(x: number) { return x + 100; }","language":"bunnative","input_transforms":{"x":{"expr":"flow_input.x","type":"javascript"}},"lock":"{}\\n//bun.lock\\n<empty>"}}]}',
|
|
'system'
|
|
);
|
|
|
|
-- Flow with a Bun + //nodejs annotation inline RawScript step
|
|
INSERT INTO public.flow(workspace_id, summary, description, path, versions, schema, value, edited_by) VALUES (
|
|
'test-workspace', '', '',
|
|
'f/system/dedicated_nodejs_flow',
|
|
'{3000000000000008}',
|
|
'{"$schema":"https://json-schema.org/draft/2020-12/schema","properties":{"x":{"type":"number","description":""}},"required":["x"],"type":"object"}',
|
|
E'{"modules":[{"id":"a","value":{"type":"rawscript","content":"//nodejs\\nexport function main(x: number) { return x + 100; }","language":"bun","input_transforms":{"x":{"expr":"flow_input.x","type":"javascript"}},"lock":"{}\\n//bun.lock\\n<empty>"}}]}',
|
|
'system'
|
|
);
|
|
|
|
INSERT INTO public.flow_version(id, workspace_id, path, schema, value, created_by) VALUES (
|
|
3000000000000008,
|
|
'test-workspace',
|
|
'f/system/dedicated_nodejs_flow',
|
|
'{"$schema":"https://json-schema.org/draft/2020-12/schema","properties":{"x":{"type":"number","description":""}},"required":["x"],"type":"object"}',
|
|
E'{"modules":[{"id":"a","value":{"type":"rawscript","content":"//nodejs\\nexport function main(x: number) { return x + 100; }","language":"bun","input_transforms":{"x":{"expr":"flow_input.x","type":"javascript"}},"lock":"{}\\n//bun.lock\\n<empty>"}}]}',
|
|
'system'
|
|
);
|
|
|
|
-- Flow with a squashed for-loop for testing flow runners.
|
|
-- The for-loop iterates over [1, 2, 3], each iteration runs a simple bun rawscript.
|
|
-- squash=true triggers spawn_flow_module_runners to create dedicated subprocesses.
|
|
INSERT INTO public.flow(workspace_id, summary, description, path, versions, schema, value, edited_by) VALUES (
|
|
'test-workspace', '', '',
|
|
'f/system/dedicated_flow_runners',
|
|
'{3000000000000004}',
|
|
'{"$schema":"https://json-schema.org/draft/2020-12/schema","properties":{},"required":[],"type":"object"}',
|
|
E'{"modules":[{"id":"a","value":{"type":"forloopflow","iterator":{"type":"javascript","expr":"[1, 2, 3]"},"skip_failures":false,"parallel":false,"squash":true,"modules":[{"id":"b","value":{"type":"rawscript","content":"export function main(iter: {value: number, index: number}) { return iter.value * 10; }","language":"bun","input_transforms":{"iter":{"expr":"flow_input.iter","type":"javascript"}},"lock":"{}\\n//bun.lock\\n<empty>"}}]}}]}',
|
|
'system'
|
|
);
|
|
|
|
INSERT INTO public.flow_version(id, workspace_id, path, schema, value, created_by) VALUES (
|
|
3000000000000004,
|
|
'test-workspace',
|
|
'f/system/dedicated_flow_runners',
|
|
'{"$schema":"https://json-schema.org/draft/2020-12/schema","properties":{},"required":[],"type":"object"}',
|
|
E'{"modules":[{"id":"a","value":{"type":"forloopflow","iterator":{"type":"javascript","expr":"[1, 2, 3]"},"skip_failures":false,"parallel":false,"squash":true,"modules":[{"id":"b","value":{"type":"rawscript","content":"export function main(iter: {value: number, index: number}) { return iter.value * 10; }","language":"bun","input_transforms":{"iter":{"expr":"flow_input.iter","type":"javascript"}},"lock":"{}\\n//bun.lock\\n<empty>"}}]}}]}',
|
|
'system'
|
|
);
|
|
|
|
-- Two flows with conflicting step IDs (both have module "a") but different RawScript content.
|
|
-- Tests that runnable_path-based lookup correctly disambiguates them.
|
|
-- Flow A: x + 1000
|
|
INSERT INTO public.flow(workspace_id, summary, description, path, versions, schema, value, edited_by) VALUES (
|
|
'test-workspace', '', '',
|
|
'f/system/conflict_flow_a',
|
|
'{3000000000000009}',
|
|
'{"$schema":"https://json-schema.org/draft/2020-12/schema","properties":{"x":{"type":"number","description":""}},"required":["x"],"type":"object"}',
|
|
E'{"modules":[{"id":"a","value":{"type":"rawscript","content":"export function main(x: number) { return x + 1000; }","language":"bun","input_transforms":{"x":{"expr":"flow_input.x","type":"javascript"}},"lock":"{}\\n//bun.lock\\n<empty>"}}]}',
|
|
'system'
|
|
);
|
|
|
|
INSERT INTO public.flow_version(id, workspace_id, path, schema, value, created_by) VALUES (
|
|
3000000000000009,
|
|
'test-workspace',
|
|
'f/system/conflict_flow_a',
|
|
'{"$schema":"https://json-schema.org/draft/2020-12/schema","properties":{"x":{"type":"number","description":""}},"required":["x"],"type":"object"}',
|
|
E'{"modules":[{"id":"a","value":{"type":"rawscript","content":"export function main(x: number) { return x + 1000; }","language":"bun","input_transforms":{"x":{"expr":"flow_input.x","type":"javascript"}},"lock":"{}\\n//bun.lock\\n<empty>"}}]}',
|
|
'system'
|
|
);
|
|
|
|
-- Flow B: x + 2000
|
|
INSERT INTO public.flow(workspace_id, summary, description, path, versions, schema, value, edited_by) VALUES (
|
|
'test-workspace', '', '',
|
|
'f/system/conflict_flow_b',
|
|
'{3000000000000010}',
|
|
'{"$schema":"https://json-schema.org/draft/2020-12/schema","properties":{"x":{"type":"number","description":""}},"required":["x"],"type":"object"}',
|
|
E'{"modules":[{"id":"a","value":{"type":"rawscript","content":"export function main(x: number) { return x + 2000; }","language":"bun","input_transforms":{"x":{"expr":"flow_input.x","type":"javascript"}},"lock":"{}\\n//bun.lock\\n<empty>"}}]}',
|
|
'system'
|
|
);
|
|
|
|
INSERT INTO public.flow_version(id, workspace_id, path, schema, value, created_by) VALUES (
|
|
3000000000000010,
|
|
'test-workspace',
|
|
'f/system/conflict_flow_b',
|
|
'{"$schema":"https://json-schema.org/draft/2020-12/schema","properties":{"x":{"type":"number","description":""}},"required":["x"],"type":"object"}',
|
|
E'{"modules":[{"id":"a","value":{"type":"rawscript","content":"export function main(x: number) { return x + 2000; }","language":"bun","input_transforms":{"x":{"expr":"flow_input.x","type":"javascript"}},"lock":"{}\\n//bun.lock\\n<empty>"}}]}',
|
|
'system'
|
|
);
|
|
|
|
-- A dedicated worker script with a preprocessor function.
|
|
-- preprocessor doubles x, main adds 100.
|
|
INSERT INTO public.script(workspace_id, created_by, content, schema, summary, description, path, hash, language, lock, dedicated_worker) VALUES (
|
|
'test-workspace',
|
|
'system',
|
|
E'export function preprocessor(x: number) { return { x: x * 2 }; }\nexport function main(x: number) { return x + 100; }',
|
|
'{"$schema":"https://json-schema.org/draft/2020-12/schema","properties":{"x":{"type":"number","description":""}},"required":["x"],"type":"object"}',
|
|
'', '',
|
|
'f/system/preprocess_script', 300030, 'bun', E'{}\n//bun.lock\n<empty>', true);
|
|
|
|
-- Second workspace for cross-workspace isolation testing.
|
|
INSERT INTO workspace(id, name, owner) VALUES ('test-workspace-2', 'test-workspace-2', 'test-user');
|
|
INSERT INTO usr(workspace_id, email, username, is_admin, role) VALUES
|
|
('test-workspace-2', 'test@windmill.dev', 'test-user', true, 'Admin');
|
|
INSERT INTO workspace_key(workspace_id, kind, key) VALUES
|
|
('test-workspace-2', 'cloud', 'test-key-2');
|
|
INSERT INTO workspace_settings (workspace_id) VALUES ('test-workspace-2');
|
|
INSERT INTO group_ (workspace_id, name, summary, extra_perms) VALUES
|
|
('test-workspace-2', 'all', 'All users', '{}');
|
|
|
|
-- Same path as dedicated_double but in workspace 2, returns x * 3 instead of x * 2.
|
|
INSERT INTO public.script(workspace_id, created_by, content, schema, summary, description, path, hash, language, lock, dedicated_worker) VALUES (
|
|
'test-workspace-2',
|
|
'system',
|
|
E'export function main(x: number) { return x * 3; }',
|
|
'{"$schema":"https://json-schema.org/draft/2020-12/schema","properties":{"x":{"type":"number","description":""}},"required":["x"],"type":"object"}',
|
|
'', '',
|
|
'f/system/dedicated_double', 300040, 'bun', E'{}\n//bun.lock\n<empty>', true);
|
|
|
|
-- ============================================================
|
|
-- Test: flow Script step + standalone conflict
|
|
-- Flow references dedicated_double (also configured as standalone).
|
|
-- Standalone worker should handle both its own jobs and the flow's Script step jobs.
|
|
-- ============================================================
|
|
INSERT INTO public.flow(workspace_id, summary, description, path, versions, schema, value, edited_by) VALUES (
|
|
'test-workspace', '', '',
|
|
'f/system/dedicated_conflict_standalone_flow',
|
|
'{3000000000000011}',
|
|
'{"$schema":"https://json-schema.org/draft/2020-12/schema","properties":{"x":{"type":"number","description":""}},"required":["x"],"type":"object"}',
|
|
'{"modules":[{"id":"a","value":{"type":"script","path":"f/system/dedicated_double","input_transforms":{"x":{"expr":"flow_input.x","type":"javascript"}}}}]}',
|
|
'system'
|
|
);
|
|
|
|
INSERT INTO public.flow_version(id, workspace_id, path, schema, value, created_by) VALUES (
|
|
3000000000000011,
|
|
'test-workspace',
|
|
'f/system/dedicated_conflict_standalone_flow',
|
|
'{"$schema":"https://json-schema.org/draft/2020-12/schema","properties":{"x":{"type":"number","description":""}},"required":["x"],"type":"object"}',
|
|
'{"modules":[{"id":"a","value":{"type":"script","path":"f/system/dedicated_double","input_transforms":{"x":{"expr":"flow_input.x","type":"javascript"}}}}]}',
|
|
'system'
|
|
);
|
|
|
|
-- ============================================================
|
|
-- Test: non-dedicated step inside dedicated flow
|
|
-- Flow with bun step (x + 10) then bash step (echo result * 2).
|
|
-- The bun step runs on dedicated worker; bash falls back to normal execution.
|
|
-- ============================================================
|
|
INSERT INTO public.flow(workspace_id, summary, description, path, versions, schema, value, edited_by) VALUES (
|
|
'test-workspace', '', '',
|
|
'f/system/dedicated_mixed_lang_flow',
|
|
'{3000000000000012}',
|
|
'{"$schema":"https://json-schema.org/draft/2020-12/schema","properties":{"x":{"type":"number","description":""}},"required":["x"],"type":"object"}',
|
|
E'{"modules":[{"id":"a","value":{"type":"rawscript","content":"export function main(x: number) { return x + 10; }","language":"bun","input_transforms":{"x":{"expr":"flow_input.x","type":"javascript"}},"lock":"{}\\n//bun.lock\\n<empty>"}},{"id":"b","value":{"type":"rawscript","content":"echo done","language":"bash","input_transforms":{"results_a":{"expr":"results.a","type":"javascript"}}}}]}',
|
|
'system'
|
|
);
|
|
|
|
INSERT INTO public.flow_version(id, workspace_id, path, schema, value, created_by) VALUES (
|
|
3000000000000012,
|
|
'test-workspace',
|
|
'f/system/dedicated_mixed_lang_flow',
|
|
'{"$schema":"https://json-schema.org/draft/2020-12/schema","properties":{"x":{"type":"number","description":""}},"required":["x"],"type":"object"}',
|
|
E'{"modules":[{"id":"a","value":{"type":"rawscript","content":"export function main(x: number) { return x + 10; }","language":"bun","input_transforms":{"x":{"expr":"flow_input.x","type":"javascript"}},"lock":"{}\\n//bun.lock\\n<empty>"}},{"id":"b","value":{"type":"rawscript","content":"echo done","language":"bash","input_transforms":{"results_a":{"expr":"results.a","type":"javascript"}}}}]}',
|
|
'system'
|
|
);
|
|
|
|
-- ============================================================
|
|
-- Test: non-dedicated step inside flow runners (squashed loop)
|
|
-- Squashed for-loop with a bash step. Bash can't spawn a flow runner,
|
|
-- so each iteration falls back to normal execution.
|
|
-- ============================================================
|
|
INSERT INTO public.flow(workspace_id, summary, description, path, versions, schema, value, edited_by) VALUES (
|
|
'test-workspace', '', '',
|
|
'f/system/dedicated_flow_runners_bash',
|
|
'{3000000000000013}',
|
|
'{"$schema":"https://json-schema.org/draft/2020-12/schema","properties":{},"required":[],"type":"object"}',
|
|
E'{"modules":[{"id":"a","value":{"type":"forloopflow","iterator":{"type":"javascript","expr":"[1, 2, 3]"},"skip_failures":false,"parallel":false,"squash":true,"modules":[{"id":"b","value":{"type":"rawscript","content":"echo done","language":"bash","input_transforms":{"iter_value":{"expr":"flow_input.iter.value","type":"javascript"}}}}]}}]}',
|
|
'system'
|
|
);
|
|
|
|
INSERT INTO public.flow_version(id, workspace_id, path, schema, value, created_by) VALUES (
|
|
3000000000000013,
|
|
'test-workspace',
|
|
'f/system/dedicated_flow_runners_bash',
|
|
'{"$schema":"https://json-schema.org/draft/2020-12/schema","properties":{},"required":[],"type":"object"}',
|
|
E'{"modules":[{"id":"a","value":{"type":"forloopflow","iterator":{"type":"javascript","expr":"[1, 2, 3]"},"skip_failures":false,"parallel":false,"squash":true,"modules":[{"id":"b","value":{"type":"rawscript","content":"echo done","language":"bash","input_transforms":{"iter_value":{"expr":"flow_input.iter.value","type":"javascript"}}}}]}}]}',
|
|
'system'
|
|
);
|
|
|
|
-- ============================================================
|
|
-- Test: Python runner group
|
|
-- Two Python scripts sharing a workspace dependency annotation.
|
|
-- ============================================================
|
|
INSERT INTO public.script(workspace_id, created_by, content, schema, summary, description, path, hash, language, lock, dedicated_worker) VALUES (
|
|
'test-workspace',
|
|
'system',
|
|
E'# extra_requirements: f/system/dedicated_double\ndef main(x: int):\n return x + 100',
|
|
'{"$schema":"https://json-schema.org/draft/2020-12/schema","properties":{"x":{"type":"number","description":""}},"required":["x"],"type":"object"}',
|
|
'', '',
|
|
'f/system/py_rg_script_a', 300050, 'python3', '', true);
|
|
|
|
INSERT INTO public.script(workspace_id, created_by, content, schema, summary, description, path, hash, language, lock, dedicated_worker) VALUES (
|
|
'test-workspace',
|
|
'system',
|
|
E'# extra_requirements: f/system/dedicated_double\ndef main(x: int):\n return x + 200',
|
|
'{"$schema":"https://json-schema.org/draft/2020-12/schema","properties":{"x":{"type":"number","description":""}},"required":["x"],"type":"object"}',
|
|
'', '',
|
|
'f/system/py_rg_script_b', 300051, 'python3', '', true);
|
|
|
|
-- ============================================================
|
|
-- Test: preprocessor in runner group
|
|
-- Two bun scripts sharing a workspace dep, one has a preprocessor.
|
|
-- Tests exec_preprocess:{path}:{args} protocol in runner groups.
|
|
-- ============================================================
|
|
INSERT INTO public.script(workspace_id, created_by, content, schema, summary, description, path, hash, language, lock, dedicated_worker) VALUES (
|
|
'test-workspace',
|
|
'system',
|
|
E'// extra_package_json: f/system/dedicated_double\nexport function preprocessor(x: number) { return { x: x * 2 }; }\nexport function main(x: number) { return x + 100; }',
|
|
'{"$schema":"https://json-schema.org/draft/2020-12/schema","properties":{"x":{"type":"number","description":""}},"required":["x"],"type":"object"}',
|
|
'', '',
|
|
'f/system/rg_preprocess_script', 300052, 'bun', E'{}\n//bun.lock\n<empty>', true);
|
|
|
|
INSERT INTO public.script(workspace_id, created_by, content, schema, summary, description, path, hash, language, lock, dedicated_worker) VALUES (
|
|
'test-workspace',
|
|
'system',
|
|
E'// extra_package_json: f/system/dedicated_double\nexport function main(x: number) { return x + 300; }',
|
|
'{"$schema":"https://json-schema.org/draft/2020-12/schema","properties":{"x":{"type":"number","description":""}},"required":["x"],"type":"object"}',
|
|
'', '',
|
|
'f/system/rg_preprocess_other', 300053, 'bun', E'{}\n//bun.lock\n<empty>', true);
|
|
|
|
-- ============================================================
|
|
-- Test: flow with BranchOne
|
|
-- Flow with branchone: condition true → branch (x + 100), default → (x + 200).
|
|
-- Tests recursive module traversal for spawning dedicated workers.
|
|
-- ============================================================
|
|
INSERT INTO public.flow(workspace_id, summary, description, path, versions, schema, value, edited_by) VALUES (
|
|
'test-workspace', '', '',
|
|
'f/system/dedicated_branch_flow',
|
|
'{3000000000000014}',
|
|
'{"$schema":"https://json-schema.org/draft/2020-12/schema","properties":{"x":{"type":"number","description":""}},"required":["x"],"type":"object"}',
|
|
E'{"modules":[{"id":"a","value":{"type":"branchone","branches":[{"expr":"flow_input.x > 10","modules":[{"id":"b","value":{"type":"rawscript","content":"export function main(x: number) { return x + 100; }","language":"bun","input_transforms":{"x":{"expr":"flow_input.x","type":"javascript"}},"lock":"{}\\n//bun.lock\\n<empty>"}}]}],"default":[{"id":"c","value":{"type":"rawscript","content":"export function main(x: number) { return x + 200; }","language":"bun","input_transforms":{"x":{"expr":"flow_input.x","type":"javascript"}},"lock":"{}\\n//bun.lock\\n<empty>"}}]}}]}',
|
|
'system'
|
|
);
|
|
|
|
INSERT INTO public.flow_version(id, workspace_id, path, schema, value, created_by) VALUES (
|
|
3000000000000014,
|
|
'test-workspace',
|
|
'f/system/dedicated_branch_flow',
|
|
'{"$schema":"https://json-schema.org/draft/2020-12/schema","properties":{"x":{"type":"number","description":""}},"required":["x"],"type":"object"}',
|
|
E'{"modules":[{"id":"a","value":{"type":"branchone","branches":[{"expr":"flow_input.x > 10","modules":[{"id":"b","value":{"type":"rawscript","content":"export function main(x: number) { return x + 100; }","language":"bun","input_transforms":{"x":{"expr":"flow_input.x","type":"javascript"}},"lock":"{}\\n//bun.lock\\n<empty>"}}]}],"default":[{"id":"c","value":{"type":"rawscript","content":"export function main(x: number) { return x + 200; }","language":"bun","input_transforms":{"x":{"expr":"flow_input.x","type":"javascript"}},"lock":"{}\\n//bun.lock\\n<empty>"}}]}}]}',
|
|
'system'
|
|
);
|
|
|
|
-- ============================================================
|
|
-- Test: Python standalone preprocessor
|
|
-- Python script with preprocessor function. Tests execd_preprocess: protocol.
|
|
-- ============================================================
|
|
INSERT INTO public.script(workspace_id, created_by, content, schema, summary, description, path, hash, language, lock, dedicated_worker) VALUES (
|
|
'test-workspace',
|
|
'system',
|
|
E'def preprocessor(x: int):\n return {"x": x * 2}\n\ndef main(x: int):\n return x + 100',
|
|
'{"$schema":"https://json-schema.org/draft/2020-12/schema","properties":{"x":{"type":"number","description":""}},"required":["x"],"type":"object"}',
|
|
'', '',
|
|
'f/system/py_preprocess_script', 300054, 'python3', '', true);
|
|
|
|
-- ============================================================
|
|
-- Test: Deno standalone preprocessor
|
|
-- Deno script with preprocessor function. Tests execd_preprocess: protocol.
|
|
-- ============================================================
|
|
INSERT INTO public.script(workspace_id, created_by, content, schema, summary, description, path, hash, language, lock, dedicated_worker) VALUES (
|
|
'test-workspace',
|
|
'system',
|
|
E'export function preprocessor(x: number) { return { x: x * 2 }; }\nexport function main(x: number) { return x + 100; }',
|
|
'{"$schema":"https://json-schema.org/draft/2020-12/schema","properties":{"x":{"type":"number","description":""}},"required":["x"],"type":"object"}',
|
|
'', '',
|
|
'f/system/deno_preprocess_script', 300055, 'deno', '', true);
|
|
|
|
-- ============================================================
|
|
-- Test: Python runner group preprocessor
|
|
-- Two Python scripts sharing a workspace dep, one has a preprocessor.
|
|
-- Tests exec_preprocess:{path}:{args} protocol for Python runner groups.
|
|
-- ============================================================
|
|
INSERT INTO public.script(workspace_id, created_by, content, schema, summary, description, path, hash, language, lock, dedicated_worker) VALUES (
|
|
'test-workspace',
|
|
'system',
|
|
E'# extra_requirements: f/system/py_preprocess_script\ndef preprocessor(x: int):\n return {"x": x * 2}\n\ndef main(x: int):\n return x + 100',
|
|
'{"$schema":"https://json-schema.org/draft/2020-12/schema","properties":{"x":{"type":"number","description":""}},"required":["x"],"type":"object"}',
|
|
'', '',
|
|
'f/system/py_rg_preprocess_a', 300056, 'python3', '', true);
|
|
|
|
INSERT INTO public.script(workspace_id, created_by, content, schema, summary, description, path, hash, language, lock, dedicated_worker) VALUES (
|
|
'test-workspace',
|
|
'system',
|
|
E'# extra_requirements: f/system/py_preprocess_script\ndef main(x: int):\n return x + 300',
|
|
'{"$schema":"https://json-schema.org/draft/2020-12/schema","properties":{"x":{"type":"number","description":""}},"required":["x"],"type":"object"}',
|
|
'', '',
|
|
'f/system/py_rg_preprocess_b', 300057, 'python3', '', true);
|
|
|
|
-- ============================================================
|
|
-- Test: Bunnative standalone preprocessor
|
|
-- Bunnative script with preprocessor function. Tests V8 isolate preprocessing.
|
|
-- ============================================================
|
|
INSERT INTO public.script(workspace_id, created_by, content, schema, summary, description, path, hash, language, lock, dedicated_worker) VALUES (
|
|
'test-workspace',
|
|
'system',
|
|
E'//native\nexport function preprocessor(x: number) { return { x: x * 2 }; }\nexport function main(x: number) { return x + 100; }',
|
|
'{"$schema":"https://json-schema.org/draft/2020-12/schema","properties":{"x":{"type":"number","description":""}},"required":["x"],"type":"object"}',
|
|
'', '',
|
|
'f/system/bunnative_preprocess_script', 300058, 'bunnative', E'{}\n//bun.lock\n<empty>', true);
|
|
|
|
-- ============================================================
|
|
-- Test: Bun dedicated worker with relative imports
|
|
-- Helper script at f/system/dedicated_helper (returns x * 10).
|
|
-- Dedicated script imports from it using a relative path.
|
|
-- ============================================================
|
|
INSERT INTO public.script(workspace_id, created_by, content, schema, summary, description, path, hash, language, lock) VALUES (
|
|
'test-workspace',
|
|
'system',
|
|
E'export function helper(x: number) { return x * 10; }',
|
|
'{"$schema":"https://json-schema.org/draft/2020-12/schema","properties":{},"required":[],"type":"object"}',
|
|
'', '',
|
|
'f/system/dedicated_helper', 300060, 'bun', E'{}\n//bun.lock\n<empty>');
|
|
|
|
INSERT INTO public.script(workspace_id, created_by, content, schema, summary, description, path, hash, language, lock, dedicated_worker) VALUES (
|
|
'test-workspace',
|
|
'system',
|
|
E'import { helper } from "./dedicated_helper.ts";\n\nexport function main(x: number) { return helper(x) + 1; }',
|
|
'{"$schema":"https://json-schema.org/draft/2020-12/schema","properties":{"x":{"type":"number","description":""}},"required":["x"],"type":"object"}',
|
|
'', '',
|
|
'f/system/dedicated_with_import', 300061, 'bun', E'{}\n//bun.lock\n<empty>', true);
|
|
|
|
-- ============================================================
|
|
-- Test: Python dedicated worker with relative imports
|
|
-- Helper script at f/system/py_dedicated_helper (returns x * 10).
|
|
-- Dedicated script imports from it using a relative path.
|
|
-- ============================================================
|
|
INSERT INTO public.script(workspace_id, created_by, content, schema, summary, description, path, hash, language, lock) VALUES (
|
|
'test-workspace',
|
|
'system',
|
|
E'def helper(x: int):\n return x * 10',
|
|
'{"$schema":"https://json-schema.org/draft/2020-12/schema","properties":{},"required":[],"type":"object"}',
|
|
'', '',
|
|
'f/system/py_dedicated_helper', 300062, 'python3', '');
|
|
|
|
INSERT INTO public.script(workspace_id, created_by, content, schema, summary, description, path, hash, language, lock, dedicated_worker) VALUES (
|
|
'test-workspace',
|
|
'system',
|
|
E'from .py_dedicated_helper import helper\n\ndef main(x: int):\n return helper(x) + 1',
|
|
'{"$schema":"https://json-schema.org/draft/2020-12/schema","properties":{"x":{"type":"number","description":""}},"required":["x"],"type":"object"}',
|
|
'', '',
|
|
'f/system/py_dedicated_with_import', 300063, 'python3', '', true);
|
|
|
|
-- ============================================================
|
|
-- Test: non-squashed for-loop in dedicated flow
|
|
-- For-loop iterates over [1, 2, 3], inner bun step returns iter.value * 10.
|
|
-- NOT squashed, so inner steps use the dedicated worker map (not flow runners).
|
|
-- ============================================================
|
|
INSERT INTO public.flow(workspace_id, summary, description, path, versions, schema, value, edited_by) VALUES (
|
|
'test-workspace', '', '',
|
|
'f/system/dedicated_forloop_flow',
|
|
'{3000000000000015}',
|
|
'{"$schema":"https://json-schema.org/draft/2020-12/schema","properties":{},"required":[],"type":"object"}',
|
|
E'{"modules":[{"id":"a","value":{"type":"forloopflow","iterator":{"type":"javascript","expr":"[1, 2, 3]"},"skip_failures":false,"parallel":false,"squash":false,"modules":[{"id":"b","value":{"type":"rawscript","content":"export function main(iter: {value: number, index: number}) { return iter.value * 10; }","language":"bun","input_transforms":{"iter":{"expr":"flow_input.iter","type":"javascript"}},"lock":"{}\\n//bun.lock\\n<empty>"}}]}}]}',
|
|
'system'
|
|
);
|
|
|
|
INSERT INTO public.flow_version(id, workspace_id, path, schema, value, created_by) VALUES (
|
|
3000000000000015,
|
|
'test-workspace',
|
|
'f/system/dedicated_forloop_flow',
|
|
'{"$schema":"https://json-schema.org/draft/2020-12/schema","properties":{},"required":[],"type":"object"}',
|
|
E'{"modules":[{"id":"a","value":{"type":"forloopflow","iterator":{"type":"javascript","expr":"[1, 2, 3]"},"skip_failures":false,"parallel":false,"squash":false,"modules":[{"id":"b","value":{"type":"rawscript","content":"export function main(iter: {value: number, index: number}) { return iter.value * 10; }","language":"bun","input_transforms":{"iter":{"expr":"flow_input.iter","type":"javascript"}},"lock":"{}\\n//bun.lock\\n<empty>"}}]}}]}',
|
|
'system'
|
|
);
|
|
|
|
-- ============================================================
|
|
-- Test: non-simple for-loop in dedicated flow (multi-step)
|
|
-- For-loop iterates over [1, 2, 3], two steps: step b (iter.value + 1), step c (results.b * 10).
|
|
-- Two steps makes is_simple_modules false, so inner steps run as separate jobs.
|
|
-- ============================================================
|
|
INSERT INTO public.flow(workspace_id, summary, description, path, versions, schema, value, edited_by) VALUES (
|
|
'test-workspace', '', '',
|
|
'f/system/dedicated_forloop_multi_step_flow',
|
|
'{3000000000000019}',
|
|
'{"$schema":"https://json-schema.org/draft/2020-12/schema","properties":{},"required":[],"type":"object"}',
|
|
E'{"modules":[{"id":"a","value":{"type":"forloopflow","iterator":{"type":"javascript","expr":"[1, 2, 3]"},"skip_failures":false,"parallel":false,"squash":false,"modules":[{"id":"b","value":{"type":"rawscript","content":"export function main(iter: {value: number, index: number}) { return iter.value + 1; }","language":"bun","input_transforms":{"iter":{"expr":"flow_input.iter","type":"javascript"}},"lock":"{}\\n//bun.lock\\n<empty>"}},{"id":"c","value":{"type":"rawscript","content":"export function main(prev: number) { return prev * 10; }","language":"bun","input_transforms":{"prev":{"expr":"results.b","type":"javascript"}},"lock":"{}\\n//bun.lock\\n<empty>"}}]}}]}',
|
|
'system'
|
|
);
|
|
|
|
INSERT INTO public.flow_version(id, workspace_id, path, schema, value, created_by) VALUES (
|
|
3000000000000019,
|
|
'test-workspace',
|
|
'f/system/dedicated_forloop_multi_step_flow',
|
|
'{"$schema":"https://json-schema.org/draft/2020-12/schema","properties":{},"required":[],"type":"object"}',
|
|
E'{"modules":[{"id":"a","value":{"type":"forloopflow","iterator":{"type":"javascript","expr":"[1, 2, 3]"},"skip_failures":false,"parallel":false,"squash":false,"modules":[{"id":"b","value":{"type":"rawscript","content":"export function main(iter: {value: number, index: number}) { return iter.value + 1; }","language":"bun","input_transforms":{"iter":{"expr":"flow_input.iter","type":"javascript"}},"lock":"{}\\n//bun.lock\\n<empty>"}},{"id":"c","value":{"type":"rawscript","content":"export function main(prev: number) { return prev * 10; }","language":"bun","input_transforms":{"prev":{"expr":"results.b","type":"javascript"}},"lock":"{}\\n//bun.lock\\n<empty>"}}]}}]}',
|
|
'system'
|
|
);
|
|
|
|
-- ============================================================
|
|
-- Test: while-loop in dedicated flow
|
|
-- While-loop with an inner bun step that returns x + 1.
|
|
-- Early stop breaks when result >= 3.
|
|
-- ============================================================
|
|
INSERT INTO public.flow(workspace_id, summary, description, path, versions, schema, value, edited_by) VALUES (
|
|
'test-workspace', '', '',
|
|
'f/system/dedicated_whileloop_flow',
|
|
'{3000000000000016}',
|
|
'{"$schema":"https://json-schema.org/draft/2020-12/schema","properties":{"x":{"type":"number","description":""}},"required":["x"],"type":"object"}',
|
|
E'{"modules":[{"id":"a","value":{"type":"whileloopflow","skip_failures":false,"squash":false,"modules":[{"id":"b","value":{"type":"rawscript","content":"export function main(n: number) { return n + 1; }","language":"bun","input_transforms":{"n":{"expr":"results.b ?? flow_input.x","type":"javascript"}},"lock":"{}\\n//bun.lock\\n<empty>"},"stop_after_if":{"expr":"result >= 3","skip_if_stopped":false}}]}}]}',
|
|
'system'
|
|
);
|
|
|
|
INSERT INTO public.flow_version(id, workspace_id, path, schema, value, created_by) VALUES (
|
|
3000000000000016,
|
|
'test-workspace',
|
|
'f/system/dedicated_whileloop_flow',
|
|
'{"$schema":"https://json-schema.org/draft/2020-12/schema","properties":{"x":{"type":"number","description":""}},"required":["x"],"type":"object"}',
|
|
E'{"modules":[{"id":"a","value":{"type":"whileloopflow","skip_failures":false,"squash":false,"modules":[{"id":"b","value":{"type":"rawscript","content":"export function main(n: number) { return n + 1; }","language":"bun","input_transforms":{"n":{"expr":"results.b ?? flow_input.x","type":"javascript"}},"lock":"{}\\n//bun.lock\\n<empty>"},"stop_after_if":{"expr":"result >= 3","skip_if_stopped":false}}]}}]}',
|
|
'system'
|
|
);
|
|
|
|
-- ============================================================
|
|
-- Test: branchall in dedicated flow
|
|
-- BranchAll with 2 parallel branches, each with a bun step.
|
|
-- Branch 0: x + 100, Branch 1: x + 200.
|
|
-- ============================================================
|
|
INSERT INTO public.flow(workspace_id, summary, description, path, versions, schema, value, edited_by) VALUES (
|
|
'test-workspace', '', '',
|
|
'f/system/dedicated_branchall_flow',
|
|
'{3000000000000017}',
|
|
'{"$schema":"https://json-schema.org/draft/2020-12/schema","properties":{"x":{"type":"number","description":""}},"required":["x"],"type":"object"}',
|
|
E'{"modules":[{"id":"a","value":{"type":"branchall","parallel":true,"branches":[{"expr":"true","modules":[{"id":"b","value":{"type":"rawscript","content":"export function main(x: number) { return x + 100; }","language":"bun","input_transforms":{"x":{"expr":"flow_input.x","type":"javascript"}},"lock":"{}\\n//bun.lock\\n<empty>"}}]},{"expr":"true","modules":[{"id":"c","value":{"type":"rawscript","content":"export function main(x: number) { return x + 200; }","language":"bun","input_transforms":{"x":{"expr":"flow_input.x","type":"javascript"}},"lock":"{}\\n//bun.lock\\n<empty>"}}]}]}}]}',
|
|
'system'
|
|
);
|
|
|
|
INSERT INTO public.flow_version(id, workspace_id, path, schema, value, created_by) VALUES (
|
|
3000000000000017,
|
|
'test-workspace',
|
|
'f/system/dedicated_branchall_flow',
|
|
'{"$schema":"https://json-schema.org/draft/2020-12/schema","properties":{"x":{"type":"number","description":""}},"required":["x"],"type":"object"}',
|
|
E'{"modules":[{"id":"a","value":{"type":"branchall","parallel":true,"branches":[{"expr":"true","modules":[{"id":"b","value":{"type":"rawscript","content":"export function main(x: number) { return x + 100; }","language":"bun","input_transforms":{"x":{"expr":"flow_input.x","type":"javascript"}},"lock":"{}\\n//bun.lock\\n<empty>"}}]},{"expr":"true","modules":[{"id":"c","value":{"type":"rawscript","content":"export function main(x: number) { return x + 200; }","language":"bun","input_transforms":{"x":{"expr":"flow_input.x","type":"javascript"}},"lock":"{}\\n//bun.lock\\n<empty>"}}]}]}}]}',
|
|
'system'
|
|
);
|
|
|
|
-- ============================================================
|
|
-- Test: nested branch inside loop in dedicated flow
|
|
-- For-loop [1,2] with inner branchone: if iter.value > 1 → x + 100, else → x + 200.
|
|
-- Tests deeply nested dispatch (forloop-N/branchone-0/step_id).
|
|
-- ============================================================
|
|
INSERT INTO public.flow(workspace_id, summary, description, path, versions, schema, value, edited_by) VALUES (
|
|
'test-workspace', '', '',
|
|
'f/system/dedicated_nested_flow',
|
|
'{3000000000000018}',
|
|
'{"$schema":"https://json-schema.org/draft/2020-12/schema","properties":{},"required":[],"type":"object"}',
|
|
E'{"modules":[{"id":"a","value":{"type":"forloopflow","iterator":{"type":"javascript","expr":"[1, 2]"},"skip_failures":false,"parallel":false,"squash":false,"modules":[{"id":"b","value":{"type":"branchone","branches":[{"expr":"flow_input.iter.value > 1","modules":[{"id":"c","value":{"type":"rawscript","content":"export function main(iter: {value: number}) { return iter.value + 100; }","language":"bun","input_transforms":{"iter":{"expr":"flow_input.iter","type":"javascript"}},"lock":"{}\\n//bun.lock\\n<empty>"}}]}],"default":[{"id":"d","value":{"type":"rawscript","content":"export function main(iter: {value: number}) { return iter.value + 200; }","language":"bun","input_transforms":{"iter":{"expr":"flow_input.iter","type":"javascript"}},"lock":"{}\\n//bun.lock\\n<empty>"}}]}}]}}]}',
|
|
'system'
|
|
);
|
|
|
|
INSERT INTO public.flow_version(id, workspace_id, path, schema, value, created_by) VALUES (
|
|
3000000000000018,
|
|
'test-workspace',
|
|
'f/system/dedicated_nested_flow',
|
|
'{"$schema":"https://json-schema.org/draft/2020-12/schema","properties":{},"required":[],"type":"object"}',
|
|
E'{"modules":[{"id":"a","value":{"type":"forloopflow","iterator":{"type":"javascript","expr":"[1, 2]"},"skip_failures":false,"parallel":false,"squash":false,"modules":[{"id":"b","value":{"type":"branchone","branches":[{"expr":"flow_input.iter.value > 1","modules":[{"id":"c","value":{"type":"rawscript","content":"export function main(iter: {value: number}) { return iter.value + 100; }","language":"bun","input_transforms":{"iter":{"expr":"flow_input.iter","type":"javascript"}},"lock":"{}\\n//bun.lock\\n<empty>"}}]}],"default":[{"id":"d","value":{"type":"rawscript","content":"export function main(iter: {value: number}) { return iter.value + 200; }","language":"bun","input_transforms":{"iter":{"expr":"flow_input.iter","type":"javascript"}},"lock":"{}\\n//bun.lock\\n<empty>"}}]}}]}}]}',
|
|
'system'
|
|
);
|
|
|