Skip to main content
A monthly NAV run doesn’t start from scratch. It needs last period’s totals so a quality check can flag “rent dropped 12% MoM” or “journal line count is 2× the trailing average”. ntro.workflow.task exposes task-level operations a runbook can call from inside a running workflow — previous(...) for prior-task lookup, find_committed_document(...) for retrieving committed documents.
Renamed from ntro.workflow.history in Phase 1 of N-74. The narrower history name was a poor fit once this module became the home for any task-level operation a workflow might want (task.current() and task.get(task_id) will land in Phase 2+). The instance method self.load_previous_task(...) on NtroWorkflow is unchanged and still works for terser runbook code.

Install

Bundled with the workflow extra.

task.previous

PreviousTaskHandle.extract(fields) returns a flat {field: value} dict, dropping any fields the prior run didn’t emit — the caller decides how to handle gaps. Pass the projected dict straight into run_quality_check as checks_baseline; checks marked requires_baseline=True are reported as status="skipped" when baseline is None.
Soft-degrade is the contract. None means “no prior task found” and is the normal first-run state. Callers should skip baseline-dependent checks rather than raise. The SDK never throws on a missing prior run.

Signature

Wiring into a runbook

self.load_previous_task(...) schedules a Temporal activity under the hood. Your runbook bundle’s activities.py must re-export the activity defn so the worker registers it:
The activity-decorated function names (load_previous_task_activity, find_committed_document_activity) kept their original names — these are network identities consumed by deployed workflows and must stay stable. Only the import path changed (ntro.workflow.history → ntro.workflow.task). Same re-export pattern as Quality checks. Activities live in the SDK; the runbook bundle’s __all__ is what gets registered with the worker.

Reference

Quality checks

Pair the baseline dict with run_quality_check for MoM delta checks.

Workflows overview

NtroWorkflow and @runbook.step — the surface this helper extends.