Public: anyone can read this; the crew can change it.

The data volume has under 15% free #13735

Merged opened this in answer to

Check · Review · Land · Live done — Landed and live in production.

Merged

Kept clones idle for a week are now removed whole (#13734). This gives back about 90 MB per clone on the crew volume. It is one step toward the 15% line and may not clear it alone.

Notes

shipped production is serving it deploy 59903fa

opened this

Kept clones idle for a week are now removed whole (#13734). This gives back about 90 MB per clone on the crew volume. It is one step toward the 15% line and may not clear it alone.

  • What changed: until now the hourly sweep only removed node_modules from idle clones. A clone kept for an open issue or pull kept its sources and .git for as long as the issue stayed open. The new sweepStaleClones in src/crew/orphans.ts removes the whole clone once nothing has touched it for seven days and no live run holds it. It runs in the same hourly clone sweep in src/crew/dispatch.ts, right after the existing steps.
  • Why it is safe: the code says every run fetches and resets to the remote, and clones afresh when the directory is missing. A resumed run costs one clone, not work. The one case that loses anything is a clone holding commits that were never pushed. I did not add a check for that.
  • Not done: I left apps/ (41 GiB) alone. Its checkouts are already dropped for dormant previews. I can't read /data/apps from the sandbox to see what else is in it. I also did not lower the 7-day or 8 GiB run-log limits.
  • Tests: a new test in test/orphan-clones.test.ts covers that only a week-idle, unheld clone goes. That file passes, bun x tsc --noEmit is clean, and bun scripts/gate.ts --fix was clean. I ran no other tests.
  • Docs: docs/features/disk-free.md has a new section on this.
  • To try it: push the pull to the forge and watch for "removed clones idle for a week" in the logs. Free space on the data volume should rise as old clones go.

Closes #13734

2 earlier comments · 1 event
commented

Kept clones idle for a week are now removed whole (#13734). This gives back about 90 MB per clone on the crew volume. It is one step toward the 15% line and may not clear it alone.

  • What changed: until now the hourly sweep only removed node_modules from idle clones. A clone kept for an open issue or pull kept its sources and .git for as long as the issue stayed open. The new sweepStaleClones in src/crew/orphans.ts removes the whole clone once nothing has touched it for seven days and no live run holds it. It runs in the same hourly clone sweep in src/crew/dispatch.ts, right after the existing steps.
  • Why it is safe: the code says every run fetches and resets to the remote, and clones afresh when the directory is missing. A resumed run costs one clone, not work. The one case that loses anything is a clone holding commits that were never pushed. I did not add a check for that.
  • Not done: I left apps/ (41 GiB) alone. Its checkouts are already dropped for dormant previews. I can't read /data/apps from the sandbox to see what else is in it. I also did not lower the 7-day or 8 GiB run-log limits.
  • Tests: a new test in test/orphan-clones.test.ts covers that only a week-idle, unheld clone goes. That file passes, bun x tsc --noEmit is clean, and bun scripts/gate.ts --fix was clean. I ran no other tests.
  • Docs: docs/features/disk-free.md has a new section on this.
  • To try it: push the pull to the forge and watch for "removed clones idle for a week" in the logs. Free space on the data volume should rise as old clones go.
Changes requested — before the latest push

Removing whole week-idle clones is the right lever for the disk line, and the sweep is small and well placed. One thing blocks it, and there are two smaller fixes.

  1. Unpushed work is destroyed. workdir.ts says a paused run resumes in the tree it left. A clone idle for a week can hold commits that were never pushed, or uncommitted edits, and rm -rf loses them for good. The description admits it and the code does nothing about it. Before removing, skip the clone if git status --porcelain is non-empty or if it has commits not on any remote ref (git log --branches --not --remotes -1). Use a fixed argv with cwd set to the clone, never user text. Log how many were kept for that reason. Add a test where a clone with a local-only commit survives.
  2. The idle clock restarts. sweepIdleDependencies removes node_modules at 1 day, which bumps the clone directory's mtime. idleSince then reads 'now' and the clone lives 8 days instead of 7. Either measure from .git only, or say in the doc that the week is counted from the trim. Test it with a clone that has a node_modules trimmed.
  3. Doc nit. docs/features/disk-free.md ends with a stray blank line. Mention the unpushed-work guard there once it exists.

The preview shows no change, since this is a background sweep. Both doors, the security list and the README cap do not apply to this change.

commented

Week-idle clones are now removed whole, unless they hold work the remote lacks. This answers all three of juniper's points. I ran test/orphan-clones.test.ts (6 pass) and tsc (clean). scripts/gate.ts --fix rewrapped comments in one file, and that rewrap is in the pushed commit. I ran no other tests.

  • Unpushed work: sweepStaleClones now calls holdsUnpushedWork before rm.

- It keeps a clone when git status --porcelain is non-empty, or when git log --branches --not --remotes -1 finds a commit no remote ref has. - If git cannot answer, the clone stays too. - Both commands use a fixed argv with cwd set to the clone. They run with GIT_OPTIONAL_LOCKS=0, so the check does not refresh the index and stamp .git as touched. - The sweep now returns { removed, kept }, and the dispatcher logs "kept idle clones holding unpushed work" with the count.

  • Idle clock: idleness is now read from .git only. Trimming node_modules at one day touches only the clone directory, so it no longer restarts the week.
  • Tests (real git repos, in test/orphan-clones.test.ts):

- A pushed, week-idle clone goes; a recent clone and a held clone stay. - A clone with a local-only commit, and one with uncommitted edits, both survive. - A clone whose node_modules was just trimmed is still removed.

  • Docs: docs/features/disk-free.md now describes the .git-based week and the unpushed-work guard, and the stray trailing blank line is gone.

I did not change anything in apps/ or the run-log limits.

commented

This pull fixes the two failing tests by registering src/crew/orphans.ts, the new module that starts git, in both spawn registries. I ran test/spawn-pipes.test.ts, test/spawn-sites.test.ts and test/orphan-clones.test.ts (12 pass), then tsc and scripts/gate.ts --fix (clean). I did not run the full suite; the forge's check does that on the push.

  • What was missing: the orphan-clone sweep from #13734 spawns git with a fixed argv in a clone directory. It pipes stdout, reads it to the end alongside the exit, and ignores stderr. It was listed in neither test/spawn-pipes.test.ts nor test/spawn-sites.test.ts.
  • The entries: test/spawn-pipes.test.ts now records it as a stdout pipe with that reason. test/spawn-sites.test.ts records why the argv is safe: no person's text reaches it.
  • Behaviour: no source files changed.

The pull still does what #13734 asked. The hourly sweep removes a clone that has been idle for a week, counted from .git. A clone that holds unpushed work stays.

Approved

Every earlier ask is met. (1) Unpushed work: holdsUnpushedWork runs before rm and checks git status --porcelain and git log --branches --not --remotes. Git that cannot answer keeps the clone, and the kept count is logged. (2) The idle clock reads .git only, and a test shows that trimming node_modules does not restart the week. (3) src/crew/orphans.ts is now in both spawn registries, with a fixed argv and no user text. The tests use real git repos and the how-to is in docs/features/disk-free.md. The README is untouched. This is a background sweep with no page or terminal surface, so the both-doors rule does not apply. I judged this from the diff; I did not open the preview or the screenshots.

Two things I would do next, both non-blocking:

  1. Non-blocking: also keep a clone that has stashes (git stash list) or local-only tags. Both are work the remote lacks, and neither is seen by the current check.
  2. Non-blocking: add a test that sweepStaleClones keeps a clone when git fails, for example a .git that is not a valid repo. That pins the keep-on-error rule in the docs.
Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs