/** * ╔══════════════════════════════════════════════════════════════════════╗ * ║ EXPERIMENTAL — EXP-30 BAKE-OFF CANDIDATE A. NOT A VALIDATED PATH. ║ * ╚══════════════════════════════════════════════════════════════════════╝ * * Candidate A — **Conditional-PUT compare-and-swap (If-Match RMW).** * * A topic segment (`current-N.jsonl`) is a single S3 object. There is no * native append, so `appendBlock` is a read-modify-write: * * GET object (+ETag, +metadata) → verify position → concat bytes * → PUT with `If-Match: ` * * The `If-Match` ETag check **is** the fence (ADR-0004 analogue): a deposed * leader holding a stale ETag gets `412 Precondition Failed`, maps it to * `LeaseLostError`, and exits — the same outcome Azure gets from its lease-ID * check. The position check (ADR-0005 analogue) is "committed length must equal * `expectedPosition`", verified from the GET'd body length and enforced * atomically by the same conditional PUT. * * Lease state lives in the object's user metadata (`lease-id`, * `lease-expires-ms`) and is claimed/renewed/released with a **self-`CopyObject` * + `MetadataDirective: REPLACE`** fenced by `CopySourceIfMatch` — a * server-side metadata rewrite that doesn't pull the body through the broker. * No separate `.lock` object (design constraint #5 forbids it for Azure; the * same split-brain reasoning applies here — the fence must be on the data * object itself). * * OPEN QUESTIONS THE BAKE-OFF MUST SETTLE (do not treat as decided): * 1. Whole-object rewrite per append → cost grows with segment size. Needs * the EXP-08 rollover-by-byte-size tuning to keep append latency bounded. * 2. LocalStack's `If-Match` / `CopySourceIfMatch` fidelity vs. real S3 — the * Phase-0 conformance probe gates whether we trust LocalStack for the * fencing verdict at all. * 3. Self-copy metadata-replace semantics + whether a concurrent appender's * PUT and an acquirer's COPY serialise the way this code assumes. * * Correctness (esp. ZERO split-brain under producer-kill, EXP-10 analogue) is * proven on **real S3** in EXP-30 before this is promoted in Phase 3. */ import { type AppendBlockOptions, type AppendResult, type LeaseToken, type RangeReadResult } from '../../types.js'; import { type S3StrategyContext } from '../s3Common.js'; import type { S3AppendLeaseStrategy, S3AppendStrategyName, S3CompactionResult } from './types.js'; export declare class CasIfMatchStrategy implements S3AppendLeaseStrategy { readonly name: S3AppendStrategyName; private readonly client; private readonly bucket; constructor(ctx: S3StrategyContext); createAppendBlob(path: string): Promise; acquireLease(path: string, ttlSeconds: number): Promise; renewLease(path: string, lease: LeaseToken): Promise; releaseLease(path: string, lease: LeaseToken): Promise; /** * Throw {@link LeaseLostError} unless `lease` is the live holder of `path`'s * lease (ADR-0027). The CAS candidate keeps the lease in the data object's own * metadata, so the check HEADs `path` directly (no sidecar). */ verifyLeaseHeld(path: string, lease: LeaseToken): Promise; appendBlock(path: string, bytes: Buffer, options: AppendBlockOptions): Promise; segmentLength(path: string): Promise; readSegment(path: string): Promise; compactSegment(srcPath: string, dstPath: string): Promise; rangeReadSegment(path: string, start: number, end: number): Promise; } //# sourceMappingURL=casIfMatch.d.ts.map