# Bottom Up Data Traceability using UI

1. [Step By Step Process](#id-1.-step-by-step-process)
2. [Demo Video](#id-2.-demo-video)

## 1. Step By Step Process

## Statistics Terminology

* Statistics **Definition** – a template which specifies schema/document fields, rules and formulas for creation of the Statistics.
* Statistics **Assessment** – a generated result/instance of the statistics (based on the **definition**) for a given collection of VC documents

### **1. Definition**

#### **1.1 List of statistics definitions and their statuses**

<figure><img src="https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-5b692b3d89fdf726a31afddab08c76e7ffab40f3%2F0%20(22).png?alt=media" alt=""><figcaption></figcaption></figure>

#### **1.2 New statistics definition**

Define new Statistics by specifying mandatory parameters:

* **Name** – the name of the statistic, this will be displayed in the statistics grid for users to choose from.
* **Policy** – the policy to which this statistic is related to. All data used in the statistics assessment will from documents produced by projects governed by this policy.

<figure><img src="https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-b95cda66cb2b64d5b136275549b9062c7aba84d1%2F1%20(24).png?alt=media" alt=""><figcaption></figcaption></figure>

<figure><img src="https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-ec40551d1d349ada25877694ec511a29db61a03c%2F2%20(26).png?alt=media" alt=""><figcaption></figcaption></figure>

#### **1.3 Configuration**

Statistics **definition** is configured via the corresponding configuration wizard.

![](https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-5bc82cf140e3038f66746c7b46140814cfea05df%2F3%20\(22\).png?alt=media)

**1.3.1 Generic configuration options**

![](https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-3d6c1f32f5a59914e93b699c9249af4a05afb6cf%2F4%20\(20\).png?alt=media)

**1.3.2 Specifying data schemas and fields**

To retrieve data from documents for use in the statistics Guardian relies on the schema and field specifications.

The main tool for their configuration is the “schema tree view” of the policy as shown below, which allows the identification of the needed fields by browsing and search.

![](https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-64b5c8002f8b8a4979b6444061b2dfbb9f28daae%2F5%20\(23\).png?alt=media)

**1.3.2.1 Search**

Field names and/or property names can be used in the search for lookup and identification of the target fields.

<figure><img src="https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-f9b0afe0f676498c0aa4373a80457d59ce51433c%2F6%20(22).png?alt=media" alt=""><figcaption></figcaption></figure>

**1.3.2.2 Selecting the fields**

Selecting a schema ‘box’ in the tree pop-ups a right-hand panel where the list of fields in the selected schema is displayed. The interface allows for the selection of multiple fields using checkboxes.

![](https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-ba762ea175fb4f8a2435ccf1aefdd88bc6c7528f%2F7%20\(22\).png?alt=media)

**Note: T*****he right-hand panel always shows fields from the parent (or top-level) schemas, which are directly used by Guardian Policies to generate documents. As sub-schemas do not map to their own stand-alone documents (they are embedded into the parent schemas), when a sub-schema is selected in the tree view the right hand-panel display also includes fields from the parent document for clarity.***

**1.3.2.3 Properties**

By default files are searched and displayed by description. Users can navigate to the **Select** **Properties** tab to switch to search and display by **Properties**.

<figure><img src="https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-f5eae5bec843814691de42ccd8cb8da9aa3885f1%2F8%20(22).png?alt=media" alt=""><figcaption></figcaption></figure>

***Note: for fields which do not have defined Properties the UI instead shows their description fields in greyed out text.***

**1.3.2.4 Document selection**

In addition to fields, for each target schema users must specify rules for selecting the target documents which conforms to the schemas. On the basis of these rules Guardian would compose 2 lists:

1. **Main** – these documents would be listed for user selection when creating Statistics Assessments. These are the documents that provide source data for statistics calculations.
2. **Relationships –** contains the list of dependent documents for the main document.

\
Document selections settings:\\

![](https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-fb3ece51e95c90fbbffc856753966b2423a2f4e3%2F9%20\(19\).png?alt=media)

1. **Main** – each document conforming to this schema will be placed into the **Main** list to be available for use in creating **Assessments.**

**Note:** *There must be at least a single schema marked as **Main.** Nominating more than one schema as **Main** for a single Assessment is not recommended.*

2. **Related** – if the schema is marked as related, for each **Main** document Guardian will find documents conforming to this schema and which are linked to the main document via the **relationships** field. The link does not have to be direct.
3. **Unrelated** – all documents of this schema will be considered to be related to each **Main** document irrespectively whether they are linked or not.

   *Example: there are 3 schemas: device, organization, Standard Registry (SR) which issued this policy. For our device statistics, fields from the organization and SR schemas are also required. In this case: device schema - Main, organisation schema - Related, and SR schema - unrelated.*

**1.3.3 Configuring formulas and scores**

The final step in statistics configuration is to configure the outputs of the statistics calculation.

![](https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-c728dbc04d3cec9875eea1dad08618f547d257dd%2F10%20\(20\).png?alt=media)

**1.3.3.1 Input Fields**

The list of source fields and schemas, selected in the previous steps, their short identifiers serve to simplify the use in formulas.\\

**1.3.3.2 Scores**

Questions with lists of possible answers and their matching numerical scores. The creator of the **Assessment** would be required to select one of the answers after reviewing the content of the fields in the target documents.

**Description –** text of the question

**Relationships –** the list of the dependent fields from **Input Fields.** These fields would be shown with the question when the assessment is created. This fields are here for clarity - to assist the user and make the selection and later scoring simpler.

**Options**

Answer options, the associated numerical values are used in the formula\[s].

![](https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-b94a4c50f46f3551fdab649fd2f1b720fd74e0e4%2F11%20\(17\).png?alt=media)

**1.3.3.3 Output Fields (Formulas)**

Output fields, which contain the results of the calculations as specified by the corresponding formulas. Guardian supports <https://mathjs.org/> syntax and Excel functions in the scope implemented in <https://formulajs.info/functions/>.

The values from the **ID** column (short names) of **Input Fields** and **Scores** can be used as variables in these formulas.

**1.3.3.4 Preview**

A sort of ‘dry-run’ mode for Formulas, useful for testing and validation of the correctness of formula specifications with test data.

![](https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-ed0783390d28aeab65de05953c8c8a6fd7c6a7a7%2F12%20\(15\).png?alt=media)

In this view users can manually fill out the test data and verify that the formula calculates the expected value.

![](https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-e3d241e82245ec2f73090bbf2892ae8d70cd38d8%2F13%20\(15\).png?alt=media)

The changes to the Statistics Definition are saved once the “Apply Changes” button is pressed.

![](https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-923c8d06485eacc2969abf3dc636c4ca93c8b2f5%2F14%20\(12\).png?alt=media)

### **2. Publication**

To enable the use of **Definitions** for creating **Assessments** of real data, they need to be published.

![](https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-9049ec9b647ab8abd43b0960663ce11695813f8f%2F15%20\(14\).png?alt=media)

### **3. Assessments**

#### **3.1 Creation**

Published **Definitions** can be used for creating an **Assessment** by pressing the **Create** button for the corresponding Statistics **Definition** which launches the **Assessment Wizard**.

![](https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-38df79e9a8e005d79f8feb27af41577f9e4f0cb2%2F16%20\(13\).png?alt=media)

**3.1.1 Target documents**

Users are presented with the choice of documents to select for the **Assessment**, this list contains all documents nominated as **Main** in the Statistics Definition.

![](https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-22ebbac37d52ab1776ec7549d9adc9325316ea48%2F17%20\(14\).png?alt=media)

**3.1.2 Preview**

The wizard then displays the relevant fields from the documents (which are configured in **Rules** in the Statistics Definition).

<figure><img src="https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-067253c791af54f5d878f1740abe6617cbfc86cf%2F18%20(12).png?alt=media" alt=""><figcaption></figcaption></figure>

**3.1.3 Scores**

Users are then required to ‘score’ the questions (if questions and options for answers were configured in the Statistics Definition).

![](https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-80029fa86179da3ef8e95ca7399ea8fe613513ad%2F19%20\(10\).png?alt=media)

**3.1.4 Statistics**

Guardian calculates and presents the Assessment result. To confirm, create, and publish the document users need to press the **Create** button.

![](https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-23bbe3b77bff4214da507bff6e833a3b5daa92d6%2F20%20\(7\).png?alt=media)

#### **3.2 Viewing**

Existing **Assessments** can be found in the corresponding grid.

<figure><img src="https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-7f153f4572b783780a3bdfdfe8b3bd0cd8edf1f5%2Fimage%20(690).png?alt=media" alt=""><figcaption></figcaption></figure>

<figure><img src="https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-dcc21b6d5a1826722705fe3a9246d076ae0d7d72%2Fimage%20(691).png?alt=media" alt=""><figcaption></figcaption></figure>

**3.2.1 General information**

Technical information about the selected Statistics, its Policy, Hedera Topic, Hedera message, the document, etc is presented in the **Overview** tab.

<figure><img src="https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-fe8f736f4db79b2c1a38ec19250d3502e30aa593%2Fimage%20(692).png?alt=media" alt=""><figcaption></figcaption></figure>

**3.2.2 Document**

The document content is viewable from the **Document** tab.

<figure><img src="https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-a53231851cff99a1314aaacdf3c22be2d5571606%2Fimage%20(693).png?alt=media" alt=""><figcaption></figcaption></figure>

**3.2.3 Links**

Related documents can be browsed and viewed from the **Relationships** tab.

<figure><img src="https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-cc71208ddb5755949356d7d3361c73252d40408b%2Fimage%20(694).png?alt=media" alt=""><figcaption></figcaption></figure>

The detailed view of the related document.

<figure><img src="https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-4df4e27329ca1075195edde9b64551c7735ee81f%2Fimage%20(695).png?alt=media" alt=""><figcaption></figcaption></figure>

### **4. Messages**

Example Hedera message on the publication of a new Statistics **Definition**

```
{
"id": "a4c14ad1-5ea4-41fd-99c1-cdaf9c334cbc"
"status": "ISSUE"
"type": "Policy-Statistic"
"action": "publish-policy-statistic"
"lang": "en-US"
"name": "Statistic Report"
"description": ""
"owner": "did:hedera:testnet:2vLnWwYDGAaG…xoWpmDr_0.0.4808747"
"uuid": "5dd4f7ff-5d8c-44fc-b89f-fc1c4c2fbc07"
"policyTopicId": "0.0.4932698"
"policyInstanceTopicId": "0.0.4933053"
"cid": "bafkreidefj5losvmads3l6qpcw4fidpitos72vorj4d4fxissmpllfk2hq"
"uri": "ipfs://bafkreidefj5losvmads3l6qpcw4fidpitos72vorj4d4fxissmpllfk2hq"
}
```

Example Hedera message on the publication of a new Statistics **Assessment**

```
{
"id": "0d2fc4c3-3c2a-42d6-9cc5-f5fe55807d52"
"status": "ISSUE"
"type": "VC-Document"
"action": "create-assessment-document"
"lang": "en-US"
"issuer": "did:hedera:testnet:5nGYw7gR...6ZiY2egeEKjf_0.0.4808747"
"relationships": ["1727800489.923243000","1727799087.616298000"]
"target": "1727800489.923243000"
"definition": "1727875229.008285000"
"cid": "bafkreigrylqfyzqifhloklsftmcw7obtqidx64vhti4hfmbnpbrnathuty"
"uri": "ipfs://bafkreigrylqfyzqifhloklsftmcw7obtqidx64vhti4hfmbnpbrnathuty"
}
```

## 2. Demo Video

[YouTube](https://youtu.be/tYLsr4rxw58?si=XNRvpap7aosnwuhh\&t=107)
