fix(test): add pytest.ini to restrict testpaths and ignore worktree branches (#927) #928
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
bug
duplicate
enhancement
help wanted
invalid
question
wontfix
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
Something is not working
This issue or pull request already exists
New feature
Need some help
Something is wrong
More information is needed
This won't be fixed
No labels
Milestone
No items
No Milestone
Projects
Clear projects
No projects
No Assignees
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: Scaled-Tech-Consulting/Gitea-Tools#928
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 #927
repo: Scaled-Tech-Consulting/Gitea-Tools
pr: #928
issue: #927
reviewer_identity: sysadmin
profile: prgs-reviewer
session_id: 18879-0f8bad4ac89d
worktree: /Users/jasonwalker/Development/Gitea-Tools/branches/review-pr928-17dd05e-s2
phase: claimed
candidate_head:
17dd05ec9dtarget_branch: master
target_branch_sha:
c30b381eb2last_activity: 2026-07-27T15:25:44Z
expires_at: 2026-07-27T15:35:44Z
blocker: none
APPROVE — PR #928 at head
17dd05ec9dfc761e199cc31cbc47b4a0c4f5df2bIndependent review by
sysadmin/prgs-reviewer; authorjcwalker3, so independence holds. Validated in a fresh session-owned worktreebranches/review-pr928-17dd05e-s2, detached at exactly this head, clean before and after validation. Merge base7bf4f1258451823a55b36d2157e74f8457165088; targetmasterre-fetched atc30b381eb2756c4ba9cbb2bf7c3f2d6f31b701e7, andgit merge-base --is-ancestorreports the head is not an ancestor, so the already-landed gate does not fire.Scope
One new file, three lines, exactly what #927 prescribed:
No production code touched. No test touched. Nothing else in the diff.
The fix was proven causal, not assumed
A fresh worktree has no
branches/directory, so #927 cannot reproduce there by simply checking out the base — the absence of the error would prove nothing. I therefore built the reproduction explicitly in a separate diagnostic worktree at the merge base (branches/diag-pr928-base-s2, never the validation worktree), planting abranches/fakewt/containing duplicate copies oftests/conftest.py,tests/test_worktrees.py, andtest_mcp_conn.py:Same tree, same decoy, single variable. The error class matches the one #927 reports; the count differs only because I planted one decoy worktree where the real checkout carries dozens.
Why the two risky properties of this change are safe here
Precedence. A new
pytest.initakes highest precedence and would silently override competing pytest configuration. There is none: nopyproject.toml,setup.cfg, ortox.iniexists in the tree, so nothing is displaced.testpaths = testsstops collecting the repo-roottest_mcp_conn.py. That file is named like a test but is a CLI diagnostic — argparsemain(),subprocess.Popen,sys.exit, and notest_-prefixed function orTest-prefixed class anywhere in it. It contributes zero tests, so no coverage is lost. It was in fact one of the modules #927 named as a collection-collision source, andrun-tests.shsimplyexecspython -m pytest "$@", so its behavior improves rather than narrows.Zero effect on the suite
Full suite at head and at the merge base, each in its own
branches/worktree withpwdandgit rev-parse HEADproof captured inside the same command block as its own pytest invocation:Every count matches and the failing ids match by identity, not merely by total. The 28 failures are the standing repository baseline and reproduce unchanged at the base, so none originates here. This change alters which paths pytest walks, and demonstrably not which tests run or pass.
Official validation status:
baseline-equivalent failure accepted. No validation failure was observed in this session beyond the pre-existing baseline. Both worktrees were clean before and after; no file in either was edited.Non-blocking observation
norecursedirsreplaces pytest's defaults rather than extending them, sobuild,dist,node_modules,.tox, and the.*hidden-directory pattern are no longer excluded. The impact is negligible becausetestpaths = testsalready confines default collection totests/, and the explicitbranchesentry still applies when a path is passed on the command line — which is the case that actually mattered for #927. Worth knowing iftestpathsis ever widened.Canonical PR State
STATE: PR #928 is open at head
17dd05ec9dand now carries a formal APPROVE verdict from sysadmin recorded at that exact head. No blocking finding is open. One non-blocking observation is recorded above.WHO_IS_NEXT: merger
NEXT_ACTION: A merger session must merge PR #928 at pinned head
17dd05ec9dafter merge preflight, having confirmed approval_at_current_head remains true.NEXT_PROMPT:
WHAT_HAPPENED: An independent review at the exact head read the entire three-line diff, confirmed no competing pytest configuration exists that the new file could override, and established that the repo-root test_mcp_conn.py excluded by testpaths is a CLI diagnostic contributing zero tests. The fix was proven causal in a separate diagnostic worktree at the merge base by planting duplicate test modules under a branches/ directory, observing the collection error, then writing the PR's exact pytest.ini into the same tree and observing clean collection. The full suite was run at the head and at the merge base in separate worktrees, returning identical pass, fail, skip and subtest counts with identical failing test id sets.
WHY: Issue #927 reports that pytest recurses into branches/, where active worktrees hold duplicate test modules, aborting collection. The change confines default collection to tests/ and excludes branches/, which resolves the reported failure without altering the suite. The two properties that make a new pytest.ini risky in general — overriding existing configuration, and narrowing collection — were each checked and found not to apply here.
ISSUE: #927
HEAD_SHA:
17dd05ec9dREVIEW_STATUS: APPROVE recorded at
17dd05ec9dby sysadminMERGE_READY: yes, subject to merger preflight and sync status at the current head
BLOCKERS: none
VALIDATION: Reviewed in /Users/jasonwalker/Development/Gitea-Tools/branches/review-pr928-17dd05e-s2, created fresh this session, detached at
17dd05ec9d, verified clean by git status --porcelain --untracked-files=all before and after. Target branch master re-fetched from prgs at c30b381eb2756c4ba9cbb2bf7c3f2d6f31b701e7; git merge-base --is-ancestor reports the head is not an ancestor. Diff against merge base7bf4f12584is 1 file, +3/-0, adding pytest.ini only. Absence of competing pytest configuration confirmed by listing the tree for pyproject.toml, setup.cfg and tox.ini, none of which exist. The repo-root test_mcp_conn.py was read in full and contains no test-prefixed function or Test-prefixed class, only argparse main, subprocess spawn and sys.exit, so testpaths exclusion removes zero tests. Causal proof of the fix was obtained in a separate diagnostic worktree branches/diag-pr928-base-s2 at the merge base, never in the validation worktree: with a planted branches/fakewt/ holding duplicate copies of tests/conftest.py, tests/test_worktrees.py and test_mcp_conn.py, collection returned 5533 tests collected with 1 error and Interrupted during collection on ERROR test_mcp_conn.py; after writing the PR's exact three-line pytest.ini into that same tree, collection returned 5521 tests collected with zero errors. Full suite at head: 28 failed, 5487 passed, 6 skipped, 994 subtests in 175.70s. Full suite at the merge base in branches/baseline-pr928-7bf4f12-s2: 28 failed, 5487 passed, 6 skipped, 994 subtests in 177.21s. Failing test id sets were captured from each leg in a command block carrying its own cd, pwd and git rev-parse HEAD, then compared with comm in both directions and found identical, so no regression originates from this branch. No file was edited in the validation or baseline worktree; the decoy files and pytest.ini written into the diagnostic worktree are reported under File edits by reviewer and that worktree is removed at completion. Pushes during validation: none.NATIVE_REVIEW_PROOF: verdict recorded via gitea_submit_pr_review on the native MCP namespace gitea-reviewer, profile prgs-reviewer, identity sysadmin, transport=native_mcp stdio, entrypoint=mcp_server, pid 18879, expected_head_sha
17dd05ec9d, reviewer lease session 18879-0f8bad4ac89d. Every Gitea read and mutation in this review used that same native namespace.LAST_UPDATED_BY: sysadmin / prgs-reviewer / gitea-reviewer namespace, reviewer lease session 18879-0f8bad4ac89d
repo: Scaled-Tech-Consulting/Gitea-Tools
pr: #928
issue: #927
reviewer_identity: sysadmin
profile: prgs-reviewer
session_id: 18879-0f8bad4ac89d
worktree: /Users/jasonwalker/Development/Gitea-Tools/branches/review-pr928-17dd05e-s2
phase: released
candidate_head:
17dd05ec9dtarget_branch: master
target_branch_sha:
c30b381eb2last_activity: 2026-07-27T15:29:43Z
expires_at: 2026-07-27T15:39:43Z
blocker: manual-release
repo: Scaled-Tech-Consulting/Gitea-Tools
pr: #928
issue: #927
reviewer_identity: sysadmin
profile: prgs-merger
session_id: 47587-87b640aebf83
worktree: /Users/jasonwalker/Development/Gitea-Tools
phase: claimed
candidate_head:
17dd05ec9dtarget_branch: master
target_branch_sha:
5fea326988last_activity: 2026-07-27T20:37:55Z
expires_at: 2026-07-27T20:47:55Z
blocker: none
repo: Scaled-Tech-Consulting/Gitea-Tools
pr: #928
issue: #927
reviewer_identity: sysadmin
profile: prgs-merger
session_id: 47587-87b640aebf83
worktree: /Users/jasonwalker/Development/Gitea-Tools
phase: released
candidate_head:
17dd05ec9dtarget_branch: master
target_branch_sha:
5fea326988last_activity: 2026-07-27T20:46:07Z
expires_at: 2026-07-27T20:56:07Z
blocker: post-merge-moot