Reviewer workflows must prove worktree ownership before reset or validation #312

Closed
opened 2026-07-07 01:08:52 -05:00 by jcwalker3 · 1 comment
Owner

A reviewer workflow merged PR #279 successfully, but it reused a branch-named worktree and ran git reset --hard FETCH_HEAD before validation.

Observed behavior:

  • Review worktree path: /Users/jasonwalker/Development/Gitea-Tools/branches/docs-issue-260-forbid-commit-fallbacks
  • The path appears to be the PR branch worktree, not a session-owned reviewer worktree.
  • The workflow ran git reset --hard FETCH_HEAD.
  • The workflow reported this as a worktree mutation.
  • The merge succeeded, but the workflow did not clearly prove the reused worktree was session-owned or safe to reset.

Problem:

Reviewers should not destructively reset arbitrary or author-owned worktrees. A git reset --hard is safe only in a fresh session-owned review worktree or when explicit safe-reuse proof exists.

Required behavior:

  1. Reviewer validation must prefer a fresh session-owned review worktree under branches/, such as:
    branches/review-pr<PR_NUMBER>-<branch-name>

  2. If reusing an existing worktree, the workflow must prove:

    • exact worktree path
    • worktree is inside branches/
    • worktree is not the main checkout
    • worktree is not owned by another active task/session
    • worktree has no uncommitted changes
    • worktree has no untracked files that would be lost
    • worktree branch/head before reset
    • reset target SHA
    • explicit project policy allowing reuse/reset
  3. git reset --hard, checkout, clean, or destructive commands must be forbidden unless the worktree is session-owned or safe-reuse proof passes.

  4. Final reports must distinguish:

    • file edits by reviewer
    • worktree mutations
    • destructive reset operations
    • cleanup operations

Acceptance criteria:

  • Fresh session-owned review worktrees pass.
  • Reused worktrees require safe-reuse proof.
  • Destructive reset in an unproven worktree fails.
  • Final-report validation rejects Workspace mutations: none when git reset --hard occurred.
  • Tests cover fresh review worktree, reused clean worktree, reused dirty worktree, untracked files, and destructive reset.
A reviewer workflow merged PR #279 successfully, but it reused a branch-named worktree and ran `git reset --hard FETCH_HEAD` before validation. Observed behavior: * Review worktree path: `/Users/jasonwalker/Development/Gitea-Tools/branches/docs-issue-260-forbid-commit-fallbacks` * The path appears to be the PR branch worktree, not a session-owned reviewer worktree. * The workflow ran `git reset --hard FETCH_HEAD`. * The workflow reported this as a worktree mutation. * The merge succeeded, but the workflow did not clearly prove the reused worktree was session-owned or safe to reset. Problem: Reviewers should not destructively reset arbitrary or author-owned worktrees. A `git reset --hard` is safe only in a fresh session-owned review worktree or when explicit safe-reuse proof exists. Required behavior: 1. Reviewer validation must prefer a fresh session-owned review worktree under `branches/`, such as: `branches/review-pr<PR_NUMBER>-<branch-name>` 2. If reusing an existing worktree, the workflow must prove: * exact worktree path * worktree is inside `branches/` * worktree is not the main checkout * worktree is not owned by another active task/session * worktree has no uncommitted changes * worktree has no untracked files that would be lost * worktree branch/head before reset * reset target SHA * explicit project policy allowing reuse/reset 3. `git reset --hard`, checkout, clean, or destructive commands must be forbidden unless the worktree is session-owned or safe-reuse proof passes. 4. Final reports must distinguish: * file edits by reviewer * worktree mutations * destructive reset operations * cleanup operations Acceptance criteria: * Fresh session-owned review worktrees pass. * Reused worktrees require safe-reuse proof. * Destructive reset in an unproven worktree fails. * Final-report validation rejects `Workspace mutations: none` when `git reset --hard` occurred. * Tests cover fresh review worktree, reused clean worktree, reused dirty worktree, untracked files, and destructive reset.
jcwalker3 added the status:in-progress label 2026-07-07 04:26:37 -05:00
Author
Owner

Implementation ready for review — see linked PR.

Adds worktree ownership verifier with tests for fresh session-owned worktrees, safe-reuse proof, dirty/untracked reuse failures, and workspace-none contradictions after git reset --hard.

Implementation ready for review — see linked PR. Adds worktree ownership verifier with tests for fresh session-owned worktrees, safe-reuse proof, dirty/untracked reuse failures, and workspace-none contradictions after `git reset --hard`.
sysadmin removed the status:in-progress label 2026-07-07 08:12:58 -05:00
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Scaled-Tech-Consulting/Gitea-Tools#312