OpenBook
  • Problems
  • Tracks
  • How it works
  • Pricing
Start practicingSign In
Problems/Auth & Permissions

29. Debug: Permission Cache Never Invalidates

Hard

A permissions module caches each user's rights, and a demoted admin keeps them. Fix it, then add a TTL, per-organisation scoping and role-wide revocation without throwing the cache away.

55 minute budget0.0% acceptancedebugging · caching · invalidation · multi-tenant

How this problem works

A small TypeScript library with a bug. Part 1: make the failing tests pass without touching tests/. Parts 2 to 4 unlock in order as each part's public tests pass. In a mock interview the product owner asks for a plan before each part, and the grader reads your answer.

  1. 1The demoted admin
  2. 2Entries that expire
  3. 3One cache, many organisations
  4. 4Role-wide changes

Part 1: The demoted admin

  1. 01Support reports that Dana was demoted from admin to viewer an hour ago and can still delete projects. Her profile page, which lists her permissions, already shows viewer.
  2. 02Any change to a user's roles (assign, remove, replace) must take effect on the very next check and the very next permission list.
  3. 03Keep the cache: a user whose roles did not change is served from it, and one user's change must not drop anyone else's cached permissions. stats() counts the lookups.
  4. 04The wildcard rules in grants.ts are correct today ("docs:*" covers everything under docs:, not docs itself or docsx:); do not change them.

What the hidden tests check in Part 1

  • Promotions, demotions and role replacements all reach both can() and permissionsOf() at once.
  • A change for one user leaves every other user's cache entry in place.
  • Wildcards keep working through the service, and returned lists cannot change the cache.
  • Unknown roles are rejected and leave the user's roles as they were.

Hints for Parts 2 to 4 appear in the workspace as each part unlocks.

Sign in to start

Attempts, files and transcripts are saved to your account so the grader can review how you worked.

Sign inCreate an account
OpenBook

Practice for interviews where you build a feature with an AI assistant.

Early preview. Problems, grading and the interviewer are still changing.

Practice

  • Problems
  • Tracks
  • How it works
  • Pricing

Legal

  • Terms
  • Privacy
© 2026 OpenBook.