/** * Resource-controlled file mutation transaction. * * This module is deliberately internal to `resources/execution.ts`: callers * receive transactions only after host authority and PathRef resolution. It * owns the data-plane sequence beneath that boundary: * * durable snapshots -> atomic multi-scope lease -> durable intent/permit * -> stage -> promote -> commit-content | restore + abort-restored * * The local backend provides taskflow-exclusive isolation. It does not claim * hostile external-process fencing; concurrent Taskflow writers are excluded * by the persistent lease and unexpected external changes fail closed. */ import type { ResolvedPathRef } from "./resolve.ts"; import type { WriteIntentJournal, PreparedMutation, WriteIntentRecord } from "./journal.ts"; import type { LeaseHandle, PersistentLeaseCoordinator } from "./leases.ts"; import type { ExecutionOwner, ScopedContentEvidence } from "./types.ts"; export interface ResolvedFileWriteTarget { effectId: string; ref: ResolvedPathRef; } export interface FileWritePayload { effectId: string; content: string | Buffer; } export type FileTransactionResult = { ok: true; intentId: string; committedPaths: string[]; commitGeneration: number; } | { ok: false; intentId: string; code: "declared-path-bypass" | "commit-rejected"; reason: string; restored: true; }; interface SnapshotManifest { version: 1; artifactId: string; effectId: string; physicalPath: string; logicalSubpath: string; exists: boolean; contentId: string; mode?: number; nearestExistingAncestor: string; blobPath?: string; } interface Snapshot extends SnapshotManifest { capabilityBindingId: string; scopeDigest: string; } export interface ResourceFileTransactionOptions { controlDirectory: string; resourceDomainId: string; owner: ExecutionOwner; targets: readonly ResolvedFileWriteTarget[]; leases: PersistentLeaseCoordinator; journal: WriteIntentJournal; leaseTimeoutMs: number; permitTtlMs: number; signal?: AbortSignal; authorizationPrincipalId?: string; authorizationScopeRoot: string; /** Preserve a failed authenticated release for the session's next-admission drain. */ onDeferredLeaseRelease?: (lease: LeaseHandle) => void; /** Internal fault-injection seam for post-terminal staging cleanup tests. */ cleanupStaging?: (stagingDirectory: string) => void; } /** Remove terminal and pre-intent orphan before-images while retaining any * pending/dirty transaction needed for recovery or explicit reconciliation. */ export declare function garbageCollectResourceFileTransactions(controlDirectory: string, intents: readonly WriteIntentRecord[]): void; /** Restore a stale content intent while journal recovery holds its mutex. */ export declare function recoverResourceFileIntent(options: { controlDirectory: string; intent: WriteIntentRecord; leases: PersistentLeaseCoordinator; leaseTimeoutMs: number; signal?: AbortSignal; }): Promise<{ scopes: ScopedContentEvidence[]; reason: string; restorableSnapshotArtifactIds: string[]; } | undefined>; export declare class PreparedResourceFileTransaction { #private; readonly intentId: string; constructor(input: { snapshots: readonly Snapshot[]; mutation: PreparedMutation; lease: LeaseHandle; journal: WriteIntentJournal; stagingDirectory: string; onDeferredLeaseRelease?: (lease: LeaseHandle) => void; authorizationScopeRoot: string; cleanupStaging?: (stagingDirectory: string) => void; }); commit(payloads: readonly FileWritePayload[]): Promise; reject(reason: string): Promise; } export declare function prepareResourceFileTransaction(options: ResourceFileTransactionOptions): Promise; export {}; //# sourceMappingURL=file-transaction.d.ts.map