The asynchronous pipeline
Long work runs in five workers on the contract queue. In deployed environments the transport is Upstash QStash; every message is also recorded in the queue ledger (queue_event), so a failed job is retried, traced and
never lost.
Handlers live in
backend/horizon-api/lib/queue/contract/handlers/. A
platform cron (/api/v3/cron/queue/event/reconcile, every 10 minutes)
requeues open jobs (received, enqueued or processing) that have
stalled.
Manual review
Withcompany_phase = last (used by the seeded workflows), every contract
signed by its customers waits in pending_review until Maihue operations
decide. The customer is already in the customer portal by then.
approveis accepted only frompending_review. It moves the contract toawaiting_enterprise_signatureand enqueues the enterprise worker.rejectneeds areasonand is accepted frompending_revieworawaiting_enterprise_signature. It cancels the signature group and the contract.
Recovery tools
A signature counts as stuck when it has waited more than 30 minutes on the
enterprise phase: a signature group in
awaiting_enterprise_signature (with
company_phase = last the group reaches that status as soon as the customers
sign, so a contract still waiting for review also shows up), a
company_phase = first group whose enterprise turn is incomplete, or a
sealed group whose contract is still in pending_signature, in_signature,
partially_signed or awaiting_enterprise_signature.
Monitoring
Better Stack watches the flow; its configuration lives ininfra/betterstack/ and is described in
Monitoring — Terraform.
The stuck scan runs as a cron (
/api/v3/cron/signature/enterprise-stuck,
every 10 minutes in production). It reports; the retry above is a manual
decision. Incident handling follows the
Monitoring runbook.
Running the flow locally
Start the apps with Turbo:
Notes for an end-to-end run:
- Mock mode seals for Maihue a few seconds after the customer signs, so
the wizard can be walked to the password. To rehearse the review, open the
wizard with
?mock_enterprise_seal=pending(alsoslowornever) once the magic link was exchanged;autois the default. After the mock checkout the portal calls the mockPOST …/payment/enrollment-notifyuntil the card is attached. - Real mode needs the platform signing certificates configured locally
(see
backend/horizon-api/.env.example) for the countersignature to seal. Approve the review with a back-office token as shown above. - Fintoc webhooks cannot reach
localhost. Against a local API, the portal callsPOST …/payment/enrollment-notifyafter returning from Fintoc so other open tabs still see the new method; deployed environments answer404to that route.
Internal runbooks
Step-by-step runbooks live in the repository underdocs/operations/: