Lifecycle reference
Look up how enterprise lifecycle runs lock, retry and roll back, release floor limits, rollback notes per channel, restart timing and what uninstall keeps.
This page holds the detail behind Upgrade, repair and remove. Start there for the steps. Error and warning codes are in Error codes.
Transactions and the lifecycle lock
Every action that changes the deployment takes the lifecycle lock, applies the change, verifies it and rolls back on failure. These are the waits for the lock:
| Run | Waits for another run | Then |
|---|---|---|
| Any lifecycle command on Linux and macOS | 5 seconds, or --lock-wait <duration> (at most 15m) | Exits 75 (busy) |
The apply trigger, and ensure --reason path without --lock-wait | 10 minutes | Exits 75 |
| deb, rpm and pkg install scripts | 8 minutes | Applies the change after the other run |
| deb and rpm removal scripts | 8 minutes | Fails without deleting anything |
| A busy lifecycle run on Windows | Depends on the action | Exits 1618 |
status on Linux and macOS | 5 seconds, also for an apply trigger that an ensure started | Exits 75 (lifecycle_busy, with pending_apply for a config change), which is not a failure |
verify and uninstall on Linux and macOS | 5 seconds for another run; up to 2 minutes for an apply trigger that an ensure started | verify exits 75 (lifecycle_busy), which is not a failure. uninstall then waits for the lock as above |
Package upgrades. A deb or rpm upgrade holds the apply trigger from before the package
manager replaces any file until its postinstall has applied the package. A config.yaml
pushed before the package is therefore applied by the new version. When the package run
keeps the last applied config because it rejected config.yaml, the install output says so.
Changes made during a run. A config.yaml or credential written while a run holds the
lock, or a run given --config, is applied by a follow-up transaction of that run (warning
input_changed), so the later file is the one in force. When the run fails instead, the
apply trigger runs ensure again once it ends, and only the edit the failed run checked is
kept as rejected.
Apply retries (Linux). When the failed run is the apply trigger itself, a transient timer
(defenseclaw-enterprise-apply-retry.timer) starts it again after 30 s, then 60 s and 120 s
if the same config.yaml keeps failing. After the third retry the run warns
retry limit reached; run ensure once the cause is fixed.
Gateway start failures (Linux and macOS). When the gateway fails to start during an
install or upgrade, the result carries a short excerpt of the gateway's own output (for
example a rule pack that does not load). The full output is kept in
last-activation-failure.log in the lifecycle directory (/var/lib/defenseclaw-enterprise
on Linux, /opt/cisco/defenseclaw/lifecycle on macOS). Only root can read it. A rollback
does not remove it; a later run that commits a deployment does.
Upgrade notes
| Case | What happens | What to do |
|---|---|---|
| Upgrade from a release in which every user of a connector shared one hook and telemetry credential | Each user gets credentials bound to their uid or SID, and the new gateway refuses the shared ones. On Windows the lifecycle restarts the guardian and waits for a fresh reconcile before it starts the new gateway. A user signed out during the upgrade is re-rendered at their next sign-in; until then their managed hooks fail closed | Restart running agents: an agent that was already running keeps the old telemetry credential, and its telemetry is lost until it restarts |
| Signed-out accounts on Windows | See the next section |
Windows accounts signed out during an upgrade
The guardian installs the new hooks only in the account's own Windows session. An account
with no active session (signed out or disconnected) does not fail a managed Windows upgrade
because its agent configuration still holds an earlier release's hooks. When a read-only
check shows that the only difference is the earlier hook render or hook path
(bin\defenseclaw-hook.exe instead of bin\hooks\<digest>\defenseclaw-hook.exe), the
connector is pending until the account signs in. status and verify show it as pending.
| Connector | Until the account signs in |
|---|---|
| Copilot, Antigravity, Kiro | The previous release's DefenseClaw hook keeps running. It runs the same hook binary and arguments, so the gateway still decides its calls. It differs only when PowerShell runs in Constrained Language mode and the launcher never starts: then it allows the call, where this release's hook refuses it |
| Claude Code, Codex, with hook fail mode open | The machine hook is this release's own. status and verify say the machine hook is in place and the account's registration finishes when it signs in |
| Claude Code, Codex, with hook fail mode closed | The upgrade leaves repair pending only when it can read the account's machine registration and prove that its runtime is closed or has no selected generation, so the registered hook fails closed. status and verify name the account and the pending repair |
These still fail the upgrade: any other difference (a deleted or replaced hook file, a link,
another owner, a drifted runtime), a hook lock this release wrote, and an account with an
active session whose repair fails. When one account has connectors of several kinds, its
reason names each group, for example
devin: not guarded until this account signs in; copilot: the previous release's DefenseClaw hook keeps running until this account signs in and the guardian updates it.
Rollback notes per channel
| Channel | How a rollback is refused or applied |
|---|---|
| Windows Setup | /ensure stops with exit 1603 and the code downgrade_refused. /upgrade does not compare versions. The older release's Setup does the replacing, so roll back while agents are idle |
| Linux packages and macOS | The preinstall script refuses an older package before any file changes, unless the root-owned marker exists; the deployed release keeps running. With the marker, the postinstall runs ensure --from-package --allow-downgrade and deletes the marker, so each rollback needs a new one. An ensure --from-package you run yourself records its result in last-package-result.json like the install script |
| Debian and Ubuntu | Every refusal starts with its code (defenseclaw-enterprise: downgrade_refused: ... refusing to downgrade to <version>. Nothing was changed.) and exits 1. An apt hook shipped with the package (/etc/apt/apt.conf.d/50defenseclaw-enterprise) refuses an older .deb before dpkg replaces any file, unless the marker /var/lib/defenseclaw-enterprise/allow-downgrade exists. It runs only for apt and apt-get: dpkg -i skips it, so do not use dpkg -i to go back |
| RHEL | dnf and rpm run the installed package's scripts after the older files are in place, so only the older package's own preinstall can refuse the downgrade. rpm -U refuses an older package; use dnf downgrade |
| macOS | The package records downgrade_refused in last-package-result.json |
| MDM wrapper (Linux) | Installs .rpm files with rpm -U, so it refuses older RHEL packages |
| Tetragon (Linux) | A failed or interrupted run that rolls itself back stops a sensor helper that loaded Tetragon policies, deletes those defenseclaw-* policies, and only then puts the previous files back. Your own Tetragon policies are not touched. A deliberate rollback to a release before Tetragon support leaves those policies loaded, so clean them up first; see Remove the policies, or downgrade |
last-package-result.json keeps the result of the package that is applied; rpm, dnf and
apt show the refusal text only.
Before you roll back
A rollback goes back to the previous install: the release this one replaced. Check this first.
| Previous install | OS | Before or after the rollback |
|---|---|---|
| A release that does not know a setting in your config | Linux packages, macOS | The older package refuses before it changes anything (product_floor_refused, config_newer_than_release) and names each setting. Remove them from the managed config, apply it with ensure --config <file>, then install the older package again |
Release floor limits
On Linux and macOS, every install, upgrade, repair and ensure checks the confirmed
bundle's release floor before it changes anything, including a repair or ensure that keeps
the recorded release. A version that is not a release (for example dev) never meets a
floor. If the check cannot read the floor, the run refuses (product_floor_refused). To go
below the floor, contact your administrator.
The floor is read from the confirmed bundle's manifest. If another file of the confirmed
bundle cannot be read, repair and ensure keep the config the last deployment committed,
repair the host and warn bundle_state_unreadable. With --config, or with no committed
config, the run stops with that code as an error instead. To replace the damaged bundle,
contact your administrator.
Which installer checks the floor:
| Installer | Checks the floor |
|---|---|
Lifecycle install, upgrade, repair, ensure (Linux, macOS) | Yes, before any change |
Package scripts (rpm, dnf, deb, macOS pkg) | Yes, before they replace files, with the installed gateway, or else the retained floor checker (a copy of the gateway that a non-purge uninstall keeps in the lifecycle directory). A checker that cannot be read, is not a root-owned file only root can change, or does not run, refuses the install |
| Package scripts, with nothing to check with | The preinstall installs the files, and the postinstall ensure then refuses a release below the floor. This happens when the installed gateway is gone and there is no retained floor checker, for example after an uninstall that warned floor_checker_not_kept |
| The apt hook of the installed package | Yes, for older packages installed through apt or apt-get. dpkg -i does not run the apt hook |
Windows Setup /install, /upgrade, /repair, /ensure | Yes, before any change, with the Setup's own verified copy of DefenseClaw (product_floor_refused, exit 1603). A floor that cannot be read refuses too. The check also works after an uninstall that kept the state. |
A reinstall at the floor is allowed by this check, including a release over itself when the confirmed floor is that release. Other lifecycle checks still apply.
A release that finds itself below the floor reports product_below_floor in status,
verify and bundle status. It is a warning only: the policy keeps enforcing and nothing
is repaired or reinstalled. bundle status shows the floor as current.min_product_version;
check it before deploying an older release.
Example refusals when the confirmed floor is FLOOR and the package is an older release OLD (the
ellipsis omits the installer's rollback instruction):
| Installer | Refusal excerpt and result |
|---|---|
RPM %prein (also Debian preinst and the apt hook) | defenseclaw-enterprise: product_floor_refused: refusing to install OLD: the signed policy bundle needs DefenseClaw FLOOR or later, and this is OLD; … Nothing was changed. RPM exits 1. The preinstall does not update /var/lib/defenseclaw-enterprise/last-package-result.json. |
macOS pkg preinstall | installer reports an error running package scripts. /var/log/install.log contains product_floor_refused: Refusing to install DefenseClaw OLD: the signed policy bundle needs DefenseClaw FLOOR or later, and this is OLD; … Nothing was changed. The pkg records product_floor_refused in errors[].code at /opt/cisco/defenseclaw/lifecycle/last-package-result.json. |
| Windows Setup | Setup returns 1603; with JSON=1, errors[].code is product_floor_refused and errors[].message begins product_floor_refused: the signed policy bundle needs DefenseClaw FLOOR or later, and this is OLD; …; nothing was changed. Windows Setup reports this in its result, not in a last-package-result.json file. |
How a config change is applied
ensure applies a change in one of two ways:
| Change | How ensure applies it |
|---|---|
Keys the gateway reloads in place (most keys), including connector enabled changes | In the running gateway, without a restart. ensure waits until the gateway reports the new policy: the policy generation on /health goes up by one |
| A file that differs only in bytes (comments, line endings, a BOM, quoting) | The same way: the config generation goes up, the effective policy digest stays, and the gateway keeps running |
A process-level key: gateway.*, guardrail.hook_self_heal, enterprise.network, the other enterprise keys (for example enterprise.machine_policy) and the keys Source of truth lists | A lifecycle transaction. On Linux and macOS it restarts the sensor helper, the gateway, the hook guardian and the hook enumerator; a config reload inside a running gateway reports enterprise.network as restart-required and keeps the previous proxy until then |
A busy host takes longer to restart the services, so give the MDM script a time limit of several minutes.
On Windows, a change takes the in-place path when the installed release is current and
the supplied config differs only in reloadable keys. ensure replaces config.yaml with its
access control kept, waits up to 30 seconds for the gateway to report the new policy, and
verifies the deployment. The result lists the change and the warning ensure_config_applied;
no service stops. Two more kinds of change take this path on Windows:
- A file that changes no setting: other line endings, comments or formatting.
- A change of who is enrolled or which connectors are: the user and group lists of
enterprise.enrollment(include_users,exclude_users,include_groups,exclude_groups,exempt_users) and the connector set (guardrail.connectors.<name>and itsenabled).ensurealso refreshes the enrolled targets, and the hook guardian reloads the config and registers or removes the hooks without a restart.
If the gateway does not report the policy in time, or the lifecycle lock is busy, ensure
puts the previous config back and runs the lifecycle transaction instead. On Windows, a change whose only
process-level keys are enterprise.machine_policy.default.managed_hooks_only or
enterprise.machine_policy.connectors.claudecode.managed_hooks_only restarts only the hook
guardian and then the gateway. ensure waits until every enrolled target verifies with the
new setting first; the setting is machine wide, so a signed-out account does not block it.
On Linux and macOS this change takes the lifecycle transaction, like any other process-level key.
The Windows transaction is the one an upgrade runs, with the installed release's own payload: it stops every service, puts the same release back in place, starts the services and verifies the deployment. Nothing is upgraded.
| Windows result warning | Meaning |
|---|---|
ensure_config_applied | Applied in the running gateway |
ensure_config_restart | Applied by the transaction; names the keys that made it restart |
ensure_upgrade | A newer release was installed |
ensure_config_failed | The transaction failed or rolled back; the change is not confirmed applied, and the errors say what failed. Until a later run applies a config, status warns and verify fails with config_rejected |
Windows Setup results add a changes list when the run wrote something: a config applied to
the running gateway without a restart, a replaced unparseable config, repaired hook runtime
access or restored bundle files.
Invalid and rejected configs
| Case | What happens | How it clears |
|---|---|---|
| The new config is invalid | ensure fails and does not apply it (config_invalid on Linux and macOS; on Windows another code with the reason in errors[].message). The installed config stays | Push a valid config |
| An in-place edit is rejected (Linux and macOS): it fails validation, or the services do not come up healthy | The lifecycle puts the last applied config back and keeps the rejected file as rejected-config.yaml in the lifecycle directory. status warns and verify fails with config_rejected | Write config.yaml again: a corrected config or the previous one |
config.yaml was deleted (Linux and macOS) | The next ensure, including the one the apply trigger starts, puts it back from the last applied config (committed-config.yaml in the lifecycle directory) and warns config_reverted | Nothing more to do |
A config you supply is refused, or its run fails and rolls back (Setup /ensure CONFIG= on Windows, ensure --config on Linux and macOS) | The host keeps running the previous config. status warns and verify fails with config_rejected, and both set coverage_complete and security_complete to false | A later run that applies a config. A later ensure --config clears it |
The config_rejected message gives the time of the failed run, the short digests of the
requested and the running config, a closed cause (route_config_drift, config_refused or
transaction_failed), the error codes of that run and the next step. It never quotes the
config or names accounts; the full result is in the lifecycle log.
| OS | Where the record is kept |
|---|---|
| Windows | config-rejected.json beside deployment.json. It no longer applies once config.yaml changes |
| Linux and macOS | rejected-config.yaml. For a refused ensure --config, the message names that file and the time of the refused run, and says that config.yaml was not changed |
What the apply trigger watches. The config file and the top level of the secrets and
policies directories. ensure re-applies when the config or a secret changed, when an
installed file, binary or machine-policy entry drifted, or when the rule pack a setting
resolves to changed. It does not track the contents of the files under policies. The
gateway reloads a rule pack when its files change; pointing guardrail.rule_pack at another
pack is applied like any other config change.
What ensure does in order
On Linux and macOS, ensure, install, upgrade and repair apply a config in this order.
Windows Setup does the same and records the generation with the actor lifecycle.
| Step | What happens |
|---|---|
| 1. Validate | Reads the --config file, or the installed config, and checks the schema, the runtime load, the fixed layout, the rule packs and every protected credential the file names. A failure is config_invalid and the installed config stays |
| 2. Write under the writer lock | Takes config.yaml.lock, writes the files that changed, and records the config in config.generation.json with the actor lifecycle and the reason enterprise ensure (or the action that ran), when the config changed and when no recorded generation matches the file |
| 3. Regenerate what is derived | Service definitions, the runtime descriptor and DefenseClaw's machine-policy entries are written from the config and never read back. The guardian renders each user's hook scripts and registrations within a minute. Anything that drifted is rewritten, whoever changed it |
| 4. Report the policy | The result carries the effective policy digest and config generation (policy), and policy-state.json records them once the gateway reports the same digest |
If any step fails, including the checks after the services start, the transaction rolls back
and the generation file goes back with it. The result's changes list says what was written.
What repair restores
On Linux and macOS, repair restores the owners and modes of every file the gateway and
the hook guardian keep in the gateway data folder, the hook guardian folders and next to
config.yaml (the audit store, the device identity key, the hook tokens, the service
.env). A chown -R or chmod -R over the deployment is undone without losing the audit
history or the device identity. A file with a second name (a hard link) is not changed; the
error names it.
Every lifecycle run first takes away the permission bits that private folders have beyond their managed mode, and a run that rolls back does not open them again.
The --json result lists what repair changed as changes: the files it rewrote or whose
mode or owner it restored, the services it started, the machine-policy entries it rewrote,
and the users and agents whose hooks the guardian rewrote. On a healthy deployment it says
nothing to repair.
Gateway restarts and hook timing
| Situation | What the hook does |
|---|---|
| The gateway refuses or drops the connection, or the service is stopped | Sends the call again for up to about 3 seconds from the start of the hook, so a quick restart is not visible to the agent |
| The restart lasts longer, default closed fail mode | Blocks each call within those 3 seconds. On Linux, where the call waits in the socket systemd holds, the block names enterprise_managed_gateway_restarting; on macOS and Windows it is enterprise_managed_gateway_not_running |
A tool call (PreToolUse and the like) waits for its decision | Up to about 3.5 seconds from gateway contact, within a 4-second cap from hook launch, whatever holds it up (a restart, an upgrade, a repair, a config change or a busy gateway). Then, with the default closed fail mode, it blocks with enterprise_managed_gateway_no_answer. DefenseClaw never holds a tool call for more than about 5 seconds |
| The decision waits on Cisco AI Defense or the LLM judge | Up to about 4 seconds, then blocked the same way |
| Prompts and session, stop and other events | Keep their whole budget |
| A Setup, pkg or rpm run holds the gateway | Blocks with "DefenseClaw is being installed or upgraded on this computer, and its gateway is stopped until that run finishes or is recovered. Try again in a moment", and points the administrator to the platform's status command. A run that was stopped before it finished leaves the same block until it is recovered. A refusal with its own cause keeps its own text |
Lifecycle runs run at a lower CPU priority than the hooks on every OS, so a repair does not take the CPU the hooks need to answer in time.
Capacity. A gateway too busy to answer blocks a tool call only when this budget runs out, never before it, so a burst makes calls wait longer before it blocks any. For many agents on one Linux host, see Many agents on one Linux host.
Fail mode during an outage. The administrator's hook_fail_mode: open allows a call only
while the hook proves the gateway service is stopped (no gateway took the call). A restart
the hook cannot prove stopped blocks, and so does a hook that reaches its answer deadline
without a decision. Integrity, peer-verification, credential and rate-limit refusals still
block. For connectors whose foreign-hook guard checks the session with the gateway
(foreign_hooks: remove, the default), open runs a call only on Linux and macOS, for an
agent process with a current clean-session note
(Foreign-hook guard).
DEFENSECLAW_STRICT_AVAILABILITY=1 closes outages too. See
Fail modes.
Rule pack edits. A running standalone gateway detects edits to a rule pack or policy file. If the pack is pinned, an in-place edit fails its digest check and the gateway keeps the previous policy generation. A restart alone cannot apply a mismatched pack and may leave the gateway unable to start. Secrets and upgrades restart the gateway on their own.
What uninstall keeps
The registrations go before the hook binary and the runtime descriptor. An agent session that started before the uninstall keeps the hook registration it read at its start until it is restarted. Once the hook binary is gone, such a session runs that hook as a missing command, which the agent treats as a non-blocking hook error, so its tool calls run without DefenseClaw. A rollback replaces the release in place and the hooks stay registered.
| What | Default uninstall | --purge |
|---|---|---|
| Deployment, config, credentials, logs, most gateway, guardian and lifecycle state | Removed | Removed |
| Service account (Linux and macOS) | Removed (--keep-service-account keeps it) | Removed |
Each user's ~/.defenseclaw and per-user binaries | Kept | DefenseClaw-owned entries removed; an account's other files stay, and the folder goes only when empty |
| Sandbox registration store and its key (Linux and macOS) | Kept when an account keeps sandboxes (see below) | Removed, with each enrolled account's sandboxes and any sandbox work not pulled yet |
/etc/defenseclaw/policies (Linux) | Kept | Removed |
lifecycle.lock (Linux and macOS) | Kept, so waiting runs keep using the same lock | Kept |
| Machine state for a reinstall | Removed (--keep-state keeps it) | Removed |
Kept sandbox state (Linux and macOS). When an account keeps sandboxes, the gateway's
registration store (/var/lib/defenseclaw/sandbox on Linux, /opt/cisco/defenseclaw/runtime/sandbox
on macOS) stays if it contains a file, and its key (redaction-correlation.key in the same
parent) stays if it is a regular file. They are root-owned while the service account is gone.
The lifecycle directory also keeps openshell-state.kept.json, the root-only record of the
sandbox setup those sandboxes were made under, and retained-state.json, the root-only record of the state folders the uninstall kept, and the kept data folder holds a root-only .defenseclaw-retained marker. The next ensure uses
them to adopt the kept state, then removes them. Use --purge for a clean image or to remove
the kept sandbox store, key and setup record.
Purge in the first removal. A purge runs the deployment's own binary, which a payload
uninstall, apt remove, dnf remove and the MDM removal scripts delete. After one of those,
install the package or payload again and purge, or delete /var/lib/defenseclaw (macOS:
/opt/cisco/defenseclaw/runtime) and the lifecycle directory by hand.
Turn the deployment on again. With the same config, run ensure --from-package --config <file>
on a package host. A payload uninstall removes the binaries, so stage the payload again and
run its ensure --payload <dir> --config <file>. On a fapolicyd host, follow the
staged-payload trust and two-stage
tarball install steps: refresh an
existing /opt/defenseclaw/ trust entry with --file update after staging, or use
--file add if no entry exists.
Uninstall notes
Linux and macOS
| Case | What happens | What to do |
|---|---|---|
| Linux package removal | Removing the package runs the lifecycle uninstall first, without purge, also when a package install failed and rolled back. apt purge also deletes what a failed uninstall left of /etc/defenseclaw, /var/lib/defenseclaw (including a kept sandbox store and key), /var/lib/defenseclaw-hook-guardian and /var/log/defenseclaw, and clears the lifecycle directory except for lifecycle.lock. Each user keeps ~/.defenseclaw and the per-user binaries, because the gateway that removes them is gone by then | Run the lifecycle uninstall --purge --json before you remove the package. The MDM uninstall.sh --purge does this for you |
| Package removal refused | The package files stay (Uninstall gives the fix) | On RHEL, the last-resort rpm -e --nopreun defenseclaw-enterprise removes the files without cleaning registrations, which then name a missing binary until removed by hand |
| Tetragon (Linux) | Uninstall deletes the defenseclaw-* policies the sensor helper loaded before it removes any file, so no control keeps denying after the helper is gone. It then removes the helper's state in /var/lib/defenseclaw-sensor and its runtime directories (--keep-state keeps the state). Tetragon itself and your own policies stay | See Remove the policies, or downgrade |
| Linux uninstall with the package kept | The package's /usr/lib/tmpfiles.d/defenseclaw.conf names the defenseclaw account the uninstall removed, so the uninstall writes an override of the same name in /etc/tmpfiles.d. The next install or removing the package removes it | None |
| macOS package receipt | A pkg has no uninstaller. The lifecycle removes the binaries itself and forgets the package receipt (com.cisco.defenseclaw.enterprise) | None |
| Registrations left, warning | Each user's registrations are removed as that user. If the user's home is unavailable, the recorded home of a removed or re-homed account is gone, or a re-homed account's old home cannot be trusted, uninstall warns with per_user_hooks_remaining and goes on | Remove DefenseClaw's entries from the named agent config. For a re-homed account, follow the clearing paths in Error codes |
| Registrations left, error | Other registration removal failures report per_user_hooks_remaining for each user and agent and stop uninstall before it removes the binaries those registrations run. The deployment record and state stay. A user's worker that runs out of time (60 seconds) is retried once with five minutes | Fix the reported cause and rerun the same uninstall; ensure restores the deployment instead |
| Manifest rows | Uninstall resolves each row of targets.yaml to its account the way reconcile does. When a row does not resolve (the account does not exist, or the directory does not answer), uninstall refuses before it stops any service or removes any policy and names the row with per_user_hooks_remaining | Fix or remove that row and run the uninstall again |
| Sandboxes | The uninstall stops the sandbox daemon and OpenShell gateway of each account. On Linux, apt remove, dnf remove and rpm -e also stop the sandbox user units of every signed-in account before the package's files go; when a user manager still runs one after three stops, or does not answer, the removal fails, keeps the package files and names the accounts. On macOS the uninstall unloads both sandbox LaunchAgents from the gui and user launchd domains of every signed-in account, and removes the defenseclaw launcher link and both plists from /Library/LaunchAgents | On Linux, stop the units as each named user (systemctl --user stop defenseclaw-sandbox.socket defenseclaw-sandbox.service defenseclaw-openshell-gateway.service) or sign the user out, then run the removal again |
| MDM | Use uninstall.sh [--purge] | See Install with an MDM |
Per-user state with --purge. --purge removes known DefenseClaw-owned entries in each
enrolled user's home, as that user. It first stops the user's per-user gateway and watchdog,
if one runs, and restores files that DefenseClaw changed and still has backups for. It then
removes managed hook scripts, hook credentials, the session cache and other known files
inside ~/.defenseclaw. From ~/.local/bin, it removes defenseclaw-gateway,
defenseclaw-acp, the hook helpers (defenseclaw-hook-post, defenseclaw-hook-user and, on
Linux, defenseclaw-sensor-helper), launcher links, the uv the per-user installer added
when unchanged, and its bookkeeping, and DefenseClaw's entries in the uv cache ~/.cache/uv.
For an account enrolled only for machine-policy connectors, it removes the same known
entries, including ~/.defenseclaw/session-facts.json; the same rule applies to an eligible
account without per-user hook enrollment. Unrelated account files and saved originals in
foreign-hooks-backup stay, and ~/.defenseclaw is removed only when empty. The purge
follows no symlink and leaves the user's own tools in ~/.local/bin. The result names
retained entries and each account whose state it removed or left alone, with the reason (a
home that is not trusted or not available, a hook removal that failed, or a gateway that
could not be stopped). Fix the cause and run the same uninstall again.
A user's own install from before the enrollment. If an enrolled account had its own
DefenseClaw install before the enrollment (its ~/.defenseclaw holds config.yaml, .env,
audit.db, previous/, or the program the per-user installer puts there, .venv/ or
installer/, also when the account never ran defenseclaw init), --purge leaves that folder and the install's binaries exactly as they are and names the account in the result
(kept the DefenseClaw per-user data of user <name> ... and a per_user_state_remaining
warning). A machine uninstall never deletes or moves an account's own data, and no
~/.defenseclaw-backup-* folder is made. The uninstall, with or without --purge, puts back
the install's hook scripts and hook settings, connector backups, hook contract lock and
session cache as they were before the enrollment. It also puts back each agent config those
backups name when the uninstall left it as it was before the own install; an agent config
changed while the computer was managed stays as it is and is named in a
per_user_state_remaining warning. The Claude Code hook script the enrollment replaced with
a blocker comes back too.
A user whose home is gone. When an enrolled user's home folder was deleted and its parent folder still holds other entries, the hooks and ~/.defenseclaw went with it. The
uninstall warns (per_user_hooks_remaining) with the home and goes on.
A home that does not answer, or whose parent folder is missing, empty (the mount point of an
unmounted volume) or cannot be read, is not available rather than gone. So is a home moved or renamed aside: its parent folder still holds another folder the account owns (for example
after mv /home/<user> /home/.<user>-away, or /Users/<user> on macOS), and that folder
keeps the agent configs with DefenseClaw's hook entries. For an account that still exists,
the uninstall refuses before it changes anything (uninstall_precheck_refused): the
services, the machine policy and the hooks and Claude Code blockers of every other user
stay. It names the home: mount it, or move it back to its home path, and run the uninstall again.
A home that goes away while the uninstall runs stops it later (uninstall_incomplete), with
the binaries, the deployment record and the services kept. A per-domain home layout (SSSD
fallback_homedir = /home/%d/%u) looks the same when the only account of a domain had its
home folder deleted: recreate that folder as a folder the account owns, then run the
uninstall again. Removing the account does not end the stop while a targets.yaml row names
it (see Manifest rows above).
Windows
| Case | What happens | What to do |
|---|---|---|
| Per-user registrations | Acting as a user needs that user's session token, which only LocalSystem can obtain. An MDM uninstall runs as LocalSystem and removes DefenseClaw's hooks and plugins (Amp, Antigravity, Devin, Hermes, Kiro, OpenCode, and a DefenseClaw Copilot user hook file) from the agent config of every user with an active (connected) session. An uninstall from an elevated administrator prompt or from Add/Remove Programs removes none, and users who are signed out, or whose session is disconnected, keep theirs. The result lists them in the user_registrations_pending and user_registrations_failed warnings | What stays is inert; see Windows: Remove |
Per-user state with PURGE=1 or --purge, run as LocalSystem | Removes known DefenseClaw-owned entries in each enrolled account's %USERPROFILE%\.defenseclaw, whether or not the account is signed in. Unrelated files and saved originals in foreign-hooks-backup stay; the folder is removed only when empty. It also removes the DefenseClaw files of a per-user install from %USERPROFILE%\.local\bin and, once that folder is empty, the folder and its entry in the account's user Path (a signed-out account's Path cannot be changed, so it keeps that entry). An account whose agent registrations stay keeps its .defenseclaw, whose connector_backups restore them; the purge still finishes | The per_user_state_remaining warning names retained account entries and each folder it could not remove, with the reason |
| An enrolled local account was deleted since the enumerator's last pass | Setup /uninstall (also with PURGE=1) runs that pass itself: it restarts the enumerator, which drops the account's rows, waits up to three minutes for the guardian to take the new targets.yaml, and goes on. When the scheduled pass already dropped the rows just before, it starts the same wait without a restart, and restarts the enumerator once if it then still finds the deleted account | No /repair is needed. If the rows are still listed after the wait, nothing was removed: run the uninstall again a few minutes later |
| MDM | Use uninstall.ps1 | See Install with an MDM |
After an uninstall
After an uninstall, and again after a reinstall (including an MDM remove and re-add), ask users to restart running agents. An agent reads its hooks when it starts.
- On Linux and macOS, while the managed hook binary is still present but its runtime descriptor has been removed, a retained hook command denies tool calls even after DefenseClaw's machine-policy entry is removed. Stop and session-end events receive a neutral allow.
- Once the binary is removed, a session that kept its command may report a hook launch failure. A Copilot CLI session does not: its DefenseClaw command exits 0 once the deployment is removed.
- An agent left running through the uninstall and the reinstall keeps running without
DefenseClaw until it restarts. On Linux and macOS, the
ensureresult,statusandverifyname each user whose agent sessions started before the deployment was activated, with theagent_sessions_restart_requiredwarning.
Upgrade, repair and remove
Upgrade, roll back, change the config, repair and uninstall a standalone DefenseClaw enterprise deployment on Windows, Linux and macOS, with a checklist.
Enterprise troubleshooting
Fix a standalone DefenseClaw enterprise deployment by symptom, on Windows, Linux, and macOS, from install and upgrade to hooks, enrollment, identity and ports.