Access and evidence policies · Original fictional data · Free files and full answers
Reject requests whose only authorization exceeds the delegation-depth limit
The local policy permits at most one membership hop. At each request day consider exact-resource unexpired allows and all-depth denies. Return request_id,minimum_allow_depth only when some otherwise valid allow exists, no applicable deny exists, but every allow requires more than one hop. Public or direct allow depth is0. Sort request_id.
Use this fixed business case to build a checked CSV and a replayable SQL handoff. No account required. Scenario datasets are shared across related exercises; each exercise has its own decision and output contract.
Your output contract
- The local policy permits at most one membership hop. At each request day consider exact-resource unexpired allows and all-depth denies. Return request_id,minimum_allow_depth only when some otherwise valid allow exists, no applicable deny exists, but every allow requires more than one hop. Public or direct allow depth is0. Sort request_id.
- Return exactly the declared columns and order. Money uses integer cents; time and date units follow the task and field dictionary. NULL is unknown and differs from numeric zero.
- These are original fictional records and exercise policies. Scenario data may be shared with related tasks, whose decisions and output contracts differ.
Return columns exactly as request_id, minimum_allow_depth. Sort order follows the task. Output has 1 rows; an empty CSV field means NULL.
Source data
grants
10 source rows · Download grants CSV
| id INTEGER | principal TEXT | resource TEXT | effect TEXT | expires INTEGER | mask INTEGER |
|---|---|---|---|---|---|
| 1 | alice | docs | allow | 20 | 1 |
| 2 | team | docs | allow | 50 | 2 |
| 3 | alice | secret | deny | 50 | 3 |
| 4 | team | secret | allow | 50 | 1 |
| 5 | bob | docs | allow | 5 | 0 |
| 6 | reviewer | finance | allow | 50 | 2 |
| 7 | public | open | allow | 50 | 0 |
| 8 | team | old | allow | 8 | 1 |
| 9 | alice | finance | allow | 50 | 1 |
| 10 | alice | archive | allow | 50 | 1 |
members
3 source rows · Download members CSV
| member TEXT | parent TEXT |
|---|---|
| alice | team |
| bob | team |
| team | reviewer |
requests
8 source rows · Download requests CSV
| id INTEGER | user TEXT | resource TEXT | day INTEGER |
|---|---|---|---|
| 1 | alice | docs | 10 |
| 2 | alice | secret | 10 |
| 3 | bob | docs | 10 |
| 4 | bob | finance | 10 |
| 5 | alice | old | 10 |
| 6 | outsider | open | 10 |
| 7 | outsider | docs | 10 |
| 8 | alice | finance | 10 |
approvals
4 source rows · Download approvals CSV
| id INTEGER | requester TEXT | approver TEXT | resource TEXT |
|---|---|---|---|
| 1 | alice | alice | finance |
| 2 | alice | bob | finance |
| 3 | bob | outsider | docs |
| 4 | bob | alice | secret |
Field dictionary and schema
grants: id INTEGER — Stable source record identifier; not a row position. principal TEXT — Literal business key or category label. Match exactly and retain NULL where present. resource TEXT — Literal business key or category label. Match exactly and retain NULL where present. effect TEXT — Permission outcome, allow or deny. expires INTEGER — Expiry boundary; the goal declares whether equality is eligible. mask INTEGER — Privacy mask level; higher values require stricter masking. members: member TEXT — Literal business key or category label. Match exactly and retain NULL where present. parent TEXT — Immediate parent identifier, or NULL for a hierarchy root. requests: id INTEGER — Stable source record identifier; not a row position. user TEXT — Literal business key or category label. Match exactly and retain NULL where present. resource TEXT — Literal business key or category label. Match exactly and retain NULL where present. day INTEGER — Integer day index, or ISO YYYY-MM-DD date when stored as text; the task declares cutoff semantics. approvals: id INTEGER — Stable source record identifier; not a row position. requester TEXT — Literal business key or category label. Match exactly and retain NULL where present. approver TEXT — Literal business key or category label. Match exactly and retain NULL where present. resource TEXT — Literal business key or category label. Match exactly and retain NULL where present.
A method you can reuse
- The local policy permits at most one membership hop. At each request day consider exact-resource unexpired allows and all-depth denies. Return request_id,minimum_allow_depth only when some otherwise valid allow exists, no applicable deny exists, but every allow requires more than one hop. Public or direct allow depth is0. Sort request_id.
- For the first output record, request_id = 4; minimum_allow_depth = 2.
- Inspect the source grain, keys and ties. Compare each result column with the full worked SQL and expected CSV.
Watch for this wrong turn
Unbounded membership reachability alone would authorize deeply delegated resources that the one-hop policy deliberately rejects.
Run and check in SQLite
Your SQL runs locally in the existing SQLite worker. The checker compares every column, row, type, value and row order with this fixed output. It accepts equivalent SELECT or WITH queries. Browser storage keeps your SQL on this device when available.
Complete worked SQL and expected output
WITH RECURSIVE m(user,principal,depth,path) AS (SELECT DISTINCT user,user,0,','||user||',' FROM requests UNION ALL SELECT m.user,g.parent,m.depth+1,m.path||g.parent||',' FROM m JOIN members g ON g.member=m.principal WHERE instr(m.path,','||g.parent||',')=0) SELECT r.id request_id,MIN(CASE WHEN g.principal='public' THEN 0 ELSE m.depth END) minimum_allow_depth FROM requests r JOIN grants g ON g.resource=r.resource AND g.effect='allow' AND g.expires>r.day LEFT JOIN m ON m.user=r.user AND m.principal=g.principal WHERE (g.principal='public' OR m.principal IS NOT NULL) AND NOT EXISTS(SELECT 1 FROM grants z WHERE z.resource=r.resource AND z.effect='deny' AND z.expires>r.day AND (z.principal='public' OR EXISTS(SELECT 1 FROM m q WHERE q.user=r.user AND q.principal=z.principal))) GROUP BY r.id HAVING MIN(CASE WHEN g.principal='public' THEN 0 ELSE m.depth END)>1 ORDER BY r.id;
"request_id","minimum_allow_depth" "4","2"Reference SQL · Complete expected CSV · Empty answer CSV
Choose another SQL task · Original data exception cases · Larger workplace projects