Skip to content

fix workflow polling#3466

Open
DatGuyJonathan wants to merge 5 commits intomainfrom
jonathan/514-376-investigate-temporal-long-running-events
Open

fix workflow polling#3466
DatGuyJonathan wants to merge 5 commits intomainfrom
jonathan/514-376-investigate-temporal-long-running-events

Conversation

@DatGuyJonathan
Copy link
Contributor

@DatGuyJonathan DatGuyJonathan commented Feb 6, 2026

It was overly aggressive checking if it's reaching event limits, but every check was creating events. Really just need to check the limit before the task.


Note

Medium Risk
Changes core workflow execution/continue-as-new behavior; mistakes could cause incorrect resume points or altered task input propagation, though the change is localized and conceptually simple.

Overview
Fixes overly aggressive continue-as-new polling in both the Python worker wrapper and the TypeScript workflow implementation.

The workflow now checks continue-as-new once before starting each task (so continue_from_task points to an unexecuted task and avoids duplicate runs) and removes the background/polling monitor logic that was generating extra workflow history. The original raw workflow input is also threaded through to continue_as_new to avoid double-processing/serialization on restart, and TS child-task chaining/ETL hasMore handling is updated to pass the full prior result object through the chain.

Written by Cursor Bugbot for commit 20982b1. This will update automatically on new commits. Configure here.

@linear
Copy link

linear bot commented Feb 6, 2026

@vercel
Copy link

vercel bot commented Feb 6, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs-v2 Ready Ready Preview, Comment Feb 6, 2026 10:55pm

Request Review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 6, 2026

Summary by CodeRabbit

  • Refactor

    • Activity/task execution now runs directly without background monitors or race logic, simplifying flow and reducing overhead.
    • Continue-as-new is checked and triggered before task execution, shrinking workflow history.
    • Original workflow input is preserved and forwarded through task context so downstream tasks receive consistent inputs.
  • Bug Fixes

    • Fixed pagination/has-more detection and ETL restart handling to prevent missed or duplicated batches.

Walkthrough

Removed monitor/polling-based continue-as-new handling; added an upfront continue-as-new check before executing activities in both Python and TypeScript workflows, deleted the ContinueAsNewData type and async/monitoring race logic, and simplified activity execution and result propagation.

Changes

Cohort / File(s) Summary
Python workflow
apps/framework-cli/src/framework/python/wrappers/scripts/python_worker_wrapper/workflow.py
Deleted ContinueAsNewData and asyncio monitor/race logic. Added pre-execution workflow.info() continue-as-new check that triggers continue_as_new before task start. _execute_activity_with_state signature updated to accept original_workflow_input and now returns List[Any]. Removed monitor function and related cleanup.
TypeScript workflow
packages/ts-moose-lib/src/scripts/workflow.ts
Added HandleTaskContext carrying originalWorkflowInput and threaded it through handleTask/executeTask. Replaced Promise.race/monitor with pre-check workflowInfo().continueAsNewSuggestedcontinueAsNew. Primary task result wrapped as [result]; child onComplete and ETL flows receive result (not result.data) and propagate ctx. Minor wording/logging and timeout wording change.
Public surface / types
packages/ts-moose-lib/src/scripts/workflow.ts
New exported interface HandleTaskContext and updated function signatures to accept ctx (default {}).
Manifest / misc
package.json (minor lines)
Small manifest edits referenced in diff summary.

Sequence Diagram

sequenceDiagram
    participant WF as ScriptWorkflow
    participant Info as WorkflowInfo
    participant Executor as TaskExecutor
    participant Activity as ActivityHandler

    rect rgba(100,200,100,0.5)
    Note over WF,Activity: Upfront continue-as-new check, direct task execution
    end

    WF->>Info: workflowInfo()
    Info-->>WF: continueAsNewSuggested?
    alt suggested
        WF->>WF: continueAsNew(WorkflowRequest with original input)
    else not suggested
        WF->>Executor: executeTask(activity, input, ctx)
        Executor->>Activity: run activity
        Activity-->>Executor: result
        Executor-->>WF: [result]
        WF->>WF: propagate [result] and ctx to onComplete/child tasks
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested reviewers

  • LucioFranco
  • phiSgr

Poem

The monitor fell away, the check took hold,
Workflows march on, simpler and bold.
Inputs passed forward, results in line,
Continue-as-new only when signs align. ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed Title 'fix workflow polling' directly relates to the main change: removing aggressive polling logic from workflow execution. However, it lacks specificity—'polling' doesn't convey the broader refactor (continue-as-new pre-check, ContinueAsNewData removal, context threading).
Description check ✅ Passed Description clearly explains the core change: moving from aggressive per-task continue-as-new polling to a single preflight check, and mentions both Python and TypeScript updates.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch jonathan/514-376-investigate-temporal-long-running-events

📜 Recent review details

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between dbed0f3 and 20982b1.

📒 Files selected for processing (2)
  • apps/framework-cli/src/framework/python/wrappers/scripts/python_worker_wrapper/workflow.py
  • packages/ts-moose-lib/src/scripts/workflow.ts
🧰 Additional context used
📓 Path-based instructions (5)
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Run linting checks before submitting PRs for TypeScript/JavaScript code

**/*.{ts,tsx,js,jsx}: Group imports by external dependencies, internal modules, and types; use named exports from barrel files (index.ts)
Use camelCase for variables and functions, PascalCase for types/classes/components, UPPER_SNAKE_CASE for constants in TypeScript/JavaScript
Prefix unused variables with underscore (e.g., _unusedParam) to bypass linting errors in TypeScript/JavaScript
Format TypeScript/JavaScript code with Prettier using experimentalTernaries: true; auto-formats on commit via Husky + lint-staged

Files:

  • packages/ts-moose-lib/src/scripts/workflow.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Prefer interfaces for objects, types for unions/intersections in TypeScript; explicit return types on public APIs

Files:

  • packages/ts-moose-lib/src/scripts/workflow.ts
**/ts-moose-lib/src/**/*.ts

⚙️ CodeRabbit configuration file

**/ts-moose-lib/src/**/*.ts: When reviewing changes to typescript moose lib:

  1. Check if any public apis were changed (class, method, type, config, etc).
  2. If yes, verify the documentation for THAT SPECIFIC feature is updated in apps/framework-docs-v2/content.
  3. If docs for that feature doesn't exist yet, it should be added. If the change removes public apis, the documentation for those should also be removed. Changing unrelated docs doesn't satisfy this requirement.
  4. In addition to reviewing for docs discrepancies, you should also review the code as per usual guidelines.

Files:

  • packages/ts-moose-lib/src/scripts/workflow.ts
**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

**/*.py: Follow PEP 8 style guide in Python; use snake_case for functions/variables, PascalCase for classes, UPPER_SNAKE_CASE for constants
Format Python code with Black using line-length 88; auto-formats on commit via Husky + lint-staged
Use type hints for function signatures and public APIs in Python

Files:

  • apps/framework-cli/src/framework/python/wrappers/scripts/python_worker_wrapper/workflow.py
**/framework-cli/src/**

⚙️ CodeRabbit configuration file

**/framework-cli/src/**: When reviewing changes to Moose CLI:

  1. Check if any user-facing changes were made (commands, flags, configs, apis, etc)
  2. If yes, verify the documentation for THAT SPECIFIC feature is updated in apps/framework-docs-v2/content
  3. If docs for that feature doesn't exist yet, it should be added. If the change removes public apis, the documentation for those should also be removed. Changing unrelated docs doesn't satisfy this requirement.
  4. In addition to reviewing for docs discrepancies, you should also review the code as per usual guidelines.

Files:

  • apps/framework-cli/src/framework/python/wrappers/scripts/python_worker_wrapper/workflow.py
🧠 Learnings (5)
📓 Common learnings
Learnt from: DatGuyJonathan
Repo: 514-labs/moosestack PR: 3400
File: apps/framework-cli/src/framework/core/infrastructure_map.rs:1238-1298
Timestamp: 2026-01-26T00:56:27.011Z
Learning: Repo 514-labs/moosestack — Workflows: The CLI’s workflow diff is intended to detect only Temporal schedule–affecting changes. In apps/framework-cli/src/framework/core/infrastructure_map.rs, workflows_config_equal should compare schedule, retries, and timeout only; it must not include tasks. Task code/config changes are picked up automatically when the orchestration worker restarts and should not trigger a WorkflowChange.
📚 Learning: 2026-01-26T00:56:27.011Z
Learnt from: DatGuyJonathan
Repo: 514-labs/moosestack PR: 3400
File: apps/framework-cli/src/framework/core/infrastructure_map.rs:1238-1298
Timestamp: 2026-01-26T00:56:27.011Z
Learning: Repo 514-labs/moosestack — Workflows: The CLI’s workflow diff is intended to detect only Temporal schedule–affecting changes. In apps/framework-cli/src/framework/core/infrastructure_map.rs, workflows_config_equal should compare schedule, retries, and timeout only; it must not include tasks. Task code/config changes are picked up automatically when the orchestration worker restarts and should not trigger a WorkflowChange.

Applied to files:

  • packages/ts-moose-lib/src/scripts/workflow.ts
  • apps/framework-cli/src/framework/python/wrappers/scripts/python_worker_wrapper/workflow.py
📚 Learning: 2026-01-15T19:41:53.563Z
Learnt from: CR
Repo: 514-labs/moosestack PR: 0
File: examples/cdp-analytics/CLAUDE.md:0-0
Timestamp: 2026-01-15T19:41:53.563Z
Learning: Applies to examples/cdp-analytics/app/workflows/*-sync.ts : Scheduled sync workflows should use Cron schedule expressions (e.g., '0 * * * *' for hourly, '*/5 * * * *' for every 5 minutes), fetch from external APIs using Bearer token authorization, and return a SyncResult object with synced count and errors

Applied to files:

  • packages/ts-moose-lib/src/scripts/workflow.ts
📚 Learning: 2026-01-15T19:41:53.563Z
Learnt from: CR
Repo: 514-labs/moosestack PR: 0
File: examples/cdp-analytics/CLAUDE.md:0-0
Timestamp: 2026-01-15T19:41:53.563Z
Learning: Applies to examples/cdp-analytics/app/services/analyticsService.ts : Service functions in analyticsService.ts should execute queries using executeQuery helper, transform raw results, and return typed data structures defined in types/analytics.ts

Applied to files:

  • packages/ts-moose-lib/src/scripts/workflow.ts
📚 Learning: 2026-01-26T01:14:58.758Z
Learnt from: DatGuyJonathan
Repo: 514-labs/moosestack PR: 3400
File: apps/framework-cli/src/framework/core/execute.rs:141-146
Timestamp: 2026-01-26T01:14:58.758Z
Learning: In apps/framework-cli/src/infrastructure/orchestration/workflows.rs, workflow scheduling failures should be non-fatal. The workflows::execute_changes function should return () and log errors rather than returning Result and propagating failures. Failing to schedule a workflow is not a reason to fail the deploy.

Applied to files:

  • apps/framework-cli/src/framework/python/wrappers/scripts/python_worker_wrapper/workflow.py
🧬 Code graph analysis (1)
apps/framework-cli/src/framework/python/wrappers/scripts/python_worker_wrapper/workflow.py (2)
packages/py-moose-lib/moose_lib/dmv2/workflow.py (2)
  • Workflow (132-189)
  • Task (56-112)
apps/framework-cli/src/framework/python/wrappers/scripts/python_worker_wrapper/types.py (1)
  • WorkflowStepResult (5-7)
🪛 Ruff (0.14.14)
apps/framework-cli/src/framework/python/wrappers/scripts/python_worker_wrapper/workflow.py

[warning] 6-6: typing.Dict is deprecated, use dict instead

(UP035)


[warning] 6-6: typing.List is deprecated, use list instead

(UP035)


[warning] 147-147: Consider moving this statement to an else block

(TRY300)

⏰ Context from checks skipped due to timeout of 900000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Test E2E TypeScript Tests Template (Node 20, npm)
🔇 Additional comments (7)
packages/ts-moose-lib/src/scripts/workflow.ts (5)

20-22: Clean context type.

Simple and effective way to thread the original input through continueAsNew boundaries.


118-131: Good fix — pre-check eliminates the duplicate-execution problem.

Moving the continueAsNewSuggested check before the activity runs means continue_from_task now correctly points to an unexecuted task. Solid improvement.


133-138: Removing the polling monitor is the right call.

The comment correctly explains that a running activity doesn't generate workflow history events. This eliminates the self-inflicted history growth.


56-58: Context threading looks correct.

Original inputData is preserved through continueAsNew boundaries and re-processed consistently on restart via line 43.


149-163: BatchResult has hasMore at the top level; code access pattern is correct.

The interface definition in packages/ts-moose-lib/src/dmv2/sdk/etlPipeline.ts shows hasMore as a top-level property of BatchResult, matching the access pattern in lines 155–156.

apps/framework-cli/src/framework/python/wrappers/scripts/python_worker_wrapper/workflow.py (2)

100-146: Preflight continue-as-new check and simplified execution look correct.

The recursive threading of original_workflow_input through child tasks is sound — continue-as-new will always replay from the raw input. Activity execution without the polling monitor avoids the history-growth problem this PR targets.


264-267: Correct separation of processed vs. raw input.

current_data (processed) goes to the activity; input_data (raw) is preserved for continue-as-new replay. This avoids double-decoding on restart.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@DatGuyJonathan DatGuyJonathan marked this pull request as ready for review February 6, 2026 20:49
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🤖 Fix all issues with AI agents
In
`@apps/framework-cli/src/framework/python/wrappers/scripts/python_worker_wrapper/workflow.py`:
- Around line 147-150: The docstring for _execute_single_activity is fine but
should explicitly document the special-case mapping where timeout="never" is
treated as a very large schedule timeout; update the _execute_single_activity
docstring to note that passing timeout="never" results in the workflow using a
large-schedule-timeout behavior (rather than infinite blocking), mention any
implications for retries or scheduling semantics, and keep it short and adjacent
to the existing """Execute a single activity.""" description so readers of the
Workflow._execute_single_activity method see the timeout="never" behavior
immediately.
- Line 143: The except block currently binds an unused exception variable via
"except Exception as e:" which triggers Ruff F841; change the handler to either
drop the binding ("except Exception:") or rename it to a prefixed unused name
("except Exception as _e:") in workflow.py so the unused-variable warning is
resolved while preserving the same exception handling behavior in that
try/except block.
- Line 6: The import line currently uses deprecated typing aliases (from typing
import Any, Dict, List, Optional); change it to only import Any and Optional
(from typing import Any, Optional) and replace all occurrences of the
annotations using Dict and List in this module (e.g., function signatures,
return types, and variable annotations in workflow.py) with the built-in
lowercase types dict and list (e.g., Dict[str, Any] -> dict[str, Any], List[int]
-> list[int]); ensure type hints throughout the file (including in any functions
or classes that reference Dict or List) are updated accordingly and that
Optional/Any remain from typing.

In `@packages/ts-moose-lib/src/scripts/workflow.ts`:
- Around line 111-128: The continueAsNew call currently only sends the request
object and drops the current inputData so resumed workflows receive undefined;
update the continueAsNew invocation inside the workflow (near executeTask/
workflowInfo/ task) to pass inputData as the second argument (same shape the
Python version uses) so the restarted workflow receives the original input;
ensure the payload type matches the continueAsNew API signature and adjust any
typing or serialization if needed.
📜 Review details

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 7d51066 and 51e3d21.

📒 Files selected for processing (2)
  • apps/framework-cli/src/framework/python/wrappers/scripts/python_worker_wrapper/workflow.py
  • packages/ts-moose-lib/src/scripts/workflow.ts
🧰 Additional context used
📓 Path-based instructions (5)
**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

**/*.py: Follow PEP 8 style guide in Python; use snake_case for functions/variables, PascalCase for classes, UPPER_SNAKE_CASE for constants
Format Python code with Black using line-length 88; auto-formats on commit via Husky + lint-staged
Use type hints for function signatures and public APIs in Python

Files:

  • apps/framework-cli/src/framework/python/wrappers/scripts/python_worker_wrapper/workflow.py
**/framework-cli/src/**

⚙️ CodeRabbit configuration file

**/framework-cli/src/**: When reviewing changes to Moose CLI:

  1. Check if any user-facing changes were made (commands, flags, configs, apis, etc)
  2. If yes, verify the documentation for THAT SPECIFIC feature is updated in apps/framework-docs-v2/content
  3. If docs for that feature doesn't exist yet, it should be added. If the change removes public apis, the documentation for those should also be removed. Changing unrelated docs doesn't satisfy this requirement.
  4. In addition to reviewing for docs discrepancies, you should also review the code as per usual guidelines.

Files:

  • apps/framework-cli/src/framework/python/wrappers/scripts/python_worker_wrapper/workflow.py
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Run linting checks before submitting PRs for TypeScript/JavaScript code

**/*.{ts,tsx,js,jsx}: Group imports by external dependencies, internal modules, and types; use named exports from barrel files (index.ts)
Use camelCase for variables and functions, PascalCase for types/classes/components, UPPER_SNAKE_CASE for constants in TypeScript/JavaScript
Prefix unused variables with underscore (e.g., _unusedParam) to bypass linting errors in TypeScript/JavaScript
Format TypeScript/JavaScript code with Prettier using experimentalTernaries: true; auto-formats on commit via Husky + lint-staged

Files:

  • packages/ts-moose-lib/src/scripts/workflow.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Prefer interfaces for objects, types for unions/intersections in TypeScript; explicit return types on public APIs

Files:

  • packages/ts-moose-lib/src/scripts/workflow.ts
**/ts-moose-lib/src/**/*.ts

⚙️ CodeRabbit configuration file

**/ts-moose-lib/src/**/*.ts: When reviewing changes to typescript moose lib:

  1. Check if any public apis were changed (class, method, type, config, etc).
  2. If yes, verify the documentation for THAT SPECIFIC feature is updated in apps/framework-docs-v2/content.
  3. If docs for that feature doesn't exist yet, it should be added. If the change removes public apis, the documentation for those should also be removed. Changing unrelated docs doesn't satisfy this requirement.
  4. In addition to reviewing for docs discrepancies, you should also review the code as per usual guidelines.

Files:

  • packages/ts-moose-lib/src/scripts/workflow.ts
🧠 Learnings (3)
📓 Common learnings
Learnt from: DatGuyJonathan
Repo: 514-labs/moosestack PR: 3400
File: apps/framework-cli/src/framework/core/infrastructure_map.rs:1238-1298
Timestamp: 2026-01-26T00:56:27.011Z
Learning: Repo 514-labs/moosestack — Workflows: The CLI’s workflow diff is intended to detect only Temporal schedule–affecting changes. In apps/framework-cli/src/framework/core/infrastructure_map.rs, workflows_config_equal should compare schedule, retries, and timeout only; it must not include tasks. Task code/config changes are picked up automatically when the orchestration worker restarts and should not trigger a WorkflowChange.
📚 Learning: 2026-01-26T00:56:27.011Z
Learnt from: DatGuyJonathan
Repo: 514-labs/moosestack PR: 3400
File: apps/framework-cli/src/framework/core/infrastructure_map.rs:1238-1298
Timestamp: 2026-01-26T00:56:27.011Z
Learning: Repo 514-labs/moosestack — Workflows: The CLI’s workflow diff is intended to detect only Temporal schedule–affecting changes. In apps/framework-cli/src/framework/core/infrastructure_map.rs, workflows_config_equal should compare schedule, retries, and timeout only; it must not include tasks. Task code/config changes are picked up automatically when the orchestration worker restarts and should not trigger a WorkflowChange.

Applied to files:

  • apps/framework-cli/src/framework/python/wrappers/scripts/python_worker_wrapper/workflow.py
  • packages/ts-moose-lib/src/scripts/workflow.ts
📚 Learning: 2026-01-15T19:41:53.563Z
Learnt from: CR
Repo: 514-labs/moosestack PR: 0
File: examples/cdp-analytics/CLAUDE.md:0-0
Timestamp: 2026-01-15T19:41:53.563Z
Learning: Applies to examples/cdp-analytics/app/workflows/*-sync.ts : Scheduled sync workflows should use Cron schedule expressions (e.g., '0 * * * *' for hourly, '*/5 * * * *' for every 5 minutes), fetch from external APIs using Bearer token authorization, and return a SyncResult object with synced count and errors

Applied to files:

  • packages/ts-moose-lib/src/scripts/workflow.ts
🧬 Code graph analysis (2)
apps/framework-cli/src/framework/python/wrappers/scripts/python_worker_wrapper/workflow.py (3)
packages/py-moose-lib/moose_lib/dmv2/workflow.py (2)
  • Workflow (132-189)
  • Task (56-112)
packages/ts-moose-lib/src/dmv2/sdk/workflow.ts (2)
  • Workflow (153-238)
  • Task (61-103)
apps/framework-cli/src/framework/python/wrappers/scripts/python_worker_wrapper/types.py (1)
  • WorkflowStepResult (5-7)
packages/ts-moose-lib/src/scripts/workflow.ts (1)
packages/ts-moose-lib/src/scripts/activity.ts (1)
  • executeTask (73-169)
🪛 Ruff (0.14.14)
apps/framework-cli/src/framework/python/wrappers/scripts/python_worker_wrapper/workflow.py

[warning] 6-6: typing.Dict is deprecated, use dict instead

(UP035)


[warning] 6-6: typing.List is deprecated, use list instead

(UP035)


[warning] 142-142: Consider moving this statement to an else block

(TRY300)


[error] 143-143: Local variable e is assigned to but never used

Remove assignment to unused variable e

(F841)

🔇 Additional comments (5)
packages/ts-moose-lib/src/scripts/workflow.ts (3)

139-153: ETL extract loop runs after onComplete children — ordering concern.

hasMore is checked after all onComplete child tasks complete (lines 130–137). If the intent is extract → transform → load → next-batch-extract, this ordering is correct. But if the extract loop was previously independent of children, this is a behavioral change worth verifying.


98-98: LGTM — comment wording updated to match the "never" literal used at line 73.


134-137: No issue — .data extraction is already present in child task execution.

The code passes the full result object { task: string; data: any } to child tasks at line 135. Child tasks extract .data at line 39 via inputData?.data || inputData, matching Python's behavior.

Likely an incorrect or invalid review comment.

apps/framework-cli/src/framework/python/wrappers/scripts/python_worker_wrapper/workflow.py (2)

100-131: Direct execution + per-task continue-as-new check — clean improvement.

Eliminates the polling monitor that was itself generating history events. The inline is_continue_as_new_suggested() check between activities is the correct Temporal pattern.


116-145: Exception handling is correct.

ContinueAsNewError in the temporalio Python SDK directly subclasses BaseException, not Exception. This is intentional design — the exception will not be caught by the except Exception handler at line 143, so failed_step will not be corrupted.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/ts-moose-lib/src/scripts/workflow.ts (1)

142-156: ⚠️ Potential issue | 🟠 Major

executeTask return type annotation is incorrect.

executeTask at line 77 of activity.ts declares Promise<any[]>, but actually returns whatever fullTask.config.run() produces. For extract tasks, this is { items, hasMore } objects (per etlPipeline.ts line 109: Task<null, BatchResult<T>>), not arrays. Change return type to Promise<any> to match actual behavior.

🤖 Fix all issues with AI agents
In `@packages/ts-moose-lib/src/scripts/workflow.ts`:
- Around line 111-131: The current continueAsNew call restarts the workflow at
continue_from_task: task.name which causes ScriptWorkflow (see ScriptWorkflow
and its handleTask logic) to fetch and re-run the same task; either persist the
completed task result in the workflow state and update handleTask to detect and
skip re-execution when a task has a stored result, or change the continueAsNew
payload to advance to the next task (e.g., set continue_from_task to the first
child of the just-completed task instead of task.name) so the completed activity
is not re-executed; update the continueAsNew invocation and/or
ScriptWorkflow.handleTask to implement the chosen approach and ensure any tasks
that may run across a continueAsNew boundary are idempotent or have their
results persisted.
- Around line 137-140: The loop that invokes child tasks passes the raw result
to children (in the block iterating task.config.onComplete and calling
handleTask), causing inconsistency with Python which unwraps result.data when
present; change the value passed to handleTask to be result.data if result is an
object with a data property (e.g., BatchResult envelope) otherwise pass result,
so child tasks receive the same payload shape as the Python implementation;
adjust the child invocation in the for loop that calls handleTask(workflow,
childTask, ...) to compute const propagated = (result && typeof result ===
"object" && "data" in result) ? result.data : result and pass propagated.
📜 Review details

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 51e3d21 and 2ed53bc.

📒 Files selected for processing (2)
  • apps/framework-cli/src/framework/python/wrappers/scripts/python_worker_wrapper/workflow.py
  • packages/ts-moose-lib/src/scripts/workflow.ts
🧰 Additional context used
📓 Path-based instructions (5)
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Run linting checks before submitting PRs for TypeScript/JavaScript code

**/*.{ts,tsx,js,jsx}: Group imports by external dependencies, internal modules, and types; use named exports from barrel files (index.ts)
Use camelCase for variables and functions, PascalCase for types/classes/components, UPPER_SNAKE_CASE for constants in TypeScript/JavaScript
Prefix unused variables with underscore (e.g., _unusedParam) to bypass linting errors in TypeScript/JavaScript
Format TypeScript/JavaScript code with Prettier using experimentalTernaries: true; auto-formats on commit via Husky + lint-staged

Files:

  • packages/ts-moose-lib/src/scripts/workflow.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Prefer interfaces for objects, types for unions/intersections in TypeScript; explicit return types on public APIs

Files:

  • packages/ts-moose-lib/src/scripts/workflow.ts
**/ts-moose-lib/src/**/*.ts

⚙️ CodeRabbit configuration file

**/ts-moose-lib/src/**/*.ts: When reviewing changes to typescript moose lib:

  1. Check if any public apis were changed (class, method, type, config, etc).
  2. If yes, verify the documentation for THAT SPECIFIC feature is updated in apps/framework-docs-v2/content.
  3. If docs for that feature doesn't exist yet, it should be added. If the change removes public apis, the documentation for those should also be removed. Changing unrelated docs doesn't satisfy this requirement.
  4. In addition to reviewing for docs discrepancies, you should also review the code as per usual guidelines.

Files:

  • packages/ts-moose-lib/src/scripts/workflow.ts
**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

**/*.py: Follow PEP 8 style guide in Python; use snake_case for functions/variables, PascalCase for classes, UPPER_SNAKE_CASE for constants
Format Python code with Black using line-length 88; auto-formats on commit via Husky + lint-staged
Use type hints for function signatures and public APIs in Python

Files:

  • apps/framework-cli/src/framework/python/wrappers/scripts/python_worker_wrapper/workflow.py
**/framework-cli/src/**

⚙️ CodeRabbit configuration file

**/framework-cli/src/**: When reviewing changes to Moose CLI:

  1. Check if any user-facing changes were made (commands, flags, configs, apis, etc)
  2. If yes, verify the documentation for THAT SPECIFIC feature is updated in apps/framework-docs-v2/content
  3. If docs for that feature doesn't exist yet, it should be added. If the change removes public apis, the documentation for those should also be removed. Changing unrelated docs doesn't satisfy this requirement.
  4. In addition to reviewing for docs discrepancies, you should also review the code as per usual guidelines.

Files:

  • apps/framework-cli/src/framework/python/wrappers/scripts/python_worker_wrapper/workflow.py
🧠 Learnings (4)
📓 Common learnings
Learnt from: DatGuyJonathan
Repo: 514-labs/moosestack PR: 3400
File: apps/framework-cli/src/framework/core/infrastructure_map.rs:1238-1298
Timestamp: 2026-01-26T00:56:27.011Z
Learning: Repo 514-labs/moosestack — Workflows: The CLI’s workflow diff is intended to detect only Temporal schedule–affecting changes. In apps/framework-cli/src/framework/core/infrastructure_map.rs, workflows_config_equal should compare schedule, retries, and timeout only; it must not include tasks. Task code/config changes are picked up automatically when the orchestration worker restarts and should not trigger a WorkflowChange.
📚 Learning: 2026-01-26T00:56:27.011Z
Learnt from: DatGuyJonathan
Repo: 514-labs/moosestack PR: 3400
File: apps/framework-cli/src/framework/core/infrastructure_map.rs:1238-1298
Timestamp: 2026-01-26T00:56:27.011Z
Learning: Repo 514-labs/moosestack — Workflows: The CLI’s workflow diff is intended to detect only Temporal schedule–affecting changes. In apps/framework-cli/src/framework/core/infrastructure_map.rs, workflows_config_equal should compare schedule, retries, and timeout only; it must not include tasks. Task code/config changes are picked up automatically when the orchestration worker restarts and should not trigger a WorkflowChange.

Applied to files:

  • packages/ts-moose-lib/src/scripts/workflow.ts
  • apps/framework-cli/src/framework/python/wrappers/scripts/python_worker_wrapper/workflow.py
📚 Learning: 2026-01-15T19:41:53.563Z
Learnt from: CR
Repo: 514-labs/moosestack PR: 0
File: examples/cdp-analytics/CLAUDE.md:0-0
Timestamp: 2026-01-15T19:41:53.563Z
Learning: Applies to examples/cdp-analytics/app/workflows/*-sync.ts : Scheduled sync workflows should use Cron schedule expressions (e.g., '0 * * * *' for hourly, '*/5 * * * *' for every 5 minutes), fetch from external APIs using Bearer token authorization, and return a SyncResult object with synced count and errors

Applied to files:

  • packages/ts-moose-lib/src/scripts/workflow.ts
📚 Learning: 2026-01-26T01:14:58.758Z
Learnt from: DatGuyJonathan
Repo: 514-labs/moosestack PR: 3400
File: apps/framework-cli/src/framework/core/execute.rs:141-146
Timestamp: 2026-01-26T01:14:58.758Z
Learning: In apps/framework-cli/src/infrastructure/orchestration/workflows.rs, workflow scheduling failures should be non-fatal. The workflows::execute_changes function should return () and log errors rather than returning Result and propagating failures. Failing to schedule a workflow is not a reason to fail the deploy.

Applied to files:

  • apps/framework-cli/src/framework/python/wrappers/scripts/python_worker_wrapper/workflow.py
🧬 Code graph analysis (1)
packages/ts-moose-lib/src/scripts/workflow.ts (1)
packages/ts-moose-lib/src/scripts/activity.ts (1)
  • executeTask (73-169)
🪛 Ruff (0.14.14)
apps/framework-cli/src/framework/python/wrappers/scripts/python_worker_wrapper/workflow.py

[warning] 6-6: typing.Dict is deprecated, use dict instead

(UP035)


[warning] 6-6: typing.List is deprecated, use list instead

(UP035)


[warning] 142-142: Consider moving this statement to an else block

(TRY300)

🔇 Additional comments (4)
packages/ts-moose-lib/src/scripts/workflow.ts (1)

96-107: LGTM on timeout handling.

Comment and logic cleanly distinguish "never" (unlimited via large scheduleToCloseTimeout) from explicit and default timeouts. Consistent with Python side.

apps/framework-cli/src/framework/python/wrappers/scripts/python_worker_wrapper/workflow.py (3)

100-131: Clean simplification — same re-execution caveat as the TS side applies here.

Removing the asyncio monitor/race in favor of a direct await + post-activity check is a solid improvement. The return-type narrowing to List[Any] is correct now that ContinueAsNewData is gone.

One note: continue_as_new on line 122 raises ContinueAsNewError (never returns), so return await is technically dead as a return. Harmless, but await workflow.continue_as_new(...) alone (without return) would be slightly more honest.

The re-execution-on-continue concern (same task re-runs) applies identically here—see the corresponding TS comment.


147-150: Docstring is fine as-is.


194-262: run method handles both start and continue-as-new cleanly.

The isinstance(request, dict) guard (line 211) correctly handles Temporal deserialization. Task resolution logic for continue_from_task is straightforward.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
apps/framework-cli/src/framework/python/wrappers/scripts/python_worker_wrapper/workflow.py (2)

220-222: ⚠️ Potential issue | 🟡 Minor

Logging raw input_data may leak sensitive information.

Line 221 and 234 log the full workflow input. If workflows process PII or credentials, these end up in Temporal worker logs.


100-141: ⚠️ Potential issue | 🟠 Major

Python workflows lack ETL extract pagination loop.

TypeScript handleTask (lines 141–155) re-invokes extract tasks when result.hasMore === true. Python's _execute_activity_with_state has no equivalent check—ETL extract pagination won't work for Python workflows.

TypeScript implementation for reference
// Check if this is an ETL extract task that needs to loop
// ETL extract tasks end with "_extract" and return BatchResult with hasMore
if (
  task.name.endsWith("_extract") &&
  result &&
  typeof result === "object" &&
  "hasMore" in result &&
  (result as any).hasMore === true
) {
  logger.info(`Extract task ${task.name} has more data, restarting chain...`);
  // Recursively call the extract task again to get the next batch
  const nextBatchResults = await handleTask(workflow, task, null);
  results.push(...nextBatchResults);
}
🤖 Fix all issues with AI agents
In
`@apps/framework-cli/src/framework/python/wrappers/scripts/python_worker_wrapper/workflow.py`:
- Around line 107-121: The code currently does "return await
workflow.continue_as_new(...)" which is misleading because
workflow.continue_as_new() raises ContinueAsNewError and never returns; change
it to a bare "await workflow.continue_as_new(...)" (remove the return) and add a
short comment explaining that continue_as_new raises ContinueAsNewError so
execution never resumes past this point; update the block referencing
workflow.continue_as_new, WorkflowRequest, task.name, wf.name, and input_data
accordingly.

In `@packages/ts-moose-lib/src/scripts/workflow.ts`:
- Around line 111-123: The call to continueAsNew inside the workflow branch
never returns (it throws a ContinueAsNewError) but the function signature claims
Promise<any[]>; make control flow explicit by adding an immediate return after
awaiting continueAsNew (or rethrow) so TypeScript and readers know execution
stops there—update the block that checks workflowInfo().continueAsNewSuggested
where continueAsNew({ workflow_name: workflow.name, execution_mode:
"continue_as_new", continue_from_task: task.name }, inputData) is awaited to
follow with a return (or throw) to mark the branch as terminal.
📜 Review details

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 2ed53bc and 3d54830.

📒 Files selected for processing (2)
  • apps/framework-cli/src/framework/python/wrappers/scripts/python_worker_wrapper/workflow.py
  • packages/ts-moose-lib/src/scripts/workflow.ts
🧰 Additional context used
📓 Path-based instructions (5)
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Run linting checks before submitting PRs for TypeScript/JavaScript code

**/*.{ts,tsx,js,jsx}: Group imports by external dependencies, internal modules, and types; use named exports from barrel files (index.ts)
Use camelCase for variables and functions, PascalCase for types/classes/components, UPPER_SNAKE_CASE for constants in TypeScript/JavaScript
Prefix unused variables with underscore (e.g., _unusedParam) to bypass linting errors in TypeScript/JavaScript
Format TypeScript/JavaScript code with Prettier using experimentalTernaries: true; auto-formats on commit via Husky + lint-staged

Files:

  • packages/ts-moose-lib/src/scripts/workflow.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Prefer interfaces for objects, types for unions/intersections in TypeScript; explicit return types on public APIs

Files:

  • packages/ts-moose-lib/src/scripts/workflow.ts
**/ts-moose-lib/src/**/*.ts

⚙️ CodeRabbit configuration file

**/ts-moose-lib/src/**/*.ts: When reviewing changes to typescript moose lib:

  1. Check if any public apis were changed (class, method, type, config, etc).
  2. If yes, verify the documentation for THAT SPECIFIC feature is updated in apps/framework-docs-v2/content.
  3. If docs for that feature doesn't exist yet, it should be added. If the change removes public apis, the documentation for those should also be removed. Changing unrelated docs doesn't satisfy this requirement.
  4. In addition to reviewing for docs discrepancies, you should also review the code as per usual guidelines.

Files:

  • packages/ts-moose-lib/src/scripts/workflow.ts
**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

**/*.py: Follow PEP 8 style guide in Python; use snake_case for functions/variables, PascalCase for classes, UPPER_SNAKE_CASE for constants
Format Python code with Black using line-length 88; auto-formats on commit via Husky + lint-staged
Use type hints for function signatures and public APIs in Python

Files:

  • apps/framework-cli/src/framework/python/wrappers/scripts/python_worker_wrapper/workflow.py
**/framework-cli/src/**

⚙️ CodeRabbit configuration file

**/framework-cli/src/**: When reviewing changes to Moose CLI:

  1. Check if any user-facing changes were made (commands, flags, configs, apis, etc)
  2. If yes, verify the documentation for THAT SPECIFIC feature is updated in apps/framework-docs-v2/content
  3. If docs for that feature doesn't exist yet, it should be added. If the change removes public apis, the documentation for those should also be removed. Changing unrelated docs doesn't satisfy this requirement.
  4. In addition to reviewing for docs discrepancies, you should also review the code as per usual guidelines.

Files:

  • apps/framework-cli/src/framework/python/wrappers/scripts/python_worker_wrapper/workflow.py
🧠 Learnings (4)
📓 Common learnings
Learnt from: DatGuyJonathan
Repo: 514-labs/moosestack PR: 3400
File: apps/framework-cli/src/framework/core/infrastructure_map.rs:1238-1298
Timestamp: 2026-01-26T00:56:27.011Z
Learning: Repo 514-labs/moosestack — Workflows: The CLI’s workflow diff is intended to detect only Temporal schedule–affecting changes. In apps/framework-cli/src/framework/core/infrastructure_map.rs, workflows_config_equal should compare schedule, retries, and timeout only; it must not include tasks. Task code/config changes are picked up automatically when the orchestration worker restarts and should not trigger a WorkflowChange.
📚 Learning: 2026-01-26T00:56:27.011Z
Learnt from: DatGuyJonathan
Repo: 514-labs/moosestack PR: 3400
File: apps/framework-cli/src/framework/core/infrastructure_map.rs:1238-1298
Timestamp: 2026-01-26T00:56:27.011Z
Learning: Repo 514-labs/moosestack — Workflows: The CLI’s workflow diff is intended to detect only Temporal schedule–affecting changes. In apps/framework-cli/src/framework/core/infrastructure_map.rs, workflows_config_equal should compare schedule, retries, and timeout only; it must not include tasks. Task code/config changes are picked up automatically when the orchestration worker restarts and should not trigger a WorkflowChange.

Applied to files:

  • packages/ts-moose-lib/src/scripts/workflow.ts
  • apps/framework-cli/src/framework/python/wrappers/scripts/python_worker_wrapper/workflow.py
📚 Learning: 2026-01-15T19:41:53.563Z
Learnt from: CR
Repo: 514-labs/moosestack PR: 0
File: examples/cdp-analytics/CLAUDE.md:0-0
Timestamp: 2026-01-15T19:41:53.563Z
Learning: Applies to examples/cdp-analytics/app/workflows/*-sync.ts : Scheduled sync workflows should use Cron schedule expressions (e.g., '0 * * * *' for hourly, '*/5 * * * *' for every 5 minutes), fetch from external APIs using Bearer token authorization, and return a SyncResult object with synced count and errors

Applied to files:

  • packages/ts-moose-lib/src/scripts/workflow.ts
📚 Learning: 2026-01-26T01:14:58.758Z
Learnt from: DatGuyJonathan
Repo: 514-labs/moosestack PR: 3400
File: apps/framework-cli/src/framework/core/execute.rs:141-146
Timestamp: 2026-01-26T01:14:58.758Z
Learning: In apps/framework-cli/src/infrastructure/orchestration/workflows.rs, workflow scheduling failures should be non-fatal. The workflows::execute_changes function should return () and log errors rather than returning Result and propagating failures. Failing to schedule a workflow is not a reason to fail the deploy.

Applied to files:

  • apps/framework-cli/src/framework/python/wrappers/scripts/python_worker_wrapper/workflow.py
🪛 Ruff (0.14.14)
apps/framework-cli/src/framework/python/wrappers/scripts/python_worker_wrapper/workflow.py

[warning] 6-6: typing.Dict is deprecated, use dict instead

(UP035)


[warning] 6-6: typing.List is deprecated, use list instead

(UP035)

🔇 Additional comments (3)
packages/ts-moose-lib/src/scripts/workflow.ts (2)

97-107: LGTM on timeout handling.

Clear branching between normal timeout (startToCloseTimeout) and unlimited (scheduleToCloseTimeout = 10 years). Comment accurately describes the rationale.


141-155: Extract task pagination state is correctly managed via batcher's internal iterator—passing null is correct.

The extract task is typed as Task<null, BatchResult<T>>, requiring null input by design. Pagination state lives in the ETLPipeline.batcher instance's internal iterator (created once, persists across calls), not in inputData. Each handleTask() call invokes this.batcher.getNextBatch(), which advances the iterator via await this.iterator.next(). Passing null is the intended behavior.

Likely an incorrect or invalid review comment.

apps/framework-cli/src/framework/python/wrappers/scripts/python_worker_wrapper/workflow.py (1)

193-261: run method cleanly handles both start and continue_as_new modes.

Dict-to-dataclass coercion on line 210-211 is a good defensive pattern for Temporal serialization. Task resolution logic is clear.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/ts-moose-lib/src/scripts/workflow.ts (1)

97-107: 🧹 Nitpick | 🔵 Trivial

Magic value "87600h" — extract to a named constant.

Proposed fix
+// 10 years ≈ effectively unlimited; Temporal requires a finite timeout.
+const UNLIMITED_TIMEOUT: Duration = "87600h";
+
 // ...
   } else {
-    activityOptions.scheduleToCloseTimeout = "87600h"; // 10 years
+    activityOptions.scheduleToCloseTimeout = UNLIMITED_TIMEOUT;
   }
🤖 Fix all issues with AI agents
In `@packages/ts-moose-lib/src/scripts/workflow.ts`:
- Around line 125-130: The executeTask function's return type is incorrect:
change its signature from Promise<any[]> to Promise<any> because executeTask
returns the single value from task.config.run() (with only the cancellation path
returning an empty array); update the type annotation for executeTask
accordingly and ensure any related callers (e.g., handleTask which wraps the
single result into results via results.push(result) and flattens child results)
still compile against the new Promise<any> return type.
📜 Review details

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 3d54830 and dbed0f3.

📒 Files selected for processing (1)
  • packages/ts-moose-lib/src/scripts/workflow.ts
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Run linting checks before submitting PRs for TypeScript/JavaScript code

**/*.{ts,tsx,js,jsx}: Group imports by external dependencies, internal modules, and types; use named exports from barrel files (index.ts)
Use camelCase for variables and functions, PascalCase for types/classes/components, UPPER_SNAKE_CASE for constants in TypeScript/JavaScript
Prefix unused variables with underscore (e.g., _unusedParam) to bypass linting errors in TypeScript/JavaScript
Format TypeScript/JavaScript code with Prettier using experimentalTernaries: true; auto-formats on commit via Husky + lint-staged

Files:

  • packages/ts-moose-lib/src/scripts/workflow.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Prefer interfaces for objects, types for unions/intersections in TypeScript; explicit return types on public APIs

Files:

  • packages/ts-moose-lib/src/scripts/workflow.ts
**/ts-moose-lib/src/**/*.ts

⚙️ CodeRabbit configuration file

**/ts-moose-lib/src/**/*.ts: When reviewing changes to typescript moose lib:

  1. Check if any public apis were changed (class, method, type, config, etc).
  2. If yes, verify the documentation for THAT SPECIFIC feature is updated in apps/framework-docs-v2/content.
  3. If docs for that feature doesn't exist yet, it should be added. If the change removes public apis, the documentation for those should also be removed. Changing unrelated docs doesn't satisfy this requirement.
  4. In addition to reviewing for docs discrepancies, you should also review the code as per usual guidelines.

Files:

  • packages/ts-moose-lib/src/scripts/workflow.ts
🧠 Learnings (3)
📓 Common learnings
Learnt from: DatGuyJonathan
Repo: 514-labs/moosestack PR: 3400
File: apps/framework-cli/src/framework/core/infrastructure_map.rs:1238-1298
Timestamp: 2026-01-26T00:56:27.011Z
Learning: Repo 514-labs/moosestack — Workflows: The CLI’s workflow diff is intended to detect only Temporal schedule–affecting changes. In apps/framework-cli/src/framework/core/infrastructure_map.rs, workflows_config_equal should compare schedule, retries, and timeout only; it must not include tasks. Task code/config changes are picked up automatically when the orchestration worker restarts and should not trigger a WorkflowChange.
📚 Learning: 2026-01-26T00:56:27.011Z
Learnt from: DatGuyJonathan
Repo: 514-labs/moosestack PR: 3400
File: apps/framework-cli/src/framework/core/infrastructure_map.rs:1238-1298
Timestamp: 2026-01-26T00:56:27.011Z
Learning: Repo 514-labs/moosestack — Workflows: The CLI’s workflow diff is intended to detect only Temporal schedule–affecting changes. In apps/framework-cli/src/framework/core/infrastructure_map.rs, workflows_config_equal should compare schedule, retries, and timeout only; it must not include tasks. Task code/config changes are picked up automatically when the orchestration worker restarts and should not trigger a WorkflowChange.

Applied to files:

  • packages/ts-moose-lib/src/scripts/workflow.ts
📚 Learning: 2026-01-15T19:41:53.563Z
Learnt from: CR
Repo: 514-labs/moosestack PR: 0
File: examples/cdp-analytics/CLAUDE.md:0-0
Timestamp: 2026-01-15T19:41:53.563Z
Learning: Applies to examples/cdp-analytics/app/workflows/*-sync.ts : Scheduled sync workflows should use Cron schedule expressions (e.g., '0 * * * *' for hourly, '*/5 * * * *' for every 5 minutes), fetch from external APIs using Bearer token authorization, and return a SyncResult object with synced count and errors

Applied to files:

  • packages/ts-moose-lib/src/scripts/workflow.ts
🧬 Code graph analysis (1)
packages/ts-moose-lib/src/scripts/workflow.ts (1)
packages/ts-moose-lib/src/scripts/activity.ts (1)
  • executeTask (73-169)
⏰ Context from checks skipped due to timeout of 900000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Test E2E TypeScript Tests Template (Node 20, npm)
🔇 Additional comments (1)
packages/ts-moose-lib/src/scripts/workflow.ts (1)

141-155: ETL loop ordering is correct: children process before next batch fetch.

Lines 136–139 execute onComplete children on the current batch result. Lines 143–155 check hasMore and recursively call handleTask to fetch the next batch. This produces: extract₁ → children₁ → extract₂ → children₂ → ...—the standard batch-process-then-fetch pattern. Python workflow implements the same ordering (apps/framework-cli/src/framework/python/wrappers/scripts/python_worker_wrapper/workflow.py lines 132–136).

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
apps/framework-cli/src/framework/python/wrappers/scripts/python_worker_wrapper/workflow.py (1)

134-145: 🧹 Nitpick | 🔵 Trivial

Use dict membership check instead of hasattr for WorkflowStepResult.

Line 142: WorkflowStepResult is a TypedDict with a guaranteed "data" key. Using hasattr(result, "data") works at runtime but is non-idiomatic for dict-based types. Use the dict membership operator instead: result.get("data", result) or result["data"] if result.get("data") is not None else result.

📜 Review details

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between dbed0f3 and 20982b1.

📒 Files selected for processing (2)
  • apps/framework-cli/src/framework/python/wrappers/scripts/python_worker_wrapper/workflow.py
  • packages/ts-moose-lib/src/scripts/workflow.ts
🧰 Additional context used
📓 Path-based instructions (5)
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Run linting checks before submitting PRs for TypeScript/JavaScript code

**/*.{ts,tsx,js,jsx}: Group imports by external dependencies, internal modules, and types; use named exports from barrel files (index.ts)
Use camelCase for variables and functions, PascalCase for types/classes/components, UPPER_SNAKE_CASE for constants in TypeScript/JavaScript
Prefix unused variables with underscore (e.g., _unusedParam) to bypass linting errors in TypeScript/JavaScript
Format TypeScript/JavaScript code with Prettier using experimentalTernaries: true; auto-formats on commit via Husky + lint-staged

Files:

  • packages/ts-moose-lib/src/scripts/workflow.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Prefer interfaces for objects, types for unions/intersections in TypeScript; explicit return types on public APIs

Files:

  • packages/ts-moose-lib/src/scripts/workflow.ts
**/ts-moose-lib/src/**/*.ts

⚙️ CodeRabbit configuration file

**/ts-moose-lib/src/**/*.ts: When reviewing changes to typescript moose lib:

  1. Check if any public apis were changed (class, method, type, config, etc).
  2. If yes, verify the documentation for THAT SPECIFIC feature is updated in apps/framework-docs-v2/content.
  3. If docs for that feature doesn't exist yet, it should be added. If the change removes public apis, the documentation for those should also be removed. Changing unrelated docs doesn't satisfy this requirement.
  4. In addition to reviewing for docs discrepancies, you should also review the code as per usual guidelines.

Files:

  • packages/ts-moose-lib/src/scripts/workflow.ts
**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

**/*.py: Follow PEP 8 style guide in Python; use snake_case for functions/variables, PascalCase for classes, UPPER_SNAKE_CASE for constants
Format Python code with Black using line-length 88; auto-formats on commit via Husky + lint-staged
Use type hints for function signatures and public APIs in Python

Files:

  • apps/framework-cli/src/framework/python/wrappers/scripts/python_worker_wrapper/workflow.py
**/framework-cli/src/**

⚙️ CodeRabbit configuration file

**/framework-cli/src/**: When reviewing changes to Moose CLI:

  1. Check if any user-facing changes were made (commands, flags, configs, apis, etc)
  2. If yes, verify the documentation for THAT SPECIFIC feature is updated in apps/framework-docs-v2/content
  3. If docs for that feature doesn't exist yet, it should be added. If the change removes public apis, the documentation for those should also be removed. Changing unrelated docs doesn't satisfy this requirement.
  4. In addition to reviewing for docs discrepancies, you should also review the code as per usual guidelines.

Files:

  • apps/framework-cli/src/framework/python/wrappers/scripts/python_worker_wrapper/workflow.py
🧠 Learnings (5)
📓 Common learnings
Learnt from: DatGuyJonathan
Repo: 514-labs/moosestack PR: 3400
File: apps/framework-cli/src/framework/core/infrastructure_map.rs:1238-1298
Timestamp: 2026-01-26T00:56:27.011Z
Learning: Repo 514-labs/moosestack — Workflows: The CLI’s workflow diff is intended to detect only Temporal schedule–affecting changes. In apps/framework-cli/src/framework/core/infrastructure_map.rs, workflows_config_equal should compare schedule, retries, and timeout only; it must not include tasks. Task code/config changes are picked up automatically when the orchestration worker restarts and should not trigger a WorkflowChange.
📚 Learning: 2026-01-26T00:56:27.011Z
Learnt from: DatGuyJonathan
Repo: 514-labs/moosestack PR: 3400
File: apps/framework-cli/src/framework/core/infrastructure_map.rs:1238-1298
Timestamp: 2026-01-26T00:56:27.011Z
Learning: Repo 514-labs/moosestack — Workflows: The CLI’s workflow diff is intended to detect only Temporal schedule–affecting changes. In apps/framework-cli/src/framework/core/infrastructure_map.rs, workflows_config_equal should compare schedule, retries, and timeout only; it must not include tasks. Task code/config changes are picked up automatically when the orchestration worker restarts and should not trigger a WorkflowChange.

Applied to files:

  • packages/ts-moose-lib/src/scripts/workflow.ts
  • apps/framework-cli/src/framework/python/wrappers/scripts/python_worker_wrapper/workflow.py
📚 Learning: 2026-01-15T19:41:53.563Z
Learnt from: CR
Repo: 514-labs/moosestack PR: 0
File: examples/cdp-analytics/CLAUDE.md:0-0
Timestamp: 2026-01-15T19:41:53.563Z
Learning: Applies to examples/cdp-analytics/app/workflows/*-sync.ts : Scheduled sync workflows should use Cron schedule expressions (e.g., '0 * * * *' for hourly, '*/5 * * * *' for every 5 minutes), fetch from external APIs using Bearer token authorization, and return a SyncResult object with synced count and errors

Applied to files:

  • packages/ts-moose-lib/src/scripts/workflow.ts
📚 Learning: 2026-01-15T19:41:53.563Z
Learnt from: CR
Repo: 514-labs/moosestack PR: 0
File: examples/cdp-analytics/CLAUDE.md:0-0
Timestamp: 2026-01-15T19:41:53.563Z
Learning: Applies to examples/cdp-analytics/app/services/analyticsService.ts : Service functions in analyticsService.ts should execute queries using executeQuery helper, transform raw results, and return typed data structures defined in types/analytics.ts

Applied to files:

  • packages/ts-moose-lib/src/scripts/workflow.ts
📚 Learning: 2026-01-26T01:14:58.758Z
Learnt from: DatGuyJonathan
Repo: 514-labs/moosestack PR: 3400
File: apps/framework-cli/src/framework/core/execute.rs:141-146
Timestamp: 2026-01-26T01:14:58.758Z
Learning: In apps/framework-cli/src/infrastructure/orchestration/workflows.rs, workflow scheduling failures should be non-fatal. The workflows::execute_changes function should return () and log errors rather than returning Result and propagating failures. Failing to schedule a workflow is not a reason to fail the deploy.

Applied to files:

  • apps/framework-cli/src/framework/python/wrappers/scripts/python_worker_wrapper/workflow.py
🧬 Code graph analysis (1)
apps/framework-cli/src/framework/python/wrappers/scripts/python_worker_wrapper/workflow.py (2)
packages/py-moose-lib/moose_lib/dmv2/workflow.py (2)
  • Workflow (132-189)
  • Task (56-112)
apps/framework-cli/src/framework/python/wrappers/scripts/python_worker_wrapper/types.py (1)
  • WorkflowStepResult (5-7)
🪛 Ruff (0.14.14)
apps/framework-cli/src/framework/python/wrappers/scripts/python_worker_wrapper/workflow.py

[warning] 6-6: typing.Dict is deprecated, use dict instead

(UP035)


[warning] 6-6: typing.List is deprecated, use list instead

(UP035)


[warning] 147-147: Consider moving this statement to an else block

(TRY300)

⏰ Context from checks skipped due to timeout of 900000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Test E2E TypeScript Tests Template (Node 20, npm)
🔇 Additional comments (7)
packages/ts-moose-lib/src/scripts/workflow.ts (5)

20-22: Clean context type.

Simple and effective way to thread the original input through continueAsNew boundaries.


118-131: Good fix — pre-check eliminates the duplicate-execution problem.

Moving the continueAsNewSuggested check before the activity runs means continue_from_task now correctly points to an unexecuted task. Solid improvement.


133-138: Removing the polling monitor is the right call.

The comment correctly explains that a running activity doesn't generate workflow history events. This eliminates the self-inflicted history growth.


56-58: Context threading looks correct.

Original inputData is preserved through continueAsNew boundaries and re-processed consistently on restart via line 43.


149-163: BatchResult has hasMore at the top level; code access pattern is correct.

The interface definition in packages/ts-moose-lib/src/dmv2/sdk/etlPipeline.ts shows hasMore as a top-level property of BatchResult, matching the access pattern in lines 155–156.

apps/framework-cli/src/framework/python/wrappers/scripts/python_worker_wrapper/workflow.py (2)

100-146: Preflight continue-as-new check and simplified execution look correct.

The recursive threading of original_workflow_input through child tasks is sound — continue-as-new will always replay from the raw input. Activity execution without the polling monitor avoids the history-growth problem this PR targets.


264-267: Correct separation of processed vs. raw input.

current_data (processed) goes to the activity; input_data (raw) is preserved for continue-as-new replay. This avoids double-decoding on restart.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

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.

1 participant