@struktoai/mirage-core
Version:
A Unified Virtual Filesystem For AI Agents
37 lines • 2.24 kB
TypeScript
import { type LostPaths, type OpRecord } from '../../observe/record.ts';
import type { CacheFacts } from '../../types.ts';
import type { FileCacheMixin } from './mixin.ts';
/** Serialize cache fills with mount ownership changes, including remote writes. */
export declare function mutationLock<T>(cache: FileCacheMixin, fn: () => Promise<T>): Promise<T>;
/**
* Latest backend fingerprint a read recorded for `path`.
*
* Reads only: a write's own record labels the bytes it sent. Backends stamp a
* read record with the content
* identifier they returned (S3 ETag, OneDrive cTag, Postgres sha256).
* Threading it into the cache entry lets a `fresh` mount's `isFresh`
* compare like with like. null means the bytes carry no token, and the
* entry then stores none: an unverifiable copy is dropped and re-read,
* which is what a fabricated one produced anyway on every backend whose
* token is not an md5 of the content.
*
* Only the newest read of the path counts: when it carries no token, neither
* does the entry, whatever an earlier read stamped. The backend did not vouch
* for the bytes stored, and an older read's token would label bytes it never
* described, which a later revert to that token serves as fresh.
*/
export declare function latestFingerprint(records: readonly OpRecord[] | undefined, path: string): string | null;
/**
* Keep the version each path last had on the line, on conditional mounts. A
* read that fills no cache (`grep`, `head`) or a write that keeps no bytes
* (`>>`, a resize, a cross-mount `cp`) still names the version it saw, and
* the next line's write on a conditional mount needs it; so does a refusal,
* whose read may have been served from the cache and left no record. Runs
* when the line ends. Mirrors Python's `keep_versions`.
*
* @param nested a nested line's (`eval`, `$(...)`): it keeps only the
* versions of paths still lost; its line keeps the rest. Its read records
* do not count: a concurrent sibling stage records into the same list.
*/
export declare function keepVersions(cache: FileCacheMixin, records: readonly OpRecord[], cacheFacts: (path: string) => CacheFacts, lost: LostPaths | null, nested?: boolean): Promise<void>;
//# sourceMappingURL=io.d.ts.map