import type { ExecuteIfUnchangedOutcome } from '../conditional-write.js'; import type { VersionToken } from '../conditional-write.js'; import type { FsObjectIdentity } from './fs.js'; /** Unambiguous fs target: a non-empty `path` string on tool arguments (Write convention). */ export declare function inferFsPathFromArgs(args: unknown): string | null; /** * Full-file body for a Write-style tool. `contents` wins; `content` only when this * is not an Edit (no old_string/new_string). Fragments are not a whole-file CAS. */ export declare function inferFullFileWriteContent(args: unknown): string | null; /** * Options carrying the AUTHORIZATION-TIME measurement into the write. */ export type FsCasWireOptions = { /** * Token of the state the AUTHORIZATION examined, measured at T1 by the runner — before preflight, * not at write time. This is the whole fix: see the note on wrapWriteWithFsCas. */ expected_token?: VersionToken | null; /** Identity (dev+ino) of that same T1 object. Catches an inode swap the token cannot see. */ expected_identity?: FsObjectIdentity | null; }; /** The pair a runner measures at T1. Both halves describe the SAME observation. */ export type FsAuthorizationMeasurement = { expected_token: VersionToken; expected_identity: FsObjectIdentity | null; }; /** * Wire the FS adapter when path + full-file contents are both present. * Otherwise run the host write unchanged. If the host already returned an * ExecuteIfUnchangedOutcome, pass it through (do not wrap again). * * THE TOKEN MUST COME FROM T1. This function used to call createFsVersionToken HERE, inside * executeFactory — after preflight (T1) and after the T2 recheck — and then condition the write on * that self-fetched value. Measured on 12.0.0: with a writer landing between T2 and that read, the * CAS adopted the interfering state as its legitimate starting point and still reported * status:'committed' with enforced:true. It was a real check of a vacuous window — it asked whether * the state had changed since a read a microsecond earlier, which is a question whose answer is * always no and which says nothing about the state the authorization actually examined. * * Now the expected token is supplied by the caller from the T1 measurement. When it is ABSENT we do * NOT fall back to self-fetching, because that is precisely the vacuous claim: the write runs * unwrapped and the guarantee is NON_ATOMIC, which is the honest thing to report and which * requireConditionalWrite will refuse. A weaker guarantee is reportable; a false one is not. */ export declare function wrapWriteWithFsCas(args: unknown, write: () => Promise | T, opts?: FsCasWireOptions): Promise>; /** * The T1 measurement itself — call this in the RUNNER, before preflight, and pass the result to * wrapWriteWithFsCas. Returns null when this call is not an inferable full-file FS write, or when * the path is unsafe / unreadable (a token we could not measure is not a token we may claim). */ export declare function measureFsAuthorization(args: unknown): Promise; /** Convenience: the token half only. */ export declare function measureFsAuthorizationToken(args: unknown): Promise; //# sourceMappingURL=fs-default-wire.d.ts.map