Skip to content

Fix completion blocked by idle workspace holders - #679

Merged
itdove merged 1 commit into
mainfrom
fix-completion-preflight
Nov 18, 2026
Merged

itdove merged 1 commit into
mainfrom
fix-completion-preflight

Conversation

@itdove

@itdove itdove commented Nov 18, 2026

Copy link
Copy Markdown
Owner

Description

  • Added a default-No interactive confirmation for completing a session without cleanup when a terminal or background daemon retains a workspace's current directory.
  • Preserves every managed clone/worktree after that confirmation, regardless of cleanup settings, while allowing the ordinary commit/push/PR workflow to proceed.
  • Holds lifecycle locks throughout completion to prevent concurrent managed agent startup. Live launch locks and process-inspection failures remain non-overridable.
  • Keeps JSON, non-interactive, and --yes modes fail-closed for unresolved directory holders. Deletion still checks actual directory use.
  • Makes refusal diagnostics backend-neutral and updates the workflow skill, documentation, and changelog.

No processes are killed, services stopped, backend locations evicted, or security settings changed.

Related issue (if applicable)

N/A — follow-up to the reported daf complete refusals, separate from the already merged worktree branch-selection change in #678.

Type of change

  • Bug fix
  • New feature
  • Security fix or detection change
  • Documentation or workflow change
  • Refactoring or maintenance

Security impact

  • This change has no security impact.
  • This change affects security behavior; describe the threat, protection, and user-visible behavior below.

The lifecycle guard protects against completing or deleting workspaces while agents are editing them. This change distinguishes a held launch lock from a working-directory holder; it does not infer inactivity from process names, ancestry, paused tracking, or native session IDs. With all lifecycle locks acquired, only explicit interactive confirmation that editing has stopped permits completion with directory holders present. All workspaces are then preserved. Enter declines; --yes, JSON, and non-interactive execution cannot supply that approval. Lock contention and inspection failures still refuse before session mutations. Actual cleanup retains its strict process-use checks, including sibling directories and late-arriving holders.

Testing

  • Tests added or updated where needed.
  • Related tests pass locally.
  • Manual verification completed, if applicable. Not run against live user sessions; isolated CLI tests exercise real Git commit and push to a temporary local remote.

Steps to test

  1. Run the focused command below.
  2. In an isolated session with no active editing agent, invoke interactive completion from inside its clone/worktree. Review the reported directory holder and explicitly approve completion without cleanup.
  3. Verify the ordinary commit/push workflow remains available and the checkout is retained, even when cleanup is enabled.
  4. Decline the confirmation, or use JSON/non-interactive/--yes mode, and verify unresolved holders still refuse without metadata changes.
  5. Hold a launch lock or simulate an inspection failure and verify no interactive override is offered.

Scenarios tested

  • Completion from inside retained clones and worktrees, with cleanup enabled and disabled.
  • Actual commit and push to an isolated local remote after preservation approval.
  • Default-No/explicit refusal preserves status, time tracking, identity, and local files.
  • Other directory holders remain alive; all conversations' workspaces are preserved.
  • Active launch locks and inspection failures cannot be overridden.
  • JSON, non-interactive, and --yes refusals remain conservative.
  • Locks span the workflow and are released on success or failure; strict cleanup tests continue to pass.

Commands run

CI=true pytest tests/test_complete*.py tests/test_clone_lifecycle.py tests/test_session_worktree.py tests/test_worktree_command.py tests/test_agent_factory.py tests/test_open_command.py tests/test_daf_workflow_skill.py -q
419 passed (local Python 3.14.10)

mypy devflow/
Success: no issues found in 213 source files

ruff check --select E9,F63,F7,F82 devflow/cli/commands/complete_command.py devflow/utils/clone_lifecycle.py tests/test_clone_lifecycle.py
All checks passed!

ruff check devflow/utils/clone_lifecycle.py
All checks passed!

git diff --check
Passed

The full test matrix and integration suite are left to CI.

Checklist

  • The change is limited to this PR's purpose.
  • Documentation is updated where needed.
  • CHANGELOG.md is updated for notable changes, or no update is needed.
  • Backward compatibility was considered for the public SDK and configuration.
  • New dependencies have compatible licenses, if applicable. No new dependencies.
  • UX contract tests are included when user-visible security behavior changes.

Deployment considerations

  • This code change is ready for deployment on its own.
  • This code change requires the following considerations before being deployed:

No configuration migration or new CLI flag is required. Automatic completion remains conservative; the new preservation approval is interactive only.

🤖 Generated with OpenCode (GPT-6.1 Sol)

Assisted-by: OpenCode

Separate explicit interactive completion from workspace deletion so an
idle terminal or daemon does not force users out of their checkout.
Require default-No confirmation that editing has stopped and preserve
every managed clone/worktree.

Hold lifecycle locks throughout completion, keep lock and inspection
failures non-overridable, and retain strict checks before deletion.
Keep automatic, JSON, and --yes behavior conservative and make
diagnostics backend-neutral.

Validate with 419 focused tests under CI=true and package-wide mypy.

🤖 Generated with [OpenCode (GPT-6.1 Sol)](https://opencode.ai)

Co-Authored-By: OpenCode <noreply@opencode.ai>
@itdove
itdove marked this pull request as ready for review November 18, 2026 03:13
@itdove
itdove merged commit 2f69ed3 into main Nov 18, 2026
11 checks passed
@itdove
itdove deleted the fix-completion-preflight branch November 18, 2026 03:13
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