---
id: TST-PFM-SEC-153
title: Invitations database and service checks
kind: integration
product_area: platform
module: security
revision: 2
status: draft
source_sha:
  services-platform: ad3f6a6582843008ed0f5a17b131878d15829af1
repository: services-platform
files:
  - modules/security/tests/integration/services/persistence/invitations.integration.spec.js
implements: []
environment: local
implementation_state: implemented
latest_result: not-run
latest_run_at: null
latest_run_ref: null
conformance: not-verified
estimated_minutes: 3
isolation: Use the prepared test database and suite-owned fixture rows; retain shared seed records.
assertion_evidence:
  - provenance: test
    source: >-
      services-platform:modules/security/tests/integration/services/persistence/invitations.integration.spec.js#security
      persistence: create-invitation
  - provenance: test
    source: >-
      services-platform:modules/security/tests/integration/services/persistence/invitations.integration.spec.js#writes
      the invitation with the token hash, the expiry and the inviter, and never the raw token
  - provenance: test
    source: >-
      services-platform:modules/security/tests/integration/services/persistence/invitations.integration.spec.js#stamps
      sent_at only when the caller says the invitation has already left
  - provenance: test
    source: >-
      services-platform:modules/security/tests/integration/services/persistence/invitations.integration.spec.js#records
      where it was sent, so a later change of the user’s e-mail does not rewrite history
  - provenance: test
    source: >-
      services-platform:modules/security/tests/integration/services/persistence/invitations.integration.spec.js#records
      the named exemption an invitation was issued under, which the acceptance reads again
  - provenance: test
    source: >-
      services-platform:modules/security/tests/integration/services/persistence/invitations.integration.spec.js#leaves
      the exemption unset on an ordinary invitation, so only the named path skips the re-check
  - provenance: test
    source: >-
      services-platform:modules/security/tests/integration/services/persistence/invitations.integration.spec.js#refuses
      an exemption no closed list declares by user_invitations_widening_exemption_check
  - provenance: test
    source: >-
      services-platform:modules/security/tests/integration/services/persistence/invitations.integration.spec.js#accepts
      the declared exemption through the same insert, so the refusal above is the name and not the
      column
  - provenance: test
    source: >-
      services-platform:modules/security/tests/integration/services/persistence/invitations.integration.spec.js#refuses
      a second live invitation for the same user: one live invitation at a time, the database
      deciding
  - provenance: test
    source: >-
      services-platform:modules/security/tests/integration/services/persistence/invitations.integration.spec.js#lets
      a user have another invitation once the live one is out of the way, newest first
  - provenance: test
    source: >-
      services-platform:modules/security/tests/integration/services/persistence/invitations.integration.spec.js#refuses
      a token hash that already exists and an unknown user
  - provenance: test
    source: >-
      services-platform:modules/security/tests/integration/services/persistence/invitations.integration.spec.js#security
      persistence: find-invitation
  - provenance: test
    source: >-
      services-platform:modules/security/tests/integration/services/persistence/invitations.integration.spec.js#finds
      the seeded invitation by the hash of the seed's own raw token
  - provenance: test
    source: >-
      services-platform:modules/security/tests/integration/services/persistence/invitations.integration.spec.js#answers
      an unknown hash with undefined rather than an error
  - provenance: test
    source: >-
      services-platform:modules/security/tests/integration/services/persistence/invitations.integration.spec.js#answers
      a row in any state by hash, but only a live one to the live read
  - provenance: test
    source: >-
      services-platform:modules/security/tests/integration/services/persistence/invitations.integration.spec.js#lists
      only a user's outstanding invitation, and nothing once it has expired
  - provenance: test
    source: >-
      services-platform:modules/security/tests/integration/services/persistence/invitations.integration.spec.js#security
      persistence: accept-invitation
  - provenance: test
    source: >-
      services-platform:modules/security/tests/integration/services/persistence/invitations.integration.spec.js#stamps
      accepted_at on a live invitation and answers the accepted row
  - provenance: test
    source: >-
      services-platform:modules/security/tests/integration/services/persistence/invitations.integration.spec.js#spends
      the token once: a second acceptance of the same invitation answers undefined
  - provenance: test
    source: >-
      services-platform:modules/security/tests/integration/services/persistence/invitations.integration.spec.js#lets
      exactly one of two concurrent acceptances win, the database deciding
  - provenance: test
    source: >-
      services-platform:modules/security/tests/integration/services/persistence/invitations.integration.spec.js#refuses
      an expired, a revoked, a superseded and an unknown invitation, changing nothing
  - provenance: test
    source: >-
      services-platform:modules/security/tests/integration/services/persistence/invitations.integration.spec.js#security
      persistence: mark-invitation-sent
  - provenance: test
    source: >-
      services-platform:modules/security/tests/integration/services/persistence/invitations.integration.spec.js#stamps
      sent_at on the invitation and answers it without the token hash; an unknown invitation answers
      undefined
  - provenance: test
    source: >-
      services-platform:modules/security/tests/integration/services/persistence/invitations.integration.spec.js#counts
      the send as an attempt, and counts a resend again
  - provenance: test
    source: >-
      services-platform:modules/security/tests/integration/services/persistence/invitations.integration.spec.js#security
      persistence: record-invitation-attempt
  - provenance: test
    source: >-
      services-platform:modules/security/tests/integration/services/persistence/invitations.integration.spec.js#counts
      each presentation of the token against the row
  - provenance: test
    source: >-
      services-platform:modules/security/tests/integration/services/persistence/invitations.integration.spec.js#counts
      concurrent presentations separately, each against the row it read
  - provenance: test
    source: >-
      services-platform:modules/security/tests/integration/services/persistence/invitations.integration.spec.js#counts
      a presentation of a spent invitation too, and never changes its state
  - provenance: test
    source: >-
      services-platform:modules/security/tests/integration/services/persistence/invitations.integration.spec.js#does
      nothing for an unknown invitation rather than failing
  - provenance: test
    source: >-
      services-platform:modules/security/tests/integration/services/persistence/invitations.integration.spec.js#security
      persistence: record-invitation-delivery
  - provenance: test
    source: >-
      services-platform:modules/security/tests/integration/services/persistence/invitations.integration.spec.js#writes
      the outcome and its reason on the invitation, and answers the record without the token hash
  - provenance: test
    source: >-
      services-platform:modules/security/tests/integration/services/persistence/invitations.integration.spec.js#records
      an outcome with no reason as no reason, not as the last one
  - provenance: test
    source: >-
      services-platform:modules/security/tests/integration/services/persistence/invitations.integration.spec.js#records
      the outcome of an invitation that is no longer live, which is the one worth reading
  - provenance: test
    source: >-
      services-platform:modules/security/tests/integration/services/persistence/invitations.integration.spec.js#answers
      nothing for an unknown invitation rather than failing
  - provenance: test
    source: >-
      services-platform:modules/security/tests/integration/services/persistence/invitations.integration.spec.js#security
      persistence: revoke-invitations
  - provenance: test
    source: >-
      services-platform:modules/security/tests/integration/services/persistence/invitations.integration.spec.js#revokes
      the outstanding invitation of the user, naming who revoked it
  - provenance: test
    source: >-
      services-platform:modules/security/tests/integration/services/persistence/invitations.integration.spec.js#answers
      an empty list the second time, keeping the first revocation moment
  - provenance: test
    source: >-
      services-platform:modules/security/tests/integration/services/persistence/invitations.integration.spec.js#leaves
      an accepted invitation accepted and an expired one alone
  - provenance: test
    source: >-
      services-platform:modules/security/tests/integration/services/persistence/invitations.integration.spec.js#answers
      an empty list for a user with no invitations at all
  - provenance: test
    source: >-
      services-platform:modules/security/tests/integration/services/persistence/invitations.integration.spec.js#security
      persistence: supersede-invitations
  - provenance: test
    source: >-
      services-platform:modules/security/tests/integration/services/persistence/invitations.integration.spec.js#supersedes
      the outstanding invitations so the old token stops working, leaving a new one live
  - provenance: test
    source: >-
      services-platform:modules/security/tests/integration/services/persistence/invitations.integration.spec.js#leaves
      an invitation that already left the live state as it was
dependency_evidence: >-
  The prepared PostgreSQL database supplies the persisted fixtures and constraints exercised here.
  The file declares no substituted collaborators.
evidence:
  - >-
    services-platform:modules/security/tests/integration/services/persistence/invitations.integration.spec.js
  - >-
    Static review at the recorded source revision; executable results remain not-run and conformance
    remains not-verified.
binding_note: >-
  The file has no scenario binding established by this examination. Its executable checks remain
  registered without assigning them broader acceptance coverage.
examiner: codex
examined_at: '2026-10-23'
final_text: OpenAI
dependency_review:
  provenance: test
  source: >-
    services-platform:modules/security/tests/integration/services/persistence/invitations.integration.spec.js
  explicit_no_doubles: true
  identified_double_boundaries: []
---
# Invitations database and service checks

## Verification Boundary

The file exercises database or service behavior through the local integration harness. The assertion references identify the source checks for invitations.

## What This Suite Proves

The file supplies executable engineering checks for the named subject. No complete acceptance scenario is inferred from the file’s existence.

## What It Does Not Prove

This examination does not run the suite. Passing behavior, deployed conformance and the behavior of substituted dependencies require separate execution evidence.

## Real Dependencies and Test Doubles

The prepared PostgreSQL database supplies the persisted fixtures and constraints exercised here. The file declares no substituted collaborators.

## Must Not Be Doubled

Keep the queried database, applicable constraints and transaction boundaries real. Provider substitutes cannot establish delivery, cloud execution or cross-service recovery.
