Skip to content

A limit each company sets in its app

The rule

A manager reviews any day someone works longer than a limit: for fatigue, for safety, or before the hours are paid. Each company chooses its own limit (10 hours, 8 hours) in the settings screen of the app it uses, and changes it there when it likes, without anyone writing policy.

Who uses it

Software providers whose app serves many companies on one install, each company a tenant: the provider writes the rule once, and each company’s administrators set its numbers in the app. Long-day review is common in healthcare, transport and construction, and where working-time limits apply (the European Union’s, for example).

How the recipe does it

Configuration only: a package (package.toml) of one policy layer with one standard step, its limit read from the tenant’s metadata.

A tenant’s metadata is a JSON object the app keeps (PATCH /api/attendance/tenants/{tenant}), never read by the engine itself. The company’s settings screen writes its limit there:

{ "review": { "long_day": "10h" } }
[[layer]]
id = "review"
[[layer.step]]
id = "long-days"
uses = "standard/limit"
params = { over_from = "review.long_day", kind = "long_day", about = "day" }
  • Each workday, the time worked is compared with the duration at review.long_day in the tenant’s metadata. More than that raises a long_day exception about the day, for a manager to look at; the detail says how long the day was and the limit.
  • A tenant that sets no limit has none raised.
  • Nobody’s pay changes: the flag is for review only.

Changing the metadata works out every person of the tenant again (as bulk work, behind each tenant’s own punches), so the new limit applies at once; a closed pay period keeps the metadata it was closed with.

Where the number is a rule’s rather than the company’s (the law’s limit, a contract’s), give it as over in a policy layer instead: layers are dated, versioned and show in each line’s stamps.

Parameters

StepParameterMeaning
long-daysover_fromWhere in the tenant’s metadata the limit is kept (review.long_day, a duration).
long-dayskindThe exception raised (long_day).
long-daysaboutday: the exception is about the day, not its latest line.

What the scenarios show

  • a-company-that-reviews-days-over-ten-hours: 11 hours flagged, 9 not.
  • a-company-that-sets-no-limit: nothing flagged.
  • another-company-sets-another-limit: at 8 hours, both days.

Where law limits daily hours, a flag is not enough on its own: check the rules where you operate.

Get the recipe

The recipe’s package and its scenarios are in the example packages repository: attendance/long_day_review. 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:

long_day_review/package.toml
name = "long_day_review"
version = "1.0.0"
description = "Days longer than a limit each company sets in its app, kept in the tenant's metadata, are flagged for review."
# Each workday worked past the tenant's review.long_day raises long_day
# about the day. A tenant that sets no limit has none raised.
[[layer]]
id = "review"
[[layer.step]]
id = "long-days"
uses = "standard/limit"
params = { over_from = "review.long_day", kind = "long_day", about = "day" }

Scenarios

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

A company whose settings in the app say to review days of more than 10 hours: Monday's 11 hours worked (the half-hour lunch not counted) are flagged, Tuesday's 9 are not
scenarios/a-company-that-reviews-days-over-ten-hours.toml
description = "A company whose settings in the app say to review days of more than 10 hours: Monday's 11 hours worked (the half-hour lunch not counted) are flagged, Tuesday's 9 are not"
punch = [
{ at = "2026-10-05 07:00", kind = "in" }, { at = "2026-10-05 12:00", kind = "lunch_start" },
{ at = "2026-10-05 12:30", kind = "lunch_end" }, { at = "2026-10-05 18:30", kind = "out" },
{ at = "2026-10-06 08:00", kind = "in" }, { at = "2026-10-06 17:00", kind = "out" },
]
[policy]
zone = "Europe/Madrid"
[tenant]
metadata = { review = { long_day = "10h" } }
[expect]
week = "2026-10-05"
exceptions = [{ kind = "long_day", at = "2026-10-05 00:00", detail = "11h worked in the day, more than 10h" }]
A company that has set no limit in the app has no long days flagged, with the same step in its policy
scenarios/a-company-that-sets-no-limit.toml
description = "A company that has set no limit in the app has no long days flagged, with the same step in its policy"
punch = [
{ at = "2026-10-05 07:00", kind = "in" }, { at = "2026-10-05 12:00", kind = "lunch_start" },
{ at = "2026-10-05 12:30", kind = "lunch_end" }, { at = "2026-10-05 18:30", kind = "out" },
{ at = "2026-10-06 08:00", kind = "in" }, { at = "2026-10-06 17:00", kind = "out" },
]
[policy]
zone = "Europe/Madrid"
[expect]
week = "2026-10-05"
exceptions = []
Another company, with the same step, reviews days of more than 8 hours: both days are flagged
scenarios/another-company-sets-another-limit.toml
description = "Another company, with the same step, reviews days of more than 8 hours: both days are flagged"
punch = [
{ at = "2026-10-05 07:00", kind = "in" }, { at = "2026-10-05 12:00", kind = "lunch_start" },
{ at = "2026-10-05 12:30", kind = "lunch_end" }, { at = "2026-10-05 18:30", kind = "out" },
{ at = "2026-10-06 08:00", kind = "in" }, { at = "2026-10-06 17:00", kind = "out" },
]
[policy]
zone = "Europe/Madrid"
[tenant]
metadata = { review = { long_day = "8h" } }
[expect]
week = "2026-10-05"
exceptions = [
{ kind = "long_day", at = "2026-10-05 00:00", detail = "11h worked in the day, more than 8h" },
{ kind = "long_day", at = "2026-10-06 00:00", detail = "9h worked in the day, more than 8h" },
]