> ## Documentation Index
> Fetch the complete documentation index at: https://docs.bbrands.io/llms.txt
> Use this file to discover all available pages before exploring further.

# History

> How MaihueSigner was built — from the signature tables to the in-house engine and its workflows — and how it changed afterwards as digital contracting tied each signature to a verified identity.

This page tells how the engine reached its current shape. Each stage says
what changed, why, and which parts of the code it touched. The other pages of
this section describe the engine **as it works today**.

## Timeline

```mermaid theme={null}
timeline
    title MaihueSigner, 2026
    May : Signature tables and back-office routes
    July : In-house engine core replaces the external vendor
         : One-time-code gesture tied to the verified identity
         : Workflows and unattended company seats
    August : PAdES verification fix
           : Signing events carry the full contract state
           : Countersignature only after operations review
    September : Identity counts only from the contract start
              : Identity re-check on recovered sessions
    October : Company administrators sign in order
            : Verified RUT as the signed document number
            : Identity limited to the person account RUT
            : Identity stamp in the audit chain
            : Emails through the notification core
            : Account on signer seats
```

## How it was built

**1. Signature tables (May 2026)**

The signature domain got its tables and back-office routes under
`/api/v3/signature`, each operation with its own permission.

**2. In-house engine core (July 2026)**

Until then the contract flow used an external e-signature vendor,
TuFirma.digital, which never reached production. The platform built its
own engine instead of keeping the vendor. It added, in this order, the
cryptographic core (hashing, one-time codes, the audit chain, PAdES
sealing and verification), the engine client behind a provider-agnostic
interface, and the signing and evidence endpoints. The vendor
integration was removed outright, with no period of running both. Every
group records which provider signs it.

**3. Workflows and unattended company seats (July 2026)**

A workflow model made the company side configurable per business unit: a
catalogue of representatives, attended or unattended seats, a quorum, and
whether the company signs first or last. The workflow is frozen as a
snapshot on each group, so changes to a workflow do not alter a group in
flight.
The same stage added the phase gate, the unattended signing job, the
back-office API with stuck-group listing and retry, and a test harness
that proves a second consumer could reuse the engine.

## How it changed afterwards

Most later changes came from digital contracting, the first consumer, as it
went from a working signature to one bound to the customer's verified
identity.

| Stage | Change | Why | Main files |
| - | - | - | - |
| July | The signing gesture asks only for the one-time code; the document number is taken from the signer's verified identity | The customer had just proved their identity; asking for the number again added friction and a second source of truth | `internal-signer.client.ts`, `signature-signing.validator.ts` |
| August | PAdES verification keeps the CMS encoding intact | Verification of sealed PDFs failed intermittently | `pades-sealer.ts` |
| August | Signing and countersignature publish the full contract state; the countersignature runs only after operations approve | The portal needs one consistent state, and, with `last` workflows, no contract is countersigned without a human review | `signature-signing.service.ts`, `contract-enterprise-sign.handler.ts` |
| September | An identity verification counts for a signature only if it happened after the contract started | A verification from an older contract must not sign a new one | `internal-signer.client.ts` |
| September | A recovered session must prove the identity card serial again before it can sign; the company job stops emailing customers | A forwarded link alone must not be enough to sign; customers already sign in the portal. The re-check first had its own route and then moved into the identity step | `signature-signing.service.ts`, `signature-signing.validator.ts`, signer routes, `contract-enterprise-sign.handler.ts` |
| October | Company administrators sign strictly in their order; each signature invites the next | A company's signing order is part of the agreement | `assert-customer-sequential-sign-lock.ts`, `signature-signing.service.ts` |
| October | The signed document number is always the verified RUT; the card serial is no longer used | Identity records no longer store the card serial | `internal-signer.client.ts` |
| October | Only identity records for the RUT on the signer's person account count | Identity belongs to the person account, not to each login | `internal-signer.client.ts` |
| October | Each signature links the identity stamp of its verification in the audit chain | The evidence points to the exact identity proof used | `internal-signer.client.ts` |
| October | Engine emails go through the platform notification core | One place sends and traces every email | `internal-signer.client.ts` |
| October | Customer and attended company seats record the account they belong to | Account-centric identity across the platform | `signature_signer` schema, `contract-send-to-signer.handler.ts` |

File names refer to `lib/integration/signature-provider/internal-signer/`,
`lib/endpoint/signature-signing/` and `lib/queue/contract/handlers/` in
`backend/horizon-api/`.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.