# AZ810: A sync line keyed by a type it can't be keyed by

`sync app.docs : view by folder` keys each doc's readers by its folder: the doc's readers name the folder's key (`folder#view:7`), and the index says whose own keys that key inherits and what each folder gives itself, so a move rewrites no doc's readers. `by` names a type with a permission that inherits (`parent.view`) and that the synced permission reaches, through dots or as its own; who holds it must be a union of what gives it, without `and` or `not` between parts that depend on who asks. Name such a type, or leave out `by`: the readers are then copied from each folder above.

Reported when the policy is compiled: `rowstile check`, the editor, `rowstile dev`.

## The mistake

```authz
app role app_user
type user = app.users
type folder = app.folders
  parent : folder = parent_id
  owner : user = owner_id
  can view = owner or parent.view
type doc = app.docs
  owner : user = owner_id
  can view = owner
sync role sync_engine
sync app.docs : view by folder
```

```
line 11: sync app.docs ... by folder: what its readers hold reaches no permission of folder that inherits (as parent.view does), so there is nothing to key them by. Leave out by folder [AZ810]
```

## Fixed

```authz
app role app_user
type user = app.users
type folder = app.folders
  parent : folder = parent_id
  owner : user = owner_id
  can view = owner or parent.view
type doc = app.docs
  folder : folder = folder_id
  owner : user = owner_id
  can view = owner or folder.view
sync role sync_engine
sync app.docs : view by folder
```
