feat(my-programs): time-scoped, audited emergency-contact access for leads#963
Open
jee7s wants to merge 1 commit into
Open
feat(my-programs): time-scoped, audited emergency-contact access for leads#963jee7s wants to merge 1 commit into
jee7s wants to merge 1 commit into
Conversation
…leads A program lead mentor gets a dedicated surface to view the emergency contacts of families in a program they lead — but only while the program is running (startAt−7d .. endAt+7d) and with every view recorded. - New route GET /api/my-programs/programs/[programId]/emergency-contacts (withAuth + explicit field shaping — the strict idiom, no new boundary/ registry change). Off-roster, out-of-window, or null-date programs return a clean 403 whose message explains the time-scoping; null dates fail closed. - Audit: one AuditLog READ row per household whose contacts are viewed (not per contact). Riding the existing AuditLog needs one additive enum value — AuditAction.READ (migration 20260709030000_lead_ec_access, expand-only). - UI: a "Contacts" subtab on /my-programs listing the caller's led programs; picking one shows the households + contacts in-window, or the 403 message. - Board/sysadmin are untouched (they keep /api/safety/emergency-contacts and its logging); this adds no audit noise there. - Window math is a pure, unit-tested helper with the buffer as a constant (not config). Route registered in routeAuthDrift EDGE_INCLUDE_ALLOWLIST (it reads ProgramParticipant to derive the roster households). Design: checkin-app/docs/designs/LEAD_EMERGENCY_CONTACT_ACCESS.md Deferred (noted in the doc): tightening the existing /api/programs/[id] lead EC exposure to the same window is a separate boundary PR. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RsD1zGYyqQFZaHT2wfkSB7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
A program lead mentor needs a family's emergency contacts to do their job — but
only while the program is running, only for their program's families, and with
a record that the access happened. Today a lead can pull emergency contacts for
any household in any program they lead, at any time, via the manage roster
(
GET /api/programs/[id]), with no time limit and no audit.This adds a dedicated, time-scoped, audited lead surface for emergency
contacts, per the product decision.
Design doc:
checkin-app/docs/designs/LEAD_EMERGENCY_CONTACT_ACCESS.md.Decisions
while
now ∈ [startAt−7d, endAt+7d]. The buffer is a constant(
LEAD_EC_ACCESS_BUFFER_DAYS), not config — a fixed policy, reviewed in code.out-of-window, or null-date requests; the message names the window and the rule.
AuditLogREAD row per household whose contacts areviewed (not per contact):
action=READ,tableName=EmergencyContact,affectedEntityId=householdId,secondaryAffectedEntity=programId./api/safety/emergency-contactsandits logging; no audit noise added there.
withAuth+ explicit field shaping(the strict idiom, like
/api/safetyand/api/household/emergency-contacts),so there is no
src/security/**change and it ships as one feature PR. Whya new route over extending
/api/programs/[id]: only a dedicated endpoint canreturn the clean per-program 403, and time-scoping the shared
their_program_householdsscope would perturb unrelated consumers and require aseparate boundary-isolation PR. (Tightening the existing manage-roster EC
exposure to the same window is called out as deferred in the doc.)
Data model
No new tables/columns. One additive enum value
AuditAction.READ(migration
20260709030000_lead_ec_access, expand-onlyALTER TYPE ... ADD VALUE).routeAuthDriftEDGE_INCLUDE_ALLOWLISTgains the new route (it readsProgramParticipantto derive the roster households).Surface
A Contacts subtab on
/my-programslists the caller's led programs; pickingone shows the households + emergency contacts when in-window, or the API's
time-scoping 403 message when not.
Testing
leadAccess.test.ts): window math — in-window, buffer edges (inclusive),just past the buffer, null-dates fail closed, plus the message builder.
myProgramsEmergencyContactsAPI.integration.test.ts, 6 cases):lead in-window sees the program's roster households' contacts and only those
(no internal fields leak); out-of-window → 403 w/ message; null dates → 403;
off-roster → 403; non-lead board member → 403 here but 200 on
/safety;one READ audit row per household per view (a 3-contact household → 1 row;
each view audited).
npx tsc --noEmitclean;eslint --max-warnings 0clean; full pre-commit suite(1714 tests) green under the shared-DB CI lock.
Deferred
Tightening
/api/programs/[id]'s lead EC exposure to the same window (a boundaryPR); core-volunteer access.
🤖 Generated with Claude Code