Skip to content

Add scheduled membership state reconciliation #53

Description

@Lakes41

Difficulty: Advanced

Type: Feature

Summary

Add a scheduled reconciliation job that updates persisted membership states when memberships expire or when indexed data falls out of sync.

Current Behaviour

Access checks can derive effective expiry at read time, but persisted membership records may still show stale states until another write occurs.

Expected Behaviour

The system should periodically reconcile stored membership state, expiry timestamps, and role-derived access state.

Suggested Implementation

Create a worker that scans memberships with expired expiresAt, updates their persisted state where appropriate, and writes audit or outbox events for state changes.

Files or Areas Likely Affected

  • apps/access-api/src/workers/
  • apps/access-api/src/services/memberService.ts
  • apps/access-api/prisma/schema.prisma
  • apps/access-api/src/services/auditService.ts
  • .env.example

Acceptance Criteria

  • Expired memberships can be found efficiently
  • Reconciliation updates stale active memberships to expired
  • Reconciliation is idempotent
  • Reconciliation emits safe audit or outbox events
  • Worker scheduling can be configured or manually invoked
  • Tests cover expired, active, suspended, and already-expired records

Additional Notes

Do not rely on reconciliation for correctness of access decisions. Read-time expiry checks should remain the first line of defence.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

GrantFox OSSGrantFox Open Source Sponsorship program tagMaybe RewardedIssue may qualify for a reward upon successful completion per campaign rulesOfficial CampaignCampaign: Official Campaign

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions