Skip to content

Commit eb97ac5

Browse files
donjorrsi-pr-agent
authored andcommitted
refactor(upstream-fixes): retire the fork's activities purge now upstream drops the table
Upstream migration 063 drops projection_thread_activities, so the fork purge keeps only the imported V1 event drain. Fork-Domain: upstream-fixes Fork-Tier: bugfix Fork-Upstreamable: yes
1 parent 10f7a3d commit eb97ac5

2 files changed

Lines changed: 6 additions & 23 deletions

File tree

‎apps/server/src/orchestration-v2/legacy/LegacyV1Purge.fork.test.ts‎

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,8 @@ it.layer(SqlitePersistence.layerMemory, { excludeTestServices: true })("legacy v
4545
VALUES (${imported}, ${now}, ${now}, ${now}, 0, NULL),
4646
(${pending}, ${now}, ${now}, NULL, 0, NULL)
4747
`;
48-
yield* sql`
49-
WITH RECURSIVE n(i) AS (SELECT 1 UNION ALL SELECT i + 1 FROM n WHERE i < 1500)
50-
INSERT INTO projection_thread_activities (
51-
activity_id, thread_id, tone, kind, summary, payload_json, created_at
52-
)
53-
SELECT 'activity:' || i, ${imported}, 'info', 'tool.completed', '', '{}', ${now} FROM n
54-
`;
5548

56-
assert.deepEqual(yield* purgeImportedLegacyV1Fork(sql), { events: 1001, activities: 1500 });
49+
assert.deepEqual(yield* purgeImportedLegacyV1Fork(sql), { events: 1001 });
5750

5851
const remaining = yield* sql<{ readonly event_id: string }>`
5952
SELECT event_id FROM orchestration_events ORDER BY event_id
@@ -62,7 +55,7 @@ it.layer(SqlitePersistence.layerMemory, { excludeTestServices: true })("legacy v
6255
remaining.map((row) => row.event_id),
6356
["v1-pending:1", "v1-pending:2", "v1-project:1", "v2:1"],
6457
);
65-
assert.deepEqual(yield* purgeImportedLegacyV1Fork(sql), { events: 0, activities: 0 });
58+
assert.deepEqual(yield* purgeImportedLegacyV1Fork(sql), { events: 0 });
6659
}),
6760
);
6861
});

‎apps/server/src/orchestration-v2/legacy/LegacyV1Purge.fork.ts‎

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Fork-owned purge of V1 rows the V2 runtime never reads. Every V2 reader selects
22
// only `application_event_version = 2` thread events, so a thread's V1 events are
3-
// dead once its transcript import finishes, and `projection_thread_activities`
4-
// has no reader at all. Upstream's `ProjectionMaintenance.compactEventStore` also
3+
// dead once its transcript import finishes. Upstream's `ProjectionMaintenance.compactEventStore` also
54
// drops these events but has no production caller, and its thread-state
65
// supersession would delete the fork's legacy issue markers. Retire this when
76
// upstream schedules its own compaction and the markers no longer depend on events.
@@ -45,20 +44,11 @@ export const purgeImportedLegacyV1Fork = Effect.fn("purgeImportedLegacyV1Fork")(
4544
)
4645
RETURNING sequence
4746
`);
48-
const activities = yield* drainPages(sql`
49-
DELETE FROM projection_thread_activities
50-
WHERE rowid IN (SELECT rowid FROM projection_thread_activities LIMIT ${PAGE_SIZE})
51-
RETURNING rowid
52-
`);
53-
if (events + activities > 0) {
54-
yield* Effect.logInfo("Purged imported legacy v1 rows", { events, activities });
55-
}
56-
return { events, activities };
47+
if (events > 0) yield* Effect.logInfo("Purged imported legacy v1 rows", { events });
48+
return { events };
5749
},
5850
// A failed purge leaves the rest for the next startup.
5951
Effect.catchCause((cause) =>
60-
Effect.logWarning("Legacy v1 purge stopped", { cause }).pipe(
61-
Effect.as({ events: 0, activities: 0 }),
62-
),
52+
Effect.logWarning("Legacy v1 purge stopped", { cause }).pipe(Effect.as({ events: 0 })),
6353
),
6454
);

0 commit comments

Comments
 (0)