Skip to content

Commit c1e8eab

Browse files
committed
Keep unpublished rewrites out of the empty checkpoint skip
Empty managed checkpoints skip the git commit when no allowlisted path differs from HEAD. A staged rewrite is still unpublished on disk at that check, so skipping would publish it in memory without writing or committing. Only skip when nothing is staged to land.
1 parent 8af755b commit c1e8eab

1 file changed

Lines changed: 18 additions & 15 deletions

File tree

‎src/session/optimized-context-store.ts‎

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -742,22 +742,25 @@ export async function createSessionStores(
742742
const headBefore = stagedRewrite === null ? null : await headOid(dir);
743743
let extraPaths: string[] = [];
744744

745-
const managedFilepaths = [
746-
...VENDOR_COMMIT_ROOT_FILES,
747-
TOOL_OUTPUT_DIR,
748-
EVIDENCE_ARCHIVE_DIR,
749-
...extraPaths,
750-
];
751-
if (!(await managedPathsDiffer(dir, managedFilepaths))) {
752-
const [head] = await base.log(1);
753-
if (head !== undefined) {
754-
pendingBlobFilepaths.clear();
755-
pendingSegmentPaths.clear();
756-
if (stagedRewrite !== null) {
757-
liveTurnRefs = stagedRewrite;
758-
unpublishedRewrite = null;
745+
// Empty managed checkpoints must not create a new commit or stage
746+
// session junk such as partial.jsonl. A staged unpublished rewrite
747+
// is still unpublished on disk — skip would swallow the compact
748+
// without writing it, so that path always goes through commit.
749+
if (stagedRewrite === null) {
750+
const managedFilepaths = [
751+
...VENDOR_COMMIT_ROOT_FILES,
752+
TOOL_OUTPUT_DIR,
753+
EVIDENCE_ARCHIVE_DIR,
754+
...pendingSegmentPaths,
755+
...pendingBlobFilepaths,
756+
];
757+
if (!(await managedPathsDiffer(dir, managedFilepaths))) {
758+
const [head] = await base.log(1);
759+
if (head !== undefined) {
760+
pendingBlobFilepaths.clear();
761+
pendingSegmentPaths.clear();
762+
return head;
759763
}
760-
return head;
761764
}
762765
}
763766

0 commit comments

Comments
 (0)