RFC-058: A Filling of a Hook's Open Term Can Name the Article the Hook Fires On

DraftPartially implemented
Depends on

Context

Awb article 4:13 sets the period within which an administrative body decides on an application:

  1. Een beschikking dient te worden gegeven binnen de bij wettelijk voorschrift bepaalde termijn of, bij het ontbreken van zulk een termijn, binnen een redelijke termijn na ontvangst van de aanvraag.
  2. De redelijke termijn is in ieder geval verstreken wanneer het bestuursorgaan binnen acht weken na ontvangst van de aanvraag geen beschikking heeft gegeven.

Paragraph 1 leaves the period to the special law, and paragraph 2 is the fallback. That is the shape of an open term (RFC-003) on a hook (RFC-007). 4:13 fires on every BESCHIKKING, whichever law gives it, and declares wettelijke_beslistermijn with a default of eight weeks after receipt. A special law that sets its own period fills the term with implements.

Take a fictional Subsidiewet voorbeeld with two decisions that both fall under 4:13. Article 1 grants a subsidy, and its period depends on the subsidy year. Article 3 settles it after a report, and its period depends on the number of projects. Each decision has a parameter the other lacks, and 4:13 knows neither.

Two problems stand in the way.

The parameters are filtered twice. A hook receives only the parameters its own article declares, so 4:13 gets datum_ontvangst and nothing else. An implementing article then receives the parameters it declares, chosen from what 4:13 has. subsidiejaar is gone by then, and the grant fails with Variable not found: subsidiejaar. The filtering is deliberate. It is least privilege: a hook or an implementation sees what it declares and not, say, the BSN of the case that happened to call it.

The second problem is that implements knows nothing of the firing. The implements index is keyed on the declaring law, article and term. Nothing in the lookup asks which article the hook fires on, so a filling meant for the grant would also run for the settlement, and for a building permit under another law.

A first version of this RFC answered both problems with the law of the decision, the host law. Under a hook only the host law filled the term, with the host’s parameters. That was too coarse in one direction and too strict in the other. Within one law, the grant and the settlement both fire 4:13 with different parameters, and a filling keyed on the law cannot tell them apart. And every filling from outside the host law stopped counting under a hook. That included a policy rule (beleidsregel) whose own hook article had its open term filled by another article of the same policy rule. Such bindings fell back to the default without a word. Execution policy of an administrative body also needs to fill a hook’s term in practice, for instance where policy decides whether a decision is taken under mandate (Awb 10:10).

Decision

A filling of an open term of a hook article may name the article the hook fires on, its host. With a host, the filling applies only while the hook fires on that article, and it receives its parameters from that article’s scope. Without a host, the filling fills the term wherever the article runs, as before, with the parameters of the hook article itself. A filling that names the host goes before one that names none.

# subsidiewet_voorbeeld, article 2 machine_readable: implements: - law: algemene_wet_voorbeeld article: '4:13' open_term: wettelijke_beslistermijn host: law: subsidiewet_voorbeeld article: '1'

In detail:

  • The field. host on an implements entry is an object with law (an $id) and article, the same pair implements uses for the article that declares the term. It arrived with schema v0.8.24; a file on an earlier version that uses it is refused by the schema and by the loader. The engine refuses a key that implements or a hook’s applies_to does not know, such as within, where it used to ignore one and leave it to the schema.
  • The host. The host is the article the hook fires on: the article that establishes the application for a hook on a submission, the article that gives the decision for a hook on a legal character. Its scope is what that article hands its hooks: its parameters, the findings given for the execution, and its resolved inputs. An input that only a filling naming the host reads is resolved before the hooks fire, because the engine resolves inputs only when something reads them (RFC-043). For post_actions the scope also holds the article’s outputs and those of the pre_actions hooks.
  • With a host. The filling is a candidate only while the hook fires on the article it names. It receives the parameters it declares, chosen from the host’s scope. It may come from any regulation: the law of the host, a policy rule, a regulation of another law. Outside that firing it is no candidate and leaves no record, because it was never offered. Called directly, outside any hook, the hook article never gets it.
  • Without a host. The filling is a candidate under every hook and outside one, exactly as an open term is filled anywhere else. It receives the parameters it declares, chosen from the hook article’s own parameters. A parameter that only the host has is not there. The implementation then fails with VariableNotFound, the error any implementation gets for a required parameter that is not in its scope, and an optional one is unknown (RFC-036). It does not quietly get a value.
  • Precedence. Under a hook the fillings that name the host come first, ranked among themselves, and then the fillings without a host, ranked among themselves. Within each group a conflict is resolved as for any open term: lex superior, then lex posterior, and an error when neither decides. The first filling in that order that gives a value fills the term. A filling that is silent for the case (null) passes the term on to the next. So does one held back because it reads the law it fills, and in the end the default applies.
  • Scope. A filling that names the host is checked against the host’s scope. The declaring law, the law of the host and a regulation of the territory of either need no scope check: the host is the article that applies to the case. A filling without a host is checked against the hook article’s parameters, as it is outside a hook.
  • Delegation gate. The gate and the version filter apply to both groups. A candidate whose regulatory_layer is not the delegation_type of the term is refused with a DelegationRefusal in the trace and the receipt. A policy rule that names the host is refused where the term demands a law, and the next candidate or the default applies.
  • A hook on a decision is not scoped to a law or article. It reacts to a kind of result (its legal character, decision type and stage) without knowing which articles produce it. Where something applies to one law or one article only, that article refers to it like any other provision; only the filling of an open term names its host. A hook on a submission keeps established_by (RFC-045), which says which application it reacts to.
  • Warnings for a host that cannot be right. A host that names the wrong thing does not fail: the filling never applies. That stays so, because the host may be in a regulation that is not loaded. Where the law of the host and the law of the hook article are loaded, just validate and the loader’s log warn about the mistakes that show in the regulation itself. They warn when that law has no article with that number, or when the hook never fires on the article. They also warn about a filling that asks for a required parameter the host does not hand the hook: not a parameter, input or open term of the host article, nor, for a hook that fires only after the actions, an output of that article or of a pre_actions hook on it. A host in a law that is not loaded gives no warning. None of this refuses a load.
  • Which article reads the host. While a hook runs, every route that reaches an article firing as a hook on the same decision belongs to that decision. A hook that reads the output of another hook on it gets that decision’s fillings. Another article of the hook law that is not itself a hook on the decision resolves its open terms as outside a hook.

Why

Benefits

The article is the unit that carries context. Each decision of a law has its own parameters, and the filling that needs them now says which decision it belongs to. The grant and the settlement of the Subsidiewet voorbeeld each get their own period, from their own data, under the same hook.

The context comes only where it is named. A filling without a host gets nothing it did not get before this RFC, and a filling that names a host gets the scope of exactly that article. Least privilege stays intact: the case data goes from the host to a filling that names it, and the hook and every other article still see only what they declare.

Fillings without a host work as they did before this RFC, and as an open term works outside a hook. A policy rule whose own article fills the term of its own hook article counts again, and so does a policy rule that fills the term of a hook article of a general law. The hook article run under a hook and the same article called directly give the same value, unless a filling names that firing.

Who may fill is the delegation gate’s question again, not a side effect of who fires the hook. The law of the host, a policy rule and another regulation all go through the same gate, so execution policy can fill a term where the law leaves it to policy, and is refused where the law demands a statutory provision.

Tradeoffs

  • A filling without a host applies everywhere the hook fires. A regulation that fills the term without naming a host changes the outcome for every decision the hook fires on. That is the meaning of an implements without a host, and the receipt names the regulation that filled the term. The first version of this RFC prevented it by letting only the host law fill; that also stopped the fillings that were meant to apply everywhere, which is the larger loss.
  • One more field to get right. A filling that needs the host’s data and forgets host fails with VariableNotFound under the hook, and so points at the omission. A filling that names a host by a wrong article number never applies, and the default does. That is a warning and not a refusal, because the host may be in another file, loaded later or not at all; the warning comes only once the law of the host is there.
  • A host on an article that fires no hook never applies. host means something only for an open term of a hook article. The loader cannot refuse it elsewhere either: whether the declaring article fires a hook is only known once its file is loaded.
  • Precedence over priority. A filling that names the host goes before a filling without one, also when the one without a host is of a higher layer. The more specific filling is the one the author wrote for this decision; lex superior and lex posterior rank fillings that are equally specific.

Choices considered for fillings without a host

The first version of this RFC let only the host law fill a hook’s term. With host available, the question was whether that restriction should stay for fillings that name no host.

Keep the restriction. Only the law of the decision could fill without naming a host, with the hook article’s parameters. That would keep the rule that loading one more rulework cannot change another law’s decision. But the reason for the restriction was the context: a foreign filling could not know which parameters a chain has. A filling without a host gets no host context either way, so that reason is gone. The restriction would still drop every filling from outside the host law, the policy rule that fills its own hook’s term included, and the hook article would give different values under a hook and when called directly.

Let every regulation fill, under the delegation gate (chosen). A filling without a host is an ordinary filling of the hook article’s open term. This restores what worked before the first version and keeps one rule for open terms, under a hook or not. Restricting who fills is the gate’s job, through delegation_type on the term.

What came from a corpus analyst’s sketch

A corpus analyst wrote a sketch of the same rule independently, with the field called within. One point of it was not in the first prototype and is now part of the decision: the warnings for a host that cannot be right. They stay warnings: a filling whose host is elsewhere is ignored there, as before, and only a mistake that can be seen in the regulation itself is reported. Two points were not taken over. The name within was not, because host was already the word for the article the hook fires on. Nor was a host on the applies_to of a hook, for the reason given under the decision: a hook on a decision is not scoped to a law or article.

The name of the field

host continues the vocabulary this RFC already used: the host is the article whose decision or application the hook fires on. It names the same pair as implements itself (law and article) and reads as “this filling belongs to that host”. applies_to was not a candidate, because a hook already uses it for a filter on the legal character or the submission, not for one article. origin and fired_by were considered. Origin suggests where the filling comes from rather than where it applies. Fired by reads as if the host were a hook as well.

Alternatives Considered

An override of the output of 4:13. The host replaces the output of 4:13 with overrides. That works, and it stays available. It models a departure (“in afwijking van”), however, while paragraph 1 delegates: the special law does not depart from 4:13, 4:13 points at it. The override also replaces the whole output, and the receipt then records a departure where the law describes a delegation.

Only the host law fills (the first version of this RFC). Described above. It cannot tell two articles of one law apart, and it drops every filling from outside the host law.

A slot on the open term naming the case data that goes through. 4:13 would list, say, passes: [subsidiejaar]. That puts the parameters of laws the Awb does not know into the Awb, which reverses the direction that makes inversion of control work.

Forward all of the host’s parameters to every filling. This removes the Variable not found error and drops least privilege with it. A regulation anywhere in the corpus would receive the full case of any decision the hook fires on.

Implementation Notes

The prototype in this RFC’s pull requests builds the decision above. The open questions at the end are not built.

  • The index. The implements index keeps, for each filling, the hosts every version of the law names. Which group a filling falls in is read from the version in force. A host added or dropped in a later version does not move a filling that is in force today. A version in force that fills the term only for another host, or not at all, fills nothing for this host on that date. The engine records nothing, as it records nothing for a hook that a version drops. An article that fills the term both for the host and without one falls back to the latter when the host’s scope does not admit it. RuleResolver::find_hook_implementations returns the fillings that name the host and then those that name none; ImplementationLookup::names_the_host tells the two apart, so the engine runs each in the scope it belongs to. find_implementations returns only fillings without a host.
  • Where the host comes from. fire_hooks records the host in the resolution context while a hook article runs: the articles that fire as hooks on the decision at either hook point, the law and number of the host article, and the parameters it hands its hooks. Afterwards, also after an error, the previous value comes back. Only the open terms of the hook articles read it. The output cache is keyed without the host, so nothing a call computes while a hook runs goes into it.
  • Where the lookup is used. For resolving the term, for deciding whether a term judged per case is filled (filled_terms), for noting the findings of a policy that fills one (note_policy_findings), and for the parameters to resolve before the hooks fire. That last one runs before the host’s scope is known, so it skips a scoped regulation of another territory that names the host.
  • Defaults read the article’s parameters. A default declares the parameters of the article its term belongs to. An optional parameter the caller left out is then unknown in the default, as it is in the article’s own actions (RFC-036), instead of a missing variable.
  • The corpus 4:13. It keeps its hook on the application and has the open term wettelijke_beslistermijn (paragraph 1), with paragraph 2 as its default, and an output uiterste_beslisdatum. No regulation in the corpus fills the term yet. The only filling in the repository, in the cel construct hook_open_term_host_fill, names its application as the host.
  • The warnings. They join the loader’s check of couplings between a hook and its host that cannot work as written (HookCouplingWarning), which also reports a pre_actions hook that reads an output of its host and an input that looks for the host’s output in the hook’s own law. It reports only what follows from the declarations, by exact name; guessing whether a name that looks alike was meant gave false positives. hook_coupling_warnings checks the hosts against the loaded set; the loader logs, with tracing::warn!, those that involve the law it just loaded, as the hook, the host or the filling, so every warning of the set appears whatever the order the laws arrive in. A law with a pre_actions hook has the whole set checked again, because its outputs reach other hooks on the same host. A warning already logged stays logged when a law loaded later resolves it. just validate prints them as WARN for the set it validates. The check reads the newest version of each law.
  • Not covered. decision_terms, which lists the open terms a decision may need for a form, does not walk hooks and is unchanged.

The warnings are pinned by the tests in load_check.rs, validate_cli.rs and the load-order test in resolver.rs, on the fictional rulework in tests/fixtures/hook_host/ and tests/fixtures/hook_coupling/. hook_host_checks.rs pins that a filling for a host that does not exist never applies, and that an unknown key is refused. Tests in packages/engine/tests/hook_host_implements.rs pin the rule on fictional rulework. Two articles of one law fire the same hook, and each gets the filling that names it, with its own parameter. A filling without a host applies to both, to a decision of another law and outside a hook. A filling that names the host goes before one without, and two fillings that name it are ranked by priority. A policy rule that names the host fills the term, and the delegation gate refuses it where the term demands a law. A filling without a host that asks for a parameter of the host fails with VariableNotFound. A regulation whose own article fills the term of its own hook article without a host counts, which is the case the first version broke. A filling for the host that is silent for the case passes the term on to the filling without a host, and the group of a filling follows the version in force.

Open questions

One layer for “wettelijk voorschrift”

delegation_type names one regulatory layer. “Bij wettelijk voorschrift bepaald” in 4:13 admits several (a wet, an AMvB, a ministeriële regeling, a verordening) and excludes a beleidsregel. The format cannot say that yet, so the fictional 4:13 in the tests declares no delegation_type. Until it can, a term like this one either admits every layer, a policy rule included, or admits only one.

Policy that belongs to the host

The first version of this RFC asked how the engine could know that a policy rule belongs to the host law, so that it could fill under the hook. With host the question no longer decides whether a policy rule can fill: it names the host, and the delegation gate decides whether its layer may. What stays open is whether the format should also say which law a policy rule executes, for instance through a structured legal_basis. The engine does not need that for this rule.

A host that names only the law, on implements

A host on implements names an article, never a law alone. A filling for every decision of one law would be useful where the decisions share the parameter it reads, with the warning on a missing parameter as the safety net for the ones that do not. It also raises a question of precedence this RFC does not answer: whether a filling for one article goes before a filling for its whole law, as one with a host goes before one without.

References

RegelRecht

An exploration into transparent, executable legislation, and one of the three projects in the starting selection of the Nederlandse Digitale Dienst.

Links

GitHub repository
How it works
Demo walkthrough
Stay informed
Roadmap (Dutch)
Documentation
Research
Basiswerk recht (Dutch)

Contact

regelrecht@minbzk.nl

Part of

Nederlandse Digitale Dienst
Ministry of Economic Affairs and Climate Policy