# Service levels and handle time when a channel opens: design

Written and committed before any code or run. The frozen protocol, `servicelevels/protocol.json`, is written after the
code passes its unit tests and a pilot on the support metrics round's three pilot seeds, and before the main run; it pins
the hash of this file and of every code file the results depend on. Anything decided after seeing results is labelled
"Change N to the protocol, made after the results" on the page. No model is called anywhere in this round.

## What this round adds, and the overlap test

The support metrics page of this study measures resolution, reopen rate, satisfaction, contacts per active account and
contact drivers on one simulated support year, and says plainly that its staffing plans ignore service-level targets and
queueing. Its simulator records a first-response time per ticket, but that time ignores how busy the team is (chat is
always answered in 3 minutes) and no result uses it. This round adds the three numbers a support team reports next to
those: first-reply time, service-level attainment by channel, and handle time read as a distribution rather than a mean.
It asks how each moves when chat opens, when a chat transfer splits one contact into two tickets, and when the queue is
measured per ticket or per issue.

Overlap test. The nearest two studies in the series are (1) the support metrics page of this study: same simulated year,
same question family (what a channel, a counting unit or a definition does to a support team's own numbers), same
linking rule; and (2) the capacity-from-a-forecast study: it asks how far above a forecast to schedule capacity when
running short costs more than running over, which is a staffing decision, not a question about how service levels read.
The first holds, so this is a new round of the self-service measurement study, on its own page linked from the support
metrics page, and not a new study. The handle-time means per ticket and per linked issue are already implied by the
support metrics page's cost rows (cost per ticket falls when chat opens while cost per linked issue barely moves); this
round adds the distribution, the per-channel split and first-reply time, which no published page measures.

## Data: the same simulated year, plus a declared queue

The arrivals are the support metrics round's simulated year exactly as `supportmetrics/model.py` produces it, with its
main parameters and all four injected events on: every ticket, its channel, role (customer-facing, chat transfer or
duplicate), opening day, linked group, true issue, reopen day and handling minutes. Nothing in that model is changed. Its
recorded first-response field is not used; this round replaces it with the first reply a declared queue produces.

Clock. Minutes from the start of day 0. Day d is a weekday when d mod 7 is 0 to 4 and a weekend day when it is 5 or 6,
as in the simulator.

Arrival time within the day. Each ticket draws one uniform number from its own stream, seeded by the year's seed and its
ticket id, so a ticket keeps its arrival time in every scenario. Email tickets, duplicates and reopens arrive by hour of
day with weights 0.1 for each hour from 00:00 to 08:00, 1.0 from 08:00 to 18:00, 0.6 from 18:00 to 20:00 and 0.3 from
20:00 to 24:00, uniform within the hour. Chat is offered only while it is staffed, so a chat start arrives between 08:00
and 20:00 with the same weights for those hours. The email ticket of a chat transfer arrives when the transfer ends: its
chat ticket's first reply plus the transfer's 5 handling minutes. A reopen arrives on its reopen day by the email
weights and adds 15 minutes of work to the email queue; it is work, not a ticket, and has no first reply of its own.

Seats. Two queues, email and chat, are staffed from 08:00 to 20:00 every day. A seat is one agent available to take
contacts, after breaks, meetings and leave, so no further shrinkage applies. Before week 30 the email queue has 9 seats
on weekdays and 4 on weekend days. From week 30, when chat opens, the team is held at the same size and moves seats to
chat: email 7 and chat 2 on weekdays, email 3 and chat 1 on weekend days. The seat counts were set from the work
arriving in the pilot seed 9001's weeks 20 to 39 (handling minutes per channel, computed before any first reply), so that
the weekday email load is about 0.72 before chat and about 0.85 after, and the weekday chat load about 0.36.

Queue rule. Each queue is worked oldest first by its seats. A contact starts when a seat is on shift and free; the
contact's first reply is sent when it starts; the seat is then busy for the contact's handling minutes, and a contact
started before 20:00 is finished even if that runs past the end of the shift. Formally, for each contact in arrival
order, every seat's earliest possible start is the first moment at or after both the arrival and the seat's previous
finish at which that seat is on shift; the contact takes the seat with the earliest such moment (lowest seat number on a
tie). Chat contacts are handled one at a time per seat. Nobody abandons a queue in this round.

## Definitions (fixed here, before any first reply is computed)

Windows: the ten weeks before chat opens (weeks 20 to 29, after the product bug) and the ten weeks after (weeks 30 to
39, before the classifier relabel). A ticket belongs to the window of its opening week; an issue to the window of its
first ticket.

Targets: a first reply within 24 hours for email and within 2 minutes for chat. Also reported, as a declared sweep that
needs no re-simulation: 4 and 8 hours for email, 1 and 5 minutes for chat.

Units, each read per channel (email, chat) and for all channels together:

1. Per ticket, the help desk's default: every ticket's first reply, timed from that ticket's own arrival, against its
   channel's target. Chat transfer tickets and duplicates count as tickets.
2. Per linked issue, the team's best view: tickets as linking leaves them. The clock starts at the arrival of the group's
   first ticket and stops at the first reply on a ticket that was not closed as a transfer or as a duplicate (the help
   desk records that close reason). A group with no such ticket stops at its first reply of any kind. The target is the
   one of the channel the group started in.
3. Truth, per true issue, available only here: the same as 2 with the true issue ids.

First-reply time is reported as the median and the 90th percentile in minutes; attainment as the share of units
answered within their target. Quantiles are nearest rank: the value at position ceil(q times n) in sorted order.

Handle time: per ticket, the ticket's handling minutes (5 for a chat transfer, 2 for a duplicate); per linked issue and
per true issue, the sum of its tickets' handling minutes. Reopen minutes are left out of handle time here (the support
metrics page already counts reopens as rework). Reported as the mean, the median, the 90th percentile and the share at 5
minutes or less, per channel (an issue's channel is the one it started in) and for all.

Load, a diagnostic: work arriving in a window (handling minutes plus reopen minutes) over seat hours in that window,
per queue.

## Scenarios

- Main: seeds 1 to 200, the seat plan above, every reading in both windows. The main year is seed 1, fixed here.
- Sweeps, 40 seeds each (seeds 1 to 40), one input at a time with the others at their main values:
  - weekday seats moved to chat at week 30: 1, 2 or 3 (weekend chat stays 1, weekend email 3);
  - weekday seats in all before chat: 9, 10 or 11, with 2 moved to chat at week 30 (weekend seats unchanged);
  - the linking rate of the simulator: 0.5, 0.9 or 1.0 (this one re-simulates the year).
- Targets: the declared sweep above, on the 200 main years.
- Worked example, by a rule fixed here: in seed 1, the first issue by id opened in week 31 that started in chat, was
  transferred to email, and whose email ticket was linked to it.

## Predictions (fixed here, before any first reply is computed)

"Median year" means the median over the 200 main years of the year's own figure. Each prediction is reported as held,
missed or untestable, with its band.

- P1. Email first replies slow down when two seats move to chat: the per-ticket email median first reply is longer in
  weeks 30 to 39 than in weeks 20 to 29 in at least 180 of 200 years. It follows from the design (email load rises from
  about 0.72 to about 0.85), so it is close to a safe bet; the size is the result.
- P2. A 24-hour email target barely sees P1: per-ticket email attainment within 24 hours differs between the two windows
  by 2 points or less in the median year.
- P3. Blended attainment per ticket falls when chat opens, by 1 to 10 points in the median year, because chat tickets
  miss a 2-minute target more often than email tickets miss 24 hours.
- P4. Per issue reads worse than per ticket after chat opens: in weeks 30 to 39, blended attainment per linked issue is
  at least 5 points below blended attainment per ticket in at least 195 of 200 years. Partly true by construction: a
  transferred issue started in chat cannot meet the chat target with its first answer, which comes at least 5 minutes
  after its chat starts.
- P5. Before chat, the unit barely matters: in weeks 20 to 29, blended attainment per ticket and per linked issue differ
  by less than 1 point in the median year (only duplicates differ).
- P6. Mean handle time per ticket falls by 10% to 20% when chat opens while the mean per linked issue moves by less than
  5%, in the median year. The per-ticket fall is largely by construction (every transfer adds a fixed 5-minute ticket).
- P7. Read as a distribution, the median handle time per ticket falls by a larger share than the mean, and the 90th
  percentile per ticket moves by less than 5%, in the median year.
- P8. Linking leaves the issue reading close to the truth: in weeks 30 to 39, blended attainment per linked issue is
  within 2 points of the true-issue attainment in the median year.
- P9. Moving a third seat to chat makes email much slower: with 3 seats moved, the per-ticket email median first reply
  in weeks 30 to 39 is at least 3 times its value with 2 moved, in the median of the 40 sweep years.

## Runs and intervals

- Pilot: seeds 9001 to 9003, run after the unit tests and before the protocol is frozen, to check that the code runs and
  the queues are stable. It prints the load per queue and window and the share of contacts started on the day they
  arrived, and nothing else. If any queue's load is above 0.95 in a window, that queue gets one more seat before
  freezing, and the change is listed in the protocol.
- Main run: seeds 1 to 200, once, after the protocol is frozen. Sweeps: as above, once.
- Shares of years are reported with Wilson 95% intervals; spreads over years as the 5th to 95th percentile.

A defect found after the main run is fixed in a declared re-run, and both results are reported.

## Limits known before running

Everything is synthetic: the arrivals come from the support metrics round's assumptions and the queue, seats, hours,
arrival profile and targets are mine. The readings are a self-test of one author's assumptions, not a measurement of any
support team. Some results are true by construction, as marked in the predictions. A first reply is sent when an agent
picks a contact up, so first-reply time is pure waiting; nobody abandons; chat is handled one contact per seat; the
recorded solve and reopen days of the simulator are not moved by the queue, so a ticket can be recorded solved before
this round's first reply (no result here reads a solve day). Nothing here claims support-operations employment, and no
help-desk product is named or imitated.
