Expand description
Pin the chain storage location once at boot, and guard it with a lock.
The kernel reads the chain checkpoint path in several places: boot
(signing key, RVF restore, tree checkpoint), the daemon’s chain.verify
RPC, and shutdown persistence. pin_chain_storage resolves the path a
single time and writes it into the kernel config, so all of them agree
even if the environment changes after boot.
Resolution, highest first:
- an explicit
kernel.chain.checkpoint_path; chain.jsonunder the runtime root (clawft_types::runtime_paths::RuntimePaths:$WEFTOS_RUNTIME_DIR, else the project’s.weftos/runtime, else legacy~/.clawft);- a project root with no chain yet, while
~/.clawft/chain.*exists (and no--new-chain): keep using the legacy chain and key. Booting a fresh genesis here would silently fork the operator’s history, so the legacy chain stays in use (WARN) untilweaver migrate user-chain(ADR-103 Phase 1) moves it.
Once the legacy chain
carries a MIGRATED-TO-WEFTOS.txt marker, a boot that would still land on
it is refused (it would fork history) unless WEFTOS_RUNTIME_DIR isolates
it or --adopt-legacy-chain is passed (with a WARN).
Whichever chain is in use is guarded by ChainLock (chain.lock beside
it) for the kernel’s lifetime, so two kernels can never append to one
chain. In this crate’s own unit tests the default is a fresh temp dir per
boot, so cargo test never touches the operator chain.
Structs§
- Chain
Choice - Which chain a default-path boot should use.
- Chain
Lock - Exclusive advisory lock on
chain.lockbeside the chain in use. - PinOutcome
- What
pin_chain_storage_noteddecided.
Enums§
- Chain
Lock Error - Why
ChainLock::try_acquirefailed.
Constants§
- LEGACY_
ACTIVE_ WINDOW - A legacy chain modified within this window may still have a live writer.
Functions§
- boot_
runtime_ paths - The runtime paths this boot uses for every non-chain runtime file (cluster peers, apps, revoked hosts).
- choose_
default_ chain - Choose the default chain for
paths(see module docs, rule 2 and 3). - pin_
chain_ storage - Resolve the chain checkpoint path and pin it into
kernel_config.chain. - pin_
chain_ storage_ noted pin_chain_storageplus the warning and refusal for the choice.- request_
adopt_ legacy_ chain - Allow the next boot to adopt the legacy
~/.clawftchain for the first time (weaver kernel start --adopt-legacy-chain). Needed only while nochain.lockexists beside it, i.e. no lock-aware kernel has used it yet. - request_
new_ chain - Ask the next boot to start a fresh chain at the resolved path instead of
adopting the legacy
~/.clawftchain (weaver kernel start --new-chain). Process-wide on purpose: it is an operator flag, not a config-file field.