Skip to content
Lovelace

Keyless CI with Workload Identity

A CI job or cluster workload can call Lattice Cloud with no Lovelace secret. The platform already signs a token naming the job: its repository and branch, or its namespace and service account. A trust policy on your Lovelace account says which of those tokens to accept. The Lattice client exchanges the job's token for a Lovelace token that lasts at most 15 minutes and works only with a key the client keeps in memory. Usage bills the account that owns the policy.

To have a coding agent set this up, install the Lovelace developer skills and ask for "Call Lattice from CI without a key"; see Build with an Agent.

1. Create the trust policy#

bash
ada developer trust-policy create \
  --preset github-actions \
  --repository acme/agents \
  --ref refs/heads/main

Approve the sign-in in your browser when asked. The command prints the policy id, such as tp_9f2c. The policy admits only jobs from acme/agents running on main.

PlatformCommand flags
GitHub Actions--preset github-actions --repository <owner/name> --ref refs/heads/<branch>
GitLab CI--preset gitlab --project-path <group/project>
Kubernetes--preset kubernetes --namespace <ns> --service-account <sa> --issuer-url <issuer>

ada developer trust-policy list shows your policies, and ada developer trust-policy delete <id> removes one. Changing or deleting a policy revokes the tokens issued under it within 30 seconds.

2. Give the job its identity#

In GitHub Actions, let the job request its token and name the policy:

yaml
permissions:
  id-token: write
  contents: read

jobs:
  summarize:
    runs-on: ubuntu-latest
    env:
      LOVELACE_TRUST_POLICY_ID: tp_9f2c
    steps:
      - uses: actions/checkout@v4
      - run: npm ci && npm run summarize

In Kubernetes, mount a projected service account token and set AWS_WEB_IDENTITY_TOKEN_FILE to its path, with LOVELACE_TRUST_POLICY_ID.

3. Use the workload credential#

ts
import {
  LatticeClient,
  workloadCredentialFromEnv,
} from "@reasonabletech/lattice-client";

const lattice = new LatticeClient({ credential: workloadCredentialFromEnv() });

const reply = await lattice.chatComplete({
  model: "lovelace:llama-3.2-3b-instruct",
  messages: [{ role: "user", content: "Summarize yesterday's failures." }],
});

The client reads the job's token, exchanges it, signs every request, and exchanges again before the Lovelace token expires.

Troubleshooting#

Error codeCause
workload_configuration_invalidThe job lacks id-token: write or LOVELACE_TRUST_POLICY_ID
workload_exchange_invalid_grantThe job's repository, branch, or token audience does not match the policy
workload_exchange_invalid_dpop_proofThe runner's clock is far from the correct time
no_provider_availableNo provider serves the model; choose one from the catalog