← Back to PatternPip

STATE / PRACTICE

Same support ticket.
Different rules at each stage.

Transfer the order lifecycle idea to a support desk. Keep command handling with the current state, and make transitions affect the next command.

YOUR MISSION / SUPPORT DESK

Assign before resolving.
Resolve only once.

Open accepts assign. Assigned accepts resolve and becomes Closed. Other commands must leave the ticket unchanged. Build the rules, test their limits, then add reopening.

Order → Ticket · OrderState → TicketState. The context keeps the data; its current state decides what is allowed. No external support service is called.

01 / BUILD THE LIFECYCLE

Make three design choices.

Decide who handles a command, how the ticket moves on, and what Closed permits.

Who decides what this command means?

Try your own design first. Hints and retries are unlimited.

02 / PREDICT · SEND · OBSERVE

Same command. Different stage.

Local simulation

A new ticket must be assigned before it can be resolved.

Predict first (optional): will Open accept “resolve”?

SAME TICKET / #204

Support desk
0resolutions recorded

Installed state · retained by Ticket

  1. OpenCurrent state
  2. AssignedNot current
  3. ClosedNot current
  1. 1 resolve
  2. 2 assign
  3. 3 resolve
CALLER SENDSWaitingStart with an Open ticket
ACTUAL HANDLERYour design decidesWatch where Ticket sends it
DECISIONNot shown yetNext step reveals the result
Open · 0 resolutionsA fresh ticket for this scenario.
A fresh ticket per test. The same ticket across its commands.

Choose your pieces, then start a trace. Your choices drive the result.

Verify all three tests with the same design. Changing a piece clears the evidence; replaying a step never sends a command twice.

See the code behind your design TypeScript

03 / THE FINAL CHALLENGE

Extend the lifecycle: reopen a ticket

A customer reports the issue is back. Closed must accept reopen and return Open. A new resolution still requires assignment first.

Closedreopen →Openassign → Assigned → resolve → Closed

Choose the three required edits, then press Apply edits & trace. Follow the six-command trace to complete the practice.

Verify all three base scenarios with one assembly to unlock this extension.

Which three edits are needed?

0 of 3 edits selected

Compare with a complete solution

Hints and retries are unlimited. Revealing the answer does not mark scenarios verified.