Title: feat(mothership): format generated function code by j15z · Pull Request #5742 · simstudioai/sim · GitHub
Open Graph Title: feat(mothership): format generated function code by j15z · Pull Request #5742 · simstudioai/sim
X Title: feat(mothership): format generated function code by j15z · Pull Request #5742 · simstudioai/sim
Description: Summary Mothership-created JavaScript and Python Function blocks now arrive formatted and readable instead of being persisted as dense single-line source. Formatting runs after workflow operations resolve the final block identity and language, preserves Sim workflow and environment references, and fails open so invalid or unverifiable source remains unchanged while the mothership receives a sanitized formatting result. This uses Prettier for JavaScript and Ruff's WebAssembly formatter for Python, keeping formatting deterministic and independent of how the mothership writes its tool-call strings. Formatted output is accepted only when Sim references remain identical and ordered, JavaScript has an equivalent Babel syntax tree, and a second formatting pass is byte-stable. Parenthesized environment expressions retain grouping through raw resolver substitution, including comment-bearing expressions; otherwise the original Function source is kept. The safety suite exercises broad JavaScript and Python syntax corpora, formatting idempotence, exact workflow/environment-reference restoration, real placeholder-token collisions, high-cardinality reference sets, invalid-source fail-open behavior, real VariableResolver integration, JavaScript runtime equivalence, and independent CPython AST and runtime equivalence. Type of Change Bug fix New feature Breaking change Documentation Other: ___________ Testing DATABASE_URL=postgres://postgres:postgres@localhost:5432/sim bunx vitest run lib/workflows/blocks/format-function-code.test.ts lib/workflows/blocks/format-function-code.safety.test.ts lib/workflows/blocks/format-function-code.validation.test.ts lib/workflows/blocks/format-function-code.integration.test.ts lib/copilot/tools/server/workflow/edit-workflow/function-code-formatting.test.ts from apps/sim - 110 tests passed. DATABASE_URL=postgres://postgres:postgres@localhost:5432/sim bun test apps/sim/lib/copilot/tools/server/workflow/edit-workflow/operations.test.ts - 14 tests passed with 45 expectations; 124 relevant tests passed in total. bunx biome check across the six formatter implementation/test files - passed. bun run check:utils - passed with no banned patterns. bun run check:api-validation - passed with all 964 API routes Zod-backed and no baseline drift. bun build apps/sim/lib/workflows/blocks/format-function-code.ts --target=node --outdir /tmp/sim-function-formatter-bundle --external @wasm-fmt/ruff_fmt/node - passed with Prettier's Babel parser bundled. bun run --cwd apps/sim type-check - the authored formatter files emitted no errors; the isolated worktree still surfaces unrelated linked-dependency drift for two audit constants, recordAuditBatch, and @google-cloud/storage. CI should validate from a fresh dependency install. Reviewers should focus on parenthesized environment-expression protection, Sim-reference ordering, the JavaScript AST normalization boundary, the independent CPython oracle, and Ruff WebAssembly tracing for standalone Next deployments. Post-deploy monitoring and validation: for 24 hours after deployment, the Workflow/Mothership owner should watch edit_workflow error rate and latency and search logs for Function code formatting failed open, grouped by language and block ID. Healthy behavior is stable edit latency/error rate with warnings limited to genuinely invalid source; a sustained warning increase, latency regression, or any behavior-changing formatted Function should trigger rollback of this change while fail-open keeps original source intact. Checklist Code follows project style guidelines Self-reviewed my changes Tests added/updated and passing No new warnings introduced I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA) Screenshots/Videos Not applicable - this changes server-side workflow code normalization and has no new visual surface.
Open Graph Description: Summary Mothership-created JavaScript and Python Function blocks now arrive formatted and readable instead of being persisted as dense single-line source. Formatting runs after workflow operations ...
X Description: Summary Mothership-created JavaScript and Python Function blocks now arrive formatted and readable instead of being persisted as dense single-line source. Formatting runs after workflow operations ...
Opengraph URL: https://github.com/simstudioai/sim/pull/5742
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:3a51812e-530c-7aee-e117-1aa89841eb13 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | 8D58:1D90B4:130752:1A30C1:6A62FD8D |
| html-safe-nonce | bf060ef73f03d1aa56ec6ddff906311ef3970bcd519ed1281fe219285ec37257 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4RDU4OjFEOTBCNDoxMzA3NTI6MUEzMEMxOjZBNjJGRDhEIiwidmlzaXRvcl9pZCI6IjQ1MDY1ODc1MzQ4MjM5ODA0MjkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | a2044975b6f3c1966c5be317b26ef3675b2e3049ae74f6ea1f4499b95868ca91 |
| hovercard-subject-tag | pull_request:4079183772 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/simstudioai/sim/pull/5742/files |
| twitter:image | https://avatars.githubusercontent.com/u/96924014?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/96924014?s=400&v=4 |
| og:image:alt | Summary Mothership-created JavaScript and Python Function blocks now arrive formatted and readable instead of being persisted as dense single-line source. Formatting runs after workflow operations ... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 59e40dc698184067b40ef2d941585f66ed42711564a879644f984f1eacea129c |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/simstudioai/sim git https://github.com/simstudioai/sim.git |
| octolytics-dimension-user_id | 199344406 |
| octolytics-dimension-user_login | simstudioai |
| octolytics-dimension-repository_id | 912559512 |
| octolytics-dimension-repository_nwo | simstudioai/sim |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 912559512 |
| octolytics-dimension-repository_network_root_nwo | simstudioai/sim |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | b4f544bf80583e749557efd76afda56317b6252d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width