@@ -489,10 +489,16 @@ const EXACT_REVIEW_QUEUE_ROLLBACK_CLOCK_SKEW_MS = 5 * 60 * 1000;
489489const EXACT_REVIEW_QUEUE_LEGACY_GENERATION_PREFIX = "__clawsweeper_sql_generation:";
490490const EXACT_REVIEW_QUEUE_STATE_KEY = "exact-review-queue";
491491const EXACT_REVIEW_SOURCE_AUTHORITY_SEQUENCE_KEY = "exact-review-source-authority-sequence:v1";
492- const TARGET_FANOUT_CURSOR_KEY_PREFIX = "target-fanout-cursor:v1:";
493- type TargetFanoutMode = "hot-intake" | "normal-review" | "audit";
494- type TargetFanoutCursor = {
495- mode: TargetFanoutMode;
492+ // Preserve the original key prefix so existing fanout cursors survive the
493+ // broader operational-cursor contract introduced for bounded recovery lanes.
494+ const OPERATIONAL_CURSOR_KEY_PREFIX = "target-fanout-cursor:v1:";
495+ type OperationalCursorMode =
496+ | "hot-intake"
497+ | "normal-review"
498+ | "audit"
499+ | `review-placeholder-${string}-${"open" | "closed"}`;
500+ type OperationalCursor = {
501+ mode: OperationalCursorMode;
496502 nextCursor: number;
497503 revision: number;
498504 updatedAt: number;
@@ -632,12 +638,15 @@ export class ExactReviewQueue {
632638 this.reviewCoverageCache = null;
633639 return json({ ok: true, accepted: true }, 202);
634640 }
635- const targetFanoutMode = targetFanoutModeFromPath (url.pathname);
636- if (targetFanoutMode && request.method === "GET") {
637- return this.readTargetFanoutCursor(targetFanoutMode );
641+ const operationalCursorMode = operationalCursorModeFromPath (url.pathname);
642+ if (operationalCursorMode && request.method === "GET") {
643+ return this.readOperationalCursor(operationalCursorMode );
638644 }
639- if (targetFanoutMode && request.method === "PUT") {
640- return this.writeTargetFanoutCursor(targetFanoutMode, await request.json().catch(() => null));
645+ if (operationalCursorMode && request.method === "PUT") {
646+ return this.writeOperationalCursor(
647+ operationalCursorMode,
648+ await request.json().catch(() => null),
649+ );
641650 }
642651 if (request.method === "GET" && url.pathname === "/recent-durable-publication-events") {
643652 const events = this.recentDurablePublicationEvents(
@@ -3100,13 +3109,13 @@ export class ExactReviewQueue {
31003109 return value;
31013110 }
31023111
3103- private readTargetFanoutCursor (mode: TargetFanoutMode ) {
3104- const stored = readTargetFanoutCursor (this.storage.kv.get(targetFanoutCursorKey (mode)), mode);
3112+ private readOperationalCursor (mode: OperationalCursorMode ) {
3113+ const stored = readOperationalCursor (this.storage.kv.get(operationalCursorKey (mode)), mode);
31053114 if (stored === "invalid") return json({ error: "fanout_cursor_store_invalid" }, 500);
3106- return json(targetFanoutCursorJson (stored ?? emptyTargetFanoutCursor (mode)));
3115+ return json(operationalCursorJson (stored ?? emptyOperationalCursor (mode)));
31073116 }
31083117
3109- private writeTargetFanoutCursor (mode: TargetFanoutMode , value: unknown) {
3118+ private writeOperationalCursor (mode: OperationalCursorMode , value: unknown) {
31103119 const body = objectValue(value);
31113120 const nextCursor = Number(body.next_cursor);
31123121 const expectedRevision = Number(body.expected_revision);
@@ -3120,38 +3129,35 @@ export class ExactReviewQueue {
31203129 }
31213130 try {
31223131 const result = this.storage.transactionSync(() => {
3123- const stored = readTargetFanoutCursor(
3124- this.storage.kv.get(targetFanoutCursorKey(mode)),
3125- mode,
3126- );
3132+ const stored = readOperationalCursor(this.storage.kv.get(operationalCursorKey(mode)), mode);
31273133 if (stored === "invalid") return { kind: "invalid" as const };
3128- const current = stored ?? emptyTargetFanoutCursor (mode);
3134+ const current = stored ?? emptyOperationalCursor (mode);
31293135 if (current.revision !== expectedRevision) {
31303136 return { kind: "conflict" as const, current };
31313137 }
31323138 if (current.revision >= Number.MAX_SAFE_INTEGER) {
31333139 return { kind: "invalid" as const };
31343140 }
3135- const next: TargetFanoutCursor = {
3141+ const next: OperationalCursor = {
31363142 mode,
31373143 nextCursor,
31383144 revision: current.revision + 1,
31393145 updatedAt: Date.now(),
31403146 };
3141- this.storage.kv.put(targetFanoutCursorKey (mode), next);
3147+ this.storage.kv.put(operationalCursorKey (mode), next);
31423148 return { kind: "written" as const, cursor: next };
31433149 });
31443150 if (result.kind === "invalid") return json({ error: "fanout_cursor_store_invalid" }, 500);
31453151 if (result.kind === "conflict") {
31463152 return json(
31473153 {
31483154 error: "fanout_cursor_revision_conflict",
3149- current: targetFanoutCursorJson (result.current),
3155+ current: operationalCursorJson (result.current),
31503156 },
31513157 409,
31523158 );
31533159 }
3154- return json(targetFanoutCursorJson (result.cursor), 202);
3160+ return json(operationalCursorJson (result.cursor), 202);
31553161 } catch (error) {
31563162 console.error(`fanout cursor write failed: ${sanitizedServerError(error)}`);
31573163 return json({ error: "fanout_cursor_store_unavailable" }, 503);
@@ -13699,23 +13705,26 @@ function objectValue(value) {
1369913705 return value && typeof value === "object" && !Array.isArray(value) ? value : {};
1370013706}
1370113707
13702- function targetFanoutModeFromPath(path: string): TargetFanoutMode | null {
13703- const match = /^\/cursors\/(hot-intake|normal-review|audit)$/.exec(path);
13704- return (match?.[1] as TargetFanoutMode | undefined) ?? null;
13708+ function operationalCursorModeFromPath(path: string): OperationalCursorMode | null {
13709+ const match =
13710+ /^\/cursors\/(hot-intake|normal-review|audit|review-placeholder-[a-f0-9]{16}-(?:open|closed))$/.exec(
13711+ path,
13712+ );
13713+ return (match?.[1] as OperationalCursorMode | undefined) ?? null;
1370513714}
1370613715
13707- function targetFanoutCursorKey (mode: TargetFanoutMode ): string {
13708- return `${TARGET_FANOUT_CURSOR_KEY_PREFIX }${mode}`;
13716+ function operationalCursorKey (mode: OperationalCursorMode ): string {
13717+ return `${OPERATIONAL_CURSOR_KEY_PREFIX }${mode}`;
1370913718}
1371013719
13711- function emptyTargetFanoutCursor (mode: TargetFanoutMode ): TargetFanoutCursor {
13720+ function emptyOperationalCursor (mode: OperationalCursorMode ): OperationalCursor {
1371213721 return { mode, nextCursor: 0, revision: 0, updatedAt: 0 };
1371313722}
1371413723
13715- function readTargetFanoutCursor (
13724+ function readOperationalCursor (
1371613725 value: unknown,
13717- mode: TargetFanoutMode ,
13718- ): TargetFanoutCursor | "invalid" | null {
13726+ mode: OperationalCursorMode ,
13727+ ): OperationalCursor | "invalid" | null {
1371913728 if (value === undefined) return null;
1372013729 const cursor = objectValue(value);
1372113730 const nextCursor = Number(cursor.nextCursor);
@@ -13735,7 +13744,7 @@ function readTargetFanoutCursor(
1373513744 return { mode, nextCursor, revision, updatedAt };
1373613745}
1373713746
13738- function targetFanoutCursorJson (cursor: TargetFanoutCursor ) {
13747+ function operationalCursorJson (cursor: OperationalCursor ) {
1373913748 return {
1374013749 ok: true,
1374113750 mode: cursor.mode,
0 commit comments