Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): reject checkpoint reverts before mutating the workspace #9069

Closeddlowzzxx(GitHub profile, opens in a new tab)wants to merge 2 commits intomain fromrefs/pull/9069/headopened View on GitHub

Showing 3 changed files with 151 additions and 6 deletions.

x
0 of 3 viewed, 3 left
12 additions and 0 deletionsapps/server/src/checkpointing/Utils.tsModified
View file
@@ -9,6 +9,18 @@
);
​
+/**
+ * Working-tree snapshot taken right before a revert so a failed provider
+ * rollback can be compensated back to the exact pre-revert state — prior
+ * checkpoints can miss uncommitted local edits. One per thread; the capture
+ * overwrites it on each revert attempt via `git update-ref`.
+ */
+export function checkpointRefForRevertBase(threadId: ThreadId): CheckpointRef {
+ return CheckpointRef.make(
+ `${CHECKPOINT_REFS_PREFIX}/${Encoding.encodeBase64Url(threadId)}/revert-base`,
+ );
+}
+​
export function resolveThreadWorkspaceCwd(input: {
readonly thread: {
readonly projectId: ProjectId;
96 additions and 1 deletionapps/server/src/orchestration/Layers/CheckpointReactor.test.tsModified
View file
@@ -55,6 +55,7 @@
ProviderService,
type ProviderServiceShape,
} from "../../provider/Services/ProviderService.ts";
+import { ProviderAdapterRequestError, type ProviderServiceError } from "../../provider/Errors.ts";
import { checkpointRefForThreadTurn } from "../../checkpointing/Utils.ts";
import { ServerConfig } from "../../config.ts";