# CORI_LIVE_CALL_COPILOT_ARCHITECTURE.md

## Document Control

- **Document Name:** CORI Live Call Copilot Architecture
- **Document Role:** Governing architecture document
- **Applies To:** Dispatcher Workspace, Company Workspace, Truck continuity workflow, global call popup, future Driver and Broker/Shipper call surfaces where applicable
- **Status:** Active
- **Owner:** Dispatch Spot core platform architecture
- **Architecture Priority:** High
- **Change Discipline:** Any build affecting CORI calling, dialer behavior, live call guidance, phone-book search, call outcomes, popup launching, or truck-call continuity must be checked against this document before implementation.

---

## 1. Purpose

CORI Live Call Copilot is the dispatcher-facing real-time calling workspace for Dispatch Spot.

Its purpose is to help a dispatcher successfully handle live calls with:

- brokers
- drivers
- shippers

CORI must:

- listen to the live call
- extract the important facts in real time
- calculate the business meaning of those facts
- surface only the shortest useful guidance
- recommend the next best line to say
- help the dispatcher close the call with a clear result
- feed the result back into truck continuity and follow-up workflows

This is not a standard chat page and not a reporting page.

This is a **live call copilot workspace**.

---

## 2. Product Positioning

CORI Live Call Copilot is not primarily a chatbot.

It is a:

- truck-aware
- voice-aware
- real-time
- negotiation and operating intelligence copilot

The dispatcher should mostly:

- select destination
- press call
- glance at guidance
- speak
- tap a result

Typing should be optional and secondary.

---

## 3. Core Design Principles

### 3.1 Call-first, not chat-first
CORI’s calling workspace must behave like a live calling tool, not like a long threaded text conversation.

### 3.2 Minimum words necessary
CORI guidance must always be:

- short
- direct
- numeric where possible
- easy to scan while speaking

### 3.3 Real-time business intelligence
CORI must not only repeat what was said on the call.
It must also add the hidden operating and pricing reality the dispatcher may not know in the moment.

### 3.4 Truck-first context
Whenever relevant, every call must be attached to:

- a truck
- and where applicable, a current load, next load, lane, or continuity decision

### 3.5 Popup from anywhere
CORI Live Call Copilot must be available as both:

- a full page
- a popup launcher from any relevant page

### 3.6 Same truth in every surface
The full-page version and popup version must use the same backend truth for:

- call state
- destination
- transcript facts
- live advice
- outcomes
- follow-up creation
- continuity updates

---

## 4. Main User Jobs

CORI Live Call Copilot must help dispatchers handle these jobs.

### 4.1 Broker call jobs

- ask pickup and delivery
- get miles and timing
- evaluate rate
- counter intelligently
- ask for accessorial coverage
- decide take / pass / callback
- request and confirm the rate con

### 4.2 Driver call jobs

- confirm location
- confirm pickup or delivery status
- communicate next instructions
- gather issue details
- handle delay and problem calls

### 4.3 Shipper call jobs

- request capacity
- confirm truck status
- provide ETA
- handle issue escalation
- coordinate service updates

---

## 5. Full-Page Layout

The full-page CORI Live Call Copilot page must have four main regions.

### 5.1 Top context strip
Always visible, compact, dense, and operational.

### 5.2 Main live intelligence board
The center of the page.
This is split into three live panels:

- Live Facts
- Hidden Reality
- CORI Advice

### 5.3 Bottom fixed dialer
Always available while the page is open.

### 5.4 Compact outcome / decision area
Shows live call result state and quick result actions.

The page should not look like a report, archive, or admin surface.

---

## 6. Top Context Strip Specification

### 6.1 Purpose
Show exactly who is being called and why.

### 6.2 Must show

- Contact name
- Contact role: Broker / Driver / Shipper
- Company name
- Phone number
- Truck
- Load or lane context when present
- Equipment type
- Target rate when relevant
- Floor rate when relevant
- Call purpose
- Call state

### 6.3 Example content

- `Acme Logistics`
- `Broker`
- `(919) 555-2011`
- `Truck 214`
- `Raleigh NC → Atlanta GA`
- `53' Van`
- `Ask: $1,250`
- `Floor: $1,100`
- `Purpose: Rate negotiation`
- `Status: Ready to call`

### 6.4 Layout rules

- small font
- compact chips
- dense one-line summaries
- no long descriptive paragraphs

---

## 7. Live Facts Panel Specification

### 7.1 Purpose
Show the important facts heard on the call so far.

### 7.2 Facts CORI should extract live

- Pickup city/state
- Delivery city/state
- Miles
- Weight
- Dimensions when relevant
- Equipment required
- Offered rate
- Pickup time
- Delivery time
- Commodity when relevant
- Special instructions
- Callback time if stated
- Customer or broker constraints if stated

### 7.3 Display style
Facts should appear as short rows or chips, such as:

- `PU: Raleigh NC`
- `DEL: Atlanta GA`
- `Miles: 380`
- `Weight: 44,000 lb`
- `Offer: $900`
- `PU: Today 4 PM`
- `DEL: Tomorrow 10 AM`

### 7.4 Rules

- one fact per line or chip
- no paragraphs
- update as the conversation develops
- replace uncertain values with confirmed values when CORI becomes confident

---

## 8. Hidden Reality Panel Specification

### 8.1 Purpose
Show what affects the decision but may not be obvious from the conversation alone.

### 8.2 Route intelligence examples

- Mountain route
- Steep grades
- Road closure risk
- Blizzard risk
- Storm risk
- Flood risk
- Traffic congestion risk
- Scheduled road work
- Toll-heavy route
- Urban delay risk

### 8.3 Truck and load fit intelligence examples

- Heavy load
- Truck fit strong
- Truck fit caution
- Truck fit poor
- Permit risk
- Dimension concern
- Equipment mismatch risk
- Engine power caution
- Mountain power caution

### 8.4 Business intelligence examples

- Offer below target
- Offer below floor
- Weak RPM
- Strong RPM
- Actual CPM pressure
- Delay risk
- Detention likely
- Layover likely
- Timing threatens next load
- Weak continuity fit

### 8.5 Accessorial prompt examples

- Ask detention
- Ask layover
- Ask TONU
- Ask extra stop
- Ask tarp pay
- Ask lumper
- Ask driver assist
- Ask permit coverage

### 8.6 Display style
Short chips or short stacked lines, such as:

- `Mountain route`
- `Blizzard risk`
- `Heavy load`
- `Permit risk`
- `Delay likely`
- `Ask detention`
- `Too cheap for route`

### 8.7 Rules

- show only high-value issues
- do not flood the dispatcher
- visible list should normally stay within 3 to 6 items
- prioritize the highest-impact route, fit, or money risks first

---

## 9. Advice Panel Specification

### 9.1 Purpose
Give the dispatcher the shortest useful next action and the next best line to say.

### 9.2 Must show

#### Rate logic
- Offered rate
- RPM
- target comparison
- floor comparison

#### Decision guidance
- Take
- Counter
- Pass
- Callback
- Ask a follow-up question

#### Speakable next line
The exact short line the dispatcher can say next.

### 9.3 Example output

- `Offer: $400`
- `RPM: $2.00`
- `Too low`
- `Counter: $700`
- `Floor: $700`
- `Say: We can do $700 minimum.`

### 9.4 More example output

- `Ask detention`
- `Say: Is detention paid after 2 hours?`
- `Callback: 2 PM`
- `Say: No problem, I’ll circle back at 2.`

### 9.5 Rules

- absolute minimum wording
- one decision line at a time
- one speakable next line at a time
- no long explanations
- no duplicated context already visible elsewhere on the page

---

## 10. Dialer Behavior Specification

### 10.1 Purpose
Let the dispatcher initiate and control the call with minimal friction.

### 10.2 Must include

- selected destination number
- keypad
- call button
- end call button
- call state
- elapsed time

### 10.3 Later controls
May be added later:
- mute
- hold
- speaker

### 10.4 Required call states

- Ready
- Dialing
- Ringing
- Connected
- Ended
- Failed
- No answer

### 10.5 Pre-call behavior

When a contact is selected:

- the dialer number populates
- the destination card populates
- the call does not auto-start
- the dispatcher must press Call

### 10.6 During-call behavior

During the call:

- CORI listens
- facts update
- hidden reality updates
- advice updates
- dispatcher may use quick actions or type a short question if needed

### 10.7 Post-call behavior

After the call ends:

- dispatcher selects an outcome
- next action is created if needed
- continuity state updates if relevant
- summary is saved
- audit event is written

---

## 11. Popup Layout Specification

### 11.1 Purpose
Allow CORI Live Call Copilot to be launched from any relevant page without leaving the current working surface.

### 11.2 Trigger sources

- Call Broker
- Call Driver
- Call Shipper

### 11.3 Popup structure

#### Top
- Contact
- Role
- Truck
- Load/lane
- Purpose
- Call status

#### Middle
Three compact live panels:
- Facts
- Hidden Reality
- Advice

#### Bottom
- Dialer
- Call / End
- Quick outcome buttons

### 11.4 Popup rules

- narrow and dense
- built for quick use
- should not feel like a full report page
- should keep the dispatcher in context with the current page

---

## 12. Launcher Behavior From Call Buttons

### 12.1 General rule
Every call launcher must pass context into CORI automatically.
The dispatcher should not have to re-explain the situation manually.

### 12.2 Call Broker launcher
Must pass:

- broker name
- broker phone
- truck
- current load or next-load context
- target lane
- target rate
- floor rate
- current continuity state
- reason for call

#### Default broker call purposes

- Negotiate rate
- Check availability
- Confirm details
- Callback
- Follow up on rate con

### 12.3 Call Driver launcher
Must pass:

- driver name
- driver phone
- truck
- active load
- status
- issue if present
- reason for call

#### Default driver call purposes

- Pickup confirmation
- Delivery update
- Delay check
- Problem resolution
- Next instructions

### 12.4 Call Shipper launcher
Must pass:

- shipper name
- shipper phone
- truck/load if relevant
- service context
- ETA or capacity context
- reason for call

#### Default shipper call purposes

- Capacity request
- Status update
- ETA update
- Issue escalation
- Coordination

---

## 13. Phone Book Search Specification

### 13.1 Purpose
Allow fast partial search for call destinations.

### 13.2 Initial searchable sources

- Brokers
- Drivers
- Shippers

### 13.3 Later searchable sources

- Carriers
- Receivers
- Saved custom contacts

### 13.4 Search matching rules
Must match on:

- first name
- last name
- company name
- phone number fragment

### 13.5 Dropdown behavior

- results appear immediately when typing
- results reduce with each additional letter
- mouse and keyboard selection supported
- selected result populates:
  - contact card
  - dialer number
  - contact role
  - known context if available

### 13.6 Example result lines

- `Acme Logistics — Sarah James — Broker — (919) 555-2011`
- `Malik Brown — Driver — Truck 214 — (404) 555-4428`

---

## 14. Call Purpose Selection

### 14.1 Purpose
Help CORI know what kind of call is being made.

### 14.2 Behavior

- prefill automatically when launched from a button
- allow manual selection when using the full-page phone book

### 14.3 Initial call purpose list

- Negotiate rate
- Check load details
- Confirm pickup
- Confirm delivery
- ETA update
- Problem resolution
- Callback
- General call

### 14.4 Why this matters
Call purpose sharpens:

- guidance
- rate logic
- route advice
- next-line suggestion
- available outcomes

---

## 15. Quick Outcome Actions

### 15.1 Purpose
Allow the dispatcher to close the call quickly without typing much.

### 15.2 Initial outcome list

- No answer
- Left voicemail
- Callback later
- Countered
- Booked
- Passed
- Driver confirmed
- Driver issue
- Shipper updated
- Needs review

### 15.3 Required behavior
Every outcome must be able to:

- save the call result
- update truck continuity when relevant
- create a follow-up when relevant
- update load state when relevant
- write an audit event

---

## 16. Real-Time Intelligence Inputs CORI Must Use

### 16.1 Live conversation inputs

- live transcript
- speaker turns
- extracted entities
- extracted rate offers
- extracted pickup and delivery locations
- extracted timing statements
- extracted callback commitments
- extracted objections

### 16.2 Truck profile inputs

- truck number
- equipment type
- make/model
- engine type
- weight capacity
- dimension limits
- accessorial profile
- break-even logic
- continuity state
- current load status

### 16.3 Driver inputs

- assigned driver
- current location when available
- HOS posture later
- known issue flags
- next availability context

### 16.4 Load inputs

- active load
- next load
- lane
- pickup time
- delivery time
- current broker or shipper
- posted rate
- target rate
- floor rate
- prior call outcomes

### 16.5 Route intelligence inputs

- route distance
- terrain classification
- mountain or steep-grade flags
- toll burden
- restricted route logic
- road closures
- construction or maintenance
- traffic disruption
- weather severity

### 16.6 Business intelligence inputs

- RPM logic
- Actual CPM logic
- accessorial opportunity rules
- detention likelihood
- layover likelihood
- continuity risk
- deadhead later
- truck suitability score later

### 16.7 Historical context inputs

- recent broker behavior
- prior rate history later
- prior lane pattern later
- prior callback history
- previous no-answer/pass/booked patterns later

---

## 17. CORI Output Model

CORI must always structure its output into these classes.

### 17.1 Facts
What was said.

### 17.2 Hidden Reality
What matters beyond what was said.

### 17.3 Advice
What to do next.

### 17.4 Speakable Next Line
What the dispatcher can say out loud next.

### 17.5 Outcome Recommendation
Take / Counter / Pass / Callback / Ask more

---

## 18. Guidance Writing Rules

### 18.1 Always

- short
- direct
- high signal
- numeric where possible
- one idea per line
- dispatch language only
- no internal system language

### 18.2 Preferred examples

- `Miles: 200`
- `Offer: $400`
- `RPM: $2.00`
- `Too low`
- `Counter: $700`
- `Ask detention`
- `Say: We can do $700 minimum.`

### 18.3 Avoid

- long paragraphs
- abstract reasoning
- technical workflow terms
- backend jargon
- repeated explanation text

---

## 19. Data and Audit Event Requirements

Every meaningful call event must be logged.

### 19.1 Must log

- popup opened
- full page opened
- destination selected
- call purpose selected
- call started
- call ended
- transcript captured where enabled
- facts extracted
- outcome selected
- callback set
- booked marked
- passed marked
- notes added
- follow-up created
- continuity updated

### 19.2 Required audit fields

- user
- org/workspace
- truck
- load if applicable
- destination contact
- timestamp
- source page
- outcome
- follow-up state

---

## 20. Relationship to Truck Continuity

CORI Live Call Copilot must not float separately from truck operations.

It must connect directly to:

- My Trucks
- Truck Overview
- Next Load continuity
- truck follow-up surfaces
- later Messages and Documents when relevant

CORI call outcomes must feed:

- next-load protection
- callback queue
- booked/pass logic
- truck continuity status

---

## 21. Non-Goals for Dispatcher UI

The dispatcher-facing CORI page must not surface:

- technical telephony internals
- token or session diagnostics
- continuity bridge jargon
- persistence language
- heavy audit troubleshooting
- large reporting blocks
- low-value system metadata

Those belong in:

- backend systems
- Super Admin
- troubleshooting-only surfaces

---

## 22. Build Sequence Recommendation

### v279
CORI Live Call Copilot foundation

- full-page layout
- popup layout shell
- phone book search
- context strip
- facts / hidden reality / advice panels
- dialer below

### v280
Launcher integration

- Call Broker
- Call Driver
- Call Shipper
- truck/load context injection

### v281
Live guidance progression

- outcome buttons
- short-form live advice behavior
- broker negotiation mode
- callback/booked/pass handling

### v282
Real-time intelligence expansion

- route/weather/risk/accessorial inputs
- stronger hidden reality panel
- speakable next-line refinement

---

## 23. Governing Rule

Any build affecting CORI’s Quotes, call popup behavior, dialer logic, phone-book search, or live call guidance must preserve this core definition:

**CORI Live Call Copilot is a truck-aware, voice-aware, real-time dispatch calling workspace that listens to the call, extracts the facts, adds hidden route and business reality, and shows the dispatcher the shortest possible next response.**


---

## 24. Live listening event flow model

This section defines the future transport shape for real live listening.

### 24.1 Event flow goals
The event flow must:
- stay staged and reversible
- keep the operator informed in plain language
- separate temporary listening facts from durable saved records
- allow popup and full-page CORI surfaces to consume the same live truth

### 24.2 Planned call event sequence
1. Dispatcher opens CORI call surface.
2. Workspace policy is checked.
3. Consent / notice posture is checked.
4. Browser dialer session starts.
5. Live listening remains blocked until the call reaches the allowed start point.
6. Provider or internal stream emits transcript fragments.
7. Fragment parser produces partial facts.
8. Partial facts are scored and either:
   - shown as tentative
   - upgraded to stable
   - dropped as noise
9. Hidden reality and advice recompute from the best current fact state.
10. Operator can still add quick notes or choose an outcome.
11. On call end, temporary state is either:
   - discarded
   - promoted into durable notes
   - attached to follow-up workflow

### 24.3 Transport layers
The architecture should treat transport in layers:
- call session state layer
- transcript fragment intake layer
- fact extraction layer
- UI state layer
- durable write layer

This prevents a future provider integration from becoming the source of truth for the whole page.

## 25. Partial fact extraction lifecycle

### 25.1 Why a lifecycle is needed
Live transcript fragments are noisy.
The first heard value may be wrong, incomplete, or later corrected.

So CORI must not treat every heard fragment as final truth.

### 25.2 Fact states
Each extracted fact should move through states:
- empty
- heard
- tentative
- stable
- replaced
- confirmed
- discarded

### 25.3 Example
- first fragment hears `Charlotte`
- second fragment hears `Charlotte NC`
- third fragment hears `delivery tomorrow 8am`

The UI should show the better newer value without confusing the dispatcher with every raw transcript fragment.

### 25.4 Promotion rules
A fact can be promoted when one or more of these are true:
- repeated consistently
- appears with stronger phrase confidence
- matches existing lane or truck context
- confirmed by operator action

### 25.5 Replacement rules
If a newer value is stronger, the older value should not remain equally visible.
The older value becomes replaced rather than silently merged.

### 25.6 Durable write rule
Only stable or operator-confirmed facts should be eligible for durable save into workflow records.

## 26. UI consumption model

### 26.1 One live truth
Popup and full-page CORI must read from the same live listening state contract.

### 26.2 UI layers
The call surface should consume live listening data in four simple groups:
- call posture
- best current facts
- advice impact
- outcome / follow-up impact

### 26.3 Operator wording
The operator should see simple labels such as:
- listening off
- listening waiting
- hearing partial facts
- facts updated
- ready to save

### 26.4 Avoid transcript wall behavior
Do not turn the dispatcher UI into a scrolling transcript wall by default.
The main surface should remain facts-first.
A raw transcript review surface can exist later if truly needed.

## 27. Privacy, consent, and failure handling

### 27.1 Before listening can start
The call surface must know:
- workspace transcript policy
- consent requirement
- whether notice is needed
- whether listening is allowed for this session

### 27.2 Failure states that must be user-visible
The operator should get short visible states for:
- listening blocked by policy
- notice needed
- provider not ready
- transcript delayed
- transcript stopped
- partial facts cleared

### 27.3 Failure behavior rule
When transcript transport fails, the call page must keep working.
The dispatcher should still be able to:
- continue the call
- type quick notes
- use advice based on typed notes and known truck/load context
- close the call cleanly
