Make work allocation complete and dependency-aware #758
Closed
opened 2026-07-19 01:02:51 -05:00 by jcwalker3
·
1 comment
No Branch/Tag Specified
master
feat/issue-615-runtime-mode-enforcement
archive/role-poisoning-dfb5ebd
archive/capability-role-invariants-bc9366c
docs/mcp-stable-control-runtime-policy
fix/issue-695-native-quarantine-v2
chore/issue-681-preserve-review-session-wip
fix/issue-673-remediate-regressions-part2
feat/issue-610-live-remote-parity
feat/issue-503-reviewer-active-worktree
feat/issue-470-preflight-contract
feat/issue-440-lock-recovery
feat/issue-440-branch-recovery
feat/issue-458-queue-fail-closed-copy
feat/issue-400-early-duplicate-work-gate
feat/issue-308-reconcile-inventory-pagination
feat/issue-308-reconcile-pagination-proof
docs/issue-261-agent-temp-artifact-cleanup
feat/issue-262-map-commit-files
fix/infra-stop-conflict-marker-false-positive
feat/issue-139-role-aware-task-routing
feat/issue-188-continuation-selection-wall
feat/issue-189-continuation-mode-proofs
feat/issue-232-refresh-wiki-proof-heads
feat/issue-210-block-workspace-edits
feat/issue-204-exact-issue-lock
docs/issue-80-label-taxonomy
docs/issue-79-safety-boundary-updates
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#758
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
The author allocator can select the wrong or ineligible issue because it truncates the candidate set before ranking and does not parse canonical
Depends:declarations. When the selected issue fails the preview-before-claim check, allocation stops instead of continuing to the next eligible candidate.This makes a supervised hourly author loop repeatedly terminate without producing work even when other eligible issues exist.
Discovered by the first supervised
/gitea-author-loopiteration. Verified against masterbde5c5fb20fbf6aec9cd6b802341c43078921d13.Observed behavior
A result-size parameter changes the winning candidate
Two read-only dry runs of
gitea_allocate_next_work(role=author, apply=false)againstScaled-Tech-Consulting/Gitea-Tools, differing only inlimit:limitcandidate_countBoth returned
outcome: "preview",priority: 20,inventory_source: "gitea_live", an emptyskippedlist, and the identicalreason_selectedof "highest-priority candidate for role 'author'".limitis shaped and documented as a result/diagnostic bound. In practice it changes which candidate wins, not merely how many are reported.A dependency-blocked issue was emitted as eligible
Issue #642 declares its dependencies in the repository's canonical form:
Both #633 and #634 are open. Despite that, #642 was emitted without
dependency_unmet=true, did not appear inskipped, and was selected as the winner in run A.The supervised author loop correctly refused to claim #642 at the preview-before-claim eligibility check. It then had no sanctioned way to request the next eligible candidate during the same iteration, so the iteration ended having performed no work.
Root cause
Two independent defects, plus one consequence of their interaction.
Defect 1 — candidate truncation occurs before ranking
gitea_mcp_server.py:17800-17802fetches the complete open-issue inventory through the paginating helper:gitea_mcp_server.py:17814then discards most of it before any candidate is constructed:limitdefaults to50in the tool signature atgitea_mcp_server.py:18091. Ranking happens later, inallocator_service.sort_candidates(allocator_service.py:244-249).This is therefore not a pagination shortfall. The full inventory is already in memory and is deliberately sliced ahead of ranking, so candidates 51..73 never become
WorkCandidateobjects and cannot win. The equivalent PR-side truncation is atgitea_mcp_server.py:17742.Defect 2 — dependency metadata is not populated for
Depends:syntaxgitea_mcp_server.py:17837-17846recognizes only two lowercase body phrases:The canonical
Depends: #633, #634form matches neither phrase, sodep_unmetstaysFalseand is passed asdependency_unmet=dep_unmetatgitea_mcp_server.py:17857.No live lookup of the referenced issues' states occurs anywhere in this path. Dependency state is inferred purely from substring presence in body text and is never verified against the actual issues.
Consequence — allocation cannot advance past an ineligible winner
Ranking is effectively flat across the ready queue.
gitea_mcp_server.py:17855assigns:Every
status:readyissue therefore ties at 20, andallocator_service.py:244-249breaks ties deterministically by(-priority, kind != "pr", number)— lowest issue number wins among ties. Ordering within the ready queue is thus decided entirely by which issues survived the Defect 1 slice.End to end: the allocator selects a candidate that Defect 2 failed to mark blocked; the preview-before-claim check correctly refuses it; and the allocator exposes no sanctioned way to fall through to the next eligible candidate within the same iteration. The queue terminates rather than advancing.
Impact
Required implementation investigation
gitea_mcp_server.py— allocator candidate-loading helper (issue and PR paths),gitea_allocate_next_worksignature andlimitsemantics.allocator_service.py—WorkCandidate,sort_candidates,allocate_next_work, and the eligibility/preview path.api_get_allpagination conventions, to confirm inventory completeness before ranking.Preferred direction: separate inventory completeness from result presentation. Rank the full candidate set, then apply any display bound to the reported output only. Parse dependency declarations into structured references and resolve their states from live issue data rather than from body substrings.
Acceptance criteria
AC1. Allocation ranks the complete relevant candidate inventory.
AC2. A diagnostic or response limit cannot alter the selected candidate.
AC3. Pagination is completed before ranking, or an incomplete inventory fails closed explicitly.
AC4. Canonical
Depends: #N, #Ndeclarations are parsed into structured dependency references without issue-number special cases.AC5. Dependency state is verified from live issue evidence.
AC6. Unresolved dependencies make a candidate ineligible.
AC7. Unavailable dependency evidence fails closed for that candidate.
AC8. When the first preview candidate is blocked, allocation continues deterministically to the next eligible candidate during the same iteration.
AC9. Dry-run and apply mode use identical inventory, dependency, priority, and selection logic.
AC10. Priority and tie-breaking behavior is explicit and documented. A flat
status:readyscore must not conceal accidental ordering caused by truncation.AC11. Tests use more than 50 candidates and prove selection invariance across result limits.
AC12. Tests cover multiple open dependencies, closed dependencies, unavailable dependency evidence, and next-candidate selection.
AC13. No-mutation dry-run behavior and lock-before-edit safeguards are preserved.
AC14. No production behavior is special-cased for #642, #633, #634, or #605.
Validation expectations
Depends:forms, multiple references, mixed open/closed states, and malformed input.gitea_allocate_next_workend to end.Linkage and ownership boundary
gitea_set_issue_labels. Similar-sounding, but a different tool and a genuine pagination shortfall, whereas Defect 1 here is post-fetch truncation of an already-complete list.Canonical issue state
CTH: Author Handoff
[THREAD STATE LEDGER] Issue #758 / PR #761 — author implementation pushed, awaiting independent review
What is true now:
ad59053cd7854818e65a854818eWhat changed:
854818eand pushedad59053landed on that branch: allocator ranks the complete candidate inventory, and canonical Depends declarations resolve against live issue stateWhat is blocked:
Who/what acts next:
ad59053cd7against AC1-AC14, using the gitea-reviewer namespace and prgs-reviewer profilead59053cd7Canonical Issue State
STATE:
PR-open
WHO_IS_NEXT:
reviewer
NEXT_ACTION:
Independently review PR #761 at head
ad59053cd7against acceptance criteria AC1 through AC14 and post the formal verdict.NEXT_PROMPT:
Review PR #761 in Scaled-Tech-Consulting/Gitea-Tools using the gitea-reviewer namespace and the prgs-reviewer profile. Pin head
ad59053cd7before verifying anything. Check AC1-AC14 of issue #758, in particular that candidate inventory is ranked without pre-ranking truncation, that a result limit cannot change the selected candidate, that canonical Depends declarations resolve from live issue state, and that unavailable dependency evidence fails closed. Confirm the two full-suite failures are pre-existing at master854818eand not caused by this branch. Submit the formal verdict and stop.WHAT_HAPPENED:
A scheduled controller cycle selected #758 for the author phase. The canonical allocator preview was run first and returned issue #644, whose body declares Depends on #633, #636 and #641 — all three still open — which reproduced this issue's Defect 2 live, with candidate_count 50 confirming Defect 1. #758 was locked, implemented on a dedicated branch, checked against the full test suite, pushed, and opened as PR #761.
WHY:
#758 declares no dependencies of its own, carries type:bug with an author-eligible queue label, and owns the loader and selection defects that were preventing correct queue selection. Taking the allocator's own preview instead would have violated the declared dependency order that this issue exists to enforce.
RELATED_DISCUSSION:
none
RELATED_PRS:
BRANCH:
fix/issue-758-allocator-dependency-aware
HEAD_SHA:
ad59053cd7VALIDATION:
Full suite via /opt/homebrew/bin/python3 -m pytest tests/: 3672 passed, 2 failed, 6 skipped, 1 warning, 431 subtests passed. Pre-existing failures test_issue_702_review_findings_f1_f6.py::TestF1RecoveryBeforeTerminalProbe::test_removed_worktree_recovers_before_probe and test_reconciler_supersession_close.py::TestReconcilerSupersessionMcpTool::test_tool_posts_comment_and_closes_superseded_pr_issue were reproduced identically in a detached worktree at unmodified master
854818ebefore commit; neither touches allocator code. Targeted allocator suites: 65 passed.BLOCKERS:
none
LAST_UPDATED_BY:
jcwalker3 / prgs-author / 2026-07-19