Chapter 13 · Part III — Tasks and execution

Separate decisions from the work they trigger

After certification, the workshop may notify an equipment owner, update a report, or dispatch a certificate to another service. These effects extend the application beyond the single record. They also introduce failures that a simple transition graph does not describe.

ADL has rules, schedules, workflows, hooks, and integrations. Their names suggest related forms of automation, but each has its own execution contract. Select the mechanism from the required timing and authority rather than from the amount of YAML it saves.

Put a blocking rule before the commit

Suppose a measurement outside a supported range must never be certified. That condition belongs in a mechanism that can refuse the relevant operation before its business result commits. A notification sent afterward cannot restore the promise that the invalid certification never existed.

Conversely, sending an email before the database commit can announce an approval that later rolls back. Decide which effects belong to the database transaction and which occur after it. Then test the failure boundary between them. “The workflow runs” is not a complete ordering contract.

The engine’s transaction and hook fixes matter because they change these orderings. When updating an older manuscript, trace the actual handler and transaction scope. An old example can remain syntactically valid while its event timing has changed.

Hooks are trusted extension code

A hook can compute or alter values that ordinary callers cannot write. That is useful for derived provenance and domain integration, but it expands the trusted implementation. A protected field is protected from the caller only if the hook’s input and authority are also understood.

The calibration example uses transition assignments without custom hooks. This keeps the provenance chain short: authenticated actor, guarded transition, recorded actor field. If a hook later overrides an assignment, include that hook in the independent-review argument and tests.

Do not assume that a hook attached to one verb covers every write path. Create, PATCH, PUT, import, restore, and transition may travel through different handlers. The current reference and regression tests identify supported coverage. New extension paths should make their own entry and exit conditions explicit.

A workflow has an execution identity

Server-side workflows and schedules can execute with elevated authority under declared rules. A Journey, by contrast, describes caller work. Confusing these identities can make a task appear feasible only because the demonstration used a privileged server actor.

Record who performs each effect. If a schedule performs a system write, identify the domain declaration that authorizes that elevation and the policies that still apply. A background job is not automatically exempt from governance simply because no human clicked a button.

External effects need reconciliation

An HTTP timeout after dispatch does not tell us whether the remote service accepted the request. A retry can duplicate the effect. A local rollback cannot retract a message already consumed elsewhere. These are ordinary distributed-system conditions, and a workflow declaration does not remove them.

Design an identifier for the intended effect, a safe retry or deduplication mechanism, and a way to reconcile uncertain outcomes. Keep the business state capable of expressing pending or uncertain delivery where that is meaningful. A certificate can be approved locally while its delivery remains pending.

Compensation is a new action with its own failure modes. Refunding a payment does not make the original charge disappear from history. Revoking a delivered document does not prove that every recipient erased it. Name the observable outcome the compensation can actually achieve.

Scheduling is about ownership of the occurrence

Periodic monitoring needs a definition of one occurrence, a claim on that occurrence, and behavior when the service restarts or a domain is resubmitted. Two live scheduler instances can otherwise perform the same work. A corrected next-run calculation solves drift but does not alone establish exactly-once effects.

Before adding automatic calibration reminders, choose whether duplicate reminders are tolerable and how missed occurrences are recovered. Keep that policy separate from the calibration approval invariant.

ADL 23, ADL 25, and ADL 37 provide the detailed contracts. This chapter describes design obligations; the handbook’s runtime lab does not execute an external dispatch or scheduled workflow.

Workshop

Design certificate delivery after approval. List the states you need when delivery succeeds, fails before sending, or times out after the remote service may have accepted it. Identify which transitions are local database facts and which require evidence from another system.