Workspace Role Change
Add a change-role endpoint, its audit record and its client method to a workspace app.
Task
This workspace app has a backend with routes and services, a mock database, and a small frontend client. Members can be listed and invited. Add the missing feature: an endpoint that changes a member's role, the audit record for it, and the client method the web app will call. Read how the existing code works before you add to it.
Requirements
- run(seed, steps) builds a fresh database from seed.members, runs the steps in order, and resolves to {results, members, audit}: one result per step, then the final members and audit tables. A step is {actor, method, path, body} for a raw request, with the result {status, body}, or {actor, call, args} for a call through the frontend client, with the result {ok: true, value} or {ok: false, status, error}. Do not change the arguments.
- New: PATCH /members/:id/role with the body {role} changes a member's role and answers 200 {member}. Refusals, checked in this order: the actor is not an owner or an admin, 403 forbidden; role is not owner, admin or member, 400 invalid_role; there is no such member, 404 member_not_found; an admin is promoting someone to owner or changing an owner, 403 forbidden; the change would demote the only owner, 409 last_owner.
- Every role change writes one audit record: {action: "member.role_changed", actor, target, from, to}. The new role and the audit record are saved together or not at all. Setting a member to the role they already have answers 200 and writes nothing.
- New: the frontend client gets changeRole(memberId, role). It sends the request above and resolves to the updated member. It rejects the way the other client methods do.
- The existing behavior stays as it is: GET /members, POST /invites, 401 unauthorized for an unknown actor, 404 not_found for an unknown route, and 500 internal when something unexpected throws.
How you are graded
- Decomposition 15%
- Prompting the assistant 15%
- Verification 20%
- Judgment about AI output 15%
- Correctness 25%
- Communication 10%
Scores use evidence from your session. A short or incomplete session may not provide enough evidence for every skill. See a sample scorecard
Interview guidance
This workspace app has a backend, a mock database and a small frontend client. Add an endpoint that changes a member's role, write the audit record for it, and add the client method. Use the AI assistant however you like. Before you ask it for code, read how an existing feature writes to the database and tell me your design.
- AI is allowed and expected: your own Claude, OpenAI or Gemini key, or the free in-browser model.
- You are graded on how you drive and check the AI, not on how much you prompt.
- Run the checks; read what fails.
- A new requirement will arrive partway through.
- Too little AI use is reported as “not enough to grade”, never as a fail.
You will answer 7 debrief questions at the end
- What did you delegate to the AI, and why?
- Name one AI suggestion you rejected or changed, and why.
- Choose one block the AI helped write. Explain what each line does and which test verifies it.
- What is still risky, and what would you test or ship next?
- Which existing code did you model the feature on, and what did you copy from it?
- Which rule was the easiest to get wrong, and which step or check of yours covers it?
- Pick ten lines the assistant wrote and explain them one by one.