Skip to content

Half-Shell Audit: private demo tenant regressions and product-fidelity gaps #75

Open

Description

@diese-tech

Why this audit exists

PR #72 introduced a second, private sandbox tenant for trusted prospects. Since then, live validation has already exposed multiple regressions that unit-level review did not catch, including broken quote actions and stale technician availability. PR #74 addresses some of those findings, but the demo tenant now touches enough of the product that it needs an end-to-end audit rather than another isolated patch review.

This issue is the umbrella Half-Shell Demo Tenant Audit. The goal is to verify that the private demo exercises the real SwiftDispatch product faithfully without creating demo-only mutation semantics, leaking synthetic load data into real tenants, or presenting UI that looks functional but is not.

Known related work:

Audit principle

The demo should be real product behavior on disposable data, not a visually similar fork of the product.

Where possible, demo UI should call the same handlers and enforce the same business rules as the real dispatcher/admin/technician experience. Demo-specific code should be limited to tenant detection, safe reset/provisioning, framing/tutorial UX, and suppression of external side effects where necessary.


Half-Shell council findings

April O'Neil — contract / route map

The private preview currently spans:

  • sandbox detection: src/lib/demo.ts
  • provisioning: scripts/seed-demo-tenant.mjs
  • destructive reset: src/lib/resetDemoTenant.ts, /api/demo/reset, /api/internal/reset-demo
  • persistent demo framing: DemoBanner, DemoTabNav, DemoTutorial, ResetDemoButton
  • dispatcher board + realtime refetch
  • technician preview: TechPhoneModal
  • job mutations: /api/jobs, /api/jobs/[id]
  • quote create/edit/preview/send/accept/decline
  • admin/analytics presentation

The legacy docs/demo-experience-design.md is now materially stale. It describes a shared /demo/tech experience and old auth assumptions that no longer match the implementation.

Donatello — architecture / contract consistency

P1 — demo tech preview has become a second mutation implementation

TechPhoneModal duplicates the real technician UI instead of reusing the production technician workflow.

Current divergence:

  • real technician Build Quote links to /tech/job/[jobId]
  • demo phone Build Quote directly PATCHes job status to quote_pending
  • real technician completion requires an accepted quote
  • demo phone completion only checks the generic state-machine transition
  • real technician callers are restricted to en_route, in_progress, and completed
  • demo phone borrows the dispatcher/admin session, so it inherits broader mutation authority

This allows the demo to create states the real technician product cannot, including quote_pending with no quote.

Required direction: remove demo-only business rules. Prefer extracting/reusing the actual technician job/action surface, or create a narrowly-scoped demo impersonation adapter that invokes the same technician rules server-side.

P2 — demo detection has two meanings and call sites must choose deliberately

isDemoCompany() is intentionally loose (demo_mode_enabled OR public demo slug).
isSandboxDemoCompany() is the destructive/synthetic allowlist.

Any code deciding whether is_demo=true rows are normal operational data must use the sandbox distinction, not globally remove filters or assume all is_demo rows belong to sandbox companies.

PR #74 currently has a blocker here: load-test scripts intentionally seed is_demo=true jobs into configurable non-sandbox companies to keep synthetic traffic out of operational views.

Raphael — correctness / security / mutation edges

P1 — quote workflow remains broken end-to-end for sandbox rows

PR #74 removes the demo-row filter from quote creation, line-item mutation, and preview, but POST /api/send-sms still requires:

.eq("is_demo", false)

QuoteBuilder calls this route from its primary Send quote to customer CTA.

Result after the current #74 direction:

  1. sandbox user can create quote
  2. add/edit/delete line items
  3. preview quote
  4. click Send quote to customer
  5. route returns 404 Quote not found

The quote workflow needs an explicit sandbox policy through the complete chain, not piecemeal removal of filters.

P2 — status-only completion leaves technician runtime state stale

PATCH /api/jobs/[id] updates technician availability/current job for assignment, reassignment, and unassignment, but a status-only transition to completed does not release the technician.

The dispatcher demo code already compensates for this with a comment noting that current_job_id may remain stale. Quote acceptance does clear the technician correctly, which makes the behavior inconsistent by completion path.

This is pre-existing production behavior that the demo exposed, not a demo-only bug.

Expected invariant: once a job reaches a terminal status, the assigned technician must not remain on_job with that job as current_job_id unless another active assignment establishes that state.

P2 — preserve synthetic-load isolation for real tenants

Do not globally remove is_demo=false from operational reads. load-tech-actions.mjs and related harnesses deliberately seed is_demo=true rows into configurable companies.

Required behavior:

  • purpose-built sandbox tenant: synthetic/demo rows are the product data and must be visible
  • ordinary tenant: synthetic load rows remain hidden from operational boards and metrics

Michelangelo — UX / product fidelity

P1 — Tech view looks real but behaves differently from the real tech portal

This is more damaging than a cosmetic mismatch because the prospect is being shown a false interaction model.

Additional fidelity gaps:

  • the phone mock renders Sign out as inert text
  • address is not a Maps link like the real tech UI
  • phone number is styled as actionable but is not a tel: link
  • tech preview is only available as a floating control on Dispatch rather than as a consistent demo persona surface

If the point is to demonstrate the field-tech product, interaction fidelity matters more than recreating phone chrome.

P2 — Admin settings CTA is visible to a preview dispatcher who cannot use it

seed-demo-tenant.mjs provisions the demo user as dispatcher.
DemoBanner always renders an Admin settings link.
proxy.ts correctly rejects non-admin users and redirects them back to Dispatch.

So the preview exposes a CTA that visibly goes nowhere.

Choose one product contract:

  • private prospect login is admin so it can demonstrate Dispatch + Analytics + Admin in one session, or
  • keep it dispatcher and hide/admin-gate the admin CTA

The current mixed model is broken UX.

P2 — reset button fails silently

ResetDemoButton shows loading and refreshes on success, but surfaces no error on non-2xx/network failure.
For a prospect, a failed destructive reset simply looks like the button did nothing.

Add explicit success/error feedback. Confirmation is optional because the tenant is intentionally disposable.

Casey Jones — ugly operational paths

P2 — "Reset data" is not a full tenant reset

resetDemoTenant() resets job-centric state:

  • jobs
  • quotes / line items
  • status events
  • SMS outbox
  • technician availability/current job

It does not restore arbitrary company settings, users, technician identity/config, templates, or other mutable admin state.

The UI/tutorial wording says things like "wipe it back to sample data," which implies a broader reset than the implementation guarantees.

This becomes especially important if the private prospect user is upgraded to admin.

Either:

  • define/reset the complete mutable demo baseline, or
  • explicitly constrain which surfaces are meant to be mutated and rename/copy the reset action to match that narrower contract

P2 — sandbox external-side-effect policy is implicit

The demo is intentionally interactive, but customer-facing actions can eventually reach SMS/payment/invoice paths. Synthetic phone numbers and manual payments reduce risk today, but the policy is accidental rather than encoded.

Audit each externally visible action and decide whether sandbox behavior should:

  • execute against a safe test provider
  • enqueue but suppress delivery
  • simulate success
  • be unavailable with an explicit demo explanation

Do not let individual routes decide this accidentally via stale is_demo filters.

Splinter — discipline / scope

Do not solve this by adding if (demo) branches throughout the app.

Preferred shape:

  1. one canonical sandbox predicate/config
  2. production handlers stay authoritative
  3. demo UX reuses production components/business rules
  4. external side-effect policy is centralized
  5. demo-only code handles framing, tutorial, reset, and provisioning
  6. regression coverage exercises complete prospect workflows, not just individual route functions

Issue #73 already tracks the duplicated sandbox allowlist and should remain separate but linked.

Shredder — adversarial challenge

For every demo-capable workflow, try both directions:

  • What happens if an is_demo=true row exists in a normal company?
  • What happens if every row in a sandbox company is is_demo=true?
  • Can a dispatcher-session demo control perform an action a real technician cannot?
  • Can a sandbox action send SMS, create payment artifacts, or mutate an external provider unexpectedly?
  • Does realtime refetch return the same population as initial SSR?
  • Does reset restore the state necessary to repeat the full walkthrough?
  • Can an admin setting change the sandbox slug and make future reset/provisioning behavior inconsistent?
  • Do public quote/status token flows still work for sandbox-generated records?

Tests should make these questions executable.


Leonardo — audit plan / priority

Phase 1 — close workflow-breaking regressions

  • Fix PR Fix demo-tenant quote actions and stale technician availability #74's normal-tenant synthetic-row regression with sandbox-aware visibility rules.
  • Make sandbox quote Send quote to customer follow the chosen sandbox policy instead of 404ing on is_demo=true.
  • Remove TechPhoneModal's fake quote_pending mutation and enforce the same Build Quote / Complete rules as the real technician experience.
  • Add end-to-end behavior coverage for the complete sandbox quote path: create → line items → preview → send/simulate send → accept/decline → resulting job/technician state. (src/lib/__tests__/demoTenantQuoteLifecycle.test.ts; the quote/intake pages themselves aren't rendered, since this repo has no page-render test harness — see Phase 4 note below.)

Phase 2 — restore state invariants

  • Release/reconcile technician availability_status + current_job_id on every terminal job path, including direct status completion. (src/lib/technicianReconciliation.ts, shared by PATCH /api/jobs/[id] and POST /api/quotes/[id]/accept, including multi-assignment promotion and is_demo/legacy-status-aware candidate selection.)
  • Verify initial SSR and realtime refetch use the same sandbox-aware visibility policy. (dispatch/page.tsx SSR and KanbanBoard's realtime refetch both gate on the same isSandboxDemoCompany result.)
  • Verify admin metrics/analytics use the intended sandbox-aware population without exposing load-test noise in ordinary tenants.

Phase 3 — UX fidelity and demo contract

  • Decide whether private preview credential is dispatcher or admin and make navigation match. (Kept dispatcher; DemoBanner's Admin settings link is now role-gated instead of dead-ending.)
  • Replace duplicated/fake tech preview behavior with shared production technician UI/business rules where practical. (TechPhoneModal now enforces the same business rules as the real technician UI — non-mutating Build Quote, Complete gated on an accepted quote, real tel:/Maps links — but still isn't wired into the actual shared component/route. Left open as an architecture decision; see docs/demo-experience-design.md's follow-ups.)
  • Make Reset data failures visible.
  • Define whether reset means job-state reset or full sandbox-baseline reset, then align copy and implementation. (Expanded to also restore technician identity and the canonical quote template.)
  • Decide and centralize sandbox SMS/payment/external-side-effect behavior. (SMS centrally suppressed in processSmsOutboxBatch; payment already made no external calls via ManualPaymentProvider.)
  • Refresh or replace docs/demo-experience-design.md so it describes the current architecture.

Phase 4 — regression gate

Add a dedicated demo-tenant regression suite that covers, at minimum:

  • sandbox vs normal-company is_demo=true visibility
  • dispatcher board initial load + realtime refetch parity (verified by code inspection, not by an automated test — no component-render harness exists in this repo to assert KanbanBoard's actual rendered output)
  • quote create/edit/delete/preview/send path (API/data level, via the E2E suite and existing per-route tests; the preview page itself isn't rendered — same test-infra gap as above)
  • customer quote accept + decline
  • technician En Route → Arrived → Build Quote → Complete behavior (rule-matching covered by code + jobMutations/technicianAssignment tests; TechPhoneModal's actual UI flow isn't component-tested for the same reason)
  • technician availability/current-job invariants
  • reset and repeatability
  • role-correct demo navigation (verified by code inspection — DemoBanner's role gate — not by an automated render test)
  • no unintended external side effects

Completion criteria

The audit is complete when a trusted prospect can repeat the intended demo walkthrough from a clean reset without encountering:

  • a 404/403 caused only by sandbox data flags
  • a button that looks functional but is not
  • a demo-only state transition that production users cannot perform
  • stale technician state after completion
  • synthetic load-test data in ordinary tenant operational views
  • silent reset failures
  • unplanned external side effects

At that point, the private demo can be treated as a regression-tested product surface rather than a collection of demo exceptions.


Status as of PR #77: every P1/P2 finding above and every Phase 1-3 checklist item is fixed except one deliberate open question (TechPhoneModal's shared-component wiring, tracked in docs/demo-experience-design.md). The two remaining Phase 4 gaps are about test infrastructure this repo doesn't have (component/page rendering), not about unverified behavior — see PRs #74/#76/#77 and their test suites for the executable coverage that does exist. Remaining work here is either the TechPhoneModal architecture decision, or standing up a render harness if page/component-level regression coverage becomes a priority.

Activity

  1. added 11 commits that reference this issue on Sep 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions