import { Script } from "./twins.js"; //#region src/scripts/placement.d.ts /** New placements need this much lease left, matching pinned's worker-side * healthy buffer; capped at leaseTtl/3 so short-lease fleets stay placeable. */ declare const PLACEMENT_HEALTH_MARGIN_MS = 5000; /** Fixed rebase point of the placement-epoch time arm (2026-01-01 UTC). */ declare const PROJECT_EPOCH_MS: number; /** * KEYS: placements, workers, ns_workers, boot_time, overwritten, epoch_floor * ARGV: id, now(ms), rand1, rand2, leaseTtlMs, ns, * preferredSessionId(''=none), affinityKey(''=none), balanceFactor, * hostname, env, takeover, excludeSessionId(''=none), * ejectedSessionIdsJson(''=none; skipped while another candidate remains) * Returns [status, workerRecordRaw|'', aux, carriedExpiry|'', epoch|'', * fresh]: aux is the remaining quarantine ms on 'quarantine', else '1'/'0' * for the id sitting on the overwritten list; carriedExpiry is set only when * this call placed with a carried wind-down; epoch is the placement row's * epoch on 'forward'; fresh is '1' when this call created the placement row. * On 'takeover-pending' aux is '1' when this call set the fence and the 4th * slot carries the fence expiry. * A re-claim (evicting a prior row before placing anew) writes the id's * overwritten marker atomically, stamping the minted epoch onto it (backoff * meta survives a re-list); a dead row that cannot be re-claimed * yet (quarantine, no backends) is left in place as the durability marker. * Each new placement decrements the chosen worker's stored headroom, so a * concurrent burst derates it until the next heartbeat refresh. */ declare const resolveScript: Script.Def; /** * KEYS: placements * ARGV: sessionId, prevSessionId(''=none), now(ms), id... * Register-time reclaim, restricted to process continuity: only rows still * owned by prevSessionId re-bind to sessionId, keeping the row epoch (same * holder across a lease blip — no writer transition, no mint). A pending * wind-down expiry carries onto the re-bound row. Every other id — absent, * expired, or owned by any other session — is left untouched and reported; * such rows re-place through the resolve claim path when traffic arrives. * Returns [claimedCount, [lost id...], [carried id, expiry, ...]]. */ declare const reclaimScript: Script.Def; /** * KEYS: placements * ARGV: deadline(epoch ms, '' clears), id... * Sets or clears the wind-down expiry on each placed id's row. * Returns [id, owning sessionId, ...] pairs; unplaced ids are skipped. */ declare const windDownScript: Script.Def; /** * KEYS: placements * ARGV: sessionId, (id, epoch)... * Compare-and-delete on (sessionId, epoch): HDELs each id only while its * row's sessionId matches and its epoch equals the quoted one ('' quotes an * epoch-less row). A mismatch leaves the row. * Returns the number of rows deleted. */ declare const releaseScript: Script.Def; /** * KEYS: overwritten * ARGV: field, epoch, metaJson('' = delete) * Compare-and-write fenced on the marker's stamped epoch: '' HDELs the field * while its epoch <= the quoted one (a proof of life under epoch E clears * every generation listed at or before E); a metaJson re-writes the backoff * meta only while the stored epoch equals the quoted one. A marker without a * numeric epoch is an error. Returns 1 on write, 0 on skip. */ declare const overwrittenCasScript: Script.Def; //#endregion export { PLACEMENT_HEALTH_MARGIN_MS, PROJECT_EPOCH_MS, overwrittenCasScript, reclaimScript, releaseScript, resolveScript, windDownScript }; //# sourceMappingURL=placement.d.ts.map