# Development Protocol Historical Notes Archive v396

Version introduced: v396
Status: Preserved historical protocol archive
Source archived from: `Project Documentation/Active/DEVELOPMENT_PROTOCOL.md` before the v396 compactness pass

## Purpose

This file preserves the older accumulated development protocol notes that were previously embedded below the active protocol section. They remain useful historical context, but they are no longer the active build-cycle procedure.

Current procedure is controlled by:

1. `Project Documentation/Active/DISPATCH_SPOT_BUILD_RULES.md`
2. `Project Documentation/00_CURRENT_OPERATING_MANUAL.md`
3. `Project Documentation/06_CONSOLIDATED_ACTIVE_PRODUCT_ARCHITECTURE_MANUAL_V394.md`
4. `Project Documentation/Active/DISPATCH_SPOT_DOCUMENTATION_SOURCE_OF_TRUTH.md`

Do not use the archived notes below to override current placement, settings, language, packaging, or Rule Check requirements.

---

# v395 Active Development Protocol

This top section is the active protocol. Older sections below are retained for history and must not override the current controlled documentation path.

Before each build, read in this order:

1. Current user prompt and stated server baseline.
2. `Project Documentation/Active/DISPATCH_SPOT_BUILD_RULES.md`.
3. `Project Documentation/00_CURRENT_OPERATING_MANUAL.md`.
4. `Project Documentation/06_CONSOLIDATED_ACTIVE_PRODUCT_ARCHITECTURE_MANUAL_V394.md`.
5. `Project Documentation/Active/DISPATCH_SPOT_DOCUMENTATION_SOURCE_OF_TRUTH.md`.
6. `Project Documentation/Active/DISPATCH_SPOT_SUPERSEDED_GUIDANCE_REGISTER.md`.
7. `Project Documentation/01_PREVIOUS_CHAT_REQUIREMENTS_REGISTER.md`.
8. `Project Documentation/Active/PROJECT_HANDOFF.md` latest entry.

## Current documentation placement rule

Durable documentation now belongs inside `Project Documentation/`. The app root should not collect new documentation files. The root `README.md` is only a pointer to the controlled documentation folder.

Historical documentation is preserved inside the controlled folders, especially `Build History/`, `Superseded/`, `Duplicates or Retired Scaffolds/`, and `HTML Mirrors/`. Historical documents do not override active build rules.

## WHM command rule

WHM commands must visibly show unzip output. Do not use `unzip -q`.

When deploying v395 over an older package, run:

```bash
node scripts/dispatchspot-doc-relocation-cleanup-v395.mjs
```

This removes old root documentation copies only after the relocated copies exist in `Project Documentation/`.

## Current baseline

Current baseline after controlled documentation relocation: v395.

---

## v370 Surface Cleanup Protocol
- Before every product-surface build, review `DISPATCH_SPOT_BUILD_RULES.md` and `DISPATCH_SPOT_SURFACE_CLEANUP_AUDIT_V370.md`.
- Do not expand a page unless it helps the user complete one clear job.
- Setup, credentials, provider tests, internal readiness, and debugging content must stay out of daily user surfaces.
- If a page is confusing, duplicated, not ready, or not useful to the user, hide it, merge it, rebuild it, or move it to Workspace Settings/Super Admin.
- Current notification decision: as of v382, `/notifications` is rebuilt as a simple app-style alert feed opened from the top-bar bell.

# v369 BUILD GOVERNANCE UPDATE

Before every future build cycle, review `DISPATCH_SPOT_BUILD_RULES.md`.

Future builds must enforce these placement rules:

- Normal user surfaces must stay clean, simple, and action-focused.
- Setup, credentials, provider tests, OAuth, SMTP, IMAP, API keys, Twilio, Stripe, QuickBooks, Google Maps, and other third-party integration configuration belong in `/company/integrations` or Super Admin when platform-scoped.
- CORI pages are AI work surfaces. They may show briefings, explanations, suggested actions, editable drafts, approval controls, and next steps. They must not become settings or technical readiness pages.
- If a requested change conflicts with `DISPATCH_SPOT_BUILD_RULES.md`, pause and explain the conflict before building.
- Every completed build response must include a Rule Check section.

Current baseline: v369
Next package: v370

# DEVELOPMENT_PROTOCOL

## Architecture governance update
- As of v271, `PLATFORM_ARCHITECTURE_INDEX.md` is the root architecture index.
- `BUILD_ARCHITECTURE_REVISED_V2.md` is the controlling platform architecture document.
- `PRIVACY_TERMS_CONSENT_DATA_LIFECYCLE_ARCHITECTURE.md` is the controlling privacy/terms/consent/data-lifecycle document.
- New builds must explicitly state whether they change product behavior or documentation only.
- New pages and workflows must identify workspace, role visibility, shared objects touched, and audit/privacy/security implications before expansion.

Current baseline: v77
Next package: v78

- MVP priority mode is active.
- Prefer packages that bundle 3 to 5 tightly related items in the same operational workflow.
- Prefer dispatch execution, onboarding, document/compliance, billing, permissions, and stabilization before expanding non-MVP governance surfaces.
- Do not mix unrelated domains in one package just to increase scope.

Current baseline: v71
Next package: v72

Current baseline: v60
Next planned package: v61

Current baseline: v58
Next package: v59
- Sender preview tooling must continue to use platform-managed SMTP transport and must not expose raw workspace SMTP credentials.

Current baseline: v57
Next package: v58
- v58 keeps raw SMTP ownership at the platform layer while allowing governed workspace-facing reply-to and sender-branding surfaces.

Current baseline: v56
Next package: v57

Current baseline: v54
Next package: v55

Current baseline: v51
Next package: v52

Current deployed baseline: v50.1
Next planned package: v51

Current deployed baseline: v49
Next planned package: v50

Current baseline: v48
Next planned package: v49

Current baseline: v45.1
Next planned package: v46
- v47 prepares SMTP readiness surfaces and persists user notification preferences with Prisma-backed storage.

- v45 adds assignment notification hook visibility and overdue escalation lanes without Prisma schema changes.
# Development Protocol

CURRENT CANONICAL BASELINE
Version: v42
Status: CRM assignment reminders and assignee queue visibility
Next planned package: v43

## Required Workflow
- Assignment reminder visibility should be driven from assignment due dates and status without introducing unnecessary schema changes.
- Assignment queues must respect org role boundaries: org admins can review workspace-wide queue visibility while non-admin users are limited to their own open work.
- CRM timeline edits must record editedAt, editedBy, and optional editReason when a governed update occurs.
- CRM timeline deletions must be soft deletes with deletedAt, deletedBy, and optional deletionReason capture; do not hard-delete operational history through normal UI flows.
- When schema changes are included, return Prisma generate and db push commands in the same terminal block.
- Assignment ownership changes for CRM and load records must flow through the assignment service and remain audit-friendly.
- Start from the latest uploaded canonical source zip and treat it as the only source of truth for the chat.
- Anchor every implementation response to the user-stated current baseline and the next sequential package.
- Return a single canonical zip named with the synchronized pattern dispatchspot-canonical-source-vX.zip.
- Keep files at zip root so unzip -o overwrites the live application cleanly.
- Provide one exact deploy block and one exact next-step copy/paste block.

## Packaging Rules
- Preserve project integrity and the existing root structure.
- Exclude generated artifacts such as .next, node_modules, tsconfig.tsbuildinfo, logs, duplicate extracted trees, and nested work folders.
- If artifact delivery fails, rebuild the archive with a fresh file handle instead of reissuing the same broken artifact reference.

## Build Validation Rules
- Run local validation where possible before packaging.
- Only include Prisma generate / db push commands when schema changes actually require them.
- If a baseline type issue remains pre-existing, note that explicitly without misattributing it to the new package.

## Commenting Standard
Use professional comments that explain purpose, structure, and non-obvious business rules. Avoid noisy comments that restate simple syntax.


## Architecture Governance Rules
- Never send production email directly from page handlers or ad hoc route code; use a shared notification service.
- Hash security-sensitive tokens at rest, including email verification, password reset, and MFA challenge tokens.
- Centralize feature and capacity gating through an entitlement service instead of scattered plan checks.
- Treat Super Admin capabilities as platform-scoped controls with full audit logging and tenant isolation safeguards.
- Prefer controlled dictionary management for platform schema items such as CRM stages, accessorials, and expense categories instead of hard-coded one-off edits.


- v49: Added auth token consumption flows for email verification and password reset, including token validation, single-use handling, expiry enforcement, and password reset completion.

- Email 2FA trust must remain platform-governed and signed by the app session secret.
- Trusted-session grace must not require schema changes when existing auth token audit data is sufficient.
- Challenge audit visibility should prefer existing auth token lifecycle data before adding new persistence.
- v62 protocol note: custom-domain requests are governed records. Workspace Admin may submit intake requests; Super Admin controls review-state transitions.


- v71: Added Super Admin verified custom-domain reviewer assignment visibility and governed next-step action prompts.

## CORI Live Call Copilot governing document
- CORI_LIVE_CALL_COPILOT_ARCHITECTURE.md


## v371 Page Cleanup Enforcement

The Page Usefulness Rule is now active in cleanup work. Before keeping a page in normal navigation, confirm the page helps the user complete one clear job. Pages that are confusing, duplicated, premature, or mostly internal should be hidden, merged, redirected, or moved to settings/admin.

As of v371, Load Board, Intelligence, Reports, report subpages, and Workspace Administration are retired from normal sidebar navigation and redirect to simpler destinations. Do not restore these as normal pages unless a later check-in approves a rebuilt version with one clear user job.

## v372 Cleanup enforcement

Before adding or restoring any setup feature, confirm whether it belongs on `/company` or `/company/integrations`.

- Company profile and team access belong on `/company`.
- Provider credentials, OAuth, API keys, webhook URLs, Twilio setup, SMTP setup, QuickBooks setup, Stripe Connect setup, and Google Maps setup belong on `/company/integrations`.
- Duplicate sidebar entries should be removed unless they represent a separate, clear user job.

## v373 Build Process Note

Before future cleanup or feature builds, review `DISPATCH_SPOT_BUILD_RULES.md` and confirm each page has one clear job. When a page shares data with another page, do not merge or duplicate it automatically. Decide based on user job:

- live execution belongs on Dispatch Board;
- record correction belongs on Loads;
- invoice and unpaid-load work belongs on Billing Records;
- AI money explanation belongs on CORI Financial;
- missing proof and files belong on Paperwork;
- partner relationships belong in CRM;
- drivers and owner operators belong under People & Assets.

## v374 List Surface Cleanup Enforcement

Before expanding any list page, confirm the page has one clear job and does not reintroduce duplicate navigation, retired report links, internal readiness panels, or technical continuity language.

Current placement rules:

- Loads is for load records and direct record work.
- Dispatch Board is for live execution.
- Routes is for load + truck + driver route planning with CORI help.
- Trucks, Drivers, and Owner Operators belong under People & Assets.
- Companies, Brokers, and Shippers belong under CRM & Partners.

If a feature does not support the page's one clear job, move it to CORI, Workspace Settings, Super Admin, or a later rebuilt surface.

## v375 Detail Page Cleanup Enforcement

Before changing any detail page, check `DISPATCH_SPOT_BUILD_RULES.md`, especially the Detail Page Cleanup Rule.

Detail pages must show the record, key people/assets, key money/route/status facts, and the next useful action first. Deeper support tools such as setup checks, assignment ownership, follow-up controls, and activity history should be collapsed unless they are essential to the user's immediate task.

Do not use CRM/internal lifecycle wording on normal user surfaces when simpler words are available.
## v375.1 - Detail Page Import Build Fix

- Fixed missing cleanup component aliases used by v375 detail pages.
- Added the missing paperwork-check component bridge.
- Preserved the v375 detail-page cleanup and simple wording direction.
- No Prisma schema changes.


## v376 Form and Subpage Cleanup Enforcement

Before changing forms, invoice views, truck subpages, Profile & Security, Workspace Settings, or Third-Party Integrations, review `DISPATCH_SPOT_BUILD_RULES.md`, especially the Form, Invoice, and Subpage Cleanup Rule.

Forms should save records. Invoice pages should show invoices first. Optional checks should be collapsed. Setup remains in Workspace Settings or Third-Party Integrations. Retired pages such as Load Board, Intelligence, and Reports should not be linked from normal user workflows unless they are rebuilt and approved later. Notifications were rebuilt in v382 as a simple top-bar alert feed.


## v377 High-Use Surface Cleanup Enforcement

Before changing CORI Briefing, Dispatch Board, Paperwork, Billing Records, or any CORI page, review `DISPATCH_SPOT_BUILD_RULES.md`, especially the High-Use Work Surface Cleanup Rule.

Do not place roadmap notes, provider internals, readiness language, technical configuration, or development-review explanations on normal user work pages. If the content explains the system instead of helping the user finish the current job, move it to root documentation, Workspace Settings, Super Admin, or remove it from the normal surface.

## v378 Hidden Section Language Enforcement

Before future cleanup or feature builds, remember that collapsed sections still count as user-facing surfaces. Do not leave internal build wording inside a collapsed panel simply because it is not visible on first page load.

For normal users, replace internal wording with plain work language:

- continuity -> next step, next-load status, or follow-up
- handoff -> next step or go back
- foundation/fallback -> manual check or setup needed
- dataset -> records or choices
- runtime/provider transport/activation -> hide from normal surfaces or move to Super Admin/settings

CORI's Quotes and Routes should stay assistant-like and action-focused.

## v379 Protocol Reminder — Admin Placement and Plain Work Language

Before each build, review `DISPATCH_SPOT_BUILD_RULES.md`, including the v379 Admin Placement and Truck Command Cleanup Rule.

Daily pages must not direct users into Super Admin language or expose internal terms. Admin setup belongs in Workspace Settings or Third-Party Integrations. Platform support and deep review belong in Super Admin. Truck, route, CRM, and CORI pages must remain plain work surfaces.

## v380 Protocol Addition — Final Language Sweep

Every build must now include a final pass against `DISPATCH_SPOT_BUILD_RULES.md`, especially the Final User-Facing Language Sweep Rule.

Check both first-visible content and collapsed/helper sections. A hidden panel is still part of the user experience and must not read like engineering, roadmap, readiness, or internal support language.

## v381 Handoff Note — Cleanup Closeout and Build Preflight Guard

v381 closes the broad cleanup cycle unless live UI review identifies a specific remaining confusing page. Future changes should resume feature development with `DISPATCH_SPOT_BUILD_RULES.md` enforced before every build.

A new preflight command is now available and should run before TypeScript and Next build:

```bash
npm run dispatchspot:preflight
```

This command checks local source imports for missing files and prints non-blocking language warnings for selected internal terms on normal user-facing surfaces. It is designed to catch cleanup bridge mistakes earlier, especially after renaming helper components or moving content between user surfaces and settings/admin pages.

No Prisma schema changes were added in v381.

## v382 protocol note

Before expanding notifications, check `DISPATCH_SPOT_BUILD_RULES.md`.

Notifications must stay simple for normal users. Do not reintroduce provider setup, delivery diagnostics, sender governance, API keys, webhooks, or technical readiness panels on `/notifications` or in the top-bar bell.

## v383 Protocol Note - Notification Preferences

Before modifying notifications, check `DISPATCH_SPOT_BUILD_RULES.md`, especially the Notification Preference Rule.

Historical note superseded by v390: notifications must remain app-style and easy to understand, but user preferences must not live on `/notifications`. Preferences belong in Workspace Settings > Notifications. Provider setup, SMTP, Twilio, push provider setup, API keys, delivery logs, and debug details must remain out of the user notification page.

## v384 protocol note

Historical note superseded by v390: provider setup stays in Workspace Settings > Third-Party Integrations. Delivery readiness and user choices belong in Workspace Settings > Notifications, not on `/notifications`. The normal Notifications page must not expose SMTP credentials, Twilio tokens, API keys, webhooks, delivery debug panels, preference controls, or delivery-readiness controls.

## v385 protocol note

Historical note superseded by v390: urgent text alerts require explicit user opt-in, and a phone number alone is not consent. Phone number fields, opt-in language, and turn-off controls belong in Workspace Settings > Notifications. Twilio setup and provider details belong in Workspace Settings > Third-Party Integrations.

## v386 protocol note

Urgent text alerts now have a guarded preview path only. Real SMS sending must remain locked until a future build adds final approval, audit records, delivery error handling, and safe Twilio send execution.

Historical note superseded by v390: before changing text alerts, check `DISPATCH_SPOT_BUILD_RULES.md`, especially the Guarded Urgent Text Delivery Prep Rule and the Notification Settings Relocation rule. The normal Notifications page must not show text status, delivery previews, opt-in controls, or provider details. Those belong in Workspace Settings > Notifications or Third-Party Integrations as appropriate.

## v387 Protocol Note — Guarded SMS Send

When adding user-triggered outbound delivery, the normal user page may show only the result, preview, and clear approval step. Provider credentials and setup remain in Workspace Settings or Super Admin.

For urgent text alerts, every send must require:

1. user phone number,
2. explicit opt-in,
3. Twilio setup through Workspace Integrations,
4. message preview,
5. user approval,
6. audit record.

Do not add SMS provider diagnostics, auth tokens, API keys, webhook setup, or raw delivery logs to `/notifications`.

