UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

51 lines (50 loc) • 3.61 kB
export interface RetentionPolicyKnobs { /** Age bound in ms. */ maxAgeMs?: number; /** Row-count bound, whole rows. */ keep?: number; /** Age bound in ms for the stale-running flip arm. */ staleRunningMaxAgeMs?: number; /** Row-count bound, whole rows (roster's write-time cap). */ maxEntries?: number; } /** * The family's typed refusal, exported so a seam whose bound has its own ADMISSIBLE RANGE refuses in * the same grammar under the same code instead of minting a second one. The one in-tree case: * file-history's boundary cap requires `>= 1` where the row stores accept `0` ("keep no rows" is a * coherent policy for a ledger; for a history whose every commit mints a boundary it is not — the * cap would reap the boundary its own commit just published), so that door cannot reuse * {@link assertRetentionPolicy}'s "0 or more" wording without telling an operator something false. */ export declare function refuseRetentionPolicy(label: string, knob: string, value: unknown, requirement: string): never; /** * The cutoff an age sweep removes entries before — `now - maxAgeMs` — or `undefined` when no age bound was stated * (nothing is aged out). A bound that cannot be evaluated is refused, as {@link assertRetentionPolicy} refuses it, and * so is a `now` that is not a finite number: either would decide what to delete instead of bounding it. The bound is * read once, and the value judged is the value the cutoff is computed from. */ export declare function ageCutoff(label: string, now: number, opts: { maxAgeMs?: number; } | undefined): number | undefined; /** The family's coded refusal of a retention bag's stray key ({@link receiveMembers}'s one sentence, under the family's code): * a misspelled bound (`maxAge` for `maxAgeMs`) reads as "no bound" — nothing is deleted and nothing is said, the silence a * retention seam exists to remove. */ export declare function retentionKnobRefusal(message: string): Error; /** * The one reading a seam takes of a caller's retention bag: the bag is received by the receipt law with the seam's * knobs as the members it takes ({@link receiveMembers}: a plain object, each member read once off its own descriptor, * a member it does not take refused by name in the family's code), each knob on the copy is judged by * {@link assertRetentionPolicy}, and the frozen copy is handed back — the value a seam judges is the value it then * deletes by, and nothing is read from the caller's bag again. A Proxy, an object of another prototype (a bound it * would inherit is never read) and a getter that throws are the receipt's refusals (`config.invalid_argument`). * Absent bag ⇒ an empty policy (nothing is applied). `beside` names members of the same bag that are not knobs and that * the seam reads itself (the joint reap's `now`): taken by the same receipt, handed back on the copy, never judged here. */ export declare function receiveRetentionPolicy<P extends RetentionPolicyKnobs>(label: string, opts: P | undefined, accepts: readonly (keyof RetentionPolicyKnobs)[], beside?: readonly Exclude<keyof P, keyof RetentionPolicyKnobs | number | symbol>[]): Readonly<Partial<P>>; /** * Refuse a malformed retention policy at the door. `undefined` on any field keeps its documented * meaning — that arm is simply not applied — so a deployment that sets nothing is untouched. * * @param label the caller's own name, so the error names the seam the operator configured. */ export declare function assertRetentionPolicy(label: string, opts: RetentionPolicyKnobs | undefined): void;