Skip to content

Send final state to lightning#1074

Merged
josephjclark merged 8 commits into
mainfrom
send_final_state
Oct 20, 2025
Merged

Send final state to lightning#1074
josephjclark merged 8 commits into
mainfrom
send_final_state

Conversation

@taylordowns2000
Copy link
Copy Markdown
Member

@taylordowns2000 taylordowns2000 commented Oct 18, 2025

Short Description

Changes RUN_COMPLETE event to send actual final state (using the nice engine implementation that the CLI already uses) instead of the unused dataclip ID reference. This enables Lightning to receive the complete workflow result directly, supporting branching workflows with multiple leaf nodes.

Implementation Details

Type Definitions

  • lexicon/lightning.d.ts: Replace final_dataclip_id?: string with final_state?: any in RunCompletePayload

Worker Implementation

  • ws-worker/src/events/run-complete.ts: Send final_state: event.state (from runtime) instead of final_dataclip_id
  • ws-worker/src/events/run-error.ts: Remove final_dataclip_id field from error case

Mock/Test Infrastructure

  • ws-worker/src/mock/runtime-engine.ts: Include state in workflow-complete event dispatch
  • ws-worker/test/events/run-complete.test.ts: Update tests + add coverage for linear/branching workflows, serialization, and binary data
  • ws-worker/test/lightning.test.ts: Assert final_state is object instead of final_dataclip_id is string

Lightning Mock

  • lightning-mock/src/api-dev.ts: Read final_state from payload instead of looking up dataclip by ID
  • lightning-mock/src/api-sockets.ts: Store final_state directly instead of dataclip lookup
  • lightning-mock/test/channels/run.test.ts: Send final_state in test payloads instead of final_dataclip_id

QA Notes

This doesn't do anything interesting unless you're connecting the worker to lightning on the sync-mode branch: OpenFn/lightning#3785

AI Usage

Please disclose how you've used AI in this work (it's cool, we just want to know!):

  • Code generation (copilot but not intellisense)
  • Learning or fact checking
  • Strategy / design
  • Optimisation / refactoring
  • Translation / spellchecking / doc gen
  • Other
  • I have not used AI

You can read more details in our Responsible AI Policy

Release branch checklist

Delete this section if this is not a release PR.

If this IS a release branch:

  • Run pnpm changeset version from root to bump versions
  • Run pnpm install
  • Commit the new version numbers
  • Run pnpm changeset tag to generate tags
  • Push tags git push --tags

Tags may need updating if commits come in after the tags are first generated.

@github-project-automation github-project-automation Bot moved this to New Issues in Core Oct 18, 2025
@taylordowns2000 taylordowns2000 changed the title send final state to lightning Send final state to lightning Oct 18, 2025
@taylordowns2000 taylordowns2000 marked this pull request as ready for review October 18, 2025 20:45
@taylordowns2000
Copy link
Copy Markdown
Member Author

@josephjclark , would love your eyes here. i don't understand mock at all. this isn't super urgent, but i'm hoping it's not actually a big change. there should be no impact on lighting, until this gets merged: OpenFn/lightning#3785

Comment thread packages/ws-worker/src/events/run-complete.ts
@josephjclark
Copy link
Copy Markdown
Collaborator

QA notes:

  • main runs absolutely fine with these changes
  • main with multiple outputs isn't very interesting, as our man @taylordowns2000 says. But nothing breaks.

I'll leave it up to lightning to decide what to do with the new final_state. Everything here looks rosy to me

@josephjclark josephjclark merged commit 68f6538 into main Oct 20, 2025
@josephjclark josephjclark deleted the send_final_state branch October 20, 2025 11:03
@github-project-automation github-project-automation Bot moved this from New Issues to Done in Core Oct 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants