Skip to content

What blocks approval, and who approves

The rule

Approval rules say what needs approving (each day, the period, a category’s lines) and in what stages. Out of the box, any open exception on a subject’s days keeps it from approval, and each stage goes to the approver its rule names. Many employers want more: only some exceptions should block (a missing punch must be fixed; a late arrival is for the supervisor to judge while approving), and some subjects need someone else (overtime past two hours a day to the plant manager, minors’ timecards to HR).

Who uses it

Any employer with an approval chain that depends on what is being approved: manufacturing plants where large overtime needs a manager’s sign-off, retailers and restaurants employing minors, whose hours HR checks against child labor limits, and payroll teams who do not want lateness alone to hold up a timecard.

How the recipe does it

Configuration only: a package (package.toml) of one layer. It raises late arrivals past 5 minutes’ grace (standard/late), puts time past 8 hours a day in overtime (standard/threshold), and runs the standard approval step, in the approve stage: only missing punches block, a day with more than 2 hours of overtime goes to the plant manager, and a minor’s timecard to HR.

[[layer]]
id = "approval"
[[layer.step]]
id = "approval"
uses = "standard/approval"
params = { blocks = ["missing_in", "missing_out"], routes = [
{ stage = "supervisor", to = "role:plant_manager", over = "2h", categories = ["overtime"] },
{ stage = "payroll", to = "role:hr", attribute = "minor" },
] }

The approve stage runs on each subject of a ledger, as where its approval stands is worked out. Its step sees ctx.subject (key, kind, days, category), ctx.rule (side, blocked_by_exceptions, stages), the subject’s exceptions (ctx.exceptions, each kind, at, about, detail, state) and its lines (ctx:lines(), ctx:time_in(filter)), and calls ctx:block(why) and ctx:route(stage, approver, why). With such a step, the step alone says what blocks. A blocked subject shows why; a routed stage shows who it waits for (approver), which the product routing approvals reads in place of the rule’s.

Parameters

ParameterMeaning
blocksThe exception kinds that block, where the rule says exceptions block (default every kind). Excused ones never do.
never_blocksKinds that never block.
routesEach { stage, to, over, categories, attribute }: stage goes to to when the subject’s time in categories (default every worked one) is over over, and the person’s employment attribute attribute is set on its last day (each only if given).

What the scenarios show

  • only-missing-punches-block: Monday, late, waits for the supervisor; Tuesday, with a missing punch, is blocked and says why.
  • long-overtime-and-minors-go-higher: a day with 1 hour of overtime waits for the supervisor, one with 3 hours for the plant manager; a minor’s period goes to HR at the payroll stage.

This is a common way companies route approvals; check the rules where you operate. Approving a timecard does not change what is owed for time actually worked.

Get the recipe

The recipe’s package and its scenarios are in the example packages repository: attendance/approval_routing. Test it, or your own copy of it, with hourctl attend test, and publish it with hourctl attend pkg publish.

The policy package

The package’s layers, with the standard steps each one runs and their settings:

approval_routing/package.toml
name = "approval_routing"
version = "1.0.0"
description = "Only missing punches keep a day from approval, long overtime goes to the plant manager, and minors' timecards to HR."
# Late arrivals past 5 minutes' grace are exceptions, and time past 8
# hours a day is overtime. Of the exceptions, only missing punches block
# approval; a day with more than 2 hours of overtime goes to the plant
# manager at the supervisor stage, and a minor's timecard to HR at the
# payroll stage.
[[layer]]
id = "approval"
[[layer.step]]
id = "late"
uses = "standard/late"
params = { grace = "5m" }
[[layer.step]]
id = "daily"
uses = "standard/threshold"
params = { over = "8h", to = "overtime", window = "day" }
[[layer.step]]
id = "approval"
uses = "standard/approval"
params = { blocks = ["missing_in", "missing_out"], routes = [
{ stage = "supervisor", to = "role:plant_manager", over = "2h", categories = ["overtime"] },
{ stage = "payroll", to = "role:hr", attribute = "minor" },
] }

Scenarios

Each scenario gives a person’s punches and setup and the timecard they must produce, worked out with this package adopted (the format).

Overtime is approved per day by the supervisor, but a day with more than 2 hours of it goes to the plant manager instead: Thursday's 1 hour stays with the supervisor, Friday's 3 hours go up. The person is a minor, so the period's payroll stage goes to HR, who checks minors' hours
scenarios/long-overtime-and-minors-go-higher.toml
description = "Overtime is approved per day by the supervisor, but a day with more than 2 hours of it goes to the plant manager instead: Thursday's 1 hour stays with the supervisor, Friday's 3 hours go up. The person is a minor, so the period's payroll stage goes to HR, who checks minors' hours"
punch = [
{ at = "2026-10-05 08:00", kind = "in" }, { at = "2026-10-05 16:00", kind = "out" },
{ at = "2026-10-06 08:00", kind = "in" }, { at = "2026-10-06 16:00", kind = "out" },
{ at = "2026-10-07 08:00", kind = "in" }, { at = "2026-10-07 16:00", kind = "out" },
{ at = "2026-10-08 08:00", kind = "in" }, { at = "2026-10-08 17:00", kind = "out" },
{ at = "2026-10-09 08:00", kind = "in" }, { at = "2026-10-09 19:00", kind = "out" },
]
[policy]
zone = "America/Chicago"
[[employment]]
effective = "2026-01-05"
kind = "hired"
attributes = { minor = true }
[[approval_rule]]
subject = "category:overtime"
stages = ["supervisor"]
[[approval_rule]]
subject = "period"
stages = ["payroll"]
[expect.period]
day = "2026-10-05"
approvals = [
"category:overtime:2026-10-08 pending supervisor",
"category:overtime:2026-10-09 pending supervisor to role:plant_manager",
"period:2026-10-05 pending payroll to role:hr",
]
Exceptions keep a day from approval, but not every kind: a missing punch must be fixed first (Tuesday is blocked, and says why), while a late arrival is for the supervisor to judge when approving (Monday waits for them)
scenarios/only-missing-punches-block.toml
description = "Exceptions keep a day from approval, but not every kind: a missing punch must be fixed first (Tuesday is blocked, and says why), while a late arrival is for the supervisor to judge when approving (Monday waits for them)"
punch = [
{ at = "2026-10-05 08:20", kind = "in" }, { at = "2026-10-05 16:00", kind = "out" },
{ at = "2026-10-06 08:00", kind = "in" }, { at = "2026-10-06 12:00", kind = "out" },
{ at = "2026-10-06 12:30", kind = "out" },
]
[policy]
zone = "America/Chicago"
[[shift_definition]]
id = "days"
start = "08:00"
end = "16:00"
days = ["monday", "tuesday"]
[[approval_rule]]
subject = "day"
stages = ["supervisor"]
blocked_by_exceptions = true
[expect.period]
day = "2026-10-05"
approvals = [
"day:2026-10-05 pending supervisor",
"day:2026-10-06 blocked (missing_in not settled)",
]
exceptions = [
{ kind = "late", at = "2026-10-05 08:20" },
{ kind = "missing_in", at = "2026-10-06 12:30" },
]