ADR 0014: One Company per installation; positive clients are Phase 1 Business Units
Status: Superseded in part by ADR 0038 for operational request scope after access cutover 2. ADR 0037 adds the stable principal/binding prerequisite. ADR 0050 removes the legacy scope API and copied Business Unit column from operational rows. ADR 0051 renames the client and tenant storage, claim and API vocabulary to Business Unit.
Context
Karyo is installed for one operating company, on a host that company controls (ADR 0001, ADR 0022). The unit that scales is the customer, not a module or a shared service.
The organization vocabulary is Company > Business Unit > Facility. A Business Unit is one 3PL client or one division of a non-3PL Company. Every Facility is dedicated to exactly one Business Unit. A Company may represent the same physical building as separate Facilities when different Business Units use it; Karyo does not add a shared-building tier.
Before this vocabulary was adopted, clients represented goods owners. Positive client_id
values already identify the records that become Business Units. Owner 0 is SYS and is also the
historic default on tenant-scoped rows. Existing data additionally contains Company defaults, SYS
operational rows, globally shared layout, and operational rows that refer to layout belonging to a
different owner. Those categories cannot safely be collapsed by renaming client_id.
Decision
- One installation serves one Company. Company is a singleton installation identity, not a
SaaS tenant and not client
0under a new name. - A positive client is the Phase 1 compatibility representation of a Business Unit. The
physical
clientstable and existingclient_idcolumns remain in place. The Business Unit API aliases the same row and preserves its positive id. There is no second writable Business Unit table or synchronized duplicate entity. - SYS is not a Business Unit. Client
0remains a compatibility identity for current defaults and legacy rows while those uses are classified. It is neither an administrator nor a wildcard. The Business Unit contract does not exposeisSystemClient. - Facility starts in Phase 2. Phase 1 does not introduce a Facility entity,
reinterpret
client_idas a Facility id, or change the term "unit load". Its later request-scope activation is recorded in ADR 0038. - P1.01 and P1.02 are additive. They record the vocabulary and baseline, then add Company,
Business Unit aliases, and
OrganizationLookup. ExistingTenantScope, roles, owner pickers, realm claims, schedulers, and workflow behavior remain unchanged. Tree grants and request selection begin in P1.03 and later steps. - P1.01 records the migration baseline. Its executable fixture distinguishes positive Business
Units, SYS defaults, SYS operational rows, and foreign layout references without rescoping them.
A future migration of real installation data must fail on an unknown classification, and no rule
may map
0to the first Business Unit. - Owner references remain plain ids during compatibility. No foreign key points from another
module at
clients; cross-module references are validated through API lookup seams (ADR 0007).
The Atlas demo database, including ACME and Globex, is disposable at the incompatible cutover. This exception does not weaken the fail-closed classification and stable-id requirements for real customer installations.
Consequences
- Existing positive client ids, business numbers, operational row ids, and legacy client routes remain stable while callers adopt Business Unit terminology.
- Company has an independent identity and metadata. Editing SYS cannot rename the Company.
- New code can say Business Unit without creating two sources of truth. Legacy
Clientnames may remain at compatibility boundaries until the coordinated storage rename. - A Business Unit's future Facilities share its product identity. Operational isolation remains on Business Unit grants after access cutover 2, before Facility scope arrives.
- Current shared-layout and SYS behavior is characterized rather than silently declared valid for the final model. A future real-data migration must stop on unknown or contradictory classifications.
- Application code remains the only current row-isolation boundary. There is no database row-level security and Hibernate's declared tenant filter is not enabled.
Alternatives considered
- Treat every current
client_idas a Facility id. Rejected. Products are Business Unit master data, SYS mixes defaults with operations, and current layout can be shared across owners. - Create a separate Business Unit table and synchronize it with
clients. Rejected. Two writable representations would drift and would make stable-id compatibility harder to prove. - Treat SYS as the Company or as an all-access Business Unit. Rejected. Client
0is a default and legacy attribution value, not authority, and its mutable display fields are not the Company identity. - Add Company row-level tenancy. Rejected. A second Company receives a separate installation.
- Preserve the Atlas demo as a customer upgrade fixture. Rejected by product decision. Real customer safeguards remain; Atlas is rebuilt later from a fresh tier-native dataset.
Evidence
services/karyo-app/src/main/resources/db/migration/auth/V1201__create_clients.sql- the compatibility table, SYS row, and positive idsservices/auth-service/karyo-auth-core/src/main/kotlin/com/karyo/auth/domain/model/Client.kt- the single entity behind the Phase 1 Business Unit aliasservices/karyo-app/src/main/resources/db/migration/auth/V1205__create_company.sql- the fixed singleton Company identityservices/auth-service/karyo-auth-core/src/main/kotlin/com/karyo/auth/api/v1/ClientResource.ktandBusinessUnitResource.kt- the legacy and Business Unit routes over the same rowservices/auth-service/karyo-auth-api/src/main/kotlin/com/karyo/auth/spi/ClientLookup.ktandOrganizationLookup.kt- the compatibility and organization lookup contractslibs/karyo-security/src/main/kotlin/com/karyo/security/FacilityScopes.kt- current read and write scopes; ADR 0050 removedTenantScope
Related
- ADR 0007 - ids, not foreign keys, across modules
- ADR 0013 - where the legacy
client_idclaim comes from - ADR 0015 - the unchanged compatibility scope
- ADR 0018 - which configuration is currently per owner
- Identity and tenancy - current scope resolution
- Company and Business Units - Business Unit administration and fixtures