import { type WorldLockOptions } from './world-store.js'; import type { WorldPaths } from './types.js'; /** The project root a World's state lives under, resolved (worldPaths's `root`, without claiming a journal identity). */ export declare function projectRoot(root?: string): string; /** * Name of the per-project state directory holding world data * (`//world/...`). Defaults to `.volter`; hosts that need a * different directory set VOLTER_STATE_DIR. Every path in this package must * go through worldStateRoot — never the literal. */ export declare function stateDirName(): string; export declare function worldStateRoot(root?: string): string; /** Install the observer; the one it replaces is returned (a test puts it back). */ export declare function observeWorldPaths(observer: ((service: string, root: string | undefined) => void) | undefined): ((service: string, root: string | undefined) => void) | undefined; /** Run `fn` without its worldPaths calls reaching the identity observer. */ export declare function withoutIdentityClaim(fn: () => T): T; export declare function worldPaths(service: string, root?: string): WorldPaths; /** * THE WORLD'S DATA DIRECTORY, as the World runtime hands it to every service it starts. Each twin of a World runs on * its own root, `/` (world-runtime's startService and startColocatedServices), so one twin's * `.volter/world/` is not another's; `ownerStoreRoots` finds a store across them. */ export declare const WORLD_DATA_ENV = "VOLTER_WORLD_DATA"; /** * The roots that hold the store of `owner` (ANOTHER pack's, read by contract: architecture A3), for a twin on `root`: * - `[root]` when `root` itself holds that store (both packs on one root: `volter world serve`, a test, a pack serving * several services on its root, as aws does); * - else, when `root` is one of a World's service roots (a directory directly under the World's data directory), every * other service root there that holds it (usually one; two when the World runs the owning pack twice); * - else `[]`: nothing is issued yet, or the twin runs outside a World. * Only a declared cross-pack read resolves through here (`projectOwnerResources`); a pack's reads of its OWN store never * leave its root, so a fresh twin never reads a sibling that happens to run the same pack. Not memoized: it is a few * stats per service root, and a store that appears after the first read (the owner's first write) must be found. */ export declare function ownerStoreRoots(owner: string, root?: string): string[]; /** Read + parse a whole-file JSON sidecar, citing the path on a parse failure. Callers own * existence semantics — this parses a file that is expected to exist; guard with existsSync * first when absence is allowed. */ export declare function readJsonFile(path: string): T; /** * Append `data` to `path`. When VOLTER_DURABLE=1, `fsyncSync` the file after the write so * the appended record survives an OS crash / power loss — not just a process crash. * * Default (VOLTER_DURABLE unset) is OFF: `appendFileSync` is a completed write syscall, so a * *process* crash after it returns still leaves the record on the log (the OS owns the page * cache). The window this leaves open is a **kernel-panic / power loss** between the write * landing in the page cache and the fs flushing it to stable storage — a torn or lost tail * record. That crash window matters more once real pulled staging data lives in these files * (purpose 2), so hosts that need durability opt in with VOLTER_DURABLE=1 at the cost of an * fsync per append. See docs/contributing/architecture.md D1. */ export declare function appendDurable(path: string, data: string): void; /** * Opt-in structured stderr logging for the audit trail: * one line per action-log append and per push-ledger row, so "who reviewed the change * that caused this real write" is mechanically greppable from a single log stream via * `correlationId`. Off by default — mirrors the VOLTER_DURABLE opt-in policy above: no * always-on I/O, never on the default path. Set VOLTER_TWIN_LOG=1 to enable. */ export declare function twinLog(kind: string, details: Record): void; /** Run `fn` holding an exclusive cross-process lock, via the active store. On the fs * store this is the reclaimable file lock the event log uses; on an in-memory, * single-instance store it is a synchronous pass-through. Used to make read-then-append * critical sections atomic. Public so world-runtime can guard concurrent `upWorld` * claims of one instance dir with the SAME lock semantics the event log uses. */ export declare function withFileLock(lockPath: string, fn: () => T, options?: WorldLockOptions): T; /** Exported so other modules that share a service's events log (e.g. egress.ts) * can serialize their own critical sections on the SAME lock, instead of * inventing a second, uncoordinated lockfile. */ export declare function eventsLockPath(paths: WorldPaths): string; /** * Serializes mutations that can change a service's projected state, regardless of whether the * durable row lands in events.jsonl or actions.jsonl. The per-log locks still protect their own * append/dedupe mechanics; this outer lock makes a projection-based decision linearizable against * connector observations as well as local actions. */ export declare function projectionLockPath(paths: WorldPaths): string;