Skip to content

fix(server): storage cleanup no longer sweeps at launch - #672

Merged
lastobelus merged 4 commits into
lastcode/mainfrom
lastcode/defer-startup-storage-cleanup
Nov 9, 2026
Merged

lastobelus merged 4 commits into
lastcode/mainfrom
lastcode/defer-startup-storage-cleanup

Conversation

@lastobelus

@lastobelus lastobelus commented Nov 9, 2026 •

Copy link
Copy Markdown
Owner

Every server start ran a full storage cleanup sweep immediately: worktree removal plus dependency and generated-build cleanup and the saved-workspace passes. That competes with launch-time Git work, and each relaunch restarts the full sweep from scratch. In one incident, three relaunches in about a minute each started a fresh full sweep alongside the launch Git burst. Traces also couldn't say which caller or Git command a runGitCommand span came from.

Fix

  • No sweep at launch. The first automatic sweep runs one interval (1 hour) after start, then hourly as before. Settings changes, thread deletions and provider-session stops still request sweeps immediately, and manual cleanup is unchanged. The delay is a FirstAutomaticSweepDelay reference. The test fixture sets it to zero so the existing sweep tests keep starting on activation.
  • Git spans name their work. runGitCommand spans record git.operation (the caller's operation name) and git.subcommand. Full arguments are never recorded, nor is anything not shaped like a subcommand, because they can carry remote URLs or -c / --config-env values.

Decisions

  • A deleted worktree that cleanup kept before a restart now waits for the first hourly sweep. The list of such worktrees lives in memory, and rebuilding it immediately would need a launch-time sweep, which this change removes on purpose.
  • The bulk of a sweep's cost, repeated walks of node_modules and worktrees for open-file evidence, is out of scope here and handled in a separate PR.

Proof

  • storageCleanup.test.ts, "automatically removes an eligible archived thread checkout an hour after launch": with the production default it checks that at 59 minutes there is no report, no worktree inventory and the worktree is still present, and at 60 minutes it expects the removal. It fails with the delay removed or with the default set to zero, and passes with the change.
  • storageCleanup.test.ts and GitVcsDriverCore.test.ts pass (596 tests). GeneratedDependencies.test.ts passes (162 tests); its worker-burst cases now start the first sweep on activation, because they test bursts during that sweep.
  • vp run check:changed origin/lastcode/main passes (format, lint, typecheck, changed tests). Knip's exports pass failed on the earlier base because of LegacyFeaturesSection; feat(web): drop the legacy sidebar mode, matching upstream #671 removed it, and this PR is rebased onto that.

Local review: 2 rounds with gpt-6.1-terra (xhigh), approved.

🤖 Generated with Claude Code (Claude Opus 5.5 in T3 Code)

@lastobelus
lastobelus marked this pull request as ready for review November 9, 2026 16:53
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-09T17:22:11.898152Z 771ebe3 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@lastobelus

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: e8af041c9e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@lastobelus

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

Reviewed commit: 033da5203a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

lastobelus and others added 4 commits November 9, 2026 10:20
Every server start ran a full storage cleanup sweep immediately, including
dependency and generated-build cleanup with their worktree walks. That
competes with launch-time Git work, and each relaunch restarts the full
sweep from scratch. Automatic sweeps now start one interval after launch
and repeat hourly as before. Settings changes and thread deletions still
request sweeps directly.

Carry-Group: incubator
Carry-Observation: The full launch-time sweep belongs to the incubator's dependency and build cleanup; upstream's launch sweep covers worktree removal only.

Co-Authored-By: Claude <[email protected]>
runGitCommand spans carried no attributes, so traces could not say which
caller or Git command a spike came from. Record the caller's operation name
and the Git subcommand. Full arguments stay out because they can carry
remote URLs or configuration values.

Carry-Group: incubator
Carry-Observation: Diagnostics for cleanup Git load; separable, but no other carry group owns tracing.

Co-Authored-By: Claude <[email protected]>
Treat --config-env as an option that takes a value, and record an argument
as the subcommand only when it is shaped like one, so option values never
reach trace attributes. The launch-delay test now reads the production
default instead of injecting one hour.

Carry-Group: incubator

Co-Authored-By: Claude <[email protected]>
The worker lifecycle cases publish bursts while the first automatic sweep
inventories, so they provide a zero first-sweep delay like the other
cleanup fixtures.

Carry-Group: incubator

Co-Authored-By: Claude <[email protected]>
@lastobelus

Copy link
Copy Markdown
Owner Author

@codex review

@lastobelus
lastobelus force-pushed the lastcode/defer-startup-storage-cleanup branch from 033da52 to 771ebe3 Compare November 9, 2026 17:20
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

Reviewed commit: 771ebe31c3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@lastobelus
lastobelus merged commit dcf3275 into lastcode/main Nov 9, 2026
20 of 38 checks passed
@lastobelus
lastobelus deleted the lastcode/defer-startup-storage-cleanup branch November 9, 2026 17:35
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.

1 participant