0.213.0 • Published 2 years ago

@signatu/policyengine v0.213.0

Weekly downloads
-
License
SEE LICENSE IN LI...
Repository
-
Last release
2 years ago

Policy Engine

The goal of the new engine is to build a robust, safe, extensible and maintainable Policy engine that can support multiple languages and output formats.

The new engine will be built using TypeScript to leverage compile-time type safety. The engine will be built to be run either on the server under node.js, or in the browser.

Design

A diagram is maintained at Draw.io

Design

Concepts

A Policy is a representation of the Privacy Policy the user has created by answering Questions. The answers will result in one or more PolicyClause, of the following type:

  • Pre-defined static clauses
  • Pre-defined clauses from a mutually exclusive list, including possible "specify..." input.
  • Pre-defined clauses from multiple selections from a list, including possible "specify..." input.
  • Free-text input

A PolicySection represents a section that considers a certain topic, e.g., "Transfer of Data". Both PolicySection and PolicyClause implements the PolicyElement interface. A Policy is hence an ordered list of objects that implement PolicyElement.

A PolicyGenerator will generate a PolicyDocument from a given Policy. Typically there will be different PolicyGenerator implementations for the different output formats, and possibly languages.

Multiple languages and outputs

All the predefined clauses has a text in controlled English language that serves as the "master" text. All other representations (e.g., plain language German, legal language French) are considered derivatives of this controlled text, and should mirror its meaning as closely as possible.

The user-specified input will as a rule not be provided in a controlled English, hence it may require translation to allow for output in other formats.

Design

Here we'll write up the general flow of alternative options. There are three complicating factors:

  1. Each question can result in different clauses depending on the option the user chooses
  2. Clauses can be output in different languages and formats (e.g., pictures)
  3. Clauses can include user-specified input texts, written in a non-controlled, natural language (e.g., German).

Basics

The PolicyElement corresponds to a specific option for a Question, referencing user-specified input through a UserInput object. A PolicyElement will have a set of PolicyContent objects associated with each option, one for each language and potentially other types as well (e.g., pictures).

Scenarios

Create the questionnaire

The Questionnaire is structured as an ordered list of Sections, who all have an ordered list of Questions. Each Question option has a single PolicyElement associated with it, specifically a PolicyClause. The masterText is the controlled English for the clause.

To add actual content to the PolicyElement, one or more PolicyContent is added to the PolicyElement. For example, a TextContent object having language: en can be added to make an English plaintext version of the clause.

Answer a questionnaire”

Each Question is presented to the user. When a particular option is chosen, it is connected to a particular PolicyElement, and the PolicyElement is added to the Policy. If the PolicyElement requiresInput, then collect input from the user, and add that to the Policy as well. The UserInput will reference the PolicyElement it contains input for. This will be used by the PolicyGenerator.

Generate a policy

A PolicyGenerator will create output based on a Policy and some parameters, such as the language, type of output (text, pictures, etc) and so on.

The generation is pretty straightforward:

  1. For each PolicyElement:
  • Get the correct associated PolicyContent object. When generating a text-based policy in English, for example, the right object would be a TextContent having language: en.
  • If the PolicyContent requires/has input, get the associated UserInput object and provide the generate() method.
  1. Combine the output of each PolicyElement in sequence into the final PolicyDocument.
  2. Repeat for different parameters (e.g., language).

User input

Some questions require the user to "specify" further - e.g., the type of processing, the retainment time for data, and so on. This input is merged into the PolicyContent from PolicyElement. Note that a PolicyElement can have multiple PolicyContent - different languages, different formats (icon, speech, video), so we need to be able to track multiple UserInput for each PolicyElement.

We want the PolicyElement and PolicyContent objects to be the same across different Policies, so the current thinking is to provide UserInput[] to a PolicyContent.generate() function.

We'll use Mustache to render user input. All UserInput objects have a given name, and that name is substituted for {{name}} in the PolicyContent text.

Metadata

Some of the PolicyContent are template strings - e.g., "{{controller.name}} processes data in the US". The meta data may be in different languages and formats, too. Meta-data is also handled with Mustache, where the Policy metaData is passed. If the text contains e.g., {{controller.name}}, then we expect meta data to have an object controller with a property name.

Generate a clause for an external service

E.g., Google Analytics. This is equivalent to the others - an ExternalService object (which implements PolicyElement) is added to the Policy. The appropriate PolicyContent objects are added to the ExternalService - e.g., IconContent .

Discussion

It would be beneficial of two PolicyDocuments containing the same PolicyElement can be said to be legally equivalent for that particular area, and that the legal consequences are similar. This may be difficult in practice, but if possible, it would ease reasoning over policies, finding similar policies and so on.

Open Questions

  • Should UserInput just be a class implementing PolicyContent?
  • Should the generate() method be moved out of the PolicyContent interface? How do we control generation to different formats - e.g., plain text, HTML, JSON, XML, PNG, etc?
  • Do we need to separate PolicySection and PolicyClause? Can't both of them just be a PolicyElement?

Answered Questions

  • How to associate the UserInput without creating a new PolicyElement for each Policy? => associate it with both the Policy and the PolicyElement (one way only). Hence when generating a policy, we keep track of the input for all the PolicyElements.
0.213.0

2 years ago

0.209.0

3 years ago

0.207.0

3 years ago

0.208.0

3 years ago

0.205.0

3 years ago

0.202.6

3 years ago

0.203.1

3 years ago

0.202.5

3 years ago

0.202.4

3 years ago

0.202.1

3 years ago

0.202.0

3 years ago

0.112.0

4 years ago

0.111.0

4 years ago

0.58.0

5 years ago

0.57.3

5 years ago

0.57.2

5 years ago

0.57.1

5 years ago

0.56.1

5 years ago

0.56.0

5 years ago

0.55.3

5 years ago

0.55.1

5 years ago

0.55.0

5 years ago

0.54.4

5 years ago

0.54.1

5 years ago

0.53.0

5 years ago

0.52.0

5 years ago

0.51.5

5 years ago

0.51.3

5 years ago

0.51.2

5 years ago

0.51.0

5 years ago

0.50.17

5 years ago

0.50.16

5 years ago

0.50.7

5 years ago

0.50.5

5 years ago

0.50.4

5 years ago

0.50.2

5 years ago

0.50.1

5 years ago

0.50.0

5 years ago

0.49.10

5 years ago

0.49.9

5 years ago

0.49.5

5 years ago

0.49.3

5 years ago

0.49.0

5 years ago

0.48.0

5 years ago

0.47.0

5 years ago

0.46.0

5 years ago

0.45.2

5 years ago

0.45.1

5 years ago

0.45.0

5 years ago

0.44.0

5 years ago

0.43.0

5 years ago

0.42.0

5 years ago

0.41.0

5 years ago

0.40.0

5 years ago

0.39.0

5 years ago

0.38.0

5 years ago

0.37.0

5 years ago

0.36.0

5 years ago

0.35.1

5 years ago

0.35.0

5 years ago

0.34.4

5 years ago

0.34.1

5 years ago

0.34.0

5 years ago

0.33.0

5 years ago

0.32.0

5 years ago

0.31.10

5 years ago

0.31.8

5 years ago

0.31.0

5 years ago

0.30.1

5 years ago

0.29.0

5 years ago

0.28.2

5 years ago

0.28.0

5 years ago

0.26.4

5 years ago

0.25.2

5 years ago

0.24.1

5 years ago

0.24.0

5 years ago

0.22.1

5 years ago

0.20.15

5 years ago

0.20.11

5 years ago

0.20.8

5 years ago

0.20.7

5 years ago

0.20.4

5 years ago

0.20.3

5 years ago

0.17.0

6 years ago

0.16.0

6 years ago

0.15.0

6 years ago

0.13.0

6 years ago

0.12.2

6 years ago

0.12.1

6 years ago

0.12.0

6 years ago

0.10.0

6 years ago

0.9.5

6 years ago

0.9.4

6 years ago

0.9.3

6 years ago

0.9.2

6 years ago

0.9.1

6 years ago

0.9.0

6 years ago

0.8.2

6 years ago

0.8.0

6 years ago

0.7.3

6 years ago

0.7.2

6 years ago

0.7.1

6 years ago

0.7.0

6 years ago

0.6.1

6 years ago

0.6.0

6 years ago

0.5.0

6 years ago

0.4.0

6 years ago

0.3.0

6 years ago

0.2.4

6 years ago

0.2.3

6 years ago

0.2.1

6 years ago

0.2.0

6 years ago

0.1.655

6 years ago

0.1.654

6 years ago

0.1.653

6 years ago

0.1.652

6 years ago

0.1.651

6 years ago

0.1.650

6 years ago

0.1.649

6 years ago

0.1.648

6 years ago

0.1.647

6 years ago

0.1.646

6 years ago

0.1.645

6 years ago

0.1.644

6 years ago

0.1.643

6 years ago

0.1.642

6 years ago

0.1.641

6 years ago

0.1.640

6 years ago