📋 Pre-flight Checks
📝 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
- Run
engram cloud serve with ENGRAM_DATABASE_URL and
ENGRAM_CLOUD_TOKEN_PEPPER configured (authenticated mode)
- Run:
engram cloud bootstrap admin --username alice
--grant-project my-project --issue-token first-token
- Observe the error above; check cloud_principals/cloud_project_grants:
admin and grant exist, cloud_principal_tokens is empty
- 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
📋 Pre-flight Checks
status:approvedbefore 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
engram cloud servewith ENGRAM_DATABASE_URL andENGRAM_CLOUD_TOKEN_PEPPER configured (authenticated mode)
engram cloud bootstrap admin --username alice
--grant-project my-project --issue-token first-token
admin and grant exist, cloud_principal_tokens is empty
✅ 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-metadatafilter.
❌ 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_tokencontains the substring "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