Skip to content

Conversation

@CiaranMn
Copy link
Member

@CiaranMn CiaranMn commented Dec 23, 2025

🌟 What is the purpose of this PR?

We have an in-app "Flows" feature – modular workflows made up of discrete, composable actions.

These are executed via Temporal, via logic that handles calling the right actions in the right order with the right inputs (without knowing what the actions actually are).

This was previously implemented and only supported inside of the AI Temporal worker, for AI-related flows. We have an 'Integration' worker, but its workflows were specific hard-coded series of actions, rather than taking the modular approach.

In preparation for adding more data integrations, the bulk of this PR deals with splitting out the Flow logic from the AI worker into a shared place, and adding support for the Flow approach to the Integration worker.

Note that while the general orchestration logic is shared, the two workers deal with different sorts of actions, and Flows can either be made up of actions supported by the AI worker or actions supported by the Integration worker, but not a mix. This is a starting position and can be changed – it is technically possible to have a workflow made up of a mixture. We can update as necessary when required.

The PR also adds a basic integration for aviation-related data – getting scheduled flights for specific airports, and their live position.

🚫 Blocked by

  • Check linting / tests

Pre-Merge Checklist πŸš€

🚒 Has this modified a publishable library?

This PR:

  • does not modify any publishable blocks or libraries, or modifications do not need publishing

πŸ“œ Does this require a change to the docs?

The changes in this PR:

  • are internal and do not require a docs change

πŸ•ΈοΈ Does this require a change to the Turbo Graph?

The changes in this PR:

  • do not affect the execution graph

⚠️ Known issues

  • H-5892: The data returned in the aviation workflows exceeds certain Temporal request size limits. We need to refactor the outputs from activities to contain pointers to persisted entities rather than the entire entity data.

Next ups

  • H-5892 (as above)
  • H-5893: Add a flow which uses the 'live flight position' API integration to poll for the position of active flights

πŸ›‘ What tests cover this?

  • None yet.

@github-actions github-actions bot added area/deps Relates to third-party dependencies (area) area/apps > hash* Affects HASH (a `hash-*` app) area/infra Relates to version control, CI, CD or IaC (area) area/apps > hash-api Affects the HASH API (app) area/libs Relates to first-party libraries/crates/packages (area) type/eng > frontend Owned by the @frontend team type/eng > backend Owned by the @backend team area/apps area/infra > terraform labels Dec 23, 2025
@codecov
Copy link

codecov bot commented Dec 23, 2025

Codecov Report

❌ Patch coverage is 0% with 113 lines in your changes missing coverage. Please review.
βœ… Project coverage is 59.02%. Comparing base (b6338db) to head (ea57477).

Files with missing lines Patch % Lines
...migrations/025-add-aviation-types.dev.migration.ts 0.00% 52 Missing ⚠️
...h-isomorphic-utils/src/flows/action-definitions.ts 0.00% 14 Missing ⚠️
...ibs/@local/hash-isomorphic-utils/src/flows/util.ts 0.00% 13 Missing ⚠️
...hash-api/src/graphql/resolvers/flows/start-flow.ts 0.00% 7 Missing ⚠️
...orphic-utils/src/flows/example-flow-definitions.ts 0.00% 6 Missing ⚠️
...utils/src/flows/browser-plugin-flow-definitions.ts 0.00% 2 Missing ⚠️
...somorphic-utils/src/flows/goal-flow-definitions.ts 0.00% 2 Missing ⚠️
...tivities/flow-activities/answer-question-action.ts 0.00% 1 Missing ⚠️
...ies/flow-activities/generate-web-queries-action.ts 0.00% 1 Missing ⚠️
...vities/flow-activities/get-file-from-url-action.ts 0.00% 1 Missing ⚠️
... and 14 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8213      +/-   ##
==========================================
+ Coverage   58.90%   59.02%   +0.12%     
==========================================
  Files        1193     1187       -6     
  Lines      112723   112486     -237     
  Branches     5013     4939      -74     
==========================================
  Hits        66394    66394              
+ Misses      45571    45334     -237     
  Partials      758      758              
Flag Coverage Ξ”
apps.hash-api 0.00% <0.00%> (ΓΈ)

Flags with carried forward coverage won't be shown. Click here to find out more.

β˜” View full report in Codecov by Sentry.
πŸ“’ Have feedback on the report? Share it here.

πŸš€ New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • πŸ“¦ JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@vercel vercel bot temporarily deployed to Preview – petrinaut December 23, 2025 17:31 Inactive
@CiaranMn CiaranMn marked this pull request as ready for review December 23, 2025 17:35
@cursor
Copy link

cursor bot commented Dec 23, 2025

PR Summary

Introduces a shared Flow engine and enables Integration flows alongside AI flows.

  • Extracts orchestration to @local/hash-backend-utils/flows (processFlowWorkflow, ProxyFlowActivity, CreateFlowActivities); adds common activities and removes AI-specific workflow logic
  • AI worker migrated to new flow types and getSimplifiedAiFlowActionInputs; cleans up legacy permission/persist wiring
  • Integration worker now supports flows: adds aviation actions (getScheduledFlightsAction, persistIntegrationEntitiesAction), integration flow context helpers, and wires common activities; Terraform adds AERO_API_KEY
  • API: startFlow now takes flowType (AI/Integration) and optional dataSources, validates per type, and dispatches to corresponding task queue
  • Frontend: GraphQL mutation and UI pass flowType; generics updated (FlowActionDefinitionId), default Date input added, provenance/sources tweaks, and integration flows included in catalog
  • Ontology: migration adds aviation data/property/link types and Flight, Airport, Airline, Aircraft
  • Misc: schema compiler disables safe URL resolver for $ref; adds createCommonFlowActivities to workers

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

@augmentcode
Copy link

augmentcode bot commented Dec 23, 2025

This pull request is too large for Augment to review. The PR exceeds the maximum size limit of 100000 tokens (approximately 400000 characters) for automated code review. Please consider breaking this PR into smaller, more focused changes.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the Flow execution system to support both AI and Integration workflows, and adds a basic aviation integration using FlightAware's AeroAPI and Flightradar24 APIs.

Key Changes:

  • Extracts shared Flow orchestration logic into @local/hash-backend-utils for reuse across workers
  • Adds FlowType enum ("ai" | "integration") to distinguish workflow types
  • Implements aviation integration with scheduled flight retrieval and entity persistence
  • Introduces new entity types: Aircraft, Airline, Airport, Flight with associated link types

Reviewed changes

Copilot reviewed 115 out of 118 changed files in this pull request and generated no comments.

Show a summary per file
File Description
libs/@local/hash-isomorphic-utils/src/flows/types.ts Adds generic type parameters to Flow types for action definition constraints
libs/@local/hash-isomorphic-utils/src/flows/action-definitions.ts Splits action definitions into AI and Integration variants
libs/@local/hash-backend-utils/src/flows/process-flow-workflow.ts Extracted shared workflow processing logic from AI worker
apps/hash-integration-worker/src/workflows/run-flow-workflow.ts New integration worker flow implementation
libs/@local/hash-backend-utils/src/integrations/aviation/** Aviation integration clients and entity mapping logic
libs/@local/hash-isomorphic-utils/src/system-types/flight.ts Generated TypeScript types for aviation entities (677 lines)
libs/@local/hash-isomorphic-utils/src/flows/integration-flow-definitions.ts Flow definition for scheduled flights retrieval

πŸ’‘ Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

if (flowType === FlowType.Ai) {
if (!("dataSources" in params)) {
throw Error.badRequest("Data sources are required for AI flows");
}
Copy link

Choose a reason for hiding this comment

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

In-place object property check always prevents AI flows

In startFlow, the condition !("dataSources" in params) always evaluates to true for AI flows because params is initialized as an object literal without that property. This causes every AI flow request to throw a badRequest error, incorrectly claiming that mandatory data sources are missing.

Fix in CursorΒ Fix in Web

@vilkinsons vilkinsons requested a review from hashdotai December 23, 2025 17:46
@vercel vercel bot temporarily deployed to Preview – petrinaut December 23, 2025 18:11 Inactive
export const goalFlowDefinitionWithReportAndSpreadsheetDeliverable: FlowDefinition<AiFlowActionDefinitionId> =
{
...goalFlowDefinition,
type: "ai",
Copy link

Choose a reason for hiding this comment

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

Goal flow ID array incorrectly contains entire object

The goalFlowDefinitionIds array incorrectly includes the entire goalFlowDefinitionWithReportAndSpreadsheetDeliverable object instead of its flowDefinitionId string. This causes identifier checks like goalFlowDefinitionIds.includes(id) to fail for this specific flow, which prevents it from being correctly identified as a goal flow in the UI.

Fix in CursorΒ Fix in Web

export const goalFlowDefinitionWithReportAndSpreadsheetDeliverable: FlowDefinition<AiFlowActionDefinitionId> =
{
...goalFlowDefinition,
type: "ai",
Copy link

Choose a reason for hiding this comment

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

Goal flow ID array incorrectly contains entire object

The goalFlowDefinitionIds array incorrectly includes the entire goalFlowDefinitionWithReportAndSpreadsheetDeliverable object instead of its flowDefinitionId string. This causes identifier checks like goalFlowDefinitionIds.includes(id) to fail for this specific flow, which prevents it from being correctly identified as a goal flow in the UI.

Fix in CursorΒ Fix in Web

Icon={PlaySolidIcon}
onClick={onRunFlowClicked}
pending={waitingToRun}
pending={false}
Copy link

Choose a reason for hiding this comment

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

Flow run button missing loading state and error handling

The flow execution button in Topbar has lost its loading state and error handling. The pending prop is now hardcoded to false, and the try...catch block was removed from onRunFlowClicked. This allows users to trigger multiple simultaneous flow runs and leaves potential API failures unhandled in the UI.

Additional Locations (1)

Fix in CursorΒ Fix in Web

Icon={PlaySolidIcon}
onClick={onRunFlowClicked}
pending={waitingToRun}
pending={false}
Copy link

Choose a reason for hiding this comment

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

Flow run button missing loading state and error handling

The flow execution button in Topbar has lost its loading state and error handling. The pending prop is now hardcoded to false, and the try...catch block was removed from onRunFlowClicked. This allows users to trigger multiple simultaneous flow runs and leaves potential API failures unhandled in the UI.

Additional Locations (1)

Fix in CursorΒ Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/apps > hash* Affects HASH (a `hash-*` app) area/apps > hash-api Affects the HASH API (app) area/apps area/deps Relates to third-party dependencies (area) area/infra > terraform area/infra Relates to version control, CI, CD or IaC (area) area/libs Relates to first-party libraries/crates/packages (area) type/eng > backend Owned by the @backend team type/eng > frontend Owned by the @frontend team

Development

Successfully merging this pull request may close these issues.

3 participants