feat(engine): standardize node outputs with O(1) sourceRefs passport - #86
Merged
Merged
Conversation
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 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. Comment |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Pull Request: Standardize Node Outputs and Implement O(1) Coordinate-Based Data Provenance
📌 Summary of Changes
This pull request completely refactors BuildFlow's workflow execution engine, data structures, and variable resolution logic to standardize data contracts across all nodes.
Previously, node execution on the
mainbranch relied on untypedanysignatures, disparate node-specific output wrappers (e.g. raw spreadsheet 2D arrays, isolated status objects), a sequential linear evaluation loop, and column-index heuristics for interpolation.This PR establishes:
ExecuteItem): An atomic record model encapsulating business payloads (json) and coordinate-based lineage metadata (sourceRefs).ExecuteItem[][]): Enforces a[wireIndex][rowIndex]output topology across all node executors, unlocking true multi-pin routing.SheetAuthContext) from execution context (NodeExecutionContext), ensuring type safety for UI metadata routes.🏛️ Architectural Paradigm Comparison
mainBranch (Legacy System)standardizing-node-outputs)any. Every node emitted completely arbitrary JSON shapes.ExecuteItemstructure (jsonpayload +sourceRefscoordinate mapping).output?: any(Could be a single object, primitive, or custom wrapper).output?: ExecuteItem[][](Strict 2D output matrix:[Pins][Items]).inputData?: any(Nodes received untyped data blobs).items: ExecuteItem[](Strictly typed array of input records).sourceRefsdictionary: Direct coordinate mapping (Record<NodeId, { wireIndex, rowIndex }>).columnsandrowsarrays specific to Google Sheets.for (const node of nodes). No support for branching or pins.executor.tswith retry delays and a customloopResultobject.📂 Detailed File-by-File Technical Changes
1.
packages/common/src/index.ts(Core Schema Contract)ExecuteItemSchemaandExecuteItemtype.sourceRefsis structured as a dictionary (Record<NodeId, Coordinates>) rather than an array, enabling2.
packages/nodes/src/registry/Execution.config.types.ts(Execution Contracts)inputData?: anywithitems: ExecuteItem[].output?: anywithoutput?: ExecuteItem[][].nodeId: stringas strictly required (removed optional flag?).3.
packages/nodes/src/google-sheets/google-sheets.executor.ts(Auth Isolation & Output Stamping)SheetAuthContextand madeNodeExecutionContext extend SheetAuthContext.executeReadRowsto transform spreadsheet rows into individualExecuteIteminstances and stamp initial coordinates.executeWriteRows,executeAppendRows, andexecuteClearRowsto preservesourceRefs: item.sourceRefsand return[outputBoxes].getSheets,getSheetTabs,getHeaderRow,ensureSheetService) to acceptSheetAuthContext./getSheets) only need authentication credentials, while workflow step execution strictly requires complete execution parameters.4.
packages/nodes/src/gmail/gmail.executor.ts(Consumer Node Output Matrix)ExecuteIteminstances containing execution response data while forwarding incomingsourceRefs: item.sourceRefs.output: [outputBoxes].5.
packages/nodes/src/filter/filter.executor.ts(Multi-Pin Output Partitioning){ filteredData, discardedData, metadata }object into a true 2D output matrix:metadata.6.
packages/common/src/interpolation.ts(O(1) Variable Resolution)resolveVariable,interpolateString, andresolveConfigVariablesto acceptsourceRefs?: Record<string, { wireIndex: number; rowIndex: number }>.{{variable}}.7.
apps/worker/src/engine/executor.ts(Engine Normalization & BFS Integration)forloop with a Breadth-First Search (BFS) DAG Queue (while (queue.length > 0)).currentInputData:itemsToProcessextraction prior to configuration resolution, supplyingitemsToProcess[0]?.sourceRefstoresolveConfigVariables.8.
apps/http-backend/src/routes/userRoutes/executionRoutes.ts(Single-Node Testing Compliance)nodeId: nodeData.idanditems: []into the test context object.error: executionResult.outputtoerror: executionResult.error.ExecutionContextcontract and prevents node provenance from recordingsourceRefs["undefined"].🧪 Verification & Testing Results
Monorepo Build Compilation:
turbo buildacross all 11 packages (@repo/common,@repo/nodes,@repo/worker,@repo/db,@repo/processor,hooks,http-backend,web).0(Zero TypeScript or build errors).Runtime Verification Suite:
wireIndexcoordinates.Alice,Bob,Charlie).Multi-Pin Executor Verification:
FilterExecutorwith test dataset:Wire 0 (Unique Records):2 itemsWire 1 (Discarded Records):1 itemMetadata:Correctly emitted operation metrics.Live Execution Test:
pnpm dev) with live Kafka broker.🚀 Next Steps
.jsonproperties to the canvas.0and1for the Splitter/Filter nodes.