-
Notifications
You must be signed in to change notification settings - Fork 0
feat(engine): add ExecutionContext and walker type interfaces #12
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
Open
albertgwo
wants to merge
1
commit into
main
Choose a base branch
from
feat/engine-pr1a-walker-types
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.
Open
Changes from all commits
Commits
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
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,7 @@ | ||
| export type { | ||
| ExecutionContext, | ||
| NodeExecutionRecord, | ||
| WalkerCallbacks, | ||
| WalkOptions, | ||
| WalkResult, | ||
| } from './types.js' |
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,82 @@ | ||
| import type { | ||
| ActionNode, | ||
| SwitchNode, | ||
| ParallelNode, | ||
| WaitNode, | ||
| ErrorNode, | ||
| TerminalNode, | ||
| TriggerNode, | ||
| } from '@ruminaider/flowprint-schema' | ||
|
|
||
| /** | ||
| * Context passed to each node handler during graph execution. | ||
| * Created fresh for each execute() call. | ||
| */ | ||
| export interface ExecutionContext { | ||
| /** Original flow input. Treated as immutable during execution. */ | ||
| readonly input: Record<string, unknown> | ||
| /** Accumulated state from prior nodes. Flat-merged after each node. */ | ||
| state: Record<string, unknown> | ||
| /** Metadata about the currently executing node. */ | ||
| readonly node: { | ||
| readonly id: string | ||
| readonly type: string | ||
| readonly lane: string | ||
| } | ||
| /** Cancellation/timeout signal. Handlers should check signal.aborted. */ | ||
| readonly signal: AbortSignal | ||
| } | ||
|
|
||
| /** | ||
| * Delta-only trace record for a single node execution. | ||
| * Stores what the node produced, not a full state snapshot. | ||
| */ | ||
| export interface NodeExecutionRecord { | ||
| nodeId: string | ||
| type: string | ||
| lane: string | ||
| startedAt: number | ||
| completedAt: number | ||
| /** What this node produced (delta). Full state reconstructable by replaying deltas. */ | ||
| output: Record<string, unknown> | ||
| /** How this node was handled. */ | ||
| handler: 'expressions' | 'rules' | 'registered' | 'entry_point' | 'native' | ||
| /** Present only if the node errored. */ | ||
| error?: { message: string; stack?: string } | ||
| } | ||
|
|
||
| /** | ||
| * Pluggable callbacks for the generic graph walker. | ||
| * TStep is generic so runner, simulator, and engine can each define their own step shape. | ||
| */ | ||
| export interface WalkerCallbacks<TStep = NodeExecutionRecord> { | ||
| onAction(nodeId: string, node: ActionNode, ctx: ExecutionContext): Promise<unknown> | ||
| onSwitch(nodeId: string, node: SwitchNode, ctx: ExecutionContext): Promise<string | undefined> | ||
| onParallel(nodeId: string, node: ParallelNode, ctx: ExecutionContext): Promise<unknown> | ||
| onWait(nodeId: string, node: WaitNode, ctx: ExecutionContext): Promise<unknown> | ||
| onError(nodeId: string, node: ErrorNode, ctx: ExecutionContext): Promise<string | undefined> | ||
| onTrigger(nodeId: string, node: TriggerNode, ctx: ExecutionContext): Promise<string | undefined> | ||
| onTerminal?(nodeId: string, node: TerminalNode, ctx: ExecutionContext): Promise<void> | ||
| /** Called after each node completes. Used for trace recording. */ | ||
| onStep(record: TStep): void | ||
| } | ||
|
|
||
| /** | ||
| * Options for walkGraph. | ||
| */ | ||
| export interface WalkOptions { | ||
| /** AbortController for the entire walk. */ | ||
| abortController?: AbortController | ||
| } | ||
|
|
||
| /** | ||
| * Result of a complete graph walk. | ||
| */ | ||
| export interface WalkResult<TStep = NodeExecutionRecord> { | ||
| /** Final accumulated state after all nodes. */ | ||
| output: Record<string, unknown> | ||
| /** Ordered list of step records. */ | ||
| trace: TStep[] | ||
| /** Terminal node outcome if reached. */ | ||
| outcome?: 'success' | 'failure' | ||
| } |
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.
Exporting new walker types changes @ruminaider/flowprint-engine's public API — should we add a .changeset/*.md entry or record a waiver?
Finding type:
AI Coding Guidelines| Severity: 🟠 MediumWant Baz to fix this for you? Activate Fixer
Other fix methods
Prompt for AI Agents:
Heads up!
Your free trial ends tomorrow.
To keep getting your PRs reviewed by Baz, update your team's subscription