---
# System prepended metadata

title: Solid Interop Diagrams

---

# Solid Interop Diagrams

### Data Grant (Source)

```mermaid
classDiagram
  class DataGrant {
    shapeTree
    dataOwner
    accessMode
    scopeOfGrant
  }
  class AllInstancesGrant {
    hasDataRegistration
    ^inheritsFromGrant
  }
  class SelectedInstancesGrant {
    hasDataInstance
    ^inheritsFromGrant
  }
  class InheritInstancesGrant {
    hasDataRegistration
    inheritsFromGrant
  }
  DataGrant <|-- AllInstancesGrant
  DataGrant <|-- SelectedInstancesGrant
  DataGrant <|-- InheritInstancesGrant
```

```mermaid
erDiagram
  AllInstancesGrant }o--|| DataRegistration : hasDataRegistration
  DataRegistration ||--o{ DataInstance : contains
  
  SelectedInstancesGrant }o--|{ DataInstance : hasDataInstance
  DataInstance |o--o{ DataInstance : "ShapePathMagic™"
  
  InheritInstancesGrant }o--|| AllInstancesGrant : inheritsFromGrant
  InheritInstancesGrant }o--|| SelectedInstancesGrant : inheritsFromGrant
  InheritInstancesGrant }o--|| DataRegistration : hasDataRegistration
```

* Data Grant (source) always leads to Data Instances
  * Selected Instances Grant links directly to Data Instances (`interop:hasDataInstance`)
  * All Instances Grant links in-directly to Data Instances via Data Registration (`interop:hasDataRegistration`)
    * Data Registration links directly to Data Instances (`ldp:contains`)
* Inherit Instances Grant has all data instances from the same Data Registration.
* Data Registration for Inherit Instances Grant has to be in the same storage as Data Registration for the grant it inherits from.
* Inherit Instances Grant and the grant it inherits from have to link to one another (`interop:inheritsFromGrant` plus used in reverse)
* All Instances Grant and Inherit Instances Grant support creating new Data Instances, they are created Data Registration referenced with (`interop:hasDataRegistration`)

### Remote Data Grant (Delegated)

```mermaid
classDiagram
  class RemoteDataGrant {
    shapeTree
    accessMode
    scopeOfGrant
  }
  class SelectedRemoteGrant {
    hasDataGrant
    ^inheritsFromRemoteGrant
  }
  class AllRemoteFromAgentGrant {
    hasRemoteAgentDataRegistration
    ^inheritsFromRemoteGrant
  }
  class AllRemoteGrant {
    hasRemoteDataRegistration
    ^inheritsFromRemoteGrant
  }
  class InheritRemoteInstancesGrant {
    inheritsFromRemoteGrant
  }
  RemoteDataGrant <|-- SelectedRemoteGrant
  RemoteDataGrant <|-- AllRemoteFromAgentGrant
  RemoteDataGrant <|-- AllRemoteGrant
  RemoteDataGrant <|-- InheritRemoteInstancesGrant
```

```mermaid
erDiagram

  SelectedRemoteGrant }o--|{ DataGrant : hasDataGrant
  AllRemoteFromAgentGrant }o--|| RemoteAgentDataRegistration : hasRemoteAgentDataRegistration
  RemoteAgentDataRegistration }o--|{ DataGrant : satisfiesDataGrant

  RemoteDataRegistration ||--o{ RemoteAgentDataRegistration : hasRemoteAgentDataRegistration

  AllRemoteGrant  }o--|| RemoteDataRegistration : hasRemoteDataRegistration
  
  InheritRemoteInstancesGrant }o--|| SelectedRemoteGrant : inheritsFromGrant
  InheritRemoteInstancesGrant }o--|| AllRemoteFromAgentGrant : inheritsFromGrant
  InheritRemoteInstancesGrant }o--|| AllRemoteGrant : inheritsFromGrant

```

* Remote Data Grant always leads to Data Grant, in a way represents delegation to that source grant / those source grants

### Data Instance

This includes mostly implementation specific relations

Reverse of `inhertisFromGrant` is internally named `hasInheritingGrant[]`

```mermaid
erDiagram

  DataInstance }o--|{ InheritableGrant : "*dataGrant"
  InheritableGrant }|--o{ InheritInstancesGrant : inheritsFromGrant
  InheritableGrant }|--o{ InheritableRemoteGrant : "*viaRemoteDataGrant"
  InheritableRemoteGrant }|--o{ InheritRemoteInstancesGrant : inheritsFromGrant
  InheritInstancesGrant }|--o{ InheritRemoteInstancesGrant : "*viaRemoteDataGrant"
  DataInstance }o--|{ InheritInstancesGrant : "*dataGrant"
  
```

Parent data instance can create child data instances (for given *shape tree*).
When it does it, source data grant to be associated with child data instance can be found:
```
(parent) Data Instance - dataGrant
-> Inheritable Data Grant - hasInheritingDataGrant[shape tree]
-> Inherit Instances Grant
```

For InheritInstancesGrant (which has specific shape three), `viaRemoteDataGrant` can be found:
```
InehritInstancesGrant - inheritsFromGrant
-> Inheritable Data Grant - viaRemoteDataGrant
-> InheritableRemoteDataGrant - hasInheritingDataGrant[shape tree]
-> Inherit Remote Instances Grant
```


### Renaming ideas

* `:hasDataRegistration` --> `:forDataRegistration`
* `:hasDataInstance` --> `:forDataInstance`
* Remote* --> Delegated
* _* --> Source
* Data Registrastion --> Data Repository (has Data Instances) | Data Collection
* Remote Data Registration --> Data Registration (links to Data Grants) | Data Reference

## Major changes ideas

* Broader data structure for User Consent - AllRemote, AllRemoteFromAgent
* Narrower Remote Data Grants (delegated), always having specific source data grant - SelectedRemote (just one) 
  * folowing closer ZCAP-LD [`parentCapability`](https://w3c-ccg.github.io/zcap-ld/#terminology)
* Specific subclass for each scope, which would remove `scopeOfGrant`


# ZCAP-LD inspired delegation

```mermaid
erDiagram

  DataInstance }o--|{ SourceInheritableGrant : "*accessGrantedIn"
  SourceInheritableGrant }|--o{ SourceInheritInstancesGrant : inheritsFromGrant
  SourceInheritableGrant }|--o{ DelegatedInheritableGrant : delegationOfGrant
  DelegatedInheritableGrant }|--o{ DelegatedInheritInstancesGrant : inheritsFromDelegatedGrant
  SourceInheritInstancesGrant }|--o{ DelegatedInheritInstancesGrant : delegationOfGrant
  DataInstance }o--|{ SourceInheritInstancesGrant : "*accessGrantedIn"
  
```

```mermaid
erDiagram

SocialAgent ||--o{ Storage : "owner"
SourceDataGrant }o--|| SocialAgent : "dataOwner"
SourceDataGrant }o--|| Agent : "grantSubject"
DelegatedDataGrant }o--|| SourceDataGrant : "delegationOfGrant"
DelegatedDataGrant }o--|| SoftwareAgent : "grantSubject"
Storage ||--|| DataRegistration : "somePropertyChain"
DataRegistration ||--o{ SourceDataGrant : "hasDataRegistration"

```

* *Delegated Data Grant* always has explicit reference to one *Source Data Grant* using `interop:delegationOfGrant`.
* *Delegated Data Grant* doesn't need scope, it just delegates to *Source Data Grant* which has specific scope.
* Application (*Software Agent*) doesn't even know how User expressed the consent, it only knows what data it can access.
* Possibility: we could just reference *Source Data Grant* from *Delegated Data Grant* without giving subject access to it,
  *Delegated Data Grant* would include copy of all the information from *Source Data Grant* that subject needs. This
  would also allow for more granular control if we want to narrow down what can be accessed during delegation.
  
  
```mermaid
erDiagram

AgentRegistry ||--o{ SocialAgentRegistration : "hasRegistration"
SocialAgentRegistration ||--|| SocialAgentRegistration : "reciprocalRegistration"
AgentRegistry ||--o{ ApplicationRegistration : "hasRegistration"
SocialAgentRegistration ||--|| AccessGrant : "hasAccessGrant"
ApplicationRegistration ||--|| AccessGrant : "hasAccessGrant"
AccessGrant ||--|{ DataGrant : "hasDataGrant"

```

```mermaid
erDiagram

AccessConsentRegistry ||--o{ AccessConsent : "hasAccessConsent"
AccessConsent ||--|{ DataConsent : "hasDataConsent"

```


## Access Consent -> Access Grant (former Access Receipt)

NOTE: code uses Access Receipt but will change to Access Grant

Authorization Agent displays the consent screen using it's UI.
Since consent is given for the application, application can't
show the screen to give consent to itself.

1. User confirms consent on the consent screen
2. AA creates access consent with data consents
3. AA creates access grant based on access consent
  * for each data consent creates data grants

```mermaid
classDiagram
  class ReadableResource {
    iri
    factory
    fetchData()
    getObject()
    getObjectsArray()
  }
  class CRUDResource {
    draft
    update()
    delete()
  }
  ReadableResource <|-- CRUDResource
  class Container {
    newContained()
  }
  class ImmutableResource {
  
  }
```
