State Operations and Safety
Direct state operations edit Netherframe's durable record of managed objects without
calling cloud create/delete APIs. Prefer normal nf plan / nf apply runs for routine
changes; use nf state subcommands for refactoring resource IDs, recovering from crashes,
releasing stuck locks, or operating PostgreSQL graph state.
Before touching state
- Confirm which backend and state location your command targets:
nf backend show - Verify no other apply is currently running (
nf follow --app <app>ornf tui). - Make a backup copy of local state (or confirm object versioning / checkpoints are enabled on remote state) before destructive edits.
Rename a resource without destroy/recreate (nf state mv)
Changing a stack ID or resource nf_id in Python changes its state address, which would
otherwise plan a - delete and + create. Move the state entry to the new address first:
# Rename a resource inside the same stack
nf state mv --app platform network.aws_vpc.old_main network.aws_vpc.main
# Move a resource across stacks
nf state mv --app platform core.aws_s3_bucket.logs audit.aws_s3_bucket.logs
- Works on every hybrid backend (local, S3, GCS, Azure, Consul, PostgreSQL document, PostgreSQL graph, HCP Terraform) in a single conditional write.
- Automatically rewrites dependency references in other state entries that pointed at the old address.
- Infrastructure is untouched; follow up with
nf plan --app platformto verify zero changes.
Stop managing a resource without deleting it (nf state rm)
To remove an object from Netherframe state while leaving the live cloud object running:
nf state rm --app platform storage.aws_s3_bucket.legacy_archive
- Netherframe refuses to leave a remaining state entry dangling on a removed dependency—if other resources depend on it, pass all dependent addresses together or remove their references first.
- Remember to remove the resource declaration from Python too, or the next
nf planwill propose creating a brand-new object.
Force replacement on the next apply (taint / untaint)
Mark a healthy-looking object as tainted so the next nf plan / nf apply replaces it
regardless of configuration:
nf state taint --app platform compute.aws_instance.worker_0
nf plan --app platform --diff # shows ± replace (reason: tainted)
# Clear the taint if you change your mind before applying
nf state untaint --app platform compute.aws_instance.worker_0
(Note: prevent_destroy still blocks replacing a tainted resource.)
Release a stuck lock after a crash (force-unlock)
Local POSIX locks (flock) clear automatically when a process exits. On remote document
backends (S3, GCS, Azure, Consul), if a runner crashed hard without releasing its lock,
read the lock ID from the error message and confirm no process is still applying before
unlocking:
nf state force-unlock <LOCK_ID> --app platform
Audit and resume finalizers after a hard crash (runs / verify / abandon)
For apps with app.check(..., phase="finalize"), Netherframe writes a run record beside
state before the first mutation. If a run is killed with kill -9 or a CI runner dies:
# 1. Inspect recorded runs and spot any stuck in "running"
nf state runs --app web
# 2. Re-run finalizers under the state lock (unrecorded changes appear as "unknown")
nf state verify --app web
# 3. Only if you have manually reconciled and want to discard an unrecoverable record:
nf state abandon --app web <RUN_ID>
See App Checks and Finalizers.
PostgreSQL graph-state operations
Apps backed by PostgreSQLGraphBackend expose additional row-level and fenced-operation
commands:
# List active or unresolved fenced operations
nf state operations --app parameters --all
# Recover an interrupted or quarantined operation
nf state recover --app parameters [OP_ID]
nf state recover --app parameters <OP_ID> --confirm-terminated
# Inspect version history or point-in-time state
nf state history --app parameters payments.aws_ssm_parameter.timeout_ms
nf state show --app parameters --at <SEQUENCE|RUN_ID|TIMESTAMP>
# List, inspect, or restore graph checkpoints
nf state checkpoint list --app parameters
nf state checkpoint restore --app parameters <CHECKPOINT_ID>
# Direct single-entry import into graph state
nf state import --app parameters payments.aws_ssm_parameter.timeout_ms /payments/timeout_ms
# Migrate state between document JSON and PostgreSQL graph state
nf state migrate --app parameters --to graph --source .nf.out/nf.tfstate
nf state migrate --app parameters --to document --path exported.tfstate