@@ -488,10 +488,16 @@ const EXACT_REVIEW_QUEUE_ROLLBACK_CLOCK_SKEW_MS = 5 * 60 * 1000;
488488const EXACT_REVIEW_QUEUE_LEGACY_GENERATION_PREFIX = "__clawsweeper_sql_generation:";
489489const EXACT_REVIEW_QUEUE_STATE_KEY = "exact-review-queue";
490490const EXACT_REVIEW_SOURCE_AUTHORITY_SEQUENCE_KEY = "exact-review-source-authority-sequence:v1";
491- const TARGET_FANOUT_CURSOR_KEY_PREFIX = "target-fanout-cursor:v1:";
492- type TargetFanoutMode = "hot-intake" | "normal-review" | "audit";
493- type TargetFanoutCursor = {
494- mode: TargetFanoutMode;
491+ // Preserve the original key prefix so existing fanout cursors survive the
492+ // broader operational-cursor contract introduced for bounded recovery lanes.
493+ const OPERATIONAL_CURSOR_KEY_PREFIX = "target-fanout-cursor:v1:";
494+ type OperationalCursorMode =
495+ | "hot-intake"
496+ | "normal-review"
497+ | "audit"
498+ | `review-placeholder-${string}-${"open" | "closed"}`;
499+ type OperationalCursor = {
500+ mode: OperationalCursorMode;
495501 nextCursor: number;
496502 revision: number;
497503 updatedAt: number;
@@ -629,12 +635,15 @@ export class ExactReviewQueue {
629635 this.reviewCoverageCache = null;
630636 return json({ ok: true, accepted: true }, 202);
631637 }
632- const targetFanoutMode = targetFanoutModeFromPath (url.pathname);
633- if (targetFanoutMode && request.method === "GET") {
634- return this.readTargetFanoutCursor(targetFanoutMode );
638+ const operationalCursorMode = operationalCursorModeFromPath (url.pathname);
639+ if (operationalCursorMode && request.method === "GET") {
640+ return this.readOperationalCursor(operationalCursorMode );
635641 }
636- if (targetFanoutMode && request.method === "PUT") {
637- return this.writeTargetFanoutCursor(targetFanoutMode, await request.json().catch(() => null));
642+ if (operationalCursorMode && request.method === "PUT") {
643+ return this.writeOperationalCursor(
644+ operationalCursorMode,
645+ await request.json().catch(() => null),
646+ );
638647 }
639648 if (request.method === "GET" && url.pathname === "/recent-durable-publication-events") {
640649 const events = this.recentDurablePublicationEvents(
@@ -3092,13 +3101,13 @@ export class ExactReviewQueue {
30923101 return value;
30933102 }
30943103
3095- private readTargetFanoutCursor (mode: TargetFanoutMode ) {
3096- const stored = readTargetFanoutCursor (this.storage.kv.get(targetFanoutCursorKey (mode)), mode);
3104+ private readOperationalCursor (mode: OperationalCursorMode ) {
3105+ const stored = readOperationalCursor (this.storage.kv.get(operationalCursorKey (mode)), mode);
30973106 if (stored === "invalid") return json({ error: "fanout_cursor_store_invalid" }, 500);
3098- return json(targetFanoutCursorJson (stored ?? emptyTargetFanoutCursor (mode)));
3107+ return json(operationalCursorJson (stored ?? emptyOperationalCursor (mode)));
30993108 }
31003109
3101- private writeTargetFanoutCursor (mode: TargetFanoutMode , value: unknown) {
3110+ private writeOperationalCursor (mode: OperationalCursorMode , value: unknown) {
31023111 const body = objectValue(value);
31033112 const nextCursor = Number(body.next_cursor);
31043113 const expectedRevision = Number(body.expected_revision);
@@ -3112,38 +3121,35 @@ export class ExactReviewQueue {
31123121 }
31133122 try {
31143123 const result = this.storage.transactionSync(() => {
3115- const stored = readTargetFanoutCursor(
3116- this.storage.kv.get(targetFanoutCursorKey(mode)),
3117- mode,
3118- );
3124+ const stored = readOperationalCursor(this.storage.kv.get(operationalCursorKey(mode)), mode);
31193125 if (stored === "invalid") return { kind: "invalid" as const };
3120- const current = stored ?? emptyTargetFanoutCursor (mode);
3126+ const current = stored ?? emptyOperationalCursor (mode);
31213127 if (current.revision !== expectedRevision) {
31223128 return { kind: "conflict" as const, current };
31233129 }
31243130 if (current.revision >= Number.MAX_SAFE_INTEGER) {
31253131 return { kind: "invalid" as const };
31263132 }
3127- const next: TargetFanoutCursor = {
3133+ const next: OperationalCursor = {
31283134 mode,
31293135 nextCursor,
31303136 revision: current.revision + 1,
31313137 updatedAt: Date.now(),
31323138 };
3133- this.storage.kv.put(targetFanoutCursorKey (mode), next);
3139+ this.storage.kv.put(operationalCursorKey (mode), next);
31343140 return { kind: "written" as const, cursor: next };
31353141 });
31363142 if (result.kind === "invalid") return json({ error: "fanout_cursor_store_invalid" }, 500);
31373143 if (result.kind === "conflict") {
31383144 return json(
31393145 {
31403146 error: "fanout_cursor_revision_conflict",
3141- current: targetFanoutCursorJson (result.current),
3147+ current: operationalCursorJson (result.current),
31423148 },
31433149 409,
31443150 );
31453151 }
3146- return json(targetFanoutCursorJson (result.cursor), 202);
3152+ return json(operationalCursorJson (result.cursor), 202);
31473153 } catch (error) {
31483154 console.error(`fanout cursor write failed: ${sanitizedServerError(error)}`);
31493155 return json({ error: "fanout_cursor_store_unavailable" }, 503);
@@ -13659,23 +13665,26 @@ function objectValue(value) {
1365913665 return value && typeof value === "object" && !Array.isArray(value) ? value : {};
1366013666}
1366113667
13662- function targetFanoutModeFromPath(path: string): TargetFanoutMode | null {
13663- const match = /^\/cursors\/(hot-intake|normal-review|audit)$/.exec(path);
13664- return (match?.[1] as TargetFanoutMode | undefined) ?? null;
13668+ function operationalCursorModeFromPath(path: string): OperationalCursorMode | null {
13669+ const match =
13670+ /^\/cursors\/(hot-intake|normal-review|audit|review-placeholder-[a-f0-9]{16}-(?:open|closed))$/.exec(
13671+ path,
13672+ );
13673+ return (match?.[1] as OperationalCursorMode | undefined) ?? null;
1366513674}
1366613675
13667- function targetFanoutCursorKey (mode: TargetFanoutMode ): string {
13668- return `${TARGET_FANOUT_CURSOR_KEY_PREFIX }${mode}`;
13676+ function operationalCursorKey (mode: OperationalCursorMode ): string {
13677+ return `${OPERATIONAL_CURSOR_KEY_PREFIX }${mode}`;
1366913678}
1367013679
13671- function emptyTargetFanoutCursor (mode: TargetFanoutMode ): TargetFanoutCursor {
13680+ function emptyOperationalCursor (mode: OperationalCursorMode ): OperationalCursor {
1367213681 return { mode, nextCursor: 0, revision: 0, updatedAt: 0 };
1367313682}
1367413683
13675- function readTargetFanoutCursor (
13684+ function readOperationalCursor (
1367613685 value: unknown,
13677- mode: TargetFanoutMode ,
13678- ): TargetFanoutCursor | "invalid" | null {
13686+ mode: OperationalCursorMode ,
13687+ ): OperationalCursor | "invalid" | null {
1367913688 if (value === undefined) return null;
1368013689 const cursor = objectValue(value);
1368113690 const nextCursor = Number(cursor.nextCursor);
@@ -13695,7 +13704,7 @@ function readTargetFanoutCursor(
1369513704 return { mode, nextCursor, revision, updatedAt };
1369613705}
1369713706
13698- function targetFanoutCursorJson (cursor: TargetFanoutCursor ) {
13707+ function operationalCursorJson (cursor: OperationalCursor ) {
1369913708 return {
1370013709 ok: true,
1370113710 mode: cursor.mode,
0 commit comments