@remnic/core 10.0.185 → 10.0.186
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/access-admin-ops-surface.js +1 -1
- package/dist/access-cli.js +1 -1
- package/dist/access-extraction-force-flush-preempt.js +1 -1
- package/dist/access-extraction-force-flush.js +1 -1
- package/dist/access-http-briefing.js +1 -1
- package/dist/access-http-query.js +1 -1
- package/dist/access-http.js +1 -1
- package/dist/access-identity-continuity-surface.js +1 -1
- package/dist/access-lcm-surface.js +1 -1
- package/dist/access-mcp.js +1 -1
- package/dist/access-observe-write-surface.js +1 -1
- package/dist/access-operations-batch.js +1 -1
- package/dist/access-operations.js +1 -1
- package/dist/access-recall-concurrency.js +1 -1
- package/dist/access-recall-response.js +1 -1
- package/dist/access-recall-surface.js +1 -1
- package/dist/access-service.js +1 -1
- package/dist/{chunk-EWLOIHAZ.js → chunk-3GD5SFDT.js} +2 -2
- package/dist/{chunk-TCSY74IN.js → chunk-LALPM2DN.js} +43 -6
- package/dist/chunk-LALPM2DN.js.map +1 -0
- package/dist/cli.js +1 -1
- package/dist/explicit-capture.js +1 -1
- package/dist/index.js +1 -1
- package/dist/orchestration/backlog-scheduler.js +2 -2
- package/dist/orchestration/buffer-drain-runner.js +2 -2
- package/dist/orchestration/extraction-queue-coordinator.d.ts +20 -0
- package/dist/orchestration/extraction-queue-coordinator.d.ts.map +1 -1
- package/dist/orchestration/turn-ingestion.d.ts.map +1 -1
- package/dist/orchestrator.js +1 -1
- package/dist/recall-navigation.js +1 -1
- package/package.json +2 -2
- package/src/orchestration/extraction-queue-coordinator.ts +64 -3
- package/src/orchestration/extraction-queue-lane-bias.test.ts +185 -0
- package/src/orchestration/turn-ingestion.ts +7 -1
- package/dist/chunk-TCSY74IN.js.map +0 -1
- /package/dist/{chunk-EWLOIHAZ.js.map → chunk-3GD5SFDT.js.map} +0 -0
package/dist/cli.js
CHANGED
|
@@ -91,7 +91,7 @@ import {
|
|
|
91
91
|
runWorkProductStatusCliCommand,
|
|
92
92
|
runWorkProjectCliCommand,
|
|
93
93
|
runWorkTaskCliCommand
|
|
94
|
-
} from "./chunk-
|
|
94
|
+
} from "./chunk-LALPM2DN.js";
|
|
95
95
|
import "./chunk-PQM3B54K.js";
|
|
96
96
|
import "./chunk-A3HLZMHD.js";
|
|
97
97
|
import "./chunk-GOZXQNIM.js";
|
package/dist/explicit-capture.js
CHANGED
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
shouldSkipImplicitExtraction,
|
|
9
9
|
stripInlineExplicitCaptureNotes,
|
|
10
10
|
validateExplicitCaptureInput
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-LALPM2DN.js";
|
|
12
12
|
import "./chunk-PQM3B54K.js";
|
|
13
13
|
import "./chunk-A3HLZMHD.js";
|
|
14
14
|
import "./chunk-GOZXQNIM.js";
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
BufferDrainRunner,
|
|
3
3
|
ClaimBufferStorage
|
|
4
|
-
} from "../chunk-
|
|
5
|
-
import "../chunk-
|
|
4
|
+
} from "../chunk-3GD5SFDT.js";
|
|
5
|
+
import "../chunk-LALPM2DN.js";
|
|
6
6
|
import "../chunk-PQM3B54K.js";
|
|
7
7
|
import "../chunk-A3HLZMHD.js";
|
|
8
8
|
import "../chunk-GOZXQNIM.js";
|
|
@@ -44,6 +44,15 @@ export interface ExtractionQueueEnqueueOptions {
|
|
|
44
44
|
front?: boolean;
|
|
45
45
|
/** Buffer/session key. Tasks sharing a key never run concurrently. */
|
|
46
46
|
key?: string;
|
|
47
|
+
/**
|
|
48
|
+
* Backlog/drain task: preferred up to `concurrency - FOREGROUND_FLOOR`
|
|
49
|
+
* concurrent slots whenever foreground work is also queued, so large
|
|
50
|
+
* claimed backlogs fill each call's prompt budget while live sessions
|
|
51
|
+
* keep a guaranteed floor share. The last slot is kept open for a
|
|
52
|
+
* fail-closed flush: a backlog task never fills it even with no
|
|
53
|
+
* foreground work queued.
|
|
54
|
+
*/
|
|
55
|
+
backlog?: boolean;
|
|
47
56
|
}
|
|
48
57
|
/**
|
|
49
58
|
* Coordinates the background bounded-parallel extraction queue. Owns the
|
|
@@ -72,6 +81,15 @@ export declare class ExtractionQueueCoordinator {
|
|
|
72
81
|
/** Preempt slots of the currently running tasks, keyed by slot identity. */
|
|
73
82
|
private readonly preemptSlots;
|
|
74
83
|
private preemptSeq;
|
|
84
|
+
/** Running tasks per lane — the backlog share and the foreground floor. */
|
|
85
|
+
private activeBacklog;
|
|
86
|
+
private activeForeground;
|
|
87
|
+
/**
|
|
88
|
+
* Slots kept available for foreground (non-backlog) tasks while backlog
|
|
89
|
+
* work also waits. A floor of one keeps live sessions extracting even at
|
|
90
|
+
* full backlog pressure; backlog tasks fill the rest.
|
|
91
|
+
*/
|
|
92
|
+
private static readonly FOREGROUND_FLOOR;
|
|
75
93
|
/** Resolves the processor's park while a new task arrives mid-drain. */
|
|
76
94
|
private wake?;
|
|
77
95
|
constructor(concurrency?: number);
|
|
@@ -125,6 +143,8 @@ export declare class ExtractionQueueCoordinator {
|
|
|
125
143
|
processQueue(): Promise<void>;
|
|
126
144
|
/** Take the next queue entry whose key is not already running or reserved (FIFO within a key). */
|
|
127
145
|
private takeRunnable;
|
|
146
|
+
/** First queue entry satisfying `match` whose key is free to run. */
|
|
147
|
+
private takeFirstMatching;
|
|
128
148
|
/** Run one entry with its own preempt slot; failures are classified + logged. */
|
|
129
149
|
private runEntry;
|
|
130
150
|
/** Test + force-flush observability: register a keyed preempt slot the way
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extraction-queue-coordinator.d.ts","sourceRoot":"","sources":["../../src/orchestration/extraction-queue-coordinator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAKH;mEACmE;AACnE,MAAM,WAAW,uBAAuB;IACtC,uEAAuE;IACvE,GAAG,CAAC,KAAK,EAAE,MAAM,IAAI,GAAG,IAAI,CAAC;IAC7B,mDAAmD;IACnD,MAAM,IAAI,IAAI,CAAC;CAChB;AAED,2EAA2E;AAC3E,MAAM,MAAM,mBAAmB,GAAG,CAAC,OAAO,CAAC,EAAE,uBAAuB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAEvF,MAAM,WAAW,6BAA6B;IAC5C,2EAA2E;IAC3E,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,sEAAsE;IACtE,GAAG,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"extraction-queue-coordinator.d.ts","sourceRoot":"","sources":["../../src/orchestration/extraction-queue-coordinator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAKH;mEACmE;AACnE,MAAM,WAAW,uBAAuB;IACtC,uEAAuE;IACvE,GAAG,CAAC,KAAK,EAAE,MAAM,IAAI,GAAG,IAAI,CAAC;IAC7B,mDAAmD;IACnD,MAAM,IAAI,IAAI,CAAC;CAChB;AAED,2EAA2E;AAC3E,MAAM,MAAM,mBAAmB,GAAG,CAAC,OAAO,CAAC,EAAE,uBAAuB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAEvF,MAAM,WAAW,6BAA6B;IAC5C,2EAA2E;IAC3E,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,sEAAsE;IACtE,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;;;;;OAOG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAgBD;;;GAGG;AACH,qBAAa,0BAA0B;IACrC,qFAAqF;IACrF,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;IACrC;;;OAGG;IACH,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAoB;IAC1C,mDAAmD;IACnD,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,SAAS,CAAQ;IACzB,qEAAqE;IACrE,OAAO,CAAC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OAAO,CAAC;QACjC,aAAa,CAAC,EAAE,CACd,KAAK,CAAC,EAAE,OAAO,EACf,MAAM,CAAC,EAAE,mBAAmB,KACzB,IAAI,CAAC;QACV,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,WAAW,CAAC,EAAE,WAAW,CAAC;QAC1B,yEAAyE;QACzE,WAAW,CAAC,EAAE,OAAO,CAAC;QACtB,sFAAsF;QACtF,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;QACxB,4EAA4E;QAC5E,cAAc,CAAC,EAAE,OAAO,CAAC;QACzB,sBAAsB,CAAC,EAAE,MAAM,CAAC;QAChC;;;;WAIG;QACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;QAC3B,qBAAqB,CAAC,EAAE,wBAAwB,GAAG,IAAI,CAAC;QACxD,wEAAwE;QACxE,SAAS,CAAC,EAAE,8BAA8B,CAAC;KACvC,GACL,OAAO,CAAC,IAAI,CAAC;IAyShB;;;;;;;;;OASG;IACG,8BAA8B,CAClC,KAAK,EAAE,SAAS,UAAU,EAAE,EAC5B,IAAI,EAAE;QACJ,UAAU,EAAE,MAAM,CAAC;QACnB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,SAAS,EAAE,MAAM,CAAC;QAClB,SAAS,EAAE,MAAM,CAAC;QAClB,aAAa,EAAE,OAAO,CAAC;QACvB,WAAW,CAAC,EAAE,WAAW,CAAC;KAC3B,GACA,OAAO,CAAC,IAAI,CAAC;CAkEjB;AAED,sFAAsF;AACtF,MAAM,MAAM,wBAAwB,GAAG,UAAU,CAAC,wBAAwB,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC"}
|
package/dist/orchestrator.js
CHANGED
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
mergeGraphExpandedResults,
|
|
7
7
|
qmdStartupCollectionChecksWithTimeout,
|
|
8
8
|
resolveEffectiveIdentityInjectionMode
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-LALPM2DN.js";
|
|
10
10
|
import "./chunk-PQM3B54K.js";
|
|
11
11
|
import "./chunk-A3HLZMHD.js";
|
|
12
12
|
import "./chunk-GOZXQNIM.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remnic/core",
|
|
3
|
-
"version": "10.0.
|
|
3
|
+
"version": "10.0.186",
|
|
4
4
|
"description": "Framework-agnostic Remnic memory engine — orchestrator, storage, extraction, search, trust zones",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -3416,7 +3416,7 @@
|
|
|
3416
3416
|
"core"
|
|
3417
3417
|
],
|
|
3418
3418
|
"peerDependencies": {
|
|
3419
|
-
"@remnic/coding-graph": "^10.0.
|
|
3419
|
+
"@remnic/coding-graph": "^10.0.186"
|
|
3420
3420
|
},
|
|
3421
3421
|
"peerDependenciesMeta": {
|
|
3422
3422
|
"@remnic/coding-graph": {
|
|
@@ -50,15 +50,28 @@ export interface ExtractionQueueEnqueueOptions {
|
|
|
50
50
|
front?: boolean;
|
|
51
51
|
/** Buffer/session key. Tasks sharing a key never run concurrently. */
|
|
52
52
|
key?: string;
|
|
53
|
+
/**
|
|
54
|
+
* Backlog/drain task: preferred up to `concurrency - FOREGROUND_FLOOR`
|
|
55
|
+
* concurrent slots whenever foreground work is also queued, so large
|
|
56
|
+
* claimed backlogs fill each call's prompt budget while live sessions
|
|
57
|
+
* keep a guaranteed floor share. The last slot is kept open for a
|
|
58
|
+
* fail-closed flush: a backlog task never fills it even with no
|
|
59
|
+
* foreground work queued.
|
|
60
|
+
*/
|
|
61
|
+
backlog?: boolean;
|
|
53
62
|
}
|
|
54
63
|
|
|
55
64
|
interface QueueEntry {
|
|
56
65
|
run: ExtractionQueueTask;
|
|
57
66
|
key?: string;
|
|
67
|
+
backlog?: boolean;
|
|
68
|
+
/** Set by enqueue({ front: true }): jumps the queue ahead of lane bias. */
|
|
69
|
+
front?: boolean;
|
|
58
70
|
}
|
|
59
71
|
|
|
60
72
|
interface PreemptSlot {
|
|
61
73
|
key?: string;
|
|
74
|
+
backlog?: boolean;
|
|
62
75
|
armed?: { abort: () => void; seq: number };
|
|
63
76
|
}
|
|
64
77
|
|
|
@@ -89,6 +102,15 @@ export class ExtractionQueueCoordinator {
|
|
|
89
102
|
/** Preempt slots of the currently running tasks, keyed by slot identity. */
|
|
90
103
|
private readonly preemptSlots = new Map<object, PreemptSlot>();
|
|
91
104
|
private preemptSeq = 0;
|
|
105
|
+
/** Running tasks per lane — the backlog share and the foreground floor. */
|
|
106
|
+
private activeBacklog = 0;
|
|
107
|
+
private activeForeground = 0;
|
|
108
|
+
/**
|
|
109
|
+
* Slots kept available for foreground (non-backlog) tasks while backlog
|
|
110
|
+
* work also waits. A floor of one keeps live sessions extracting even at
|
|
111
|
+
* full backlog pressure; backlog tasks fill the rest.
|
|
112
|
+
*/
|
|
113
|
+
private static readonly FOREGROUND_FLOOR = 1;
|
|
92
114
|
/** Resolves the processor's park while a new task arrives mid-drain. */
|
|
93
115
|
private wake?: () => void;
|
|
94
116
|
|
|
@@ -120,7 +142,7 @@ export class ExtractionQueueCoordinator {
|
|
|
120
142
|
enqueue(task: ExtractionQueueTask, options?: ExtractionQueueEnqueueOptions): boolean {
|
|
121
143
|
if (!this.accepting) return false;
|
|
122
144
|
const key = options?.key;
|
|
123
|
-
const entry: QueueEntry = { run: task, key };
|
|
145
|
+
const entry: QueueEntry = { run: task, key, backlog: options?.backlog, front: options?.front };
|
|
124
146
|
if (options?.front) {
|
|
125
147
|
this.preemptRunning(options.key);
|
|
126
148
|
this.queue.unshift(entry);
|
|
@@ -184,9 +206,13 @@ export class ExtractionQueueCoordinator {
|
|
|
184
206
|
const armed = Array.from(this.preemptSlots.values()).filter((slot) => slot.armed !== undefined);
|
|
185
207
|
if (armed.length === 0) return;
|
|
186
208
|
const preferred = preferredKey !== undefined ? armed.find((slot) => slot.key === preferredKey) : undefined;
|
|
209
|
+
// Lane-aware victim choice: with no same-key slot to abort, a flush takes
|
|
210
|
+
// a foreground slot before a backlog one, so drain chunk calls survive
|
|
211
|
+
// routine force-flush preemption while the flush still always wins a slot.
|
|
212
|
+
const victims = armed.some((slot) => slot.backlog !== true) ? armed.filter((slot) => slot.backlog !== true) : armed;
|
|
187
213
|
const chosen =
|
|
188
214
|
preferred ??
|
|
189
|
-
|
|
215
|
+
victims.reduce((a, b) => ((b.armed?.seq ?? -1) > (a.armed?.seq ?? -1) ? b : a));
|
|
190
216
|
const abort = chosen.armed?.abort;
|
|
191
217
|
chosen.armed = undefined;
|
|
192
218
|
abort?.();
|
|
@@ -291,11 +317,44 @@ export class ExtractionQueueCoordinator {
|
|
|
291
317
|
|
|
292
318
|
/** Take the next queue entry whose key is not already running or reserved (FIFO within a key). */
|
|
293
319
|
private takeRunnable(): QueueEntry | undefined {
|
|
320
|
+
// Front tasks jump the queue ahead of lane bias: a fail-closed force
|
|
321
|
+
// flush must start before any queued backlog work, even when the
|
|
322
|
+
// foreground floor is open. Same-key and reserved-key checks stay in
|
|
323
|
+
// takeFirstMatching, so a front flush still waits for its own running
|
|
324
|
+
// call rather than preempting it from the selection pass.
|
|
325
|
+
if (this.queue[0]?.front === true) {
|
|
326
|
+
const front = this.takeFirstMatching((entry) => entry.front === true);
|
|
327
|
+
if (front) return front;
|
|
328
|
+
}
|
|
329
|
+
// Lane bias: foreground keeps a floor of FOREGROUND_FLOOR slots while
|
|
330
|
+
// backlog work also waits, so a claimed backlog can never crowd live
|
|
331
|
+
// sessions out entirely; backlog tasks then fill every remaining slot.
|
|
332
|
+
// Backlog never holds the last slot, so a fail-closed flush always
|
|
333
|
+
// finds either a free slot or a foreground victim and never preempts an
|
|
334
|
+
// armed drain call. (A pick-time-only cap leaks: backlog armed to the
|
|
335
|
+
// full count stays armed when the foreground task finishes.) Either
|
|
336
|
+
// lane may still use all slots when the other has work to fill them.
|
|
337
|
+
if (this.activeForeground < ExtractionQueueCoordinator.FOREGROUND_FLOOR) {
|
|
338
|
+
const foreground = this.takeFirstMatching((entry) => entry.backlog !== true);
|
|
339
|
+
if (foreground) return foreground;
|
|
340
|
+
}
|
|
341
|
+
if (this.activeBacklog < Math.max(this.concurrency - 1, 1)) {
|
|
342
|
+
const backlog = this.takeFirstMatching((entry) => entry.backlog === true);
|
|
343
|
+
if (backlog) return backlog;
|
|
344
|
+
}
|
|
345
|
+
return this.takeFirstMatching((entry) => entry.backlog !== true);
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
/** First queue entry satisfying `match` whose key is free to run. */
|
|
349
|
+
private takeFirstMatching(match: (entry: QueueEntry) => boolean): QueueEntry | undefined {
|
|
294
350
|
for (let index = 0; index < this.queue.length; index += 1) {
|
|
295
351
|
const entry = this.queue[index];
|
|
352
|
+
if (!match(entry)) continue;
|
|
296
353
|
if (entry.key !== undefined && (this.activeKeys.has(entry.key) || this.reservedKeys.has(entry.key))) continue;
|
|
297
354
|
this.queue.splice(index, 1);
|
|
298
355
|
if (entry.key !== undefined) this.activeKeys.add(entry.key);
|
|
356
|
+
if (entry.backlog === true) this.activeBacklog += 1;
|
|
357
|
+
else this.activeForeground += 1;
|
|
299
358
|
return entry;
|
|
300
359
|
}
|
|
301
360
|
return undefined;
|
|
@@ -304,13 +363,15 @@ export class ExtractionQueueCoordinator {
|
|
|
304
363
|
/** Run one entry with its own preempt slot; failures are classified + logged. */
|
|
305
364
|
private async runEntry(entry: QueueEntry): Promise<void> {
|
|
306
365
|
const slot: PreemptSlot = {};
|
|
307
|
-
this.preemptSlots.set(slot, { key: entry.key });
|
|
366
|
+
this.preemptSlots.set(slot, { key: entry.key, backlog: entry.backlog });
|
|
308
367
|
try {
|
|
309
368
|
await entry.run(this.createPreemptHandle(slot));
|
|
310
369
|
} catch (err) {
|
|
311
370
|
this.logExtractionQueueFailure(err, "task");
|
|
312
371
|
} finally {
|
|
313
372
|
this.preemptSlots.delete(slot);
|
|
373
|
+
if (entry.backlog === true) this.activeBacklog -= 1;
|
|
374
|
+
else this.activeForeground -= 1;
|
|
314
375
|
if (entry.key !== undefined) this.activeKeys.delete(entry.key);
|
|
315
376
|
}
|
|
316
377
|
}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import test from "node:test";
|
|
3
|
+
|
|
4
|
+
import { ExtractionQueueCoordinator } from "./extraction-queue-coordinator.js";
|
|
5
|
+
|
|
6
|
+
const tick = () => new Promise<void>((resolve) => setImmediate(resolve));
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Lane bias (backlog priority + foreground floor): claimed-backlog drain
|
|
10
|
+
* tasks fill every slot past the foreground floor whenever both lanes wait,
|
|
11
|
+
* while live foreground work can never be fully crowded out.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/** One blocked task per enqueue; `started` records which lane began. */
|
|
15
|
+
function harness(concurrency: number) {
|
|
16
|
+
const queue = new ExtractionQueueCoordinator(concurrency);
|
|
17
|
+
const started: string[] = [];
|
|
18
|
+
const resolvers = new Map<string, () => void>();
|
|
19
|
+
const enqueue = (lane: "fg" | "bg", tag: string) =>
|
|
20
|
+
queue.enqueue(async () => {
|
|
21
|
+
started.push(tag);
|
|
22
|
+
await new Promise<void>((resolve) => resolvers.set(tag, resolve));
|
|
23
|
+
}, { backlog: lane === "bg" });
|
|
24
|
+
const release = (tag: string) => {
|
|
25
|
+
resolvers.get(tag)?.();
|
|
26
|
+
resolvers.delete(tag);
|
|
27
|
+
};
|
|
28
|
+
const releaseAll = () => {
|
|
29
|
+
for (const tag of [...resolvers.keys()]) release(tag);
|
|
30
|
+
};
|
|
31
|
+
return { queue, started, enqueue, release, releaseAll };
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
test("backlog fills every slot past the one-slot foreground floor", async () => {
|
|
35
|
+
const h = harness(4);
|
|
36
|
+
// Interleave lanes on enqueue: selection order, not arrival order, decides.
|
|
37
|
+
h.enqueue("fg", "f1");
|
|
38
|
+
h.enqueue("bg", "b1");
|
|
39
|
+
h.enqueue("fg", "f2");
|
|
40
|
+
h.enqueue("bg", "b2");
|
|
41
|
+
h.enqueue("bg", "b3");
|
|
42
|
+
h.enqueue("bg", "b4");
|
|
43
|
+
h.enqueue("fg", "f3");
|
|
44
|
+
h.enqueue("bg", "b5");
|
|
45
|
+
await tick();
|
|
46
|
+
assert.deepEqual(h.started.sort(), ["b1", "b2", "b3", "f1"],
|
|
47
|
+
"3 backlog + 1 foreground: the floor holds under full backlog pressure");
|
|
48
|
+
// A settling backlog slot refills with backlog, not the waiting foreground.
|
|
49
|
+
h.releaseAll();
|
|
50
|
+
for (let i = 0; i < 20 && h.started.length < 8; i += 1) await tick();
|
|
51
|
+
assert.deepEqual(h.started.sort(), ["b1", "b2", "b3", "b4", "b5", "f1", "f2", "f3"],
|
|
52
|
+
"every queued task settles once released — the bias delays, never drops");
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
test("the foreground floor applies per slot at any concurrency", async () => {
|
|
56
|
+
const h = harness(2);
|
|
57
|
+
h.enqueue("bg", "b1");
|
|
58
|
+
h.enqueue("bg", "b2");
|
|
59
|
+
h.enqueue("bg", "b3");
|
|
60
|
+
h.enqueue("fg", "f1");
|
|
61
|
+
h.enqueue("fg", "f2");
|
|
62
|
+
await tick();
|
|
63
|
+
assert.deepEqual(h.started.sort(), ["b1", "f1"],
|
|
64
|
+
"concurrency 2: one slot to each lane while both wait");
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
test("backlog alone leaves the last slot free for a flush", async () => {
|
|
68
|
+
const h = harness(4);
|
|
69
|
+
h.enqueue("bg", "b1");
|
|
70
|
+
h.enqueue("bg", "b2");
|
|
71
|
+
h.enqueue("bg", "b3");
|
|
72
|
+
h.enqueue("bg", "b4");
|
|
73
|
+
await tick();
|
|
74
|
+
assert.deepEqual(h.started, ["b1", "b2", "b3"],
|
|
75
|
+
"one slot stays open so a fail-closed flush need not preempt");
|
|
76
|
+
// A foreground (flush-path) arrival takes the free slot, not a victim.
|
|
77
|
+
h.enqueue("fg", "f1");
|
|
78
|
+
await tick();
|
|
79
|
+
assert.deepEqual(h.started, ["b1", "b2", "b3", "f1"]);
|
|
80
|
+
// While any foreground runs, backlog may again fill every other slot.
|
|
81
|
+
h.enqueue("bg", "b5");
|
|
82
|
+
await tick();
|
|
83
|
+
assert.deepEqual(h.started, ["b1", "b2", "b3", "f1"],
|
|
84
|
+
"no free slot while all four are armed");
|
|
85
|
+
// Releasing the foreground task must NOT let queued backlog take the
|
|
86
|
+
// freed last slot — the reserve survives foreground completion.
|
|
87
|
+
h.release("f1");
|
|
88
|
+
await tick();
|
|
89
|
+
assert.deepEqual(h.started, ["b1", "b2", "b3", "f1"],
|
|
90
|
+
"the fourth slot stays open after foreground settles");
|
|
91
|
+
h.releaseAll();
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
test("force-flush preemption takes a foreground victim before a backlog one", async () => {
|
|
95
|
+
const queue = new ExtractionQueueCoordinator(2);
|
|
96
|
+
const aborted: string[] = [];
|
|
97
|
+
const enqueue = (lane: "fg" | "bg", tag: string) =>
|
|
98
|
+
queue.enqueue(async (preempt) => {
|
|
99
|
+
preempt?.arm(() => aborted.push(tag));
|
|
100
|
+
await new Promise<void>(() => {}); // never settles
|
|
101
|
+
}, { backlog: lane === "bg" });
|
|
102
|
+
enqueue("bg", "b1");
|
|
103
|
+
enqueue("fg", "f1");
|
|
104
|
+
await tick();
|
|
105
|
+
// Both slots armed: the flush has no same-key match and must pick a victim.
|
|
106
|
+
queue.preemptRunning("unrelated-key");
|
|
107
|
+
await tick();
|
|
108
|
+
assert.deepEqual(aborted, ["f1"],
|
|
109
|
+
"the foreground slot dies first — backlog chunk calls survive routine flushes");
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
test("a same-key armed backlog slot still loses to the flush", async () => {
|
|
113
|
+
const queue = new ExtractionQueueCoordinator(2);
|
|
114
|
+
const aborted: string[] = [];
|
|
115
|
+
queue.enqueue(async (preempt) => {
|
|
116
|
+
preempt?.arm(() => aborted.push("bg"));
|
|
117
|
+
await new Promise<void>(() => {});
|
|
118
|
+
}, { backlog: true, key: "k1" });
|
|
119
|
+
await tick();
|
|
120
|
+
queue.preemptRunning("k1");
|
|
121
|
+
await tick();
|
|
122
|
+
assert.deepEqual(aborted, ["bg"],
|
|
123
|
+
"same-key correctness beats the lane preference");
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
test("foreground keeps all slots when no backlog work is queued", async () => {
|
|
127
|
+
const h = harness(4);
|
|
128
|
+
h.enqueue("fg", "f1");
|
|
129
|
+
h.enqueue("fg", "f2");
|
|
130
|
+
h.enqueue("fg", "f3");
|
|
131
|
+
await tick();
|
|
132
|
+
assert.deepEqual(h.started, ["f1", "f2", "f3"],
|
|
133
|
+
"foreground-only traffic is unaffected by the lane tag");
|
|
134
|
+
h.releaseAll();
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
test("a front flush starts before queued backlog work", async () => {
|
|
138
|
+
const queue = new ExtractionQueueCoordinator(2);
|
|
139
|
+
const started: string[] = [];
|
|
140
|
+
const resolvers = new Map<string, () => void>();
|
|
141
|
+
const enqueue = (tag: string, options?: { backlog?: boolean; front?: boolean; key?: string }) =>
|
|
142
|
+
queue.enqueue(async () => {
|
|
143
|
+
started.push(tag);
|
|
144
|
+
await new Promise<void>((resolve) => resolvers.set(tag, resolve));
|
|
145
|
+
}, options);
|
|
146
|
+
const release = (tag: string) => resolvers.get(tag)?.();
|
|
147
|
+
enqueue("fg", { key: "fg" });
|
|
148
|
+
enqueue("hold", { key: "hold" });
|
|
149
|
+
await tick();
|
|
150
|
+
enqueue("bl", { backlog: true, key: "bl" });
|
|
151
|
+
enqueue("flush", { front: true, key: "flush" });
|
|
152
|
+
// Both slots are full until hold ends. Releasing it is what lets the
|
|
153
|
+
// front flush start; the queued backlog must not take that slot.
|
|
154
|
+
release("hold");
|
|
155
|
+
await tick();
|
|
156
|
+
assert.deepEqual(started, ["fg", "hold", "flush"],
|
|
157
|
+
"front flush must run before queued backlog: actual " + started.join(","));
|
|
158
|
+
for (const tag of [...resolvers.keys()]) release(tag);
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
test("a front flush starts before queued backlog work (CodeRabbit Major, pure-backlog)", async () => {
|
|
162
|
+
const queue = new ExtractionQueueCoordinator(2);
|
|
163
|
+
const started: string[] = [];
|
|
164
|
+
const resolvers = new Map<string, () => void>();
|
|
165
|
+
const enqueue = (tag: string, options?: { backlog?: boolean; front?: boolean; key?: string }) =>
|
|
166
|
+
queue.enqueue(async () => {
|
|
167
|
+
started.push(tag);
|
|
168
|
+
await new Promise<void>((resolve) => resolvers.set(tag, resolve));
|
|
169
|
+
}, options);
|
|
170
|
+
const release = (tag: string) => resolvers.get(tag)?.();
|
|
171
|
+
enqueue("bl", { backlog: true, key: "bl" });
|
|
172
|
+
enqueue("bl2", { backlog: true, key: "bl2" });
|
|
173
|
+
enqueue("bl3", { backlog: true, key: "bl3" });
|
|
174
|
+
await tick();
|
|
175
|
+
// The fail-closed flush lands at the head after the backlog is queued.
|
|
176
|
+
enqueue("flush", { front: true, key: "flush" });
|
|
177
|
+
await tick();
|
|
178
|
+
// The flush must start before queued backlog work even with the foreground
|
|
179
|
+
// floor open (the lane check previously denied the front flag).
|
|
180
|
+
assert.deepEqual(started, ["bl", "flush"],
|
|
181
|
+
"front flush starts ahead of queued backlog work");
|
|
182
|
+
release("bl");
|
|
183
|
+
release("bl2");
|
|
184
|
+
release("flush");
|
|
185
|
+
});
|
|
@@ -1013,7 +1013,13 @@ export class TurnIngestionCoordinator {
|
|
|
1013
1013
|
if (sharingNode) this.snapshotSharing.release(sharingNode);
|
|
1014
1014
|
exit.report();
|
|
1015
1015
|
}
|
|
1016
|
-
}, {
|
|
1016
|
+
}, {
|
|
1017
|
+
front: options.preemptRunning === true,
|
|
1018
|
+
key: bufferKey,
|
|
1019
|
+
// Claim/drain tasks (options.execution carries the claim-backed buffer)
|
|
1020
|
+
// take the backlog lane: biased to fill all-but-foreground-floor slots.
|
|
1021
|
+
backlog: options.execution !== undefined,
|
|
1022
|
+
});
|
|
1017
1023
|
if (!accepted) {
|
|
1018
1024
|
if (sharingNode) this.snapshotSharing.release(sharingNode);
|
|
1019
1025
|
settleTask(new Error("extraction queue is stopped"));
|