# Sovereign Desk

**Private on-premise AI for Colorado law and CPA firms.** Document review, intake triage, and
drafting that run on hardware inside the firm's own office. Client files never leave the building,
and the software produces the log that proves it.

A RIG offering. Built and supported by Mike Rodgers, Denver CO.

---

## What is in this directory

| File | What it is |
|---|---|
| `app/` | The working application — plain HTML/CSS/JS, no build step, no dependencies |
| `app/index.html` | Application shell, four tabs |
| `app/styles.css` | All styling |
| `app/app.js` | Rules engine, triage engine, drafting engine, fleet client, egress ledger |
| `app/samples.js` | Sample corpus: 5 documents, 4 intake emails, 10 conflict records, 4 templates, 19 clauses |
| `landing.html` | Sales page with a live iframe of the real app |
| `icon.svg` | Hand-authored 512×512 mark |
| `icon-256.png` | 256px raster export |
| `GTM.md` | ICP, trigger events, 5-email sequence, 3 LinkedIn posts, objections, 10 prospect types |
| `PRICING.md` | Tiers, replacement math, COGS, margins, capacity ceiling, discount policy |
| `README.md` | This file |

---

## How to run it

The app is static. Two ways to open it.

**Recommended — local web server** (needed for the fleet calls, because Ollama echoes a specific
`Origin` header and a `file://` origin is `null`):

```bash
cd ~/Developer/rig-offerings/sovereign-desk
python3 -m http.server 8080 --bind 127.0.0.1
# then open:
#   http://127.0.0.1:8080/app/index.html      <- the workspace
#   http://127.0.0.1:8080/landing.html        <- the sales page
```

**Double-click** `app/index.html` also works. The rules engine, triage, drafting, ledger, and all
sample data function normally over `file://`. The blackwell node (vLLM, `Access-Control-Allow-Origin: *`)
still answers; the Ollama nodes may not, because of the origin echo.

No install step. No npm. No bundler. That is deliberate — a firm's IT contractor has to be able to
read every line of this.

---

## What the app actually does

### Document Review
Five sample documents load on open: a Colorado commercial lease, an unexecuted vendor MSA, a mutual
NDA, an engagement letter, and an IRS CP2000 notice. Paste or upload your own (`.txt`, `.md`, `.eml`).

A **deterministic rules engine** runs in ~1–20 ms with no model involved and flags:

- governing law and whether it is Colorado
- mandatory arbitration and its venue, jury-trial waivers
- auto-renewal clauses **and the notice window in days** (it reads both sides of the sentence, so
  "not less than one hundred eighty (180) days prior … shall automatically renew" resolves to 180)
- indemnity with no limitation of liability
- one-way vs. mutual indemnity, and which party carries it
- assignment permitted without consent
- data-boundary language: subprocessors, out-of-state processing, "to improve its models"
- cure and notice periods, insurance limits, annual escalation with the compounded five-year effect
- unfilled placeholders (`[STATE]`, `____`, `TBD`)
- hard deadlines, with days-until computed against today's date
- missing signature block

Each finding carries the **literal quoted span**, is severity-weighted into a 0–100 risk score, and
clicking it scrolls to and highlights that text in the document. Extracted facts (parties, dollar
figures, dates, governing law, cure periods) are pulled out separately.

**"Deep read on fleet"** then sends the document to a real GPU node and returns a four-section
attorney review. This is a live network call to actual hardware.

### Intake Triage
Paste an inbound client email (or click one of four samples). Locally, before any model runs:

- classifies practice area against a weighted keyword model across 6 areas, shows the runner-up and
  the matched signals
- extracts a stated deadline ("21 days", "due March 3, 2026") and computes days remaining
- parses incident age from natural language ("14 months ago", "3 years and 2 months ago")
- runs the **Colorado limitations clock** — CADA/EEOC 300-day charge windows, C.R.S. 13-80-101
  three-year contract and motor-vehicle periods, 13-80-102 two-year negligence, 13-80-103.5 six-year
  liquidated debt, CP2000 and SNOD procedural windows — and marks each open / tight / critical / barred
- runs a **conflict check** against the firm client list and flags current clients and adverse parties
  with the RPC 1.7 prompt
- produces a ranked next-actions list

**"Draft reply on fleet"** generates an intake response on your own hardware. When a conflict is
detected the prompt is changed so the reply refuses to discuss facts — that behavior is verified
working (the Ortega sample hits Front Range Capital Partners LP, an existing client).

### Drafting
Four templates (engagement letter, demand letter, records request, mutual NDA) over a 19-clause
library. Assembly is **deterministic string merge** — no model, no hallucination surface. "Polish on
fleet" is optional and clearly labelled as the model layer. Copy or download as `.txt`.

### Sovereignty
- live latency probe of all four fleet nodes, with a routing selector
- **request ledger**: every outbound call the app makes, classified LAN or WAN by RFC1918 + CGNAT
  100.64/10 + loopback matching. Exportable as JSON.
- egress byte counter in the header, red the instant anything non-private is contacted
- session data inventory and the written data-boundary policy

---

## What is real vs. what is stubbed

### Real — verified, not asserted

- **The app runs.** Opened in Chrome, all four tabs exercised via Playwright, **zero console errors,
  zero page errors.** Screenshots taken of every tab.
- **The rules engine is real code.** It found 10 findings and a 100/100 risk score on the vendor MSA,
  including the Delaware governing law, the uncapped indemnity, the 90-day auto-renewal window, the
  San Francisco arbitration venue, the blank insurance limit, and 7 unfilled placeholders — each with
  its quoted span. It found the 180-day auto-renewal window in the lease.
- **The fleet calls are real.** Measured in-browser during verification:
  `blackwell 100.67.126.117:8000` — doc review 4,403 B up, HTTP 200 in 1,479 ms; intake reply
  1,369 B up, 200 in 1,060 ms. All four nodes probed 200 at 9–24 ms.
- **The triage engine is real.** The Ortega sample classifies as Tax controversy (signal 57),
  urgency Same-day, extracts the 21-day deadline, anchors the CP2000 window to it, and returns
  2 conflict hits including a current client.
- **The drafting engine is real.** Produces a complete, correctly merged demand letter and engagement
  letter with live field edits.
- **The egress ledger is real.** It wraps every `fetch()` the app makes; nothing bypasses it.
- **The sample corpus is real text**, generated on the fleet (blackwell + rig-96gb + rig-36gb + rig-28gb)
  and hand-checked — not lorem ipsum. The MSA was hand-authored to carry the exact defects the engine
  is built to catch, which is why it scores 100.
- **The landing page renders.** Screenshotted at 1500×1050 across every section, zero page errors,
  and the demo section iframes the actual application rather than a picture of it.
- **The public sourcing channels in `GTM.md`** were each fetched live and return HTTP 200.

### Stubbed, simulated, or not built

- **No persistence.** Documents live in browser memory. Reload destroys everything. That is a
  demo-honest choice, not a shipped-product choice — a real install needs local disk storage with
  matter-level access controls, and that is Vault-tier work.
- **No authentication, no user accounts, no per-matter permissions.** Single-user demo.
- **No DMS integration.** No NetDocuments, iManage, or Clio connector. Paste, drop, upload only.
  This is stated plainly in the landing page FAQ rather than hidden.
- **No PDF or DOCX parsing.** Plain text only. A production install needs `pdf.js` and a `.docx`
  extractor; both are straightforward, neither is built.
- **The conflict list is 10 fictional records**, not a real client database.
- **The Colorado limitations table is a triage aid, not legal advice**, and is labelled as such in
  the UI. It covers six practice areas at the headline level. It is not exhaustive, does not model
  tolling, discovery-rule accrual, or minority, and would need a Colorado attorney's review before
  a firm relied on it.
- **The fleet nodes are RIG's hardware, not a customer's.** In a real install this is one appliance
  in the client's office. The four-node fleet in the demo is what makes the routing selector
  interesting; a customer sees one node.
- **No installer, no provisioning automation, no monitoring agent.** Setup today is manual work by
  Mike. That is fine at 2 accounts and breaks at 15.
- **Apollo prospect list was NOT pulled.** The live key in `com.rig.env.APOLLO_API_KEY` is on a Free
  plan — `mixed_companies/search` returns HTTP 403 `API_INACCESSIBLE` and `organizations/enrich`
  returns 422 insufficient credits. `GTM.md` documents this and uses manually verified public
  sources instead. No fabricated prospect list was written.
- **Nothing has been sent.** No emails, no LinkedIn posts, no outreach of any kind. All GTM copy is
  drafted and staged only. Gate-D applies.
- **The three LinkedIn posts were drafted on the fleet and then rewritten by hand**, because the
  model versions invented client counts ("I've helped dozens of firms") and a war story that never
  happened. The published versions contain only arithmetic and cited authority.

### Known rough edges

- The rules engine is regex-based. It will miss clauses phrased unusually and can double-count a
  cure period that appears twice. It is a first-pass tool and the UI says so.
- Entity extraction over-captures on documents with many capitalized headings.
- `max_model_len` on the blackwell vLLM node is 16,384 tokens, so documents are truncated to 9,000
  characters for the deep read. Long agreements need chunking, which is not built.
- No mobile layout for the app (the landing page is responsive; the workspace is desktop-only by design).

---

## Fleet used to build this

| Node | Endpoint | Model | Used for |
|---|---|---|---|
| blackwell | `100.67.126.117:8000` (vLLM) | Qwen3-Coder-30B-A3B-Instruct | sample lease, intake emails, LinkedIn drafts, live doc review |
| rig-96gb | `100.102.142.84:11434` | qwen3-coder:30b | sample NDA |
| rig-36gb | `100.89.143.27:11434` | qwen3-coder:30b | sample intake batch |
| rig-28gb | `100.76.209.22:11434` | qwen3-coder:30b | engagement letter + CP2000 notice |

All four are on the private network (100.64/10 CGNAT). Verified reachable and CORS-open from a
browser at build time.

---

## License and ownership

Not open source. This is a commercial RIG offering. Customer installs include a source and
model-weight escrow clause — see `PRICING.md` §1.
