Assistant recovery
Recovery is an opt-in, same-instance runtime feature. It is separate from portable backup/import and offline native-history transfer: recovery artifacts can contain private provider credentials, conversations, workspace trust and native approvals. Keep the destination private and protect it independently. The private runtime format is not a portable user archive and adds no custom per-object encryption. Use encrypted storage and narrow access externally; hashes detect corruption, not malicious replacement by an authorized writer.
Choose the right operation
| Need | Use | What it preserves |
|---|---|---|
| Move reviewed content into a fresh installation | CLI/Admin portable backup and restore | Knowledge, workspace and allowlisted settings; sensitive content is opt-in and tasks need review. |
| Preserve or relocate an entire stopped instance | CLI/Admin full-instance export/import (--full) |
Entire home, including native history, sign-ins, keys, active tasks and same-instance identity; external sources need separate protection. |
| Resume the same agent after replacing its disk/container | Assistant runtime recovery | Native databases, sessions, credentials, approvals and selected files, under single-owner checkpoint authority. |
| Transfer conversations with reviewed workspace mappings | Offline native history export/restore | Conversation history, not an entire runtime. |
These are different restore purposes and coverage promises. Assistant backup export/import now packages the same validated checkpoint used by automatic recovery; see checkpoint packages. Whole-home and reviewed-content exports retain their actual scope and safeguards. Reviewed-content import does not replay runtime credentials or checkpoint authority; same-instance recovery preserves native state. Container exclusions are never silently applied to host portable backup. See managing fhold for the currently available flows.
Runtime configuration
The recommended destination is a local or mounted backup directory. Each checkpoint first snapshots SQLite with its native backup mechanism and captures selected files into a temporary directory on local disk. After local capture succeeds, the worker copies completed content to the destination, reusing identical objects already present. It publishes the accepted generation last. Interrupted capture or copy leaves the previous accepted checkpoint usable; unreferenced partial files are not restored. This is incremental content reuse, not an atomic snapshot across all live applications. Ordinary files must remain stable while they are captured.
For ACA, mount a separate Azure Files SMB share at /recovery; keep all live
databases and temporary snapshots on the container's local ephemeral storage.
Startup reads and verifies the accepted checkpoint into local storage before
starting native writers. No hard links or live SQLite operations run on the share.
Size local ephemeral storage for live data plus the complete staged checkpoint.
Directory ownership remains persistent: after an unclean stop, confirm all old
writers have terminated and use the existing exact-owner unlock --confirm-stopped
procedure before a replacement can acquire the destination.
Azure Blob recovery is deprecated, superseded by local checkpoint staging
and copying to a mounted backup directory. Existing Blob destinations, credentials
and restore behavior remain supported. Deprecation does not migrate or disable
existing deployments. New ACA installs default to a dedicated backup share; use
"recovery": "azblob" explicitly to retain Blob for a new installation.
Standalone deployments supply the image inputs below. Docker CLI/Admin installs
store the same non-secret intent in state/stack.json under recovery, selection
in config/recovery/include.json, and Blob credentials in the private file
state/secrets/fhold_recovery_connection_string. The runtime itself includes no
cloud-management tooling. The experimental host-side ACA provider supplies those
same image inputs through native deployment settings and secret-file mounts;
see Azure hosting.
Configure through Admin or CLI
Open System → Backup and recovery → Automatic Assistant backups. Persistent
and replaceable containers use this same location, interval and coverage form;
there is no ephemeral-container mode to choose. Environment variables and
fhold recovery commands are unchanged.
Enable automatic backups and startup recovery, then choose
a private local/mounted directory outside the instance home or an existing
azblob://account/container/prefix. The stable instance ID defaults from the
saved instance name. Blob uses a private connection-string file or the deployment's
explicit managed identity, never a host CLI account. Saving does not initialize
storage or restart containers; a persistent alert records unapplied settings.
The directory picker selects a path on the instance's Docker host, including over SSH. If the connection does not offer host directory browsing, enter the already mounted backup path inside the container instead. On ACA this must be an Azure Files mount; saving a path does not provision storage. Storage authentication controls appear only for the deprecated Blob destination. The backup interval and stale-backup warning are common settings; identity, operation timeout and custom coverage remain advanced.
If settings have not been inspected, Inspect saved coverage loads them through the shared connection. It remains available without a local Docker configuration. Unsupported actions explain their native limitation beside the controls. A scaled-to-zero app is not a confirmed stopped app.
For a genuinely new namespace: save, stop the instance through its confirmed lifecycle action, and choose Initialize new destination. Confirmation is required, existing namespaces are refused, and native writers remain stopped. Then start normally and Check checkpoint status. Initialization is not a checkpoint. For an existing namespace, never initialize again: startup validates/restores before writers run. Validate / restore same instance does that offline while stopped; it does not erase surviving data or select an older rollback point. Stale ownership still requires separate external verification.
Inspect saved coverage is read-only. Advanced checkpoint settings exposes additional paths/SQLite and exclusions/required mounts/discovery. These are literal container paths, not host names; listing them does not mount a drive. The native engine checks database integrity, required mounts and accepted authority. Ordinary image upgrades and coverage edits do not require a new destination. Package versions are recorded for diagnosis, not used to reject an otherwise valid checkpoint. Native tools handle their own database upgrades.
For ACA, changes are staged locally for the exact resource and applied through the common pending-change confirmation. Native coverage/status inspection requires an explicit agent connection. Start restores the app's checkpoint before its writers run. A separate Job cannot restore the app's ephemeral writable layer, so the offline Validate / restore action remains unavailable for ACA. Fresh installation initializes its new namespace using a finite same-image Job; existing-namespace initialization still requires stopped writers and suitable native authentication. Unsupported identity/mount layouts are reported rather than silently changed. Cloud full export/import is separate future work.
The CLI uses the same shared operations:
fhold --name my-agent recovery configure --directory /absolute/private-checkpoints
# Deprecated Blob alternative; the input file must be mode 600/400:
fhold --name my-agent recovery credential --from /absolute/private-connection-string
fhold --name my-agent recovery configure --to azblob://account/container/my-agent
fhold --name my-agent recovery show
fhold --name my-agent stop
fhold --name my-agent recovery init --confirm-new-instance # new namespaces ONLY
fhold --name my-agent start
fhold --name my-agent recovery status
fhold --name my-agent recovery inspect
recovery configure --selection-file /absolute/policy.json saves a reviewed
selection. --interval, --max-unsaved and --timeout adjust bounded timing;
--instance-id supplies stable identity. --managed-identity [--client-id UUID]
selects externally supplied identity; --connection-string selects the private
file. recovery disable saves an off choice for next restart and keeps all data,
credentials and checkpoints. recovery restore --confirm-stopped validates and
restores offline, not a portable archive.
Update earlier managed homes with the current CLI before configuring this
surface, so their allowlisted Compose file has the recovery mounts. Saving never
updates an old image implicitly. Activation and offline operations also require
the matching Assistant image's mixed-storage recovery capability; an older image
is refused before containers or checkpoints are changed. Compose derives termination grace from the
operation budget (297 seconds by default), mounts the backup root at /recovery,
the policy read-only at /run/fhold-recovery/include.json, and private staging/
receipts from data/recovery at
/run/fhold-recovery-state/<destination-and-ID-digest>. Changing a destination
does not copy or fabricate native authority.
Recovery protects the Assistant, not deployment intent, managed system policy, Guardian/portal databases or independently persistent drives. Preserve those separately. Recovery credentials and selection files are not portable backup members. A different home or image does not make a checkpoint portable.
| Input | Default / purpose |
|---|---|
FH_RECOVERY_URL |
Unset keeps ordinary disk persistence; file:///absolute/path or azblob://account/container[/prefix] enables strict recovery. |
FH_INSTANCE_ID |
Required with recovery; stable lowercase slug, not a replica/revision name. |
FH_SCHEDULER_ENABLED |
1; set 0 to disable user scheduling only. |
FH_RECOVERY_INTERVAL_SECONDS |
60; capture cadence, 1–86,400 seconds. |
FH_RECOVERY_MAX_UNSAVED_SECONDS |
300; warn when the last accepted checkpoint is older than this threshold. Does not stop the agent; independent of the capture interval. |
FH_RECOVERY_OPERATION_TIMEOUT_SECONDS |
120; monotonic between-step/SQLite budget, 1–3,600 seconds. |
FH_RECOVERY_AKM_INDEX_CAPTURE |
0; exact 1 enables EXPERIMENTAL optional AKM cache capture. May change or be removed. |
FH_RECOVERY_AKM_INDEX_RESTORE |
0; exact 1 enables EXPERIMENTAL eligible AKM cache restoration. May change or be removed. |
FH_RECOVERY_PROBE_PORT |
0 (off); private health-only probe, not the native API port. |
FH_RECOVERY_STATE_DIR |
/home/fhold/.fhold-recovery; private staging/receipt, no arbitrary native-tree overlap. |
FH_RECOVERY_INCLUDE_FILE |
Unset keeps the native catalog; externally supplied absolute JSON file for additional paths, SQLite registrations and optional mount policy. |
FH_RUNTIME_DIR |
/tmp/fhold-runtime; ephemeral private process/status files. |
FH_RECOVERY_CREDENTIAL_FILE |
Unset uses explicit managed identity; otherwise absolute private standard Blob connection-string file. |
AZURE_CLIENT_ID |
Unset uses system managed identity; UUID selects a user-assigned identity. |
FH_RECOVERY_ALLOW_INSECURE |
Off; exact 1 enables HTTP only for allowed emulator hosts. |
FH_RESTORE_TIMEOUT_SECONDS |
300; entrypoint wait for validated restoration before native startup. |
FH_SHUTDOWN_SECONDS |
25; writer-stop grace, not the final backup deadline. |
Invalid numeric timing/probe settings log their setting names and use the documented defaults; they do not prevent a valid instance from starting. Invalid scheduler enablement disables scheduling only. Identity, destination, authentication and restore-safety errors still require correction before startup.
Set the existing native API password through its normal private secret-file contract. Codex/Claude workers remain independent and experimental. Both supervisors default on, with independent explicit off switches. Configuring recovery does not sign them in, accept trust or approve their tools.
Local or mounted-directory destination (recommended)
Use FH_RECOVERY_URL=file:///absolute/path/to/private-backups and a stable
FH_INSTANCE_ID. The directory is a backup destination, not the live Assistant
home. Keep working SQLite databases on local storage. A network-mounted backup
directory is eligible only when all owners see the same filesystem and atomic
directory creation, exclusive file creation and atomic rename behave correctly.
This does not qualify live SQLite WAL on NFS/SMB or object-storage FUSE.
Hard-link support is not required. Completed copies use a temporary file and
same-filesystem rename under the existing ownership/mutation guard. A content
hash conflict is refused rather than overwritten.
To switch an existing deployment, stop its writers, provision and mount a new private backup directory, and explicitly configure/initialize a genuinely unused namespace. Preserve the old Blob destination until a new checkpoint and a restore drill have been verified. Old accepted Blob checkpoints are not automatically transferred or adopted by the new destination.
Initialize a genuinely unused namespace through the explicit recovery
initialization operation before ordinary startup. Initialization is not an
always-on flag: startup refuses a missing, corrupt, inaccessible, incompatible
or wrong-instance recovery head. It must never quietly create a blank agent.
With the same destination/identity environment that ordinary startup will use,
run the image's fhold-recovery init --confirm-new-instance once. Use
fhold-recovery status for the private durability status; initialization alone
is not a checkpoint or application readiness. Do not reinitialize an established
namespace to work around a restore error.
For a new disposable instance, external tooling can initialize the namespace by overriding the image's ordinary entrypoint. Choose an exact empty backup directory and exact image reference yourself; this example does not create or delete them:
docker run --rm --entrypoint fhold-recovery \
--user "$(id -u):$(id -g)" \
--mount type=bind,src=/absolute/private-backups,dst=/recovery \
--env FH_RECOVERY_URL=file:///recovery \
--env FH_INSTANCE_ID=my-agent \
YOUR_DIGEST_PINNED_ASSISTANT_IMAGE init --confirm-new-instance
The mount must be writable by the configured non-root user. For host-owned bind mounts, use the same numeric UID/GID for initialization and every subsequent container, as managed fhold installs do. Configure ordinary startup with the same destination and instance identity, separate writable local native state, and native password secret. Perform native provider/vendor sign-in through the image's existing private exec/setup flow after restoration; no Azure management CLI or copied host login is involved.
Only one owner may serve an instance. Directory ownership does not expire automatically. After a crash, an external operator must confirm the old writer and its descendants have stopped before explicitly transferring ownership. A timeout or replica count of one is not proof that the old writer is stopped. Never manually remove a lock while an old writer may still run.
For an image upgrade, drain the old deployment before starting its replacement. An orchestrator reporting Stopped, NotRunning, or an old successful readiness result does not prove the final checkpoint finished or ownership was released. Wait for the old replicas/processes and descendants to be removed, allow the full termination grace described below, and check for completed checkpoint publication and owner release. Do not update/restart immediately after only a stop request is accepted. An interrupted shutdown may leave an owner nonce even when the final process is gone; use the exact-owner unlock procedure below only after external confirmation that every old owner stopped. Keep deployment-specific lifecycle scripts outside the fhold runtime.
Blob uses a 60-second descriptor lease, renewed every 10 seconds with a conservative 45-second local safety window. Azure's native retry policy retries transient renewal failures only within the remaining existing window; claims, publication and release keep their separate single-attempt request bounds. An unresponsive renewal attempt is canceled at the existing request timeout and retried with the same lease ID within that unchanged window; a server-side timeout hint alone does not bound a stalled connection. Only a positively confirmed renewal before the old deadline extends authority. Definitive lease conflicts fail immediately; a sustained outage stops writers at the safety deadline, and a late response cannot revive ownership. A persistent owner nonce remains after lease expiry: expiry alone never authorizes takeover. Neither descriptor fencing nor a timer can stop a partitioned native process's local writes or arbitrary external tool action. External routing must not expose two owners, and a paused old host must be confirmed terminated before ownership transfer.
After externally confirming every old writer/publisher and descendant is stopped, read the exact owner nonce from the private descriptor/owner record. With the same destination, instance identity and transport authentication environment, run:
fhold-recovery unlock --confirm-stopped --owner EXACT_PREVIOUS_OWNER_NONCE
Use the image's recovery executable in a separate non-writing operator invocation
(override its normal entrypoint), not a running Assistant tool session. The command
checks exact identity/nonce; it does not establish that the old process is dead.
Then start normally and allow full restore validation. Never substitute an old
nonce, delete a lock manually or run init to work around failed recovery.
Recovery logs preserve allowlisted failure reasons without exposing file paths, credentials or raw SDK errors. Repeated identical checkpoint failures are logged once until a capture succeeds; the private status records the current failure. An unreleased owner explains blocked restarts, not necessarily the initial crash. Retain platform system/console logs externally to distinguish an interrupted shutdown, lost storage ownership, an unhealthy probe or resource exhaustion.
Blob destination and authentication (deprecated)
Azure Blob uses the identical storage-neutral core added after directory proof.
Use azblob://account/container[/prefix], without credentials/query strings.
Account is 3–24 lowercase letters/digits; container is 3–63 lowercase
letters/digits/hyphens with no consecutive hyphens. Prefix components use only
letters/digits/underscore/hyphen, 1–128 characters each. Empty components, dot
segments, percent escapes and trailing slashes are rejected.
Authentication is explicit managed identity (system identity by default,
AZURE_CLIENT_ID selects a user-assigned identity) or
FH_RECOVERY_CREDENTIAL_FILE pointing to a private standard connection-string
file. No default host CLI account discovery or credential logging is allowed.
The file must be a regular non-linked file with owner-only permissions, such as
mode 600/400; SAS and UseDevelopmentStorage shorthand are not accepted.
Transport credentials must live outside native/knowledge/workspace trees (or
inside the excluded private recovery directory), never in searchable knowledge.
An emulator endpoint comes only from that connection string; HTTP requires exact
FH_RECOVERY_ALLOW_INSECURE=1 and a host of localhost, 127.0.0.1, [::1] or
azurite. Cloud authentication and hosted/native-client qualification remain
separate from emulator evidence. S3 is not qualified. There are no cloud
management tools, hosting selectors, mandatory sidecars or startup installs.
The private health-only probe has /live and /ready, no control API. Do not
route it publicly. A conflicting or unavailable probe warns and is disabled;
it does not prevent restoration, checkpoints or native startup. Recovery environment must be removed from native worker/tool
launch environments, but trusted same-UID code is not OS-isolated from private recovery
files; external storage policies must protect retention/rollback independently.
Scheduling and durability
FH_SCHEDULER_ENABLED=0 disables boot task synchronization and cron,
not recovery, AKM knowledge or native access. Explicit scheduling enablement
preserves reviewed same-instance intent and resumes future slots only; it does
not replay missed slots or in-flight tool calls. Portable/manual restore retains
its separate task-review requirement.
Periodic captures use SQLite-native snapshots, never a changing database/WAL
file copy. Each database is individually consistent, but sequential databases
and workspace/auth files do not form one application-wide transaction. Capture
intervals must be recorded. Readiness requires completed restoration and active
ownership, not a recovery worker PID alone. An overdue or failed checkpoint
reports durable: false and a backup warning while the agent keeps running and
retrying. It does not make a working agent unhealthy or trigger a restart.
Actual ownership loss still stops writers to prevent competing checkpoints.
Private status publication is diagnostic: write failures warn and retry without
being treated as ownership loss. If status cannot be read, report diagnostics as
unavailable, not as proof that a live owner lost its lock. The owner still enforces
restoration and renewals independently; its exit stops the native writers.
Accepted-checkpoint age is owned by the engine after conditional publication
and its private receipt write; the supervisor uses that same monotonic clock.
A later staging-cleanup error must not make an accepted, receipted checkpoint
disappear from health bookkeeping. An older restored checkpoint alone does not
count as a fresh boot publication.
Core health proves the authenticated agent is usable and, when configured, restoration completed with a live recovery owner. Optional boot task sync, scheduler, knowledge and keep-alive failures appear as health-log warnings in CLI status and Admin Overview. They never trigger a whole-container restart. A failed boot task sync retries every minute until schedules are installed, and heartbeat failures retry. A stopped optional process requires corrective action and an explicit restart. Readiness is not provider/client readiness.
The potential loss window includes the timer interval, capture and upload time; outages make it longer. SIGTERM should stop writers and descendants before a bounded final checkpoint, releasing ownership last. SIGKILL or a failed final upload can lose changes after the previous accepted generation. There is no zero-loss or numerical RPO/RTO guarantee from small synthetic fixtures.
The recovery shutdown phase has a separate derived budget of twice
FH_RECOVERY_OPERATION_TIMEOUT_SECONDS plus 30 seconds. This allows an in-flight
capture to finish and then a final capture of the stopped writers. The default
host termination grace must cover 25 seconds for writers, two seconds for
killed-writer settling and 270 seconds for recovery: at least 297 seconds.
External deployments must supply a grace period covering the total budget. Increasing operation or writer
budgets requires increasing the host grace too. These bounds do not cancel
kernel-level hung filesystem I/O or guarantee a successful upload during an outage.
Snapshot subprocess deadlines do not guarantee cancellation of a kernel-level hung filesystem operation on a network mount. Use external host deadlines and health/routing controls; an unresponsive mount must never justify lock takeover while the previous writer may still exist.
Controlled shutdown and restart
Use the runtime's normal stop operation, which sends SIGTERM to the image's PID 1. Do not stop just OpenCode or signal the recovery worker directly. The entrypoint stops writers and descendants first, then waits for the recovery worker's in-flight capture and ownership renewal to finish before its final checkpoint and exact-owner release. A genuine renewal failure still prevents an unsafe final checkpoint. No pre-stop command, automatic unlock, sidecar or hosting-specific runtime is needed.
If a checkpoint fails, preserve the existing private
$FH_RUNTIME_DIR/recovery-status.json before restarting or replacing the writable
layer (default /tmp/fhold-runtime/recovery-status.json). Its checkpointFailure
records the capture/publication phase, filesystem code and syscall/path when
available, the current member path, previous generation and attempted generation.
Each path is bounded to 1 KiB of encoded JSON; truncated: true marks shortening.
The file is mode 0600 and may contain private filenames. Do not paste it into
public issues or ordinary logs. Normal fhold-recovery status, CLI/Admin status,
health probes and console failures omit this detail.
publication: "not-attempted" means this attempt had not called descriptor CAS;
"accepted" means the store confirmed the new descriptor before a later receipt,
cleanup or completion failure. "unconfirmed" means CAS was attempted but its
response did not confirm acceptance; inspect the private accepted descriptor
externally after stopping all writers before drawing conclusions. Neither an
ENOENT nor a nonzero final checkpoint exit proves the old generation remained
accepted. lastPublishedAt advances on confirmed descriptor acceptance, while
lastAttemptFailed and the nonzero shutdown result still report any subsequent
failure. There is no automatic fallback, unlock or omission of missing state.
If deployment setup runs before the assistant, prefer a one-shot setup followed
by exec /usr/local/bin/fhold-assistant under the image's init process. A parent
that remains running must forward TERM/INT and wait for the assistant's actual
exit, keeping its log streams open throughout cleanup. Keep the parent's signal
handlers installed until that exit and make repeat forwarding idempotent: a
one-shot listener can restore default termination while the child is still
checkpointing. In Node or Bun, use process.on('SIGTERM', stop) and
process.on('SIGINT', stop), not process.once, until the child exits.
AbortController.abort() is already idempotent. A child-process
AbortSignal error
reports signal forwarding, not completed shutdown. Test the deployed parent
chain, not just the stock entrypoint; do not infer owner release from either event.
- Finish or explicitly interrupt the current work, stop sending new requests, and retain console/system logs outside the disposable container.
- Request normal termination with the full grace period above. Managed installs
use
fhold --name my-agent stop; a standalone Docker deployment can usedocker stop --time 360 EXACT_CONTAINER. Supply at least the actual derived budget if settings differ; these examples do not override a hosting platform's deadline. When the host's stop API is asynchronous, wait for its operation result before issuing a start or deployment update; acceptance is not completion. - Check the retained entrypoint logs, in order:
shutdown: stopping native writers,shutdown: writers stopped; finishing recovery checkpoint and owner release,shutdown: recovery checkpoint completed and owner released, thenshutdown complete. A vanished/procentry during child exit is harmless, not a reason to abandon final recovery. A failed recovery worker produces a nonzero exit and a shutdown failure message, not a success claim. - Wait for the old container and all revision replicas/descendants to be gone.
Inspect the private checkpoint namespace: the accepted generation must remain
readable; Blob's descriptor
ownermust benull, or the directoryowner/noncemust be absent. A stop request, zero replicas or lease expiry alone does not prove this. Keep non-owner descriptor fields and artifacts intact. - Start the same instance using the same destination, identity and policy. Verify the saved native session and an accepted new checkpoint. Never reinitialize an established namespace.
Failed final uploads may leave the previous accepted generation and still release the owner; a killed worker or failed release may leave ownership recorded. Retain the failure logs and follow the externally confirmed exact-owner procedure only when necessary. It is not part of the routine stop/start path.
ACA lifecycle guidance describes SIGTERM during scale-in and revision deactivation. Its ARM Stop API is an asynchronous resource operation, not a recovery receipt. Qualify ARM Stop, revision deactivation and scale-to-zero separately using the sequence above and the real configured termination grace. Container/platform management remains outside fhold.
The fixed default engine limits are 10,000 files, 64 MiB per ordinary file, 256 MiB per database (including live main/WAL/SHM preflight), 1 GiB total member bytes, 4 MiB manifest and configured 120-second whole-operation/SQLite budgets. The operation uses monotonic deadline checks between steps, including restore, but this is not cancellation of a kernel-level hung filesystem call. Oversized SQLite members are rejected rather than becoming plain file copies. These are acceptance caps, not promised capacity: captured buffers, databases, temporary snapshots, downloads and application WAL growth consume additional memory/disk. Use externally enforced filesystem quotas and headroom; a free-space check is not a quota. A dense catalog can hit file-count limits before byte limits. Recovery preserves ordinary file contents and owner executable bits, not full ACLs/xattrs/group permissions or empty-directory metadata. Unsupported state must be reviewed explicitly rather than advertised as a perfect home clone.
Restore validates identity, supported checkpoint format, member hashes, SQLite integrity and path containment before admitting writers. Package versions remain provenance in the descriptor, manifest and receipt, not an upgrade gate. After restore, Assistant invokes AKM's native backed-up migrator before agents and task writers. Other native tools migrate their schemas when they start; recovery does not implement a dependency-version compatibility matrix. An empty replacement layout restores members selected by the current configuration. A surviving receipt matching the accepted generation permits missing selected members to be restored, including SQLite databases, while preserving every surviving local file or database, which may contain newer writes. Changing the image or retrying a failed startup does not invalidate that receipt. Recovery does not rescan a receipted home against backup size/count limits before starting native tools. Those limits apply to capture and restored artifacts, not newer surviving local files. This is not permission to adopt unreceipted local state, ignore orphan WAL/SHM files or overwrite existing files. Unexpected loss of an initialized core or explicitly registered database still blocks publication. Versioned Codex database filenames and newly discovered databases may change as native tools migrate their state. Unresolved authority fails closed. Corruption does not authorize automatic rollback to an older generation.
Container recovery retains the existing native roots (/home/fhold,
/stash, /work, /opt/akm/data, /etc/akm). Explicit additional paths restore
to their original absolute container locations. Container FH_HOME does not
remap them; host CLI/Admin home selection remains separate. Symbolic links and
special files are refused rather than silently followed or copied.
Directory artifacts can live on qualifying local or network mounts, but no real
network-mounted filesystem was exercised in the current qualification.
Which files are included?
The image owns an explicit, versioned catalog in
catalog.mjs. It recursively captures
ordinary files and SQLite databases in these trees, plus individually selected
SQLite databases outside them:
| Tree | Included state |
|---|---|
/work |
Workspace files, Git metadata and other regular files. |
/stash |
Knowledge, task sources/results and private native provider files. |
/home/fhold/.config/opencode, .local/share/opencode, .local/state/opencode |
Native OpenCode configuration, sessions, account and supporting files. |
/home/fhold/.codex |
Codex configuration, account, sessions, approvals and databases. |
/home/fhold/.claude, .claude.json |
Claude configuration, account, sessions and consent. |
/opt/akm/data, /etc/akm |
AKM durable state, logs and configuration. |
Generated SDK dependencies, vendor plugin caches, transient coordination files
and the rebuilt AKM index are excluded. The catalog is not the entire home:
for example, /home/fhold/.my-client and /home/fhold/.npm are not selected.
Adding a file under /work or /stash needs no catalog change, subject to the
existing bounds, link rules and SQLite checks. Keep third-party credentials out
of searchable knowledge and ordinary shared workspaces.
Experimental optional AKM index cache
Both cache settings default off and may change or be removed. For a managed
installation, save fhold recovery configure --akm-index-capture 1 --akm-index-restore 1
and apply through the normal restart. Admin exposes the two experimental switches
under advanced checkpoint settings. Standalone deployments can set the two
FH_RECOVERY_AKM_INDEX_* variables above. Set both to 0 to stop new captures
and ignore retained caches on the next restart. This preserves local indexes,
essential state, credentials, recovery identity and historical checkpoints;
switching off is not erasure. Settings have no effect without ordinary recovery.
Capture-only produces optional artifacts without restoring them. Restore-only
can consume and carry forward an already accepted eligible reference without
creating a new vector artifact. Both off omit the optional reference from future
checkpoints. The Assistant's boot akm index builds an absent index as usual. Explicit custom
SQLite selection of index.db retains its ordinary required semantics; remove
that selection if the intent is best-effort caching.
The first experimental scope supports plain JSON AKM configuration and materialized filesystem bundles with
one explicitly configured native akm or agent-skills component adapter per
bundle, including a declared component whose effective content root matches the
primary bundle path (the configured defaultBundle, /stash by default). Inferred adapters, a defaultBundle that is not
declared and enabled, and the deprecated AKM_BUNDLE_DIR override skip
caching without changing native detection or indexing behavior. Readable persistent and
read-only source mounts are supported. Inherited AKM configuration, other source providers or
adapters, missing/unreadable roots, and source roots overlapping explicit recovery
excludePaths skip the optional cache. Ordinary externalMounts and automatic
network-mount exclusion do not prohibit the cache. Opting in explicitly permits
copying native vector artifacts from those independently persistent bundles into
private recovery storage. AKM's format carries model fingerprints, hashes of
embedding input and vectors; it does not carry document text or source paths.
Vectors can still be sensitive. Review their
data sensitivity and backup access/retention policies first.
Artifacts bind to this instance and current enabled source IDs, roots, components, adapters and redaction settings, plus the recovery selection policy. Source revocation or an explicit source exclusion rejects the old reference. AKM owns vector format and model/text matching: a changed model or document is an ordinary import miss and uses normal native embedding behavior. fhold neither fingerprints semantic configuration nor reads AKM's vector/index schemas. Older experimental whole-index references are ignored; essential backups still restore normally. There is no exact AKM package-version admission requirement. Cache age is recorded as artifact provenance, never evidence of freshness or permission. There is no separate maximum-age setting.
Capture runs the shipped native akm index --export-vectors FILE against the
existing local index. It does not rescan sources, make embedding requests, copy
AKM state databases or rewrite live databases/configuration. No index or no
vectors means no optional artifact, so lexical-only installations gain no cache
startup work. An unchanged artifact reuses its existing content-addressed object.
Export still has command/read/transfer overhead; this is not a delta transfer.
Immutable artifacts increase retained storage when their bytes change.
After essential restoration, an eligible artifact is downloaded and its recovery
checksum verified. The shipped native akm index --clean --import-vectors FILE
builds a fresh private index from current sources, reusing only matching vectors.
AKM reads its own configuration and stored provider credentials in place; only
derived data/state are isolated. fhold does not parse/copy provider credentials.
These operations preserve native config/credential bytes. Native transient
coordination files remain AKM-owned and are not durable configuration changes.
Deleted or changed cached documents cannot be restored from the vector artifact.
Only a completed source scan, clean and successful native verification admits
the new database; successful lock skips are not completion proof. A
surviving local database or WAL/SHM is preserved. Invalid/missing/corrupt/oversized
caches and incomplete refreshes leave the core able to start without a restored
index; the boot akm index rebuilds it. Invalid or model-incompatible vector content
uses AKM's native fallback to normal embedding where it completes within the
budget. Native fallback can make ordinary embedding requests; recovery does not
run extract/improve/LLM enrichment or hydrate remote bundle providers.
Cache admission adds a
bounded startup delay; no cache means no full index build in core startup.
Surviving local indexes retain native AKM migration/freshness behavior; these
switches do not repair, replace or erase them.
Experimental limits are 64 MiB for each local index including its WAL/SHM and each artifact, and a separate five-second normal-operation budget per cache capture/admission attempt. Essential work keeps its configured operation allowance. The input bound skips large lexical indexes even when their vectors would be small. AKM streams the export since 0.10.261121 (AKM #1608), but restore still builds and copies a whole candidate index, which the same bound keeps in limits. Ownership renewal checks the actual owner and mount topology independently of that work budget. A checkpoint timeout fails the checkpoint; it cannot by itself turn valid ownership into an Assistant shutdown during optional cache work. Capture-enabled managed shutdown therefore adds ten seconds to the existing derived termination grace, covering an in-flight and a final capture. Standalone hosts must do the same. These limits bound accepted data and subprocess work, not total RAM/disk or kernel-hung filesystem I/O: private candidate databases, native temporary files, buffers and application growth need external resource headroom/quotas. Cleanup or uncancellable filesystem I/O can exceed wall-clock budgets. Optional cache errors warn through existing recovery/health diagnostics; actual ownership loss, topology changes and essential-state failures still retain their existing protection.
The native integration fixture reports cold indexing, checkpoint/admission time,
artifact size and provider calls for 96 synthetic documents with 384-dimensional
vectors and a deterministic endpoint with 100 ms request latency. It also verifies
changed/deleted sources, native model mismatch, credential references, corruption,
exclusions and lexical-only skipping. These measurements describe the fixture,
not production latency, throughput or real-provider behavior. Set
FH_AKM_CACHE_TEST_BUNDLE_ROOT to an existing disposable network directory to run
the same native cases with source files on that filesystem; configuration, state
and SQLite remain local. No existing bundle or stack is adopted by this test.
The external benchmark explicitly records safe deadline fallback when a source
scan exceeds the five-second admission budget; that adds startup work before
the ordinary boot index build, so opting into caching can be slower for that workload.
Measure core-ready and first-correct-knowledge-ready time separately, including
full artifact transfer, provider requests, checkpoint duration and retained-object
growth before enabling this optimization for a workload.
Additional files, directories and SQLite databases
Set FH_RECOVERY_INCLUDE_FILE=/run/fhold/recovery-include.json and supply that
file externally on every boot, including init and empty-container restoration.
For example, mount it read-only; it contains paths, not authentication keys:
{
"paths": [
"/home/fhold/.my-client",
"/extra/project-files",
"/extra/settings.json"
],
"sqlite": [
"/extra/project-files/application.db",
"/home/fhold/.my-client/state.sqlite"
]
}
pathsselects individual regular files or recursive directories, in addition to the native catalog.sqliteregisters individual database files; those files need not also appear inpaths. Either list may be omitted or empty. This unversioned format accepts only those two keys. There is no fixed entry-count limit; existing capture, manifest-size and deadline bounds still apply. The include file is at most 4 MiB.- Entries are literal, canonical absolute container paths. Spaces and Unicode are supported; globs, tilde/environment expansion, trailing slashes, dot segments, relative paths, links and special files are not. Repeated/overlapping entries capture each physical file once. Missing paths/databases may initialize later; unexpected loss of a captured explicitly registered database blocks publication.
- Each SQLite file uses the same bounded native
VACUUM INTOsnapshot and integrity validation as the built-in databases. Committed WAL changes are included, but live-wal/-shmfiles are never ordinary backup members. Additional SQLite is identified by its file header in selected directories, regardless of extension; it does not need a separatesqliteentry. The explicit list selects individual databases outside those directories. Databases must remain on local storage. Each database is consistent individually, not one transaction across all apps. - Operator-selected paths can opt into a normally omitted cache, but cannot select
recovery staging/receipts, runtime coordination, its storage credentials, its own
include file, the backup destination,
/proc,/sys,/devor the filesystem root. A deliberately selected parent such as the native home still excludes private engine/runtime state. Do not put the include file in a captured tree; a read-only external mount or excluded private recovery directory is appropriate. Native Codextmp,.tmp,locks,thread-writer-locksand its live control socket, AKM process locks and Claude's.claude/bridge-spawndirectory remain excluded even when a parent is selected. Claude removes its per-spawn prompt files on child exit; they are not durable conversation or account state. Native.claude/backups/.claude.json.backup.<numeric-timestamp>copies are also excluded from capture and old-checkpoint restore: Claude rotates them while it runs. The actual.claude.json, corrupted-config evidence and unrelated files in the backup directory remain covered. Missing durable files still fail capture. These exclusions cover transient native state, not plugin/account data. Ordinary native control metadata and operator-selected plugin caches remain recoverable; arbitrary links elsewhere are still refused, never dereferenced as a shortcut. Bundled native plugin caches contain executable symlinks. Keep their default exclusion; when explicitly selecting.claudeor.codex, also list/home/fhold/.claude/plugins/cacheand/home/fhold/.codex/plugins/cacheinexcludePaths. The image reseeds these caches; account settings and plugin selections remain covered. A custom cache can be selected only if its files meet the same regular-file and size rules as other recovery content. For the image's AKM data/state layout, the reserved transient paths are/opt/akm/data/index.db.write.lock,index.rebuild.lock,akm.lock.lck,state/locks/,secret-locks/,extract-locks/,workflow-run-locks/, and/etc/akm/config.json.lck. Native PID/UUID temporary and stale-lock companions of those sentinels are also excluded. Durable/opt/akm/data/akm.lock, native state/log databases and configuration are preserved. These are specific native locations, not a general rule to omit files ending in.lock. Older checkpoints containing these previously captured AKM locks remain usable: their original manifest/selection identity, member metadata and budgets are validated, but current coverage omits the transient members before staging or reading their objects. All restored content still passes checksum and SQLite integrity checks before any target is written. Historical objects are retained; the next successful checkpoint omits them. Surviving local locks are neither removed nor overwritten; AKM retains ownership of their live lifecycle. If an older include file explicitly registered a now-protected lock path inpathsorsqlite, remove that transient registration before restarting; retaining it is rejected as protected state. Other selections and historical essential state remain usable. Selecting a parent directory needs no change. - Custom catalogs record the normalized lists in the immutable manifest and bind their hash into the descriptor/receipt. Restore never adopts paths from a backup that the current operator configuration does not cover. The external tooling must preserve this configuration across replacements; it is not itself restored.
- Apply selection changes on the next restart. Restore uses the current selection and leaves newly excluded, unselected or independent paths untouched. The next accepted checkpoint records the new selection; older immutable checkpoints remain intact. Adding or removing entries does not require a new destination, identity or receipt. Reordering/duplicates do not change the normalized selection. Never reinitialize an existing namespace.
Files restore to their original locations without overwriting pre-existing files. The image's non-root user must be able to create/write the chosen locations and parent directories. A backup of a read-only mounted source needs a writable empty target on replacement; this does not add mount provisioning or mount remapping. This selection works identically for directory and Blob destinations, with no Azure-specific settings in the snapshot algorithm. Host-specific deployment placement belongs to the provider, not the recovery engine.
Do not use path selection to emulate an unavailable OS credential store: a client whose tokens live in a desktop keyring still needs a headless storage backend. Runtime backups may now include third-party private state: protect the destination and avoid selecting credential folders into searchable knowledge.
Local CLI/Admin portable backup is a different archive: it selects knowledge, workspace and a small operator-configuration allowlist, with explicit sensitive data opt-ins. It does not back up the native runtime home. Use same-instance recovery for ephemeral hosting, not a portable archive as full runtime recovery.
CLI/Admin also offer entire-instance export/import with containers stopped. It includes all home-owned native state and recovery configuration/receipts, but does not roll back an external checkpoint namespace, lease or independently persistent mount. Import stays stopped and preserves the saved identity; review the recovery destination and stopped-writer ownership before starting. This manual directory snapshot is separate from automatic ephemeral checkpoints.
Independently persistent mounts
Use the versioned form of the same externally supplied include file when some content belongs to an independent drive/volume rather than recovery:
{
"version": 1,
"paths": ["/home/fhold/.my-client"],
"sqlite": ["/home/fhold/.my-client/state.sqlite"],
"excludePaths": ["/work/scratch"],
"externalMounts": ["/work/shared-drive"],
"autoExcludeNetworkMounts": false,
"recoverMounts": []
}
Lists default empty; discovery defaults off. This policy works with ordinary Docker binds, named volumes and independently provisioned mounts on other hosts. The recovery engine does not provision mounts. Host providers may attach existing storage separately; selecting a path here never attaches or copies a drive.
excludePaths: canonical absolute directory roots skipped even when absent or not mounted. Recovery never traverses/restores them. Existing linked paths and non-directories fail; redundant nested entries normalize away.externalMounts: exact required visible, readable directory mount roots, also excluded recursively. An ordinary directory is not a substitute. Missing mounts block initialization/startup/capture/restore without creating fallback directories. Roots outside the selected catalog work too. External tooling owns backing-volume identity and expected read/write permissions.autoExcludeNetworkMounts: opt-in discovery of visiblecifs,smb3,nfsandnfs4mounts intersecting selected content, including nested, ancestor and file mounts. It never excludes/or guesses persistence for local volumes, tmpfs or unknown FUSE. Declare known required mounts explicitly: discovery cannot detect a mount absent on the first boot.recoverMounts: exact visible mount roots retained despite network discovery. These must exist, do not select otherwise unselected files, cannot override explicit exclusions, and do not opt in separately mounted descendants. Captured read-only files still require a writable empty restore target. This exception never permits network SQLite.
Ordinary local Compose home/data/workspace volumes retain their coverage. There is no “ignore all mounts” switch. External read-only roots are never chmodded or written; newer independent content survives cold restore and does not count as unreceipted local runtime state.
Built-in and explicitly registered SQLite and WAL/SHM paths cannot be excluded, even before a database exists. Recognized network placement fails even with discovery off or a mount opt-in. Newly discovered SQLite in retained trees also uses native snapshots and must remain local. Excluded content is not inspected/certified: relocate any database an application opens there to local storage. See SQLite's network-filesystem guidance.
Linux /proc/self/mountinfo is read in this container's namespace. Parent
relationships resolve stacked/hidden and same-device binds; sources/credentials
are not stored or logged. See the Linux mountinfo contract.
Mount IDs detect changes within this process, never durable identity across boots.
Topology is rechecked before accepted publication, SQLite snapshots and each
native restore write. Changes abort; partial restore journals remain and writers
are not admitted. This cannot protect against a privileged host racing remounts
between checks. Keep mounts stable; hung I/O needs external termination bounds.
Run the image's private, read-only fhold-recovery inspect with the same
configuration/mounts to see selected trees/databases, exclusions and required
mount read-only state. It never creates a namespace or claims ownership. Its
path-bearing output is for operators, not public health. status remains compact.
Versioned policies use catalog 3: normalized policy and effective automatic exclusions are hash-bound to the immutable manifest and descriptor/receipt. Catalogs 1/2 and legacy include files remain readable with original coverage; old images reject catalog 3 rather than ignoring exclusions. Historical manifests retain their recorded selection and hashes. Restore applies the current policy, including current network-mount discovery, without overwriting newly excluded or independently owned paths. Required mounts must still exist. These coverage edits keep the same instance identity and checkpoint destination.
Change an established recovery ownership policy
Coverage can change on restart without a policy-migration engine or new checkpoint namespace. For an existing recovered directory moving onto an independent drive, the external operator handles the data move:
- Stop and externally confirm all old writers/publishers and descendants have stopped. Retain the checkpoint, original disk, private receipts and logs.
- If necessary, restore/validate offline with the original policy into empty
local native paths. Override the normal entrypoint
and run
fhold-recovery restore --confirm-stoppedwith the old destination, identity and mounts. It releases ownership after validation, without seeding defaults or starting writers. Valid surviving local state is preserved. - Transfer the relevant content offline to the independently provisioned drive; verify it and mount its exact declared root. External tooling owns this move.
- Supply the new policy with the same destination, instance ID and private recovery state. Never edit receipts or historical manifests. The new policy keeps the independent drive out of restore and future capture.
- Start normally; do not initialize again. Verify the independent content and an accepted checkpoint before retiring any old copies. Historical checkpoints retain their original members, even when the new selection omits them.
--confirm-stopped is an operator assertion, not proof that another writer is
dead. Selecting or excluding a path is not a data-copy operation; recovery never
migrates files onto an independent drive or provisions the mount.
Qualification limits
Reproduce local qualification
Use a checkout with installed Bun dependencies and an explicitly selected local candidate Assistant image. Image tests require a usable Docker daemon; they never use real provider/vendor accounts or an existing home.
bun run test:recovery
FH_RECOVERY_TEST_IMAGE=YOUR_EXACT_LOCAL_CANDIDATE_IMAGE bun run smoke:recovery
FH_RECOVERY_TEST_IMAGE=YOUR_EXACT_LOCAL_CANDIDATE_IMAGE bun run smoke:recovery:blob
# Exercise a published-image upgrade with empty storage, then a surviving home:
FH_RECOVERY_TEST_IMAGE=YOUR_EXACT_LOCAL_CANDIDATE_IMAGE FH_RECOVERY_UPGRADE_FROM_IMAGE=YOUR_PUBLISHED_SOURCE_IMAGE bun run smoke:recovery
FH_RECOVERY_TEST_IMAGE=YOUR_EXACT_LOCAL_CANDIDATE_IMAGE FH_RECOVERY_UPGRADE_FROM_IMAGE=YOUR_PUBLISHED_SOURCE_IMAGE FH_RECOVERY_TEST_SURVIVING_HOME=1 bun run smoke:recovery
FH_RECOVERY_TEST_IMAGE is required for both image commands; choose the exact
built digest/ID, not an assumed latest image. Blob smoke creates a disposable
Docker network, private fixtures and local Azurite 3.37.0 container; it does not
contact Azure. It uses emulator-only --skipApiVersionCheck because shipped
SDK 12.34.0 requests REST 2026-10-06, newer than that emulator's accepted versions.
Do not apply that workaround to a cloud endpoint or interpret it as cloud API
compatibility qualification.
Emulator qualification also injects a single delayed renewal, an unresponsive connection, a server-accepted renewal whose response is lost, a definitive lease conflict, responses arriving after the safety deadline, and sustained service or connection outages. It exercises the shipped Azure retry policy and adapter under both Node and Bun with real monotonic timing. The real recovery wrapper must signal its synthetic writer parent by the original safety deadline, retain the last accepted checkpoint and refuse automatic takeover. Both native CI architectures run this fixture and the full Blob replacement smoke. This does not inject faults into Azure or qualify a real hosted outage.
Run the smokes as a non-root Linux user with Docker access. Their containers use that user's numeric UID/GID, matching private bind-mount ownership without weakening permissions or modifying the candidate image.
Smoke scripts retain private /tmp/fhold-recovery-smoke-* and
/tmp/fhold-blob-smoke-* fixtures/reports, including synthetic account/trust
state and runtime env. They clean only their own tracked test containers/network;
never use broad Docker pruning or wildcard directory deletion. Keep retained
fixtures private and out of searchable knowledge/commits. Review each report's
exact fixture path and confirm it is generated by that run before requesting
path-specific cleanup approval; use trash when practical. Failed-run state is
diagnostic evidence, not permission to erase backups or a live installation.
Evidence scope
Local synthetic acceptance proves only exercised cases. Synthetic credential and trust files establish file preservation, not token refresh, native-client account readiness or sandbox support. Keep account and hosting qualification separate. No real network-mounted filesystem or numerical RPO/RTO is qualified by these tests.
The reusable focused recovery suite covers explicit custom file/directory/database
lists, coverage edits, discovered SQLite, WAL/concurrent captures, empty-layout restoration,
workspace/Git/modes/deletions, all registered Codex databases, initialized-presence
enforcement, corruption/deadline/ownership refusal, safe errors and accepted
publication clocks, upgrades with changed dependency versions, surviving receipts
and backup warnings without stopping the agent. Entrypoint tests cover scheduler independence and separate
writer/final-checkpoint budgets, deterministic process exit between /proc
check/read, and visible nonzero final-recovery failures. Exact-image directory and Blob-emulator smokes
exercise native session/shell/file APIs, restored state and all three offline
AKM harnesses without copying host accounts or repairing image behavior. Native
smokes on OpenCode 2 also complete a synthetic native assistant reply, wait seven
seconds before normal Stop, and compare full native message records after fresh
restore. Both directory and Blob-emulator runs cover the independent read-only
configuration file and required read-only/writable drive boundaries. Bind mounts
do not qualify actual CIFS behavior, live managed identity or signed-in workers.
These tests do not reproduce the hosted ENOENT reported in issue #42.
Upgrade smokes replace a published image in cold-storage and surviving-home modes, then
restore a checkpoint produced by the replacement image on its next restart.
Candidate-image stops also verify PID 1's ordered shutdown/completion logs;
the Blob smoke verifies the final accepted generation and cleared owner.
These local fixtures do not qualify ACA's ARM Stop or establish the exact cause
of a past hosted shutdown without matching retained platform logs.
See Linux product qualification for exact candidate evidence and remaining product gates. Host-specific deployment, optional third-party setup and hosting qualification remain external operator responsibilities, not additional fhold runtime features.
See the runtime plan and implementation review for the general responsibility boundary and current code map.