# ADR 0020: Infrastructure, common and platform CLI surfaces

> Partly binding. Binding today: the olf infra group, the common top-level commands, and the hidden aliases that keep every earlier path working (#536, PR…

Source: https://openlakeforge.dev/docs/adr/0020-infrastructure-common-and-platform-cli-surfaces/

## Status

Partly binding. **Binding today:** the `olf infra` group, the common top-level
commands, and the hidden aliases that keep every earlier path working (#536,
PR 2b), the platform session commands `olf login`, `whoami` and `logout`
(PR 4), `olf query`, and the platform reads `olf jobs list`, `olf runs
list|show`, `olf domain list` and `olf product list` (#669), and `olf report
import|export` (#670). **Decided, not
built:** the non-interactive authentication contract below. Platform
commands are clients of the platform API, decided in
[ADR 0021](https://openlakeforge.dev/docs/adr/0021-platform-api/) and not built either, except where a
service accepts the person's token and the command calls its route directly.

## Context

`olf` deployed infrastructure and offered end-user operations through one
command tree, and its code did not keep them apart. Every command that reached
a service did so with a kubeconfig, and the service saw a bot or a workload,
never the person. [ADR 0014](https://openlakeforge.dev/docs/adr/0014-identity-and-authorization/) classified
every `olf` call as class 2, which is right for deployment and leaves no safe
way to hand a person, or their local agent, a CLI.

## Decision

`olf` stays one executable with three surfaces. **The credential a command
needs decides its surface**, not who runs it.

| | Infra (`olf infra ...`) | Common (`olf ...`) | Platform (`olf ...`) |
| --- | --- | --- | --- |
| Needs | Cluster or cloud permissions | None | A Dex session, the same path as the UI |
| Identity | Cloud IAM or SDK identity, kubeconfig and Kubernetes RBAC; workload or CI credentials | None | Human OIDC session; delegated user identity for local agents |
| Reaches | Cloud and Kubernetes APIs, Terraform state, Helm, registry, object store | Local files, local Docker, public release metadata | The platform API ([ADR 0021](https://openlakeforge.dev/docs/adr/0021-platform-api/)), and directly the public route of a service that authorizes the person's token: Trino's `query_api` for data-plane reads (ADR 0021, decision 2); never Kubernetes Secrets, exec or port-forward |

Being `platform-admin` in the OpenLakeForge UI grants no Kubernetes or cloud
rights. A platform command cannot reach a privileged operation through an infra
client, a shared service-admin token or an implicit port-forward.

Code follows the same split: `olf/common` imports neither `olf/infra` nor
`olf/platform`, and `tools/olf/tests/common/test_package_boundaries.py` fails
on a violation. `olf/cli.py` is the only module that imports both. When
`olf/platform` exists it imports nothing from `olf/infra`, and the same test
gains that rule. The service operations both surfaces need live in a library
the infra commands and the platform API share (ADR 0021, decision 4), not in
either command package.

## Command ownership

| Surface | Commands |
| --- | --- |
| Infra | `deploy`, `plan`, `destroy`, `doctor`, `status`, `forward`, `break-glass`, `query`, `auth *`, `platform *`, `access trust`, `github connect`, `secrets rotate`, `k8s`, `catalog`, `artifacts`, `openmetadata *`, `superset *`, `report import\|export`, `project build\|deploy\|status\|image\|revision *`, `product run`, `images load`, `contracts env`, `diagnostics collect`, `dbt parse`, `e2e`, `smoke` |
| Common | `init`, `version`, `check *`, `release *`, `toolchain *`, `distribution *`, `profile validate\|resolve`, `source new`, `domain new`, `product new`, `project validate\|graph`, `report validate`, `contracts check`, `images build`, `layers enabled`, `diagnostics tree` |
| Platform | `login`, `whoami`, `logout`, `query`, `jobs list`, `runs list\|show\|launch`, `logs`, `domain list`, `product list`, `report import\|export` |

Groups that mix credentials exist on both sides: `olf project validate` is
common and `olf infra project deploy` is infra.

`project image` sits in infra although #536 lists it as common, because it
builds through the cloud provider and needs cloud credentials on `aws` and
`azure`.

`olf infra query` is workload-scoped: it runs as the stage's shared Trino
principal. `olf query` is the platform command for a person's own queries
([ADR 0019](https://openlakeforge.dev/docs/adr/0019-data-plane-authorization-deferral/)): it signs in with the
platform session and reaches only Trino's `query_api` route. The hidden alias
`olf query` → `olf infra query` ended with it, the first exception to the
migration rule below.

`olf report import|export` is the second. `olf infra report import|export` run
as the stage's Superset admin and move every bundle a project holds, for
operators. `olf report import <dir>` and `olf report export <dashboard> <dir>`
move one report as the signed-in person, through the platform API: the import
is zipped on the client within the API's limits and runs as the stage's
non-admin service user, DEV only, and the export is unpacked into the report
directory as the infra export unpacks it. Their hidden aliases to the infra
commands ended.

`olf check contracts` and `olf contracts check` are common, but one of their
checks (`hcl_phase_two_invariants`) runs `terraform output` against applied
state. It is skipped when no environment is applied; with an applied remote
backend and cloud credentials in the environment it reads that state.

## Migration

Every earlier path stays as a hidden alias of its new home: it runs the same
callback, takes the same options, and does not appear in `--help`.
`olf deploy` and `olf infra deploy` are one command; so are `olf project
deploy` and `olf infra project deploy`. An alias prints one line on stderr,
`this command moved to `olf infra <path>`; the old path will be removed in a
later release`, and then behaves as before: same stdout and exit code. `olf
query`, `olf report import` and `olf report export` are no aliases: they are
platform commands. A command that moves from
infra to common keeps its `olf infra` path the same way, warning with its
common path: `olf infra report validate` runs `olf report validate`.
`tools/olf/tests/common/test_cli_surfaces.py` holds the list of earlier paths
and fails if one stops resolving to its new home or stops warning.

## Non-interactive platform authentication

CI and service agents cannot complete a browser login. When they need the
platform surface, for example to publish project artifacts, the credential must:

- be short-lived, valid for minutes and issued per run;
- be scoped to the operation and project it serves, and carry no infra rights;
- identify the workload or pipeline, not a person;
- come from exchanging an identity the runner already holds, not from a secret
  stored in CI;
- never be a human refresh token or personal access token, and never be
  derived from one.

An infra credential is not a substitute. Infrastructure CI/CD keeps using
cloud and Kubernetes permissions. The exchange is not built; it needs its own
design against these requirements. Until it is, the artifacts phase imports
reports and metadata with infra credentials and does not call the platform API
(ADR 0021, decision 4).

## Consequences

- A person or agent can be given the platform surface without a kubeconfig.
- Every old script keeps working until the deprecation window opens.
- `project image` stays on the infra surface (above).
- The `olf infra` documentation paths land with PR 6 of #536.

## History

New record (#536).

Rewritten for [ADR 0021](https://openlakeforge.dev/docs/adr/0021-platform-api/): the platform surface reaches
the platform API instead of each service's public route; `olf query` joins the
planned platform commands, and its hidden alias to `olf infra query` ends when
ADR 0019's person path is built.

The platform session commands exist (#536, PR 4): `olf/platform` holds `olf login`,
`olf whoami` and `olf logout`, registered at the top level. Until the platform
API serves its discovery document (ADR 0021), the instance comes from the
Deployment Profile: the issuer is `https://auth.<base_domain>` for
`identity.issuer: github` and `issuer_url` for `external`, and the client is
`identity.client_ids['olf-cli']` or `olf-cli`. The session is a mode-0600 file
under `OLF_HOME`; the OS keyring is a follow-up. A test holds the import
direction: `olf/platform` imports only `olf.common`.

The hidden aliases started warning once the documentation and CI moved to
`olf infra` (#536, PR 6).

`report validate` moved to common (#664): the bundle validators live in
`olf.common.report_bundles`, and `olf infra report validate` became a hidden
alias that warns with the new path.

The platform row follows ADR 0021's rewritten decision 2 (#665): a platform
command may call a service's public route directly when that service
authorizes the person's token, as `olf domain list` does with OpenMetadata.

`olf query` is a platform command (ADR 0019, build step 7); its alias to `olf
infra query` ended.

The platform reads exist (#669): `olf jobs list`, `olf runs list|show`, `olf
domain list` and `olf product list`, each a client of the platform API.
`domain list` reads OpenMetadata through the API's `/api/v1/domains`, which
forwards the person's token unchanged (ADR 0021, decision 2), instead of
OpenMetadata's own route as planned: one client for the CLI and the portal, and
one place for the first-time-user registration. Only `olf query` still calls a
service's route directly. `domain list` and `product list` sit in the common
`domain` and `product` groups beside `new`, on the platform surface.

`olf report import|export` are platform commands (#670), the second exception to
the migration rule: their pre-2b aliases to `olf infra report import|export`
ended, and the infra commands stay for operators. The import zips only
`metadata.yaml` and the YAML under `datasets/`, `charts/` and `dashboards/`,
so a report's `databases/` never leaves the machine.

---

<small>Synced from openlakeforge @ `v0.6.0-alpha.3` (`882b426`), [docs/adr/0020-infrastructure-common-and-platform-cli-surfaces.md](https://github.com/OpenLakeForge/openlakeforge/blob/882b426992381ef277f7c0830f36c0d6fa348644/docs/adr/0020-infrastructure-common-and-platform-cli-surfaces.md).</small>
