Theory
The grading checklist and stretch goals
Here is what "done and correct" means — grade yourself against it. Each line is something the track already taught; the capstone is assembling them without a guide.
Correctness — the feature works:
- A pending signer can decline with a reason; the document becomes
declined; the signer's declined state is shown on return. - Declining is single-use: a second decline (or a sign after a decline) changes zero rows and shows the terminal state, not an error.
- The document status and the audit event are written in one transaction — imagine killing the process mid-handler and confirm neither can land without the other.
Security & integrity — the constraints hold:
- The decline request carries no document id — the token resolves to exactly one signer row (verify a mangled token 404s).
- The
document.declinedaudit event is present,actorSigner, with a frozen message including the reason; it survives even if the document is later deleted (FK-free). - You did not weaken any existing guard — signing still works, the integrity banner still recomputes, owner routes are still owner-scoped.
Honesty — the framing is intact:
- The UI never implies a decline is more than it is. A decline is evidence that this signer refused these exact bytes at this time — not a legal instrument.
Stretch goals (each re-uses a different lesson, none required):
- Withdraw an invitation (owner-side): let the owner cancel a pending signer before they act — another
status='pending'-guarded update, another audit event. - Decline notifies the owner: reuse the
email.Senderinterface to email the owner when a signer declines (it prints to your console/logs). - A terminal-outcome banner on the document detail page summarising completed-vs-declined.
- A
GET /documents/{id}/audit.jsonowner-scoped endpoint returning the trail as JSON — the same authorization rule, a different representation.
Do the core task well before reaching for these. Three solid, correct pieces beat a sprawl of half-wired features — the same standard every lesson held.