Skip to content

fix: clean disposable resources after development tasks - #443

Merged
devSejung merged 1 commit into
mainfrom
fix/dev-resource-lifecycle
Nov 4, 2026
Merged

devSejung merged 1 commit into
mainfrom
fix/dev-resource-lifecycle

Conversation

@devSejung

Copy link
Copy Markdown
Owner

Closes #442

What Problem This Solves

Fixes an issue where developers repeatedly exhaust disk space because verification work leaves source clones, temporary inputs, worktrees, and tagged Docker images without one completion owner. Manual cleanup could not safely distinguish disposable work from another active task.

Why This Change Was Made

Add a dependency-free Node/Git developer workflow: create, bounded run, managed image, explicit finish, recover, list, sweep, and report-only audit. Worktrees share the primary Git repository; task-local temporary inputs and namespace-tagged verification images have recorded ownership in a separate development-only SQLite registry. This bootstrap registry uses fixed parameterized native SQLite primitives because setup/cleanup must work before package installation; product runtime databases and schema versions are untouched.

The existing development cleanup remains the sweep entry point. Per-task OS-owned locks serialize lifecycle operations; shared Git mutations have their own lock. Windows uses named pipes and Linux uses abstract Unix sockets, avoiding observed TCP ephemeral-port collisions and stale lock files. A hard-killed controller does not imply completion: uncertain tasks require explicit confirmation that their descendants stopped.

Image cleanup never force-removes images or implicitly prunes unmanaged parents. Dirty, untracked, ignored, hidden-index-modified, or container-referenced work is preserved. The existing Windows dependency-link guard is accepted only for exact unchanged tracked link placeholders. Docker build success is verified against an actual local owned image and the recorded engine.

User Impact

  • One primary checkout and managed task worktrees instead of ad-hoc independent clones.
  • Package-free workspace bootstrap; normal package caches/toolchain wrappers remain reusable where compatible. Windows linked-worktree installs remain prohibited.
  • Identical bounded manual/scheduled maintenance options, a four-hour Windows schedule, and visible blocked/uncertain task outcomes.
  • A shared setup/run/finish/recovery guide in scripts/README.md, linked from PLATFORMCLAW.md and producer policy in scripts/AGENTS.md.
  • No automatic adoption/deletion of legacy clones, no live service/container stops, no volume/DB deletion, and no automatic Docker/WSL downtime for VHDX compaction.

This is AI-assisted. Existing operator changes and services were preserved.

Evidence

Source base: 0c813eea16424a69d1c49f55853de42199f454dc (main including the composer alignment fix, PR #441). Final candidate bytes were matched by SHA-256 across all 11 changed files between the Windows worktree and isolated Linux proof checkout.

  • Linux, Node 24.18.0, isolated task-owned Docker container with a fresh pnpm install --frozen-lockfile: OPENCLAW_CHECK_CHANGED_REMOTE_CHILD=1 node scripts/platformclaw-check.mjs --changed passed. This includes 112 focused tests (20 lifecycle, 62 runtime contracts, 21 CI-plan, 9 shared-check), formatting, script declarations, root test types, dependency/patch/policy guards, and lint of 910 scripts. No gate/skip flags were used to turn failures into passes.
  • Native Windows Node: real temporary Git repository create → bounded run → preview → sweep → finish → idempotent finish passed; no installed packages required.
  • Native PowerShell: hidden primary .git installation path and four-hour/bounded arguments passed with task registration stubbed; the operator's actual scheduled task was not changed.
  • Linux isolated Docker-in-Docker engine (no host Docker socket): real managed build, referenced-container cleanup rejection, explicit source completion, unrelated alias preservation, and tag cleanup passed. A Docker exit-0/no-image negative case (--help) failed before the fix and passes after verification was added.
  • Regression tests preserve tracked/untracked/ignored work, both hidden Git index flags, canonical guarded link targets, interrupted tasks, symlink/junction boundaries, and reject grouped Docker publication flags before Docker is invoked.
  • git diff --check passed. Independent autoreview: final P0–P2 scoped-clean (exit 0). Repaired findings included hidden Git index changes, implicit parent image pruning, grouped Docker publication flags, and hidden Windows .git installation. Manual boundary checks additionally found and repaired exit-0/no-image reporting and TCP lock collisions.

Production LOC delta: +729 (including the 684-line dependency-free lifecycle owner); tests +410, documentation/instructions +158. Growth is justified by the previously missing developer resource owner and its safety boundary, not a product/runtime feature. There are no new packages or package installs in Windows linked worktrees.

Setup after merge

From the updated primary checkout (not a removable linked worktree):

.\scripts\platformclaw-dev-maintenance.ps1 -Action Install
.\scripts\platformclaw-dev-maintenance.ps1 -Action Status
git fetch origin main
node scripts/platformclaw-dev-task.mjs create example-fix --branch fix/example-fix --ref origin/main
node scripts/platformclaw-dev-task.mjs list
# Edit the printed worktree. Run bounded checks from the primary checkout:
node scripts/platformclaw-dev-task.mjs run example-fix -- node scripts/run-vitest.mjs test/scripts/platformclaw-dev-task.test.ts
# Commit or deliberately resolve your own edits/files, then preview and finish:
node scripts/platformclaw-dev-task.mjs finish example-fix
node scripts/platformclaw-dev-task.mjs finish example-fix --apply

Boundaries and follow-ups

Legacy independent clones/proof artifacts need separate ownership classification; timestamps or matching names alone do not authorize deletion. Most audited sibling clones share Git objects through alternates, and junctions are not duplicate dependency bytes. The actual host has 17 sibling clones plus the primary checkout, not 18 complete copies of history.

Existing release rollback provenance and deployment/archive retention remain release-owner follow-ups; this PR does not claim to fix those or bound total disk/VHDX size. Managed commands support Windows/Linux and must not daemonize. Final release images/archives, operator containers, data volumes, and VHDX compaction remain separate lifecycle contracts.

@devSejung
devSejung marked this pull request as ready for review November 4, 2026 07:49
@devSejung
devSejung merged commit 628c932 into main Nov 4, 2026
106 checks passed
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.

fix: completed development tasks leave disposable resources behind

1 participant