fix(workflow): retire status:pr-open on every terminal PR transition (Closes #780) #782
Merged
sysadmin
merged 1 commits from 2026-07-21 15:14:21 -05:00
fix/issue-780-terminal-pr-open-label-cleanup into master
Labels
Clear labels
allocator
anti-stomp
architecture
bug
chore
codex
concurrency
contamination
control-plane
dashboard
database
design
documentation
enhancement
gitea
glitchtip
important
incident
incident-bridge
integration
jenkins
labels
leases
mcp
mcp-health
mcp-menu
multi-project
mutating
nice-to-have
observability
portability
preflight
protected-branch
queue
read-only
reconnect
recovery
refactor
release
reliability
resumable-review
reviewer
roadmap
safety
security
self-hosted
sentry
stale-runtime
status:blocked
status:in-progress
status:pr-open
status:ready
terminal-lock
testing
tracker
type:bug
type:feature
type:feature
type:guardrail
visibility
workflow
workflow-hardening
workflow-hardening
Controller-owned work allocator
Prevent concurrent LLM session stomping
Architecture / structural design
OpenAI Codex client / workflow session surface
Concurrent session safety
Workflow or session contamination incident
MCP control-plane coordination and allocation authority
MCP operational dashboard/queue view
Internal coordination storage (SQLite/Postgres)
Design / investigation, no implementation
Docs / runbooks
New feature or improvement
Gitea MCP workflow
GlitchTip integration
Operational or process incident requiring durable audit trail
Sentry-to-Gitea incident bridging
Integration testing
Jenkins integration
Label taxonomy management
Lease adopt/release/expire lifecycle
MCP server / tooling
MCP namespace and runtime health
MCP menu surface
Work spanning multiple monitoring projects or Gitea repos
Mutating action; requires gating
Observability, metrics, traces, error reporting
Cross-platform / portability
Shared preflight gates before mutation
Protected branch / stable-branch policy concern
Work queue visibility and allocation
Read-only, no mutation
MCP client reconnect/reload recovery path
Recovery paths for stale/foreign leases
Code refactor / restructure
Release / versioning
Reliability / failure handling
Persist and resume prepared review verdicts across sessions
Reviewer workflow tooling
Roadmap / umbrella issue
Safety rails and fail-closed mutation guards
Security / trust boundary
Self-hosted infrastructure integration
Sentry error monitoring integration
Stale backend daemon / runtime-vs-master parity failures
Issue is blocked
Issue is being worked on
Issue has an open pull request
Issue is ready for work
Terminal review lock (#332) path
Tests / test coverage
Issue tracker hygiene / meta
Bug or defect
Feature or enhancement
Feature or enhancement
Safety gate or guardrail
Workflow state visibility for LLMs/operators
Cross-tool workflow
LLM workflow coordination hardening
LLM workflow coordination hardening
No labels
Milestone
No items
No Milestone
Projects
Clear projects
No projects
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: Scaled-Tech-Consulting/Gitea-Tools#782
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Closes #780
Problem
status:pr-openwas applied bygitea_create_prand never removed again. Everyterminal path finished without touching it, so a repository-wide audit found 40
closed issues still advertising a pull request that had long since merged or
closed.
Fix
terminal_pr_label_cleanup.pyis the single authoritative rule. Everysanctioned terminal path now routes through it, so the paths cannot drift:
mergedgitea_merge_prclosed_without_mergegitea_edit_prclosing the PRsupersededgitea_reconcile_superseded_by_merged_pralready_landedgitea_reconcile_already_landed_prcontroller_closuregitea_close_issueretry_recoverygitea_cleanup_terminal_pr_labelsThe rule removes only
status:pr-open, preserves every other label verbatim,allows an empty resulting set when it was the issue's only label, is a no-op
when the label is absent (so retries are harmless), and confirms the outcome by
read-after-write instead of assumption.
Controller closure runs the cleanup before the state change and fails
closed if it cannot be completed and verified — closing first would bake in the
stale label with no later step to catch it. Post-merge cleanup never blocks the
merge, which already happened; failures are reported with a
safe_next_action.Also
gitea_assess_terminal_label_hygiene: read-only terminal validation thatreports any residual
status:pr-open, exempting issues that have a genuinelyopen PR.
_put_issue_label_namesnow accepts Gitea's empty response body when therequested set is empty, so clearing the last label works.
test_audit's close_issue fixture keys on the request instead of call order,since closing now also reads labels for the cleanup and its read-back.
Docs
docs/label-taxonomy.mdterminal-transition section, a runbook pointer, and theterminal-label requirements in the review-merge and reconcile-landed
final-report schemas.
Tests
New
tests/test_terminal_pr_label_cleanup.py(35 tests) covers merge,close-without-merge, supersession, already-landed reconciliation, controller
closure, retry/idempotency, preservation of every other label, the only-label
empty set, read-after-write verification, failure reporting, and a regression
that reproduces the observed leak across all five terminal paths at once.
ed0e8c8: 4045 passed, 11 failed, 6 skipped.df31674baseline: 4010 passed, 11 failed, 6 skipped.test_commit_payloadsx6,test_issue_702_review_findings_f1_f6x2,test_mcp_serverpreflight,test_post_merge_moot_lease,test_reconciler_supersession_close) —pre-existing on master, not introduced here.
LLM Handoff Metadata
ed0e8c82dePR and holds no merge authority.
repo: Scaled-Tech-Consulting/Gitea-Tools
pr: #782
issue: #780
reviewer_identity: sysadmin
profile: prgs-reviewer
session_id: 40811-838360dac52c
worktree: /Users/jasonwalker/Development/Gitea-Tools/branches/review-fix-issue-780-terminal-pr-open-label-cleanup
phase: claimed
candidate_head:
ed0e8c82detarget_branch: master
target_branch_sha:
df3167488clast_activity: 2026-07-21T20:01:09Z
expires_at: 2026-07-21T20:11:09Z
blocker: none
repo: Scaled-Tech-Consulting/Gitea-Tools
pr: #782
issue: #780
reviewer_identity: sysadmin
profile: prgs-reviewer
session_id: 40811-838360dac52c
worktree: /Users/jasonwalker/Development/Gitea-Tools/branches/review-fix-issue-780-terminal-pr-open-label-cleanup
phase: validated
candidate_head:
ed0e8c82detarget_branch: master
target_branch_sha:
df3167488clast_activity: 2026-07-21T20:02:04Z
expires_at: 2026-07-21T20:12:04Z
blocker: none
Canonical PR State
STATE: approved
WHO_IS_NEXT: merger
NEXT_ACTION: Merge PR #782 at exact head
ed0e8c82deafter fresh live recheck and lease adoption; do not re-review unless head moves.NEXT_PROMPT:
WHAT_HAPPENED: Independent reviewer sysadmin/prgs-reviewer inspected all 9 changed files and traced every #780 terminal path (merge, close-without-merge, supersession/abandonment, already-landed, controller closure, retry/recovery). One authoritative idempotent cleanup rule; only status:pr-open removed; empty label set supported; controller fails closed before state change; merge-path cleanup failure does not block merge and emits safe_next_action. New assess/recovery tools have correct permissions, preflight, audit, and read-after-write. _put_issue_label_names empty-body fix is scoped and safe.
WHY: Acceptance criteria for #780 are met; tests pass; no blocking findings; reviewer independent of author jcwalker3.
ISSUE: #780
HEAD_SHA:
ed0e8c82deREVIEW_STATUS: approved / approval_at_current_head
MERGE_READY: true
BLOCKERS: none
VALIDATION: focused tests/test_terminal_pr_label_cleanup.py 35 passed; broader related suite 162 passed with 1 pre-existing baseline failure test_reconciler_supersession_close; documented full-suite baseline master 4010p/11f/6s vs branch 4045p/11f/6s with identical 11 failures accepted
NATIVE_REVIEW_PROOF: transport=native_mcp; entrypoint=mcp_server; token_fingerprint=ff677c50d33000dc
LAST_UPDATED_BY: sysadmin / prgs-reviewer
Review findings
Files reviewed: terminal_pr_label_cleanup.py; gitea_mcp_server.py (clear_pr_open_label, merge, edit_pr close, already-landed, supersession, close_issue, recovery/assess tools, empty PUT body); task_capability_map.py; tests/test_terminal_pr_label_cleanup.py; tests/test_audit.py; docs/label-taxonomy.md; docs/llm-workflow-runbooks.md; schemas review-merge and reconcile-landed.
Lease session: 40811-838360dac52c
Worktree: branches/review-fix-issue-780-terminal-pr-open-label-cleanup (clean; HEAD matches pinned head)
Namespace: gitea-reviewer only; healthy; master parity in parity at
df3167488cReview Metadata
repo: Scaled-Tech-Consulting/Gitea-Tools
pr: #782
issue: #780
reviewer_identity: sysadmin
profile: prgs-merger
session_id: 48296-08f4a3cd6b63
worktree: branches/merge-pr-782
phase: claimed
candidate_head:
ed0e8c82detarget_branch: master
target_branch_sha:
df3167488clast_activity: 2026-07-21T20:13:43Z
expires_at: 2026-07-21T20:23:43Z
blocker: none
Stale #332 review-decision lock cleanup (#594)
Status: APPLIED
sysadminprgs-merger2026-07-21T20:14:22.649482+00:00approveon PR fix(workflow): retire status:pr-open on every terminal PR transition (Closes #780) (#782)closed(merged=True)8e149e6cfa3557e4642a3ac72c971460adbc30371prgs-reviewerManual deletion of session-state files is not the workflow.
This path only clears a lock when the referenced PR is merged/closed.