Skip to content

cloud bootstrap admin --issue-token always fails: completion audit metadata key issued_token is rejected by the sensitive-metadata filter #597

Description

@jobiols

📋 Pre-flight Checks

  • I have searched existing issues and this is not a duplicate
  • I understand this issue needs status:approved before a PR can be opened

📝 Bug Description

engram cloud bootstrap admin --issue-token can never succeed. The command writes a completion audit event whose metadata includes the key issued_token (a boolean), but the auth-audit sensitive-metadata filter rejects any key containing the substring "token". Since the managed token and its completion audit are persisted atomically, the token creation always fails — making it impossible to issue the first managed admin token via CLI bootstrap.
This also creates a chicken-and-egg lockout: all identity-mutation endpoints (/admin/* and /dashboard/admin/* — create user, issue token, grant project) require a managed admin authenticated with a managed token (requireManagedAdmin checks Source == PrincipalSourceManagedToken; the legacy ENGRAM_CLOUD_ADMIN operator is read-only for identity). The only way to obtain the first managed token is the buggy bootstrap path, and re-running bootstrap is refused once the admin principal exists. Result: a permanently tokenless managed admin with no supported recovery path.

🔄 Steps to Reproduce

  1. Run engram cloud serve with ENGRAM_DATABASE_URL and
    ENGRAM_CLOUD_TOKEN_PEPPER configured (authenticated mode)
  2. Run:
    engram cloud bootstrap admin --username alice
    --grant-project my-project --issue-token first-token
  3. Observe the error above; check cloud_principals/cloud_project_grants:
    admin and grant exist, cloud_principal_tokens is empty
  4. Re-run the same command → refused: "a managed admin already exists"

✅ Expected Behavior

engram cloud bootstrap admin --issue-token <name> should complete successfully:
create the managed admin principal, apply the requested project grants, mint the
managed token atomically with its completion audit event, and print the raw token
once. The audit event's own metadata (which only contains a boolean flag
issued_token: true, never the token value) should pass the sensitive-metadata
filter.

❌ Actual Behavior

Token issuance always fails — the bootstrap's own success/completion audit is
rejected by the sensitive-metadata filter because the metadata key issued_token
contains the substring "token":

engram: cloud bootstrap admin: create token with completion audit:
cloudstore: auth audit insert failed:
cloudstore: sensitive auth audit metadata is not allowed: issued_token

Since the token and its audit are persisted atomically, no token is minted. The
admin principal and project grants ARE durably created before the failure, so
re-running bootstrap is refused ("a managed admin already exists"). Because all
identity-mutation endpoints (/admin/, /dashboard/admin/) require a managed
admin authenticated with a managed token — the legacy ENGRAM_CLOUD_ADMIN operator
is read-only for identity — the deployment is left with a permanently tokenless
managed admin and no supported recovery path.

Operating System

Linux (Ubuntu/Debian)

Engram Version

v1.19.0

Agent / Client

Claude Code

📋 Relevant Logs

💡 Additional Context

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions