Karyo
Documentation/ Decision records

ADR 0049: Sign-in events belong to the Company, never a Facility

Karyo 2.1.1rendered at build time
On this page

Status: Accepted. Supersedes ADR 0010's combined authentication and inventory journal.

Context

A sign-in does not prove physical work at a Facility. A user can hold grants at several sites. Assigning a default site invents provenance. Copying a sign-in into every granted site changes its audience.

The captain chose one Company-wide sign-in log while preserving existing authentication records. The optional managed-Keycloak event poller remains its only production source.

Decision

  • LOGIN, LOGOUT and LOGIN_FAILED belong to karyo.sign_in_log in auth-core.
  • The log has no Business Unit or Facility key. Actor identity and provider/source attribution are audit evidence, not an audience.
  • GET /api/v1/sign-in-log requires users.manage at Company node 1. A Business Unit or Facility grant is insufficient.
  • Migration V1216 transfers every authentication row from the inventory journal. It preserves timestamps, attribution and the entire original row as SQL-only JSON evidence.
  • The inventory journal rejects future authentication record types. Its endpoint exposes movements only.
  • The existing Keycloak poller keeps its provider/source cursor and deduplication. It includes platform and unresolved identities without inventing a Facility.
  • External providers gain no recording hook. This decision adds no provider-neutral auditing, export, retention policy or authentication transport.

Consequences

Company administrators can read sign-ins without selecting a Facility. Site administrators and operators cannot read that stream. Existing records remain recoverable, including fields the new endpoint does not expose. The poller retains its existing best-effort delivery limitations and managed-Keycloak-only operation.

Alternatives considered

  • Keep default-site stamping: rejected because sign-in events supply no Facility provenance.
  • Copy events into every granted site: rejected because it changes the audience and duplicates evidence.
  • Retire the optional poller: not chosen; the captain explicitly retained the existing source.
  • Add recording for other providers: outside this decision and not authorized.

Evidence

  • services/karyo-app/src/main/resources/db/migration/auth/V1216__company_sign_in_log.sql, karyo.sign_in_log, karyo.inventory_journals - independent table, complete preservation, movement-only constraint.
  • services/auth-service/karyo-auth-core/src/main/kotlin/com/karyo/auth/api/v1/SignInLogResource.kt, SignInLogResource - Company-node authorization and bounded read.
  • services/karyo-app/src/main/kotlin/com/karyo/app/auth/KeycloakEventPoller.kt, KeycloakEventPoller - existing source and cursor mechanics.
  • services/karyo-app/src/test/kotlin/com/karyo/auth/SignInLogMigrationTest.kt, SignInLogMigrationTest - real PostgreSQL preservation proof, including duplicate events.
  • services/karyo-app/src/test/kotlin/com/karyo/app/auth/KeycloakEventPollerTest.kt, KeycloakEventPollerTest - real Keycloak event ingestion and deduplication.
  • services/karyo-app/src/test/kotlin/com/karyo/app/auth/MultiFacilityOperationTest.kt, MultiFacilityOperationTest.create - Company access and refusal for Business Unit and Facility audiences.
  • ADR 0010 - immutable movement history.
  • ADR 0037 - exact provider bindings and stable principals.
  • ADR 0048 - action catalogue and node grants.