GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(server): count wakes that ran ahead when ordering a queued run · pingdotgg/t3code@1ff0353

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • apps/server/src/orchestration-v2
    • Orchestrator.ts
    • runtimeLayer.test.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎apps/server/src/orchestration-v2/Orchestrator.ts‎

Copy file name to clipboardExpand all lines: apps/server/src/orchestration-v2/Orchestrator.ts
+12-12Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1330,18 +1330,18 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
13301330
// Run ordinals order the transcript, checkpoints, and the latest run. A
13311331
// run that started while this one waited (a resume of a held queue, a
13321332
// reorder, a delivery that jumps the queue) has a newer ordinal, so this
1333-
// run moves after it. A message cancelled from the queue never started.
1334-
const startedRunIds = new Set(
1335-
projection.turnItems.flatMap((item) =>
1336-
item.type === "user_message" && item.runId !== null ? [item.runId] : [],
1337-
),
1338-
);
1339-
const ordinal = projection.runs.some(
1340-
(run) =>
1341-
run.status !== "queued" && run.ordinal > queuedRun.ordinal && startedRunIds.has(run.id),
1342-
)
1343-
? nextRunOrdinal(projection)
1344-
: queuedRun.ordinal;
1333+
// run moves after it. A started run has its prompt in the transcript (a
1334+
// wake's prompt is a notification); a message cancelled from the queue has none.
1335+
const newerRunIds = projection.runs
1336+
.filter((run) => run.status !== "queued" && run.ordinal > queuedRun.ordinal)
1337+
.map((run) => run.id);
1338+
const startedAhead =
1339+
newerRunIds.length > 0 &&
1340+
(yield* projectionStore.getThreadRecords(threadId, ["turnItems"], {
1341+
turnItemTypes: ["user_message", "notification"],
1342+
turnItemRunIds: newerRunIds,
1343+
})).turnItems.length > 0;
1344+
const ordinal = startedAhead ? nextRunOrdinal(projection) : queuedRun.ordinal;
13451345
const rootNodeId = queuedRun.rootNodeId;
13461346
const attemptId = queuedRun.activeAttemptId;
13471347
const providerThreadId = queuedRun.providerThreadId;
Collapse file

‎apps/server/src/orchestration-v2/runtimeLayer.test.ts‎

Copy file name to clipboardExpand all lines: apps/server/src/orchestration-v2/runtimeLayer.test.ts
+10Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3988,6 +3988,16 @@ it.layer(layerTest)("OrchestrationV2LayerLive lifecycle", (it) => {
39883988
yield* settle("queued", queuedStartedAt);
39893989
assert.equal(yield* Queue.take(startedRunIds), (yield* runFor("late-wake")).id);
39903990
assert.equal(millis((yield* runFor("late-wake")).workStartedAt), millis(queuedStartedAt));
3991+
3992+
// Runs sort in the order they started, including after a wake that ran ahead.
3993+
const ordinals = yield* Effect.forEach(
3994+
["prompt", "early-wake", "queued", "late-wake"],
3995+
(key) => Effect.map(runFor(key), (run) => run.ordinal),
3996+
);
3997+
assert.deepEqual(
3998+
ordinals,
3999+
ordinals.toSorted((left, right) => left - right),
4000+
);
39914001
}),
39924002
);
39934003

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.