Why you should code your COVID-19 policies and laws

TJ Harrop
5 min readMar 23, 2020

If you’re a Government or corporation creating new policies, regulations, or even laws for COVID-19, rules as code presents a whole bunch of benefits.

What is Rules as Code?

Rules are policies, business rules, regulations, and in Government organisations they can be the actual law. Nearly every rule written ends up being interpreted in to systems, websites, apps, or connected devices.

Rules as Code is an approach that acknowledges this, and rather than writing a document which needs human interpretation, creates actual logical rules that other systems can interact with directly (an API). It’s also a process; a ‘tech person’ and a ‘rules person’ work together to create the rules in the first place.

What does all of this have to do with COVID-19?

During the coronavirus pandemic of 2020, we have already seen companies adapt to a work-from-home model, and Governments introduce new laws to help stop the virus spreading. All of these new rules have 4 things in common:

  • It’s 2020, so they will be programmed in to apps, systems, and websites
  • They’re being created rapidly
  • They will change to react to the changing pandemic environment
  • In the future, they will lessen, then eventually stop completely

Benefits of the Rules as Code approach

Rules as code helps us avoid issues relating to all 4 of those themes.

Make your rules system-friendly from day 1

It’s 2020, so they will be programmed in to apps, systems, and websites.

With rules as code, you can create good rules faster. The old process involved a rules person writing rules and when they were finished, the tech people could step in. Even if a rules engine was made, it still didn’t happen until afterwards. This meant that there were oversights in the rules which made them harder to create systems for. There’s an example on my medium of a rule we coded that involved a person being over 4.5 years old — think on that. Oversights like these create work for people, and delays for projects. In a rushed environment, we don’t have that time.

Avoid delays and re-work for rules people

The rules are being created rapidly

Using a platform like openfisca, rules can be coded in minutes or hours. Once coded, we can use them to avoid accidental loopholes, gaps, or dead-ends. By integrating the person coding the rules in to the team making the rules, not only do we gain a mountain of time efficiencies, we also introduce the ability to test/QA that the rules work as intended. Openfisca’s rules engine, like some other rules engines, works off scenarios. The automated testing functionality in the platform lets you create as many ‘scenarios’ as you like, to see what the results of the rules would be. In the old process this was done manually, by the team writing the rules often trying to imagine the gaps, edge-cases, or ‘hacks’ and writing confusing sentences to close them. By running automated scenarios against our rules, we can:

  • See how any new rules might accidentally ‘break’ those already in the policy
  • Create scenario’s for those ‘edge cases’ to check the result
  • Trace the route of an unexpected result, and ‘mend’ the algorithm
  • Use quant data to generate models, predictions, and reports

And for tech people

In an environment where you need to launch a new set of rules (and the products which consume them) in very little time, the people making the apps, websites, and systems which need to know what the rules are need to start writing code as soon as possible. There isn’t time to wait for the policies and laws to be finalised.

With the rules as code approach, those developers can be given an API schema on day 1, as it comes bundled with the platform. They can then start working on how to build, package, and send the scenario, and then display the results. The fact that the specifics of the rules aren’t finished makes sweet little difference.

This means that, instead of waiting for rules to be finished, developers can work in parallel to your rule-makers and rule-coders. This can save a lot of time, and save re-work where temporary assumptions had to be made.

You don’t need to re-work all the products when the rules change

They will change to react to the changing pandemic environment

With time, the rules will change. They might get stricter, less strict, or work at different hours. By using a standardised template for the scenarios, even if there are 100 apps and websites consuming the rules, we only need to make one change to update them all.

Example — The Government of Sanitiser Town want to implement a new rule saying that people can only drive at certain times. The rules are coded, as Sanitiser Town is very forward thinking (albeit a bit authoritarian, too). The local companies follow, and the API is used by uber, 10 logistic companies, and a car-sharing startup, who program it in to their system to stop their 100 cars from used at no-drive times.

Sanitiser Town is now changing the rules. You can now drive at different hours. They change their API, and none of the above consumers need to do anything. They keep sending the same scenario, just the responses change.

In a constantly changing environment, a lot of rules will be in a constant state of flux. Without a rules as code rules engine, this potentially represents a huge amount of rework.

Rules as code platforms are set up for reform

In the future, they will lessen, then eventually stop completely

We know the rules will change a lot, and as described above we can avoid the rework. Using the same principles we can avoid the delayed process of dissemination when the rules change. You see, when rules are interpreted, not only might they be misunderstood, they also only represent a point in time. Platforms like openfisca are built with reformation in mind, and all scenarios are run against a point in time. In our example, when the rule is lifted on the driving ban, all systems which use that rule are now up to date, too. The law change could be applied instantly, whereas it might have taken weeks to disseminate that information previously. Depending on the rules, this could help to stimulate the economy instantly, re-open businesses, or even avoid accidental criminal proceedings.

In summary, rules as code is a better way to create and manage rules — especially for Governments. It solves a list of things that make it hard to create, manage, and decommission rules. It also helps your work quickly, with quality assurance — the holy grail of combinations.

Whilst we might ‘get away with’ the problems we face as rule-makers in our business-as-usual, those problems are amplified by something like COVID-19, and approaches like this are suddenly a lot more valuable.

If you’re interested in using openfisca, I’d recommend looking at openfisca.org. I’d also recommend looking in to Legalese by Meng Weng Wong and following the blog of Pia Andrews at pipka.org

--

--

TJ Harrop

RegTech Product guy. Currently NSW Government. Prev: UK Gov, Jaguar Land Rover, Apple & more stuff. Been around the block. Ex digi lecturer. Designers can code!