feat: add first-class stacked PR support to author workflow (Closes #484) #489
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#489
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 #484.
Adds a first-class, proof-backed stacked PR path to the author workflow so
gitea_create_prcan open a PR based on another unmerged PR's branch — without retargeting tomaster(which would entangle the dependency's diff) or bypassing the issue-lock / base-branch gate.Normal master-based safety gates are unchanged: when no stacked base is declared,
gitea_lock_issuestill requires amaster/main/devbase worktree andgitea_create_prstill targets a normal base branch.Motivating case
#482 (stacked on #479 / #478) could not be opened via MCP because the lock required a
master/main/devbase worktree. That PR had to be opened manually. This change makes that flow first-class.Design
stacked_pr_support.py(new, pure): approve a non-master base only when it is explicitly declared AND owned by a live open PR whose number matches; reject arbitrary, mismatched, or stale (merged/closed) bases; require the PR body to document the stack.issue_lock_worktree.py:read_worktree_git_state/_find_matching_base_refgain an opt-inextra_basesarg so an approved stacked base can anchor the base check alongside master/main/dev. Empty by default → behavior unchanged.gitea_mcp_server.py:gitea_lock_issuegainsstacked_base_branch+stacked_base_pr. When declared, it verifies the open PR owns the branch, anchors the base check to it, and recordsapproved_stacked_base = {branch, pr_number, verified_open}on the lock.gitea_create_prvalidates a non-masterbaseagainst the lock's approved stacked base, re-checks the dependency PR is still open, and enforces the stacked-PR body fields. Master-based path untouched.docs/llm-workflow-runbooks.mdandskills/llm-project-workflow/workflows/work-issue.mddocument when stacked PRs are allowed and the required body wording (Stacked on PR #X / issue #Y,Base branch,Head branch,Do not merge before PR #X, retarget-after-land).Constraints honored
master/main/devbase (unchanged).Tests
tests/test_stacked_pr_support.py— 18 policy cases (declaration proof, arbitrary/stale rejection, PR-number mismatch, body-field enforcement, master path unchanged, create-time re-verification).tests/test_issue_lock_worktree.py— stacked base anchoring viaextra_bases(real temp git repo); a non-matching base does not anchor.tests/test_issue_lock_store.py—approved_stacked_basepersistence round-trip.Validation
Run in
branches/issue-484-stacked-pr-support@0cbd1fc:Note: one separate test,
TestMergePR::test_merge_blocked_on_stale_approval_head, fails on pristinemastertoo (verified by stashing this branch's edits) — a pre-existing failure in merge-approval code, out of scope here.Worktree
branches/issue-484-stacked-pr-support@0cbd1fcNormal author work is unchanged: gitea_lock_issue still requires the worktree to be base-equivalent to master/main/dev, and gitea_create_pr still targets a normal base branch. A *stacked* PR (based on another unmerged PR's branch) is a new explicit, proof-backed path — it never bypasses the issue lock. - stacked_pr_support.py: pure policy. Approve a non-master base only when it is declared AND owned by a live OPEN PR whose number matches; reject arbitrary, mismatched, or stale (merged/closed) branches; require the PR body to document the stack (base branch, stacked-on PR, merge ordering). - issue_lock_worktree.py: read_worktree_git_state / _find_matching_base_ref gain an opt-in extra_bases arg so an approved stacked base can anchor base-equivalence in addition to master/main/dev (empty by default = unchanged). - gitea_mcp_server.py: - gitea_lock_issue gains stacked_base_branch + stacked_base_pr. When declared, it verifies the open PR owns the branch, anchors base-equivalence to it, and records approved_stacked_base = {branch, pr_number, verified_open} on the lock. - gitea_create_pr validates a non-master base against the lock's approved stacked base, re-checks the dependency PR is still open, and enforces the stacked-PR body fields. Master-based path untouched. - Docs: llm-workflow-runbooks.md and work-issue.md document when stacked PRs are allowed and the required PR-body wording. Tests: test_stacked_pr_support.py (18 policy cases), stacked base-equivalence in test_issue_lock_worktree.py, approved_stacked_base persistence round-trip in test_issue_lock_store.py. Existing lock/create_pr regressions still pass. The #482 -> #479/#478 case motivates this: create_pr previously could not open a stacked PR because the lock required a master-equivalent worktree. Closes #484. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>repo: Scaled-Tech-Consulting/Gitea-Tools
pr: #489
issue: #484
reviewer_identity: sysadmin
profile: prgs-reviewer
session_id: 96981-2106e7a7d1bf
worktree: /Users/jasonwalker/Development/Gitea-Tools/branches/review-pr489
phase: claimed
candidate_head:
0cbd1fc801target_branch: master
target_branch_sha: none
last_activity: 2026-07-08T06:34:56Z
expires_at: 2026-07-08T08:34:56Z
blocker: none
repo: Scaled-Tech-Consulting/Gitea-Tools
pr: #489
issue: none
reviewer_identity: sysadmin
profile: prgs-reviewer
session_id: 96981-2106e7a7d1bf
worktree: /Users/jasonwalker/Development/Gitea-Tools/branches/review-pr489
phase: claimed
candidate_head:
0cbd1fc801target_branch: master
target_branch_sha: none
last_activity: 2026-07-08T06:38:38Z
expires_at: 2026-07-08T08:38:38Z
blocker: none
APPROVED: PR #489 stacked PR support pure logic, tests, and integration are clean, robust, and fully verified.
repo: Scaled-Tech-Consulting/Gitea-Tools
pr: #489
issue: #484
reviewer_identity: sysadmin
profile: prgs-reviewer
session_id: 96981-2106e7a7d1bf
worktree: /Users/jasonwalker/Development/Gitea-Tools/branches/review-pr489
phase: abandoned
candidate_head:
0cbd1fc801target_branch: master
target_branch_sha: none
last_activity: 2026-07-08T06:39:41Z
expires_at: 2026-07-08T08:39:41Z
blocker: none