Skip to content

fix: share Git objects and prune orphan snapshots - #300

Merged
konard merged 8 commits into
mainfrom
issue-298-563f08b7679d
Sep 1, 2026
Merged

konard merged 8 commits into
mainfrom
issue-298-563f08b7679d

Conversation

@konard

@konard konard commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Summary

  • store snapshot commits through a Git alternates link to the source repository object database instead of duplicating unchanged objects
  • prune old snapshot stores whose recorded worktree no longer exists, including related sessions, messages, parts, diffs, and todos
  • run cleanup at project startup and instance disposal while protecting the newest snapshot, snapshots newer than 15 minutes, and snapshots with live worktrees
  • keep the clean-package CI consumer free of Bun template dependencies so current Bun releases do not inject unrelated peer warnings
  • add a patch changeset

Reproduction

Before this change, creating snapshots for multiple project worktrees populated each snapshot repository with its own full object database, and deleting a worktree left its snapshot and associated storage records indefinitely.

Verification

  • Added an isolated real-Git regression test proving snapshots use the source object database and remain restorable
  • Added filesystem regression coverage for newest, recent, live, and old orphan stores plus the complete associated-record cascade
  • Added lifecycle coverage for startup and disposal cleanup
  • npm run check
  • npm test: 718 passed, 4 todo, 0 failed
  • cargo test
  • node scripts/validate-changeset.mjs
  • CI: JS CI/CD Pipeline passed on Linux, macOS, and Windows

Fixes #298

Adding .gitkeep for PR creation (default mode).
This file will be removed when the task is complete.

Issue: #298
@konard konard self-assigned this Sep 1, 2026
@konard

konard commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

Working session summary

I reproduced the defect: tracking an 8 MB repository created another ~8 MB snapshot object store with no alternates. Using Git alternates reduced the unchanged snapshot store to 16 KB while preserving object access.

This is a bounded fix. Proposed design:

  • Update js/src/snapshot/index.ts to configure the snapshot repository’s objects/info/alternates with the real repository object directory before git add.
  • Add focused project cleanup logic that prunes snapshot stores only when they are old, not newest, and their recorded worktree no longer exists.
  • Remove associated project/session/message/part/session-diff records for pruned projects.
  • Run cleanup at project startup and instance disposal.
  • Add real filesystem/Git tests covering object sharing, snapshot operations, orphan deletion, and preservation of newest/recent/live stores.
  • Do not automatically disable snapshots under $TMPDIR; that could silently remove revert functionality. Alternates plus safe pruning address the leak without changing user-facing behavior.

PR #300 currently has no reviews or comments. Approve this design so I can begin the failing tests and implementation?


This summary was automatically extracted from the AI working session output.

@konard konard changed the title [WIP] Snapshot store duplicates the whole repository per project and is never garbage-collected (115 orphaned stores / 31 GB in one run) Snapshot store duplicates the whole repository per project and is never garbage-collected (115 orphaned stores / 31 GB in one run) Sep 1, 2026
@konard
konard marked this pull request as ready for review September 1, 2026 19:08
@konard

konard commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

🤖 Solution Draft Log

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost estimation:

  • Model: GPT-5.6 Sol
  • Provider: OpenAI
  • Public pricing estimate: $1.482124

📊 Context and tokens usage:

  • 79.3K / 200K (40%) input tokens, 8.9K / 128K (7%) output tokens

Total: (79.3K + 725.8K cached) input tokens, 8.9K output tokens, $1.482124 cost

🤖 Models used:

  • Tool: OpenAI Codex
  • Requested: gpt-5.6-sol
  • Thinking level: medium (~15999 tokens)
  • Model: GPT-5.6 Sol (gpt-5.6-sol)

📎 Log file uploaded as Gist (833KB)


Now working session is ended, feel free to review and add any feedback on the solution draft.

@konard

konard commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

🔄 Auto-restart 1/5

Reason: Merge conflicts detected

Starting new session to address the issues.


Auto-restart-until-mergeable mode is active. This run will stop after 5 restart iterations in total.

@konard
konard marked this pull request as draft September 1, 2026 19:10
Configure Git alternates before indexing so unchanged blobs remain in the source repository instead of being duplicated.\n\nRefs #298
Keep the newest, recent, and live snapshot stores while removing old stores whose recorded worktrees no longer exist. Cascade cleanup through project session storage at startup and disposal.\n\nRefs #298
Complete the per-session storage cascade and bound the isolated regression test process. Refs #298.
@konard konard changed the title Snapshot store duplicates the whole repository per project and is never garbage-collected (115 orphaned stores / 31 GB in one run) fix: share Git objects and prune orphan snapshots Sep 1, 2026
@konard
konard marked this pull request as ready for review September 1, 2026 19:32
Let bun add create the clean consumer manifest so changes in the bun init template cannot inject incompatible peer versions.
@konard

konard commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

Working session summary

Resolved and finalized PR #300.

  • Merged latest main and resolved conflicts.
  • Implemented Git alternates and safe orphan snapshot/storage pruning.
  • Added regression and lifecycle tests plus a patch changeset.
  • Addressed independent review feedback for orphan todo cleanup.
  • Fixed the clean-package CI fixture for Bun 1.4.
  • Local: 718 JS tests passed; full Rust suite and checks passed.
  • Final CI run passed on SHA 8f38960.
  • PR is ready, mergeable, conflict-free, and the working tree is clean.

This summary was automatically extracted from the AI working session output.

@konard

konard commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

🔄 Auto-restart-until-mergeable Log 1/5

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost estimation:

  • Model: GPT-5.6 Sol
  • Provider: OpenAI
  • Public pricing estimate: $10.270603

📊 Context and tokens usage:

  • 283.5K / 200K (142%) input tokens, 44.1K / 128K (34%) output tokens

Total: (283.5K + 8.3M cached) input tokens, 44.1K output tokens, $10.270603 cost

🤖 Models used:

  • Tool: OpenAI Codex
  • Requested: gpt-5.6-sol
  • Model: GPT-5.6 Sol (gpt-5.6-sol)

📎 Log file uploaded as Gist (4897KB)


Now working session is ended, feel free to review and add any feedback on the solution draft.

@konard
konard merged commit f915209 into main Sep 1, 2026
10 checks passed
@konard

konard commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

🎉 Auto-merged

This pull request has been automatically merged by hive-mind.

  • All CI checks have passed

Auto-merged by hive-mind with --auto-merge flag

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Snapshot store duplicates the whole repository per project and is never garbage-collected (115 orphaned stores / 31 GB in one run)

1 participant