Skip to content

refactor(workflow): rename defineWaitPoint/defineWaitPoints to createWaitPoint/createWaitPoints#1556

Merged
toiroakr merged 10 commits into
v2from
chore/rename-define
Jun 26, 2026
Merged

refactor(workflow): rename defineWaitPoint/defineWaitPoints to createWaitPoint/createWaitPoints#1556
toiroakr merged 10 commits into
v2from
chore/rename-define

Conversation

@toiroakr

@toiroakr toiroakr commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Rename `defineWaitPoint` → `createWaitPoint` and `defineWaitPoints` → `createWaitPoints`
  • These functions create runtime instances with `.wait()` / `.resolve()` methods that call the platform API, so `create*` is the accurate prefix per the SDK naming convention
  • Document the `define*` vs `create*` rule in `.agents/rules/sdk-internals.md`
  • Add `v2/wait-point-rename` codemod to automate the migration: handles non-aliased and aliased imports, scope-aware body renaming, no-ops when no SDK import is present
  • Codemod shadow detection covers: local function declarations, variable declarations (direct and destructuring patterns), for-loop initializers, for...of/for...in bindings, required and optional function/arrow parameters
  • Codemod renames `shorthand_property_identifier` nodes in object literals (e.g. `{ defineWaitPoints }`) in addition to regular `identifier` references
  • Scope range check uses exclusive end boundary (`pos < r.end`) consistent with tree-sitter byte ranges
  • Register `v2/wait-point-rename` in `tsdown.config.ts` so the script is emitted to dist
  • Add optional-parameter shadow test fixture (`optional-param-shadow`) to verify `optional_parameter` nodes are correctly detected as shadows

toiroakr added 2 commits June 25, 2026 10:31
…WaitPoint/createWaitPoints

These functions create runtime instances with .wait()/.resolve() methods
that call the platform API, so they follow the create* naming convention.
Also document the define* vs create* rule in sdk-internals agent rules.
@changeset-bot

changeset-bot Bot commented Jun 25, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 59ef383

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@tailor-platform/sdk Major
@tailor-platform/create-sdk Major
@tailor-platform/sdk-codemod Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Jun 25, 2026

Copy link
Copy Markdown

Open in StackBlitz

pnpm add https://pkg.pr.new/@tailor-platform/create-sdk@59ef383
pnpm add https://pkg.pr.new/@tailor-platform/sdk@59ef383

commit: 59ef383

@github-actions

This comment has been minimized.

Rename defineWaitPoint and defineWaitPoints to createWaitPoint and
createWaitPoints in user code. Handles both non-aliased imports (renames
the specifier and all body references) and aliased imports (renames only
the imported name, preserving the alias).

Includes fixture tests for: basic rename, aliased imports, no-op cases
(no matching imports, no SDK import).
@github-actions

This comment has been minimized.

This comment was marked as resolved.

@toiroakr
toiroakr marked this pull request as ready for review June 25, 2026 13:43
@toiroakr
toiroakr requested a review from a team as a code owner June 25, 2026 13:43
Skip body-identifier rename for any name that is also declared as a
function or variable in the file body, preventing incorrect rewrites of
locals that happen to share the SDK import name (e.g. a helper that
re-declares defineWaitPoints in an inner scope).

Adds a local-shadow fixture to verify the import specifier is still
renamed while the shadowed body usages are left unchanged.
@github-actions

This comment has been minimized.

This comment was marked as resolved.

Replace the over-broad needsBodyRename.delete() guard with a per-scope
byte-range map. For each local declaration that shadows an SDK import
name, record the byte range of its containing statement_block (or program
for top-level). Body identifiers are only skipped when their position
falls within one of those ranges, so top-level SDK usages are correctly
renamed even when the same name is re-declared in a nested function.

Adds a nested-shadow fixture to verify: top-level defineWaitPoints is
renamed to createWaitPoints while the re-declared local inside a helper
function and its calls are left unchanged.
@github-actions

This comment has been minimized.

This comment was marked as resolved.

Add for_statement and for_in_statement to the scope-kind check when
walking up the AST to find the containing scope of a local declaration.
Without this, a variable_declarator in a for-loop initializer
(for (let defineWaitPoints = ...)) walked all the way up to program,
causing the entire file to be treated as shadowed and preventing top-level
SDK usages from being renamed.

Adds a for-loop-shadow fixture to verify that top-level defineWaitPoints
is renamed while the loop counter and body references are left unchanged.
@github-actions

This comment has been minimized.

This comment was marked as resolved.

@toiroakr
toiroakr requested a review from Copilot June 25, 2026 15:06
@github-actions

This comment has been minimized.

This comment was marked as off-topic.

});
for (const decl of localDecls) {
if (isInsideImportStatement(decl)) continue;
const nameChild = decl.children().find((c: SgNode) => c.kind() === "identifier");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Destructured local bindings such as const { defineWaitPoints } = source are not recorded as shadows, so the transform can rewrite their local calls to createWaitPoints() after renaming the SDK import.

}
}

const identifiers = root.findAll({ rule: { kind: "identifier" } });

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Object-literal shorthand usages such as const api = { defineWaitPoints } are not renamed, so after the import becomes createWaitPoints the shorthand still references an undefined defineWaitPoints.

@dqn dqn assigned toiroakr and unassigned dqn Jun 26, 2026
@github-actions

This comment has been minimized.

This comment was marked as outdated.

@github-actions

This comment has been minimized.

This comment was marked as off-topic.

@toiroakr toiroakr assigned dqn and unassigned toiroakr Jun 26, 2026

@dqn dqn left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Please just fix the conflicts

@dqn dqn assigned toiroakr and unassigned dqn Jun 26, 2026
@github-actions

Copy link
Copy Markdown

Code Metrics Report (packages/sdk)

main (04c2ebb) #1556 (840d4e4) +/-
Coverage 69.7% 70.7% +0.9%
Code to Test Ratio 1:0.4 1:0.4 +0.0
Details
  |                    | main (04c2ebb) | #1556 (840d4e4) |  +/-  |
  |--------------------|----------------|-----------------|-------|
+ | Coverage           |          69.7% |           70.7% | +0.9% |
  |   Files            |            422 |             417 |    -5 |
  |   Lines            |          15081 |           15098 |   +17 |
+ |   Covered          |          10516 |           10676 |  +160 |
+ | Code to Test Ratio |          1:0.4 |           1:0.4 |  +0.0 |
  |   Code             |         102339 |          102537 |  +198 |
+ |   Test             |          45593 |           46347 |  +754 |

Code coverage of files in pull request scope (71.5% → 76.1%)

Details
Files Coverage +/- Status
packages/sdk-codemod/src/registry.ts 0.0% -60.0% modified
packages/sdk/example/tailordb/user.ts 0.0% -100.0% affected
packages/sdk/llm-challenge/src/types.ts 0.0% -100.0% affected
packages/sdk/src/cli/commands/deploy/test_fixtures/tailor.config.generators-compat.ts 0.0% -100.0% affected
packages/sdk/src/cli/commands/deploy/test_fixtures/tailor.config.plugins-compat.ts 0.0% -100.0% affected
packages/sdk/src/cli/commands/deploy/auth-invoker.ts 0.0% -100.0% affected
packages/sdk/src/cli/commands/deploy/deploy.ts 83.4% +3.1% affected
packages/sdk/src/cli/commands/deploy/executor.ts 80.1% +0.1% affected
packages/sdk/src/cli/commands/deploy/grouped-display.ts 85.0% -0.2% affected
packages/sdk/src/cli/commands/deploy/invoker.ts 100.0% +100.0% affected
packages/sdk/src/cli/commands/function/logs.ts 39.7% -4.6% affected
packages/sdk/src/cli/commands/function/test-run.ts 56.8% -3.4% affected
packages/sdk/src/cli/commands/generate/service.ts 58.3% -9.9% affected
packages/sdk/src/cli/commands/login.ts 7.8% -0.2% affected
packages/sdk/src/cli/commands/profile/create.ts 75.0% +70.0% affected
packages/sdk/src/cli/commands/profile/update.ts 89.3% +0.4% affected
packages/sdk/src/cli/commands/remove.ts 1.3% -0.6% affected
packages/sdk/src/cli/commands/tailordb/migrate/db-types-generator.ts 96.5% -0.8% affected
packages/sdk/src/cli/commands/user/switch.ts 87.5% +73.2% affected
packages/sdk/src/cli/commands/workflow/start.ts 83.6% +12.5% affected
packages/sdk/src/cli/crashreport/report.ts 88.0% +2.2% affected
packages/sdk/src/cli/index.ts 27.2% -6.1% affected
packages/sdk/src/cli/shared/auth-namespace.ts 100.0% +100.0% affected
packages/sdk/src/cli/shared/config-loader.ts 74.1% -8.2% affected
packages/sdk/src/cli/shared/context.ts 80.8% +16.8% affected
packages/sdk/src/cli/shared/register-ts-hook.ts 100.0% +100.0% affected
packages/sdk/src/cli/ts-hook.mjs 84.4% +84.4% affected
packages/sdk/src/configure/services/auth/index.ts 66.6% -8.4% affected
packages/sdk/src/configure/services/tailordb/schema.ts 81.6% +0.5% affected
packages/sdk/src/configure/services/workflow/job.ts 90.0% +4.2% affected
packages/sdk/src/configure/services/workflow/registry.ts 95.0% +11.1% affected
packages/sdk/src/configure/services/workflow/test-env-key.ts 100.0% +6.6% affected
packages/sdk/src/configure/services/workflow/wait-point.ts 100.0% 0.0% modified
packages/sdk/src/configure/services/workflow/workflow.ts 66.6% +6.6% affected
packages/sdk/src/parser/service/idp/schema.ts 93.9% -0.2% affected
packages/sdk/src/parser/service/tailordb/field.ts 96.4% +1.1% affected
packages/sdk/src/plugin/builtin/seed/index.ts 0.0% -1.6% affected
packages/sdk/src/vitest/mock.ts 95.2% +2.1% affected
packages/sdk/src/vitest/workflow-local.ts 79.4% +79.4% affected
packages/sdk/src/vitest/workflow-runtime.ts 66.6% +26.6% affected

SDK Configure Bundle Size

main (04c2ebb) #1556 (840d4e4) +/-
configure-index-size 20.14KB 21.24KB 1.1KB
dependency-chunks-size 47.71KB 35.38KB -12.33KB
total-bundle-size 67.85KB 56.62KB -11.23KB

Runtime Performance

main (04c2ebb) #1556 (840d4e4) +/-
Generate Median 3,013ms 2,994ms -19ms
Generate Max 3,028ms 3,112ms 84ms
Apply Build Median 3,087ms 3,008ms -79ms
Apply Build Max 3,116ms 3,024ms -92ms

Type Performance (instantiations)

main (04c2ebb) #1556 (840d4e4) +/-
tailordb-basic 36,391 36,160 -231
tailordb-optional 3,841 3,841 0
tailordb-relation 6,012 6,012 0
tailordb-validate 2,566 2,566 0
tailordb-hooks 5,777 5,777 0
tailordb-object 12,136 12,136 0
tailordb-enum 2,462 2,462 0
resolver-basic 9,438 9,413 -25
resolver-nested 26,125 26,100 -25
resolver-array 18,201 18,176 -25
executor-schedule 4,268 4,255 -13
executor-webhook 907 894 -13
executor-record 6,788 6,775 -13
executor-resolver 4,417 4,401 -16
executor-operation-function 899 886 -13
executor-operation-gql 903 890 -13
executor-operation-webhook 918 905 -13
executor-operation-workflow 1,747 1,726 -21

Reported by octocov

This comment was marked as off-topic.

@toiroakr
toiroakr merged commit c7b684d into v2 Jun 26, 2026
43 checks passed
@toiroakr
toiroakr deleted the chore/rename-define branch June 26, 2026 20:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants