-
Notifications
You must be signed in to change notification settings - Fork 148
implement event-sourced architecture #621
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
pranaygp
wants to merge
27
commits into
main
Choose a base branch
from
pranaygp/perf-phase-3b-atomic-events
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
0b2771f
perf: implement event-sourced architecture
pranaygp ce7fc09
fix(world-vercel): handle wire format for step in event results
pranaygp 0b26b2b
feat(world-postgres): handle hook_disposed event in event handler
pranaygp 3b918e6
feat(world-postgres): enforce hook token uniqueness per tenant
pranaygp a73d077
feat: add e2e test for hook token conflict
pranaygp 3e42977
chore: remove flaky hookTokenConflictWorkflow test
pranaygp 5b45de6
fix: address code review issues
pranaygp 8566245
fix: throw error on corrupted event log instead of warning
pranaygp 6e11240
Move event log corruption check to step_created event
pranaygp 0a3431f
Remove unused paused/resumed run events and states
pranaygp 969da00
Add changeset for paused/resumed removal
pranaygp ce24493
Fix hook token conflict error to use WorkflowAPIError with status 409
pranaygp 6bd8baa
Remove obsolete tests for deprecated direct create methods
pranaygp 038cdd6
Remove fatal field from step_failed event
pranaygp 6f26c56
Rename step's lastKnownError to error
pranaygp 88e61fd
Add terminal state validation and comprehensive event lifecycle tests
pranaygp 7419729
Add terminal state validation to world-postgres and rename firstStart…
pranaygp 736cecd
Add step_retrying on terminal step tests
pranaygp faecbea
Fix performance regression: reuse validation reads
pranaygp a4569e6
Optimize events.create: skip redundant run validation
pranaygp c8b6af6
Optimize postgres events.create with prepared statements and conditio…
pranaygp e4f7ca1
Fix unused variable in postgres storage
pranaygp 5d9512c
Add Event Sourcing documentation page
pranaygp 09e07b7
Update world-vercel to use v2 API endpoints everywhere
pranaygp aead729
Improve event sourcing documentation accuracy and cross-linking
pranaygp d1c485a
Fix hook documentation to describe general hook primitive
pranaygp 4c5fd4c
Add Entity IDs section to event sourcing docs
pranaygp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| --- | ||
| "@workflow/core": patch | ||
| "@workflow/world": patch | ||
| "@workflow/world-local": patch | ||
| "@workflow/world-postgres": patch | ||
| "@workflow/world-vercel": patch | ||
| "@workflow/web": patch | ||
| "@workflow/web-shared": patch | ||
| --- | ||
|
|
||
| perf: implement event-sourced architecture for runs, steps, and hooks | ||
|
|
||
| - Add run lifecycle events (run_created, run_started, run_completed, run_failed, run_cancelled) | ||
| - Add step_retrying event for non-fatal step failures that will be retried | ||
| - Remove `fatal` field from step_failed event (step_failed now implies terminal failure) | ||
| - Rename step's `lastKnownError` to `error` for consistency with server | ||
| - Update world implementations to create/update entities from events via events.create() | ||
| - Entities (runs, steps, hooks) are now materializations of the event log | ||
| - This makes the system faster, easier to reason about, and resilient to data inconsistencies | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| --- | ||
| "@workflow/world": patch | ||
| "@workflow/world-local": patch | ||
| "@workflow/world-vercel": patch | ||
| "@workflow/cli": patch | ||
| "@workflow/web": patch | ||
| "@workflow/web-shared": patch | ||
| --- | ||
|
|
||
| **BREAKING CHANGE**: Remove unused paused/resumed run events and states | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It'd be nice to split this change out |
||
|
|
||
| - Remove `run_paused` and `run_resumed` event types | ||
| - Remove `paused` status from `WorkflowRunStatus` | ||
| - Remove `PauseWorkflowRunParams` and `ResumeWorkflowRunParams` types | ||
| - Remove `pauseWorkflowRun` and `resumeWorkflowRun` functions from world-vercel | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,66 @@ | ||
| # Workflow DevKit Docs | ||
|
|
||
| Check out the docs [here](https://useworkflow.dev/) | ||
|
|
||
| ## Mermaid Diagram Style Guide | ||
|
|
||
| When adding diagrams to documentation, follow these conventions for consistency. | ||
|
|
||
| ### Diagram Type | ||
|
|
||
| Use `flowchart TD` (top-down) or `flowchart LR` (left-right) for flow diagrams: | ||
|
|
||
| ```mermaid | ||
| flowchart TD | ||
| A["Source Code"] --> B["Transform"] | ||
| B --> C["Output"] | ||
| ``` | ||
|
|
||
| ### Node Syntax | ||
|
|
||
| Use square brackets with double quotes for rectangular nodes: | ||
|
|
||
| ``` | ||
| A["Label Text"] # Correct - rectangular node | ||
| A[Label Text] # Avoid - can cause parsing issues | ||
| A(Label Text) # Avoid - rounded node, inconsistent style | ||
| ``` | ||
|
|
||
| ### Edge Labels | ||
|
|
||
| Use the pipe syntax with double quotes for edge labels: | ||
|
|
||
| ``` | ||
| A -->|"label"| B # Correct | ||
| A --> B # Correct (no label) | ||
| ``` | ||
|
|
||
| ### Highlighting Important Nodes | ||
|
|
||
| Use the purple color scheme to highlight terminal states or key components: | ||
|
|
||
| ``` | ||
| style NodeId fill:#a78bfa,stroke:#8b5cf6,color:#000 | ||
| ``` | ||
|
|
||
| Place all `style` declarations at the end of the diagram. | ||
|
|
||
| ### Complete Example | ||
|
|
||
| ```mermaid | ||
| flowchart TD | ||
| A["(start)"] --> B["pending"] | ||
| B -->|"started"| C["running"] | ||
| C -->|"completed"| D["completed"] | ||
| C -->|"failed"| E["failed"] | ||
|
|
||
| style D fill:#a78bfa,stroke:#8b5cf6,color:#000 | ||
| style E fill:#a78bfa,stroke:#8b5cf6,color:#000 | ||
| ``` | ||
|
|
||
| ### Guidelines | ||
|
|
||
| - Keep diagrams simple and readable | ||
| - Use meaningful node labels | ||
| - Limit complexity - split into multiple diagrams if needed | ||
| - Add a legend or callout explaining highlighted nodes when appropriate |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't actually affect web - that's the pause/unpause changes only from what I can see