You will attach predetermined effects to the repair-depot tasks.

Create the Changes source

Create changes.workspec.js:

JavaScript
// @ts-check
/// <reference types="workspec/workspec-changes" />

WorkSpec.task("inspect_pump", (task) => {
  task.onStart(() => {
    set("pump", "state", "under_inspection", { temporary: true });
  });

  task.onComplete(() => {
    set("pump", "state", "inspection_complete");
    move("pump", "workshop");
  });
});

WorkSpec.task("repair_pump", (task) => {
  task.onStart(() => {
    set("pump", "state", "under_repair", { temporary: true });
  });

  task.onComplete(() => {
    set("pump", "state", "repaired");
    move("pump", "dispatch");
  });
});

The temporary state lasts only while its task is active. The runtime restores the earlier value before it applies completion effects.

Validate the project sources

Run project validation through the final completion:

Terminal
npx workspec validate start.workspec.json \
  --changes changes.workspec.js \
  --time 08:30

Expected final line:

Text
✓ No problems found

Observe a temporary effect

Inspect the world while inspection is active:

Terminal
npx workspec snapshot start.workspec.json \
  --changes changes.workspec.js \
  --time 08:05 \
  --json

The value at state.objects.pump.properties.state is:

Text
under_inspection

Observe completion effects

Inspect the final state:

Terminal
npx workspec snapshot start.workspec.json \
  --changes changes.workspec.js \
  --time 08:30 \
  --json

The pump has state repaired and location dispatch.

Use Authoring Changes and Change operations for exact behavior.

Next step

Add a Constraint to check a domain rule against the resolved result.