Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 2 additions & 17 deletions apps/server/src/orchestration/Layers/OrphanSessionRecovery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import {
type OrphanSessionRecoveryShape,
} from "../Services/OrphanSessionRecovery.ts";
import { ProjectionSnapshotQuery } from "../Services/ProjectionSnapshotQuery.ts";
import { readProviderRestartRecoveryMarker } from "../../provider/ProviderRestartRecovery.ts";
import { ProviderService } from "../../provider/Services/ProviderService.ts";
import { ProviderSessionDirectory } from "../../provider/Services/ProviderSessionDirectory.ts";

Expand Down Expand Up @@ -228,25 +227,14 @@ const make = Effect.gen(function* () {
.pipe(Effect.orElseSucceed(() => ({ threads: [] as const })));
const bindings = yield* directory.listBindings().pipe(Effect.orElseSucceed(() => []));
const threadIds = new Set<string>();
const recoveryMarkedThreadIds = new Set(
bindings.flatMap((binding) =>
readProviderRestartRecoveryMarker(binding.runtimePayload) === undefined
? []
: [String(binding.threadId)],
),
);

let settledSessions = 0;
let interruptedSessions = 0;
for (const thread of snapshot.threads) {
if (recoveryMarkedThreadIds.has(String(thread.id))) {
continue;
}
const claimsLive = isLiveClaimingSessionStatus(thread.session?.status);
const processIsLive = claimsLive ? yield* hasLiveProcess(thread.id) : false;
// Provider restart reconciliation runs before this audit and may
// already have resumed the thread. Never classify that replacement
// process as an orphan merely because its projected session is live.
// A replacement process started after boot (for example #9167
// continuation) is live — never classify that as an orphan.
if (
!shouldSettleAfterServerRestart({
claimsLive,
Expand All @@ -269,9 +257,6 @@ const make = Effect.gen(function* () {

let settledRuntimes = 0;
for (const binding of bindings) {
if (recoveryMarkedThreadIds.has(String(binding.threadId))) {
continue;
}
const claimsLive = binding.status === "running" || binding.status === "starting";
if (!claimsLive) {
continue;
Expand Down
Loading
Loading