fix(author bootstrap): restore missing runtime identity and session helpers #943
Closed
opened 2026-07-26 07:29:45 -05:00 by jcwalker3
·
4 comments
No Branch/Tag Specified
master
fix/issue-987-native-mcp-bootstrap
feat/issue-985-project-scoped-launcher-identity
fix/issue-983-cross-repo-base-ref
feat/issue-980-stale-worker-retirement
fix/issue-975-client-identity-heartbeat
fix/issue-973-cross-repo-canonical-roots
fix/issue-970-safely-resolve-missing-worktrees
fix/issue-969-native-mcp-bootstrap
feat/issue-664-break-glass-restart
feat/issue-708-mcp-namespace-attachment
feat/issue-665-restart-audit
fix/issue-700-durable-walls
fix/issue-704-prevent-env-workspace-bindings
feat/issue-707-cross-project-boundaries
fix/issue-690-review-profile-switch-guard
fix/issue-953-bootstrap-lock-provenance
feat/issue-949-native-fleet-inventory
fix/issue-943-runtime-context-helpers
fix/issue-945-owning-pr-renewal-evidence
fix/issue-941-scope-guard-bootstrap-wiring
docs/issue-930-remote-mcp-coupling-inventory
fix/issue-892-author-bootstrap-deadlock
fix/issue-686-detect-reject-manual-mcp
fix/issue-672-mcp-config-drift
fix/issue-689-deterministic-mcp-namespace
feat/issue-666-concurrent-mcp-restart-tests
feat/issue-659-maintenance-drain-mode
feat/issue-648-notifications-console
fix/issue-670-direct-master-incident
feat/issue-644-console-recovery
feat/issue-650-providers-insights
feat/issue-669-scoped-component-recovery
docs/issue-668-mcp-ha-rolling-restart
feat/issue-667-console-restart-controls
feat/issue-645-linkage-console
feat/issue-643-request-preview-initiate
fix/issue-897-permission-stale-runtime-classification
feat/issue-641-runtime-session-view
feat/issue-663-restart-classes
feat/issue-661-drain-proof-hard-gate
fix/issue-854-semantic-container-exclusion
issue-640
fix/issue-682-starlette-httpx2
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
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
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#943
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 sanctioned
gitea_bootstrap_author_issue_worktreecapability crashes before enteringauthor_issue_bootstrap.bootstrap_author_issue_worktreebecausegitea_mcp_server.pyreferences three undefined helpers:_active_username_active_profile_name_current_session_idThis makes native author issue-worktree bootstrap unusable for every caller, including
dry_run=true.Observed failure
Commissioning was performed against deployed revision:
aab54d4825270f5a5c6f9c1abc1ab09eb4f3e218The sanctioned call used:
Result:
The failure occurs while evaluating arguments around
gitea_mcp_server.py:10235, before the underlying bootstrap function executes.Source inspection found:
_active_username_active_profile_name_current_session_idProvenance
The undefined references were introduced by commit
a942afe, "Implement native author issue worktree bootstrap (#850)."This is separate from #941 and PR #942. PR #942 successfully corrected the bootstrap scope guard: commissioning passed
verify_preflight_purityand advanced beyond the formermissing_issue_worktreerefusal before reaching this latentNameError.Impact
gitea_bootstrap_author_issue_worktreeis unconditionally broken at the deployed revision.Expected behavior
The MCP wrapper must obtain the active username, profile, and session identifier through defined, canonical runtime-context accessors and invoke the underlying bootstrap service successfully.
With
dry_run=true, the capability must:NameError, internal errors, or reliance on undefined globals.Acceptance criteria
gitea_bootstrap_author_issue_worktree(dry_run=true).Related work
[THREAD STATE LEDGER] Issue #943 / PR #944 — implementation delivered, awaiting independent review
What is true now:
f49e781102aab54d4825(verified as the commit parent)What changed:
f49e781102, PR #944 opened, issue #943 moved to status:pr-openWhat is blocked:
Who/what acts next:
f49e781102Canonical Issue State
STATE: Implementation for #943 is complete and delivered as PR #944 at head
f49e781102. Four globals referenced by gitea_bootstrap_author_issue_worktree and defined nowhere are now defined: _active_username, _active_profile_name, _current_session_id, and _author_mutation_block. The fourth was not in the original report and was found by the generalised AST regression test.WHO_IS_NEXT: reviewer
NEXT_ACTION: Review PR #944 against the #943 acceptance criteria with the head pinned to
f49e781102, then post APPROVE or REQUEST_CHANGES from a reviewer namespace.NEXT_PROMPT:
WHAT_HAPPENED: Commissioning #941 against deployed revision
aab54d4825cleared the scope guard PR #942 fixed and then failed with builtins.NameError, name '_active_username' is not defined, while evaluating call arguments at gitea_mcp_server.py:10235. Source inspection found three such globals, each with one reference and no definition, introduced by commita942afeunder #850. Issue #943 was filed. This branch defines all three plus a fourth, _author_mutation_block, on the reviewer-stop refusal path. _active_username reads the immutable #714 session context seeded by gitea_whoami; _active_profile_name prefers the live get_profile with the session context as fallback; _current_session_id mints the same profile-pid-hex shape as the three pre-existing lease call sites, bound once per process; _author_mutation_block returns the uniform refusal shape the other author mutations already use. The diff is 2 files, +534 / -0, with no guard, signature, permission, or role change.WHY: The bootstrap capability was unusable for every caller including dry_run=true, because the NameError fired before the bootstrap service was entered. That left authors with no sanctioned path to an issue-backed worktree and kept issue #931 unable to start through the canonical workflow. The defect was masked until PR #942 removed the scope-guard refusal that preceded it.
RELATED_PRS: PR #944 (open, head
f49e781102, closes #943); PR #942 (merge performed ataab54d4825, closed #941, exposed this defect); PR #926 (merge performed, closed #892)BLOCKERS: no blocker
VALIDATION: New suite pre-fix against unmodified
aab54d48: 20 failed, 13 passed. New suite post-fix: 27 passed, 12 subtests. Targeted suites for 943, 941, 892, author_issue_bootstrap, create_issue_bootstrap, 683, 757, anti_stomp_preflight, root_checkout_guard, 618: 245 passed, 59 subtests. Full suite from the branches worktree: 28 failed, 5552 passed, 6 skipped, 1006 subtests in 151.72s; the 28 are the standing baseline and every one also fails against the unmodified base, verified by failing-test identity rather than by count.LAST_UPDATED_BY: jcwalker3 / prgs-author / gitea-author namespace, session author_issue_work-d1a91a7d2c7d43df, pid 18161
[THREAD STATE LEDGER] Issue #943 / PR #944 — REQUEST_CHANGES posted to Gitea (review 622)
What is true now:
f49e781102aab54d4825(live master, unmoved during review)f49e781102, not dismissed, not staleWhat changed:
What is blocked:
Who/what acts next:
Canonical Issue State
STATE: PR #944 for issue #943 carries one formal REQUEST_CHANGES review (622) from sysadmin at head
f49e781102. Two blocking findings and two lesser findings are open. Three of the four restored helpers are correct; the fourth makes the allocator-driven bootstrap path unusable.WHO_IS_NEXT: author
NEXT_ACTION: Author jcwalker3 must make owner_session resolve to the control-plane session that owns the supplied lease instead of minting a per-process identifier, add a test that supplies assignment_id plus lease_id and asserts the ownership comparison succeeds, unify the identity and profile authorities on one source, narrow the bare exception handler around get_profile, then push and publish a new head-pinned handoff for a fresh independent review.
NEXT_PROMPT:
WHAT_HAPPENED: An independent reviewer read both changed files at the exact head, traced all four previously undefined globals to their data sources and call sites, and drove the real bootstrap service rather than trusting the author's summary. _author_mutation_block, _active_username and _active_profile_name behave correctly in the paths that matter, and the AST-based regression test is sound and is what originally surfaced _author_mutation_block. _current_session_id, however, mints a fresh identifier that can never equal the control-plane session which owns an allocated lease; an isolated temporary control-plane DB reproduced lease_session_mismatch, and the same gate passed when handed the true owner session. The wrapper exposes no session_id parameter, so no caller can supply the correct value. The new test file never supplies assignment_id or lease_id, leaving that path uncovered. Full suites were run at the head and at a clean base checkout: 28 failed / 5552 passed / 1006 subtests versus 28 failed / 5525 passed / 994 subtests, with identical failing test id sets, so the branch causes no regression.
WHY: The tool's purpose is bootstrapping an allocated author issue worktree, and ownership of that allocation is compared by session identifier. A minted identifier cannot match the allocator's session, so the canonical flow stays refused and issue #931 still cannot start through it. Process-lifetime identity also contradicts #790, whose own documentation states the long-lived daemon's process identity proves nothing about task ownership, and contradicts live control-plane data showing several distinct author sessions under a single PID.
RELATED_PRS: PR #944 (open, head
f49e781102, closes #943, review 622 REQUEST_CHANGES); PR #942 (merge performed ataab54d4825, closed #941, exposed the #943 defect); PR #924 (open, #690 cross-profile session invalidation, relevant to finding F3)BLOCKERS: code blocker
VALIDATION: New #943 suite at head: 27 passed, 12 subtests. Targeted bootstrap, guard, session, lease, identity and stale-runtime suites at head: 356 passed, 77 subtests, 0 failed. Full suite at head
f49e7811: 28 failed, 5552 passed, 6 skipped, 1006 subtests in 168.20s. Full suite at clean base checkoutaab54d48: 28 failed, 5525 passed, 6 skipped, 994 subtests in 172.64s. Failing test id sets identical between head and base, so no regression originates from this branch; the extra 27 passes are this PR's new tests. Isolated temporary control-plane DB probe reproduced lease_session_mismatch for the wrapper-minted session and passed for the true owner session.LAST_UPDATED_BY: sysadmin / prgs-reviewer / gitea-reviewer namespace, reviewer lease session 18216-99c21d36dc2b
[THREAD STATE LEDGER]
What is true now
47bfae07d2. approval_at_current_head is true, review_feedback_stale is false, has_blocking_change_requests is false. Review 622 REQUEST_CHANGES at the superseded headf49e781102now reads dismissed and stale. Merge not performed.status:pr-open. PR #944 is open, mergeable, with no conflicts, 11 commits behind live master35ed8a2fcb, and no branch protection or required checks.What changed
_current_session_idis removed entirely, not patched, and the suite asserts it cannot return._resolve_owner_workflow_sessionresolves the owning session through four fail-closed steps, and the wrapper passes it asowner_session. Review 622's own experiment was reproduced over an isolated temporary control-plane database: the canonical allocator path now passes, while the round-1 identifier shape is still refused withlease_session_mismatch. Forged sessions, wrong-role sessions, wrong-profile sessions, allocator identifiers without an establishable session, and non-live leases all fail closed. The minted fallback carries no process identifier, and sequential tasks on one daemon do not share an owner.record_mutation_authoritypairing, with the pinned session context used only for drift detection. Drift is a refusal rather than a blend, which goes beyond what review 622 asked and closes the live #690 / PR #924 window.aab54d4825, all three published SHA-256 digests reproducing byte-identically.What is blocked
recovery_modeandhead_relationcome fromissue_lock_recovery.py, whileno_existing_pr_proofcomes fromissue_lock_adoption.pyand derives from a value passed as the literalTrueat its single call site, so it can never be false. It is a receipt meaning the open-PR check was performed, not an assertion that no PR exists, so the two blocks do not contradict each other semantically. The field name is nonetheless misleading and warrants a follow-up issue againstissue_lock_adoption.py. It is outside PR #944's scope: that file is absent from the diff, and the relevant line ingitea_mcp_server.pyis untouched by this PR.Who/what acts next
47bfae07d2, passingbranch_protection_requires_current_base=falseexplicitly so a behind-but-approved PR does not mis-route toupdate_branch_by_merge, and re-reading live PR state to confirm the approval is still valid at the exact current head before acting.f49e7811.Canonical Issue State
STATE:
Issue #943 is open with
status:pr-open. PR #944 is open at head47bfae07d2and carries review 631, an approved review posted to gitea by sysadmin at that exact head. All four review-622 findings are resolved and independently re-verified. Merge not performed.WHO_IS_NEXT:
merger
NEXT_ACTION:
An independent prgs-merger session must perform a merge assessment for PR #944 pinned to head
47bfae07d2. The reviewer role is complete and the reviewer lease is released.NEXT_PROMPT:
WHAT_HAPPENED:
An independent review was performed at the exact head in a dedicated reviewer worktree, with scope taken from correction comment 17695 rather than the stale PR description. Each review-622 finding was re-tested against the new code over an isolated temporary control-plane database, and the decisive control was that the ownership gate still refuses the exact identifier shape it refused before. Compatibility with the PR #946 owning-PR continuation repair was proven rather than assumed: zero line overlap in the one shared file, a clean merge simulation into live master producing an identical diffstat, and the #945/#946 renewal-continuation suites passing together with the #943 suites on the merged result. Four full-suite runs across four checkouts produced identical failing test identifier sets in both comparisons.
WHY:
The capability exists to bootstrap an allocated author issue worktree, and ownership of that allocation is compared by session identifier. Supplying the session that actually owns the lease, and refusing when it cannot be established, addresses the cause review 622 identified rather than the symptom. Because the gate still refuses the previously refused value, the capability was restored by supplying a correct owner rather than by loosening the comparison, and that distinction is what makes this an approval instead of a further round of changes.
RELATED_PRS:
#944
ISSUE:
#943
HEAD_SHA:
47bfae07d2REVIEW_STATUS:
Review 631, an approved review posted to gitea by sysadmin at head
47bfae07d2.MERGE_READY:
yes
BLOCKERS:
no blocker
VALIDATION:
Full suite at head
47bfae07from a branches/ worktree: 30 failed, 5565 passed, 6 skipped, 1002 subtests in 187.06s. Full suite at a clean base checkoutaab54d48: 30 failed, 5523 passed, 6 skipped, 994 subtests in 181.86s. Full suite on a merge simulation of the head into live master: 30 failed, 5690 passed, 6 skipped, 1042 subtests in 185.88s. Full suite at live master35ed8a2f: 30 failed, 5648 passed, 6 skipped, 1034 subtests in 184.81s. The failing test identifier sets are identical in both comparisons and in both directions, so no failure originates from this branch and merging introduces no failure against live master. Comparison is by identifier and never by count, because the standing baseline has drifted from 28 at review 622 to 30 and moves identically at every revision. Focused suite tests/test_issue_943_runtime_context_helpers.py: 42 passed, 8 subtests. Targeted bootstrap, guard, session, lock, allocator and duplicate-work suites at head: 273 passed, 39 subtests, 0 failed. The same suites plus the #945/#946 renewal-continuation suites on the merged result: 266 passed, 27 subtests, 0 failed. An isolated temporary control-plane database reproduced the canonical allocator path passing and the round-1 identifier shape still being refused. Duplicate-work protections are unweakened. Merge not performed.NATIVE_REVIEW_PROOF:
Native MCP review mutation via gitea_submit_pr_review in the gitea-reviewer namespace, profile prgs-reviewer, identity sysadmin, review id 631, reviewer lease session 56921-a15e047ac4db, pinned to expected_head_sha
47bfae07d2.LAST_UPDATED_BY:
sysadmin / prgs-reviewer / gitea-reviewer namespace, reviewer lease session 56921-a15e047ac4db
server-side mutation ledger:
47bfae07d2.[THREAD STATE LEDGER]
Correction to one line of the mutation ledger in comment 17712. The review verdict, the test evidence and the findings are unaffected.
What is true now
47bfae07d2, with approval_at_current_head true and no blocking change requests. Merge not performed.gitea_assess_reviewer_pr_leasereportsactive_lease: null, and the only control-plane lease in the repository is an unrelated, pre-existing author lease on PR #906 whose owning process is dead.What changed
gitea_release_reviewer_pr_leasecall therefore returnedreleased: falsewith the reason "no active reviewer lease found on PR" rather than performing an explicit release.phase: releasedfor session 56921-a15e047ac4db, so anyone reconciling the lease comment trail should read the expiry rather than expect a release marker.What is blocked
Who/what acts next
47bfae07d2, passingbranch_protection_requires_current_base=falseexplicitly, and re-reading live PR state to confirm the approval is still valid at the exact current head before acting.phase: releasedlease comment as evidence that a reviewer lease is still held; do not adopt or clear the unrelated PR #906 author lease as part of this work; do not touch issue #931; do not run reconciler cleanup for PR #942.Canonical Issue State
STATE:
Issue #943 is open with
status:pr-open. PR #944 is open at head47bfae07d2and carries review 631, an approved review posted to gitea by sysadmin at that exact head. This comment corrects only the lease-disposition line of comment 17712. Merge not performed.WHO_IS_NEXT:
merger
NEXT_ACTION:
Proceed with the independent prgs-merger merge assessment for PR #944 described in comment 17712, pinned to head
47bfae07d2.NEXT_PROMPT:
WHAT_HAPPENED:
After publishing the canonical decision record in comment 17712, the reviewer lease was found to have expired on its own ten-minute timer during the canonical-comment validation retries, so the explicit release call reported that no active lease remained. Comment 17712's mutation ledger had already described the lease as released. This comment records the accurate disposition and confirms the resulting lease state from live evidence.
WHY:
An audit ledger is only useful if each line matches what the control plane actually recorded. A future session reconciling the lease comment trail would look for a release marker that was never written, and could misread its absence as an unreleased or contended lease. Correcting the record costs one comment and removes that ambiguity.
RELATED_PRS:
#944
ISSUE:
#943
HEAD_SHA:
47bfae07d2REVIEW_STATUS:
Review 631, an approved review posted to gitea by sysadmin at head
47bfae07d2. Unchanged by this correction.MERGE_READY:
yes
BLOCKERS:
no blocker
VALIDATION:
gitea_assess_reviewer_pr_leasefor PR #944 reportsactive_lease: null.gitea_list_workflow_leasesreports a single active lease in the repository:lease-6d38e6cb69904976, role author, sessionprgs-author-92989-cd7e0310, on PR #906, freshnessstale_dead_processwithowner_pid_alive: false— unrelated to this review and pre-existing before it began. Reviewer lease comments for session 56921-a15e047ac4db are 17699 (claimed), 17701 and 17703 (reviewing); no release comment exists. All test evidence recorded in comment 17712 stands unchanged.NATIVE_REVIEW_PROOF:
Native MCP review mutation via gitea_submit_pr_review in the gitea-reviewer namespace, profile prgs-reviewer, identity sysadmin, review id 631, pinned to expected_head_sha
47bfae07d2.LAST_UPDATED_BY:
sysadmin / prgs-reviewer / gitea-reviewer namespace
server-side mutation ledger: