/** * True when `path` is `root` itself or a descendant of it. * * Segment semantics, not string-prefix semantics. `relative()` returning * something that starts with the two characters '..' does not mean the path * escapes the root: `home/..state` is a legitimate descendant whose relative * path is '..state'. Only a leading '..' *segment* climbs out. */ export declare function isUnderRoot(root: string, path: string): boolean; /** * The write root currently in effect. Capture this once, when a storage object * is constructed, and hold it for that object's lifetime. * * `resolveAnimaHome()` picks a cwd-local `.anima` *only while that directory * exists*, and otherwise falls back to `~/.anima`. So the root is not a stable * fact about the process: delete the local home and the "root" silently becomes * a different directory. A guard that re-derives the root on every write will, * after teardown, decide the doomed path was never inside the root at all - and * happily recreate it. Root identity must outlive the directory it names. */ export declare function currentWriteRoot(): string; /** * Create the parent directory of `path` without ever creating `root`. * * Inside the root, directories are created one segment at a time with * **non-recursive** `mkdir`, anchored at the root. A non-recursive `mkdir` * cannot manufacture its own parent, so no call in this walk is capable of * recreating the root: if the root vanishes before or during the walk, the very * next `mkdir` fails with ENOENT. That is a structural property, not a checked * one - there is no window between "we looked" and "we wrote" in which a delete * can slip through, because the dangerous operation does not exist here. * * (`mkdir(dirname(path), { recursive: true })` is exactly that dangerous * operation, and it is why an operator's `rm -rf` raced a late health flush and * lost.) * * Paths outside the root are none of this guard's business and keep the old * recursive behavior. */ export declare function ensureParentDirectory(path: string, root: string): Promise; /** * Create `directory` and any missing ancestors *below* `root`, never `root`. * * The same walk `ensureParentDirectory` uses, exposed for the callers that * create a directory rather than a file's parent - `AgentHealthStore` and * `AgentRestartCommandStore` provisioning `/run`. Those used a recursive * mkdir, which made them a second, accidental provisioner of the runtime root: * startup could create the *ambient* home and then have `ensureDirectory()` * silently manufacture the real one. Deliberate provisioning belongs to * `ensureAnimaHome`, and to nothing else. */ export declare function ensureDirectoryUnderRoot(directory: string, root: string): Promise; /** * Create the write root deliberately. Called by the acts that genuinely * provision - runtime startup, and the CLI commands that write config - so that * every later write can assert the root rather than manufacture it. * * Takes the root explicitly, from the same authority as the caller's stores. A * caller that holds an explicit home (`RuntimeHost` with `deps.animaHome`) must * pass it: provisioning the *ambient* root instead would create a directory * nothing writes to, while the caller's own stores correctly refuse to write to * the home that was never created. Defaults to the ambient root, which is right * for callers that have no other authority. */ export declare function ensureAnimaHome(root?: string): Promise; //# sourceMappingURL=write-root.d.ts.map