CURRENT CANONICAL BASELINE
Version: v41
Status: CRM timeline edit and deletion governance refinement
Next planned package: v42

# Field Operations Access Plan

## Current phase note
- v42 timeline governance gives office operators controlled edit and delete actions with visible accountability, without exposing uncontrolled history mutation to field users.

# Field Operations Access Plan

## Purpose
This document defines how Dispatch Spot should support road-side users without diluting the dispatcher and fleet-admin experience. It formalizes the field-access architecture so owner operators, company drivers, and future co-drivers can access the right operational information while preserving company control over finance, documents, and workflow actions.

## Why This Matters
Dispatch Spot already models loads, drivers, trucks, documents, and truck-scoped KPIs. That gives us a strong foundation, but office workflows and field workflows are not the same. The application now needs an explicit field-access layer so the people on the road can:
- see assigned loads
- retrieve load documents such as BOL and POD
- review truck-scoped performance metrics
- receive dispatch instructions
- perform limited status actions later

## Design Principle
The field experience should be a **restricted operational portal**, not a copy of the dispatcher dashboard.

## User Groups and Product Surfaces

### 1. Dispatcher
Primary responsibilities:
- assign loads
- manage load workflow
- detect conflicts
- coordinate exceptions
- manage operational documents
- watch urgency and profitability

Core product surface:
- Dispatch Board
- load command center
- dashboard alerts
- full company and truck KPI visibility

### 2. Workspace Admin / Fleet Owner
Primary responsibilities:
- oversee truck and company financial performance
- manage users, permissions, and access
- oversee documents and workflow health

Core product surface:
- dashboard with company and truck scope
- truck administration
- users and roles
- company settings
- financial and operational reporting

### 3. Owner Operator
Primary responsibilities:
- manage and monitor the business performance of the truck
- access assigned loads and dispatch documents
- review settlement-style performance metrics
- upload or access supporting trip documents later

Core product surface:
- field portal home
- assigned loads feed
- truck performance dashboard
- document access panel
- limited operational updates

### 4. Company Driver
Primary responsibilities:
- follow current and upcoming assignments
- access dispatch documents and instructions
- submit limited status updates later
- stay focused on the next required operational step

Core product surface:
- trip-oriented field portal
- current load and next load cards
- document viewer
- instructions / notes section
- limited workflow buttons

### 5. Back Office / Accounting
Primary responsibilities:
- invoice follow-up
- payment tracking
- revenue and cost closure
- load-level financial reconciliation

Core product surface:
- financial queues
- invoice and payment visibility
- load financial detail
- dashboard reporting

### 6. Future External Participants
Not for immediate build, but the architecture should preserve a path for:
- broker-facing shipment visibility
- shipper document exchange
- customer tracking portals

## Required Capability Matrix

### Field users must be able to access
- current assigned load
- upcoming assigned loads
- pickup and delivery details
- appointments and instructions
- field-visible documents
- truck-scoped KPI dashboard
- later: limited status updates and document upload

### Field users must not automatically inherit
- company-wide dashboard visibility
- unrelated truck performance
- company-wide financial metrics
- internal-only documents
- unrestricted workflow controls

## Access Model Recommendation

### Office roles
- Super Admin
- Workspace Admin
- Dispatcher
- Accounting / Operations

### Field roles
- Owner Operator
- Company Driver
- Future: Co-Driver / Team Driver

Field roles should be permission-scoped to their assigned truck(s), driver record, and field-visible documents.

## Schema Groundwork Required
These items do **not** all need immediate schema implementation, but they must now be preserved as first-class design requirements.

### User <-> Driver linkage
Add or formalize the ability for a login user to be linked to a driver profile.

Recommended direction:
- `User.linkedDriverId` (nullable)
- relation from `User` to `Driver`

This is the cleanest way to let a driver/owner-operator log in and only see the truck and loads they are allowed to see.

### Driver <-> Truck access context
We already have driver and truck relationships through load assignment. We should also preserve the idea of a primary or default truck context for field visibility and dashboard scope.

Recommended planning direction:
- allow a field user to derive visible trucks from:
  - current assigned loads
  - linked driver record
  - optional primary/default truck relation later

### Document visibility scope
Documents must not all be treated the same.

Recommended planning direction:
- add document visibility classification such as:
  - `INTERNAL_ONLY`
  - `FIELD_VISIBLE`
  - `ACCOUNTING_ONLY`
  - `CUSTOMER_VISIBLE` (future)

This matters for BOL, POD, rate confirmations, receipts, and internal notes.

### Load field instructions
Loads should support the concept of field-facing instructions separate from internal dispatch-only notes.

Recommended planning direction:
- preserve or add a field-visible instructions channel
- keep dispatcher-only notes separate

### Truck KPI access scoping
Truck-level metrics already exist. We must preserve the rule that field users can only see KPI data for the truck(s) they are authorized to access.

## Required Future Portal Surfaces

### Field Portal Home
Should eventually show:
- current load card
- next load card
- truck snapshot metrics
- urgent documents / missing docs
- dispatch notes

### Assigned Loads Screen
Should eventually show:
- active assigned load
- upcoming assigned loads
- pickup and delivery details
- instructions
- core contacts when appropriate

### Documents Screen
Should eventually show field-visible documents only, including:
- BOL
- POD
- lumper receipt later
- fuel / scale / receipts later
- field-safe versions of any rate or instruction documents

### Truck Metrics Screen
Should eventually show the truck scorecard only for the linked truck or selected authorized truck.

Metrics should align with the main dashboard contract where appropriate:
- loads booked
- outstanding
- paid in full
- gross profit
- actual cost
- average RPM
- actual CPM
- total miles
- dispatch fee
- cost (ops)
- projected RPM and projected CPM when applicable

### Limited Workflow Actions
Later, field users should be able to perform only carefully scoped actions, such as:
- arrived at pickup
- loaded
- delivered
- upload document
- mark paperwork submitted

These should remain narrower than dispatcher controls.

## Mobile Strategy Alignment
This field-access plan is critical for the future native mobile app roadmap. The future Android and iOS apps should not try to reproduce every dispatcher/admin surface. Instead:
- office users can continue using the full web app
- field users can later get focused mobile experiences built on the same API and permission model

That means this plan directly supports:
- driver app
- owner-operator portal app
- push notifications for assignment and urgency
- mobile document viewing and upload

## Recommended Sequential Implementation Order
1. Formalize the field-access architecture in project docs.
2. Add schema groundwork notes for user-driver linkage and document visibility.
3. Add permission model planning for field roles.
4. Add field-facing document visibility planning.
5. Build field portal backend contracts.
6. Build field web portal or native mobile surfaces later.

## Immediate Conclusion
Dispatch Spot is still on the correct path, but this requirement needed to be made explicit now so we do not accidentally optimize only for office users. The application already has the right core entities; what was missing was a formal field-operations access model.


## v22 schema alignment update
The schema groundwork for this plan has now been added at the data-model level. The live UI does not yet enforce field-visible document access, but the canonical schema direction now includes:
- `User.linkedDriverId` for field login linkage
- document category and visibility scope enums
- optional document linkage to loads, trucks, and drivers
- field-specific document labels and required flags
- `Load.fieldInstructionsText` and `Load.internalNotesText` to separate field-facing instructions from office-only notes

## v23 Backend Groundwork
- Field document visibility is now enforced in service/API design.
- Future owner operator and company driver portals can consume `/api/documents` safely once UI surfaces are built.
