gitea_publish_unpublished_issue_branch fails closed for every caller: its own preflight discards the worktree_path it requires #816
Open
opened 2026-07-22 17:07:02 -05:00 by jcwalker3
·
0 comments
No Branch/Tag Specified
master
fix/issue-790-slice-a-heartbeat-policy
feat/issue-628-autonomous-handoffs-orchestration
feat/issue-634-readonly-system-health-api
feat/issue-638-webui-app-shell-phase1
fix/issue-840-cross-role-queue-allocation
feat/issue-822-atomic-install-authority-kernel
feat/issue-633-console-authz-audit-model
feat/issue-636-inventory-api
fix/issue-815-preflight-worktree-forwarding
feat/issue-812-publish-unpublished-commit
feat/issue-635-project-registry-api
feat/issue-798-worker-registry-schema
feat/issue-610-live-remote-parity
docs/issue-632-web-console-architecture
fix/issue-760-exact-owner-renewal
fix/issue-787-kill-segment-separators
chore/issue-681-preserve-review-session-wip
v1.1.0
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
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#816
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.
Problem statement
gitea_publish_unpublished_issue_branch(#812, landed in PR #814 at99fda93) cannot succeed for any caller. Its preflight resolves the author worktree from the MCP process root instead of from theworktree_pathargument the tool declares as required, so the #618 author-worktree gate blocks it against the stable control checkout before any of the tool's own ownership evidence is read.Live invocation,
gitea-author/prgs-author, parity clean at910b6ed,mutation_safe: true, correct preflight order (gitea_whoami→gitea_resolve_task_capabilitytaskpublish_unpublished_branch,allowed_in_current_session: true):dry_run=truefails identically, so there is no read-only path to the decision either.Root cause
gitea_mcp_server.py:9176:verify_preflight_purityacceptsworktree_path(signature atgitea_mcp_server.py:1342) and passes it to_resolve_namespace_mutation_context(worktree_path). With the argument omitted it resolvesNone→ the process root → the control checkout, and forrole == "author"namespace_workspace_bindingroutes toauthor_mutation_worktree.resolve_durable_author_worktree, which by design refuses a control-checkout fallback and raises.The tool's own
worktree_pathis not consulted untilgitea_mcp_server.py:9180, four lines after the raise. Sibling worktree-scoped author tools forward it —edit_issueat12302, the shared resolver at1804,post_heartbeat's neighbour at17505all passworktree_path=. This call site is the outlier.Fix shape: forward the argument.
Why the test suite did not catch it
tests/test_issue_812_publish_unpublished_commit.pydrives the real tool, but every case runs under pytest and the file sets neitherGITEA_TEST_FORCE_ANTI_STOMPnor anypurity_order_forced()signal.skip_purity_order(gitea_mcp_server.py:1381) is therefore true and the entireif not skip_purity_order:block — which contains the #618 resolution at1417— never executes. The suite exercises the tool's evidence model thoroughly and its preflight not at all.The harness also applies
patch.object(mcp_server, "PROJECT_ROOT", self.repo), so even were the gate live, the synthetic fixture would not reproduce the control-checkout collision that every real caller hits.User and operational impact
#812 exists to break the entry-point-B deadlock: work already committed on a registered worktree, unpublished, where publication is lock-derived under #618 and the lock is withheld until a remote head exists. That deadlock is still live.
Issue #635 is the concrete casualty and is now on its sixth blocked cycle. Its state:
b2f6e9a6dc40e9651ef876f322dd0a68bddebfd8onfeat/issue-635-project-registry-api, tree clean, no remote head;prgs-Scaled-Tech-Consulting-Gitea-Tools-635.jsonnames claimantjcwalker3/prgs-authorand the correct worktree — exactly the ownership record this tool reads;2026-07-22T15:46:17Zwhile recorded pid36856is a livemcp_server.pydaemon, so #601 reclaim (needs a dead pid) and #760 exact-owner renewal (needs a published head) both stay unreachable.Every documented escape from that state routes through this tool.
Required implementation investigation
gitea_mcp_server.gitea_publish_unpublished_issue_branch(9105–9200),verify_preflight_purity(1340–1470),namespace_workspace_binding.resolve_namespace_workspace(60–120),author_mutation_worktree.resolve_durable_author_worktree(535+),tests/test_issue_812_publish_unpublished_commit.py.Confirm no other
verify_preflight_puritycall site in a worktree-scoped mutation tool has the same omission —close_pr(8792),edit_pr(8794),commit_files(9056),delete_branch(10409),close_issue(12155) all pass noworktree_pathand should each be classified as correct-by-lock-derivation or defective, rather than assumed.Proposed direction
worktree_pathat9176.worktree_paththat is a registered non-control worktree, asserting the call is not blocked by #618. This is the assertion whose absence let the defect ship.Security and workflow-safety requirements
Forwarding a caller-supplied path must not weaken #618. The explicit-
worktree_pathbranch already validates registration and membership against the canonical root; the argument becomes a candidate, not a bypass. The lock file stays the sole source of ownership, and #812 AC23/AC24 hold — no lease renewal, reclaim, or clearing, and no consultation of the recorded owner pid's liveness.Acceptance criteria
gitea_publish_unpublished_issue_branchcompletes preflight when called with a valid registeredworktree_pathfrom a control-checkout process root.dry_run=truereturns its decision and evidence rather than raising.Required tests
Extend
tests/test_issue_812_publish_unpublished_commit.pywith a purity-order-enforced class; re-run the existing #812 suite unchanged; run the affected lock/worktree/preflight suites.Observability and audit requirements
The block surfaces as
internal_errorwithexception_class: builtins.RuntimeError, which reads as a server fault rather than a gate decision. Prefer a typedpreconditionrefusal carryingblocker_kindandexact_safe_next_actionif that can be done without broadening the gate.Dependencies and linkage
99fda93) · Blocks: #635 · Related: #618, #601, #760, fix(mcp): recover clean unpublished author work after the owning session exits (#772)Canonical issue state
Required final evidence
PR with the fix, the regression test that fails on current master, the sibling call-site audit, and full-suite results classified against a clean master baseline.
Required final response and handoff expectations
Brief PR handoff to reviewer, naming #635 as the unblocked consumer.