fix: remove duplicate verify_preflight_purity in gitea_adopt_merger_pr_lease (closes #548) #550

Merged
sysadmin merged 1 commits from issue-548-fix-duplicate-preflight into master 2026-07-08 20:54:40 -05:00
Owner

Summary

Fixes the duplicate verify_preflight_purity call inside gitea_adopt_merger_pr_lease (and the resulting _clear_preflight_capability_state) that was discovered and temporarily worked around during PR #542 / Issue #517 post-merge cleanup by the reconciler.

Closes #548.

Root cause

  • _verify_role_mutation_workspace(...) (added for namespace/worktree binding) internally calls verify_preflight_purity(..., worktree_path=...).
  • The adopt function had a second direct verify_preflight_purity(remote, task=...) immediately after.
  • verify_preflight_purity always ends with _clear_preflight_capability_state(), so capability proofs accumulated from record_preflight_check / prior whoami+resolve were cleared between (or by the duplicate) checks.
  • This forced one-line local patches during otherwise valid merger/reconcile runs.

Fix (minimal)

  • Remove the redundant direct verify_preflight_purity call. The _verify_role... path is the single, correct one (and passes the worktree_path).

Tests

  • Updated TestAdoptTool.setUp and added test_adopt_preserves_preflight_capability_state_no_duplicate_clear.
  • Proves: single invocation of purity check, valid incoming state not cleared unexpectedly by dupe, success without patches/raw fallbacks, MCP-native only.
  • Full relevant suite (merger lease + cleanup proofs + mcp server): 242 passed.
  • git diff --check prgs/master: clean.

See #542, #517, controller record #549, handoff comments on #542 (#7164 etc). Fresh reviewer pass requested.

## Summary Fixes the duplicate `verify_preflight_purity` call inside `gitea_adopt_merger_pr_lease` (and the resulting `_clear_preflight_capability_state`) that was discovered and temporarily worked around during PR #542 / Issue #517 post-merge cleanup by the reconciler. Closes #548. ## Root cause - `_verify_role_mutation_workspace(...)` (added for namespace/worktree binding) internally calls `verify_preflight_purity(..., worktree_path=...)`. - The adopt function had a second direct `verify_preflight_purity(remote, task=...)` immediately after. - `verify_preflight_purity` always ends with `_clear_preflight_capability_state()`, so capability proofs accumulated from `record_preflight_check` / prior whoami+resolve were cleared between (or by the duplicate) checks. - This forced one-line local patches during otherwise valid merger/reconcile runs. ## Fix (minimal) - Remove the redundant direct `verify_preflight_purity` call. The `_verify_role...` path is the single, correct one (and passes the worktree_path). ## Tests - Updated `TestAdoptTool.setUp` and added `test_adopt_preserves_preflight_capability_state_no_duplicate_clear`. - Proves: single invocation of purity check, valid incoming state not cleared unexpectedly by dupe, success without patches/raw fallbacks, MCP-native only. - Full relevant suite (merger lease + cleanup proofs + mcp server): 242 passed. - `git diff --check prgs/master`: clean. See #542, #517, controller record #549, handoff comments on #542 (#7164 etc). Fresh reviewer pass requested.
jcwalker3 added 1 commit 2026-07-08 14:05:06 -05:00
The second direct call after _verify_role_mutation_workspace caused
_clear_preflight_capability_state() to run twice (or between checks),
clearing valid capability/preflight state. This forced temp local
patches during #542/#517 merge/reconcile.

- Remove the redundant verify call (the _verify already performs
  purity verification with correct worktree_path).
- Update test to reflect single invocation path and add explicit
  test proving state preservation, single call, no dupe clear,
  and no need for raw/temp fallbacks.
- Reconciler/controller flows stay fully MCP-native.

Fixes #548
Owner

repo: Scaled-Tech-Consulting/Gitea-Tools
pr: #550
issue: none
reviewer_identity: sysadmin
profile: prgs-reviewer
session_id: 99504-f3d005731a2b
worktree: /Users/jasonwalker/Development/Gitea-Tools/branches/review-pr550
phase: claimed
candidate_head: a4e014e62b
target_branch: master
target_branch_sha: none
last_activity: 2026-07-08T19:08:58Z
expires_at: 2026-07-08T21:08:58Z
blocker: none

<!-- mcp-review-lease:v1 --> repo: Scaled-Tech-Consulting/Gitea-Tools pr: #550 issue: none reviewer_identity: sysadmin profile: prgs-reviewer session_id: 99504-f3d005731a2b worktree: /Users/jasonwalker/Development/Gitea-Tools/branches/review-pr550 phase: claimed candidate_head: a4e014e62b0a424c88b0cbf9111d9c5f81273672 target_branch: master target_branch_sha: none last_activity: 2026-07-08T19:08:58Z expires_at: 2026-07-08T21:08:58Z blocker: none
Owner

Reconciler Audit & Status Update — PR #550

📝 Review & Deadlock Context

  • PR #550 was audited and verified as code-complete and clean.
  • However, the live APPROVED review submission failed and remains blocked due to the known Issue #546 preflight capability/lease deadlock.
  • Lease Audit: The reviewer lease comment #7200 (session ID: 99504-f3d005731a2b) remains active/orphaned on this open PR. Release is blocked because no canonical MCP tool exists to release reviewer leases on open PRs (capability limit).

🧪 Validation Details & Wording Correction

  • Previous Session Validation Wording Correction: The full test suite was described in some contexts as a clean pass; however, it contained pre-existing master failures. The actual validation results for the head branch are 1947 passed, 2 known/pre-existing failures (which are pre-existing environmental failures present on master).
  • PR Code Health: The code changes are verified as functionally correct and clean of trailing whitespaces.

🗳️ Merge Eligibility Status

  • Merge Eligibility: No merge eligibility exists at this time. Merge operations are strictly blocked until a clean, non-bypass canonical review approval is successfully submitted at the current head SHA.
## Reconciler Audit & Status Update — PR #550 ### 📝 Review & Deadlock Context - PR #550 was audited and verified as code-complete and clean. - However, the live `APPROVED` review submission failed and remains blocked due to the known **Issue #546 preflight capability/lease deadlock**. - **Lease Audit:** The reviewer lease comment #7200 (session ID: `99504-f3d005731a2b`) remains **active/orphaned** on this open PR. Release is blocked because no canonical MCP tool exists to release reviewer leases on open PRs (capability limit). ### 🧪 Validation Details & Wording Correction - **Previous Session Validation Wording Correction:** The full test suite was described in some contexts as a clean pass; however, it contained pre-existing master failures. The actual validation results for the head branch are **1947 passed, 2 known/pre-existing failures** (which are pre-existing environmental failures present on master). - **PR Code Health:** The code changes are verified as functionally correct and clean of trailing whitespaces. ### 🗳️ Merge Eligibility Status - **Merge Eligibility:** **No merge eligibility exists** at this time. Merge operations are strictly blocked until a clean, non-bypass canonical review approval is successfully submitted at the current head SHA.
Owner

repo: Scaled-Tech-Consulting/Gitea-Tools
pr: #550
issue: #548
reviewer_identity: sysadmin
profile: prgs-reviewer
session_id: 99504-f3d005731a2b
worktree: /Users/jasonwalker/Development/Gitea-Tools/branches/review-pr550
phase: claimed
candidate_head: a4e014e62b
target_branch: master
target_branch_sha: none
last_activity: 2026-07-08T19:38:19Z
expires_at: 2026-07-08T21:38:19Z
blocker: none

<!-- mcp-review-lease:v1 --> repo: Scaled-Tech-Consulting/Gitea-Tools pr: #550 issue: #548 reviewer_identity: sysadmin profile: prgs-reviewer session_id: 99504-f3d005731a2b worktree: /Users/jasonwalker/Development/Gitea-Tools/branches/review-pr550 phase: claimed candidate_head: a4e014e62b0a424c88b0cbf9111d9c5f81273672 target_branch: master target_branch_sha: none last_activity: 2026-07-08T19:38:19Z expires_at: 2026-07-08T21:38:19Z blocker: none
Owner

repo: Scaled-Tech-Consulting/Gitea-Tools
pr: #550
issue: #548
reviewer_identity: sysadmin
profile: prgs-reviewer
session_id: 99504-f3d005731a2b
worktree: /Users/jasonwalker/Development/Gitea-Tools/branches/review-pr550
phase: claimed
candidate_head: a4e014e62b
target_branch: master
target_branch_sha: none
last_activity: 2026-07-08T19:57:08Z
expires_at: 2026-07-08T21:57:08Z
blocker: none

<!-- mcp-review-lease:v1 --> repo: Scaled-Tech-Consulting/Gitea-Tools pr: #550 issue: #548 reviewer_identity: sysadmin profile: prgs-reviewer session_id: 99504-f3d005731a2b worktree: /Users/jasonwalker/Development/Gitea-Tools/branches/review-pr550 phase: claimed candidate_head: a4e014e62b0a424c88b0cbf9111d9c5f81273672 target_branch: master target_branch_sha: none last_activity: 2026-07-08T19:57:08Z expires_at: 2026-07-08T21:57:08Z blocker: none
Owner

repo: Scaled-Tech-Consulting/Gitea-Tools
pr: #550
issue: none
reviewer_identity: sysadmin
profile: prgs-reviewer
session_id: 99504-f3d005731a2b
worktree: /Users/jasonwalker/Development/Gitea-Tools/branches/review-pr550
phase: claimed
candidate_head: a4e014e62b
target_branch: master
target_branch_sha: none
last_activity: 2026-07-08T20:14:20Z
expires_at: 2026-07-08T22:14:20Z
blocker: none

<!-- mcp-review-lease:v1 --> repo: Scaled-Tech-Consulting/Gitea-Tools pr: #550 issue: none reviewer_identity: sysadmin profile: prgs-reviewer session_id: 99504-f3d005731a2b worktree: /Users/jasonwalker/Development/Gitea-Tools/branches/review-pr550 phase: claimed candidate_head: a4e014e62b0a424c88b0cbf9111d9c5f81273672 target_branch: master target_branch_sha: none last_activity: 2026-07-08T20:14:20Z expires_at: 2026-07-08T22:14:20Z blocker: none
Owner

repo: Scaled-Tech-Consulting/Gitea-Tools
pr: #550
issue: none
reviewer_identity: sysadmin
profile: prgs-reviewer
session_id: 99504-f3d005731a2b
worktree: /Users/jasonwalker/Development/Gitea-Tools/branches/review-pr550
phase: released
candidate_head: a4e014e62b
target_branch: master
target_branch_sha: none
last_activity: 2026-07-08T20:14:34Z
expires_at: 2026-07-08T22:14:34Z
blocker: manual-release

<!-- mcp-review-lease:v1 --> repo: Scaled-Tech-Consulting/Gitea-Tools pr: #550 issue: none reviewer_identity: sysadmin profile: prgs-reviewer session_id: 99504-f3d005731a2b worktree: /Users/jasonwalker/Development/Gitea-Tools/branches/review-pr550 phase: released candidate_head: a4e014e62b0a424c88b0cbf9111d9c5f81273672 target_branch: master target_branch_sha: none last_activity: 2026-07-08T20:14:34Z expires_at: 2026-07-08T22:14:34Z blocker: manual-release
Owner

repo: Scaled-Tech-Consulting/Gitea-Tools
pr: #550
issue: none
reviewer_identity: sysadmin
profile: prgs-reviewer
session_id: 99504-f3d005731a2b
worktree: /Users/jasonwalker/Development/Gitea-Tools/branches/review-pr550
phase: claimed
candidate_head: a4e014e62b
target_branch: master
target_branch_sha: none
last_activity: 2026-07-08T20:15:53Z
expires_at: 2026-07-08T22:15:53Z
blocker: none

<!-- mcp-review-lease:v1 --> repo: Scaled-Tech-Consulting/Gitea-Tools pr: #550 issue: none reviewer_identity: sysadmin profile: prgs-reviewer session_id: 99504-f3d005731a2b worktree: /Users/jasonwalker/Development/Gitea-Tools/branches/review-pr550 phase: claimed candidate_head: a4e014e62b0a424c88b0cbf9111d9c5f81273672 target_branch: master target_branch_sha: none last_activity: 2026-07-08T20:15:53Z expires_at: 2026-07-08T22:15:53Z blocker: none
sysadmin approved these changes 2026-07-08 15:16:17 -05:00
Dismissed
sysadmin left a comment
Owner

APPROVED

APPROVED
Owner

repo: Scaled-Tech-Consulting/Gitea-Tools
pr: #550
issue: #548
reviewer_identity: sysadmin
profile: prgs-reviewer
session_id: 13040-53c1ba160f8a
worktree: /Users/jasonwalker/Development/Gitea-Tools/branches/review-pr550-fresh
phase: claimed
candidate_head: a4e014e62b
target_branch: master
target_branch_sha: 78fce0dbb6
last_activity: 2026-07-09T01:44:07Z
expires_at: 2026-07-09T03:44:07Z
blocker: none

<!-- mcp-review-lease:v1 --> repo: Scaled-Tech-Consulting/Gitea-Tools pr: #550 issue: #548 reviewer_identity: sysadmin profile: prgs-reviewer session_id: 13040-53c1ba160f8a worktree: /Users/jasonwalker/Development/Gitea-Tools/branches/review-pr550-fresh phase: claimed candidate_head: a4e014e62b0a424c88b0cbf9111d9c5f81273672 target_branch: master target_branch_sha: 78fce0dbb650a6760b4751346ec7b4c3ff4b21f1 last_activity: 2026-07-09T01:44:07Z expires_at: 2026-07-09T03:44:07Z blocker: none
sysadmin approved these changes 2026-07-08 20:44:32 -05:00
sysadmin left a comment
Owner

Review PR #550 / Issue #548

Verdict: APPROVE

Scope

  • Minimal one-line removal of duplicate verify_preflight_purity in gitea_adopt_merger_pr_lease
  • Test update + regression proving single purity invocation via _verify_role_mutation_workspace
  • Files: gitea_mcp_server.py, tests/test_merger_lease_adoption.py only

Correctness

  • Confirmed _verify_role_mutation_workspace already calls verify_preflight_purity(remote, worktree_path=resolved, task=task)
  • Duplicate direct call was clearing capability state mid-flow (#548)
  • Fix matches acceptance criteria; no temp patches/raw fallbacks required

Validation

  • git diff --check prgs/master...HEAD: clean
  • Targeted: tests/test_merger_lease_adoption.py — 10 passed
  • Full suite: 1947 passed, 6 skipped, 2 failed
  • Same 2 failures on clean master baseline 78fce0d (pre-existing/environment):
    • test_verify_preflight_blocks_control_checkout_with_test_porcelain
    • test_pr487_style_merge_binds_clean_merger_workspace

Eligibility / identity

  • Reviewer: sysadmin / prgs-reviewer
  • Author: jcwalker3 (not self-review)
  • Head: a4e014e62b0a424c88b0cbf9111d9c5f81273672
  • Base: master; mergeable: true

No REQUEST_CHANGES findings.

Next: merger session may merge after formal approval is visible at this head.

## Review PR #550 / Issue #548 **Verdict: APPROVE** ### Scope - Minimal one-line removal of duplicate `verify_preflight_purity` in `gitea_adopt_merger_pr_lease` - Test update + regression proving single purity invocation via `_verify_role_mutation_workspace` - Files: `gitea_mcp_server.py`, `tests/test_merger_lease_adoption.py` only ### Correctness - Confirmed `_verify_role_mutation_workspace` already calls `verify_preflight_purity(remote, worktree_path=resolved, task=task)` - Duplicate direct call was clearing capability state mid-flow (#548) - Fix matches acceptance criteria; no temp patches/raw fallbacks required ### Validation - `git diff --check prgs/master...HEAD`: clean - Targeted: `tests/test_merger_lease_adoption.py` — 10 passed - Full suite: **1947 passed, 6 skipped, 2 failed** - Same 2 failures on clean master baseline `78fce0d` (pre-existing/environment): - `test_verify_preflight_blocks_control_checkout_with_test_porcelain` - `test_pr487_style_merge_binds_clean_merger_workspace` ### Eligibility / identity - Reviewer: `sysadmin` / `prgs-reviewer` - Author: `jcwalker3` (not self-review) - Head: `a4e014e62b0a424c88b0cbf9111d9c5f81273672` - Base: master; mergeable: true No REQUEST_CHANGES findings. **Next:** merger session may merge after formal approval is visible at this head.
Owner

repo: Scaled-Tech-Consulting/Gitea-Tools
pr: #550
issue: #548
reviewer_identity: sysadmin
profile: prgs-reviewer
session_id: 13040-53c1ba160f8a
worktree: /Users/jasonwalker/Development/Gitea-Tools/branches/review-pr550-lease-reconcile-215322
phase: claimed
candidate_head: a4e014e62b
target_branch: master
target_branch_sha: 78fce0dbb6
last_activity: 2026-07-09T01:54:26Z
expires_at: 2026-07-09T03:54:26Z
blocker: none

<!-- mcp-review-lease:v1 --> repo: Scaled-Tech-Consulting/Gitea-Tools pr: #550 issue: #548 reviewer_identity: sysadmin profile: prgs-reviewer session_id: 13040-53c1ba160f8a worktree: /Users/jasonwalker/Development/Gitea-Tools/branches/review-pr550-lease-reconcile-215322 phase: claimed candidate_head: a4e014e62b0a424c88b0cbf9111d9c5f81273672 target_branch: master target_branch_sha: 78fce0dbb650a6760b4751346ec7b4c3ff4b21f1 last_activity: 2026-07-09T01:54:26Z expires_at: 2026-07-09T03:54:26Z blocker: none
Owner

adopted_at: 2026-07-09T01:54:28Z
adopted_by_identity: sysadmin
adopted_by_profile: prgs-merger
adopted_from_session_id: 13040-53c1ba160f8a
adopted_from_profile: prgs-reviewer
adopted_from_reviewer_identity: sysadmin
adopted_from_comment_id: 7309
adoption_reason: merger-handoff-approved-head

repo: Scaled-Tech-Consulting/Gitea-Tools
pr: #550
issue: #548
reviewer_identity: sysadmin
profile: prgs-merger
session_id: 33810-53d3541f8480
worktree: /Users/jasonwalker/Development/Gitea-Tools/branches/merge-pr550
phase: adopted
candidate_head: a4e014e62b
target_branch: master
target_branch_sha: 78fce0dbb6
last_activity: 2026-07-09T01:54:28Z
expires_at: 2026-07-09T03:54:28Z
blocker: none

<!-- mcp-review-lease-adoption:v1 --> adopted_at: 2026-07-09T01:54:28Z adopted_by_identity: sysadmin adopted_by_profile: prgs-merger adopted_from_session_id: 13040-53c1ba160f8a adopted_from_profile: prgs-reviewer adopted_from_reviewer_identity: sysadmin adopted_from_comment_id: 7309 adoption_reason: merger-handoff-approved-head <!-- mcp-review-lease:v1 --> repo: Scaled-Tech-Consulting/Gitea-Tools pr: #550 issue: #548 reviewer_identity: sysadmin profile: prgs-merger session_id: 33810-53d3541f8480 worktree: /Users/jasonwalker/Development/Gitea-Tools/branches/merge-pr550 phase: adopted candidate_head: a4e014e62b0a424c88b0cbf9111d9c5f81273672 target_branch: master target_branch_sha: 78fce0dbb650a6760b4751346ec7b4c3ff4b21f1 last_activity: 2026-07-09T01:54:28Z expires_at: 2026-07-09T03:54:28Z blocker: none
sysadmin merged commit 18e7d7b6e1 into master 2026-07-08 20:54:40 -05:00
Sign in to join this conversation.
No Reviewers
No labels
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

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