Overview
Guards before the engine
The signer routes run these checks before calling the engine:
The order lock applies to customer seats only and only when there is more
than one; company representatives follow the workflow.
Requesting a code
sendSignerOtp:
- Refuses a seat that has already signed, rejected or been cancelled
(
409). - Applies the phase gate: the seat’s side must be the one whose turn it is
(
409otherwise). See Workflows. - Applies a resend budget per seat (
429when it is spent). - Creates a new six-digit code, stores only its salted hash and invalidates any earlier code for the seat.
- Hands the email to the notification core, which queues it. If the core skips it or fails, the call fails and nothing is recorded as sent.
- Appends
otp_sentto the audit chain and answers the masked email and the expiry time.
The signing gesture
registerSignerAction with sign and the code:
- Applies the phase gate again.
- Validates the code: it must not be expired, used or past its wrong-attempt limit.
- Resolves the document number recorded for the gesture (below).
- Computes one hash over the hashes of every document in the group: a single gesture signs all of them.
- Marks the seat
signed, stores its evidence and appendssigner_signedto the audit chain. - Advances the group (below).
The document number
The signer types only the code. The engine resolves the document number from the signer’s verified identity, in this order:- The latest verified identity of the signer, counted only if it happened
after the contract started (when it has started). When the signer has a
person account, only identity records for that account’s RUT count
(person accounts that disagree on the RUT fail with
422). Since the card serial is no longer stored, the verified RUT is the document number. - Only for the primary signer (the seat with
signing_order = 1) with no identity record at all: the RUT on their person account, or else the RUT of the contract’s account. - Any other case is refused with
400: the signer must verify their identity first.
Rejecting
registerSignerAction with reject (and an optional reason) marks the seat
and the group rejected and appends signer_rejected to the
audit chain. No other seat can sign afterwards. The phase gate does not
apply to a rejection.
How the group advances
The diagram showscompany_phase = last. With first, the group waits for
the company side before any customer seat can sign, and the last customer
signature seals the group.
The consumer decides what each outcome means for its own record. The engine
also exposes
cancelSignatureRequest, which invalidates the pending codes of
the signers listed when the request was opened and marks the request
cancelled.
Code
Paths are relative to
backend/horizon-api/.