# Phase Handover — 9.2 Sports Center Member Management

> Mandatory starting point for Phase 9.3 — Coach & Staff Management.

## Overview

Phase 9.2 delivered **Member Management** on `sports-center-service` / `sports_center_db` (port **8006**, version **0.9.2.0**). Sports members, family/medical/emergency shells, membership assignment against the 9.1 catalog, cards/QR/digital passes, waivers, and document refs are in place. **Coach, attendance, and booking engines were not implemented.**

## Completed Scope

- Eight member-related aggregates + additive `memberships.member_id` / freeze window columns
- Status transition rules for memberships (`pending|active|frozen|suspended|expired|cancelled`)
- Card/QR generation shells and waiver sign workflow
- Validators, permissions, publish-only events
- Alembic `0003_phase_92_member_management`
- Tests + docs + registry/manifest updates

## Created Modules

| Module | Notes |
| --- | --- |
| Members | New profile aggregate |
| Family Members | New |
| Emergency Contacts | New |
| Medical Information | New (one per member) |
| Membership Cards | New |
| Digital Memberships | New |
| Waivers | New |
| Member Documents | New (Storage file refs) |
| Memberships | Extended assignment + status actions |

## Models

See `app/models/members.py` and additive fields on `Membership` in `app/models/foundation.py`.

## Repositories / Services / Validators

- `app/repositories/members.py`
- `app/services/members.py` (+ `MembershipService` assignment/status in `foundation.py`)
- `app/validators/members.py`

## Public APIs

Listed in [sports-center-phase-9-2.md](../sports-center-phase-9-2.md). Soft delete via `POST /{id}/delete` where applicable.

## Events

See phase doc. Legacy memberships created **without** `member_id` still emit `sports_center.member.created` for backward compatibility; real members emit it from `MemberService.create`.

## Database Changes

Additive only within `sports_center_db`. No Core/CRM/Loyalty/Communication schema changes. Catalog tables unchanged.

## Migration History

| Revision | Description |
| --- | --- |
| `0001_initial` | Phase 9.0 foundation |
| `0002_phase_91_membership_catalog` | Phase 9.1 catalog |
| `0003_phase_92_member_management` | Phase 9.2 members |

## Indexes / Constraints

- Unique `(tenant_id, member_number)`, `(tenant_id, card_number)`, `(tenant_id, pass_code)`
- Unique medical row per `(tenant_id, member_id)`
- Indexes on `(tenant_id, member_id)` for child tables

## Configuration

No new tenant configuration keys. Uses existing sports configuration shells.

## Connector Framework

Unchanged (interfaces only). Cards store QR/barcode payloads as strings — device adapters remain Phase 9.5+.

## Integration Points

| Platform | Phase 9.2 usage |
| --- | --- |
| Accounting | Contract only (`external_customer_ref`) |
| CRM | `external_crm_contact_ref` on Member/Membership |
| Loyalty | Not enrolled here |
| Communication | Not sending messages |
| Storage | `file_ref` / `document_file_ref` / `signature_ref` only |
| Identity | `external_user_ref` only |
| AI | Not used |

## Known Limitations

- No coach/attendance/booking engines
- Rule expression evaluation from catalog still deferred for complex eligibility
- Route-level permission enforcement still deferred (JWT + `X-Tenant-ID`)
- Events in-memory (no durable outbox yet)
- No frontend module UI
- Medical data is a privacy-aware shell, not an EHR

## Backward Compatibility

- Existing memberships remain valid with nullable `member_id`
- Legacy membership create without member still works
- Catalog APIs unchanged

## Architectural Decisions

No new ADR. Relies on ADR-014, ADR-001, ADR-003, ADR-006.

## Future Dependencies

Phase 9.3 Coach & Staff Management depends on this member foundation for assignments.

## Requirements for Phase 9.3

1. Read this handover + `docs/sports-center-phase-9-2.md` + ADR-014
2. Do not recreate member/catalog tables
3. Implement coaches/trainers/staff depth only as scoped
4. Keep sport-agnostic rules; keep connectors adapter-based
5. Do not own Accounting/CRM/Loyalty/Communication/Notification/Storage/Identity/AI

## Open Risks

- Member vs Platform Member vs Loyalty Member terminology confusion — keep refs explicit
- Medical confidentiality vs reporting needs in later phases
- Card QR payload format may need versioning when attendance devices come online

## Performance Notes

CRUD + tenant indexes only; no hot-path attendance writes.

## Security Notes

JWT + tenant isolation; soft deletes; audit trail; medical `is_confidential` flag; no binary secrets in DB.

## Testing Summary

Pytest: architecture (member models/permissions/events), members API flow, assign/isolation, invalid transitions, migration, docs, plus prior suites. All green at completion.

## Documentation Summary

- `docs/sports-center-phase-9-2.md`
- `docs/phase-handover/phase-9-2.md` (this file)
- Updates: progress, next-steps, roadmap, module-registry, glossary, manifests, SportsCenter phase area

## Next Phase Entry Point

Start Phase **9.3** from this document. Confirm scope in `docs/next-steps.md` before coding. Do not skip ahead.

## Completion Sign-Off

- [x] Quality gates passed
- [x] Tests green
- [x] Documentation updated
- [x] Progress / next-steps / registries / manifests updated
- [x] No unfinished claimed deliverables
