Skip to content

Commit 3f9f672

Browse files
fix(server): recheck native child branches under any worktree prefix
Temporary worktree branches can now carry a project's static prefix, so the t3/<hex> pattern no longer identifies them. Recheck every native child that shares a worktree; the check only compares HEAD with the recorded branch. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent b5ce12f commit 3f9f672

2 files changed

Lines changed: 12 additions & 15 deletions

File tree

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

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1863,15 +1863,18 @@ layer("ProviderEventIngestorV2", (it) => {
18631863
);
18641864

18651865
it.effect.each([
1866-
{ parentMoved: false, failure: null },
1867-
{ parentMoved: true, failure: null },
1868-
{ parentMoved: false, failure: "write" },
1869-
{ parentMoved: false, failure: "git" },
1866+
{ parentMoved: false, failure: null, temporaryBranch: "t3/abcd1234" },
1867+
{ parentMoved: true, failure: null, temporaryBranch: "t3/abcd1234" },
1868+
{ parentMoved: false, failure: "write", temporaryBranch: "t3/abcd1234" },
1869+
{ parentMoved: false, failure: "git", temporaryBranch: "t3/abcd1234" },
1870+
{ parentMoved: false, failure: null, temporaryBranch: "my-prefix/abcd1234" },
18701871
])(
18711872
"rechecks a pending native child's branch after the rename scan: %j",
1872-
({ parentMoved, failure }) =>
1873+
({ parentMoved, failure, temporaryBranch }) =>
18731874
Effect.gen(function* () {
18741875
const { worktreePath, command } = yield* makeSharedWorktree;
1876+
if (temporaryBranch !== "t3/abcd1234")
1877+
yield* command(worktreePath, ["branch", "-m", temporaryBranch]);
18751878
const git = yield* GitVcsDriver.GitVcsDriver;
18761879
const now = yield* DateTime.now;
18771880
const eventSink = yield* EventSink.EventSinkV2;
@@ -1881,13 +1884,13 @@ layer("ProviderEventIngestorV2", (it) => {
18811884
if (rootEvent.type !== "thread.created") throw new Error("Expected thread fixture");
18821885
const parent = {
18831886
...rootEvent.payload,
1884-
branch: "t3/abcd1234",
1887+
branch: temporaryBranch,
18851888
worktreePath,
18861889
};
18871890
yield* eventSink.write({ events: [{ ...rootEvent, payload: parent }] });
18881891
const childId = ids.derive.threadFromProviderThread({
18891892
driver: CODEX_DRIVER,
1890-
nativeThreadId: `child-created-during-rename:${parentMoved}:${failure}`,
1893+
nativeThreadId: `child-created-during-rename:${parentMoved}:${failure}:${temporaryBranch}`,
18911894
});
18921895
const beforeCommit = yield* Deferred.make<
18931896
void,
@@ -2056,7 +2059,7 @@ layer("ProviderEventIngestorV2", (it) => {
20562059
});
20572060
assert.equal((yield* projections.getThread(childId)).branch, branch);
20582061
assert.equal(stored.length, 1);
2059-
assert.equal(gitReads, scenario === "explicit" ? 0 : 1);
2062+
assert.equal(gitReads, 1);
20602063
}),
20612064
);
20622065

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

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import * as Schema from "effect/Schema";
2525
import * as SqlError from "effect/sql/SqlError";
2626

2727
import { AgentScope } from "@t3tools/shared/AgentScope";
28-
import { isTemporaryWorktreeBranch } from "@t3tools/shared/git";
2928
import { modelSelectionsEqual } from "@t3tools/shared/model";
3029
import {
3130
ProviderTurnAnalytics,
@@ -771,12 +770,7 @@ export const layer: Layer.Layer<
771770
);
772771
if (created?.event.type !== "thread.created") return storedEvents;
773772
const child = created.event.payload;
774-
if (
775-
child.worktreePath === null ||
776-
child.branch === null ||
777-
!isTemporaryWorktreeBranch(child.branch)
778-
)
779-
return storedEvents;
773+
if (child.worktreePath === null || child.branch === null) return storedEvents;
780774
// Git renames before scanning committed threads. If that scan missed this
781775
// creation, HEAD already has the new name, even if the parent moved away.
782776
const branch = yield* git.resolveBranchName(child.worktreePath, "HEAD");

0 commit comments

Comments
 (0)