# AZ305: A condition inheritance can't store

Conditions that limit inheritance, and a link table's `where`, are worked out once and stored in the tree, so they give the same answer for everyone at any time. They can't read the clock (`now()`, `current_timestamp`, `current_date`, `current_time`, `localtime`, `localtimestamp`, `clock_timestamp()`, `statement_timestamp()`, `transaction_timestamp()`, `timeofday()`, `age(x)` with one argument, a date or time written `'now'`, `'today'`, `'tomorrow'` or `'yesterday'`), chance (`random()`, `random_normal()`, `gen_random_uuid()`, `uuidv4()`, `uuidv7()`), who asks or the session (`authz.uid()`, `authz.ctx()`, `authz.principal()`, `current_user`, `current_role`, `session_user`, `user`, `system_user`, `current_setting()`, `current_schema`, `current_catalog`, `current_database()`, `pg_backend_pid()`, `txid_current()`, `pg_current_xact_id()`, `current_schemas()`, `pg_my_temp_schema()`, `pg_trigger_depth()`, `pg_has_role()`, `has_*_privilege()` (`has_table_privilege()` and the others), `row_security_active()`, `inet_client_addr()`, `inet_client_port()`, `inet_server_addr()`, `inet_server_port()`, `nextval()`, `currval()`, `lastval()`), and a link table's `where` reads only that table's columns. Use a column the app sets (`archived`), or put the time or the user in a permission beside the inheritance.

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
  owner  : user = owner_id
  parent : folder = parent_id
  can view = owner or (parent.view and {created_at > now() - interval '1 day'})
```

```
line 6: {created_at > now() - interval '1 day'} can't limit inheritance: it depends on now, but inherited rights are stored, so the condition must give the same answer for every user at any time [AZ305]
```

## Fixed

```authz
app role app_user
type user = app.users
type folder = app.folders
  owner  : user = owner_id
  parent : folder = parent_id
  can view = owner or (parent.view and {not archived})
```
