Advanced2 hr 10 min8 implementation labs5 hostile paths

Build Field-service task lifecycle

An eight-lab, source-bounded workshop for the complete task lifecycle: exact commands and events, durable records, replay, concurrency, unknown outcomes, hostile fixtures, a maintained capstone, and production exit evidence.

Durable boundarytask · 8 states · 8 transitions · 8 event identities

Freeze the evidence boundary first

This curriculum teaches the durable host workflow around reviewed Mappls surfaces. It does not manufacture provider endpoints, callbacks, resource states, entitlement, or completion evidence.

The journey blueprint and application event contracts are implementation guidance, not Mappls provider payload specifications.Only linked normalized contracts and source guides may define provider request syntax; empty evidence is never backfilled.The simulator and maintained capstone operate in explicit fixture mode and make no entitlement claim.Credentials, precise production payloads, opaque native objects, and provider secrets stay outside workshop inputs and durable examples.
Lab 1 · 15 min

Model the lifecycle before the UI

Turn the task blueprint into an explicit aggregate boundary owned by the application.

Build

unassigned: The job exists with client, site, SLA, skills, window, and proof policy but no worker owns it.assigned: A specific eligible worker owns the next decision and dispatch has recorded why they were selected.accepted: The worker has acknowledged responsibility and the customer-facing plan can become firm.en_route: Travel has begun and ETA, route deviation, and SLA-risk observations may change continuously.in_progress: Arrival is established and work evidence can be gathered under the declared proof policy.proof_pending: The worker submitted an immutable evidence set awaiting automated or supervisor validation.completed: Required proof is accepted and downstream billing, inventory, SLA, and customer workflows may run.cancelled: A named actor stopped the job with a reason before completion.

Prove before continuing

Every persisted state exists in the reviewed blueprint.Terminal states reject ordinary forward commands.Recovery text is operational guidance, not another hidden state.
Lab 2 · 20 min

Implement every command and event pair

Make intent, actor authority, allowed source state, committed state, and emitted fact reviewable together.

Build

create_task by Integration service: new aggregate → unassigned; emit task.created.assign by Dispatcher: unassigned | assigned → assigned; emit task.assigned.accept by Field worker: assigned → accepted; emit task.accepted.start_travel by Field worker: accepted → en_route; emit task.en_route.arrive by Field worker: en_route → in_progress; emit task.started.submit_proof by Field worker: in_progress → proof_pending; emit task.proof_submitted.approve_proof by Supervisor: proof_pending → completed; emit task.completed.reject_proof by Supervisor: proof_pending → in_progress; emit task.proof_rejected.

Prove before continuing

create_task resolves to field-service-task-task-created without claiming a provider webhook payload.assign resolves to field-service-task-task-assigned without claiming a provider webhook payload.accept resolves to field-service-task-task-accepted without claiming a provider webhook payload.start_travel resolves to field-service-task-task-en-route without claiming a provider webhook payload.arrive resolves to field-service-task-task-started without claiming a provider webhook payload.submit_proof resolves to field-service-task-task-proof-submitted without claiming a provider webhook payload.approve_proof resolves to field-service-task-task-completed without claiming a provider webhook payload.reject_proof resolves to field-service-task-task-proof-rejected without claiming a provider webhook payload.
Lab 3 · 15 min

Persist restart-safe records

Separate business identity, provider evidence, command receipts, immutable facts, audit, and downstream delivery.

Build

Task snapshot: Fast current-state reads and optimistic concurrency. Keys: taskId, externalId, state, version, assigneeId, mapplsPin.Audit event: Attributable, replayable history for support and compliance. Keys: eventId, aggregateVersion, actor, commandId, occurredAt.Evidence manifest: Immutable references and hashes for checklist, media, signature, and consent. Keys: manifestId, taskVersion, captureTime, contentHash, retentionClass.Transactional outbox: Reliable downstream billing, inventory, notification, and analytics delivery. Keys: outboxId, eventId, status, attempts, nextAttemptAt.

Prove before continuing

Process restart restores the same aggregate version and command result.Opaque SDK or native UI objects are not durable records.Provider evidence and application decisions remain distinguishable.
Lab 4 · 15 min

Make concurrency and replay deterministic

Apply optimistic expected versions and aggregate-scoped idempotency before executing effects.

Build

One upstream external job maps to one durable task aggregate.Only the assigned worker can accept, travel, arrive, or submit proof unless an attributable override is recorded.Every command carries tenant, actor, idempotency key, expected version, and occurrence time.Completion is impossible until the declared proof policy passes.Task history is append-only; corrections use new events or compensating work.

Prove before continuing

An exact replay returns the first result without another event or version.A reused key with different intent conflicts.A stale expected version changes no durable truth.
Lab 5 · 15 min

Control effects and unknown outcomes

Commit outbox intent atomically, execute effects outside the transaction, and reconcile ambiguous results.

Build

Create-task response times out: detect with No provider response but the upstream external ID and idempotency key are known. Recover with Query by known identity or repeat the same command; do not mint a new job ID.Two dispatchers edit the same task: detect with The submitted expected version is older than the current aggregate version. Recover with Return conflict with current state; refresh context and require an intentional new command.Worker is offline during proof capture: detect with Evidence exists locally but no server acknowledgement or event ID exists. Recover with Retain command ID, hashes, capture timestamps, and retry queue until the committed event is returned.Downstream system is unavailable after completion: detect with Task is complete but its outbox entry remains pending or retrying. Recover with Retry outbox delivery independently; never reopen or re-complete the task to trigger side effects.

Prove before continuing

A timeout remains an unknown outcome until identity-based reconciliation completes.Retries are bounded and preserve the original business and command identities.Dead-letter or manual review retains the entire attempt history.
Lab 6 · 15 min

Run all hostile fixture scenarios

Exercise the success path plus replay, concurrency, state, and response-loss failures without an account.

Build

Complete journey: Commit the shortest reviewed success path to the journey-specific operating target.Idempotent replay: Repeat one command identity and prove that version, event identity, and side effects do not duplicate.Stale version: Reject a command based on an outdated aggregate version without changing durable truth.Invalid transition: Reject a known command when the current state does not permit it.Unknown outcome recovery: Reconcile after a lost response, then replay the original command identity safely.

Prove before continuing

All fixture checks pass for all five scenarios.Rejected commands emit no event and do not increment version.The fixture makes zero provider calls and exposes no write tool.
Lab 7 · 20 min

Trace the Field Service Console capstone

Follow the maintained source through domain rules, adapter seam, repository transaction, HTTP boundary, UI evidence, and restart test.

Build

Run the app's declared test suite (6 tests).Run fixture mode without a credential.Inspect audit and outbox evidence after each transition.Restart the process and continue the same aggregate.

Prove before continuing

The downloadable archive checksum verifies before execution.The capstone covers the journey target without inventing provider completion.Browser and HTTP surfaces report the same durable version.
Lab 8 · 15 min

Qualify the real integration boundary

Replace only reviewed adapter seams and collect independent production evidence without weakening application invariants.

Build

Command acceptance, rejection code, actor, task version, and latencyTime spent in each state and SLA-risk intervalDuplicate command rate and version-conflict rateOffline queue age and proof upload completenessOutbox backlog, attempt count, and dead-letter agePrecise-location access with purpose and retention class

Prove before continuing

Exact product entitlement and regional behavior are validated separately.Provider contract tests cover success, rejection, throttling, timeout, and unknown outcome.Security, privacy, operations, rollback, and product owners approve exact evidence.Fixture completion is never presented as provider or production completion.

Application-owned reliability scaffolds

The aggregate and SQL examples implement host truth; the fixture clients call the credential-free Journey Lab. Replace only the separately reviewed provider adapter seam.

Field-service task lifecycle workshop scaffolds
type State = "unassigned" | "assigned" | "accepted" | "en_route" | "in_progress" | "proof_pending" | "completed" | "cancelled";
type CommandName = "create_task" | "assign" | "accept" | "start_travel" | "arrive" | "submit_proof" | "approve_proof" | "reject_proof";

type Command = {
  name: CommandName;
  aggregateId: string;
  expectedVersion: number;
  idempotencyKey: string;
};

const transitions = {
  "create_task": { from: [null], to: "unassigned", event: "task.created" },
  "assign": { from: ["unassigned", "assigned"], to: "assigned", event: "task.assigned" },
  "accept": { from: ["assigned"], to: "accepted", event: "task.accepted" },
  "start_travel": { from: ["accepted"], to: "en_route", event: "task.en_route" },
  "arrive": { from: ["en_route"], to: "in_progress", event: "task.started" },
  "submit_proof": { from: ["in_progress"], to: "proof_pending", event: "task.proof_submitted" },
  "approve_proof": { from: ["proof_pending"], to: "completed", event: "task.completed" },
  "reject_proof": { from: ["proof_pending"], to: "in_progress", event: "task.proof_rejected" },
} as const;

export function decide(current: { state: State | null; version: number }, command: Command) {
  const rule = transitions[command.name];
  if (command.expectedVersion !== current.version) throw new Error("version_conflict");
  if (!rule.from.includes(current.state as never)) throw new Error("invalid_transition");
  return {
    state: rule.to as State,
    version: current.version + 1,
    event: rule.event,
    idempotencyKey: command.idempotencyKey,
  };
}

// Persist the result, immutable event, audit row, and outbox intent atomically.
// Store the first result by idempotencyKey before executing another effect.

Exit with reviewable evidence

All 8 reviewed transitions are implemented with actor and source-state checks.All 8 application event identities are immutable and versioned.Exact replay, idempotency conflict, stale version, invalid transition, and unknown outcome are tested.Aggregate, event, audit, command result, and outbox intent commit atomically.The Field Service Console capstone passes 6 declared tests after archive checksum verification.Provider entitlement, payload, callback, completion, and production behavior remain independently evidenced.
Workshop completion is not production authority

Workshop completion proves an application-owned reliability design only. Production still requires issued entitlement, exact adapter contract tests, regional and quota validation, security/privacy review, operational drills, and independent release approval.

Trace every external claim to an indexed source

Break the application before connecting the provider.

Run all five hostile scenarios and the maintained capstone test suite. Then qualify the exact provider seam under independently reviewed non-production entitlement.