Khurram Badar / Archive / Papers / Sales purchase agreement engine build specification

Sales purchase agreement engine build specification

manuscript · 2026-07-01 · 2121 words · Khurram Badar

Technical specification for autonomous SPA draft generation and legal lifecycle tracking in UAE real estate with compliance guardrails.

real-estate · legal-automation · uae-regulations · contracts · engineering

SPA ENGINE — BUILD SPEC

**For:** Claude Code (eyes on the live `uniestate` repo — source of truth)
**Target:** add an **SPA Engine** to the Cockpit — draft-generation + lifecycle tracking for the reservation → contract → Oqood pipeline
**Format mirrors:** `OUTREACH-ENGINE-SPEC.md` and `CRM-ENGINE-SPEC.md` — paste-ready, reuse the live store/tokens/patterns, all AI/e-sign/registration simulated and marked `// API`
**Governing thesis:** the engine turns a booking into a *draft* SPA and then *drives and tracks* the legal lifecycle — it does not replace the developer's signature, the DLD, the escrow trustee, or a lawyer. Getting that boundary right is what makes it credible to Uniestate rather than a liability.

---

0. THE ONE THING TO READ FIRST — what "autonomous" can and cannot mean here

The vendor marketing that inspired this ("instant SPA generation," "autonomous SPA creator") blurs a legal line. An SPA is a **binding contract registered with a government authority.** Deep research into the 2026 DLD/RERA framework gives hard limits that the engine must encode as *guardrails*, not ignore as friction:

**Design consequence — the engine is a "draft + drive" system, not an "auto-execute" system.** Every legally-operative act (developer signature, UAE PASS signing, DLD/Oqood submission, escrow movement) is a **HUMAN/AUTHORITY GATE** rendered explicitly in the UI. The engine's job is to make everything *up to* each gate instant, correct, and verified — and to track what happens after. Marketing it as "no human needed" would be both false and a compliance risk; **market it as "minutes not days, with every legal gate visible and enforced."** That honesty is the sell to a 30-year developer.

---

1. What this adds — one paragraph

An **SPA Engine** that, the moment a unit is reserved (from the CRM allocation flow), assembles a **compliant draft SPA** from verified buyer KYC + unit record + the project's payment plan + escrow reference, branching correctly between **off-plan SPA** and **secondary Form F**. It runs a **pre-flight compliance checklist** (project registered, escrow active, KYC/AML complete, TRN for corporates), routes the draft through **simulated e-signature**, then **tracks the post-signing legal lifecycle** — Oqood 90-day countdown, escrow milestone mapping, and handover/title conversion — every government/human step shown as an explicit gate. Reuses the CRM's `unit`, `milestone`, and lead store; writes status back so the pipeline and inventory stay in sync (one brain).

---

2. Data model — extend the existing store

Builds directly on `CRM-ENGINE-SPEC.md` objects (`unit`, `milestone`, `project`, lead). Add:

```
transactionType = "off_plan_spa" | "secondary_form_f" // BRANCH EVERYTHING ON THIS

kyc = {
leadId,
buyerType, // "individual" | "company"
// individual
passportOnFile, emiratesIdOnFile, visaOnFile, // booleans — presence only, no doc storage in demo
// company
tradeLicenseOnFile, moaOnFile, trn, // TRN required for corporate (2026)
amlScreened, // bool — sanctions/PEP screen ran // API
poaOnFile, // if signing by power of attorney
minorGuardian, // if buyer is a minor, guardian record required (DLD rule)
}

spaDraft = {
id, leadId, unitId, transactionType,
status, // see lifecycle §4
// populated fields (from verified sources, never invented):
partiesBlock, // buyer legal name/ID refs + developer/SPV legal entity
propertyBlock, // project name, DLD project no., plot, unit ref, floor, size sqft, view, parking
priceBlock, // total AED, payment plan label
scheduleBlock, // milestone rows (from `milestone[]`)
escrowBlock, // project escrow IBAN + trustee bank (reference only)
clauseBlock, // delay penalty, force majeure, spec-change, termination, assignment, defect-liability (12mo), 5% retention
feesBlock, // 4% DLD, Oqood AED 1,000 self-reg, who-pays flags
generatedAt, templateVersion,
}

legalLifecycle = {
spaId,
preflightPassed, // bool — all §3 gates green
developerSigned, // HUMAN GATE
buyerSigned, // HUMAN GATE (UAE PASS for Form F)
oqoodSubmittedAt, // AUTHORITY GATE (developer's portal action)
oqoodDeadline, // = buyerSigned date + 90 days
oqoodCertificate, // provisional e-cert ref once issued // API
escrowLinked, // bool — plan mapped to escrow IBAN
handoverAt, titleDeedAt, // far-future, tracked
}
```

**Never invent contract clause text or legal entity names.** Clause block uses the **standard RERA-approved SPA structure** as labelled section headers with plain-language summaries; the authoritative wording comes from the developer's approved template (a `templateVersion` pointer). Where real Uniestate SPV / DLD project numbers aren't known, render the field as **`[ — pending client template ]`** and surface it in a "fields awaiting source" list — same discipline as the PDF photography gap. Do not fabricate a DLD project number.

---

3. Pre-flight compliance checklist (the gate before any draft is "ready")

Render as a visible checklist on each draft. Draft can be *assembled* anytime, but cannot advance to "Ready to sign" until all green. Each item is real 2026 law:

1. **Project registered with DLD** (off-plan) — project has a DLD registration no. + approval cert. *Unregistered project = cannot sell.*
2. **Escrow account active** — project escrow IBAN present + trustee bank named. *No escrow = cannot take buyer funds.*
3. **RERA-approved template selected** — `templateVersion` set (off-plan SPA) OR REST/Form-F path selected (secondary).
4. **KYC complete** — individual: passport (+ Emirates ID / visa if resident); company: trade licence + MOA + **TRN**; minor → guardian; POA if applicable.
5. **AML screen passed** — sanctions/PEP check ran clean `// API`.
6. **Payment plan mapped** — milestone schedule exists and ties to escrow (from CRM `milestone[]`).
7. **Fees assigned** — 4% DLD + Oqood self-reg fee: who-pays flagged.

A red item shows the **exact real-world action** to clear it (e.g. "TRN required — corporate buyers must provide Tax Registration Number before contract, 2026 rule").

---

4. Lifecycle state machine (statuses + gates)

Render as a horizontal tracker (reuse the CRM stage-tracker component). Gate types are visually distinct: **⚙ engine (auto)** vs **✋ human** vs **🏛 authority**.

```
1. ⚙ Reserved — unit allocated (from CRM); SPA draft auto-assembled
2. ⚙ Pre-flight — compliance checklist run; blockers surfaced
3. ✋ Ready to sign — all gates green; draft locked for signature
4. ✋ Developer signed — HUMAN GATE (authorised Uniestate/SPV signatory)
5. ✋ Buyer signed — HUMAN GATE (UAE PASS if secondary/Form F)
6. 🏛 Oqood submitted — AUTHORITY GATE (developer's Oqood portal action) → 90-day clock starts at step 5
7. 🏛 Oqood registered — provisional e-certificate issued by DLD // API
8. ⚙ Escrow linked — payment plan bound to escrow IBAN; installments tracked vs milestones
9. 🏛 Handover / Title — far-future; Oqood → permanent title deed at completion
```

---

5. Surfaces to build (under the Cockpit)

5.1 SPA Generator

5.2 Lifecycle Tracker

5.3 Compliance & Escrow panel

5.4 Document register

---

6. Guardrails (visible UI, not buried) — reuse the Outreach-lane pattern

---

7. "One brain" wiring

---

8. Build order (verify at each step)

1. Extend store (transactionType, kyc, spaDraft, legalLifecycle) + seed 2–3 drafts across both branches. Clean build, exit 0.
2. SPA Generator — assembly from unit/milestone/kyc; missing-field flagging. Verify no invented data renders.
3. Pre-flight checklist with real blocker actions. Verify gating (can't reach "Ready to sign" with a red item).
4. Lifecycle Tracker + 90-day Oqood countdown + Digest hook.
5. Compliance & Escrow panel (reference-only notices).
6. Document register + export stub.
7. Capital toggle wires the Form F / secondary path.
8. Bundle grep for new strings; per-surface screenshots; flag mobile/real-device as the open human check.

---

9. Acceptance checklist

---

10. Copy anchors (brand-true, defensible)

← DUBAI REST KNOWLEDGE CORPUSCRM ENGINE — BUILD SPEC →
Two years of working thought, indexed.
Ask me to present it in your conference room — WhatsApp +971 55 623 9111
Book Session →