On this page
Auth-shadow repair and running-state detection: clears the session credentials that shadow a profile's stored token, and spots live Claude Code sessions.
#claudewheel.profile_ops
#claudewheel.profile_ops
Profile auth-shadow repair and running-state detection.
Profile create/delete/rename live in :mod:claudewheel.profile_store now; this module retains only the fix-auth flow and the session running-state check that callers apply as policy before delegating deletions to the store. That check is a delegate: :mod:claudewheel.session_registry owns every read of Claude Code's per-session registry.
#FixAuthResult
Outcome of fix_auth_shadow(): success or a reason for no-op/failure.
ok: True when the shadow was removed, False otherwise. reason: None on success; "no-token" / "no-shadow" / "unreadable-creds" on failure.
#fix_auth_shadow
def fix_auth_shadow(ws: 'Workspace', name: str) -> FixAuthResultRemove session credentials (claudeAiOauth) that shadow a long-lived token.
Reads the profile's .credentials.json and strips the claudeAiOauth key. Whatever plan-tier fields that block carried are discarded with it: the declared plan lives in the profile's own token entry and is written there by claudewheel's plan picker, never harvested back out of Claude Code's credential file. A file left holding nothing is removed rather than kept as an empty object, which would go on answering "this profile has credentials" to discovery, the inspection report and the permission check.
Zero printing, zero sys.exit -- returns a FixAuthResult describing what happened.
A corrupt token entry raises :class:TokenStoreError (the hard-error contract) -- token resolution cannot proceed and the operator must fix it.
#_is_profile_running
def _is_profile_running(ws: 'Workspace', name: str) -> boolTrue when a human's Claude Code session is live in this profile.
A delegate to :func:claudewheel.session_registry.has_live_interactive -- the single reader of Claude Code's per-session registry, which parses the sessions/<pid>.json files, filters out phantoms (a stale file, or a PID the kernel has since handed to something else) and classifies each record by kind. Background jobs, daemons and daemon workers are live processes but do not answer True here: they are not a person at a terminal, and the delete flow offers the user a choice about them rather than a veto.