Skip to content

fix(orchestrator): add worktree ownership manifest gate to sweep Refs #1731#877

Merged
AlexMikhalev merged 1 commit into
mainfrom
task/1731-worktree-ownership-manifest
May 18, 2026
Merged

fix(orchestrator): add worktree ownership manifest gate to sweep Refs #1731#877
AlexMikhalev merged 1 commit into
mainfrom
task/1731-worktree-ownership-manifest

Conversation

@AlexMikhalev
Copy link
Copy Markdown
Contributor

Summary

Adds WorktreeManifest sentinel written at worktree creation time. Both sweep_stale (Rust) and adf-cleanup.sh (shell) now require a valid .adf-worktree-manifest.json before deleting any directory, regardless of naming convention.

Problem

Layer 2 and Layer 3 ADF cleanup delete every direct child of /tmp/adf-worktrees without a marker or ownership check. The root ExecStartPre script can remove unrelated data.

Changes

  • scope.rs: WorktreeManifest struct with read/write/validate. Written by create_worktree. sweep_one requires valid manifest before deletion.
  • adf-cleanup.sh: valid_manifest() POSIX function checks repo and path fields before rm -rf.
  • test_adf_cleanup.sh: Updated to write manifests for test worktrees.
  • SweepReport: New no_manifest_skipped field for observability.

Verification

  • cargo test -p terraphim_orchestrator --lib -- test_sweep: 7 passed
  • bash scripts/adf-setup/tests/test_adf_cleanup.sh: PASS
  • cargo fmt, cargo clippy: clean
  • UBS: no critical issues

Refs terraphim/terraphim-ai#1731 (Gitea)

… #1731

Add WorktreeManifest sentinel written at worktree creation time.
sweep_one and adf-cleanup.sh now require a valid manifest before
deleting any directory, regardless of naming convention.

- scope.rs: Add WorktreeManifest struct with read/write/validate.
  write_test_manifest helper for tests. sweep_one skips entries
  without valid manifest (counted as no_manifest_skipped).
- adf-cleanup.sh: valid_manifest() gate before /bin/rm -rf.
- test_adf_cleanup.sh: write manifests for test worktrees.
- Updated all sweep unit tests to use write_test_manifest.
- SweepReport gains no_manifest_skipped field.
@AlexMikhalev AlexMikhalev merged commit dd23f11 into main May 18, 2026
2 of 5 checks passed
@AlexMikhalev AlexMikhalev deleted the task/1731-worktree-ownership-manifest branch May 18, 2026 13:37
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