Skip to main content

Overview

ark-flows-worker is the Temporal worker that runs Ark's onboarding workflows. It is a long-running process with no HTTP API of its own (only a small health-probe server for Kubernetes). It connects to a Temporal server, polls the onboarding-task-queue, and does two things:

  • hosts the workflow code — the parent and child workflows imported from @digizoo/ark-flows-definitions;
  • implements the activities those workflows call — the activity functions are also defined in @digizoo/ark-flows-definitions, and they make the real HTTP calls to the Ark Platform and to Microsoft Entra ID.

The worker source itself (src/main.ts) is a thin shell: it imports the workflows, activities, config, codec, and health server from the shared library and wires them into a Temporal Worker.

What the worker hosts and implements

The worker registers six workflows (from @digizoo/ark-flows-definitions/workflows) and twelve activities (from @digizoo/ark-flows-definitions/activities).

WorkflowRoleSpawned by
onboardingIndividualWorkflowparentark-flows-api via workflow.start (POST /v1/onboarding/individual)
onboardingSoleTraderWorkflowparentark-flows-api via workflow.start (POST /v1/onboarding/sole-trader)
onboardingCompanyWorkflowparentark-flows-api via workflow.start (POST /v1/onboarding/company)
kycVerificationWorkflowchildany parent via executeChild (id kyc-{workflowId})
provisioningWorkflowchildthe individual / sole-trader parent via executeChild (id provisioning-{workflowId})
companyProvisioningWorkflowchildthe company parent via executeChild (id provisioning-{workflowId}) — adds an addSignatories step

The three parents share a common pre-provisioning trunk (steps 1–7: token, address, KYX, uploads, KYC poll, risk + LOW gate) implemented in workflows/parents/_shared/pre-provisioning.ts and differ only on the risk rule key they pass and the provisioning child they spawn.

The twelve activities the worker registers:

ActivityWhat it calls
getTokenMicrosoft Entra ID OAuth2 client_credentials token endpoint
updateWorkflowStatusark-flows-api internal POST /v1/internal/workflow-state
lookupAddressArk Platform — PAF address autocomplete
validateAddressArk Platform — PAF address metadata-by-id (canonical DPID record)
initiateKyxArk Platform — start the KYX identity check
uploadDocumentArk Platform — upload an identity document
getKyxStatusArk Platform — read KYX verification status
scoreRiskArk Platform — BRE rule evaluation
provisionPartyArk Platform — provision the party
provisionAccountArk Platform — provision the account
addSignatoriesArk Platform — link the signatory party to the account (used by companyProvisioningWorkflow only)
provisionCardArk Platform — provision the card

The activity functions live in the shared library, not in this app. The worker only registers and runs them. See the library docs for each activity's internal flow.

Role in the stack

ConcernOwned by
Workflow orchestration (step order, retries, timing)the workflow code in @digizoo/ark-flows-definitions — the worker only hosts it
Side effects (token, address, KYX, risk, provision)the activity implementations in @digizoo/ark-flows-definitions — the worker only runs them
Starting / observing workflowsthe Ark Flows API (the REST API)
Durable execution, retries, schedulingthe Temporal server

The worker must be running for any onboarding to make progress: the API only starts a workflow; Temporal dispatches its workflow and activity tasks to a connected worker, which executes them.

Two lifecycles, two homes

A single onboarding run has two distinct lifecycles:

  • the business onboarding journey (INITIATED → IN_PROGRESS → PENDING_ACTION → COMPLETED / FAILED) — what a caller sees. Documented in the Ark Flows API lifecycle. Not duplicated here.
  • the Temporal workflow-execution lifecycle — the parent/child execution tree, activity executions, retries, durable replay, cancellation, and terminal execution statuses. That is the worker's own lens and lives in lifecycle.
  • lifecycle — the Temporal workflow-execution lifecycle.
  • architecture — worker bootstrap, codec/DataConverter, health server.
  • development — build, run, Temporal prereq, and config.
  • notes — quirks and things to be aware of.