docs← Back to article

Markdown for LLMs

Set an execution window from an event

The source Markdown for this article. Copy it into your assistant or download it as a text file.

Download this articlePlain text ↗
# Set an execution window from an event

## Intention

I want to count two business days from the date a request was received.

## Incorrect form and why it stays silent

The unit is part of the norm, and the chosen policy is a required case input. An incomplete declaration is rejected:

```text title="Incorrect form"
deadline policy Days { start_count next_day; include_end true; }
```

Even with a complete declaration, the absence of a deadline_policy choice in the case does not mean an automatic choice.

## Correct form

```law
language "law.core" version "0.2";
package recipes.e.r01 version "0.1.0";
namespace "urn:recipe:e-time:01";

entity Person;
relation registered(p: Person);
source SyntheticCalendar { kind standard; jurisdiction "none"; number "E-CALENDAR"; }
calendar Calendar {
    timezone "Asia/Almaty";
    timezone_db "iana-tzdb@2026a";
    period [@2024-01-01, @2028-01-01);
    source SyntheticCalendar;
    resource "resources/calendar-2024-2027.json";
    format "law.calendar/0.1";
    content_hash "sha256:dfd0181e1347cc2fd48b5fd81d27f3551cabae10eaefbf8b4dffb70bcbb3cd12";
}
deadline policy Days {
    start_count next_day;
    include_end true;
    roll next_working_day;
}
relation received(p: Person, on: Date);
relation submitted(p: Person);
rule Reply strict {
    for p: Person; for on: Date;
    when received(p, on);
    then duty File {
        bearer p;
        goal achievement {
            condition submitted(p);
            window [on, add_business_days(on, 2 business_day)];
        }
    };
}
```

## Frozen execution scene

| Facts / cut | Question | Answer |
|---|---|---|
| received 06.03, cut 11.03 | File | ACTIVE |
| received 06.03, cut 12.03, no performance facts | File | UNDETERMINED |
| same, not submitted | File | VIOLATED |
| same, submitted | File | SATISFIED |
| policy not chosen | positions | NON_EXECUTABLE, MISSING_POLICY |

```law
test "deadline includes window end day" {
    given {
        context {
            legal_time @2026-03-11;
            decision_time @2026-03-11T12:00:00+05:00;
            knowledge_time @2027-12-31T09:00:00+05:00;
            timezone "Asia/Almaty";
            deadline_policy Days;
        }
        assert received(entity_ref("urn:recipe:e-time:01:a"), @2026-03-06);
    }
    evaluate positions();
    expect position(File, ACTIVE);
}
```

```law
test "expired deadline without input" {
    given {
        context {
            legal_time @2026-03-12;
            decision_time @2026-03-12T09:00:00+05:00;
            knowledge_time @2027-12-31T09:00:00+05:00;
            timezone "Asia/Almaty";
            deadline_policy Days;
        }
        assert received(entity_ref("urn:recipe:e-time:01:a"), @2026-03-06);
    }
    evaluate positions();
    expect position(File, UNDETERMINED);
}
```

```law
test "established non-performance violates" {
    given {
        context {
            legal_time @2026-03-12;
            decision_time @2026-03-12T09:00:00+05:00;
            knowledge_time @2027-12-31T09:00:00+05:00;
            timezone "Asia/Almaty";
            deadline_policy Days;
        }
        assert received(entity_ref("urn:recipe:e-time:01:a"), @2026-03-06);
        assert not submitted(entity_ref("urn:recipe:e-time:01:a"));
    }
    evaluate positions();
    expect position(File, VIOLATED);
}
```

```law
test "established performance satisfies" {
    given {
        context {
            legal_time @2026-03-12;
            decision_time @2026-03-12T09:00:00+05:00;
            knowledge_time @2027-12-31T09:00:00+05:00;
            timezone "Asia/Almaty";
            deadline_policy Days;
        }
        assert received(entity_ref("urn:recipe:e-time:01:a"), @2026-03-06);
        assert submitted(entity_ref("urn:recipe:e-time:01:a"));
    }
    evaluate positions();
    expect position(File, SATISFIED);
}
```

```law
test "missing policy refuses positions" {
    given {
        context {
            legal_time @2026-03-10;
            decision_time @2026-03-10T09:00:00+05:00;
            knowledge_time @2027-12-31T09:00:00+05:00;
            timezone "Asia/Almaty";
        }
        assert received(entity_ref("urn:recipe:e-time:01:a"), @2026-03-06);
    }
    evaluate positions();
    expect evaluation_status == NON_EXECUTABLE;
    expect issue(MISSING_POLICY);
}
```

The calendar is synthetic: Mon–Fri, 9 March 2026 is a conventional non-working day; this is not an official calendar.

## Counterfactual

teaches removes roll from Days and requires E1307. The scene without deadline_policy pins a separate runtime rejection; expiry of the term without a negative fact is not declared a violation. `check` by itself does not guarantee correctness of arbitrary window-boundary arithmetic.

## Boundary

The event here is presented as a date in received. For an event instance with activation by a carrier, see [Present an event with a time](/recipes/n-package/event/); no instant inside the day is chosen. The units business_day and calendar_day are not interchangeable.

## Pitfall

A window from a term is executable; after the cutoff without facts the status is UNDETERMINED, with explicit non-filing VIOLATED. The as-of moment for statuses is the decision time, so every scene names its decision date explicitly; the law date only selects the law.