/**
 * Closed-set catalogue for `Person.source` per
 * [ADR-0026 §"Confirmation"](../../../../../docs/decisions/0026-person-user-portal-data-model.md).
 *
 * Defense in depth, same posture as STRUCTURE_KINDS (ADR-0027):
 *
 *   1. TypeScript type union `PersonSource` — compile-time check at
 *      every typed assignment.
 *   2. `scripts/check-catalogue-drift.mjs` — CI gate asserting every
 *      `source: 'X'` literal in files importing this module is in
 *      the catalogue.
 *
 * Person.source is NOT enforced at the DB level (no CHECK constraint
 * in the migration) — the field is documented as free-form string in
 * the ADR with promotion to enum-on-DB a follow-up decision once the
 * sync sources (ADR-0029) are concrete. The drift gate + type union
 * are enough for v1 since the only writer is
 * `PersonAndUserProvisioner.ensureUser` and any future writer will
 * import this module to get the type.
 *
 * v1 values:
 *   - 'self-signin' — lazy creation at first OIDC callback.
 *   - 'admin-ui'    — manually entered by an admin before first sign-in.
 *   - 'seed'        — test-tenant provisioning.
 *
 * ADR-0029 will add 'pleiades' and 'acteurs-plus'.
 */
export const PERSON_SOURCES = ['self-signin', 'admin-ui', 'seed'] as const;

export type PersonSource = (typeof PERSON_SOURCES)[number];

export function isPersonSource(value: string): value is PersonSource {
  return (PERSON_SOURCES as readonly string[]).includes(value);
}
