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 — perf(server): thread list reads no longer scan a long thread's runs a… · incognitojam/styal@3c7b846

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • apps/server/src
    • orchestration-v2
      • FoundationPersistence.test.ts
      • ProjectionStore.test.ts
      • ProjectionStore.ts
    • persistence
      • ForkMigrations.test.ts
      • Migrations.ts
      • Migrations
        • 084_LastExecutedRunIndex.ts
        • 085_TurnItemCounts.test.ts
        • 085_TurnItemCounts.ts
      • reconcileV2PreviewMigration.test.ts
  • docs/internals
    • performance-regressions.md
Expand file treeCollapse file tree
Open diff view settings
Collapse file

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

Copy file name to clipboardExpand all lines: apps/server/src/orchestration-v2/FoundationPersistence.test.ts
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4159,6 +4159,7 @@ it.layer(layerTest)("orchestration V2 foundation persistence", (it) => {
41594159
});
41604160
const afterUpdate = yield* projectionStore.getThreadProjection(threadId);
41614161
assert.equal(afterUpdate.turnItems[0]?.ordinal, ordinals[0]);
4162+
assert.equal((yield* projectionStore.getThreadShell(threadId))?.itemCount, 151);
41624163
assert.equal((yield* maintenance.verify).valid, true);
41634164

41644165
yield* sql`
@@ -4173,6 +4174,7 @@ it.layer(layerTest)("orchestration V2 foundation persistence", (it) => {
41734174
const rebuilt = yield* maintenance.rebuild;
41744175
assert.isTrue(rebuilt.valid);
41754176
assert.lengthOf((yield* projectionStore.getThreadProjection(threadId)).turnItems, 151);
4177+
assert.equal((yield* projectionStore.getThreadShell(threadId))?.itemCount, 151);
41764178
}),
41774179
);
41784180
});
Collapse file

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

Copy file name to clipboardExpand all lines: apps/server/src/orchestration-v2/ProjectionStore.test.ts
+96-40Lines changed: 96 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -5753,42 +5753,71 @@ it.layer(layerTest)("ProjectionStoreV2", (it) => {
57535753
}),
57545754
);
57555755

5756-
it.effect("looks up shell stop requests and report questions through partial indexes", () =>
5757-
Effect.gen(function* () {
5758-
const projectionStore = yield* ProjectionStore.ProjectionStoreV2;
5759-
const sql = yield* SqlClient.SqlClient;
5760-
const { projectId } = yield* assertProjectScopedShells("sql-shell-stop-index");
5761-
const { statements, tracer } = traceSqlStatements();
5762-
yield* projectionStore
5763-
.getShellSnapshot({ projectId, location: "active" })
5764-
.pipe(Effect.withTracer(tracer));
5756+
it.effect(
5757+
"reads shell runs, item counts, and report questions without walking thread history",
5758+
() =>
5759+
Effect.gen(function* () {
5760+
const projectionStore = yield* ProjectionStore.ProjectionStoreV2;
5761+
const sql = yield* SqlClient.SqlClient;
5762+
const { projectId } = yield* assertProjectScopedShells("sql-shell-stop-index");
5763+
const { statements, tracer } = traceSqlStatements();
5764+
yield* projectionStore
5765+
.getShellSnapshot({ projectId, location: "active" })
5766+
.pipe(Effect.withTracer(tracer));
5767+
const planOf = (statement: string) =>
5768+
sql
5769+
.unsafe<{ readonly detail: string }>(`EXPLAIN QUERY PLAN ${statement}`)
5770+
.pipe(Effect.map((rows) => rows.map((row) => row.detail)));
57655771

5766-
const threadQuery = statements.find((statement) =>
5767-
statement.includes("AS latest_run_stop_requested"),
5768-
);
5769-
assert.isDefined(threadQuery);
5770-
const plan = (yield* sql.unsafe<{ readonly detail: string }>(
5771-
`EXPLAIN QUERY PLAN ${threadQuery}`,
5772-
)).map((row) => row.detail);
5773-
for (const [alias, index] of [
5774-
["report", "report_key"],
5775-
["newer", "report_key"],
5776-
["answer", "report_answer"],
5777-
]) {
5778-
const lookup = plan.find((detail) => detail.startsWith(`SEARCH ${alias} `));
5779-
assert.isDefined(lookup);
5780-
assert.include(lookup, `orchestration_v2_projection_messages_${index}_idx`);
5781-
}
5782-
assert.include(
5783-
plan.find((detail) => detail.startsWith("SEARCH newer ")),
5784-
"(thread_id=? AND <expr>=? AND <expr>>?)",
5785-
);
5786-
const stopRequestLookups = plan.filter((detail) => detail.startsWith("SEARCH stop_request "));
5787-
assert.lengthOf(stopRequestLookups, 2);
5788-
for (const lookup of stopRequestLookups) {
5789-
assert.include(lookup, "orchestration_v2_projection_turn_items_stop_request_idx");
5790-
}
5791-
}),
5772+
const threadQuery = statements.find((statement) =>
5773+
statement.includes("AS latest_run_stop_requested"),
5774+
);
5775+
assert.isDefined(threadQuery);
5776+
const plan = yield* planOf(threadQuery);
5777+
for (const [alias, index] of [
5778+
["report", "report_key"],
5779+
["newer", "report_key"],
5780+
["answer", "report_answer"],
5781+
]) {
5782+
const lookup = plan.find((detail) => detail.startsWith(`SEARCH ${alias} `));
5783+
assert.isDefined(lookup);
5784+
assert.include(lookup, `orchestration_v2_projection_messages_${index}_idx`);
5785+
}
5786+
assert.include(
5787+
plan.find((detail) => detail.startsWith("SEARCH newer ")),
5788+
"(thread_id=? AND <expr>=? AND <expr>>?)",
5789+
);
5790+
const stopRequestLookups = plan.filter((detail) =>
5791+
detail.startsWith("SEARCH stop_request "),
5792+
);
5793+
assert.lengthOf(stopRequestLookups, 2);
5794+
for (const lookup of stopRequestLookups) {
5795+
assert.include(lookup, "orchestration_v2_projection_turn_items_stop_request_idx");
5796+
}
5797+
// The active, activity, and pending-secret lookups; walking the ordinal index instead
5798+
// reads every run of an idle thread.
5799+
const activeRunLookups = plan.filter(
5800+
(detail) => detail.startsWith("SEARCH r ") && detail.includes("(thread_id=?"),
5801+
);
5802+
assert.lengthOf(activeRunLookups, 4);
5803+
for (const lookup of activeRunLookups) {
5804+
assert.include(lookup, "orchestration_v2_projection_runs_thread_status_idx");
5805+
}
5806+
const lastExecutedIndex = plan.findIndex((detail) =>
5807+
detail.includes("orchestration_v2_projection_runs_last_executed_idx"),
5808+
);
5809+
assert.notStrictEqual(lastExecutedIndex, -1);
5810+
// The lookup that follows the search is the sort it no longer needs.
5811+
assert.notInclude(plan[lastExecutedIndex + 1] ?? "", "USE TEMP B-TREE");
5812+
5813+
const countQueries = statements.filter((statement) => statement.includes("item_count"));
5814+
assert.isNotEmpty(countQueries);
5815+
for (const countQuery of countQueries) {
5816+
for (const detail of yield* planOf(countQuery)) {
5817+
assert.notInclude(detail, "orchestration_v2_projection_turn_items");
5818+
}
5819+
}
5820+
}),
57925821
);
57935822

57945823
it.effect("reads a run's turn-start items by thread and run, not by walking thread history", () =>
@@ -6042,6 +6071,7 @@ it.layer(layerTest)("ProjectionStoreV2", (it) => {
60426071
},
60436072
});
60446073
}
6074+
let runWrites = 0;
60456075
const applyRun = (
60466076
threadId: ThreadId,
60476077
suffix: string,
@@ -6050,9 +6080,10 @@ it.layer(layerTest)("ProjectionStoreV2", (it) => {
60506080
) => {
60516081
const runId = RunId.make(`run:shell-item-counts:${suffix}`);
60526082
const rootNodeId = NodeId.make(`node:shell-item-counts:${suffix}`);
6083+
runWrites += 1;
60536084
return projectionStore
60546085
.apply({
6055-
id: EventId.make(`event:shell-item-counts:${suffix}:run`),
6086+
id: EventId.make(`event:shell-item-counts:${suffix}:run:${runWrites}`),
60566087
type: "run.created",
60576088
threadId,
60586089
runId,
@@ -6079,11 +6110,14 @@ it.layer(layerTest)("ProjectionStoreV2", (it) => {
60796110
})
60806111
.pipe(Effect.as(runId));
60816112
};
6082-
let ordinal = 0;
6083-
const applyItem = (threadId: ThreadId, runId: RunId | null) => {
6084-
ordinal += 1;
6113+
let items = 0;
6114+
let writes = 0;
6115+
// Passing `rewrite` writes that earlier item again, possibly under another run.
6116+
const applyItem = (threadId: ThreadId, runId: RunId | null, rewrite?: number) => {
6117+
const ordinal = rewrite ?? (items += 1);
6118+
writes += 1;
60856119
return projectionStore.apply({
6086-
id: EventId.make(`event:shell-item-counts:item:${ordinal}`),
6120+
id: EventId.make(`event:shell-item-counts:write:${writes}`),
60876121
type: "turn-item.updated",
60886122
threadId,
60896123
...(runId === null ? {} : { runId }),
@@ -6136,6 +6170,28 @@ it.layer(layerTest)("ProjectionStoreV2", (it) => {
61366170
);
61376171
assert.equal(shell?.itemCount, itemCount);
61386172
}
6173+
6174+
// Writing an item again keeps its count; moving it to another run moves the count.
6175+
const itemCountOf = (threadId: ThreadId) =>
6176+
projectionStore.getThreadShell(threadId).pipe(Effect.map((shell) => shell?.itemCount));
6177+
yield* applyItem(busyThreadId, completedRunId, 3);
6178+
assert.equal(yield* itemCountOf(busyThreadId), 4);
6179+
yield* applyItem(busyThreadId, rolledBackRunId, 3);
6180+
assert.equal(yield* itemCountOf(busyThreadId), 3);
6181+
yield* applyItem(busyThreadId, null, 3);
6182+
assert.equal(yield* itemCountOf(busyThreadId), 4);
6183+
6184+
// A run's rollback uncounts its items, and writing the run again counts them back.
6185+
yield* applyRun(busyThreadId, "busy-completed", 1, true);
6186+
assert.equal(yield* itemCountOf(busyThreadId), 3);
6187+
yield* applyRun(busyThreadId, "busy-completed", 1, false);
6188+
assert.equal(yield* itemCountOf(busyThreadId), 4);
6189+
// Items written before their run exist count once it does.
6190+
const lateRunId = RunId.make("run:shell-item-counts:late");
6191+
yield* applyItem(otherThreadId, lateRunId);
6192+
assert.equal(yield* itemCountOf(otherThreadId), 1);
6193+
yield* applyRun(otherThreadId, "late", 2, false);
6194+
assert.equal(yield* itemCountOf(otherThreadId), 2);
61396195
}),
61406196
);
61416197

Collapse file

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

Copy file name to clipboardExpand all lines: apps/server/src/orchestration-v2/ProjectionStore.ts
+14-14Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7296,7 +7296,10 @@ export const layer: Layer.Layer<ProjectionStoreV2, never, SqlClient.SqlClient> =
72967296
active.status AS active_run_status,
72977297
(
72987298
SELECT r.status
7299+
-- Read active runs by status. Walking the ordinal index to skip this sort
7300+
-- reads every run of a thread with none active.
72997301
FROM orchestration_v2_projection_runs r
7302+
INDEXED BY orchestration_v2_projection_runs_thread_status_idx
73007303
WHERE r.thread_id = t.thread_id
73017304
AND r.status IN ('preparing', 'starting', 'running', 'waiting')
73027305
AND NOT ${isSilentShellRun("r")}
@@ -7311,6 +7314,7 @@ export const layer: Layer.Layer<ProjectionStoreV2, never, SqlClient.SqlClient> =
73117314
r.requested_at
73127315
)
73137316
FROM orchestration_v2_projection_runs r
7317+
INDEXED BY orchestration_v2_projection_runs_thread_status_idx
73147318
WHERE r.thread_id = t.thread_id
73157319
AND r.status IN ('preparing', 'starting', 'running', 'waiting')
73167320
AND NOT ${isSilentShellRun("r")}
@@ -7374,6 +7378,7 @@ export const layer: Layer.Layer<ProjectionStoreV2, never, SqlClient.SqlClient> =
73747378
SELECT secret.payload_json
73757379
-- Keep runs outermost so completed history is never scanned for a pending secret.
73767380
FROM orchestration_v2_projection_runs r
7381+
INDEXED BY orchestration_v2_projection_runs_thread_status_idx
73777382
CROSS JOIN orchestration_v2_projection_turn_items secret
73787383
INDEXED BY orchestration_v2_projection_turn_items_thread_run_idx
73797384
WHERE r.thread_id = t.thread_id
@@ -7425,6 +7430,7 @@ export const layer: Layer.Layer<ProjectionStoreV2, never, SqlClient.SqlClient> =
74257430
LEFT JOIN orchestration_v2_projection_runs active ON active.run_id = (
74267431
SELECT r.run_id
74277432
FROM orchestration_v2_projection_runs r
7433+
INDEXED BY orchestration_v2_projection_runs_thread_status_idx
74287434
WHERE r.thread_id = t.thread_id
74297435
AND r.status IN ('preparing', 'starting', 'running')
74307436
AND NOT ${isSilentShellRun("r")}
@@ -7528,27 +7534,21 @@ export const layer: Layer.Layer<ProjectionStoreV2, never, SqlClient.SqlClient> =
75287534

75297535
const selectShellRunItemCounts = (threadIds: ReadonlyArray<ThreadId>) =>
75307536
sql<ShellRunItemCountRow>`
7531-
SELECT thread_id, run_id, COUNT(*) AS item_count
7532-
FROM orchestration_v2_projection_turn_items
7533-
WHERE run_id IS NOT NULL AND thread_id IN (SELECT value FROM json_each(${encodeIdList(threadIds)}))
7534-
GROUP BY thread_id, run_id
7537+
SELECT thread_id, run_key AS run_id, item_count
7538+
FROM orchestration_v2_projection_turn_item_counts
7539+
WHERE run_key <> '' AND thread_id IN (SELECT value FROM json_each(${encodeIdList(threadIds)}))
75357540
`;
75367541

7537-
// Count all selected threads in one index walk; fork sources still need per-run counts.
75387542
const selectShellItemCounts = (threadIds: ReadonlyArray<ThreadId>) =>
75397543
sql<ShellItemCountRow>`
75407544
SELECT counts.thread_id,
7541-
SUM(CASE WHEN counts.run_id IS NULL OR r.status <> 'rolled_back'
7545+
SUM(CASE WHEN counts.run_key = '' OR r.status <> 'rolled_back'
75427546
THEN counts.item_count ELSE 0 END) AS item_count,
7543-
SUM(CASE WHEN counts.run_id IS NULL THEN counts.item_count ELSE 0 END)
7547+
SUM(CASE WHEN counts.run_key = '' THEN counts.item_count ELSE 0 END)
75447548
AS runless_item_count
7545-
FROM (
7546-
SELECT thread_id, run_id, COUNT(*) AS item_count
7547-
FROM orchestration_v2_projection_turn_items
7548-
WHERE thread_id IN (SELECT value FROM json_each(${encodeIdList(threadIds)}))
7549-
GROUP BY thread_id, run_id
7550-
) counts
7551-
LEFT JOIN orchestration_v2_projection_runs r ON r.run_id = counts.run_id
7549+
FROM orchestration_v2_projection_turn_item_counts counts
7550+
LEFT JOIN orchestration_v2_projection_runs r ON r.run_id = counts.run_key
7551+
WHERE counts.thread_id IN (SELECT value FROM json_each(${encodeIdList(threadIds)}))
75527552
GROUP BY counts.thread_id
75537553
`;
75547554

Collapse file

‎apps/server/src/persistence/ForkMigrations.test.ts‎

Copy file name to clipboardExpand all lines: apps/server/src/persistence/ForkMigrations.test.ts
+7-11Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import { migrationManifest, runMigrations } from "./Migrations.ts";
1414
import * as NodeSqliteClient from "@t3tools/shared/nodeSqliteClient";
1515

1616
import dropWorktreeSetupState from "./ForkMigrations/014_DropWorktreeSetupState.ts";
17-
import { createMessageSearchTriggers } from "../orchestration-v2/messageSearchIndex.ts";
1817

1918
const encodeJson = Schema.encodeEffect(Schema.fromJsonString(Schema.Unknown));
2019
const decodeJson = Schema.decodeUnknownEffect(Schema.fromJsonString(Schema.Unknown));
@@ -81,16 +80,11 @@ organizedLayer("ForkMigrations project pins from fork migration 11", (it) => {
8180
const sql = yield* SqlClient.SqlClient;
8281
const pinnedAt = "2026-10-01T00:00:00.000Z";
8382
// An earlier build's history: fork migration 11 ran, upstream stops at 75.
84-
yield* runAllMigrations();
85-
yield* sql`DELETE FROM effect_sql_migrations WHERE migration_id >= 76`;
86-
yield* sql`DROP INDEX orchestration_v2_projection_threads_subagent_result_idx`;
87-
yield* sql`DROP INDEX orchestration_v2_projection_runs_delegated_delivery_idx`;
88-
yield* sql`ALTER TABLE scheduled_tasks DROP COLUMN thread_mode`;
89-
yield* sql`DROP TRIGGER orchestration_v2_message_search_insert`;
90-
yield* sql`DROP TRIGGER orchestration_v2_message_search_update`;
91-
yield* sql`DROP TRIGGER orchestration_v2_message_search_delete`;
92-
yield* sql`ALTER TABLE orchestration_v2_projection_messages DROP COLUMN search_text`;
93-
yield* createMessageSearchTriggers(sql);
83+
yield* runMigrations({ toMigrationInclusive: 62 });
84+
yield* sql`ALTER TABLE projection_thread_activities RENAME TO styal_legacy_v1_thread_activities`;
85+
yield* sql`ALTER TABLE projection_turns RENAME TO styal_legacy_v1_turns`;
86+
yield* runMigrations({ toMigrationInclusive: 75 });
87+
yield* runForkMigrations({ toMigrationInclusive: 11 });
9488
yield* sql`
9589
INSERT INTO projection_projects (
9690
project_id, title, workspace_root, scripts_json, created_at, updated_at,
@@ -111,6 +105,8 @@ organizedLayer("ForkMigrations project pins from fork migration 11", (it) => {
111105
[81, "ProjectionMessageSearchText"],
112106
[82, "TurnItemConversationIndex"],
113107
[83, "CommandReadIndexes"],
108+
[84, "LastExecutedRunIndex"],
109+
[85, "TurnItemCounts"],
114110
]);
115111
assert.deepStrictEqual(
116112
yield* sql`
Collapse file

‎apps/server/src/persistence/Migrations.ts‎

Copy file name to clipboardExpand all lines: apps/server/src/persistence/Migrations.ts
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ import Migration0080 from "./Migrations/080_ScheduledTaskThreadMode.ts";
8686
import Migration0081 from "./Migrations/081_ProjectionMessageSearchText.ts";
8787
import Migration0082 from "./Migrations/082_TurnItemConversationIndex.ts";
8888
import Migration0083 from "./Migrations/083_CommandReadIndexes.ts";
89+
import Migration0084 from "./Migrations/084_LastExecutedRunIndex.ts";
90+
import Migration0085 from "./Migrations/085_TurnItemCounts.ts";
8991

9092
const migrationEntries = [
9193
[1, "OrchestrationEvents", Migration0001],
@@ -172,6 +174,8 @@ const migrationEntries = [
172174
[81, "ProjectionMessageSearchText", Migration0081],
173175
[82, "TurnItemConversationIndex", Migration0082],
174176
[83, "CommandReadIndexes", Migration0083],
177+
[84, "LastExecutedRunIndex", Migration0084],
178+
[85, "TurnItemCounts", Migration0085],
175179
] as const;
176180

177181
export const migrationManifest = migrationEntries.map(([id, name]) => [id, name] as const);
Collapse file

‎apps/server/src/persistence/Migrations/084_LastExecutedRunIndex.ts‎

Copy file name to clipboard
+18Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import * as Effect from "effect/Effect";
2+
import * as SqlClient from "effect/sql/SqlClient";
3+
4+
export default Effect.gen(function* () {
5+
const sql = yield* SqlClient.SqlClient;
6+
7+
// The shell's last executed run lookup sorts every run of the thread. This index carries
8+
// that order and the same predicate the lookup filters on. A database that already has
9+
// the index keeps it, so a hand-applied one does not fail the migration.
10+
yield* sql`
11+
CREATE INDEX IF NOT EXISTS orchestration_v2_projection_runs_last_executed_idx
12+
ON orchestration_v2_projection_runs(
13+
thread_id, (completed_at IS NULL) DESC, completed_at DESC, ordinal DESC, run_id DESC
14+
)
15+
WHERE status <> 'queued'
16+
AND NOT (status = 'cancelled' AND json_extract(payload_json, '$.startedAt') IS NULL)
17+
`;
18+
});
Collapse file

‎apps/server/src/persistence/Migrations/085_TurnItemCounts.test.ts‎

Copy file name to clipboard
+60Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import { assert, it } from "@effect/vitest";
2+
import * as NodeSqliteClient from "@t3tools/shared/nodeSqliteClient";
3+
import * as Effect from "effect/Effect";
4+
import * as SqlClient from "effect/sql/SqlClient";
5+
6+
import { runMigrations } from "../Migrations.ts";
7+
8+
const layer = it.layer(NodeSqliteClient.layer({ filename: ":memory:" }));
9+
10+
layer("085_TurnItemCounts", (it) => {
11+
it.effect("backfills item counts, then follows upserts, moves, and deletes", () =>
12+
Effect.gen(function* () {
13+
const sql = yield* SqlClient.SqlClient;
14+
yield* runMigrations({ toMigrationInclusive: 84 });
15+
const upsert = (id: string, threadId: string, runId: string | null) => sql`
16+
INSERT INTO orchestration_v2_projection_turn_items (
17+
turn_item_id, thread_id, run_id, ordinal, type, status, updated_at, payload_json
18+
)
19+
VALUES (
20+
${id}, ${threadId}, ${runId}, 1, 'assistant_message', 'completed',
21+
'2026-10-29T00:00:00.000Z', '{}'
22+
)
23+
ON CONFLICT(turn_item_id) DO UPDATE SET
24+
thread_id = excluded.thread_id,
25+
run_id = excluded.run_id,
26+
status = excluded.status
27+
`;
28+
yield* upsert("runless-1", "thread-1", null);
29+
yield* upsert("runless-2", "thread-1", null);
30+
yield* upsert("run-1", "thread-1", "run-1");
31+
32+
yield* runMigrations();
33+
34+
const counts = () =>
35+
sql<{ readonly thread_id: string; readonly run_key: string; readonly item_count: number }>`
36+
SELECT thread_id, run_key, item_count
37+
FROM orchestration_v2_projection_turn_item_counts
38+
ORDER BY thread_id, run_key
39+
`;
40+
assert.deepEqual(yield* counts(), [
41+
{ thread_id: "thread-1", run_key: "", item_count: 2 },
42+
{ thread_id: "thread-1", run_key: "run-1", item_count: 1 },
43+
]);
44+
45+
yield* upsert("run-1", "thread-1", "run-1");
46+
yield* upsert("run-2", "thread-2", "run-2");
47+
yield* upsert("runless-2", "thread-1", "run-1");
48+
assert.deepEqual(yield* counts(), [
49+
{ thread_id: "thread-1", run_key: "", item_count: 1 },
50+
{ thread_id: "thread-1", run_key: "run-1", item_count: 2 },
51+
{ thread_id: "thread-2", run_key: "run-2", item_count: 1 },
52+
]);
53+
54+
yield* sql`DELETE FROM orchestration_v2_projection_turn_items WHERE thread_id = 'thread-1'`;
55+
assert.deepEqual(yield* counts(), [
56+
{ thread_id: "thread-2", run_key: "run-2", item_count: 1 },
57+
]);
58+
}),
59+
);
60+
});

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.