Imports the previously untracked working tree as-is so that the review changes that follow (requirements -> design -> implementation) can be reviewed as diffs and reverted if needed. No content changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
13 lines
539 B
JavaScript
13 lines
539 B
JavaScript
/** Serialize provision/cleanup for a run across generations in this provisioner process. */
|
|
export function createRunOperationQueue() {
|
|
const pending = new Map();
|
|
return async function runOperation(tenantId, runId, operation) {
|
|
const key = `${tenantId}\0${runId}`;
|
|
const previous = pending.get(key) ?? Promise.resolve();
|
|
const current = previous.catch(() => {}).then(operation);
|
|
pending.set(key, current);
|
|
try { return await current; }
|
|
finally { if (pending.get(key) === current) pending.delete(key); }
|
|
};
|
|
}
|