@sema-agent/core
Version:
Stateless, task-oriented AI agent core
34 lines (33 loc) • 2.63 kB
TypeScript
/**
* What a host states about a file data root — facts about the DEPLOYMENT the engine cannot observe from inside one process.
*
* `singleProcessTable: true` states: every process that opens this data root runs in this one process table — no other
* container and no other host mounts it (a self-launched, single-user process over a local disk). The directory locks under
* the root then read a lock record that names no pid namespace (one written by an engine before the namespace was recorded)
* as written in this table, and judge it by its pid and start times like any lock written here. Without the declaration such
* a record is not comparable on a host that names its pid namespace (Linux), because a restarted container keeps its host
* name while its pids live in another table, and it is refused until removed by hand.
*
* It is NOT true — and must not be declared — where two containers, pods or hosts can have the root mounted at once: several
* replicas over one volume, or a rolling upgrade during which two generations of a pod both run.
*/
export interface DataRootDeclaration {
/** Every process that opens the data root runs in this one process table. Only the literal `true`. */
readonly singleProcessTable: true;
}
/**
* Declare a fact about a file data root ({@link DataRootDeclaration}). Call it before the first store over the root is
* opened; a lock judged before the call was judged without it. Declaring a root twice is declaring it once, and the
* declaration lasts for the process.
*
* The root is resolved exactly as `FileStorageBackend` resolves its own ({@link resolveDataRoot}: NFC-normalized, created
* if absent, then its physical path), so the declaration names the directory the stores open — and every directory lock at
* or under it, whichever store or door takes it, reads the declaration. `anchor` places a relative root as the backend's own
* `anchor` option does (another process's working directory, for a host declaring the root that process will open).
*
* Refused `config.invalid_argument`: a root that is not a non-empty string, a declaration that is not a plain record, a member
* the declaration does not take, a `singleProcessTable` that is anything but the literal `true` (`"true"`, `1`, `false`
* included — a deployment for which the fact does not hold makes no declaration; a member only a prototype supplies is no
* member), and an anchor that is not a non-empty absolute path. A refused call declares nothing.
*/
export declare function declareDataRoot(root: string, declaration: DataRootDeclaration, anchor?: string): void;