fix(gate): stop classifying stale-runtime blocks as permission denials (Closes #897) #901
Merged
sysadmin
merged 2 commits from 2026-07-25 06:56:16 -05:00
fix/issue-897-permission-stale-runtime-classification 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#901
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.
Summary
Closes #897.
Stale-runtime and runtime-mode mutation refusals were returned as permission denials:
permission_reportnamed a permission the active profile already held and recommendedgitea_activate_profile/ session switch. That diagnosis is wrong and the recovery is hazardous (#685 reconnect-only; #690/#714 no mid-session role switch).Changes
_build_operation_gate_refusal:blocker_kind=runtime_reconnect_requiredfor master parity staleness (parity heads + reconnect-only action; nopermission_report)blocker_kind=runtime_mode_blockedfor stable-control runtime blocks (nopermission_report)blocker_kind=permission_deniedfor true profile denials (permission_reportretained)_profile_operation_gatecollects all refusal classes (no short-circuit)_profile_permission_blockuses the typed builder (covers mark/create/mutation paths)_permission_block_reportfails closed asdiagnostic_defectwhen the active profile already holds the opTests
Role matrix: author / reviewer / merger / reconciler — stale+permitted, fresh+forbidden, stale+forbidden, create_issue regression.
Head
fix/issue-897-permission-stale-runtime-classification6e6ca9433873056c7a84d2a1ef3590323ea5a636branches/issue-897-permission-stale-runtimeCanonical PR state
repo: Scaled-Tech-Consulting/Gitea-Tools
pr: #901
issue: none
reviewer_identity: sysadmin
profile: prgs-reviewer
session_id: 19262-c1d8c36e6171
worktree: branches/issue-897-permission-stale-runtime
phase: claimed
candidate_head: none
target_branch: master
target_branch_sha: none
last_activity: 2026-07-25T06:04:24Z
expires_at: 2026-07-25T06:14:24Z
blocker: none
Canonical PR State
STATE: reviewer-approved
WHO_IS_NEXT: merger
NEXT_ACTION: merge PR 901 at head
6e6ca94338NEXT_PROMPT:
WHAT_HAPPENED: Formal review completed by sysadmin under prgs-reviewer profile. PR #901 correctly addresses #897 by stopping misclassification of stale-runtime and runtime-mode refusals as permission denials.
WHY: All acceptance criteria A-H verified in code and tests. Focused test suite passed cleanly (23 tests).
ISSUE: #897
HEAD_SHA:
6e6ca94338REVIEW_STATUS: APPROVED
MERGE_READY: true
BLOCKERS: none
VALIDATION: pytest tests/test_issue_897_permission_stale_runtime_classification.py tests/test_permission_reports.py (23 passed)
LAST_UPDATED_BY: sysadmin
NATIVE_REVIEW_PROOF: transport=native_mcp; entrypoint=mcp_server; token_fingerprint=4539170d8551c07a
Detailed Review Summary
PR #901 addresses issue #897 by ensuring stale-runtime and runtime-mode refusals are properly classified as system/runtime gate failures rather than profile permission denials.
Key verifications:
blocker_kind=runtime_reconnect_required, runtime-mode refusals useblocker_kind=runtime_mode_blocked, and true profile denials useblocker_kind=permission_denied.permission_report: Stale and runtime-mode refusals do not attachpermission_reportor claim missing permissions that the active profile already holds._permission_block_reportintegrity: Flagsdiagnostic_defect: Truewhen active profile holds operation.stale_runtime_reasonsandpermission_block_reasons.gitea_mcp_server.pyandtests/test_issue_897_permission_stale_runtime_classification.py. All 23 tests pass cleanly.repo: Scaled-Tech-Consulting/Gitea-Tools
pr: #901
issue: none
reviewer_identity: sysadmin
profile: prgs-reviewer
session_id: 19262-c1d8c36e6171
worktree: branches/issue-897-permission-stale-runtime
phase: released
candidate_head: none
target_branch: master
target_branch_sha: none
last_activity: 2026-07-25T06:09:38Z
expires_at: 2026-07-25T06:19:38Z
blocker: manual-release
repo: Scaled-Tech-Consulting/Gitea-Tools
pr: #901
issue: #897
reviewer_identity: sysadmin
profile: prgs-reviewer
session_id: 18549-06adf7e9875e
worktree: /Users/jasonwalker/Development/Gitea-Tools/branches/issue-897-permission-stale-runtime
phase: claimed
candidate_head:
54559aebc3target_branch: master
target_branch_sha:
715863799flast_activity: 2026-07-25T11:52:51Z
expires_at: 2026-07-25T12:02:51Z
blocker: none
Canonical PR State
STATE: reviewer-approved
WHO_IS_NEXT: merger
NEXT_ACTION: merge PR 901 at head
54559aebc3NEXT_PROMPT:
WHAT_HAPPENED: Fresh independent review at the post-sync head
54559aebc3. The former-head verdict (review 588 at6e6ca94338) was treated as superseded and was not reused. The update-by-merge was audited, the full effective diff re-read, the focused suite re-run, the full suite run at this head, and its failure set compared against the current master baseline at715863799f.WHY: The #897 acceptance criteria hold at this exact head, the branch sync introduced no content of its own, and the full-suite failure set is identical to the master baseline.
ISSUE: #897
HEAD_SHA:
54559aebc3BASE_SHA:
715863799fREVIEW_STATUS: APPROVED
MERGE_READY: true
BLOCKERS: none
VALIDATION: focused pytest tests/test_issue_897_permission_stale_runtime_classification.py tests/test_permission_reports.py at
54559aeb-> 23 passed, 12 subtests passed. Full suite at54559aeb-> 23 failed, 5267 passed, 6 skipped, 926 subtests passed. Master baseline at715863799f(separate branches/ worktree) -> 23 failed, 5256 passed, 6 skipped, 914 subtests passed. Failure sets compared line-by-line: identical, zero new failures and zero fixed failures; the delta is exactly the 11 new test methods and 12 new subtests this PR adds. Mutation probes: neutering _reason_is_stale_runtime -> 11 failed / 8 passed; restoring the pre-PR short-circuit in _profile_operation_gate -> 1 failed. Live gate probe on gitea_acquire_merger_pr_lease: stale daemon -> blocker_kind=runtime_reconnect_required with no permission_report; runtime-mode block -> blocker_kind=runtime_mode_blocked with no permission_report; profile forbidding gitea.pr.merge -> permission_report with missing_permission=gitea.pr.merge and diagnostic_defect=false.LAST_UPDATED_BY: sysadmin
NATIVE_REVIEW_PROOF: transport=native_mcp; entrypoint=mcp_server; token_fingerprint=3f9d215f6de35cd6
Sync audit (new head)
The head advanced by a merge commit only, with no history rewrite:
54559aebparents are exactly6e6ca943(prior head, first parent) and715863799f(live base).merge-base --is-ancestor 715863799f 54559aebsucceeds, so the branch contains current base;commits_behind=0,mergeable=true,has_conflicts=false.7c47ece670a955fa156a0ab31312250d5aa3ca16, byte-identical togit merge-tree --write-tree 6e6ca943 715863799f. The sync therefore carries no conflict-resolution edits and no content of its own.gitea_mcp_server.pyandtests/test_issue_897_permission_stale_runtime_classification.py(+749 / -70). Scope matches issue #897; no unrelated files.Verification of the #897 fix at this head
_build_operation_gate_refusalemitsblocker_kind=runtime_reconnect_requiredfor parity staleness (withstartup_head/current_head/live_remote_head/live_staleand reconnect-only recovery),runtime_mode_blockedfor stable-control runtime blocks, andpermission_deniedfor genuine profile denials. Verified by live probe against the tool boundary, not only by unit test.permission_report. Mixed causes are separated intostale_runtime_reasons/runtime_mode_reasonsandpermission_block_reasons, with the full partition undergate_reason_classes.master_parity_gate.parity_block_reasonsemits the local-stale text ("started at commit … workspace master is now …; restart the server to load the current capability gates"), the live-stale text ("the daemon is stale relative to live master -- restart/reconnect before mutating"), and the fallback ("server code is stale relative to master (fail closed)") — all classify as stale.stable_control_runtime.assess_runtime_mutation_gateemits unknown-mode, dev-test, dev-worktree-launch, dirty-stable, and alignment texts — all classify as runtime-mode. The two non-blocking parity texts ("startup commit was not captured", "current workspace HEAD could not be read") are unreachable through the gate becauseparity_block_reasonsreturns reasons only whenstaleorlive_staleis set._permission_block_reportintegrity. When the active profile already holds the operation it returnsmissing_permission=None,diagnostic_defect=True,different_mcp_namespace_required=False, and advice that explicitly forbidsgitea_activate_profile/ role-session switching. A true denial still reports the missing permission withdiagnostic_defect=False._profile_operation_gateno longer short-circuits; it accumulates parity, runtime-mode, and permission reasons so typed consumers can separate causes, while boolean callers still see a non-empty list.Non-blocking observations (no change requested)
gitea_acquire_merger_pr_leasewas not converted. Thegitea.pr.mergegate (aroundgitea_mcp_server.py:14867) still returns the legacy dict with an unconditionalpermission_reportand noblocker_kind, while thegitea.readandgitea.pr.commentgates in the same function were converted. Probed rather than assumed: this path cannot be reached while stale or runtime-mode-blocked, because the precedinggitea.pr.commentgate trips first on those causes and is typed. It is reachable only on a true permission denial, where the legacy payload is semantically correct; the only loss is theblocker_kind/gate_reason_classeslabels. No hazardous recovery advice is emitted, so this does not block the merge._reason_is_runtime_modetests for the substringreproof, butassess_namespace_reproofemits "has not been re-proven since the transport flap …". That text would fall intootherand be labelledpermission_denied. Currently unreachable:_runtime_mode_blockcallsruntime_block_reasons(report)without anamespace, so the re-proof branch never contributes reasons on this path. If a future caller passesnamespace, the label would be wrong (though_permission_block_reportwould still mark itdiagnostic_defectrather than fabricate a missing permission).test_stale_plus_forbidden_op_both_causes_separatedpatches_profile_operation_gateitself, so it asserts the builder rather than the real accumulation. Restoring the pre-PR short-circuit under mutation left that test green and failed onlytest_runtime_mode_block_no_permission_report. A test that lets the real gate run with both a stale parity block and a forbidden operation would close this.Independence and gates
Reviewer identity
sysadminunderprgs-reviewer; PR author isjcwalker3, so no self-review. Reviewer namespace parity was green (in_parity=true,mutation_safe=true, startup head715863799f) both before and after the author phase. Branch protection requires no status checks formaster(checks_status=not_required,checks_enabled=false). No unresolved change-requests exist on this PR: the only prior review is 588, an approval at a former head, now correctly reportedstale=truewithapproval_at_current_head=false.adopted_at: 2026-07-25T11:55:56Z
adopted_by_identity: sysadmin
adopted_by_profile: prgs-merger
adopted_from_session_id: 18549-06adf7e9875e
adopted_from_profile: prgs-reviewer
adopted_from_reviewer_identity: sysadmin
adopted_from_comment_id: 16641
adoption_reason: merger-handoff-approved-head
repo: Scaled-Tech-Consulting/Gitea-Tools
pr: #901
issue: #897
reviewer_identity: sysadmin
profile: prgs-merger
session_id: 18556-15564104d8f4
worktree: /Users/jasonwalker/Development/Gitea-Tools/branches/issue-897-permission-stale-runtime
phase: adopted
candidate_head:
54559aebc3target_branch: master
target_branch_sha:
715863799flast_activity: 2026-07-25T11:55:56Z
expires_at: 2026-07-25T12:05:56Z
blocker: none