/** * Copyright (c) 2025 Elara AI Pty Ltd * Licensed under BSL 1.1. See LICENSE for details. */ import { type DatasetRef } from '@elaraai/e3-types'; import type { DatasetRefStore } from '../interfaces.js'; export declare class LocalDatasetRefStore implements DatasetRefStore { /** * Get the filesystem path for a dataset ref file. */ private refPath; /** Read raw ref bytes, or null if the file is absent. */ private readBytes; /** Atomically replace the ref file: write to a unique staging file, then rename. */ private writeBytes; /** * Flat lock-resource name for a per-dataset compare-and-swap. * * Lands the `.lock` file directly under `workspaces/` (a sibling of the * `/data/` ref tree, so it never shows up in {@link list}) and never * collides with the workspace's own `.lock`. The dataset path's slashes * are flattened so the resource maps to a single lock file rather than a * nested directory the lock service would not create. */ private casResource; /** * In-process keys for a single `.ref`, both derived from the SAME * {@link casResource} the cross-process lock uses (so they can never drift) plus * the repo, since one process may hold several repos open. Two keys, two scopes: * * - {@link critKey} guards only the read-compare-rename **critical section** * (microseconds). Reads and the rename take it, so a writer's atomic rename * never overlaps a same-process reader's open handle — the Windows * sharing-violation that no rename-retry budget can fully absorb — eliminated * by construction, without serializing a read against the cross-process wait. * - {@link writeSerializeKey} serializes same-process *writers* across the whole * {@link writeIf} (including its cross-process file-lock wait), so K concurrent * writers never stampede the exclusive `.lock`; reads never take it, so a read * is never blocked behind a writer's up-to-30s file-lock wait. * * The filesystem lock in {@link writeIf} stays the load-bearing CROSS-process * serializer — these mutexes are same-process optimizations with NO cross-process * meaning and MUST NOT be relied on for correctness between processes. */ private critKey; private writeSerializeKey; read(repo: string, ws: string, datasetPath: string): Promise; write(repo: string, ws: string, datasetPath: string, ref: DatasetRef): Promise; readVersioned(repo: string, ws: string, datasetPath: string): Promise<{ ref: DatasetRef; revision: string; } | null>; writeIf(repo: string, ws: string, datasetPath: string, ref: DatasetRef, expectedRevision: string | null): Promise<{ revision: string; }>; list(repo: string, ws: string): Promise; /** * Recursively walk a directory collecting .ref file paths. */ private walkDir; remove(repo: string, ws: string, datasetPath: string): Promise; removeAll(repo: string, ws: string): Promise; } //# sourceMappingURL=LocalDatasetRefStore.d.ts.map