Skip to content

fix(projects): prevent automatic Git repacks in managed clones - #182086

Merged
steipete merged 3 commits into
mainfrom
steipete/perf-micro-managed-git-maintenance-20260919
Oct 24, 2026
Merged

steipete merged 3 commits into
mainfrom
steipete/perf-micro-managed-git-maintenance-20260919

Conversation

@steipete

@steipete steipete commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes detached, memory-heavy Git auto-repacks starting from ordinary commits or fetches in Gateway-cloned projects when a command clears the injected agent environment.

User Impact

New managed clones and existing clones reused or refreshed after an update retain repository-local maintenance policy, including in linked worktrees. Operator-registered repositories keep their Git configuration. No OpenClaw configuration or Doctor migration is needed; existing clones are adopted lazily under their checkout lifecycle lease.

Why This Change Was Made

Agent environment suppression already exists. Persisting maintenance.auto=false and gc.auto=0 makes the repository own that policy. Managed clones also set pack.threads=1 and pack.windowMemory=64m; the window bounds delta-search memory per thread, not total RSS.

The existing hourly worktree owner remains the only automatic maintenance scheduler. It already consolidates small packs in sequential batches of at most 512 MiB, with one thread, no new delta search, lower CPU priority, idle I/O where available, and cancellable subprocesses. This change introduces no replacement scheduler, cache, schema, or fallback reader.

Production delta: +52 lines (53 added / 1 removed in src/projects); the growth implements persistent policy and its existing-clone adoption boundary. Tests add 85 lines; the rerunnable synthetic measurement script adds 268 lines. There was no superseded production path to delete.

Evidence

  • Before the fix, all three real-Git regressions fail: new clone, reused clone, refreshed clone. A linked-worktree commit/fetch launches maintenance after clearing injected Git configuration. With the fix, all three pass and launch no maintenance/GC/repack child.
  • A separate real-Git case confirms reusing an operator-registered repository preserves its policy.
  • node scripts/run-vitest.mjs src/projects/project-registry.test.ts src/projects/project-clone-runtime.test.ts --maxWorkers=1: both files pass. Registry file: 52.57 s, mostly existing large-ref inventory cases; the three new regressions take about 2.1 s. Additional operator-policy case passes (about 0.7 s). CI initially found a missing mocked export in the Windows environment-routing fixture; the mock is corrected and all 18 tests in that file pass locally (0.76 s). The test-only repair received a clean independent review. CI then requested removal of the now-obsolete mock exception. The owning generator pruned exactly that one entry (7,129 → 7,128); independent review confirmed the shrink-only change. Prior-head CI run 40052653193 passed on a637006e60be738f7395da483cf6293b40b6c27a. After a patch-identical rebase onto latest main, CI run 40055190091 passed on head 5386927a988e633d7fe1ee437033cc736d7f6136.
  • Changed-file oxfmt and oxlint pass; pnpm tsgo:core passes using tsrs. Export-name collision guard passes. Eager-import and PR-wrapper closure tests: 22 pass.
  • Independent subagent review (autoreview route unavailable): no actionable P0–P2 findings. The installed helper refused the requested provider route because it did not match the operator configuration; no configuration was changed.

Measurement acceptance and status

Acceptance was recorded before measurement: ordinary commit/fetch launches zero automatic maintenance children; owner maintenance consolidates a synthetic 128 MiB / 4,096-blob / 32-pack repository without losing objects, running full GC, detaching, or accessing a network. The script verifies blob identities/sizes and runs git fsck afterward.

RSS bound unmeasured. The maintainer explicitly approved landing this incident reliability fix based on the real-Git red-to-green suppression regressions; RSS measurement is supporting evidence, not a landing gate. No throughput or total-RSS guarantee is claimed. Four 128 MiB fixtures were prepared, but no measurement ran while the authorized sandbox was overloaded. Benchmark slots are now closed, so no further measurement is scheduled. The existing maintenance owner is unchanged. After SSH recovered and both memory-pressure avg10 readings were 0.00, the queued task process tree was stopped and the task sandbox was removed; no benchmark was started. No local fixture was available for a cheap optional RSS run.

Sibling audit: skill and marketplace Git clones are temporary; installed skill exports strip .git; session cold storage is not Git. Git plugin updates replace their checkout with a fresh clone instead of accumulating fetch packs. Operator-owned Git backups are a separate follow-up because their commits can trigger auto-GC; this PR does not change that ownership contract.

@clawsweeper

clawsweeper Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-24T02:43:11.569113Z 5386927 New commits
ℹ️ 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.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation scripts Repository scripts size: M labels Oct 24, 2026
@steipete
steipete force-pushed the steipete/perf-micro-managed-git-maintenance-20260919 branch 2 times, most recently from 5a7db0b to a637006 Compare October 24, 2026 02:04
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 24, 2026
@clawsweeper

clawsweeper Bot commented Oct 24, 2026

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

Persist Git maintenance suppression and packing limits in Gateway-managed clones, including existing clones when reused or refreshed.

Example: A linked worktree runs git commit after clearing GIT_CONFIG_PARAMETERS and GIT_CONFIG_COUNT.

  • Before: Environment-only suppression disappears, allowing automatic maintenance and repacking.
  • After: Shared repository settings maintenance.auto=false and gc.auto=0 continue suppressing automatic maintenance.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Focused and source-consistent repair with useful real-Git regression coverage; validation remains incomplete.
Proof confidence 🦐 gold shrimp (3/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Ordinary Git commands can launch memory-heavy automatic repacks in Gateway-managed projects after clearing injected environment settings.
Reason: The maintainer-authored direction closes a demonstrated coverage gap while retaining existing ownership and explicitly preserving operator-registered policy.

Merge readiness

⛔ Blocked before merge - 1 item remains

Keep open: this maintainer-authored PR closes a source-confirmed gap in managed-clone maintenance policy, with no concrete introduced correctness defect found.

Priority: P2
Reviewed head: a637006e60be738f7395da483cf6293b40b6c27a

Before merge

  • Add data-model compatibility proof - The review found that existing stored data may not work after upgrade. Show that existing data still loads and works with this change.

Findings

None.

Tests

  • Missing end-to-end proof: Supply the pending paired maintenance results and a fresh-install/latest-stable upgrade run showing lazy adoption, linked-worktree suppression, and preservation of unrelated repository settings.
Agent review details

How this fits together

Gateway project materialization owns managed clones and their lifecycle leases; repository-local Git policy governs ordinary commands, while the existing hourly worktree cleanup owner performs explicit bounded maintenance.

flowchart TD
  A[Gateway project request] --> B[Project clone owner]
  B --> C[New managed clone]
  B --> D[Existing checkout lifecycle lease]
  C --> E[Shared local Git configuration]
  D --> E
  E --> F[Linked worktree Git commands]
  G[Hourly cleanup owner] --> E
Loading

Technical review

Best possible solution:

Keep persistent policy in the existing managed-clone owner and retain the existing bounded hourly maintenance scheduler.

Do we have a high-confidence way to reproduce the issue?

Current-main clone provisioning persists no suppression policy, so clearing injected Git settings exposes Git defaults; the PR supplies real-Git regression cases and reports base failures, but this read-only review ran no target code.

Is this the best way to solve the issue?

This addresses the policy at its existing repository owner, preserves operator-registered repositories, and adds no competing scheduler or state store.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 516a142b102f.

Provenance checked

  • Repository-local maintenance policy changes intended behavior with a stated reason (9284c76: Environment-only suppression preserved repository configuration and covered existing worktrees; this PR explains the additional environment-clearing failure case.)
  • Existing-clone lifecycle adoption keeps the original intent (16419cb: Serialize existing-project reuse with registration and deletion to preserve shared checkout references; the new writes remain inside that lifecycle.)
  • Clone command cleanup keeps the original intent (2613409: Retain checkout and staging artifacts when Git cleanup is uncertain; adding clone configuration arguments preserves that command owner and cleanup classification.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 8876528 adds src/projects/project-clone.ts:8 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 8876528f7c0e; files: src/projects/project-clone.ts)
  • Galin Iliev: Raw commit db01f6d adds src/projects/project-clone.ts:13 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: db01f6d520b8; files: src/projects/project-clone.ts)

PR surface

Source +52, Tests +85, Docs +11, Other +267. Total +415 across 7 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 2 53 1 +52
Tests 2 85 0 +85
Docs 1 12 1 +11
Config 0 0 0 0
Generated 0 0 0 0
Other 2 268 1 +267
Total 7 418 3 +415

Review metrics

Metric Value Why it matters
Production versus tests Production +53/-1; tests +85/-0 Growth implements shared persistent policy and two existing-clone adoption boundaries, with distinct creation, reuse, refresh, and operator-policy regressions.
Persisted Git settings 4 repository-local settings; 0 OpenClaw configuration options Managed clones receive maintenance.auto=false, gc.auto=0, pack.threads=1, and pack.windowMemory=64m.

Labels

Label changes:

  • add P2: Automatic repacking can consume substantial resources in managed repositories, but the evidence establishes a bounded workflow defect rather than an urgent widespread outage.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.

Label justifications:

  • P2: Automatic repacking can consume substantial resources in managed repositories, but the evidence establishes a bounded workflow defect rather than an urgent widespread outage.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Complete the already-declared paired maintenance measurement.
  • Demonstrate fresh-install and latest-stable upgrade behavior with existing repository settings preserved.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 23, 2026, 10:30 PM ET / October 24, 2026, 02:30 UTC.

Persist repository-local maintenance policy at clone creation and adopt existing managed projects under the checkout lease. Retain the bounded hourly worktree maintenance owner and preserve operator-registered repository configuration.
@steipete
steipete force-pushed the steipete/perf-micro-managed-git-maintenance-20260919 branch from a637006 to 5386927 Compare October 24, 2026 02:40
@steipete
steipete merged commit 8720a81 into main Oct 24, 2026
137 checks passed
@steipete
steipete deleted the steipete/perf-micro-managed-git-maintenance-20260919 branch October 24, 2026 02:50
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 24, 2026
…law#182086)

* fix(projects): prevent automatic Git repacks in managed clones

Persist repository-local maintenance policy at clone creation and adopt existing managed projects under the checkout lease. Retain the bounded hourly worktree maintenance owner and preserve operator-registered repository configuration.

* test(projects): isolate maintenance configuration in environment fixtures

* test(projects): prune the retired clone runtime mock exception
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. scripts Repository scripts size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant